Merge "Removing accessibility description from page indicators" into ub-launcher3-master
diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
index 3ff9921..ce17d25 100644
--- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
+++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManagerImpl.java
@@ -50,7 +50,9 @@
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
+import android.util.ArraySet;
import android.util.Log;
+import android.util.Pair;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
@@ -178,7 +180,15 @@
anim.play(getIconAnimator(v));
if (launcherClosing) {
- anim.play(getLauncherContentAnimator(false /* show */));
+ Pair<AnimatorSet, Runnable> launcherContentAnimator =
+ getLauncherContentAnimator(false /* show */);
+ anim.play(launcherContentAnimator.first);
+ anim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ launcherContentAnimator.second.run();
+ }
+ });
}
anim.play(getWindowAnimators(v, targetCompats));
}
@@ -267,8 +277,9 @@
* @param show If true: Animate the content so that it moves upwards and fades in.
* Else: Animate the content so that it moves downwards and fades out.
*/
- private AnimatorSet getLauncherContentAnimator(boolean show) {
+ private Pair<AnimatorSet, Runnable> getLauncherContentAnimator(boolean show) {
AnimatorSet launcherAnimator = new AnimatorSet();
+ Runnable endListener;
float[] alphas = show
? new float[] {0, 1}
@@ -288,6 +299,13 @@
ObjectAnimator alpha = ObjectAnimator.ofFloat(appsView, View.ALPHA, alphas);
alpha.setDuration(217);
alpha.setInterpolator(LINEAR);
+ appsView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ alpha.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ appsView.setLayerType(View.LAYER_TYPE_NONE, null);
+ }
+ });
ObjectAnimator transY = ObjectAnimator.ofFloat(appsView, View.TRANSLATION_Y, trans);
transY.setInterpolator(AGGRESSIVE_EASE);
transY.setDuration(350);
@@ -295,13 +313,11 @@
launcherAnimator.play(alpha);
launcherAnimator.play(transY);
- launcherAnimator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- appsView.setAlpha(startAlpha);
- appsView.setTranslationY(startY);
- }
- });
+ endListener = () -> {
+ appsView.setAlpha(startAlpha);
+ appsView.setTranslationY(startY);
+ appsView.setLayerType(View.LAYER_TYPE_NONE, null);
+ };
} else {
mDragLayer.setAlpha(alphas[0]);
mDragLayer.setTranslationY(trans[0]);
@@ -316,15 +332,14 @@
launcherAnimator.play(dragLayerAlpha);
launcherAnimator.play(dragLayerTransY);
- launcherAnimator.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationEnd(Animator animation) {
- mDragLayer.setAlpha(1);
- mDragLayer.setTranslationY(0);
- }
- });
+ mDragLayer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
+ endListener = () -> {
+ mDragLayer.setLayerType(View.LAYER_TYPE_NONE, null);
+ mDragLayer.setAlpha(1);
+ mDragLayer.setTranslationY(0);
+ };
}
- return launcherAnimator;
+ return new Pair<>(launcherAnimator, endListener);
}
/**
@@ -658,9 +673,16 @@
private void createLauncherResumeAnimation(AnimatorSet anim) {
if (mLauncher.isInState(LauncherState.ALL_APPS)
|| mLauncher.getDeviceProfile().isVerticalBarLayout()) {
- AnimatorSet contentAnimator = getLauncherContentAnimator(true /* show */);
- contentAnimator.setStartDelay(LAUNCHER_RESUME_START_DELAY);
- anim.play(contentAnimator);
+ Pair<AnimatorSet, Runnable> contentAnimator =
+ getLauncherContentAnimator(true /* show */);
+ contentAnimator.first.setStartDelay(LAUNCHER_RESUME_START_DELAY);
+ anim.play(contentAnimator.first);
+ anim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ contentAnimator.second.run();
+ }
+ });
} else {
AnimatorSet workspaceAnimator = new AnimatorSet();
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 2e70e45..597e333 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -630,9 +630,9 @@
TaskView firstTask = (TaskView) getChildAt(0);
if (firstTask != null) {
if (animate) {
- firstTask.animateIconToScale(scale);
+ firstTask.animateIconToScaleAndDim(scale);
} else {
- firstTask.setIconScale(scale);
+ firstTask.setIconScaleAndDim(scale);
}
}
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
index 326eb9f..6473d16 100644
--- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -28,6 +28,8 @@
import android.graphics.Rect;
import android.graphics.Shader;
import android.util.AttributeSet;
+import android.util.FloatProperty;
+import android.util.Property;
import android.view.View;
import com.android.launcher3.BaseActivity;
@@ -46,6 +48,19 @@
private static final LightingColorFilter[] sDimFilterCache = new LightingColorFilter[256];
+ public static final Property<TaskThumbnailView, Float> DIM_ALPHA =
+ new FloatProperty<TaskThumbnailView>("dimAlpha") {
+ @Override
+ public void setValue(TaskThumbnailView thumbnail, float dimAlpha) {
+ thumbnail.setDimAlpha(dimAlpha);
+ }
+
+ @Override
+ public Float get(TaskThumbnailView thumbnailView) {
+ return thumbnailView.mDimAlpha;
+ }
+ };
+
private final float mCornerRadius;
private final BaseActivity mActivity;
@@ -111,6 +126,8 @@
/**
* Sets the alpha of the dim layer on top of this view.
+ *
+ * If dimAlpha is 0, no dimming is applied; if dimAlpha is 1, the thumbnail will be black.
*/
public void setDimAlpha(float dimAlpha) {
mDimAlpha = dimAlpha;
@@ -149,7 +166,7 @@
}
private void updateThumbnailPaintFilter() {
- int mul = (int) (mDimAlpha * 255);
+ int mul = (int) ((1 - mDimAlpha) * 255);
if (mBitmapShader != null) {
LightingColorFilter filter = getLightingColorFilter(mul);
mPaint.setColorFilter(filter);
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.java b/quickstep/src/com/android/quickstep/views/TaskView.java
index f04acaf..2c1318c 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskView.java
@@ -16,6 +16,11 @@
package com.android.quickstep.views;
+import static com.android.quickstep.views.TaskThumbnailView.DIM_ALPHA;
+
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
+import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.app.ActivityOptions;
import android.content.Context;
@@ -75,6 +80,8 @@
private TaskThumbnailView mSnapshotView;
private ImageView mIconView;
private float mCurveScale;
+ private float mCurveDimAlpha;
+ private Animator mDimAlphaAnim;
public TaskView(Context context) {
this(context, null);
@@ -166,14 +173,27 @@
// Do nothing
}
- public void animateIconToScale(float scale) {
+ public void animateIconToScaleAndDim(float scale) {
mIconView.animate().scaleX(scale).scaleY(scale).setDuration(SCALE_ICON_DURATION).start();
+ mDimAlphaAnim = ObjectAnimator.ofFloat(mSnapshotView, DIM_ALPHA, scale * mCurveDimAlpha);
+ mDimAlphaAnim.setDuration(SCALE_ICON_DURATION);
+ mDimAlphaAnim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ mDimAlphaAnim = null;
+ }
+ });
+ mDimAlphaAnim.start();
}
- protected void setIconScale(float iconScale) {
+ protected void setIconScaleAndDim(float iconScale) {
mIconView.animate().cancel();
mIconView.setScaleX(iconScale);
mIconView.setScaleY(iconScale);
+ if (mDimAlphaAnim != null) {
+ mDimAlphaAnim.cancel();
+ }
+ mSnapshotView.setDimAlpha(iconScale * mCurveDimAlpha);
}
public void resetVisualProperties() {
@@ -190,7 +210,10 @@
float curveInterpolation =
CURVE_INTERPOLATOR.getInterpolation(scrollState.linearInterpolation);
- mSnapshotView.setDimAlpha(1 - curveInterpolation * MAX_PAGE_SCRIM_ALPHA);
+ mCurveDimAlpha = curveInterpolation * MAX_PAGE_SCRIM_ALPHA;
+ if (mDimAlphaAnim == null && mIconView.getScaleX() > 0) {
+ mSnapshotView.setDimAlpha(mCurveDimAlpha);
+ }
mCurveScale = 1 - curveInterpolation * EDGE_SCALE_DOWN_FACTOR;
setScaleX(mCurveScale);