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.fuelgauge.batterysaver 17 18 import android.content.Context 19 import com.android.settings.R 20 import com.android.settings.Settings.BatterySaverSettingsActivity 21 import com.android.settings.flags.Flags 22 import com.android.settings.utils.makeLaunchIntent 23 import com.android.settingslib.metadata.PreferenceMetadata 24 import com.android.settingslib.metadata.ProvidePreferenceScreen 25 import com.android.settingslib.metadata.preferenceHierarchy 26 import com.android.settingslib.preference.PreferenceScreenCreator 27 28 @ProvidePreferenceScreen(BatterySaverScreen.KEY) 29 open class BatterySaverScreen : PreferenceScreenCreator { 30 override val key: String 31 get() = KEY 32 33 override val title: Int 34 get() = R.string.battery_saver 35 36 override val keywords: Int 37 get() = R.string.keywords_battery_saver 38 isFlagEnablednull39 override fun isFlagEnabled(context: Context) = Flags.catalystBatterySaverScreen() 40 41 override fun fragmentClass() = BatterySaverSettings::class.java 42 43 override fun hasCompleteHierarchy() = false 44 45 override fun getPreferenceHierarchy(context: Context) = 46 preferenceHierarchy(context, this) { +BatterySaverPreference() order -100 } 47 getLaunchIntentnull48 override fun getLaunchIntent(context: Context, metadata: PreferenceMetadata?) = 49 makeLaunchIntent(context, BatterySaverSettingsActivity::class.java, metadata?.key) 50 51 companion object { 52 const val KEY = "battery_saver_screen" 53 } 54 } 55