1 /*
2  * Copyright (C) 2021 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.car.ui.preference;
18 
19 import androidx.annotation.Nullable;
20 import androidx.preference.Preference;
21 
22 import java.util.function.Consumer;
23 
24 /**
25  * An interface for preferences that can be clicked while disabled.
26  *
27  * These preference will appear disabled but will still perform an action when clicked.
28  */
29 @SuppressWarnings("AndroidJdkLibsChecker")
30 public interface ClickableWhileDisabledPreference {
31     /** Sets this preference as clickable while disabled or not */
setClickableWhileDisabled(boolean clickableWhileDisabled)32     void setClickableWhileDisabled(boolean clickableWhileDisabled);
33 
34     /** Returns if this preference is currently clickable while disabled. */
isClickableWhileDisabled()35     boolean isClickableWhileDisabled();
36 
37     /** Sets a listener to be called if the preference is clicked while it is disabled */
setDisabledClickListener(@ullable Consumer<Preference> listener)38     void setDisabledClickListener(@Nullable Consumer<Preference> listener);
39 
40     /** Gets the listener to be called if the preference is clicked while it is disabled */
41     @Nullable
getDisabledClickListener()42     Consumer<Preference> getDisabledClickListener();
43 }
44