[-1] Show toast when user trys to swipe to -1 on extreme battery saver mode
Fix: 355485335
Flag: com.android.launcher3.use_activity_overlay
Test: manual - record a video
Change-Id: I79a3ece2fb2c0d1eddac0e4f91274ffe222e317f
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index bafb528..2eda54d 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3036,6 +3036,7 @@
return mPopupDataProvider.getDotInfoForItem(info);
}
+ @NonNull
public LauncherOverlayManager getOverlayManager() {
return mOverlayManager;
}
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 365fbd3..0ec3b79 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -1463,6 +1463,15 @@
mEdgeGlowLeft.onFlingVelocity(velocity);
mEdgeGlowRight.onFlingVelocity(velocity);
}
+
+ // Detect if user tries to swipe to -1 page but gets disallowed by checking if there was
+ // left-over values in mEdgeGlowLeft (or mEdgeGlowRight in RLT).
+ final int layoutDir = getLayoutDirection();
+ if ((mEdgeGlowLeft.getDistance() > 0 && layoutDir == LAYOUT_DIRECTION_LTR)
+ || (mEdgeGlowRight.getDistance() > 0 && layoutDir == LAYOUT_DIRECTION_RTL)) {
+ onDisallowSwipeToMinusOnePage();
+ }
+
mEdgeGlowLeft.onRelease(ev);
mEdgeGlowRight.onRelease(ev);
// End any intermediate reordering states
@@ -1487,6 +1496,8 @@
return true;
}
+ protected void onDisallowSwipeToMinusOnePage() {}
+
protected void onNotSnappingToPageInFreeScroll() { }
/**
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 255260e..0e9c861 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1123,6 +1123,11 @@
return super.onTouchEvent(ev);
}
+ @Override
+ protected void onDisallowSwipeToMinusOnePage() {
+ mLauncher.getOverlayManager().onDisallowSwipeToMinusOnePage();
+ }
+
/**
* Called directly from a CellLayout (not by the framework), after we've been added as a
* listener via setOnInterceptTouchEventListener(). This allows us to tell the CellLayout