[Regional Preference] Add each option entry

- Add a entry in langauge and input page
 - Add new page for the options of Temperature unit, calendar type,
   first day of week, and numbering system.

Bug: b/246929960
Test: atest pass
Test: Manual test pass
Change-Id: I69377fe9cd6dcd7a27c933a8dc98483df3da7665
This commit is contained in:
tom hsu
2022-12-19 20:05:44 +08:00
parent 58c3318e19
commit 504a5dda43
16 changed files with 1500 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
/*
* 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.icu.text.NumberingSystem;
import android.provider.Settings;
import android.text.TextUtils;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
import java.util.Locale;
/** A controller for the entry of Numbering System's page */
public class NumberingSystemController extends BasePreferenceController {
private static final String UNICODE_EXTENSION_NUMBERING_SYSTEM = "nu";
public NumberingSystemController(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 (!TextUtils.isEmpty(record)) {
result = Locale.forLanguageTag(record)
.getUnicodeLocaleType(UNICODE_EXTENSION_NUMBERING_SYSTEM);
}
if (TextUtils.isEmpty(result)) {
result = Locale.getDefault(Locale.Category.FORMAT)
.getUnicodeLocaleType(UNICODE_EXTENSION_NUMBERING_SYSTEM);
if (TextUtils.isEmpty(result)) {
return mContext.getString(R.string.default_string_of_regional_preference);
}
}
Locale locale = new Locale.Builder()
.setUnicodeLocaleKeyword(UNICODE_EXTENSION_NUMBERING_SYSTEM, result)
.build();
return NumberingSystem.getInstance(locale).getName();
}
}