blob: 32a7ba55158ef891362e80727f0b32c0899beec0 [file] [log] [blame]
Aaron Heuckroth2659c0f2019-05-02 11:04:42 -04001/*
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
17package com.android.settings.gestures;
18
19import android.content.Context;
20import android.provider.Settings;
21import android.text.TextUtils;
22
23import com.android.internal.annotations.VisibleForTesting;
24
25public class GlobalActionsPanelPreferenceController extends GesturePreferenceController {
26 private static final String PREF_KEY_VIDEO = "global_actions_panel_video";
27
Aaron Heuckroth2659c0f2019-05-02 11:04:42 -040028 @VisibleForTesting
Aran Inkb8e81542019-05-07 16:36:56 -040029 protected static final String ENABLED_SETTING = Settings.Secure.GLOBAL_ACTIONS_PANEL_ENABLED;
Aaron Heuckroth2659c0f2019-05-02 11:04:42 -040030 @VisibleForTesting
Aran Inkb8e81542019-05-07 16:36:56 -040031 protected static final String AVAILABLE_SETTING =
32 Settings.Secure.GLOBAL_ACTIONS_PANEL_AVAILABLE;
Aaron Heuckroth2659c0f2019-05-02 11:04:42 -040033
34 @VisibleForTesting
35 protected static final String TOGGLE_KEY = "gesture_global_actions_panel_switch";
36
37 public GlobalActionsPanelPreferenceController(Context context, String key) {
38 super(context, key);
39 }
40
41 @Override
42 public int getAvailabilityStatus() {
43 int enabled = Settings.Secure.getInt(mContext.getContentResolver(), AVAILABLE_SETTING, 0);
44 return enabled == 1 ? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
45 }
46
47 @Override
48 public boolean setChecked(boolean isChecked) {
49 return Settings.Secure.putInt(mContext.getContentResolver(), ENABLED_SETTING,
50 isChecked ? 1 : 0);
51 }
52
53 @Override
54 protected String getVideoPrefKey() {
55 return PREF_KEY_VIDEO;
56 }
57
58 @Override
59 public boolean isSliceable() {
60 return TextUtils.equals(getPreferenceKey(), TOGGLE_KEY);
61 }
62
63 @Override
Yi-Ling Chuang1089f7c2019-11-27 17:14:17 +080064 public boolean isPublicSlice() {
65 return true;
66 }
67
68 @Override
Aaron Heuckroth2659c0f2019-05-02 11:04:42 -040069 public boolean isChecked() {
70 int enabled = Settings.Secure.getInt(mContext.getContentResolver(), ENABLED_SETTING, 0);
71 return enabled == 1;
72 }
73}