2 * Copyright (C) 2015 The CyanogenMod Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package org
.lineageos
.settings
.doze
;
19 import android
.app
.ActionBar
;
20 import android
.os
.Bundle
;
21 import android
.provider
.Settings
;
22 import android
.view
.MenuItem
;
23 import androidx
.preference
.Preference
;
24 import androidx
.preference
.PreferenceFragment
;
25 import androidx
.preference
.SwitchPreference
;
27 import org
.lineageos
.internal
.util
.ScreenType
;
29 public class TouchscreenGestureSettings
extends PreferenceFragment
{
31 private static final String KEY_HAND_WAVE
= "gesture_hand_wave";
32 private static final String KEY_PROXIMITY_WAKE
= "proximity_wake_enable";
34 private SwitchPreference mHandwavePreference
;
35 private SwitchPreference mProximityWakePreference
;
38 public void onCreatePreferences(Bundle savedInstanceState
, String rootKey
) {
39 addPreferencesFromResource(R
.xml
.gesture_panel
);
40 final ActionBar actionBar
= getActivity().getActionBar();
41 actionBar
.setDisplayHomeAsUpEnabled(true);
44 (SwitchPreference
) findPreference(KEY_HAND_WAVE
);
45 mHandwavePreference
.setOnPreferenceChangeListener(mProximityListener
);
46 mProximityWakePreference
=
47 (SwitchPreference
) findPreference(KEY_PROXIMITY_WAKE
);
48 mProximityWakePreference
.setOnPreferenceChangeListener(mProximityListener
);
52 public void onResume() {
55 // If running on a phone, remove padding around the listview
56 if (!ScreenType
.isTablet(getContext())) {
57 getListView().setPadding(0, 0, 0, 0);
61 private Preference
.OnPreferenceChangeListener mProximityListener
=
62 new Preference
.OnPreferenceChangeListener() {
64 public boolean onPreferenceChange(Preference preference
, Object newValue
) {
65 if ((boolean) newValue
) {
66 if (preference
.getKey().equals(KEY_HAND_WAVE
)) {
67 mProximityWakePreference
.setChecked(false);
68 } else if (preference
.getKey().equals(KEY_PROXIMITY_WAKE
)) {
69 mHandwavePreference
.setChecked(false);
77 public boolean onOptionsItemSelected(MenuItem item
) {
78 if (item
.getItemId() == android
.R
.id
.home
) {
79 getActivity().onBackPressed();