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.car.developeroptions.gestures;
18 
19 import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
20 
21 import android.content.Context;
22 import android.content.om.IOverlayManager;
23 import android.os.ServiceManager;
24 import android.text.TextUtils;
25 
26 import androidx.annotation.VisibleForTesting;
27 
28 import com.android.car.developeroptions.widget.RadioButtonPreference;
29 
30 public class SystemNavigationEdgeToEdgePreferenceController extends
31         SystemNavigationPreferenceController {
32     static final String PREF_KEY_EDGE_TO_EDGE = "gesture_edge_to_edge";
33 
SystemNavigationEdgeToEdgePreferenceController(Context context, String key)34     public SystemNavigationEdgeToEdgePreferenceController(Context context, String key) {
35         this(context, IOverlayManager.Stub.asInterface(ServiceManager.getService(
36                 Context.OVERLAY_SERVICE)), key);
37     }
38 
39     @VisibleForTesting
SystemNavigationEdgeToEdgePreferenceController(Context context, IOverlayManager overlayManager, String key)40     public SystemNavigationEdgeToEdgePreferenceController(Context context,
41             IOverlayManager overlayManager, String key) {
42         super(context, overlayManager, key);
43     }
44 
45     @Override
isSliceable()46     public boolean isSliceable() {
47         return TextUtils.equals(PREF_KEY_EDGE_TO_EDGE, getPreferenceKey());
48     }
49 
50     @Override
onRadioButtonClicked(RadioButtonPreference preference)51     public void onRadioButtonClicked(RadioButtonPreference preference) {
52         setNavBarInteractionMode(mOverlayManager, NAV_BAR_MODE_GESTURAL_OVERLAY);
53         selectRadioButtonInGroup(PREF_KEY_EDGE_TO_EDGE, mPreferenceScreen);
54     }
55 
56     @Override
isChecked()57     public boolean isChecked() {
58         return isEdgeToEdgeEnabled(mContext);
59     }
60 }
61