summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.mk1
-rw-r--r--AndroidManifest-common.xml4
-rw-r--r--src/com/android/launcher3/touch/WorkspaceTouchListener.java19
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;
+ }
}