From 56e1019e95a502fbc8144a6ba651095c0e12def1 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Tue, 22 May 2018 13:22:25 -0700 Subject: Making caret visibility part of state definition > Hiding the caret in fast overview state > Hiding caret in task swipe down interaction Bug: 79700605 Change-Id: I984d535bc75802501e8aeb13c8f37387f331e5bc --- .../launcher3/uioverrides/OverviewState.java | 4 ++-- .../quickstep/views/LauncherRecentsView.java | 11 ++++++++- .../android/quickstep/views/ShelfScrimView.java | 9 ------- src/com/android/launcher3/LauncherState.java | 5 ++-- .../allapps/AllAppsTransitionController.java | 4 ++++ src/com/android/launcher3/views/ScrimView.java | 28 +++++++++++++++++++++- 6 files changed, 46 insertions(+), 15 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java index 3a49294c5..0116a8e0e 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java +++ b/quickstep/src/com/android/launcher3/uioverrides/OverviewState.java @@ -100,9 +100,9 @@ public class OverviewState extends LauncherState { @Override public int getVisibleElements(Launcher launcher) { if (launcher.getDeviceProfile().isVerticalBarLayout()) { - return 0; + return VERTICAL_SWIPE_INDICATOR; } else { - return HOTSEAT_SEARCH_BOX | + return HOTSEAT_SEARCH_BOX | VERTICAL_SWIPE_INDICATOR | (launcher.getAppsView().getFloatingHeaderView().hasVisibleContent() ? ALL_APPS_HEADER_EXTRA : HOTSEAT_ICONS); } diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java index 950f7fb99..5aca4f326 100644 --- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java +++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java @@ -35,6 +35,9 @@ import android.view.ViewDebug; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherState; +import com.android.launcher3.R; +import com.android.launcher3.anim.Interpolators; +import com.android.launcher3.views.ScrimView; import com.android.quickstep.OverviewInteractionState; import com.android.quickstep.util.ClipAnimationHelper; import com.android.quickstep.util.LayoutUtils; @@ -136,6 +139,12 @@ public class LauncherRecentsView extends RecentsView { } anim.play(ObjectAnimator.ofFloat( mActivity.getAllAppsController(), ALL_APPS_PROGRESS, allAppsProgressOffscreen)); + + ObjectAnimator dragHandleAnim = ObjectAnimator.ofInt( + mActivity.findViewById(R.id.scrim_view), ScrimView.DRAG_HANDLE_ALPHA, 0); + dragHandleAnim.setInterpolator(Interpolators.ACCEL_2); + anim.play(dragHandleAnim); + return anim; } @@ -150,7 +159,7 @@ public class LauncherRecentsView extends RecentsView { mActivity.getStateManager().goToState(NORMAL, false /* animate */); } else { LauncherState state = mActivity.getStateManager().getState(); - mActivity.getAllAppsController().setProgress(state.getVerticalProgress(mActivity)); + mActivity.getAllAppsController().setState(state); } super.onTaskLaunched(success); } diff --git a/quickstep/src/com/android/quickstep/views/ShelfScrimView.java b/quickstep/src/com/android/quickstep/views/ShelfScrimView.java index 24afd4868..aca8351a0 100644 --- a/quickstep/src/com/android/quickstep/views/ShelfScrimView.java +++ b/quickstep/src/com/android/quickstep/views/ShelfScrimView.java @@ -153,15 +153,6 @@ public class ShelfScrimView extends ScrimView { } } - @Override - protected void updateDragHandleAlpha() { - if (mDrawingFlatColor) { - super.updateDragHandleAlpha(); - } else if (mDragHandle != null) { - mDragHandle.setAlpha(255); - } - } - @Override protected void onDraw(Canvas canvas) { float translate = drawBackground(canvas); diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index fbe27b0ac..76681f280 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -51,6 +51,7 @@ public class LauncherState { public static final int ALL_APPS_HEADER = 1 << 2; public static final int ALL_APPS_HEADER_EXTRA = 1 << 3; // e.g. app predictions public static final int ALL_APPS_CONTENT = 1 << 4; + public static final int VERTICAL_SWIPE_INDICATOR = 1 << 5; protected static final int FLAG_MULTI_PAGE = 1 << 0; protected static final int FLAG_DISABLE_ACCESSIBILITY = 1 << 1; @@ -201,9 +202,9 @@ public class LauncherState { public int getVisibleElements(Launcher launcher) { if (launcher.getDeviceProfile().isVerticalBarLayout()) { - return HOTSEAT_ICONS; + return HOTSEAT_ICONS | VERTICAL_SWIPE_INDICATOR; } - return HOTSEAT_ICONS | HOTSEAT_SEARCH_BOX; + return HOTSEAT_ICONS | HOTSEAT_SEARCH_BOX | VERTICAL_SWIPE_INDICATOR; } /** diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 2c3e3ee7b..ccd55863c 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -4,6 +4,7 @@ import static com.android.launcher3.LauncherState.ALL_APPS_CONTENT; import static com.android.launcher3.LauncherState.ALL_APPS_HEADER; import static com.android.launcher3.LauncherState.ALL_APPS_HEADER_EXTRA; import static com.android.launcher3.LauncherState.OVERVIEW; +import static com.android.launcher3.LauncherState.VERTICAL_SWIPE_INDICATOR; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE; import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_VERTICAL_PROGRESS; import static com.android.launcher3.anim.Interpolators.FAST_OUT_SLOW_IN; @@ -198,6 +199,9 @@ public class AllAppsTransitionController implements StateHandler, OnDeviceProfil setter.setViewAlpha(mAppsView.getContentView(), hasContent ? 1 : 0, LINEAR); setter.setViewAlpha(mAppsView.getScrollBar(), hasContent ? 1 : 0, LINEAR); mAppsView.getFloatingHeaderView().setContentVisibility(hasHeaderExtra, hasContent, setter); + + setter.setInt(mScrimView, ScrimView.DRAG_HANDLE_ALPHA, + (visibleElements & VERTICAL_SWIPE_INDICATOR) != 0 ? 255 : 0, LINEAR); } public AnimatorListenerAdapter getProgressAnimatorListener() { diff --git a/src/com/android/launcher3/views/ScrimView.java b/src/com/android/launcher3/views/ScrimView.java index 6bbce00fe..d01da43d1 100644 --- a/src/com/android/launcher3/views/ScrimView.java +++ b/src/com/android/launcher3/views/ScrimView.java @@ -45,6 +45,7 @@ import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat; import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat; import android.support.v4.widget.ExploreByTouchHelper; import android.util.AttributeSet; +import android.util.Property; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; @@ -73,6 +74,19 @@ import java.util.List; public class ScrimView extends View implements Insettable, OnChangeListener, AccessibilityStateChangeListener, StateListener { + public static final Property DRAG_HANDLE_ALPHA = + new Property(Integer.TYPE, "dragHandleAlpha") { + + @Override + public Integer get(ScrimView scrimView) { + return scrimView.mDragHandleAlpha; + } + + @Override + public void set(ScrimView scrimView, Integer value) { + scrimView.setDragHandleAlpha(value); + } + }; private static final int WALLPAPERS = R.string.wallpaper_button_text; private static final int WIDGETS = R.string.widget_button_text; private static final int SETTINGS = R.string.settings_button_text; @@ -102,6 +116,8 @@ public class ScrimView extends View implements Insettable, OnChangeListener, @Nullable protected Drawable mDragHandle; + private int mDragHandleAlpha = 255; + public ScrimView(Context context, AttributeSet attrs) { super(context, attrs); mLauncher = Launcher.getLauncher(context); @@ -187,7 +203,17 @@ public class ScrimView extends View implements Insettable, OnChangeListener, protected void updateDragHandleAlpha() { if (mDragHandle != null) { - mDragHandle.setAlpha(Math.round(255 * Utilities.boundToRange(mProgress, 0, 1))); + mDragHandle.setAlpha(mDragHandleAlpha); + } + } + + private void setDragHandleAlpha(int alpha) { + if (alpha != mDragHandleAlpha) { + mDragHandleAlpha = alpha; + if (mDragHandle != null) { + mDragHandle.setAlpha(mDragHandleAlpha); + invalidate(); + } } } -- cgit v1.2.3