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 package com.android.settings.security
17 
18 import android.content.Context
19 import com.android.settings.R
20 import com.android.settings.Settings.LockScreenSettingsActivity
21 import com.android.settings.display.AmbientDisplayAlwaysOnPreference
22 import com.android.settings.flags.Flags
23 import com.android.settings.notification.LockScreenNotificationPreferenceController
24 import com.android.settings.utils.makeLaunchIntent
25 import com.android.settingslib.metadata.PreferenceMetadata
26 import com.android.settingslib.metadata.PreferenceSummaryProvider
27 import com.android.settingslib.metadata.ProvidePreferenceScreen
28 import com.android.settingslib.metadata.preferenceHierarchy
29 import com.android.settingslib.preference.PreferenceScreenCreator
30 
31 @ProvidePreferenceScreen
32 open class LockScreenPreferenceScreen : PreferenceScreenCreator, PreferenceSummaryProvider {
33     override val key: String
34         get() = KEY
35 
36     override val title: Int
37         get() = R.string.lockscreen_settings_title
38 
39     override val keywords: Int
40         get() = R.string.keywords_ambient_display_screen
41 
getSummarynull42     override fun getSummary(context: Context): CharSequence? =
43         context.getString(LockScreenNotificationPreferenceController.getSummaryResource(context))
44 
45     override fun isFlagEnabled(context: Context) = Flags.catalystLockscreenFromDisplaySettings()
46 
47     override fun hasCompleteHierarchy() = false
48 
49     override fun fragmentClass() = LockscreenDashboardFragment::class.java
50 
51     override fun getLaunchIntent(context: Context, metadata: PreferenceMetadata?) =
52         makeLaunchIntent(context, LockScreenSettingsActivity::class.java, metadata?.key)
53 
54     override fun getPreferenceHierarchy(context: Context) =
55         preferenceHierarchy(this) {
56             +AmbientDisplayAlwaysOnPreference()
57         }
58 
59     companion object {
60         const val KEY = "lockscreen_from_display_settings"
61     }
62 }
63