Loading app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentLanguageSettings.java +16 −1 Original line number Diff line number Diff line Loading @@ -14,11 +14,14 @@ package app.fedilab.android.ui.fragment.settings; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see <http://www.gnu.org/licenses>. */ import android.annotation.SuppressLint; import android.content.SharedPreferences; import android.os.Bundle; import androidx.preference.ListPreference; import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceManager; import app.fedilab.android.R; import app.fedilab.android.helper.Helper; Loading @@ -31,16 +34,28 @@ public class FragmentLanguageSettings extends PreferenceFragmentCompat implement createPref(); } @SuppressLint("ApplySharedPref") private void createPref() { ListPreference SET_DEFAULT_LOCALE_NEW = findPreference(getString(R.string.SET_DEFAULT_LOCALE_NEW)); if (SET_DEFAULT_LOCALE_NEW != null) { SET_DEFAULT_LOCALE_NEW.getContext().setTheme(Helper.dialogStyle()); } Preference SET_TRANSLATE_VALUES_RESET = findPreference(getString(R.string.SET_TRANSLATE_VALUES_RESET)); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); if (SET_TRANSLATE_VALUES_RESET != null) { SET_TRANSLATE_VALUES_RESET.setOnPreferenceClickListener(preference -> { SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString(getString(R.string.SET_DEFAULT_LOCALE_NEW), null); editor.commit(); return true; }); } } @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.compareToIgnoreCase(getString(R.string.SET_DEFAULT_LOCALE_NEW)) == 0) { if (key.compareToIgnoreCase(getString(R.string.SET_DEFAULT_LOCALE_NEW)) == 0 || key.compareToIgnoreCase(getString(R.string.SET_TRANSLATE_VALUES_RESET)) == 0) { requireActivity().recreate(); Helper.recreateMainActivity(requireActivity()); } Loading app/src/main/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -779,6 +779,7 @@ <string name="SET_FEATURED_TAG_ACTION" translatable="false">SET_FEATURED_TAG_ACTION</string> <string name="SET_RETRIEVE_METADATA_IF_URL_FROM_EXTERAL" translatable="false">SET_RETRIEVE_METADATA_IF_URL_FROM_EXTERAL</string> <string name="SET_TRANSLATE_VALUES_RESET" translatable="false">SET_TRANSLATE_VALUES_RESET</string> <string-array name="SET_TRANSLATE_ENTRIES" translatable="false"> <item>en</item> <item>fr</item> Loading Loading @@ -978,6 +979,7 @@ <string name="files_cache_size">File cache size</string> <string name="clear_cache">Clear cache</string> <string name="delete_cache_message">Are you sure you want to delete cache? If you have drafts with media, the attached media will be lost.</string> <string name="default_system_language">Use the default system language</string> <string-array name="photo_editor_emoji" translatable="false"> <!-- Smiles --> Loading app/src/main/res/xml/pref_language.xml +6 −0 Original line number Diff line number Diff line Loading @@ -11,4 +11,10 @@ app:summary="@string/set_push_notifications" app:title="@string/set_change_locale" app:useSimpleSummaryProvider="true" /> <Preference android:key="@string/SET_TRANSLATE_VALUES_RESET" android:summary="@string/default_system_language" android:title="@string/reset" app:iconSpaceReserved="false" /> </PreferenceScreen> No newline at end of file Loading
app/src/main/java/app/fedilab/android/ui/fragment/settings/FragmentLanguageSettings.java +16 −1 Original line number Diff line number Diff line Loading @@ -14,11 +14,14 @@ package app.fedilab.android.ui.fragment.settings; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see <http://www.gnu.org/licenses>. */ import android.annotation.SuppressLint; import android.content.SharedPreferences; import android.os.Bundle; import androidx.preference.ListPreference; import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; import androidx.preference.PreferenceManager; import app.fedilab.android.R; import app.fedilab.android.helper.Helper; Loading @@ -31,16 +34,28 @@ public class FragmentLanguageSettings extends PreferenceFragmentCompat implement createPref(); } @SuppressLint("ApplySharedPref") private void createPref() { ListPreference SET_DEFAULT_LOCALE_NEW = findPreference(getString(R.string.SET_DEFAULT_LOCALE_NEW)); if (SET_DEFAULT_LOCALE_NEW != null) { SET_DEFAULT_LOCALE_NEW.getContext().setTheme(Helper.dialogStyle()); } Preference SET_TRANSLATE_VALUES_RESET = findPreference(getString(R.string.SET_TRANSLATE_VALUES_RESET)); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity()); if (SET_TRANSLATE_VALUES_RESET != null) { SET_TRANSLATE_VALUES_RESET.setOnPreferenceClickListener(preference -> { SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putString(getString(R.string.SET_DEFAULT_LOCALE_NEW), null); editor.commit(); return true; }); } } @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { if (key.compareToIgnoreCase(getString(R.string.SET_DEFAULT_LOCALE_NEW)) == 0) { if (key.compareToIgnoreCase(getString(R.string.SET_DEFAULT_LOCALE_NEW)) == 0 || key.compareToIgnoreCase(getString(R.string.SET_TRANSLATE_VALUES_RESET)) == 0) { requireActivity().recreate(); Helper.recreateMainActivity(requireActivity()); } Loading
app/src/main/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -779,6 +779,7 @@ <string name="SET_FEATURED_TAG_ACTION" translatable="false">SET_FEATURED_TAG_ACTION</string> <string name="SET_RETRIEVE_METADATA_IF_URL_FROM_EXTERAL" translatable="false">SET_RETRIEVE_METADATA_IF_URL_FROM_EXTERAL</string> <string name="SET_TRANSLATE_VALUES_RESET" translatable="false">SET_TRANSLATE_VALUES_RESET</string> <string-array name="SET_TRANSLATE_ENTRIES" translatable="false"> <item>en</item> <item>fr</item> Loading Loading @@ -978,6 +979,7 @@ <string name="files_cache_size">File cache size</string> <string name="clear_cache">Clear cache</string> <string name="delete_cache_message">Are you sure you want to delete cache? If you have drafts with media, the attached media will be lost.</string> <string name="default_system_language">Use the default system language</string> <string-array name="photo_editor_emoji" translatable="false"> <!-- Smiles --> Loading
app/src/main/res/xml/pref_language.xml +6 −0 Original line number Diff line number Diff line Loading @@ -11,4 +11,10 @@ app:summary="@string/set_push_notifications" app:title="@string/set_change_locale" app:useSimpleSummaryProvider="true" /> <Preference android:key="@string/SET_TRANSLATE_VALUES_RESET" android:summary="@string/default_system_language" android:title="@string/reset" app:iconSpaceReserved="false" /> </PreferenceScreen> No newline at end of file