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 SystemLocaleSuggestedListPreferenceController extends 30 LocalePickerBaseListPreferenceController { 31 private static final String KEY_PREFERENCE_CATEGORY_ADD_A_LANGUAGE_SUGGESTED = 32 "system_language_suggested_category"; 33 private static final String KEY_PREFERENCE_SYSTEM_LOCALE_SUGGESTED_LIST = 34 "system_locale_suggested_list"; 35 36 @Nullable private LocaleStore.LocaleInfo mLocaleInfo; 37 private boolean mIsNumberingSystemMode; 38 SystemLocaleSuggestedListPreferenceController(@onNull Context context, @NonNull String preferenceKey)39 public SystemLocaleSuggestedListPreferenceController(@NonNull Context context, 40 @NonNull String preferenceKey) { 41 super(context, preferenceKey); 42 } 43 SystemLocaleSuggestedListPreferenceController(@onNull Context context, @NonNull String preferenceKey, @NonNull LocaleStore.LocaleInfo parentLocale, boolean isNumberingSystemMode)44 public SystemLocaleSuggestedListPreferenceController(@NonNull Context context, 45 @NonNull String preferenceKey, 46 @NonNull LocaleStore.LocaleInfo parentLocale, boolean isNumberingSystemMode) { 47 super(context, preferenceKey); 48 mLocaleInfo = parentLocale; 49 mIsNumberingSystemMode = isNumberingSystemMode; 50 } 51 52 @Override getPreferenceCategoryKey()53 protected @NonNull String getPreferenceCategoryKey() { 54 return KEY_PREFERENCE_CATEGORY_ADD_A_LANGUAGE_SUGGESTED; 55 } 56 57 @Override getPreferenceKey()58 public @NonNull String getPreferenceKey() { 59 return KEY_PREFERENCE_SYSTEM_LOCALE_SUGGESTED_LIST; 60 } 61 62 @Override getLocaleCollectorController(Context context)63 protected LocaleCollectorBase getLocaleCollectorController(Context context) { 64 return new SystemLocaleCollector(context, getExplicitLocaleList()); 65 } 66 67 @Override getParentLocale()68 protected @Nullable LocaleStore.LocaleInfo getParentLocale() { 69 return mLocaleInfo; 70 } 71 72 @Override isNumberingMode()73 protected boolean isNumberingMode() { 74 return mIsNumberingSystemMode; 75 } 76 77 @Override getExplicitLocaleList()78 protected @Nullable LocaleList getExplicitLocaleList() { 79 return null; 80 } 81 } 82