Files
app_Settings/src/com/android/settings/gestures/TapScreenGesturePreferenceController.java
Lucas Dupin 97b8aae933 Tap gesture settings
Tap setting is similar to double tap, it will wake-up the phone
when invoked. This setting page allows for configuration since both
gestures aren't mutually exclusive.

Change-Id: Ia62a1fafcc108e3c0b14613cb30224eae7b35f6a
Fixes: 121198822
Test: make RunSettingsRoboTests
2019-01-16 11:41:44 -08:00

89 lines
2.5 KiB
Java

/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.settings.gestures;
import static android.provider.Settings.Secure.DOZE_TAP_SCREEN_GESTURE;
import android.annotation.UserIdInt;
import android.content.Context;
import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;
import com.android.internal.hardware.AmbientDisplayConfiguration;
public class TapScreenGesturePreferenceController extends GesturePreferenceController {
private static final String PREF_KEY_VIDEO = "gesture_tap_screen_video";
private AmbientDisplayConfiguration mAmbientConfig;
@UserIdInt
private final int mUserId;
public TapScreenGesturePreferenceController(Context context, String key) {
super(context, key);
mUserId = UserHandle.myUserId();
}
public TapScreenGesturePreferenceController setConfig(AmbientDisplayConfiguration config) {
mAmbientConfig = config;
return this;
}
@Override
public int getAvailabilityStatus() {
// No hardware support for this Gesture
if (!getAmbientConfig().tapSensorAvailable()) {
return UNSUPPORTED_ON_DEVICE;
}
return AVAILABLE;
}
@Override
public boolean isSliceable() {
return true;
}
@Override
protected String getVideoPrefKey() {
return PREF_KEY_VIDEO;
}
@Override
public CharSequence getSummary() {
return super.getSummary();
}
@Override
public boolean isChecked() {
return getAmbientConfig().tapGestureEnabled(mUserId);
}
@Override
public boolean setChecked(boolean isChecked) {
return Settings.Secure.putInt(mContext.getContentResolver(), DOZE_TAP_SCREEN_GESTURE,
isChecked ? 1 : 0);
}
private AmbientDisplayConfiguration getAmbientConfig() {
if (mAmbientConfig == null) {
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
}
return mAmbientConfig;
}
}