diff --git a/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java b/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java index e2331174..0ff66e29 100644 --- a/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java +++ b/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java @@ -4,11 +4,13 @@ import android.app.AlertDialog; import android.content.Intent; import android.content.pm.PackageManager; import android.os.AsyncTask; +import android.os.Build; import android.os.Bundle; import android.preference.CheckBoxPreference; import android.preference.EditTextPreference; import android.preference.ListPreference; import android.preference.Preference; +import android.preference.PreferenceCategory; import android.preference.PreferenceFragment; import android.preference.PreferenceScreen; import android.util.Log; @@ -106,14 +108,19 @@ public class SettingsActivity extends SyncthingActivity { mSyncOnlyOnSSIDs.setEnabled(mSyncOnlyWifi.isChecked()); ListPreference languagePref = (ListPreference) findPreference(Languages.PREFERENCE_LANGUAGE); - Languages languages = new Languages(getActivity()); - languagePref.setDefaultValue(Languages.USE_SYSTEM_DEFAULT); - languagePref.setEntries(languages.getAllNames()); - languagePref.setEntryValues(languages.getSupportedLocales()); - languagePref.setOnPreferenceChangeListener((p, o) -> { - languages.forceChangeLanguage(getActivity(), (String) o); - return false; - }); + if (Build.VERSION.SDK_INT >= 24) { + PreferenceScreen category = (PreferenceScreen) findPreference("category_behaviour"); + category.removePreference(languagePref); + } else { + Languages languages = new Languages(getActivity()); + languagePref.setDefaultValue(Languages.USE_SYSTEM_DEFAULT); + languagePref.setEntries(languages.getAllNames()); + languagePref.setEntryValues(languages.getSupportedLocales()); + languagePref.setOnPreferenceChangeListener((p, o) -> { + languages.forceChangeLanguage(getActivity(), (String) o); + return false; + }); + } mDeviceName = (EditTextPreference) findPreference("deviceName"); mListenAddresses = (EditTextPreference) findPreference("listenAddresses"); diff --git a/src/main/java/com/nutomic/syncthingandroid/util/Languages.java b/src/main/java/com/nutomic/syncthingandroid/util/Languages.java index 41e1a56e..4490436f 100644 --- a/src/main/java/com/nutomic/syncthingandroid/util/Languages.java +++ b/src/main/java/com/nutomic/syncthingandroid/util/Languages.java @@ -68,11 +68,6 @@ public final class Languages { */ @TargetApi(17) public void setLanguage(Context context) { - if (Build.VERSION.SDK_INT >= 24) { - Log.d(TAG, "Languages.setLanguage() ignored on >= android-24"); - mPreferences.edit().remove(PREFERENCE_LANGUAGE).apply(); - return; - } String language = mPreferences.getString(PREFERENCE_LANGUAGE, null); Locale locale; if (TextUtils.equals(language, DEFAULT_LOCALE.getLanguage())) { @@ -111,10 +106,6 @@ public final class Languages { public void forceChangeLanguage(Activity activity, String newLanguage) { mPreferences.edit().putString(PREFERENCE_LANGUAGE, newLanguage).commit(); setLanguage(activity); - if (Build.VERSION.SDK_INT >= 24) { - Log.d(TAG, "Languages.forceChangeLanguage() ignored on >= android-24"); - return; - } Intent intent = activity.getIntent(); if (intent == null) { // when launched as LAUNCHER return; diff --git a/src/main/res/xml/app_settings.xml b/src/main/res/xml/app_settings.xml index 59d75e13..606a06ca 100644 --- a/src/main/res/xml/app_settings.xml +++ b/src/main/res/xml/app_settings.xml @@ -33,6 +33,7 @@