Possibility to pick custom language

This commit is contained in:
Jens 2023-02-26 18:12:47 +01:00
parent fd8ffd4f7d
commit e5433bf2ec
18 changed files with 148 additions and 3 deletions

View File

@ -44,6 +44,7 @@ public class ActivityMainPoi extends ActivityGeneric
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(ActivityMainPoi.this);
setContentView(R.layout.main_poi_layout);
instance = this;

View File

@ -40,6 +40,7 @@ public class ActivityMainProfiles extends ActivityGeneric
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(ActivityMainProfiles.this);
setContentView(R.layout.main_profile_layout);
instance = this;

View File

@ -47,7 +47,8 @@ public class ActivityMainRules extends ActivityGeneric
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(ActivityMainRules.this);
setContentView(R.layout.main_rule_layout);
instance = this;

View File

@ -6,9 +6,12 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
@ -31,6 +34,7 @@ import com.jens.automation2.location.LocationProvider;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Locale;
@SuppressLint("NewApi")
public class ActivityMainScreen extends ActivityGeneric
@ -51,6 +55,7 @@ public class ActivityMainScreen extends ActivityGeneric
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Miscellaneous.setDisplayLanguage(ActivityMainScreen.this);
setContentView(R.layout.main_overview_layout);
activityMainScreenInstance = this;

View File

@ -3,12 +3,17 @@ package com.jens.automation2;
import android.annotation.SuppressLint;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import com.jens.automation2.receivers.NfcReceiver;
import java.util.Locale;
@SuppressLint("NewApi")
public class ActivityMainTabLayout extends TabActivity
@ -17,8 +22,8 @@ public class ActivityMainTabLayout extends TabActivity
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Settings.readFromPersistentStorage(ActivityMainTabLayout.this);
Miscellaneous.setDisplayLanguage(ActivityMainTabLayout.this);
if(Settings.tabsPlacement == 1)
setContentView(R.layout.main_tab_layout_tabs_at_bottom);

View File

@ -12,6 +12,8 @@ import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.media.AudioManager;
import android.os.Binder;
import android.os.Build;
@ -20,6 +22,7 @@ import android.os.Environment;
import android.os.IBinder;
import android.speech.tts.TextToSpeech;
import android.speech.tts.TextToSpeech.OnInitListener;
import android.util.DisplayMetrics;
import android.util.Log;
import android.widget.Toast;
@ -127,6 +130,8 @@ public class AutomationService extends Service implements OnInitListener
// Store a reference to myself. Other classes often need a context or something, this can provide that.
centralInstance = this;
Miscellaneous.setDisplayLanguage(AutomationService.this);
}
public boolean checkStartupRequirements(Context context, boolean startAtBoot)

View File

@ -15,6 +15,7 @@ import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
import android.media.AudioAttributes;
import android.media.RingtoneManager;
@ -31,6 +32,7 @@ import android.provider.Settings.Secure;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.util.Base64;
import android.util.DisplayMetrics;
import android.util.Log;
import android.widget.Toast;
@ -1985,4 +1987,20 @@ public class Miscellaneous extends Service
{
return context.getApplicationContext().getApplicationInfo().targetSdkVersion;
}
public static void setDisplayLanguage(Context context)
{
if(!Settings.displayLanguage.equals(Settings.default_displayLanguage))
{
Locale myLocale = new Locale(Settings.displayLanguage);
Resources res = context.getResources();
DisplayMetrics dm = res.getDisplayMetrics();
Configuration conf = res.getConfiguration();
conf.locale = myLocale;
res.updateConfiguration(conf, dm);
//Intent refresh = new Intent(this, AndroidLocalize.class);
//finish();
//startActivity(refresh);
}
}
}

View File

