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
This commit is contained in:
parent
f9d2082cf3
commit
b77878ebe3
|
@ -16,5 +16,5 @@
|
|||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item
|
||||
android:color="@android:color/system_neutral2_50"
|
||||
android:lStar="30" />
|
||||
android:lStar="35" />
|
||||
</selector>
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2021 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item
|
||||
android:color="@android:color/system_neutral2_50"
|
||||
android:lStar="30" />
|
||||
</selector>
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2021 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item
|
||||
android:color="@android:color/system_accent2_50"
|
||||
android:lStar="80" />
|
||||
</selector>
|
|
@ -16,6 +16,6 @@
|
|||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="?attr/folderFillColor" />
|
||||
<solid android:color="?attr/folderBackgroundColor" />
|
||||
<corners android:radius="?android:attr/dialogCornerRadius" />
|
||||
</shape>
|
||||
|
|
|
@ -16,6 +16,6 @@
|
|||
-->
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="?attr/folderFillColor" />
|
||||
<solid android:color="?attr/folderBackgroundColor" />
|
||||
<corners android:radius="@dimen/bg_round_rect_radius" />
|
||||
</shape>
|
||||
|
|
|
@ -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"
|
||||
/>
|
||||
|
|
|
@ -43,7 +43,8 @@
|
|||
|
||||
<attr name="folderDotColor" format="color" />
|
||||
<attr name="folderPaginationColor" format="color" />
|
||||
<attr name="folderFillColor" format="color" />
|
||||
<attr name="folderPreviewColor" format="color" />
|
||||
<attr name="folderBackgroundColor" format="color" />
|
||||
<attr name="folderIconRadius" format="float" />
|
||||
<attr name="folderIconBorderColor" format="color" />
|
||||
<attr name="folderTextColor" format="color" />
|
||||
|
@ -72,7 +73,7 @@
|
|||
|
||||
<!-- BubbleTextView specific attributes. -->
|
||||
<declare-styleable name="FolderIconPreview">
|
||||
<attr name="folderFillColor" />
|
||||
<attr name="folderPreviewColor" />
|
||||
<attr name="folderIconBorderColor" />
|
||||
<attr name="folderDotColor" />
|
||||
</declare-styleable>
|
||||
|
|
|
@ -63,6 +63,9 @@
|
|||
<color name="folder_background_light">#F9F9F9</color>
|
||||
<color name="folder_background_dark">#464746</color>
|
||||
|
||||
<color name="folder_preview_light">#F9F9F9</color>
|
||||
<color name="folder_preview_dark">#464746</color>
|
||||
|
||||
<color name="folder_dot_color">?attr/colorPrimary</color>
|
||||
<color name="folder_pagination_color_light">#ff006c5f</color>
|
||||
<color name="folder_pagination_color_dark">#ffbfebe3</color>
|
||||
|
|
|
@ -51,7 +51,8 @@
|
|||
<item name="widgetsTheme">@style/WidgetContainerTheme</item>
|
||||
<item name="folderDotColor">@color/folder_dot_color</item>
|
||||
<item name="folderPaginationColor">@color/folder_pagination_color_light</item>
|
||||
<item name="folderFillColor">@color/folder_background_light</item>
|
||||
<item name="folderPreviewColor">@color/folder_preview_light</item>
|
||||
<item name="folderBackgroundColor">@color/folder_background_light</item>
|
||||
<item name="folderIconBorderColor">?android:attr/colorPrimary</item>
|
||||
<item name="folderTextColor">@color/workspace_text_color_dark</item>
|
||||
<item name="isFolderDarkText">true</item>
|
||||
|
@ -110,7 +111,8 @@
|
|||
<item name="widgetsTheme">@style/WidgetContainerTheme.Dark</item>
|
||||
<item name="folderDotColor">@color/folder_dot_color</item>
|
||||
<item name="folderPaginationColor">@color/folder_pagination_color_dark</item>
|
||||
<item name="folderFillColor">@color/folder_background_dark</item>
|
||||
<item name="folderPreviewColor">@color/folder_preview_dark</item>
|
||||
<item name="folderBackgroundColor">@color/folder_background_dark</item>
|
||||
<item name="folderIconBorderColor">?android:attr/colorPrimary</item>
|
||||
<item name="folderTextColor">@color/workspace_text_color_light</item>
|
||||
<item name="isFolderDarkText">false</item>
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue