Remove Numbering System preference if no corresponding locale.

- If locale has no multiple numbering systems, it shall not
   show the locale on list.
 - If there is no locale with numberung system, remove the entry of
   numbering system preference on UI.

Bug: b/274053189
Test: atest passed
Test: Manual test passed
Change-Id: If61c7e233630644e2d6245c5efd75d15d52cf94b
This commit is contained in:
tom hsu
2023-03-20 11:55:00 +08:00
parent fced4027ab
commit 881e8ac556
6 changed files with 136 additions and 14 deletions

View File

@@ -111,8 +111,8 @@ public class NumberingSystemItemControllerTest {
@Test
@UiThreadTest
public void displayPreference_languageOptAndHas2Locale_show2Options() {
LocaleList.setDefault(LocaleList.forLanguageTags("en-US, zh-TW"));
public void displayPreference_languageOptAndHas2LocaleWithSingleNu_showNothing() {
LocaleList.setDefault(LocaleList.forLanguageTags("en-US,zh-TW"));
Bundle bundle = new Bundle();
bundle.putString(RegionalPreferencesEntriesFragment.ARG_KEY_REGIONAL_PREFERENCE,
NumberingSystemItemController.ARG_VALUE_LANGUAGE_SELECT);
@@ -123,13 +123,31 @@ public class NumberingSystemItemControllerTest {
mController.displayPreference(mPreferenceScreen);
assertEquals(LocaleList.getDefault().size(), mPreferenceScreen.getPreferenceCount());
assertEquals(0, mPreferenceScreen.getPreferenceCount());
}
@Test
@UiThreadTest
public void displayPreference_languageOptAndHas2LocaleWithMultiNu_showLocaleWithMultiNuOnly() {
// ar-JO and dz-BT have multiple numbering systems.
LocaleList.setDefault(LocaleList.forLanguageTags("en-US,zh-TW,ar-JO,dz-BT"));
Bundle bundle = new Bundle();
bundle.putString(RegionalPreferencesEntriesFragment.ARG_KEY_REGIONAL_PREFERENCE,
NumberingSystemItemController.ARG_VALUE_LANGUAGE_SELECT);
bundle.putString(
NumberingSystemItemController.KEY_SELECTED_LANGUAGE, Locale.US.toLanguageTag());
mController = new NumberingSystemItemController(mApplicationContext, bundle);
mController.setParentFragment(mFragment);
mController.displayPreference(mPreferenceScreen);
assertEquals(2, mPreferenceScreen.getPreferenceCount());
}
@Test
@UiThreadTest
public void displayPreference_enUsNumbersOpt_show1Option() {
LocaleList.setDefault(LocaleList.forLanguageTags("en-US, zh-TW"));
LocaleList.setDefault(LocaleList.forLanguageTags("en-US,zh-TW"));
Bundle bundle = new Bundle();
bundle.putString(RegionalPreferencesEntriesFragment.ARG_KEY_REGIONAL_PREFERENCE,
NumberingSystemItemController.ARG_VALUE_NUMBERING_SYSTEM_SELECT);