From b77878ebe319b1a24765a9632fa3bc368ef95014 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Wed, 6 Oct 2021 16:57:33 -0700 Subject: [PATCH] Update folder preview and folder background colors. Bug: 201332301 Test: light theme / dark theme open and close folder, ensure colors are accurate Change-Id: I49198eb2faee03111be33051fd1cb08094844c77 --- .../folder_background_dark.xml | 2 +- res/color-night-v31/folder_preview_dark.xml | 20 ++++++++++++++++ res/color-v31/folder_preview_light.xml | 20 ++++++++++++++++ res/drawable-v28/round_rect_folder.xml | 2 +- res/drawable/round_rect_folder.xml | 2 +- res/layout/keyboard_drag_and_drop.xml | 2 +- res/values/attrs.xml | 5 ++-- res/values/colors.xml | 3 +++ res/values/styles.xml | 6 +++-- .../folder/FolderAnimationManager.java | 13 +++-------- .../launcher3/folder/PreviewBackground.java | 23 ++++--------------- 11 files changed, 62 insertions(+), 36 deletions(-) create mode 100644 res/color-night-v31/folder_preview_dark.xml create mode 100644 res/color-v31/folder_preview_light.xml diff --git a/res/color-night-v31/folder_background_dark.xml b/res/color-night-v31/folder_background_dark.xml index a5bd6367d5..d607395155 100644 --- a/res/color-night-v31/folder_background_dark.xml +++ b/res/color-night-v31/folder_background_dark.xml @@ -16,5 +16,5 @@ + android:lStar="35" /> diff --git a/res/color-night-v31/folder_preview_dark.xml b/res/color-night-v31/folder_preview_dark.xml new file mode 100644 index 0000000000..a5bd6367d5 --- /dev/null +++ b/res/color-night-v31/folder_preview_dark.xml @@ -0,0 +1,20 @@ + + + + + diff --git a/res/color-v31/folder_preview_light.xml b/res/color-v31/folder_preview_light.xml new file mode 100644 index 0000000000..fe30c87202 --- /dev/null +++ b/res/color-v31/folder_preview_light.xml @@ -0,0 +1,20 @@ + + + + + diff --git a/res/drawable-v28/round_rect_folder.xml b/res/drawable-v28/round_rect_folder.xml index 0403be09b0..77a4aa4e98 100644 --- a/res/drawable-v28/round_rect_folder.xml +++ b/res/drawable-v28/round_rect_folder.xml @@ -16,6 +16,6 @@ --> - + diff --git a/res/drawable/round_rect_folder.xml b/res/drawable/round_rect_folder.xml index 8b3d06ca9b..6c5864e2e9 100644 --- a/res/drawable/round_rect_folder.xml +++ b/res/drawable/round_rect_folder.xml @@ -16,6 +16,6 @@ --> - + diff --git a/res/layout/keyboard_drag_and_drop.xml b/res/layout/keyboard_drag_and_drop.xml index e9463c40a0..bc3a9c145a 100644 --- a/res/layout/keyboard_drag_and_drop.xml +++ b/res/layout/keyboard_drag_and_drop.xml @@ -26,7 +26,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" - android:background="?attr/folderFillColor" + android:background="?attr/folderBackgroundColor" android:padding="8dp" android:textColor="?attr/folderTextColor" /> diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 319c87d85f..6d71a6df02 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -43,7 +43,8 @@ - + + @@ -72,7 +73,7 @@ - + diff --git a/res/values/colors.xml b/res/values/colors.xml index 5020127440..0b1b451302 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -63,6 +63,9 @@ #F9F9F9 #464746 + #F9F9F9 + #464746 + ?attr/colorPrimary #ff006c5f #ffbfebe3 diff --git a/res/values/styles.xml b/res/values/styles.xml index 8ad4fcdb97..818a032f94 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -51,7 +51,8 @@ @style/WidgetContainerTheme @color/folder_dot_color @color/folder_pagination_color_light - @color/folder_background_light + @color/folder_preview_light + @color/folder_background_light ?android:attr/colorPrimary @color/workspace_text_color_dark true @@ -110,7 +111,8 @@ @style/WidgetContainerTheme.Dark @color/folder_dot_color @color/folder_pagination_color_dark - @color/folder_background_dark + @color/folder_preview_dark + @color/folder_background_dark ?android:attr/colorPrimary @color/workspace_text_color_light false diff --git a/src/com/android/launcher3/folder/FolderAnimationManager.java b/src/com/android/launcher3/folder/FolderAnimationManager.java index 399d142acb..61ffd9d00c 100644 --- a/src/com/android/launcher3/folder/FolderAnimationManager.java +++ b/src/com/android/launcher3/folder/FolderAnimationManager.java @@ -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); diff --git a/src/com/android/launcher3/folder/PreviewBackground.java b/src/com/android/launcher3/folder/PreviewBackground.java index 18d0b10528..8f9fa8a575 100644 --- a/src/com/android/launcher3/folder/PreviewBackground.java +++ b/src/com/android/launcher3/folder/PreviewBackground.java @@ -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() {