Loading res/values/strings.xml +18 −0 Original line number Diff line number Diff line Loading @@ -354,6 +354,24 @@ <!-- Description for introduction of the locale selection supported of app list [CHAR LIMIT=NONE]--> <string name="desc_app_locale_selection_supported">Only apps that support language selection are shown here.</string> <!-- Regional Preferences begin --> <!-- The title of the menu entry of regional preferences. [CHAR LIMIT=50] --> <string name="regional_preferences_title">Regional preferences</string> <!-- The summary of the menu entry of regional preferences. [CHAR LIMIT=NONE] --> <string name="regional_preferences_summary">Set units and number preferences</string> <!-- The subtitle of main page of regional preferences. [CHAR LIMIT=NONE] --> <string name="regional_preferences_main_page_sub_title">Apps can use your regional preferences to personalize your experience</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 Calendar type preference. [CHAR LIMIT=50] --> <string name="calendar_preferences_title">Calendar</string> <!-- The title of the menu entry of First day of week preference. [CHAR LIMIT=50] --> <string name="first_day_of_week_preferences_title">First day of week</string> <!-- The title of the menu entry of Numbers system preference. [CHAR LIMIT=50] --> <string name="numbers_preferences_title">Numbers</string> <!-- The summary of default string for each regional preference. [CHAR LIMIT=50] --> <string name="default_string_of_regional_preference">[No preference]</string> <!-- The title of the confirmation dialog shown when the user selects one / several languages and tries to remove them [CHAR LIMIT=60] --> <string name="dlg_remove_locales_title">{count, plural, =1 {Remove selected language?} Loading res/xml/language_and_input.xml +9 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,15 @@ 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 Loading res/xml/regional_preference_main_page.xml 0 → 100644 +49 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2022 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/regional_preferences_title"> <com.android.settingslib.widget.TopIntroPreference android:title="@string/regional_preferences_main_page_sub_title" android:persistent="false" /> <Preference android:key="key_temperature_unit" android:title="@string/temperature_preferences_title" android:summary="@string/default_string_of_regional_preference" settings:controller="com.android.settings.regionalpreferences.TemperatureUnitController"/> <Preference android:key="key_calendar_type" android:title="@string/calendar_preferences_title" android:summary="@string/default_string_of_regional_preference" settings:controller="com.android.settings.regionalpreferences.CalendarTypeController"/> <Preference android:key="key_first_day_of_week" android:title="@string/first_day_of_week_preferences_title" android:summary="@string/default_string_of_regional_preference" settings:controller="com.android.settings.regionalpreferences.FirstDayOfWeekController"/> <Preference android:key="key_numbering_system" android:title="@string/numbers_preferences_title" android:summary="@string/default_string_of_regional_preference" settings:controller="com.android.settings.regionalpreferences.NumberingSystemController"/> </PreferenceScreen> src/com/android/settings/regionalpreferences/CalendarTypeController.java 0 → 100644 +66 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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 com.android.settings.R; import com.android.settings.core.BasePreferenceController; import java.util.Locale; /** * A controller for the entry of Calendar types' page */ public class CalendarTypeController extends BasePreferenceController { public CalendarTypeController(Context context, 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() { return AVAILABLE; } @Override public CharSequence getSummary() { String record = Settings.System.getString( mContext.getContentResolver(), Settings.System.LOCALE_PREFERENCES); String result = ""; if (record != null) { result = LocalePreferences.getCalendarType(Locale.forLanguageTag(record), false); } if (result.isEmpty()) { result = LocalePreferences.getCalendarType(false); } return result.isEmpty() ? mContext.getString(R.string.default_string_of_regional_preference) : result; } } src/com/android/settings/regionalpreferences/FirstDayOfWeekController.java 0 → 100644 +64 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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 com.android.settings.R; import com.android.settings.core.BasePreferenceController; import java.util.Locale; /** A controller for the entry of First Day of Week's page */ public class FirstDayOfWeekController extends BasePreferenceController { public FirstDayOfWeekController(Context context, 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() { return AVAILABLE; } @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) : result; } } Loading
res/values/strings.xml +18 −0 Original line number Diff line number Diff line Loading @@ -354,6 +354,24 @@ <!-- Description for introduction of the locale selection supported of app list [CHAR LIMIT=NONE]--> <string name="desc_app_locale_selection_supported">Only apps that support language selection are shown here.</string> <!-- Regional Preferences begin --> <!-- The title of the menu entry of regional preferences. [CHAR LIMIT=50] --> <string name="regional_preferences_title">Regional preferences</string> <!-- The summary of the menu entry of regional preferences. [CHAR LIMIT=NONE] --> <string name="regional_preferences_summary">Set units and number preferences</string> <!-- The subtitle of main page of regional preferences. [CHAR LIMIT=NONE] --> <string name="regional_preferences_main_page_sub_title">Apps can use your regional preferences to personalize your experience</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 Calendar type preference. [CHAR LIMIT=50] --> <string name="calendar_preferences_title">Calendar</string> <!-- The title of the menu entry of First day of week preference. [CHAR LIMIT=50] --> <string name="first_day_of_week_preferences_title">First day of week</string> <!-- The title of the menu entry of Numbers system preference. [CHAR LIMIT=50] --> <string name="numbers_preferences_title">Numbers</string> <!-- The summary of default string for each regional preference. [CHAR LIMIT=50] --> <string name="default_string_of_regional_preference">[No preference]</string> <!-- The title of the confirmation dialog shown when the user selects one / several languages and tries to remove them [CHAR LIMIT=60] --> <string name="dlg_remove_locales_title">{count, plural, =1 {Remove selected language?} Loading
res/xml/language_and_input.xml +9 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,15 @@ 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 Loading
res/xml/regional_preference_main_page.xml 0 → 100644 +49 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2022 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/regional_preferences_title"> <com.android.settingslib.widget.TopIntroPreference android:title="@string/regional_preferences_main_page_sub_title" android:persistent="false" /> <Preference android:key="key_temperature_unit" android:title="@string/temperature_preferences_title" android:summary="@string/default_string_of_regional_preference" settings:controller="com.android.settings.regionalpreferences.TemperatureUnitController"/> <Preference android:key="key_calendar_type" android:title="@string/calendar_preferences_title" android:summary="@string/default_string_of_regional_preference" settings:controller="com.android.settings.regionalpreferences.CalendarTypeController"/> <Preference android:key="key_first_day_of_week" android:title="@string/first_day_of_week_preferences_title" android:summary="@string/default_string_of_regional_preference" settings:controller="com.android.settings.regionalpreferences.FirstDayOfWeekController"/> <Preference android:key="key_numbering_system" android:title="@string/numbers_preferences_title" android:summary="@string/default_string_of_regional_preference" settings:controller="com.android.settings.regionalpreferences.NumberingSystemController"/> </PreferenceScreen>
src/com/android/settings/regionalpreferences/CalendarTypeController.java 0 → 100644 +66 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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 com.android.settings.R; import com.android.settings.core.BasePreferenceController; import java.util.Locale; /** * A controller for the entry of Calendar types' page */ public class CalendarTypeController extends BasePreferenceController { public CalendarTypeController(Context context, 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() { return AVAILABLE; } @Override public CharSequence getSummary() { String record = Settings.System.getString( mContext.getContentResolver(), Settings.System.LOCALE_PREFERENCES); String result = ""; if (record != null) { result = LocalePreferences.getCalendarType(Locale.forLanguageTag(record), false); } if (result.isEmpty()) { result = LocalePreferences.getCalendarType(false); } return result.isEmpty() ? mContext.getString(R.string.default_string_of_regional_preference) : result; } }
src/com/android/settings/regionalpreferences/FirstDayOfWeekController.java 0 → 100644 +64 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 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 com.android.settings.R; import com.android.settings.core.BasePreferenceController; import java.util.Locale; /** A controller for the entry of First Day of Week's page */ public class FirstDayOfWeekController extends BasePreferenceController { public FirstDayOfWeekController(Context context, 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() { return AVAILABLE; } @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) : result; } }