Removing multi-state apha control for hotseat

Change-Id: I68ccbe96caa70921aefd18fc8ec9ad0638c3fab1
diff --git a/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java b/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java
index 6395473..426fe35 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/AllAppsState.java
@@ -83,7 +83,7 @@
 
     @Override
     public float getHoseatAlpha(Launcher launcher) {
-        return launcher.getDeviceProfile().isVerticalBarLayout() ? 0 : 1;
+        return 0;
     }
 
     @Override
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index c946a44..e6aa6be 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -179,27 +179,6 @@
 
     private SpringLoadedDragController mSpringLoadedDragController;
 
-    // Direction used for moving the workspace and hotseat UI
-    public enum Direction {
-        X  (TRANSLATION_X),
-        Y  (TRANSLATION_Y);
-
-        private final Property<View, Float> viewProperty;
-
-        Direction(Property<View, Float> viewProperty) {
-            this.viewProperty = viewProperty;
-        }
-    }
-
-    private static final int HOTSEAT_STATE_ALPHA_INDEX = 2;
-
-    /**
-     * Hotseat alpha can be changed when moving horizontally, vertically, changing states.
-     * The values correspond to {@link Direction#X}, {@link Direction#Y} &
-     * {@link #HOTSEAT_STATE_ALPHA_INDEX} respectively.
-     */
-    private final float[] mHotseatAlpha = new float[] {1, 1, 1};
-
     private boolean mIsSwitchingState = false;
 
     boolean mChildrenLayersEnabled = true;
@@ -1206,81 +1185,8 @@
         // TODO(adamcohen): figure out a final effect here. We may need to recommend
         // different effects based on device performance. On at least one relatively high-end
         // device I've tried, translating the launcher causes things to get quite laggy.
-        setWorkspaceTranslationAndAlpha(transX, alpha);
-        setHotseatTranslationAndAlpha(Direction.X, transX, alpha);
-    }
-
-    /**
-     * Moves the workspace UI in the provided direction.
-     * @param translation the amount of horizontal shift.
-     * @param alpha the alpha for the workspace page
-     */
-    private void setWorkspaceTranslationAndAlpha(float translation, float alpha) {
-        float finalAlpha = alpha;
-
-        View currentChild = getChildAt(getCurrentPage());
-        if (currentChild != null) {
-            currentChild.setTranslationX(translation);
-            currentChild.setAlpha(finalAlpha);
-        }
-
-        // When the animation finishes, reset all pages, just in case we missed a page.
-        if (Float.compare(translation, 0) == 0) {
-            for (int i = getChildCount() - 1; i >= 0; i--) {
-                View child = getChildAt(i);
-                child.setTranslationX(0);
-                child.setAlpha(finalAlpha);
-            }
-        }
-    }
-
-    /**
-     * Moves the Hotseat UI in the provided direction.
-     * @param direction the direction to move the workspace
-     * @param translation the amount of shift.
-     * @param alpha the alpha for the hotseat page
-     */
-    public void setHotseatTranslationAndAlpha(Direction direction, float translation, float alpha) {
-        Property<View, Float> property = direction.viewProperty;
-        // Skip the page indicator movement in the vertical bar layout
-        if (direction != Direction.Y || !mLauncher.getDeviceProfile().isVerticalBarLayout()) {
-            property.set(mPageIndicator, translation);
-        }
-        property.set(mLauncher.getHotseat(), translation);
-        setHotseatAlphaAtIndex(alpha, direction.ordinal());
-    }
-
-    private void setHotseatAlphaAtIndex(float alpha, int index) {
-        mHotseatAlpha[index] = alpha;
-        final float hotseatAlpha = mHotseatAlpha[0] * mHotseatAlpha[1] * mHotseatAlpha[2];
-        final float pageIndicatorAlpha = mHotseatAlpha[0] * mHotseatAlpha[2];
-
-        mLauncher.getHotseat().setAlpha(hotseatAlpha);
-        mPageIndicator.setAlpha(pageIndicatorAlpha);
-    }
-
-    public ValueAnimator createHotseatAlphaAnimator(float finalValue) {
-        if (Float.compare(finalValue, mHotseatAlpha[HOTSEAT_STATE_ALPHA_INDEX]) == 0) {
-            // Return a dummy animator to avoid null checks.
-            return ValueAnimator.ofFloat(0, 0);
-        } else {
-            ValueAnimator animator = ValueAnimator
-                    .ofFloat(mHotseatAlpha[HOTSEAT_STATE_ALPHA_INDEX], finalValue);
-            animator.addUpdateListener(new AnimatorUpdateListener() {
-                @Override
-                public void onAnimationUpdate(ValueAnimator valueAnimator) {
-                    float value = (Float) valueAnimator.getAnimatedValue();
-                    setHotseatAlphaAtIndex(value, HOTSEAT_STATE_ALPHA_INDEX);
-                }
-            });
-
-            final boolean accessibilityEnabled = isAccessibilityEnabled(mLauncher);
-            animator.addUpdateListener(
-                    new AlphaUpdateListener(mLauncher.getHotseat(), accessibilityEnabled));
-            animator.addUpdateListener(
-                    new AlphaUpdateListener(mPageIndicator, accessibilityEnabled));
-            return animator;
-        }
+        mLauncher.getDragLayer().setTranslationX(transX);
+        mLauncher.getDragLayer().setAlpha(alpha);
     }
 
     @Override
diff --git a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
index cf35e52..21f5d67 100644
--- a/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
+++ b/src/com/android/launcher3/WorkspaceStateTransitionAnimation.java
@@ -138,9 +138,8 @@
         propertySetter.setFloat(mWorkspace, View.TRANSLATION_Y,
                 scaleAndTranslation[2], Interpolators.ZOOM_IN);
 
