1 /*
2  * Copyright (C) 2019 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.role.ui;
18 
19 import android.content.Context;
20 import android.util.AttributeSet;
21 
22 import androidx.annotation.AttrRes;
23 import androidx.annotation.NonNull;
24 import androidx.annotation.Nullable;
25 import androidx.annotation.StyleRes;
26 import androidx.preference.Preference;
27 
28 /**
29  * {@link Preference} with the widget layout as a separate target.
30  *
31  * @see com.android.settingslib.TwoTargetPreference
32  */
33 public abstract class TwoTargetPreference extends Preference {
34 
TwoTargetPreference(@onNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr, @StyleRes int defStyleRes)35     public TwoTargetPreference(@NonNull Context context, @Nullable AttributeSet attrs,
36             @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
37         super(context, attrs, defStyleAttr, defStyleRes);
38     }
39 
TwoTargetPreference(@onNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr)40     public TwoTargetPreference(@NonNull Context context, @Nullable AttributeSet attrs,
41             @AttrRes int defStyleAttr) {
42         super(context, attrs, defStyleAttr);
43     }
44 
TwoTargetPreference(@onNull Context context, @Nullable AttributeSet attrs)45     public TwoTargetPreference(@NonNull Context context, @Nullable AttributeSet attrs) {
46         super(context, attrs);
47     }
48 
TwoTargetPreference(@onNull Context context)49     public TwoTargetPreference(@NonNull Context context) {
50         super(context);
51     }
52 
53     /**
54      * Set the listener for second target click.
55      *
56      * @param listener the listener
57      */
setOnSecondTargetClickListener( @ullable OnSecondTargetClickListener listener)58     public abstract void setOnSecondTargetClickListener(
59             @Nullable OnSecondTargetClickListener listener);
60 
61     /**
62      * Listener for second target click.
63      */
64     public interface OnSecondTargetClickListener {
65 
66         /**
67          * Callback when the second target is clicked.
68          *
69          * @param preference the {@link TwoTargetPreference} that was clicked
70          */
onSecondTargetClick(@onNull TwoTargetPreference preference)71         void onSecondTargetClick(@NonNull TwoTargetPreference preference);
72     }
73 }
74