1 /* 2 * Copyright (C) 2020 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 android.widget.TextView 22 import androidx.preference.Preference 23 import androidx.preference.PreferenceViewHolder 24 import com.android.permissioncontroller.R 25 26 /** 27 * A Preference for the footer of a screen. Has two summaries, and adjusted spacing and icon 28 * placement. 29 */ 30 class FooterPreference : Preference { 31 constructor(c: Context): super(c) 32 constructor(c: Context, a: AttributeSet): super(c, a) 33 constructor(c: Context, a: AttributeSet, attr: Int): super(c, a, attr) 34 constructor(c: Context, a: AttributeSet, attr: Int, res: Int): super(c, a, attr, res) 35 36 init { 37 layoutResource = R.layout.footer_preference 38 } 39 var secondSummary: CharSequence = "" 40 set(value) { 41 secondSummaryView?.text = value 42 field = value 43 notifyChanged() 44 } 45 46 private var secondSummaryView: TextView? = null 47 onBindViewHoldernull48 override fun onBindViewHolder(holder: PreferenceViewHolder) { 49 secondSummaryView = holder.findViewById(R.id.summary2) as TextView 50 secondSummaryView?.text = secondSummary 51 super.onBindViewHolder(holder) 52 } 53 } 54