From 8acf8b506d8c5db2ddcac825a24d0a3bda9fe100 Mon Sep 17 00:00:00 2001 From: Mario Bertschler Date: Thu, 11 May 2017 10:45:20 -0700 Subject: [PATCH] Design adjustments for transition from workspace to All apps. Change-Id: I0aeb8da7f0eebdf677ca7bda06fb538f08a6ee51 --- res/layout-land/launcher.xml | 4 +- res/layout-port/launcher.xml | 4 +- res/layout-sw720dp/launcher.xml | 4 +- res/layout/gradient_scrim.xml | 2 +- .../allapps/AllAppsTransitionController.java | 18 +++-- ...ialGradientView.java => GradientView.java} | 76 +++++++++---------- .../android/launcher3/graphics/ScrimView.java | 33 ++++++-- 7 files changed, 77 insertions(+), 64 deletions(-) rename src/com/android/launcher3/graphics/{RadialGradientView.java => GradientView.java} (65%) diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml index 565728cdcf..1e82f22761 100644 --- a/res/layout-land/launcher.xml +++ b/res/layout-land/launcher.xml @@ -32,8 +32,6 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - + + - - + + - - + + - 0) { createRadialShader(); } @@ -110,14 +98,15 @@ public class RadialGradientView extends View { // only being called when colors change private void createRadialShader() { - float radius = Math.max(mHeight, mWidth) * mConfig.gradientCenterY; + final float gradientCenterY = 1.05f; + float radius = Math.max(mHeight, mWidth) * gradientCenterY; float posScreenBottom = (radius - mHeight) / radius; // center lives below screen RadialGradient shader = new RadialGradient( - mWidth * mConfig.gradientCenterX, - mHeight * mConfig.gradientCenterY, + mWidth * 0.5f, + mHeight * gradientCenterY, radius, - new int[] {mConfig.color1, mConfig.color1, mConfig.color2}, + new int[] {mColor1, mColor1, mColor2}, new float[] {0f, posScreenBottom, 1f}, Shader.TileMode.CLAMP); mPaint.setShader(shader); @@ -130,17 +119,22 @@ public class RadialGradientView extends View { @Override protected void onDraw(Canvas canvas) { - float head = mConfig.gradientHeadStartFactor; + float head = 0.29f; float linearProgress = head + (mProgress * (1f - head)); - float adjustProgress = mConfig.useGradientAlphaDecel - ? mDecelInterpolator.getInterpolation(linearProgress) - : linearProgress; - float startMaskY = (1f - adjustProgress) * mHeight - mMaskHeight * adjustProgress; - + float startMaskY = (1f - linearProgress) * mHeight - mMaskHeight * linearProgress; + float startAlpha = 100; + float interpolatedAlpha = (255 - startAlpha) * mAccelerator.getInterpolation(mProgress); + mPaint.setAlpha((int) (startAlpha + interpolatedAlpha)); mAlphaMaskRect.set(0, startMaskY, mWidth, startMaskY + mMaskHeight); mFinalMaskRect.set(0, startMaskY + mMaskHeight, mWidth, mHeight); canvas.drawBitmap(sAlphaGradientMask, null, mAlphaMaskRect, mPaint); canvas.drawBitmap(sFinalGradientMask, null, mFinalMaskRect, mPaint); + + if (DEBUG) { + mDebugPaint.setColor(0xFF00FF00); + canvas.drawLine(0, startMaskY, mWidth, startMaskY, mDebugPaint); + canvas.drawLine(0, startMaskY + mMaskHeight, mWidth, startMaskY + mMaskHeight, mDebugPaint); + } } } \ No newline at end of file diff --git a/src/com/android/launcher3/graphics/ScrimView.java b/src/com/android/launcher3/graphics/ScrimView.java index 521fbedd6f..feb3f030f0 100644 --- a/src/com/android/launcher3/graphics/ScrimView.java +++ b/src/com/android/launcher3/graphics/ScrimView.java @@ -26,18 +26,22 @@ import android.graphics.RectF; import android.support.v4.graphics.ColorUtils; import android.util.AttributeSet; import android.view.View; +import android.view.animation.AccelerateInterpolator; +import android.view.animation.Interpolator; import com.android.launcher3.R; import com.android.launcher3.Utilities; public class ScrimView extends View { - // Config - private static final int MASK_HEIGHT_DP = 600; - private static final float MASK_START_LENGTH_FACTOR = 0.4f; + private static final boolean DEBUG = false; + + private static final int MASK_HEIGHT_DP = 300; + private static final float MASK_START_LENGTH_FACTOR = 1f; private static final float FINAL_ALPHA = 0.87f; private static final int SCRIM_COLOR = ColorUtils.setAlphaComponent( Color.WHITE, (int) (FINAL_ALPHA * 255)); + private static final boolean APPLY_ALPHA = true; private static Bitmap sFinalScrimMask; private static Bitmap sAlphaScrimMask; @@ -50,6 +54,8 @@ public class ScrimView extends View { private final RectF mFinalMaskRect = new RectF(); private final Paint mPaint = new Paint(); private float mProgress; + private final Interpolator mAccelerator = new AccelerateInterpolator(); + private final Paint mDebugPaint = DEBUG ? new Paint() : null; public ScrimView(Context context, AttributeSet attrs) { super(context, attrs); @@ -73,17 +79,22 @@ public class ScrimView extends View { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int width = MeasureSpec.getSize(widthMeasureSpec); mVisibleHeight = MeasureSpec.getSize(heightMeasureSpec); - int fullHeight = mVisibleHeight * 2 + mMaskHeight; - setMeasuredDimension(width, fullHeight); + setMeasuredDimension(width, mVisibleHeight * 2); setProgress(mProgress); } public void setProgress(float progress) { mProgress = progress; float initialY = mVisibleHeight - mHeadStart; - float fullTranslationY = mMaskHeight + initialY + mVisibleHeight; - float translationY = initialY - progress * fullTranslationY; - setTranslationY(translationY); + float fullTranslationY = mVisibleHeight; + float linTranslationY = initialY - progress * fullTranslationY; + setTranslationY(linTranslationY); + + if (APPLY_ALPHA) { + int alpha = 55 + (int) (200f * mAccelerator.getInterpolation(progress)); + mPaint.setAlpha(alpha); + invalidate(); + } } @Override @@ -92,6 +103,12 @@ public class ScrimView extends View { mFinalMaskRect.set(0, mMaskHeight, getWidth(), getHeight()); canvas.drawBitmap(sAlphaScrimMask, null, mAlphaMaskRect, mPaint); canvas.drawBitmap(sFinalScrimMask, null, mFinalMaskRect, mPaint); + + if (DEBUG) { + mDebugPaint.setColor(0xFF0000FF); + canvas.drawLine(0, mAlphaMaskRect.top, getWidth(), mAlphaMaskRect.top, mDebugPaint); + canvas.drawLine(0, mAlphaMaskRect.bottom, getWidth(), mAlphaMaskRect.bottom, mDebugPaint); + } } }