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 androidx.annotation.NonNull;
20 import androidx.annotation.Nullable;
21 import androidx.preference.Preference;
22 
23 /**
24  * {@link androidx.preference.Preference} with the widget layout as a separate target.
25  *
26  * This has to be an interface because we may need to extend from either the SettingsLib
27  * {@link com.android.settingslib.widget.TwoTargetPreference} or the AndroidX
28  * {@link androidx.preference.Preference}.
29  *
30  * @see com.android.settingslib.widget.TwoTargetPreference
31  */
32 public interface TwoTargetPreference {
33 
34     /**
35      * Set the listener for second target click.
36      *
37      * @param listener the listener
38      */
setOnSecondTargetClickListener(@ullable OnSecondTargetClickListener listener)39     void setOnSecondTargetClickListener(@Nullable OnSecondTargetClickListener listener);
40 
41     /**
42      * Return this preference as {@link Preference}.
43      */
44     @NonNull
asPreference()45     Preference asPreference();
46 
47     /**
48      * Listener for second target click.
49      */
50     interface OnSecondTargetClickListener {
51 
52         /**
53          * Callback when the second target is clicked.
54          *
55          * @param preference the {@link TwoTargetPreference} that was clicked
56          */
onSecondTargetClick(@onNull TwoTargetPreference preference)57         void onSecondTargetClick(@NonNull TwoTargetPreference preference);
58     }
59 }
60