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.permissioncontroller.permission.ui.handheld 18 19 import android.content.Context 20 import android.util.AttributeSet 21 import androidx.annotation.AttrRes 22 import androidx.annotation.StyleRes 23 import androidx.preference.PreferenceCategory 24 import com.android.modules.utils.build.SdkLevel 25 import com.android.permissioncontroller.DeviceUtils 26 import com.android.permissioncontroller.R 27 28 open class PermissionPreferenceCategory : PreferenceCategory { 29 constructor(context: Context) : super(context) 30 31 constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) 32 33 constructor( 34 context: Context, 35 attrs: AttributeSet?, 36 @AttrRes defStyleAttr: Int, 37 ) : super(context, attrs, defStyleAttr) 38 39 constructor( 40 context: Context, 41 attrs: AttributeSet?, 42 @AttrRes defStyleAttr: Int, 43 @StyleRes defStyleRes: Int, 44 ) : super(context, attrs, defStyleAttr, defStyleRes) 45 46 init { 47 if (SdkLevel.isAtLeastV() && DeviceUtils.isHandheld(context)) { 48 layoutResource = R.layout.permission_preference_category 49 } 50 } 51 } 52