Merge "Fixing LauncherState not getting applied in some cases" into ub-launcher3-master
diff --git a/quickstep/src/com/android/quickstep/QuickScrubController.java b/quickstep/src/com/android/quickstep/QuickScrubController.java
index d868d12..275fd29 100644
--- a/quickstep/src/com/android/quickstep/QuickScrubController.java
+++ b/quickstep/src/com/android/quickstep/QuickScrubController.java
@@ -38,9 +38,14 @@
public static final int QUICK_SCRUB_START_DURATION = 210;
+ /**
+ * Snap to a new page when crossing these thresholds. The first and last auto-advance.
+ */
+ private static final float[] QUICK_SCRUB_THRESHOLDS = new float[] {
+ 0.05f, 0.35f, 0.65f, 0.95f
+ };
+
private static final boolean ENABLE_AUTO_ADVANCE = true;
- private static final int NUM_QUICK_SCRUB_SECTIONS = 3;
- private static final long INITIAL_AUTO_ADVANCE_DELAY = 1000;
private static final long AUTO_ADVANCE_DELAY = 500;
private static final int QUICKSCRUB_SNAP_DURATION_PER_PAGE = 325;
private static final int QUICKSCRUB_END_SNAP_DURATION_PER_PAGE = 60;
@@ -52,7 +57,6 @@
private boolean mInQuickScrub;
private int mQuickScrubSection;
private boolean mStartedFromHome;
- private boolean mHasAlarmRun;
private boolean mFinishedTransitionToQuickScrub;
public QuickScrubController(BaseActivity activity, RecentsView recentsView) {
@@ -68,7 +72,6 @@
mInQuickScrub = true;
mStartedFromHome = startingFromHome;
mQuickScrubSection = 0;
- mHasAlarmRun = false;
mFinishedTransitionToQuickScrub = false;
snapToNextTaskIfAvailable();
@@ -105,16 +108,23 @@
}
public void onQuickScrubProgress(float progress) {
- int quickScrubSection = Math.round(progress * NUM_QUICK_SCRUB_SECTIONS);
+ int quickScrubSection = 0;
+ for (float threshold : QUICK_SCRUB_THRESHOLDS) {
+ if (progress < threshold) {
+ break;
+ }
+ quickScrubSection++;
+ }
if (quickScrubSection != mQuickScrubSection) {
+ boolean cameFromAutoAdvance = mQuickScrubSection == QUICK_SCRUB_THRESHOLDS.length
+ || mQuickScrubSection == 0;
int pageToGoTo = mRecentsView.getNextPage() + quickScrubSection - mQuickScrubSection;
- if (mFinishedTransitionToQuickScrub) {
+ if (mFinishedTransitionToQuickScrub && !cameFromAutoAdvance) {
goToPageWithHaptic(pageToGoTo);
}
if (ENABLE_AUTO_ADVANCE) {
- if (quickScrubSection == NUM_QUICK_SCRUB_SECTIONS || quickScrubSection == 0) {
- mAutoAdvanceAlarm.setAlarm(mHasAlarmRun
- ? AUTO_ADVANCE_DELAY : INITIAL_AUTO_ADVANCE_DELAY);
+ if (quickScrubSection == QUICK_SCRUB_THRESHOLDS.length || quickScrubSection == 0) {
+ mAutoAdvanceAlarm.setAlarm(AUTO_ADVANCE_DELAY);
} else {
mAutoAdvanceAlarm.cancelAlarm();
}
@@ -148,13 +158,12 @@
@Override
public void onAlarm(Alarm alarm) {
int currPage = mRecentsView.getNextPage();
- if (mQuickScrubSection == NUM_QUICK_SCRUB_SECTIONS
+ if (mQuickScrubSection == QUICK_SCRUB_THRESHOLDS.length
&& currPage < mRecentsView.getPageCount() - 1) {
goToPageWithHaptic(currPage + 1);
} else if (mQuickScrubSection == 0 && currPage > 0) {
goToPageWithHaptic(currPage - 1);
}
- mHasAlarmRun = true;
if (ENABLE_AUTO_ADVANCE) {
mAutoAdvanceAlarm.setAlarm(AUTO_ADVANCE_DELAY);
}