• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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.settings.gestures;
18 
19 import android.content.Context;
20 import android.provider.Settings;
21 import android.support.v7.preference.Preference;
22 
23 import com.android.settings.core.lifecycle.Lifecycle;
24 
25 public class SwipeToNotificationPreferenceController extends GesturePreferenceController {
26 
27     private static final String PREF_KEY_VIDEO = "gesture_swipe_down_fingerprint_video";
28     private final String mSwipeDownFingerPrefKey;
29 
SwipeToNotificationPreferenceController(Context context, Lifecycle lifecycle, String key)30     public SwipeToNotificationPreferenceController(Context context, Lifecycle lifecycle,
31             String key) {
32         super(context, lifecycle);
33         mSwipeDownFingerPrefKey = key;
34     }
35 
36     @Override
getPreferenceKey()37     public String getPreferenceKey() {
38         return mSwipeDownFingerPrefKey;
39     }
40 
41     @Override
getVideoPrefKey()42     protected String getVideoPrefKey() {
43         return PREF_KEY_VIDEO;
44     }
45 
46     @Override
isAvailable()47     public boolean isAvailable() {
48         return mContext.getResources().getBoolean(
49                 com.android.internal.R.bool.config_supportSystemNavigationKeys);
50     }
51 
52     @Override
onPreferenceChange(Preference preference, Object newValue)53     public boolean onPreferenceChange(Preference preference, Object newValue) {
54         Settings.Secure.putInt(mContext.getContentResolver(),
55                 Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, (boolean) newValue ? 1 : 0);
56         return true;
57     }
58 
59     @Override
isSwitchPrefEnabled()60     protected boolean isSwitchPrefEnabled() {
61         return Settings.Secure.getInt(mContext.getContentResolver(),
62                 Settings.Secure.SYSTEM_NAVIGATION_KEYS_ENABLED, 0)
63                 == 1;
64     }
65 }
66