Merge "Update folder preview and folder background colors." into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
273aa1c7af
@@ -22,7 +22,6 @@ import static com.android.launcher3.BubbleTextView.TEXT_ALPHA_PROPERTY;
|
||||
import static com.android.launcher3.LauncherAnimUtils.SCALE_PROPERTY;
|
||||
import static com.android.launcher3.folder.ClippedFolderIconLayoutRule.MAX_NUM_ITEMS_IN_PREVIEW;
|
||||
import static com.android.launcher3.graphics.IconShape.getShape;
|
||||
import static com.android.launcher3.icons.GraphicsUtils.setColorAlphaBound;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorListenerAdapter;
|
||||
@@ -175,15 +174,9 @@ public class FolderAnimationManager {
|
||||
final float yDistance = initialY - lp.y;
|
||||
|
||||
// Set up the Folder background.
|
||||
final int finalColor;
|
||||
int folderFillColor = Themes.getAttrColor(mContext, R.attr.folderFillColor);
|
||||
if (mIsOpening) {
|
||||
finalColor = folderFillColor;
|
||||
} else {
|
||||
finalColor = mFolderBackground.getColor().getDefaultColor();
|
||||
}
|
||||
final int initialColor = setColorAlphaBound(
|
||||
folderFillColor, mPreviewBackground.getBackgroundAlpha());
|
||||
final int initialColor = Themes.getAttrColor(mContext, R.attr.folderPreviewColor);
|
||||
final int finalColor = Themes.getAttrColor(mContext, R.attr.folderBackgroundColor);
|
||||
|
||||
mFolderBackground.mutate();
|
||||
mFolderBackground.setColor(mIsOpening ? initialColor : finalColor);
|
||||
|
||||
|
||||
@@ -66,7 +66,6 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
|
||||
private final Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
|
||||
float mScale = 1f;
|
||||
private float mColorMultiplier = 1f;
|
||||
private int mBgColor;
|
||||
private int mStrokeColor;
|
||||
private int mDotColor;
|
||||
@@ -87,7 +86,6 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
|
||||
|
||||
// Drawing / animation configurations
|
||||
private static final float ACCEPT_SCALE_FACTOR = 1.20f;
|
||||
private static final float ACCEPT_COLOR_MULTIPLIER = 1.5f;
|
||||
|
||||
// Expressed on a scale from 0 to 255.
|
||||
private static final int BG_OPACITY = 255;
|
||||
@@ -154,7 +152,7 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
|
||||
TypedArray ta = context.getTheme().obtainStyledAttributes(R.styleable.FolderIconPreview);
|
||||
mDotColor = ta.getColor(R.styleable.FolderIconPreview_folderDotColor, 0);
|
||||
mStrokeColor = ta.getColor(R.styleable.FolderIconPreview_folderIconBorderColor, 0);
|
||||
mBgColor = ta.getColor(R.styleable.FolderIconPreview_folderFillColor, 0);
|
||||
mBgColor = ta.getColor(R.styleable.FolderIconPreview_folderPreviewColor, 0);
|
||||
ta.recycle();
|
||||
|
||||
DeviceProfile grid = activity.getDeviceProfile();
|
||||
@@ -227,8 +225,7 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
|
||||
}
|
||||
|
||||
public int getBgColor() {
|
||||
int alpha = (int) Math.min(MAX_BG_OPACITY, BG_OPACITY * mColorMultiplier);
|
||||
return setColorAlphaBound(mBgColor, alpha);
|
||||
return mBgColor;
|
||||
}
|
||||
|
||||
public int getDotColor() {
|
||||
@@ -384,14 +381,10 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
|
||||
return mDrawingDelegate != null;
|
||||
}
|
||||
|
||||
private void animateScale(float finalScale, float finalMultiplier,
|
||||
final Runnable onStart, final Runnable onEnd) {
|
||||
private void animateScale(float finalScale, final Runnable onStart, final Runnable onEnd) {
|
||||
final float scale0 = mScale;
|
||||
final float scale1 = finalScale;
|
||||
|
||||
final float bgMultiplier0 = mColorMultiplier;
|
||||
final float bgMultiplier1 = finalMultiplier;
|
||||
|
||||
if (mScaleAnimator != null) {
|
||||
mScaleAnimator.cancel();
|
||||
}
|
||||
@@ -403,7 +396,6 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
|
||||
public void onAnimationUpdate(ValueAnimator animation) {
|
||||
float prog = animation.getAnimatedFraction();
|
||||
mScale = prog * scale1 + (1 - prog) * scale0;
|
||||
mColorMultiplier = prog * bgMultiplier1 + (1 - prog) * bgMultiplier0;
|
||||
invalidate();
|
||||
}
|
||||
});
|
||||
@@ -429,8 +421,7 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
|
||||
}
|
||||
|
||||
public void animateToAccept(CellLayout cl, int cellX, int cellY) {
|
||||
animateScale(ACCEPT_SCALE_FACTOR, ACCEPT_COLOR_MULTIPLIER,
|
||||
() -> delegateDrawing(cl, cellX, cellY), null);
|
||||
animateScale(ACCEPT_SCALE_FACTOR, () -> delegateDrawing(cl, cellX, cellY), null);
|
||||
}
|
||||
|
||||
public void animateToRest() {
|
||||
@@ -440,11 +431,7 @@ public class PreviewBackground extends CellLayout.DelegatedCellDrawing {
|
||||
CellLayout cl = mDrawingDelegate;
|
||||
int cellX = mDelegateCellX;
|
||||
int cellY = mDelegateCellY;
|
||||
animateScale(1f, 1f, () -> delegateDrawing(cl, cellX, cellY), this::clearDrawingDelegate);
|
||||
}
|
||||
|
||||
public int getBackgroundAlpha() {
|
||||
return (int) Math.min(MAX_BG_OPACITY, BG_OPACITY * mColorMultiplier);
|
||||
animateScale(1f, () -> delegateDrawing(cl, cellX, cellY), this::clearDrawingDelegate);
|
||||
}
|
||||
|
||||
public float getStrokeWidth() {
|
||||
|
||||
Reference in New Issue
Block a user