Improve dialog popup
1. Disable dialog when the sys language doesn't change 2. Associate region with system locale Bug: 402600866 Test: atest LocaleListEditTest Flag: EXEMPT bugfix Change-Id: I2c7ddbf89b6caa02a35e247ebe97086f5880adee
This commit is contained in:
@@ -529,7 +529,11 @@ public class LocaleListEditor extends RestrictedSettingsFragment implements View
|
||||
@Nullable Locale defaultLocaleBeforeRemoval) {
|
||||
Locale currentSystemLocale = LocalePicker.getLocales().get(0);
|
||||
if (!localeInfo.getLocale().equals(currentSystemLocale)) {
|
||||
displayDialogFragment(localeInfo, true);
|
||||
if (Locale.getDefault().equals(localeInfo.getLocale())) {
|
||||
mAdapter.doTheUpdate();
|
||||
} else {
|
||||
displayDialogFragment(localeInfo, true);
|
||||
}
|
||||
} else {
|
||||
if (!localeInfo.isTranslated()) {
|
||||
if (defaultLocaleBeforeRemoval == null) {
|
||||
|
@@ -18,7 +18,6 @@ package com.android.settings.regionalpreferences;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.LocaleList;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -92,7 +91,7 @@ public abstract class RegionPickerBaseListPreferenceController extends BasePrefe
|
||||
? getSuggestedLocaleList()
|
||||
: getSupportedLocaleList();
|
||||
if (getPreferenceCategoryKey().contains(KEY_SUGGESTED)) {
|
||||
Locale systemLocale = LocaleList.getDefault().get(0);
|
||||
Locale systemLocale = Locale.getDefault();
|
||||
LocaleStore.LocaleInfo localeInfo = LocaleStore.getLocaleInfo(systemLocale);
|
||||
result.add(localeInfo);
|
||||
}
|
||||
@@ -106,7 +105,7 @@ public abstract class RegionPickerBaseListPreferenceController extends BasePrefe
|
||||
mPreferenceCategory.addPreference(pref);
|
||||
pref.setTitle(locale.getFullCountryNameNative());
|
||||
pref.setKey(locale.toString());
|
||||
if (locale.getLocale().equals(LocaleList.getDefault().get(0))) {
|
||||
if (locale.getLocale().equals(Locale.getDefault())) {
|
||||
pref.setChecked(true);
|
||||
} else {
|
||||
pref.setChecked(false);
|
||||
@@ -154,7 +153,7 @@ public abstract class RegionPickerBaseListPreferenceController extends BasePrefe
|
||||
|
||||
private List<LocaleStore.LocaleInfo> getSortedLocaleList(
|
||||
List<LocaleStore.LocaleInfo> localeInfos) {
|
||||
final Locale sortingLocale = LocaleList.getDefault().get(0);
|
||||
final Locale sortingLocale = Locale.getDefault();
|
||||
final LocaleHelper.LocaleInfoComparator comp =
|
||||
new LocaleHelper.LocaleInfoComparator(sortingLocale, true);
|
||||
Collections.sort(localeInfos, comp);
|
||||
@@ -162,7 +161,7 @@ public abstract class RegionPickerBaseListPreferenceController extends BasePrefe
|
||||
}
|
||||
|
||||
private void switchRegion(LocaleStore.LocaleInfo localeInfo) {
|
||||
if (localeInfo.getLocale().equals(LocaleList.getDefault().get(0))) {
|
||||
if (localeInfo.getLocale().equals(Locale.getDefault())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,6 @@ package com.android.settings.regionalpreferences;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.LocaleList;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -84,7 +83,7 @@ public class RegionPickerFragment extends DashboardFragment{
|
||||
|
||||
private List<AbstractPreferenceController> buildPreferenceControllers(
|
||||
@NonNull Context context) {
|
||||
Locale parentLocale = LocaleStore.getLocaleInfo(LocaleList.getDefault().get(0)).getParent();
|
||||
Locale parentLocale = LocaleStore.getLocaleInfo(Locale.getDefault()).getParent();
|
||||
LocaleStore.LocaleInfo parentLocaleInfo = LocaleStore.getLocaleInfo(parentLocale);
|
||||
SystemRegionSuggestedListPreferenceController mSuggestedListPreferenceController =
|
||||
new SystemRegionSuggestedListPreferenceController(
|
||||
|
@@ -17,7 +17,6 @@
|
||||
package com.android.settings.regionalpreferences;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.LocaleList;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.Preference;
|
||||
@@ -27,6 +26,8 @@ import com.android.internal.app.LocaleStore;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.flags.Flags;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/** A controller for the entry of region picker page */
|
||||
public class RegionPreferenceController extends BasePreferenceController {
|
||||
|
||||
@@ -39,7 +40,7 @@ public class RegionPreferenceController extends BasePreferenceController {
|
||||
super.displayPreference(screen);
|
||||
Preference preference = screen.findPreference(getPreferenceKey());
|
||||
LocaleStore.LocaleInfo localeInfo = LocaleStore.getLocaleInfo(
|
||||
LocaleList.getDefault().get(0));
|
||||
Locale.getDefault());
|
||||
preference.setSummary(localeInfo.getFullCountryNameNative());
|
||||
}
|
||||
|
||||
|
@@ -275,6 +275,7 @@ public class LocaleListEditorTest {
|
||||
public void showConfirmDialog_systemLocaleSelected_shouldShowLocaleChangeDialog()
|
||||
throws Exception {
|
||||
//pre-condition
|
||||
Locale.setDefault(Locale.forLanguageTag("zh-TW"));
|
||||
setUpLocaleConditions(true);
|
||||
final Configuration config = new Configuration();
|
||||
config.setLocales((LocaleList.forLanguageTags("zh-TW,en-US")));
|
||||
@@ -379,6 +380,7 @@ public class LocaleListEditorTest {
|
||||
@Test
|
||||
public void onTouch_dragDifferentLocaleToTop_showConfirmDialog() throws Exception {
|
||||
MotionEvent event = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_UP, 0.0f, 0.0f, 0);
|
||||
Locale.setDefault(Locale.forLanguageTag("zh-TW"));
|
||||
setUpLocaleConditions(true);
|
||||
final Configuration config = new Configuration();
|
||||
config.setLocales((LocaleList.forLanguageTags("zh-TW,en-US")));
|
||||
|
Reference in New Issue
Block a user