Revert "Use flag to control the hierarchy tree changes"

This reverts commit 34ea3dc075.

Reason for revert: Droidmonitor created revert due to b/380258772. Will be verifying through ABTD before submission.

Change-Id: Ife4707fba00b52ade53eb6dc2f4bcd7a466afe0f
This commit is contained in:
Priyanka Advani (xWF)
2024-11-21 18:57:44 +00:00
committed by Android (Google) Code Review
parent 34ea3dc075
commit 2f996492ff
19 changed files with 147 additions and 670 deletions

View File

@@ -387,6 +387,12 @@
<!-- Title for the locale picker category. [CHAR LIMIT=50]-->
<string name="locale_picker_category_title">Preferred Language</string>
<!-- Title for the Apps' locale menu entry [CHAR LIMIT=50]-->
<string name="app_locales_picker_menu_title">App languages</string>
<!-- Summary for the app's locale picker activity. [CHAR LIMIT=50]-->
<string name="app_locale_picker_summary">Set the language for each app</string>
<!-- Title for the App's locale picker activity. [CHAR LIMIT=50]-->
<string name="app_locale_picker_title">App language</string>
@@ -453,14 +459,6 @@
<string name="regional_preferences_main_page_sub_title">Let apps know your regional preferences so they can personalize your experience.</string>
<!-- The subtitle of option's page of regional preferences for Temperature units, Calendar and First day of week. [CHAR LIMIT=NONE] -->
<string name="regional_preferences_option_page_sub_title">Apps will use your regional preferences where possible.</string>
<!-- Category for more language settings. [CHAR LIMIT=NONE]-->
<string name="more_language_settings_category">More language settings</string>
<!-- Title for the Apps' locale menu entry [CHAR LIMIT=50]-->
<string name="app_locales_picker_menu_title">App languages</string>
<!-- Summary for the app's locale picker activity. [CHAR LIMIT=50]-->
<string name="app_locale_picker_summary">Set the language for each app</string>
<!-- Category for the regional preferences. [CHAR LIMIT=NONE]-->
<string name="regional_preferences_category_title">Regional preferences</string>
<!-- The title of menu entry of Temperature unit preference. [CHAR LIMIT=50] -->
<string name="temperature_preferences_title">Temperature</string>
<!-- The title of the menu entry of First day of week preference. [CHAR LIMIT=50] -->

View File