@ -68,6 +68,7 @@ public class Settings implements SharedPreferences
public static boolean showToasts;
public static boolean automaticUpdateCheck;
public static long musicCheckFrequency;
public static String displayLanguage;
public static boolean lockSoundChanges;
public static boolean noticeAndroid9MicrophoneShown;
@ -138,6 +139,7 @@ public class Settings implements SharedPreferences
public static final long default_lastNewsPolltime = -1;
public static final long default_lastUpdateCheck = -1;
public static final long default_musicCheckFrequency = 2500;
public static final String default_displayLanguage = "systemDefaultLanguage";
@Override
public boolean contains(String arg0)
@ -273,6 +275,7 @@ public class Settings implements SharedPreferences
tabsPlacement = Integer.parseInt(prefs.getString("tabsPlacement", String.valueOf(default_tabsPlacement)));
musicCheckFrequency = Long.parseLong(prefs.getString("musicCheckFrequency", String.valueOf(default_musicCheckFrequency)));
displayLanguage = prefs.getString("displayLanguage", default_displayLanguage);
if(Settings.musicCheckFrequency == 0)
Settings.musicCheckFrequency = Settings.default_musicCheckFrequency;
@ -482,6 +485,9 @@ public class Settings implements SharedPreferences
if(!prefs.contains("musicCheckFrequency") || force)
editor.putLong("musicCheckFrequency", default_musicCheckFrequency);
if(!prefs.contains("displayLanguage") || force)
editor.putString("displayLanguage", default_displayLanguage);
if(!prefs.contains("lockSoundChanges") || force)
editor.putBoolean("lockSoundChanges", default_lockSoundChanges);
@ -568,6 +574,8 @@ public class Settings implements SharedPreferences
Settings.musicCheckFrequency = Settings.default_musicCheckFrequency;
editor.putString("musicCheckFrequency", String.valueOf(musicCheckFrequency));
editor.putString("displayLanguage", displayLanguage);
editor.putBoolean("lockSoundChanges", lockSoundChanges);
editor.putBoolean("noticeAndroid9MicrophoneShown", noticeAndroid9MicrophoneShown);
editor.putBoolean("noticeAndroid10WifiShown", noticeAndroid10WifiShown);

View File

@ -59,6 +59,13 @@
android:entries="@array/tabsPlacementOptions"
android:entryValues="@array/tabsPlacementOptionsValues" />
<ListPreference
android:key="displayLanguage"
android:title="@string/displayLanguage"
android:summary="@string/displayLanguageSummary"
android:entries="@array/displayLanguageOptions"
android:entryValues="@array/displayLanguageValues" />
<CheckBoxPreference
android:key="executeRulesAndProfilesWithSingleClick"
android:title="@string/executeRulesAndProfilesWithSingleClickTitle" />

View File

@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="languageSystemDefault">System Standard</string>
<string name="languageEnglish">Englisch</string>
<string name="languageGerman">Deutsch</string>
<string name="languageItalian">Italienisch</string>
<string name="languageSpanish">Spanisch</string>
<string name="languageDutch">Niederländisch</string>
<string name="languageRussian">Russisch</string>
<string name="languageFrench">Französisch</string>
<string name="ruleActivate">Aktiviere Regel %1$s</string>
<string name="profileActivate">Aktiviere Profil %1$s</string>
<string name="ruleActivateToggle">Aktiviere Regel %1$s im Umkehrmodus</string>
@ -780,4 +788,7 @@
<string name="showToastsForEvents">Toasts anzeigen</string>
<string name="showToastsForEventsSummary">Popups anzeigen, wenn Ereignisse wie Regelausführungen auftreten</string>
<string name="notificationAccessAndroid13">Nachdem Sie auf OK geklickt haben, wählen Sie Automatisierung, dann \"Benachrichtigungszugriff zulassen\" und dann \"Zulassen\".</string>
<string name="displayLanguage">Anzeigesprache</string>
<string name="displayLanguageSummary">Bestimmte Anzeigesprache wählen</string>
<string name="displayLanguageSummary">B</string>
</resources>

View File

