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

@@ -73,6 +73,7 @@ import com.android.launcher3.dragndrop.SpringLoadedDragController;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.logging.UserEventDispatcher;
import com.android.launcher3.pageindicators.PageIndicatorLine;
import com.android.launcher3.userevent.nano.LauncherLogProto;
import com.android.launcher3.userevent.nano.LauncherLogProto.Target;
import com.android.launcher3.util.LongArrayMap;
@@ -803,6 +804,8 @@ public class Workspace extends PagedView
if (stripEmptyScreens) {
stripEmptyScreens();
}
// Update the page indicator to reflect the removed page.
showPageIndicatorAtCurrentScroll();
}
}
};
@@ -1642,8 +1645,6 @@ public class Workspace extends PagedView
if (listener != null) {
getPageIndicator().setOnClickListener(listener);
}
showPageIndicatorAtCurrentScroll();
}
// Update wallpaper dimensions if they were changed since last onResume
@@ -2048,6 +2049,9 @@ public class Workspace extends PagedView
@Override
public void onLauncherTransitionStart(Launcher l, boolean animated, boolean toWorkspace) {
if (mPageIndicator instanceof PageIndicatorLine) {
((PageIndicatorLine) mPageIndicator).setShouldAutoHide(mState != State.SPRING_LOADED);
}
}
@Override
@@ -2061,7 +2065,7 @@ public class Workspace extends PagedView
updateChildrenLayersEnabled(false);
showCustomContentIfNecessary();
mForceDrawAdjacentPages = false;
if (mState == State.NORMAL || mState == State.SPRING_LOADED) {
if (mState == State.SPRING_LOADED) {
showPageIndicatorAtCurrentScroll();
}
}

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)