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

@@ -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);
}