@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2016 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.
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/language_settings">
<PreferenceCategory
android:key="languages_category"
android:title="@string/locale_picker_category_title">
<Preference
android:key="phone_language"
android:title="@string/phone_language"
android:fragment="com.android.settings.localepicker.LocaleListEditor"
settings:controller="com.android.settings.language.PhoneLanguagePreferenceController" />
<Preference
android:key="apps_language"
android:title="@string/app_locales_picker_menu_title"
android:summary="@string/app_locale_picker_summary"
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
settings:controller="com.android.settings.applications.appinfo.ManageAppLocalePreferenceController">
<extra
android:name="classname"
android:value="com.android.settings.applications.appinfo.AppLocaleDetails" />
</Preference>
<Preference
android:key="regional_preferences"
android:title="@string/regional_preferences_title"
android:summary="@string/regional_preferences_summary"
android:fragment="com.android.settings.regionalpreferences.RegionalPreferencesEntriesFragment"
settings:controller="com.android.settings.regionalpreferences.RegionalPreferencesController">
</Preference>
</PreferenceCategory>
<PreferenceCategory
android:key="keyboards_category"
android:title="@string/keyboard_and_input_methods_category">
<Preference
android:key="virtual_keyboard_pref"
android:title="@string/virtual_keyboard_category"
android:fragment="com.android.settings.inputmethod.AvailableVirtualKeyboardFragment"
settings:keywords="@string/keywords_virtual_keyboard"/>
<Preference
android:key="physical_keyboard_pref"
android:title="@string/physical_keyboard_title"
android:summary="@string/summary_placeholder"
android:fragment="com.android.settings.inputmethod.PhysicalKeyboardFragment"/>
</PreferenceCategory>
<PreferenceCategory
android:key="speech_category"
android:title="@string/speech_category_title">
<com.android.settings.widget.GearPreference
android:key="voice_input_settings"
android:title="@string/voice_input_settings_title"
android:fragment="com.android.settings.language.DefaultVoiceInputPicker" />
<Preference
android:key="tts_settings_summary"
android:title="@string/tts_settings_title"
android:fragment="com.android.settings.tts.TextToSpeechSettings"
settings:searchable="false"/>
</PreferenceCategory>
<PreferenceCategory
android:key="input_assistance_category"
android:title="@string/input_assistance">
<!-- Spell checker preference title, summary and fragment will be set programmatically. -->
<!-- Note: Mark this as persistent="false" to remove unnecessarily saved shared preference.
See: InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference. -->
<Preference
android:key="spellcheckers_settings"
android:title="@string/spellcheckers_settings_title"
android:persistent="false"
android:fragment="com.android.settings.inputmethod.SpellCheckersSettings" />
<!-- User dictionary preference title and fragment will be set programmatically. -->
<Preference
android:key="key_user_dictionary_settings"
android:title="@string/user_dict_settings_title"
android:summary="@string/user_dict_settings_summary"
android:fragment="com.android.settings.inputmethod.UserDictionaryList"
settings:controller="com.android.settings.language.UserDictionaryPreferenceController" />
</PreferenceCategory>
<PreferenceCategory
android:key="pointer_category"
android:layout="@layout/preference_category_no_label">
<com.android.settings.PointerSpeedPreference
android:key="pointer_speed"
android:title="@string/pointer_speed"
android:dialogTitle="@string/pointer_speed" />
</PreferenceCategory>
<SwitchPreferenceCompat
android:key="vibrate_input_devices"
android:title="@string/vibrate_input_devices"
android:summary="@string/vibrate_input_devices_summary"
settings:controller="com.android.settings.inputmethod.GameControllerPreferenceController" />
<com.android.settings.widget.WorkOnlyCategory
android:key="language_and_input_for_work_category"
android:title="@string/language_and_input_for_work_category_title"
settings:searchable="false">
<Preference
android:key="spellcheckers_settings_for_work_pref"
android:title="@string/spellcheckers_settings_for_work_title"
android:fragment="com.android.settings.inputmethod.SpellCheckersSettings"
settings:forWork="true"
settings:controller="com.android.settings.core.WorkPreferenceController" />
<Preference
android:key="user_dictionary_settings_for_work_pref"
android:title="@string/user_dict_settings_for_work_title"
android:fragment="com.android.settings.inputmethod.UserDictionaryList"
settings:forWork="true"
settings:controller="com.android.settings.inputmethod.SpellCheckerForWorkPreferenceController" />
</com.android.settings.widget.WorkOnlyCategory>
</PreferenceScreen>

View File

