1 /*
2  * Copyright (C) 2023 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.settingslib.drawer;
18 
19 /**
20  *  Interface for {@link EntryController} whose instances support switch widget provided from the
21  *  content provider
22  */
23 public interface ProviderSwitch {
24     /**
25      * Returns the checked state of this switch.
26      */
isSwitchChecked()27     boolean isSwitchChecked();
28 
29     /**
30      * Called when the checked state of this switch is changed.
31      *
32      * @return true if the checked state was successfully changed, otherwise false
33      */
onSwitchCheckedChanged(boolean checked)34     boolean onSwitchCheckedChanged(boolean checked);
35 
36     /**
37      * Returns the error message which will be toasted when {@link #onSwitchCheckedChanged} returns
38      * false.
39      */
getSwitchErrorMessage(boolean attemptedChecked)40     String getSwitchErrorMessage(boolean attemptedChecked);
41 }
42