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