diff --git a/F-Droid/AndroidManifest.xml b/F-Droid/AndroidManifest.xml index 2ea40fb35..ee95c711f 100644 --- a/F-Droid/AndroidManifest.xml +++ b/F-Droid/AndroidManifest.xml @@ -91,7 +91,7 @@ + android:configChanges="layoutDirection|locale|keyboardHidden|orientation|screenSize" > @@ -300,7 +300,8 @@ + android:parentActivityName=".FDroid" + android:configChanges="layoutDirection|locale" > @@ -309,7 +310,8 @@ android:name=".views.ManageReposActivity" android:label="@string/app_name" android:launchMode="singleTask" - android:parentActivityName=".FDroid" > + android:parentActivityName=".FDroid" + android:configChanges="layoutDirection|locale" > @@ -323,12 +325,14 @@ + android:noHistory="true" + android:configChanges="layoutDirection|locale" /> + android:windowSoftInputMode="stateHidden" + android:configChanges="layoutDirection|locale" > @@ -338,7 +342,8 @@ android:name=".AppDetails" android:label="@string/app_details" android:exported="true" - android:parentActivityName=".FDroid" > + android:parentActivityName=".FDroid" + android:configChanges="layoutDirection|locale" > @@ -378,7 +383,8 @@ android:label="@string/search_results" android:exported="true" android:launchMode="singleTop" - android:parentActivityName=".FDroid" > + android:parentActivityName=".FDroid" + android:configChanges="layoutDirection|locale" > diff --git a/F-Droid/src/org/fdroid/fdroid/FDroidApp.java b/F-Droid/src/org/fdroid/fdroid/FDroidApp.java index ba2f048f8..64fb48d4c 100644 --- a/F-Droid/src/org/fdroid/fdroid/FDroidApp.java +++ b/F-Droid/src/org/fdroid/fdroid/FDroidApp.java @@ -66,6 +66,8 @@ public class FDroidApp extends Application { private static final String TAG = "FDroidApp"; + private static Locale locale = null; + // for the local repo on this device, all static since there is only one public static int port; public static String ipAddressString; @@ -145,18 +147,25 @@ public class FDroidApp extends Application { bssid = ""; } - public static void updateLanguage(Context c) { - SharedPreferences prefs = PreferenceManager - .getDefaultSharedPreferences(c); + public void updateLanguage() { + Context ctx = getBaseContext(); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); String lang = prefs.getString("language", ""); - updateLanguage(c, lang); + locale = Utils.getLocaleFromAndroidLangTag(lang); + applyLanguage(); } - public static void updateLanguage(Context c, String lang) { - final Configuration cfg = new Configuration(); - final Locale newLocale = Utils.getLocaleFromAndroidLangTag(lang); - cfg.locale = newLocale == null ? Locale.getDefault() : newLocale; - c.getResources().updateConfiguration(cfg, null); + private void applyLanguage() { + Context ctx = getBaseContext(); + Configuration cfg = new Configuration(); + cfg.locale = locale == null ? Locale.getDefault() : locale; + ctx.getResources().updateConfiguration(cfg, null); + } + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + applyLanguage(); } @TargetApi(9) @@ -172,7 +181,7 @@ public class FDroidApp extends Application { .penaltyLog() .build()); } - updateLanguage(this); + updateLanguage(); super.onCreate(); // Needs to be setup before anything else tries to access it. diff --git a/F-Droid/src/org/fdroid/fdroid/views/fragments/PreferencesFragment.java b/F-Droid/src/org/fdroid/fdroid/views/fragments/PreferencesFragment.java index 2365e169c..478a24456 100644 --- a/F-Droid/src/org/fdroid/fdroid/views/fragments/PreferencesFragment.java +++ b/F-Droid/src/org/fdroid/fdroid/views/fragments/PreferencesFragment.java @@ -1,5 +1,6 @@ package org.fdroid.fdroid.views.fragments; +import android.app.Activity; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; @@ -130,8 +131,9 @@ public class PreferencesFragment extends PreferenceFragment entrySummary(key); if (changing) { result |= PreferencesActivity.RESULT_RESTART; - getActivity().setResult(result); - FDroidApp.updateLanguage(this.getActivity()); + Activity activity = getActivity(); + activity.setResult(result); + ((FDroidApp) activity.getApplication()).updateLanguage(); } break;