@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="languageSystemDefault">Predeterminado</string>
<string name="languageEnglish">Inglés</string>
<string name="languageGerman">Alemán</string>
<string name="languageItalian">Italiano</string>
<string name="languageSpanish">Español</string>
<string name="languageDutch">Holandés</string>
<string name="languageRussian">Ruso</string>
<string name="languageFrench">Francés</string>
<string name="ruleActivate">Estoy activando regla %1$s</string>
<string name="profileActivate">Estoy activando perfil %1$s</string>
<string name="ruleActivateToggle">Estoy activando regla %1$s en el modo de invertir</string>
@ -779,4 +787,6 @@
<string name="showToastsForEvents">Mostrar toasts</string>
<string name="showToastsForEventsSummary">Mostrar notificaciones del sistema cuando se producen eventos como ejecuciones de reglas</string>
<string name="notificationAccessAndroid13">Después de hacer clcliquear en OK, seleccione Automation, luego seleccione \"Permitir acceso a notificaciones\", luego \"Permitir\".</string>
<string name="displayLanguage">Idioma de visualización</string>
<string name="displayLanguageSummary">Establecer un idioma personalizado para la aplicación</string>
</resources>

View File

@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="languageSystemDefault">Valeur par défaut du système</string>
<string name="languageEnglish">Anglais</string>
<string name="languageGerman">Allemand</string>
<string name="languageItalian">Italien</string>
<string name="languageSpanish">Espagnol</string>
<string name="languageDutch">Néerlandais</string>
<string name="languageRussian">Russe</string>
<string name="languageFrench">Français</string>
<string name="ruleActivate">Activation de la règle %1$s</string>
<string name="profileActivate">Activation du profil %1$s</string>
<string name="ruleActivateToggle">Activation de la règle %1$s en mode alternatif</string>
@ -779,4 +787,6 @@
<string name="showToastsForEvents">Afficher les toasts</string>
<string name="showToastsForEventsSummary">Afficher les toasts lorsque des événements tels que des exécutions de règles se produisent</string>
<string name="notificationAccessAndroid13">Après avoir cliqué sur OK, sélectionnez Automatisation, puis sélectionnez « Autoriser l\'accès aux notifications », puis « Autoriser ».</string>
<string name="displayLanguage">Langue d\'affichage</string>
<string name="displayLanguageSummary">Définir une langue personnalisée pour l\'application</string>
</resources>

View File

@ -396,6 +396,14 @@
<string name="roaming">Roaming</string>
<string name="rootExplanation">È necessario avere i permessi di root per utilizzare questa funzione. Una volta abilitato l\'accesso root, dovrai \"eseguire la regola manualmente\" per attivare la richiesta di autorizzazione come superuser. Nella finestra di popup di superuser, bisognerà consentire sempre l\'esecuzione dell\'applicazione con questi permessi. In caso contrario, la regola non potrà funzionare quando il telefono è inattivo.</string>
<string name="rule">Regola</string>
<string name="languageSystemDefault">Impostazione predefinita del sistema</string>
<string name="languageEnglish">Inglese</string>
<string name="languageGerman">Tedesco</string>
<string name="languageItalian">Italiano</string>
<string name="languageSpanish">Spagnolo</string>
<string name="languageDutch">Olandese</string>
<string name="languageRussian">Russo</string>
<string name="languageFrench">Francese</string>
<string name="ruleActivate">Attivando la regola %1$s</string>
<string name="ruleActivateToggle">Attivando la regola %1$s in modalità reversibile</string>
<string name="ruleActive">Regola attiva</string>
@ -780,4 +788,6 @@
<string name="showToastsForEvents">Mostra toast</string>
<string name="showToastsForEventsSummary">Mostrare gli avvisi popup quando si verificano eventi come le esecuzioni di regole</string>
<string name="notificationAccessAndroid13">Dopo aver fatto clic su OK, selezionare Automazione, quindi selezionare \"Consenti accesso alle notifiche\", quindi \"Consenti\".</string>
<string name="displayLanguage">Lingua di visualizzazione</string>
<string name="displayLanguageSummary">Set a custom language for the application</string>
</resources>

View File

