forked from mirrors/Fedilab
Allow to reset language
This commit is contained in:
parent
a632618a66
commit
b158d01311
3 changed files with 24 additions and 1 deletions
|
@ -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,
|
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||||
* see <http://www.gnu.org/licenses>. */
|
* see <http://www.gnu.org/licenses>. */
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
import app.fedilab.android.R;
|
import app.fedilab.android.R;
|
||||||
import app.fedilab.android.helper.Helper;
|
import app.fedilab.android.helper.Helper;
|
||||||
|
@ -31,16 +34,28 @@ public class FragmentLanguageSettings extends PreferenceFragmentCompat implement
|
||||||
createPref();
|
createPref();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ApplySharedPref")
|
||||||
private void createPref() {
|
private void createPref() {
|
||||||
ListPreference SET_DEFAULT_LOCALE_NEW = findPreference(getString(R.string.SET_DEFAULT_LOCALE_NEW));
|
ListPreference SET_DEFAULT_LOCALE_NEW = findPreference(getString(R.string.SET_DEFAULT_LOCALE_NEW));
|
||||||
if (SET_DEFAULT_LOCALE_NEW != null) {
|
if (SET_DEFAULT_LOCALE_NEW != null) {
|
||||||
SET_DEFAULT_LOCALE_NEW.getContext().setTheme(Helper.dialogStyle());
|
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
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
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();
|
requireActivity().recreate();
|
||||||
Helper.recreateMainActivity(requireActivity());
|
Helper.recreateMainActivity(requireActivity());
|
||||||
}
|
}
|
||||||
|
|
|
@ -779,6 +779,7 @@
|
||||||
<string name="SET_FEATURED_TAG_ACTION" translatable="false">SET_FEATURED_TAG_ACTION</string>
|
<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_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">
|
<string-array name="SET_TRANSLATE_ENTRIES" translatable="false">
|
||||||
<item>en</item>
|
<item>en</item>
|
||||||
<item>fr</item>
|
<item>fr</item>
|
||||||
|
@ -978,6 +979,7 @@
|
||||||
<string name="files_cache_size">File cache size</string>
|
<string name="files_cache_size">File cache size</string>
|
||||||
<string name="clear_cache">Clear cache</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="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">
|
<string-array name="photo_editor_emoji" translatable="false">
|
||||||
<!-- Smiles -->
|
<!-- Smiles -->
|
||||||
|
|
|
@ -11,4 +11,10 @@
|
||||||
app:summary="@string/set_push_notifications"
|
app:summary="@string/set_push_notifications"
|
||||||
app:title="@string/set_change_locale"
|
app:title="@string/set_change_locale"
|
||||||
app:useSimpleSummaryProvider="true" />
|
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>
|
</PreferenceScreen>
|
Loading…
Reference in a new issue