Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2178a42e authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Gerrit Code Review
Browse files

Merge "SystemUI: Add double tap to sleep gesture" into cm-11.0

parents cfaa80a3 f258f447
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -3362,6 +3362,12 @@ public final class Settings {
         */
        public static final String LOCKSCREEN_VIBRATE_ENABLED = "lockscreen.vibrate_enabled";

        /**
         *  Enable statusbar double tap gesture on to put device to sleep
         * @hide
         */
        public static final String DOUBLE_TAP_SLEEP_GESTURE = "double_tap_sleep_gesture";

        /**
         * Settings to backup. This is here so that it's in the same place as the settings
         * keys and easy to update.
+22 −0
Original line number Diff line number Diff line
@@ -26,6 +26,9 @@ import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
import android.view.GestureDetector;
import android.os.PowerManager;
import android.provider.Settings;

import com.android.systemui.EventLogTags;
import com.android.systemui.R;
@@ -46,6 +49,7 @@ public class PhoneStatusBarView extends PanelBar {
    PanelView mNotificationPanel, mSettingsPanel;
    private boolean mShouldFade;
    private final PhoneStatusBarTransitions mBarTransitions;
    private GestureDetector mDoubleTapGesture;

    public PhoneStatusBarView(Context context, AttributeSet attrs) {
        super(context, attrs);
@@ -60,6 +64,20 @@ public class PhoneStatusBarView extends PanelBar {
        }
        mFullWidthNotifications = mSettingsPanelDragzoneFrac <= 0f;
        mBarTransitions = new PhoneStatusBarTransitions(this);

        mDoubleTapGesture = new GestureDetector(mContext, new GestureDetector.SimpleOnGestureListener() {
            @Override
            public boolean onDoubleTap(MotionEvent e) {
                PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
                Log.d(TAG, "Gesture!!");
                if(pm != null)
                    pm.goToSleep(e.getEventTime());
                else
                    Log.d(TAG, "getSystemService returned null PowerManager");

                return true;
            }
        });
    }

    public BarTransitions getBarTransitions() {
@@ -198,6 +216,10 @@ public class PhoneStatusBarView extends PanelBar {
            }
        }

        if (Settings.System.getInt(mContext.getContentResolver(),
                    Settings.System.DOUBLE_TAP_SLEEP_GESTURE, 0) == 1)
            mDoubleTapGesture.onTouchEvent(event);

        return barConsumedEvent || super.onTouchEvent(event);
    }