Merge changes I7b9e6e7f,I9729cd40 into sc-dev
* changes:
2/ Notify adjust touch slop when one handed mode activated
1/ Provides feasibility to adjust touch slop in TouchController
diff --git a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java
index eb62110..283743d 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/NoButtonNavbarToOverviewTouchController.java
@@ -51,7 +51,7 @@
* first home screen instead of to Overview.
*/
public class NoButtonNavbarToOverviewTouchController extends PortraitStatesTouchController {
-
+ private static final float ONE_HANDED_ACTIVATED_SLOP_MULTIPLIER = 2.5f;
// How much of the movement to use for translating overview after swipe and hold.
private static final float OVERVIEW_MOVEMENT_FACTOR = 0.25f;
@@ -260,4 +260,14 @@
private float dpiFromPx(float pixels) {
return Utilities.dpiFromPx(pixels, mLauncher.getResources().getDisplayMetrics().densityDpi);
}
+
+ @Override
+ public void onOneHandedModeStateChanged(boolean activated) {
+ if (activated) {
+ mDetector.setTouchSlopMultiplier(ONE_HANDED_ACTIVATED_SLOP_MULTIPLIER);
+ } else {
+ // Reset touch slop multiplier to default 1.0f
+ mDetector.setTouchSlopMultiplier(1f /* default */);
+ }
+ }
}
diff --git a/quickstep/src/com/android/quickstep/BaseActivityInterface.java b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
index 4ae6fa8..7ab371b 100644
--- a/quickstep/src/com/android/quickstep/BaseActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/BaseActivityInterface.java
@@ -114,6 +114,9 @@
public abstract void onAssistantVisibilityChanged(float visibility);
+ /** Called when one handed mode activated or deactivated. */
+ public abstract void onOneHandedModeStateChanged(boolean activated);
+
public abstract AnimationFactory prepareRecentsUI(RecentsAnimationDeviceState deviceState,
boolean activityVisible, Consumer<AnimatorControllerWithResistance> callback);
diff --git a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java
index 4ee4398..906599f 100644
--- a/quickstep/src/com/android/quickstep/FallbackActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/FallbackActivityInterface.java
@@ -73,6 +73,11 @@
// set to zero prior to this class becoming active.
}
+ @Override
+ public void onOneHandedModeStateChanged(boolean activated) {
+ // Do nothing for FallbackActivityInterface
+ }
+
/** 6 */
@Override
public AnimationFactory prepareRecentsUI(RecentsAnimationDeviceState deviceState,
diff --git a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java
index 9014774..30abfbb 100644
--- a/quickstep/src/com/android/quickstep/LauncherActivityInterface.java
+++ b/quickstep/src/com/android/quickstep/LauncherActivityInterface.java
@@ -105,6 +105,15 @@
}
@Override
+ public void onOneHandedModeStateChanged(boolean activated) {
+ Launcher launcher = getCreatedActivity();
+ if (launcher == null) {
+ return;
+ }
+ launcher.onOneHandedStateChanged(activated);
+ }
+
+ @Override
public AnimationFactory prepareRecentsUI(RecentsAnimationDeviceState deviceState,
boolean activityVisible, Consumer<AnimatorControllerWithResistance> callback) {
notifyRecentsOfOrientation(deviceState.getRotationTouchHelper());
diff --git a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java
index fb8f9fe..0efe666 100644
--- a/quickstep/src/com/android/quickstep/OverviewComponentObserver.java
+++ b/quickstep/src/com/android/quickstep/OverviewComponentObserver.java
@@ -111,6 +111,11 @@
if (mDeviceState.isHomeDisabled() != mIsHomeDisabled) {
updateOverviewTargets();
}
+
+ // Notify ALL_APPS touch controller when one handed mode state activated or deactivated
+ if (mDeviceState.isOneHandedModeEnabled()) {
+ mActivityInterface.onOneHandedModeStateChanged(mDeviceState.isOneHandedModeActive());
+ }
}
private void updateOverviewTargets(Intent unused) {
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 8889e60..299c68f 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -576,6 +576,14 @@
mHotseat.getQsb().setAlpha(1f - visibility);
}
+ /**
+ * Called when one handed mode activated and deactivated.
+ * @param activated true if one handed mode activated, false otherwise.
+ */
+ public void onOneHandedStateChanged(boolean activated) {
+ mDragLayer.onOneHandedModeStateChanged(activated);
+ }
+
private void initDeviceProfile(InvariantDeviceProfile idp) {
// Load configuration-specific DeviceProfile
mDeviceProfile = idp.getDeviceProfile(this);
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index c2f609c..011325d 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -48,6 +48,7 @@
import com.android.launcher3.graphics.Scrim;
import com.android.launcher3.keyboard.ViewGroupFocusHelper;
import com.android.launcher3.util.Thunk;
+import com.android.launcher3.util.TouchController;
import com.android.launcher3.views.BaseDragLayer;
import java.util.ArrayList;
@@ -519,4 +520,14 @@
public Scrim getWorkspaceDragScrim() {
return mWorkspaceDragScrim;
}
+
+ /**
+ * Called when one handed mode state changed.
+ * @param activated true if one handed mode activated, false otherwise.
+ */
+ public void onOneHandedModeStateChanged(boolean activated) {
+ for (TouchController controller : mControllers) {
+ controller.onOneHandedModeStateChanged(activated);
+ }
+ }
}
diff --git a/src/com/android/launcher3/touch/SingleAxisSwipeDetector.java b/src/com/android/launcher3/touch/SingleAxisSwipeDetector.java
index 8c3c115..f751b7d 100644
--- a/src/com/android/launcher3/touch/SingleAxisSwipeDetector.java
+++ b/src/com/android/launcher3/touch/SingleAxisSwipeDetector.java
@@ -102,6 +102,8 @@
private int mScrollDirections;
+ private float mTouchSlopMultiplier = 1f;
+
public SingleAxisSwipeDetector(@NonNull Context context, @NonNull Listener l,
@NonNull Direction dir) {
this(ViewConfiguration.get(context), l, dir, Utilities.isRtl(context.getResources()));
@@ -115,6 +117,19 @@
mDir = dir;
}
+ /**
+ * Provides feasibility to adjust touch slop when visible window size changed. When visible
+ * bounds translate become smaller, multiply a larger multiplier could ensure the UX
+ * more consistent.
+ *
+ * @see #shouldScrollStart(PointF)
+ *
+ * @param touchSlopMultiplier the value to multiply original touch slop.
+ */
+ public void setTouchSlopMultiplier(float touchSlopMultiplier) {
+ mTouchSlopMultiplier = touchSlopMultiplier;
+ }
+
public void setDetectableScrollConditions(int scrollDirectionFlags, boolean ignoreSlop) {
mScrollDirections = scrollDirectionFlags;
mIgnoreSlopWhenSettling = ignoreSlop;
@@ -133,7 +148,7 @@
@Override
protected boolean shouldScrollStart(PointF displacement) {
// Reject cases where the angle or slop condition is not met.
- float minDisplacement = Math.max(mTouchSlop,
+ float minDisplacement = Math.max(mTouchSlop * mTouchSlopMultiplier,
Math.abs(mDir.extractOrthogonalDirection(displacement)));
if (Math.abs(mDir.extractDirection(displacement)) < minDisplacement) {
return false;
diff --git a/src/com/android/launcher3/util/TouchController.java b/src/com/android/launcher3/util/TouchController.java
index fc1d819..9c397c0 100644
--- a/src/com/android/launcher3/util/TouchController.java
+++ b/src/com/android/launcher3/util/TouchController.java
@@ -32,5 +32,10 @@
*/
boolean onControllerInterceptTouchEvent(MotionEvent ev);
+ /**
+ * Called when one handed mode state changed
+ */
+ default void onOneHandedModeStateChanged(boolean activated) { }
+
default void dump(String prefix, PrintWriter writer) { }
}