Use flag to control the hierarchy tree changes
This change includes these: 1. App languages 2.Regional preferences 2-1. Temperature 2-2. First day of week 2-3. Numbering system 3. Terms of address Bug: 379962955 Flag: com.android.settings.flags.regional_preferences_api_enabled Test: check hsv and atest TermsOfAddressCategoryControllerTest, FirstDayOfWeekControllerTest, NumberingSystemControllerTest, TemperatureUnitControllerTest Change-Id: I9ae376f24ac4d1cf9a186ad3d77b539ac4b83642 Change-Id: I1b2f508f618fba94e67b5f8b102620837a6dda1c
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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<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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
|
@@ -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.
|
||||
* </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);
|
||||
}
|
||||
}
|
@@ -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.
|
||||
* </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());
|
||||
}
|
||||
}
|
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
@@ -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.
|
||||
* </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);
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user