1 /* 2 * Copyright 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 package com.android.car.ui.preference; 17 18 import androidx.annotation.Nullable; 19 import androidx.preference.Preference; 20 21 import java.util.function.Consumer; 22 23 /** 24 * An interface for preferences that can be ux restricted. 25 * 26 * A ux restricted preference will be displayed differently to indicate such, and will 27 * display a toast message informing the user they cannot click it when they try to. 28 */ 29 @SuppressWarnings("AndroidJdkLibsChecker") 30 public interface UxRestrictablePreference { 31 32 /** Sets this preference as ux restricted or not */ setUxRestricted(boolean restricted)33 void setUxRestricted(boolean restricted); 34 35 /** Returns if this preference is currently ux restricted */ isUxRestricted()36 boolean isUxRestricted(); 37 38 /** Sets a listener to be called if the preference is clicked while it is ux restricted */ setOnClickWhileRestrictedListener(@ullable Consumer<Preference> listener)39 void setOnClickWhileRestrictedListener(@Nullable Consumer<Preference> listener); 40 41 /** Gets the listener to be called if the preference is clicked while it is ux restricted */ 42 @Nullable getOnClickWhileRestrictedListener()43 Consumer<Preference> getOnClickWhileRestrictedListener(); 44 } 45