diff options
author | Thecrazyskull <anaskarbila@gmail.com> | 2017-02-10 09:38:50 -0500 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2022-05-07 00:20:58 +0800 |
commit | 505a0dc4a835333fc1e128cb9f5b515bcfe55952 (patch) | |
tree | 6ac26bedc036340cf4eabdbef1099f4bbd94a5c0 | |
parent | 97cd71cae82ce09a411a848a1f61a3eaf83f84dd (diff) |
Launcher3: Double tap on home screen to turn off screen
Co-authored-by: LibXZR <i@xzr.moe>
Change-Id: I554c005d5e523aca0842c78a353686e86af1a7f2
-rw-r--r-- | Android.mk | 1 | ||||
-rw-r--r-- | AndroidManifest-common.xml | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/touch/WorkspaceTouchListener.java | 19 |
3 files changed, 23 insertions, 1 deletions
diff --git a/Android.mk b/Android.mk index 8105d58b4b..40f3874ea3 100644 --- a/Android.mk +++ b/Android.mk @@ -69,6 +69,7 @@ else LOCAL_MIN_SDK_VERSION := 26 endif LOCAL_PACKAGE_NAME := Launcher3QuickStep +LOCAL_CERTIFICATE := platform LOCAL_PRIVILEGED_MODULE := true LOCAL_SYSTEM_EXT_MODULE := true LOCAL_OVERRIDES_PACKAGES := Home Launcher2 Launcher3 diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml index a929c14704..364e52a24b 100644 --- a/AndroidManifest-common.xml +++ b/AndroidManifest-common.xml @@ -41,7 +41,9 @@ <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" /> <!-- for rotating surface by arbitrary degree --> <uses-permission android:name="android.permission.ROTATE_SURFACE_FLINGER" /> - + <!-- for double tap to sleep --> + <uses-permission android:name="android.permission.DEVICE_POWER" /> + <!-- Permissions required for read/write access to the workspace data. These permission name should not conflict with that defined in other apps, as such an app should embed its package diff --git a/src/com/android/launcher3/touch/WorkspaceTouchListener.java b/src/com/android/launcher3/touch/WorkspaceTouchListener.java index 20d2ad36a5..de484de283 100644 --- a/src/com/android/launcher3/touch/WorkspaceTouchListener.java +++ b/src/com/android/launcher3/touch/WorkspaceTouchListener.java @@ -15,6 +15,8 @@ */ package com.android.launcher3.touch; +import static android.provider.Settings.Secure.DOUBLE_TAP_SLEEP_GESTURE; + import static android.view.MotionEvent.ACTION_CANCEL; import static android.view.MotionEvent.ACTION_DOWN; import static android.view.MotionEvent.ACTION_MOVE; @@ -24,8 +26,12 @@ import static android.view.MotionEvent.ACTION_UP; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_WORKSPACE_LONGPRESS; +import android.content.ContentResolver; +import android.content.Context; import android.graphics.PointF; import android.graphics.Rect; +import android.os.PowerManager; +import android.provider.Settings; import android.view.GestureDetector; import android.view.HapticFeedbackConstants; import android.view.MotionEvent; @@ -67,15 +73,21 @@ public class WorkspaceTouchListener extends GestureDetector.SimpleOnGestureListe private int mLongPressState = STATE_CANCELLED; + private final PowerManager mPm; + private final GestureDetector mGestureDetector; + private final ContentResolver mContentResolver; + public WorkspaceTouchListener(Launcher launcher, Workspace workspace) { mLauncher = launcher; mWorkspace = workspace; // Use twice the touch slop as we are looking for long press which is more // likely to cause movement. mTouchSlop = 2 * ViewConfiguration.get(launcher).getScaledTouchSlop(); + mPm = (PowerManager) workspace.getContext().getSystemService(Context.POWER_SERVICE); mGestureDetector = new GestureDetector(workspace.getContext(), this); + mContentResolver = workspace.getContext().getContentResolver(); } @Override @@ -180,4 +192,11 @@ public class WorkspaceTouchListener extends GestureDetector.SimpleOnGestureListe } } } + + @Override + public boolean onDoubleTap(MotionEvent event) { + if (Settings.Secure.getInt(mContentResolver, DOUBLE_TAP_SLEEP_GESTURE, 0) == 1) + mPm.goToSleep(event.getEventTime()); + return true; + } } |