@ -1,4 +1,12 @@
<resources>
<string name="languageSystemDefault">Systeemstandaard</string>
<string name="languageEnglish">Engels</string>
<string name="languageGerman">Duits</string>
<string name="languageItalian">Italiaans</string>
<string name="languageSpanish">Spaans</string>
<string name="languageDutch">Nederlands</string>
<string name="languageRussian">Russisch</string>
<string name="languageFrench">Frans</string>
<string name="ruleActivate">Activering regel %1$s</string>
<string name="profileActivate">Activeren profiel %1$s</string>
<string name="ruleActivateToggle">Activeren regel %1$s in Togglemode</string>
@ -778,5 +786,7 @@
<string name="showToastsForEvents">Toon toasts</string>
<string name="showToastsForEventsSummary">Pop-ups weergeven wanneer gebeurtenissen zoals regeluitvoeringen plaatsvinden</string>
<string name="notificationAccessAndroid13">Nadat u op OK hebt geklikt, selecteert u Automatisering, selecteert u vervolgens \"Toegang tot meldingen toestaan\" en vervolgens \"toestaan\".</string>
<string name="displayLanguage">Taal weergeven</string>
<string name="displayLanguageSummary">Een aangepaste taal instellen voor de toepassing</string>
</resources>

View File

@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="languageSystemDefault">Системное значение по умолчанию</string>
<string name="languageEnglish">Английский</string>
<string name="languageGerman">Немецкий</string>
<string name="languageItalian">Итальянский</string>
<string name="languageSpanish">Испанский</string>
<string name="languageDutch">Нидерландский</string>
<string name="languageRussian">русский</string>
<string name="languageFrench">Французский</string>
<string name="ruleActivate">Активация правила %1$s</string>
<string name="profileActivate">Активация профиля %1$s</string>
<string name="ruleActivateToggle">Активация правила %1$s в режиме переключения</string>
@ -837,4 +845,6 @@
<string name="showToastsForEvents">Показать тосты</string>
<string name="showToastsForEventsSummary">Отображение всплывающих уведомлений при таких событиях, как выполнение правил</string>
<string name="notificationAccessAndroid13">После нажатия кнопки «ОК» выберите «Автоматизация», затем выберите «Разрешить доступ к уведомлениям», затем «Разрешить».</string>
<string name="displayLanguage">Язык интерфейса</string>
<string name="displayLanguageSummary">Язык интерфейса</string>
</resources>

View File

@ -22,6 +22,28 @@
<item name="3">3</item>
</string-array>
<string-array name="displayLanguageOptions">
<item name="0">@string/languageSystemDefault</item>
<item name="1">@string/languageEnglish</item>
<item name="2">@string/languageGerman</item>
<item name="3">@string/languageItalian</item>
<item name="4">@string/languageSpanish</item>
<item name="5">@string/languageDutch</item>
<item name="6">@string/languageRussian</item>
<item name="7">@string/languageFrench</item>
</string-array>
<string-array name="displayLanguageValues">
<item name="0">systemDefaultLanguage</item>
<item name="1">en</item>
<item name="2">de</item>
<item name="3">it</item>
<item name="4">es</item>
<item name="5">nl</item>
<item name="6">ru</item>
<item name="7">fr</item>
</string-array>
<string-array name="tabsPlacementOptions">
<item name="0">@string/top</item>
<item name="1">@string/bottom</item>
@ -33,4 +55,12 @@
<item name="3">3</item>
</string-array>
<string name="languageSystemDefault">System default</string>
<string name="languageEnglish">English</string>
<string name="languageGerman">German</string>
<string name="languageItalian">Italian</string>
<string name="languageSpanish">Spanish</string>
<string name="languageDutch">Dutch</string>
<string name="languageRussian">Russian</string>
<string name="languageFrench">French</string>
</resources>

View File

@ -877,4 +877,6 @@
<string name="showToastsForEvents">Show toasts</string>
<string name="showToastsForEventsSummary">Show toasts when events like rule executions occur</string>
<string name="notificationAccessAndroid13">After clicking ok, select Automation, then select \"Allow notification access\", then \"allow\".</string>
<string name="displayLanguage">Display language</string>
<string name="displayLanguageSummary">Set a custom language for the application</string>
</resources>

View File

@ -1 +1,2 @@
* Fixed: Editing variable action was not possible
* Fixed: Editing variable action was not possible
* Added: Possibility to pick a custom language in settings