diff --git a/res/values/strings.xml b/res/values/strings.xml index 8b5e63f4329..232799ae467 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -387,12 +387,6 @@ Preferred Language - - App languages - - - Set the language for each app - App language @@ -459,6 +453,14 @@ Let apps know your regional preferences so they can personalize your experience. Apps will use your regional preferences where possible. + + More language settings + + App languages + + Set the language for each app + + Regional preferences Temperature diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml deleted file mode 100644 index 1848f86ce4e..00000000000 --- a/res/xml/language_and_input.xml +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/xml/language_settings.xml b/res/xml/language_settings.xml index 7618399db97..7983b05da5b 100644 --- a/res/xml/language_settings.xml +++ b/res/xml/language_settings.xml @@ -28,6 +28,7 @@ android:title="@string/system_language" android:fragment="com.android.settings.localepicker.LocaleListEditor" settings:controller="com.android.settings.language.PhoneLanguagePreferenceController" /> + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/com/android/settings/applications/appinfo/ManageAppLocalePreferenceController.java b/src/com/android/settings/applications/appinfo/ManageAppLocalePreferenceController.java new file mode 100644 index 00000000000..60cb8be16fe --- /dev/null +++ b/src/com/android/settings/applications/appinfo/ManageAppLocalePreferenceController.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.applications.appinfo; + +import android.content.Context; + +import androidx.annotation.NonNull; + +import com.android.settings.core.BasePreferenceController; +import com.android.settings.flags.Flags; + +/** + * A controller to update current locale information of application + * and a entry to launch {@link ManageApplications}. + */ +public class ManageAppLocalePreferenceController extends BasePreferenceController { + public ManageAppLocalePreferenceController(@NonNull Context context, @NonNull String key) { + super(context, key); + } + + @Override + public int getAvailabilityStatus() { + if (!Flags.regionalPreferencesApiEnabled()) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; + } +} diff --git a/src/com/android/settings/applications/appinfo/NewManageAppLocalePreferenceController.java b/src/com/android/settings/applications/appinfo/NewManageAppLocalePreferenceController.java new file mode 100644 index 00000000000..00daab6b9a5 --- /dev/null +++ b/src/com/android/settings/applications/appinfo/NewManageAppLocalePreferenceController.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.applications.appinfo; + +import android.content.Context; + +import androidx.annotation.NonNull; + +import com.android.settings.core.BasePreferenceController; +import com.android.settings.flags.Flags; + +/** + * A controller to update current locale information of application + * and a entry to launch {@link ManageApplications}. + */ +public class NewManageAppLocalePreferenceController extends BasePreferenceController { + + public NewManageAppLocalePreferenceController(@NonNull Context context, @NonNull String key) { + super(context, key); + } + + @Override + public int getAvailabilityStatus() { + if (Flags.regionalPreferencesApiEnabled()) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; + } +} diff --git a/src/com/android/settings/language/MoreLanguagesSettingsCategoryController.java b/src/com/android/settings/language/MoreLanguagesSettingsCategoryController.java new file mode 100644 index 00000000000..b174ae0ceb7 --- /dev/null +++ b/src/com/android/settings/language/MoreLanguagesSettingsCategoryController.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.settings.language; + +import android.content.Context; + +import androidx.annotation.NonNull; + +import com.android.settings.flags.Flags; +import com.android.settings.widget.PreferenceCategoryController; + +public class MoreLanguagesSettingsCategoryController extends PreferenceCategoryController { + + public MoreLanguagesSettingsCategoryController(@NonNull Context context, @NonNull String key) { + super(context, key); + } + + @Override + public int getAvailabilityStatus() { + if (Flags.regionalPreferencesApiEnabled()) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; + } +} diff --git a/src/com/android/settings/localepicker/NewTermsOfAddressController.java b/src/com/android/settings/localepicker/NewTermsOfAddressController.java new file mode 100644 index 00000000000..fe92405f1a1 --- /dev/null +++ b/src/com/android/settings/localepicker/NewTermsOfAddressController.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.localepicker; + +import android.content.Context; +import android.os.LocaleList; + +import androidx.annotation.NonNull; + +import com.android.internal.app.LocaleStore; +import com.android.settings.R; +import com.android.settings.core.BasePreferenceController; +import com.android.settings.flags.Flags; + +import java.util.Arrays; +import java.util.List; +import java.util.Locale; + +public class NewTermsOfAddressController extends BasePreferenceController { + + public NewTermsOfAddressController(@NonNull Context context, @NonNull String preferenceKey) { + super(context, preferenceKey); + } + + @Override + public int getAvailabilityStatus() { + if (Flags.regionalPreferencesApiEnabled()) { + if (Flags.termsOfAddressEnabled()) { + return checkAvailabilityStatus(); + } + } + return CONDITIONALLY_UNAVAILABLE; + } + + private int checkAvailabilityStatus() { + // If language is not available for system language, or if ToA does not apply to + // system language, we will hide it. + final Locale defaultLocale = Locale.getDefault(); + LocaleStore.LocaleInfo localeInfo = LocaleStore.getLocaleInfo(defaultLocale); + final List supportedLanguageList = Arrays.asList( + mContext.getResources().getStringArray( + R.array.terms_of_address_supported_languages)); + final List notSupportedLocaleList = Arrays.asList( + mContext.getResources().getStringArray( + R.array.terms_of_address_unsupported_locales)); + + final Locale locale = localeInfo.getLocale().stripExtensions(); + final String language = locale.getLanguage(); + final String localeTag = locale.toLanguageTag(); + + // Supported locales: + // 1. All French is supported except fr-CA. + // 2. QA language en-XA (LTR pseudo locale), ar_XB (RTL pseudo locale). + if ((supportedLanguageList.contains(language) + && !notSupportedLocaleList.contains(localeTag)) + || LocaleList.isPseudoLocale(locale)) { + return AVAILABLE; + } + + return CONDITIONALLY_UNAVAILABLE; + } +} diff --git a/src/com/android/settings/localepicker/TermsOfAddressCategoryController.java b/src/com/android/settings/localepicker/TermsOfAddressCategoryController.java index 01168c7ff7b..1e2fbef7e83 100644 --- a/src/com/android/settings/localepicker/TermsOfAddressCategoryController.java +++ b/src/com/android/settings/localepicker/TermsOfAddressCategoryController.java @@ -20,7 +20,6 @@ import static com.android.settings.flags.Flags.termsOfAddressEnabled; import android.content.Context; import android.os.LocaleList; -import android.text.TextUtils; import android.util.Log; import androidx.preference.PreferenceCategory; @@ -28,6 +27,7 @@ import androidx.preference.PreferenceScreen; import com.android.internal.app.LocaleStore; import com.android.settings.R; +import com.android.settings.flags.Flags; import com.android.settings.widget.PreferenceCategoryController; import java.util.Arrays; @@ -64,6 +64,9 @@ public class TermsOfAddressCategoryController extends PreferenceCategoryControll @Override public int getAvailabilityStatus() { + if (Flags.regionalPreferencesApiEnabled()) { + return CONDITIONALLY_UNAVAILABLE; + } if (!termsOfAddressEnabled()) { return CONDITIONALLY_UNAVAILABLE; diff --git a/src/com/android/settings/regionalpreferences/NewFirstDayOfWeekController.java b/src/com/android/settings/regionalpreferences/NewFirstDayOfWeekController.java new file mode 100644 index 00000000000..aa691ed0b45 --- /dev/null +++ b/src/com/android/settings/regionalpreferences/NewFirstDayOfWeekController.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.regionalpreferences; + +import android.content.Context; +import android.provider.Settings; + +import androidx.annotation.NonNull; +import androidx.core.text.util.LocalePreferences; + +import com.android.settings.R; +import com.android.settings.core.BasePreferenceController; +import com.android.settings.flags.Flags; + +import java.util.Locale; + +/** A controller for the entry of First Day of Week's page */ +public class NewFirstDayOfWeekController extends BasePreferenceController { + + public NewFirstDayOfWeekController(@NonNull Context context, @NonNull String preferenceKey) { + super(context, preferenceKey); + } + + /** + * @return {@link AvailabilityStatus} for the Setting. This status is used to determine if the + * Setting should be shown or disabled in Settings. Further, it can be used to produce + * appropriate error / warning Slice in the case of unavailability. + *

+ * The status is used for the convenience methods: {@link #isAvailable()}, {@link + * #isSupported()} + *

+ * The inherited class doesn't need to check work profile if android:forWork="true" is set in + * preference xml. + */ + @Override + public int getAvailabilityStatus() { + if (Flags.regionalPreferencesApiEnabled()) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; + } + + @Override + public CharSequence getSummary() { + String record = Settings.System.getString( + mContext.getContentResolver(), Settings.System.LOCALE_PREFERENCES); + String result = ""; + if (record != null) { + result = LocalePreferences.getFirstDayOfWeek(Locale.forLanguageTag(record), false); + } + + if (result.isEmpty()) { + result = LocalePreferences.getFirstDayOfWeek(false); + } + return result.isEmpty() + ? mContext.getString(R.string.default_string_of_regional_preference) + : RegionalPreferencesDataUtils.dayConverter(mContext, result); + } +} diff --git a/src/com/android/settings/regionalpreferences/NewNumberingSystemController.java b/src/com/android/settings/regionalpreferences/NewNumberingSystemController.java new file mode 100644 index 00000000000..429d1f35503 --- /dev/null +++ b/src/com/android/settings/regionalpreferences/NewNumberingSystemController.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.regionalpreferences; + +import android.content.Context; +import android.os.LocaleList; + +import androidx.annotation.NonNull; + +import com.android.internal.app.LocaleStore; +import com.android.settings.core.BasePreferenceController; +import com.android.settings.flags.Flags; +import com.android.settings.localepicker.LocaleFeatureProviderImpl; + +import java.util.HashSet; +import java.util.Locale; +import java.util.Set; + +/** A controller for the entry of Numbering System's page */ +public class NewNumberingSystemController extends BasePreferenceController { + private static final String TAG = NewNumberingSystemController.class.getSimpleName(); + + private LocaleList mLocaleList; + public NewNumberingSystemController(@NonNull Context context, @NonNull String preferenceKey) { + super(context, preferenceKey); + // Initialize the supported languages to LocaleInfos + LocaleStore.fillCache(context); + mLocaleList = getNumberingSystemLocale(); + } + + /** + * @return {@link AvailabilityStatus} for the Setting. This status is used to determine if the + * Setting should be shown or disabled in Settings. Further, it can be used to produce + * appropriate error / warning Slice in the case of unavailability. + *

+ * The status is used for the convenience methods: {@link #isAvailable()}, {@link + * #isSupported()} + *

+ * The inherited class doesn't need to check work profile if android:forWork="true" is set in + * preference xml. + */ + @Override + public int getAvailabilityStatus() { + if (Flags.regionalPreferencesApiEnabled()) { + return mLocaleList.isEmpty() ? CONDITIONALLY_UNAVAILABLE : AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; + } + + private static LocaleList getNumberingSystemLocale() { + LocaleList localeList = LocaleList.getDefault(); + Set localesHasNumberingSystems = new HashSet<>(); + for (int i = 0; i < localeList.size(); i++) { + Locale locale = localeList.get(i); + LocaleStore.LocaleInfo localeInfo = LocaleStore.getLocaleInfo(locale); + if (localeInfo.hasNumberingSystems()) { + localesHasNumberingSystems.add(locale); + } + } + return convertToLocaleList(localesHasNumberingSystems); + } + + private static LocaleList convertToLocaleList(Set locales) { + if (locales.isEmpty()) { + return LocaleList.getEmptyLocaleList(); + } + return new LocaleList(locales.stream().toArray(Locale[]::new)); + } + + @Override + public CharSequence getSummary() { + return new LocaleFeatureProviderImpl().getLocaleNames(getNumberingSystemLocale()); + } +} diff --git a/src/com/android/settings/regionalpreferences/NewRegionalFooterPreferenceController.java b/src/com/android/settings/regionalpreferences/NewRegionalFooterPreferenceController.java new file mode 100644 index 00000000000..9c800de82c8 --- /dev/null +++ b/src/com/android/settings/regionalpreferences/NewRegionalFooterPreferenceController.java @@ -0,0 +1,81 @@ +/** + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.regionalpreferences; + +import android.content.Context; +import android.content.Intent; +import android.util.Log; + +import androidx.annotation.NonNull; +import androidx.annotation.VisibleForTesting; +import androidx.preference.PreferenceScreen; + +import com.android.settings.R; +import com.android.settings.core.BasePreferenceController; +import com.android.settings.flags.Flags; +import com.android.settingslib.HelpUtils; +import com.android.settingslib.widget.FooterPreference; + +/** + * Preference controller for regional preference footer. + */ +public class NewRegionalFooterPreferenceController extends BasePreferenceController { + + private static final String TAG = "NewRegionalFooterPreferenceController"; + + public NewRegionalFooterPreferenceController(@NonNull Context context, @NonNull String key) { + super(context, key); + } + + @Override + public int getAvailabilityStatus() { + if (Flags.regionalPreferencesApiEnabled()) { + return AVAILABLE_UNSEARCHABLE; + } + + + return CONDITIONALLY_UNAVAILABLE; + } + + @Override + public void displayPreference(@NonNull PreferenceScreen screen) { + super.displayPreference(screen); + FooterPreference footerPreference = screen.findPreference(getPreferenceKey()); + setupFooterPreference(footerPreference); + } + + @VisibleForTesting + void setupFooterPreference(FooterPreference footerPreference) { + if (footerPreference != null) { + footerPreference.setLearnMoreAction(v -> openLocaleLearnMoreLink()); + footerPreference.setLearnMoreText(mContext.getString( + R.string.desc_regional_pref_footer_learn_more)); + } + } + + private void openLocaleLearnMoreLink() { + Intent intent = HelpUtils.getHelpIntent( + mContext, + mContext.getString(R.string.regional_pref_footer_learn_more_link), + mContext.getClass().getName()); + if (intent != null) { + mContext.startActivity(intent); + } else { + Log.w(TAG, "HelpIntent is null"); + } + } +} diff --git a/src/com/android/settings/regionalpreferences/NewTemperatureUnitController.java b/src/com/android/settings/regionalpreferences/NewTemperatureUnitController.java new file mode 100644 index 00000000000..7d3dc3e59c6 --- /dev/null +++ b/src/com/android/settings/regionalpreferences/NewTemperatureUnitController.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.regionalpreferences; + +import android.content.Context; +import android.provider.Settings; + +import androidx.annotation.NonNull; +import androidx.core.text.util.LocalePreferences; + +import com.android.settings.R; +import com.android.settings.core.BasePreferenceController; +import com.android.settings.flags.Flags; + +import java.util.Locale; + +/** A controller for the entry of Temperature units' page */ +public class NewTemperatureUnitController extends BasePreferenceController { + private static final String TAG = NewTemperatureUnitController.class.getSimpleName(); + public NewTemperatureUnitController(@NonNull Context context, @NonNull String preferenceKey) { + super(context, preferenceKey); + } + + /** + * @return {@link AvailabilityStatus} for the Setting. This status is used to determine if the + * Setting should be shown or disabled in Settings. Further, it can be used to produce + * appropriate error / warning Slice in the case of unavailability. + *

+ * The status is used for the convenience methods: {@link #isAvailable()}, {@link + * #isSupported()} + *

+ * The inherited class doesn't need to check work profile if android:forWork="true" is set in + * preference xml. + */ + @Override + public int getAvailabilityStatus() { + if (Flags.regionalPreferencesApiEnabled()) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; + } + + @Override + public CharSequence getSummary() { + String record = Settings.System.getString( + mContext.getContentResolver(), Settings.System.LOCALE_PREFERENCES); + String result = ""; + if (record != null) { + result = LocalePreferences.getTemperatureUnit(Locale.forLanguageTag(record), false); + } + + if (result.isEmpty()) { + result = LocalePreferences.getTemperatureUnit(false); + } + + return result.isEmpty() + ? mContext.getString(R.string.default_string_of_regional_preference) + : RegionalPreferencesDataUtils.temperatureUnitsConverter(mContext, result); + } +} diff --git a/src/com/android/settings/regionalpreferences/RegionalPreferencesCategoryController.java b/src/com/android/settings/regionalpreferences/RegionalPreferencesCategoryController.java new file mode 100644 index 00000000000..ad524a4ed3c --- /dev/null +++ b/src/com/android/settings/regionalpreferences/RegionalPreferencesCategoryController.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings.regionalpreferences; + +import android.content.Context; + +import androidx.annotation.NonNull; + +import com.android.settings.flags.Flags; +import com.android.settings.widget.PreferenceCategoryController; + +public class RegionalPreferencesCategoryController extends PreferenceCategoryController { + public RegionalPreferencesCategoryController(@NonNull Context context, @NonNull String key) { + super(context, key); + } + + @Override + public int getAvailabilityStatus() { + if (Flags.regionalPreferencesApiEnabled()) { + return AVAILABLE; + } + return CONDITIONALLY_UNAVAILABLE; + } +} diff --git a/src/com/android/settings/regionalpreferences/RegionalPreferencesController.java b/src/com/android/settings/regionalpreferences/RegionalPreferencesController.java index 5e5fc9d2175..f194659c00b 100644 --- a/src/com/android/settings/regionalpreferences/RegionalPreferencesController.java +++ b/src/com/android/settings/regionalpreferences/RegionalPreferencesController.java @@ -20,6 +20,7 @@ import android.content.Context; import android.os.SystemProperties; import com.android.settings.core.BasePreferenceController; +import com.android.settings.flags.Flags; /** A controller for the entry of Regional preferences */ public class RegionalPreferencesController extends BasePreferenceController { @@ -42,6 +43,9 @@ public class RegionalPreferencesController extends BasePreferenceController { */ @Override public int getAvailabilityStatus() { + if (Flags.regionalPreferencesApiEnabled()) { + return CONDITIONALLY_UNAVAILABLE; + } return SystemProperties.getBoolean(FEATURE_PROPERTY, true) ? AVAILABLE : CONDITIONALLY_UNAVAILABLE; } diff --git a/src/com/android/settings/regionalpreferences/RegionalPreferencesEntriesFragment.java b/src/com/android/settings/regionalpreferences/RegionalPreferencesEntriesFragment.java index 848febcf2d2..8b1e749ef79 100644 --- a/src/com/android/settings/regionalpreferences/RegionalPreferencesEntriesFragment.java +++ b/src/com/android/settings/regionalpreferences/RegionalPreferencesEntriesFragment.java @@ -17,9 +17,11 @@ package com.android.settings.regionalpreferences; import android.app.settings.SettingsEnums; +import android.content.Context; import com.android.settings.R; import com.android.settings.dashboard.DashboardFragment; +import com.android.settings.flags.Flags; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settingslib.search.SearchIndexable; @@ -55,5 +57,13 @@ public class RegionalPreferencesEntriesFragment extends DashboardFragment { } public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = - new BaseSearchIndexProvider(R.xml.regional_preference_main_page); + new BaseSearchIndexProvider(R.xml.regional_preference_main_page) { + @Override + protected boolean isPageSearchEnabled(Context context) { + if (Flags.regionalPreferencesApiEnabled()) { + return false; + } + return true; + } + }; } diff --git a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressCategoryControllerTest.java b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressCategoryControllerTest.java index b025abdf06a..ed878f48f2b 100644 --- a/tests/unit/src/com/android/settings/localepicker/TermsOfAddressCategoryControllerTest.java +++ b/tests/unit/src/com/android/settings/localepicker/TermsOfAddressCategoryControllerTest.java @@ -24,10 +24,13 @@ import static org.mockito.Mockito.spy; import android.content.Context; import android.os.Looper; +import android.platform.test.annotations.DisableFlags; import androidx.test.core.app.ApplicationProvider; import androidx.test.ext.junit.runners.AndroidJUnit4; +import com.android.settings.flags.Flags; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -65,6 +68,7 @@ public class TermsOfAddressCategoryControllerTest { } @Test + @DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED) public void getAvailabilityStatus_returnAvailable() { Locale.setDefault(Locale.forLanguageTag("fr-FR")); diff --git a/tests/unit/src/com/android/settings/regionalpreferences/FirstDayOfWeekControllerTest.java b/tests/unit/src/com/android/settings/regionalpreferences/FirstDayOfWeekControllerTest.java index 062aef8393a..759b356cfab 100644 --- a/tests/unit/src/com/android/settings/regionalpreferences/FirstDayOfWeekControllerTest.java +++ b/tests/unit/src/com/android/settings/regionalpreferences/FirstDayOfWeekControllerTest.java @@ -19,10 +19,12 @@ package com.android.settings.regionalpreferences; import static org.junit.Assert.assertEquals; import android.content.Context; +import android.platform.test.annotations.DisableFlags; import android.provider.Settings; import androidx.test.core.app.ApplicationProvider; +import com.android.settings.flags.Flags; import com.android.settings.testutils.ResourcesUtils; import org.junit.After; @@ -54,6 +56,7 @@ public class FirstDayOfWeekControllerTest { } @Test + @DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED) public void getSummary_hasProviderValue_resultIsWed() { RegionalPreferenceTestUtils.setSettingsProviderContent(mApplicationContext, "und-u-fw-wed"); @@ -64,6 +67,7 @@ public class FirstDayOfWeekControllerTest { } @Test + @DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED) public void getSummary_hasProviderValue_resultIsSat() { RegionalPreferenceTestUtils.setSettingsProviderContent(mApplicationContext, "und-u-fw-sat"); @@ -74,6 +78,7 @@ public class FirstDayOfWeekControllerTest { } @Test + @DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED) public void getSummary_noProviderValueButHasDefaultLocaleWithSubtag_resultIsSat() { RegionalPreferenceTestUtils.setSettingsProviderContent(mApplicationContext, ""); Locale.setDefault(Locale.forLanguageTag("en-US-u-fw-sat")); @@ -85,6 +90,7 @@ public class FirstDayOfWeekControllerTest { } @Test + @DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED) public void getSummary_noProviderValueAndDefaultLocaleWithoutSubtag_resultIsdefault() { RegionalPreferenceTestUtils.setSettingsProviderContent(mApplicationContext, ""); Locale.setDefault(Locale.forLanguageTag("en-US")); diff --git a/tests/unit/src/com/android/settings/regionalpreferences/NumberingSystemControllerTest.java b/tests/unit/src/com/android/settings/regionalpreferences/NumberingSystemControllerTest.java index 6a95bb95826..bb745a6fb28 100644 --- a/tests/unit/src/com/android/settings/regionalpreferences/NumberingSystemControllerTest.java +++ b/tests/unit/src/com/android/settings/regionalpreferences/NumberingSystemControllerTest.java @@ -23,9 +23,12 @@ import static org.junit.Assert.assertEquals; import android.content.Context; import android.os.LocaleList; +import android.platform.test.annotations.DisableFlags; import androidx.test.core.app.ApplicationProvider; +import com.android.settings.flags.Flags; + import org.junit.Before; import org.junit.Test; @@ -39,6 +42,7 @@ public class NumberingSystemControllerTest { } @Test + @DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED) public void getAvailabilityStatus_noLocale_unavailable() { LocaleList.setDefault(LocaleList.forLanguageTags("en-US,zh-Hant-TW")); mController = new NumberingSystemController(mApplicationContext, "key"); @@ -49,6 +53,7 @@ public class NumberingSystemControllerTest { } @Test + @DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED) public void getAvailabilityStatus_hasLocaleWithNumberingSystems_available() { // ar-JO has different numbering system. LocaleList.setDefault(LocaleList.forLanguageTags("en-US,zh-Hant-TW,ar-JO")); diff --git a/tests/unit/src/com/android/settings/regionalpreferences/TemperatureUnitControllerTest.java b/tests/unit/src/com/android/settings/regionalpreferences/TemperatureUnitControllerTest.java index aa652cab1f4..fb05dfaedb4 100644 --- a/tests/unit/src/com/android/settings/regionalpreferences/TemperatureUnitControllerTest.java +++ b/tests/unit/src/com/android/settings/regionalpreferences/TemperatureUnitControllerTest.java @@ -19,10 +19,12 @@ package com.android.settings.regionalpreferences; import static org.junit.Assert.assertEquals; import android.content.Context; +import android.platform.test.annotations.DisableFlags; import android.provider.Settings; import androidx.test.core.app.ApplicationProvider; +import com.android.settings.flags.Flags; import com.android.settings.testutils.ResourcesUtils; import org.junit.After; @@ -54,6 +56,7 @@ public class TemperatureUnitControllerTest { } @Test + @DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED) public void getSummary_hasProviderValue_resultIsCelsius() { RegionalPreferenceTestUtils.setSettingsProviderContent( mApplicationContext, "und-u-mu-celsius"); @@ -65,6 +68,7 @@ public class TemperatureUnitControllerTest { } @Test + @DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED) public void getSummary_hasProviderValue_resultIsFahrenheit() { RegionalPreferenceTestUtils.setSettingsProviderContent( mApplicationContext, "und-u-mu-fahrenhe"); @@ -76,6 +80,7 @@ public class TemperatureUnitControllerTest { } @Test + @DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED) public void getSummary_noProviderValueButHasDefaultLocaleWithSubtag_resultIsFahrenheit() { RegionalPreferenceTestUtils.setSettingsProviderContent(mApplicationContext, ""); Locale.setDefault(Locale.forLanguageTag("en-US-u-mu-fahrenhe")); @@ -87,6 +92,7 @@ public class TemperatureUnitControllerTest { } @Test + @DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED) public void getSummary_noProviderValueAndDefaultLocaleWithoutSubtag_resultIsDefault() { RegionalPreferenceTestUtils.setSettingsProviderContent(mApplicationContext, ""); Locale.setDefault(Locale.forLanguageTag("en-US"));