Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 95cc90d

Browse files
keianhzoMortimerGoro
authored andcommitted
Keyboard polishing (#2425)
* Update keyboard domains * Force capitalize initial keyboard letter * Remove hardcoded languages
1 parent 236ed3c commit 95cc90d

15 files changed

+122
-189
lines changed

app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ protected void onCreate(Bundle savedInstanceState) {
212212
// Set a global exception handler as soon as possible
213213
GlobalExceptionHandler.register(this.getApplicationContext());
214214

215-
LocaleUtils.init(this);
215+
LocaleUtils.init();
216216

217217
if (DeviceType.isOculusBuild()) {
218218
workaroundGeckoSigAction();
@@ -225,6 +225,7 @@ protected void onCreate(Bundle savedInstanceState) {
225225
SessionStore.get().setContext(this, extras);
226226
SessionStore.get().initializeServices();
227227
SessionStore.get().initializeStores(this);
228+
SessionStore.get().setLocales(LocaleUtils.getPreferredLocales(this));
228229

229230
// Create broadcast receiver for getting crash messages from crash process
230231
IntentFilter intentFilter = new IntentFilter();

app/src/common/shared/org/mozilla/vrbrowser/browser/SettingsStore.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ public String getVoiceSearchLocale() {
421421
String language = mPrefs.getString(
422422
mContext.getString(R.string.settings_key_voice_search_language), null);
423423
if (language == null) {
424-
return LocaleUtils.getDefaultVoiceSearchLocale(mContext);
424+
return LocaleUtils.getDefaultSupportedLocale();
425425
}
426426
return language;
427427
}
@@ -436,7 +436,7 @@ public String getDisplayLocale() {
436436
String language = mPrefs.getString(
437437
mContext.getString(R.string.settings_key_display_language), null);
438438
if (language == null) {
439-
return LocaleUtils.getDefaultDisplayLocale(mContext);
439+
return LocaleUtils.getDefaultSupportedLocale();
440440
}
441441
return language;
442442
}

app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/GermanKeyboard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ public String getSpaceKeyText(String aComposingText) {
6666

6767
@Override
6868
public String[] getDomains(String... domains) {
69-
return super.getDomains(".de");
69+
return super.getDomains(".de", ".at", ".ch");
7070
}
7171
}

app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/RussianKeyboard.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,4 @@ public Locale getLocale() {
6565
public String getSpaceKeyText(String aComposingText) {
6666
return StringUtils.getStringByLocale(mContext, R.string.settings_language_russian, getLocale());
6767
}
68-
69-
@Override
70-
public String[] getDomains(String... domains) {
71-
return super.getDomains(".ru");
72-
}
7368
}

app/src/common/shared/org/mozilla/vrbrowser/ui/keyboards/SpanishKeyboard.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,4 @@ public Locale getLocale() {
4848
public String getSpaceKeyText(String aComposingText) {
4949
return StringUtils.getStringByLocale(mContext, R.string.settings_language_spanish, getLocale());
5050
}
51-
52-
@Override
53-
public String[] getDomains(String... domains) {
54-
return super.getDomains(".es");
55-
}
5651
}

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/KeyboardWidget.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,17 @@ private void initialize(Context aContext) {
185185

186186
mKeyboards = new ArrayList<>();
187187
mKeyboards.add(new EnglishKeyboard(aContext));
188-
mKeyboards.add(new ItalianKeyboard(aContext));
188+
mKeyboards.add(new ChinesePinyinKeyboard(aContext));
189+
mKeyboards.add(new ChineseZhuyinKeyboard(aContext));
190+
mKeyboards.add(new JapaneseKeyboard(aContext));
189191
mKeyboards.add(new FrenchKeyboard(aContext));
190192
mKeyboards.add(new GermanKeyboard(aContext));
191193
mKeyboards.add(new SpanishKeyboard(aContext));
192194
mKeyboards.add(new RussianKeyboard(aContext));
193-
mKeyboards.add(new ChinesePinyinKeyboard(aContext));
194-
mKeyboards.add(new ChineseZhuyinKeyboard(aContext));
195195
mKeyboards.add(new KoreanKeyboard(aContext));
196-
mKeyboards.add(new JapaneseKeyboard(aContext));
197-
mKeyboards.add(new PolishKeyboard(aContext));
196+
mKeyboards.add(new ItalianKeyboard(aContext));
198197
mKeyboards.add(new DanishKeyboard(aContext));
198+
mKeyboards.add(new PolishKeyboard(aContext));
199199
mKeyboards.add(new NorwegianKeyboard(aContext));
200200
mKeyboards.add(new SwedishKeyboard(aContext));
201201
mKeyboards.add(new FinnishKeyboard(aContext));
@@ -686,7 +686,7 @@ private void handleGlobeClick() {
686686
if (mLanguageSelectorView.getItems() == null || mLanguageSelectorView.getItems().size() == 0) {
687687
ArrayList<KeyboardSelectorView.Item> items = new ArrayList<>();
688688
for (KeyboardInterface keyboard: mKeyboards) {
689-
items.add(new KeyboardSelectorView.Item(keyboard.getKeyboardTitle(), keyboard));
689+
items.add(new KeyboardSelectorView.Item(StringUtils.capitalize(keyboard.getKeyboardTitle()), keyboard));
690690
}
691691
mLanguageSelectorView.setItems(items);
692692
}

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/ContentLanguageOptionsView.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.mozilla.vrbrowser.utils.LocaleUtils;
2626

2727
import java.util.Arrays;
28+
import java.util.Collections;
2829

2930
public class ContentLanguageOptionsView extends SettingsView {
3031

@@ -115,9 +116,9 @@ public void onMoveDown(View view, Language language) {
115116

116117
private void saveCurrentLanguages() {
117118
SettingsStore.getInstance(getContext()).setContentLocales(
118-
LocaleUtils.getLanguageIdsFromList(mPreferredAdapter.getItems()));
119+
LocaleUtils.getLocalesFromLanguages(mPreferredAdapter.getItems()));
119120
SessionStore.get().setLocales(
120-
LocaleUtils.getLanguageIdsFromList(mPreferredAdapter.getItems()));
121+
LocaleUtils.getLocalesFromLanguages(mPreferredAdapter.getItems()));
121122
}
122123

123124
private void refreshLanguages() {
@@ -129,8 +130,8 @@ private void refreshLanguages() {
129130

130131
@Override
131132
protected boolean reset() {
132-
SettingsStore.getInstance(getContext()).setContentLocales(Arrays.asList(LocaleUtils.getSystemLocale()));
133-
SessionStore.get().setLocales(Arrays.asList(LocaleUtils.getSystemLocale()));
133+
SettingsStore.getInstance(getContext()).setContentLocales(Collections.singletonList(LocaleUtils.getSystemLocale()));
134+
SessionStore.get().setLocales(Collections.singletonList(LocaleUtils.getSystemLocale()));
134135
LocaleUtils.resetLanguages();
135136
refreshLanguages();
136137

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/DisplayLanguageOptionsView.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,30 @@ private void initialize(Context aContext) {
4848
// Footer
4949
mBinding.footerLayout.setFooterButtonClickListener(mResetListener);
5050

51-
String language = LocaleUtils.getDisplayLocale(getContext());
51+
mBinding.languageRadio.setOptions(LocaleUtils.getSupportedLocalizedLanguages(getContext()));
52+
53+
String locale = LocaleUtils.getDisplayLocale(getContext());
5254
mBinding.languageRadio.setOnCheckedChangeListener(mLanguageListener);
53-
setLanguage(mBinding.languageRadio.getIdForValue(language), false);
55+
setLanguage(LocaleUtils.getIndexForSupportedLocale(locale), false);
5456
}
5557

5658
@Override
5759
protected boolean reset() {
5860
String systemLocale = LocaleUtils.getSystemLocale();
5961
String currentLocale = LocaleUtils.getCurrentLocale();
6062
if (!currentLocale.equalsIgnoreCase(systemLocale)) {
61-
setLanguage(mBinding.languageRadio.getIdForValue(systemLocale), true);
63+
setLanguage(LocaleUtils.getIndexForSupportedLocale(systemLocale), true);
6264
return true;
6365

6466
} else {
65-
setLanguage(mBinding.languageRadio.getIdForValue(systemLocale), false);
67+
setLanguage(LocaleUtils.getIndexForSupportedLocale(systemLocale), false);
6668
return false;
6769
}
6870
}
6971

7072
private RadioGroupSetting.OnCheckedChangeListener mLanguageListener = (radioGroup, checkedId, doApply) -> {
7173
String currentLocale = LocaleUtils.getCurrentLocale();
72-
String locale = mBinding.languageRadio.getValueForId(mBinding.languageRadio.getCheckedRadioButtonId()).toString();
74+
String locale = LocaleUtils.getSupportedLocaleForIndex(mBinding.languageRadio.getCheckedRadioButtonId());
7375

7476
if (!locale.equalsIgnoreCase(currentLocale)) {
7577
setLanguage(checkedId, true);
@@ -86,8 +88,8 @@ private void setLanguage(int checkedId, boolean doApply) {
8688
mBinding.languageRadio.setOnCheckedChangeListener(mLanguageListener);
8789

8890
if (doApply) {
89-
String language = mBinding.languageRadio.getValueForId(checkedId).toString();
90-
LocaleUtils.setDisplayLocale(getContext(), language);
91+
String locale = LocaleUtils.getSupportedLocaleForIndex(checkedId);
92+
LocaleUtils.setDisplayLocale(getContext(), locale);
9193

9294
if (mDelegate != null) {
9395
mDelegate.showRestartDialog();

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/LanguageOptionsView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected void onDismiss() {
9292
};
9393

9494
private void setVoiceLanguage() {
95-
mBinding.voiceSearchLanguageDescription.setText(getSpannedLanguageText(LocaleUtils.getVoiceSearchLanguageString(getContext())), TextView.BufferType.SPANNABLE);
95+
mBinding.voiceSearchLanguageDescription.setText(getSpannedLanguageText(LocaleUtils.getVoiceSearchLanguage(getContext())), TextView.BufferType.SPANNABLE);
9696
}
9797

9898
private void setContentLanguage() {
@@ -105,7 +105,7 @@ private void setContentLanguage() {
105105
}
106106

107107
private void setDisplayLanguage() {
108-
mBinding.displayLanguageDescription.setText(getSpannedLanguageText(LocaleUtils.getDisplayCurrentLanguageString()));
108+
mBinding.displayLanguageDescription.setText(getSpannedLanguageText(LocaleUtils.getDisplayLanguage()));
109109
}
110110

111111
private int getLanguageIndex(@NonNull String text) {

app/src/common/shared/org/mozilla/vrbrowser/ui/widgets/settings/VoiceSearchLanguageOptionsView.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,18 @@ private void initialize(Context aContext) {
4848
// Footer
4949
mBinding.footerLayout.setFooterButtonClickListener(mResetListener);
5050

51-
String language = LocaleUtils.getVoiceSearchLocale(getContext());
51+
mBinding.languageRadio.setOptions(LocaleUtils.getSupportedLocalizedLanguages(getContext()));
52+
53+
String locale = LocaleUtils.getVoiceSearchLocale(getContext());
5254
mBinding.languageRadio.setOnCheckedChangeListener(mLanguageListener);
53-
setLanguage(mBinding.languageRadio.getIdForValue(language), false);
55+
setLanguage(LocaleUtils.getIndexForSupportedLocale(locale), false);
5456
}
5557

5658
@Override
5759
protected boolean reset() {
58-
String value = mBinding.languageRadio.getValueForId(mBinding.languageRadio.getCheckedRadioButtonId()).toString();
60+
String value = LocaleUtils.getSupportedLocaleForIndex(mBinding.languageRadio.getCheckedRadioButtonId());
5961
if (!value.equals(LocaleUtils.getSystemLocale())) {
60-
setLanguage(mBinding.languageRadio.getIdForValue(LocaleUtils.getSystemLocale()), true);
62+
setLanguage(LocaleUtils.getIndexForSupportedLocale(LocaleUtils.getSystemLocale()), true);
6163
}
6264

6365
return false;
@@ -76,7 +78,7 @@ private void setLanguage(int checkedId, boolean doApply) {
7678
mBinding.languageRadio.setChecked(checkedId, doApply);
7779
mBinding.languageRadio.setOnCheckedChangeListener(mLanguageListener);
7880

79-
LocaleUtils.setVoiceSearchLocale(getContext(), mBinding.languageRadio.getValueForId(checkedId).toString());
81+
LocaleUtils.setVoiceSearchLocale(getContext(), LocaleUtils.getSupportedLocaleForIndex(checkedId));
8082
}
8183

8284
@Override

0 commit comments

Comments
 (0)