mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-05 22:30:12 +00:00
fix small bugs in secondary locale settings
This commit is contained in:
parent
99260a0aa8
commit
115d0f8120
1 changed files with 5 additions and 10 deletions
|
@ -19,7 +19,6 @@ package org.dslul.openboard.inputmethod.latin.settings;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
|
@ -42,7 +41,6 @@ import java.util.Set;
|
||||||
|
|
||||||
public final class SecondaryLocaleSettingsFragment extends SubScreenFragment {
|
public final class SecondaryLocaleSettingsFragment extends SubScreenFragment {
|
||||||
private RichInputMethodManager mRichImm;
|
private RichInputMethodManager mRichImm;
|
||||||
private SharedPreferences mPrefs;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(final Bundle savedInstanceState) {
|
public void onCreate(final Bundle savedInstanceState) {
|
||||||
|
@ -54,6 +52,7 @@ public final class SecondaryLocaleSettingsFragment extends SubScreenFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetKeyboardLocales() {
|
private void resetKeyboardLocales() {
|
||||||
|
mRichImm.refreshSubtypeCaches();
|
||||||
getPreferenceScreen().removeAll();
|
getPreferenceScreen().removeAll();
|
||||||
final Context context = getActivity();
|
final Context context = getActivity();
|
||||||
List<InputMethodSubtype> subtypes = mRichImm.getMyEnabledInputMethodSubtypeList(false);
|
List<InputMethodSubtype> subtypes = mRichImm.getMyEnabledInputMethodSubtypeList(false);
|
||||||
|
@ -78,11 +77,6 @@ public final class SecondaryLocaleSettingsFragment extends SubScreenFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSecondaryLocaleDialog(String mainLocale, boolean asciiCapable) {
|
private void showSecondaryLocaleDialog(String mainLocale, boolean asciiCapable) {
|
||||||
final SettingsValues settingsValues = Settings.getInstance().getCurrent();
|
|
||||||
// TODO: does this really return latin for persian? might need that huge map from somewhere github
|
|
||||||
// or maybe extend the script map, also with exception for sr_ZZ
|
|
||||||
// but: could this break other things?
|
|
||||||
|
|
||||||
final List<String> locales = new ArrayList<>(getAvailableDictionaryLocales(mainLocale, asciiCapable));
|
final List<String> locales = new ArrayList<>(getAvailableDictionaryLocales(mainLocale, asciiCapable));
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(
|
final AlertDialog.Builder builder = new AlertDialog.Builder(
|
||||||
DialogUtils.getPlatformDialogThemeContext(getActivity()))
|
DialogUtils.getPlatformDialogThemeContext(getActivity()))
|
||||||
|
@ -98,13 +92,14 @@ public final class SecondaryLocaleSettingsFragment extends SubScreenFragment {
|
||||||
// add "no secondary language" option
|
// add "no secondary language" option
|
||||||
locales.add(getResources().getString(R.string.secondary_locale_none));
|
locales.add(getResources().getString(R.string.secondary_locale_none));
|
||||||
|
|
||||||
|
final Locale displayLocale = getResources().getConfiguration().locale;
|
||||||
final CharSequence[] titles = locales.toArray(new CharSequence[0]);
|
final CharSequence[] titles = locales.toArray(new CharSequence[0]);
|
||||||
for (int i = 0; i < titles.length - 1 ; i++) {
|
for (int i = 0; i < titles.length - 1 ; i++) {
|
||||||
final Locale loc = LocaleUtils.constructLocaleFromString(titles[i].toString());
|
final Locale loc = LocaleUtils.constructLocaleFromString(titles[i].toString());
|
||||||
titles[i] = loc.getDisplayLanguage(settingsValues.mLocale);
|
titles[i] = loc.getDisplayLanguage(displayLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
Locale currentSecondaryLocale = settingsValues.mSecondaryLocale;
|
Locale currentSecondaryLocale = Settings.getSecondaryLocale(getSharedPreferences(), mainLocale);
|
||||||
int checkedItem;
|
int checkedItem;
|
||||||
if (currentSecondaryLocale == null)
|
if (currentSecondaryLocale == null)
|
||||||
checkedItem = locales.size() - 1;
|
checkedItem = locales.size() - 1;
|
||||||
|
@ -130,7 +125,6 @@ public final class SecondaryLocaleSettingsFragment extends SubScreenFragment {
|
||||||
if (!updated)
|
if (!updated)
|
||||||
encodedLocales.add(mainLocale + "§" + locale);
|
encodedLocales.add(mainLocale + "§" + locale);
|
||||||
getSharedPreferences().edit().putStringSet(Settings.PREF_SECONDARY_LOCALES, encodedLocales).apply();
|
getSharedPreferences().edit().putStringSet(Settings.PREF_SECONDARY_LOCALES, encodedLocales).apply();
|
||||||
// getSharedPreferences().edit().putString(Settings.PREF_SECONDARY_LOCALE, locale).apply();
|
|
||||||
final Intent newDictBroadcast = new Intent(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION);
|
final Intent newDictBroadcast = new Intent(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION);
|
||||||
getActivity().sendBroadcast(newDictBroadcast);
|
getActivity().sendBroadcast(newDictBroadcast);
|
||||||
resetKeyboardLocales();
|
resetKeyboardLocales();
|
||||||
|
@ -147,6 +141,7 @@ public final class SecondaryLocaleSettingsFragment extends SubScreenFragment {
|
||||||
mainScript = ScriptUtils.SCRIPT_LATIN;
|
mainScript = ScriptUtils.SCRIPT_LATIN;
|
||||||
else
|
else
|
||||||
mainScript = ScriptUtils.getScriptFromSpellCheckerLocale(mainL);
|
mainScript = ScriptUtils.getScriptFromSpellCheckerLocale(mainL);
|
||||||
|
// TODO: does this really return latin for persian? might need that huge map from somewhere github
|
||||||
|
|
||||||
final Set<String> locales = new HashSet<>();
|
final Set<String> locales = new HashSet<>();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue