Only show workspace page indicator when scrolling or in spring-loaded mode.

- Stop showing indicator when resuming or ending transitions.
- In spring-loaded mode, prevent page indicator from auto-hiding.

Change-Id: I87070d2d8f46cf491e60380aed5540196f2fbba3
This commit is contained in:
Tony Wickham
2016-05-26 13:00:02 -07:00
parent 85fc55a976
commit d4b28d2e1b
2 changed files with 27 additions and 8 deletions

View File

@@ -14,7 +14,6 @@ import android.support.v4.graphics.ColorUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Property;
import android.view.View;
import android.view.ViewConfiguration;
import com.android.launcher3.Utilities;
@@ -33,7 +32,9 @@ public class PageIndicatorLine extends PageIndicator {
public static final int WHITE_ALPHA = (int) (0.70f * 255);
public static final int BLACK_ALPHA = (int) (0.65f * 255);
private final Handler mHandler = new Handler(Looper.getMainLooper());
private final Handler mDelayedLineFadeHandler = new Handler(Looper.getMainLooper());
private boolean mShouldAutoHide = true;
private ValueAnimator mLineAlphaAnimator;
private int mAlpha = 0;
@@ -97,9 +98,14 @@ public class PageIndicatorLine extends PageIndicator {
mProgress = Utilities.boundToRange(((float) currentScroll) / totalScroll, 0f, 1f);;
invalidate();
// Hide after a brief period.
mHandler.removeCallbacksAndMessages(null);
mHandler.postDelayed(mHideLineRunnable, LINE_FADE_DELAY);
if (mShouldAutoHide) {
hideAfterDelay();
}
}
private void hideAfterDelay() {
mDelayedLineFadeHandler.removeCallbacksAndMessages(null);
mDelayedLineFadeHandler.postDelayed(mHideLineRunnable, LINE_FADE_DELAY);
}
@Override
@@ -111,6 +117,15 @@ public class PageIndicatorLine extends PageIndicator {
invalidate();
}
public void setShouldAutoHide(boolean shouldAutoHide) {
mShouldAutoHide = shouldAutoHide;
if (shouldAutoHide && mLinePaint.getAlpha() > 0) {
hideAfterDelay();
} else if (!shouldAutoHide) {
mDelayedLineFadeHandler.removeCallbacksAndMessages(null);
}
}
/**
* The line's color will be:
* - mostly opaque white if the hotseat is white (ignoring alpha)