• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.settings.localepicker;
18 
19 import android.content.Context;
20 import android.os.LocaleList;
21 
22 import com.android.internal.app.LocaleCollectorBase;
23 import com.android.internal.app.LocaleStore;
24 import com.android.internal.app.SystemLocaleCollector;
25 
26 import androidx.annotation.NonNull;
27 import androidx.annotation.Nullable;
28 
29 public class SystemLocaleAllListPreferenceController extends
30         LocalePickerBaseListPreferenceController {
31     private static final String KEY_PREFERENCE_CATEGORY_ADD_LANGUAGE_ALL_SUPPORTED =
32             "system_language_all_supported_category";
33     private static final String KEY_PREFERENCE_SYSTEM_LOCALE_LIST = "system_locale_list";
34 
35     private boolean mIsNumberingSystemMode;
36     @Nullable private LocaleStore.LocaleInfo mLocaleInfo;
37     @Nullable private LocaleList mExplicitLocales;
38 
SystemLocaleAllListPreferenceController(@onNull Context context, @NonNull String preferenceKey)39     public SystemLocaleAllListPreferenceController(@NonNull Context context,
40             @NonNull String preferenceKey) {
41         super(context, preferenceKey);
42     }
43 
SystemLocaleAllListPreferenceController(@onNull Context context, @NonNull String preferenceKey, @NonNull LocaleStore.LocaleInfo parentLocale, boolean isNumberingSystemMode)44     public SystemLocaleAllListPreferenceController(@NonNull Context context,
45             @NonNull String preferenceKey, @NonNull LocaleStore.LocaleInfo parentLocale,
46             boolean isNumberingSystemMode) {
47         super(context, preferenceKey);
48         mLocaleInfo = parentLocale;
49         mIsNumberingSystemMode = isNumberingSystemMode;
50     }
51 
SystemLocaleAllListPreferenceController(@onNull Context context, @NonNull String preferenceKey, @Nullable LocaleList explicitLocales)52     public SystemLocaleAllListPreferenceController(@NonNull Context context,
53             @NonNull String preferenceKey, @Nullable LocaleList explicitLocales) {
54         super(context, preferenceKey);
55         mExplicitLocales = explicitLocales;
56     }
57 
58     @Override
getPreferenceCategoryKey()59     protected String getPreferenceCategoryKey() {
60         return KEY_PREFERENCE_CATEGORY_ADD_LANGUAGE_ALL_SUPPORTED;
61     }
62 
63     @Override
getPreferenceKey()64     public @NonNull String getPreferenceKey() {
65         return KEY_PREFERENCE_SYSTEM_LOCALE_LIST;
66     }
67 
68     @Override
getLocaleCollectorController(Context context)69     protected LocaleCollectorBase getLocaleCollectorController(Context context) {
70         return new SystemLocaleCollector(context, getExplicitLocaleList());
71     }
72 
73     @Override
getParentLocale()74     protected @Nullable LocaleStore.LocaleInfo getParentLocale() {
75         return mLocaleInfo;
76     }
77 
78     @Override
isNumberingMode()79     protected boolean isNumberingMode() {
80         return mIsNumberingSystemMode;
81     }
82 
83     @Override
getExplicitLocaleList()84     protected @Nullable LocaleList getExplicitLocaleList() {
85         return mExplicitLocales;
86     }
87 }
88