-        float hotseatAlpha = state.getHoseatAlpha(mLauncher);
-        propertySetter.setViewAlpha(mWorkspace.createHotseatAlphaAnimator(hotseatAlpha),
-                mLauncher.getHotseat(), hotseatAlpha);
+        propertySetter.setViewAlpha(mLauncher.getHotseat(), state.getHoseatAlpha(mLauncher),
+                pageAlphaProvider.interpolator);
 
         // Set scrim
         propertySetter.setInt(mLauncher.getDragLayer().getScrim(), DRAWABLE_ALPHA,
@@ -165,11 +164,7 @@
 
     public static class PropertySetter {
 
-        public void setViewAlpha(Animator anim, View view, float alpha) {
-            if (anim != null) {
-                anim.end();
-                return;
-            }
+        public void setViewAlpha(View view, float alpha, TimeInterpolator interpolator) {
             view.setAlpha(alpha);
             AlphaUpdateListener.updateVisibility(view, isAccessibilityEnabled(view.getContext()));
         }
@@ -196,17 +191,14 @@
         }
 
         @Override
-        public void setViewAlpha(Animator anim, View view, float alpha) {
-            if (anim == null) {
-                if (view.getAlpha() == alpha) {
-                    return;
-                }
-                anim = ObjectAnimator.ofFloat(view, View.ALPHA, alpha);
-                anim.addListener(new AlphaUpdateListener(view,
-                        isAccessibilityEnabled(view.getContext())));
+        public void setViewAlpha(View view, float alpha, TimeInterpolator interpolator) {
+            if (view.getAlpha() == alpha) {
+                return;
             }
-
-            anim.setDuration(mDuration).setInterpolator(getFadeInterpolator(alpha));
+            ObjectAnimator anim = ObjectAnimator.ofFloat(view, View.ALPHA, alpha);
+            anim.addListener(new AlphaUpdateListener(
+                    view, isAccessibilityEnabled(view.getContext())));
+            anim.setDuration(mDuration).setInterpolator(interpolator);
             mStateAnimator.play(anim);
         }
 
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index d8a0d64..c02f2df 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -20,7 +20,6 @@
 import com.android.launcher3.Workspace;
 import com.android.launcher3.anim.AnimationSuccessListener;
 import com.android.launcher3.anim.AnimatorSetBuilder;
-import com.android.launcher3.anim.Interpolators;
 import com.android.launcher3.util.SystemUiController;
 import com.android.launcher3.util.Themes;
 import com.android.launcher3.views.AllAppsScrim;
@@ -52,8 +51,6 @@
         }
     };
 
-    private final Interpolator mHotseatAccelInterpolator = Interpolators.ACCEL_1_5;
-
     public static final float PARALLAX_COEFFICIENT = .125f;
 
     private AllAppsContainerView mAppsView;
@@ -111,7 +108,6 @@
 
         float workspaceHotseatAlpha = Utilities.boundToRange(progress, 0f, 1f);
         float alpha = 1 - workspaceHotseatAlpha;
-        float hotseatAlpha = mHotseatAccelInterpolator.getInterpolation(workspaceHotseatAlpha);
 
         mAppsView.setTranslationY(shiftCurrent);
         if (mAllAppsScrim == null) {
@@ -122,8 +118,8 @@
 
         if (!mIsVerticalLayout) {
             mAppsView.setAlpha(alpha);
-            mWorkspace.setHotseatTranslationAndAlpha(Workspace.Direction.Y, hotseatTranslation,
-                    hotseatAlpha);
+            mLauncher.getHotseat().setTranslationY(hotseatTranslation);
+            mLauncher.getWorkspace().getPageIndicator().setTranslationY(hotseatTranslation);
 
             // Use a light system UI (dark icons) if all apps is behind at least half of the
             // status bar.
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index 93a5679..677694f 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -366,6 +366,16 @@
     }
 
     @Override
+    public boolean dispatchTouchEvent(MotionEvent ev) {
+        ev.offsetLocation(getTranslationX(), 0);
+        try {
+            return super.dispatchTouchEvent(ev);
+        } finally {
+            ev.offsetLocation(-getTranslationX(), 0);
+        }
+    }
+
+    @Override
     public LayoutParams generateLayoutParams(AttributeSet attrs) {
         return new LayoutParams(getContext(), attrs);
     }
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java
index 24236d8..fd33ee1 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/AllAppsState.java
@@ -62,6 +62,11 @@
     }
 
     @Override
+    public float getHoseatAlpha(Launcher launcher) {
+        return 0;
+    }
+
+    @Override
     public View getFinalFocus(Launcher launcher) {
         return launcher.getAppsView();
     }
diff --git a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
index 9a09c97..2d39505 100644
--- a/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
+++ b/src_ui_overrides/com/android/launcher3/uioverrides/OverviewPanel.java
@@ -37,6 +37,7 @@
 import com.android.launcher3.WorkspaceStateTransitionAnimation.AnimatedPropertySetter;
 import com.android.launcher3.WorkspaceStateTransitionAnimation.PropertySetter;
 import com.android.launcher3.anim.AnimatorSetBuilder;
+import com.android.launcher3.anim.Interpolators;
 import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
 import com.android.launcher3.userevent.nano.LauncherLogProto.ControlType;
 import com.android.launcher3.widget.WidgetsFullSheet;
@@ -173,8 +174,7 @@
     }
 
     private void setState(LauncherState state, PropertySetter setter) {
-        float hotseatAlpha = state.getHoseatAlpha(mLauncher);
-        setter.setViewAlpha(null, this, 1f - hotseatAlpha);
+        setter.setViewAlpha(this, 1f - state.getHoseatAlpha(mLauncher), Interpolators.ACCEL);
     }
 
     public static int getButtonBarHeight(Launcher launcher) {