summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMario Bertschler <bmario@google.com>2017-05-11 10:45:20 -0700
committerMario Bertschler <bmario@google.com>2017-05-16 16:13:11 -0700
commit8acf8b506d8c5db2ddcac825a24d0a3bda9fe100 (patch)
tree053d15104fe183ce00f9d260f4e009cf380f0595 /src
parent7f91393c5518584fd48913a16f2dd2759bad31ea (diff)
downloadandroid_packages_apps_Trebuchet-8acf8b506d8c5db2ddcac825a24d0a3bda9fe100.tar.gz
android_packages_apps_Trebuchet-8acf8b506d8c5db2ddcac825a24d0a3bda9fe100.tar.bz2
android_packages_apps_Trebuchet-8acf8b506d8c5db2ddcac825a24d0a3bda9fe100.zip
Design adjustments for transition from workspace to
All apps. Change-Id: I0aeb8da7f0eebdf677ca7bda06fb538f08a6ee51
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/allapps/AllAppsTransitionController.java18
-rw-r--r--src/com/android/launcher3/graphics/GradientView.java (renamed from src/com/android/launcher3/graphics/RadialGradientView.java)76
-rw-r--r--src/com/android/launcher3/graphics/ScrimView.java33
3 files changed, 70 insertions, 57 deletions
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 97aa54ac5..7c6ff5120 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -24,7 +24,7 @@ import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dynamicui.ExtractedColors;
-import com.android.launcher3.graphics.RadialGradientView;
+import com.android.launcher3.graphics.GradientView;
import com.android.launcher3.graphics.ScrimView;
import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
@@ -47,7 +47,8 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
private static final String TAG = "AllAppsTrans";
private static final boolean DBG = false;
- private final Interpolator mAccelInterpolator = new AccelerateInterpolator(2f);
+ private final Interpolator mWorkspaceAccelnterpolator = new AccelerateInterpolator(2f);
+ private final Interpolator mHotseatAccelInterpolator = new AccelerateInterpolator(.5f);
private final Interpolator mDecelInterpolator = new DecelerateInterpolator(3f);
private final Interpolator mFastOutSlowInInterpolator = new FastOutSlowInInterpolator();
private final VerticalPullDetector.ScrollInterpolator mScrollInterpolator
@@ -95,7 +96,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
// Used in discovery bounce animation to provide the transition without workspace changing.
private boolean mIsTranslateWithoutWorkspace = false;
private AnimatorSet mDiscoBounceAnimation;
- private RadialGradientView mGradientView;
+ private GradientView mGradientView;
private ScrimView mScrimView;
public AllAppsTransitionController(Launcher l) {
@@ -275,7 +276,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
private void updateAllAppsBg(float progress) {
// gradient
if (mGradientView == null) {
- mGradientView = (RadialGradientView) mLauncher.findViewById(R.id.gradient_bg);
+ mGradientView = (GradientView) mLauncher.findViewById(R.id.gradient_bg);
mGradientView.setVisibility(View.VISIBLE);
onExtractedColorsChanged();
}
@@ -313,7 +314,8 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
float workspaceHotseatAlpha = Utilities.boundToRange(progress, 0f, 1f);
float alpha = 1 - workspaceHotseatAlpha;
- float interpolation = mAccelInterpolator.getInterpolation(workspaceHotseatAlpha);
+ float workspaceAlpha = mWorkspaceAccelnterpolator.getInterpolation(workspaceHotseatAlpha);
+ float hotseatAlpha = mHotseatAccelInterpolator.getInterpolation(workspaceHotseatAlpha);
int color = (Integer) mEvaluator.evaluate(mDecelInterpolator.getInterpolation(alpha),
mHotseatBackgroundColor, mAllAppsBackgroundColor);
@@ -331,18 +333,18 @@ public class AllAppsTransitionController implements TouchController, VerticalPul
if (!mLauncher.getDeviceProfile().isVerticalBarLayout()) {
mWorkspace.setHotseatTranslationAndAlpha(Workspace.Direction.Y, -mShiftRange + shiftCurrent,
- interpolation);
+ hotseatAlpha);
} else {
mWorkspace.setHotseatTranslationAndAlpha(Workspace.Direction.Y,
PARALLAX_COEFFICIENT * (-mShiftRange + shiftCurrent),
- interpolation);
+ hotseatAlpha);
}
if (mIsTranslateWithoutWorkspace) {
return;
}
mWorkspace.setWorkspaceYTranslationAndAlpha(
- PARALLAX_COEFFICIENT * (-mShiftRange + shiftCurrent), interpolation);
+ PARALLAX_COEFFICIENT * (-mShiftRange + shiftCurrent), workspaceAlpha);
if (!mDetector.isDraggingState()) {
mContainerVelocity = mDetector.computeVelocity(shiftCurrent - shiftPrevious,
diff --git a/src/com/android/launcher3/graphics/RadialGradientView.java b/src/com/android/launcher3/graphics/GradientView.java
index cf6851c00..c5b769366 100644
--- a/src/com/android/launcher3/graphics/RadialGradientView.java
+++ b/src/com/android/launcher3/graphics/GradientView.java
@@ -27,7 +27,8 @@ import android.graphics.RectF;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.View;
-import android.view.animation.DecelerateInterpolator;
+import android.view.animation.AccelerateInterpolator;
+import android.view.animation.Interpolator;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
@@ -36,63 +37,50 @@ import com.android.launcher3.Utilities;
* Draws a translucent radial gradient background from an initial state with progress 0.0 to a
* final state with progress 1.0;
*/
-public class RadialGradientView extends View {
+public class GradientView extends View {
- public static final int DEFAULT_COLOR_1 = Color.WHITE;
- public static final int DEFAULT_COLOR_2 = Color.BLACK;
+ private static final int DEFAULT_COLOR = Color.WHITE;
+ private static final float GRADIENT_ALPHA_MASK_LENGTH_DP = 300;
+ private static final float FINAL_GRADIENT_ALPHA = 0.75f;
+ private static final boolean DEBUG = false;
private static Bitmap sFinalGradientMask;
private static Bitmap sAlphaGradientMask;
- // TODO needs to be cleaned up once design finalizes
- static class Config {
- // dimens
- final float gradientCenterX = 0.5f;
- final float gradientCenterY = 1.05f;
- final float gradientHeadStartFactor = 0.35f;
- final float gradientAlphaMaskLengthDp = 700;
- // interpolation
- final boolean useGradientAlphaDecel = false;
- final float decelFactorForGradientAlpha = 2f;
- // colors
- final float finalGradientAlpha = 0.75f;
- int color1 = DEFAULT_COLOR_1;
- int color2 = DEFAULT_COLOR_2;
- }
-
+ private int mColor1 = DEFAULT_COLOR;
+ private int mColor2 = DEFAULT_COLOR;
+ private int mWidth;
+ private int mHeight;
private final RectF mAlphaMaskRect = new RectF();
private final RectF mFinalMaskRect = new RectF();
private final Paint mPaint = new Paint();
- private final Config mConfig = new Config();
- private final DecelerateInterpolator mDecelInterpolator;
private float mProgress;
- private int mWidth;
- private int mHeight;
private final int mMaskHeight;
private final Context mAppContext;
+ private final Paint mDebugPaint = DEBUG ? new Paint() : null;
+ private final Interpolator mAccelerator = new AccelerateInterpolator();
- public RadialGradientView(Context context, AttributeSet attrs) {
+ public GradientView(Context context, AttributeSet attrs) {
super(context, attrs);
this.mAppContext = context.getApplicationContext();
- this.mDecelInterpolator = new DecelerateInterpolator(mConfig.decelFactorForGradientAlpha);
- this.mMaskHeight = Utilities.pxFromDp(mConfig.gradientAlphaMaskLengthDp,
+ this.mMaskHeight = Utilities.pxFromDp(GRADIENT_ALPHA_MASK_LENGTH_DP,
mAppContext.getResources().getDisplayMetrics());
if (sFinalGradientMask == null) {
sFinalGradientMask = Utilities.convertToAlphaMask(
- Utilities.createOnePixBitmap(), mConfig.finalGradientAlpha);
+ Utilities.createOnePixBitmap(), FINAL_GRADIENT_ALPHA);
}
if (sAlphaGradientMask == null) {
Bitmap alphaMaskFromResource = BitmapFactory.decodeResource(context.getResources(),
R.drawable.all_apps_alpha_mask);
sAlphaGradientMask = Utilities.convertToAlphaMask(
- alphaMaskFromResource, mConfig.finalGradientAlpha);
+ alphaMaskFromResource, FINAL_GRADIENT_ALPHA);
}
}
public void onExtractedColorsChanged(int color1, int color2) {
- mConfig.color1 = color1;
- mConfig.color2 = color2;
+ this.mColor1 = color1;
+ this.mColor2 = color2;
if (mWidth + mHeight > 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 521fbedd6..feb3f030f 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);
+ }
}
}