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.deviceinfo.aboutphone 18 19 import android.content.Context 20 import android.os.Build 21 import android.provider.Settings 22 import com.android.settings.R 23 import com.android.settings.flags.Flags 24 import com.android.settingslib.metadata.PreferenceIconProvider 25 import com.android.settingslib.metadata.PreferenceSummaryProvider 26 import com.android.settingslib.metadata.ProvidePreferenceScreen 27 import com.android.settingslib.metadata.preferenceHierarchy 28 import com.android.settingslib.preference.PreferenceScreenCreator 29 import com.android.settingslib.widget.SettingsThemeHelper.isExpressiveTheme 30 31 @ProvidePreferenceScreen(MyDeviceInfoScreen.KEY) 32 class MyDeviceInfoScreen : 33 PreferenceScreenCreator, PreferenceSummaryProvider, PreferenceIconProvider { 34 override val key: String 35 get() = KEY 36 37 override val title: Int 38 get() = R.string.about_settings 39 getSummarynull40 override fun getSummary(context: Context): CharSequence? { 41 return Settings.Global.getString(context.contentResolver, Settings.Global.DEVICE_NAME) 42 ?: Build.MODEL 43 } 44 getIconnull45 override fun getIcon(context: Context) = 46 when { 47 isExpressiveTheme(context) -> R.drawable.ic_homepage_about 48 Flags.homepageRevamp() -> R.drawable.ic_settings_about_device_filled 49 else -> R.drawable.ic_settings_about_device 50 } 51 isFlagEnablednull52 override fun isFlagEnabled(context: Context) = Flags.catalystMyDeviceInfoPrefScreen() 53 54 override fun fragmentClass() = MyDeviceInfoFragment::class.java 55 56 override fun getPreferenceHierarchy(context: Context) = preferenceHierarchy(context, this) {} 57 hasCompleteHierarchynull58 override fun hasCompleteHierarchy() = false 59 60 companion object { 61 const val KEY = "my_device_info_pref_screen" 62 } 63 } 64