@@ -28,7 +28,6 @@
android:title="@string/system_language"
android:fragment="com.android.settings.localepicker.LocaleListEditor"
settings:controller="com.android.settings.language.PhoneLanguagePreferenceController" />
<Preference
android:key="apps_language"
android:title="@string/app_locales_picker_menu_title"
@@ -46,68 +45,7 @@
android:summary="@string/regional_preferences_summary"
android:fragment="com.android.settings.regionalpreferences.RegionalPreferencesEntriesFragment"
settings:controller="com.android.settings.regionalpreferences.RegionalPreferencesController" />
</PreferenceCategory>
<PreferenceCategory
android:key="more_language_settings_category"
android:title="@string/more_language_settings_category"
settings:controller="com.android.settings.language.MoreLanguagesSettingsCategoryController">
<Preference
android:key="apps_language_in_more_language_settings"
android:title="@string/app_locales_picker_menu_title"
android:summary="@string/app_locale_picker_summary"
android:fragment="com.android.settings.applications.manageapplications.ManageApplications"
settings:controller="com.android.settings.applications.appinfo.NewManageAppLocalePreferenceController">
<extra
android:name="classname"
android:value="com.android.settings.applications.appinfo.AppLocaleDetails" />
</Preference>
<Preference
android:key="terms_of_address_in_more_language_settings"
android:title="@string/terms_of_address_title"
android:summary="@string/terms_of_address_summary"
android:fragment="com.android.settings.localepicker.TermsOfAddressFragment"
settings:controller="com.android.settings.localepicker.NewTermsOfAddressController"/>
</PreferenceCategory>
<PreferenceCategory
android:key="regional_preferences_category"
android:title="@string/regional_preferences_category_title"
settings:controller="com.android.settings.regionalpreferences.RegionalPreferencesCategoryController">
<Preference
android:key="temperature_preference"
android:title="@string/temperature_preferences_title"
android:summary="@string/default_string_of_regional_preference"
settings:controller="com.android.settings.regionalpreferences.NewTemperatureUnitController"
settings:fragment="com.android.settings.regionalpreferences.TemperatureUnitFragment">
<extra
android:name="arg_key_regional_preference"
android:value="mu"/>
</Preference>
<Preference
android:key="first_day_of_week_preference"
android:title="@string/first_day_of_week_preferences_title"
android:summary="@string/default_string_of_regional_preference"
settings:controller="com.android.settings.regionalpreferences.NewFirstDayOfWeekController"
settings:fragment="com.android.settings.regionalpreferences.FirstDayOfWeekItemFragment">
<extra
android:name="arg_key_regional_preference"
android:value="fw"/>
</Preference>
<Preference
android:key="numbering_system_preference"
android:title="@string/numbers_preferences_title"
android:summary="@string/default_string_of_regional_preference"
settings:controller="com.android.settings.regionalpreferences.NewNumberingSystemController"
settings:fragment="com.android.settings.regionalpreferences.NumberingPreferencesFragment">
<extra
android:name="arg_key_regional_preference"
android:value="arg_value_language_select"/>
</Preference>
</PreferenceCategory>
<PreferenceCategory
@@ -131,11 +69,4 @@
android:fragment="com.android.settings.tts.TextToSpeechSettings"
settings:searchable="false"/>
</PreferenceCategory>
<com.android.settingslib.widget.FooterPreference
android:key="new_regional_pref_footer"
android:title="@string/title_regional_pref_footer"
android:selectable="false"
settings:searchable="false"
settings:controller="com.android.settings.regionalpreferences.NewRegionalFooterPreferenceController"/>
</PreferenceScreen>

View File

@@ -1,42 +0,0 @@
/*
* 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;
}
}

View File

@@ -1,43 +0,0 @@
/*
* 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;
}
}

View File

@@ -1,38 +0,0 @@
/*
* 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;
}
}

View File

@@ -1,76 +0,0 @@
/*
* 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<String> supportedLanguageList = Arrays.asList(
mContext.getResources().getStringArray(
R.array.terms_of_address_supported_languages));
final List<String> 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;
}
}

View File

@@ -20,6 +20,7 @@ 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;
@@ -27,7 +28,6 @@ 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,9 +64,6 @@ public class TermsOfAddressCategoryController extends PreferenceCategoryControll
@Override
public int getAvailabilityStatus() {
if (Flags.regionalPreferencesApiEnabled()) {
return CONDITIONALLY_UNAVAILABLE;
}
if (!termsOfAddressEnabled()) {
return CONDITIONALLY_UNAVAILABLE;

View File

@@ -1,73 +0,0 @@
/*
* 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.
* </p>
* The status is used for the convenience methods: {@link #isAvailable()}, {@link
* #isSupported()}
* </p>
* 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);
}
}

View File

@@ -1,88 +0,0 @@
/*
* 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.
* </p>
* The status is used for the convenience methods: {@link #isAvailable()}, {@link
* #isSupported()}
* </p>
* 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<Locale> 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<Locale> locales) {
if (locales.isEmpty()) {
return LocaleList.getEmptyLocaleList();
}
return new LocaleList(locales.stream().toArray(Locale[]::new));
}
@Override
public CharSequence getSummary() {
return new LocaleFeatureProviderImpl().getLocaleNames(getNumberingSystemLocale());
}
}

View File

@@ -1,81 +0,0 @@
/**
* 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");
}
}
}

View File

@@ -1,74 +0,0 @@
/*
* 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.
* </p>
* The status is used for the convenience methods: {@link #isAvailable()}, {@link
* #isSupported()}
* </p>
* 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);
}
}

View File

@@ -1,38 +0,0 @@
/*
* 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;
}
}

View File

@@ -20,7 +20,6 @@ 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 {
@@ -43,9 +42,6 @@ public class RegionalPreferencesController extends BasePreferenceController {
*/
@Override
public int getAvailabilityStatus() {
if (Flags.regionalPreferencesApiEnabled()) {
return CONDITIONALLY_UNAVAILABLE;
}
return SystemProperties.getBoolean(FEATURE_PROPERTY, true)
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
}

View File

@@ -17,11 +17,9 @@
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;
@@ -57,13 +55,5 @@ public class RegionalPreferencesEntriesFragment extends DashboardFragment {
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.regional_preference_main_page) {
@Override
protected boolean isPageSearchEnabled(Context context) {
if (Flags.regionalPreferencesApiEnabled()) {
return false;
}
return true;
}
};
new BaseSearchIndexProvider(R.xml.regional_preference_main_page);
}

View File

@@ -24,13 +24,10 @@ 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;
@@ -68,7 +65,6 @@ public class TermsOfAddressCategoryControllerTest {
}
@Test
@DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED)
public void getAvailabilityStatus_returnAvailable() {
Locale.setDefault(Locale.forLanguageTag("fr-FR"));

View File

@@ -19,12 +19,10 @@ 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;
@@ -56,7 +54,6 @@ public class FirstDayOfWeekControllerTest {
}
@Test
@DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED)
public void getSummary_hasProviderValue_resultIsWed() {
RegionalPreferenceTestUtils.setSettingsProviderContent(mApplicationContext, "und-u-fw-wed");
@@ -67,7 +64,6 @@ public class FirstDayOfWeekControllerTest {
}
@Test
@DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED)
public void getSummary_hasProviderValue_resultIsSat() {
RegionalPreferenceTestUtils.setSettingsProviderContent(mApplicationContext, "und-u-fw-sat");
@@ -78,7 +74,6 @@ 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"));
@@ -90,7 +85,6 @@ 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"));

View File

@@ -23,12 +23,9 @@ 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;
@@ -42,7 +39,6 @@ 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");
@@ -53,7 +49,6 @@ 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"));

View File

@@ -19,12 +19,10 @@ 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;
@@ -56,7 +54,6 @@ public class TemperatureUnitControllerTest {
}
@Test
@DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED)
public void getSummary_hasProviderValue_resultIsCelsius() {
RegionalPreferenceTestUtils.setSettingsProviderContent(
mApplicationContext, "und-u-mu-celsius");
@@ -68,7 +65,6 @@ public class TemperatureUnitControllerTest {
}
@Test
@DisableFlags(Flags.FLAG_REGIONAL_PREFERENCES_API_ENABLED)
public void getSummary_hasProviderValue_resultIsFahrenheit() {
RegionalPreferenceTestUtils.setSettingsProviderContent(
mApplicationContext, "und-u-mu-fahrenhe");
@@ -80,7 +76,6 @@ 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"));
@@ -92,7 +87,6 @@ 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"));