Folder polish
- Update folder hint text to ensure enough contrast.
- Clamp down on alpha when animating to local color extraction
- Update colors to new spec.
Bug: 179209484
Bug: 175329686
Test: manual
Change-Id: I9471504e10f02630ae13b2c478ced1ee05bd5220
diff --git a/res/values-v31/colors.xml b/res/values-v31/colors.xml
index 5ade64c..7b37001 100644
--- a/res/values-v31/colors.xml
+++ b/res/values-v31/colors.xml
@@ -28,6 +28,9 @@
<color name="workspace_text_color_light">@android:color/system_neutral1_0</color>
<color name="workspace_text_color_dark">@android:color/system_neutral1_1000</color>
+ <color name="folder_hint_text_color_light">@android:color/system_neutral1_50</color>
+ <color name="folder_hint_text_color_dark">@android:color/system_neutral2_700</color>
+
<color name="text_color_primary_dark">@android:color/system_neutral1_50</color>
<color name="text_color_secondary_dark">@android:color/system_neutral2_200</color>
<color name="text_color_tertiary_dark">@android:color/system_neutral2_400</color>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index e6553a2..ae55485 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -52,6 +52,9 @@
<color name="workspace_text_color_light">#FFF</color>
<color name="workspace_text_color_dark">#FF000000</color>
+ <color name="folder_hint_text_color_light">#FFF</color>
+ <color name="folder_hint_text_color_dark">#FF000000</color>
+
<color name="text_color_primary_dark">#FFFFFFFF</color>
<color name="text_color_secondary_dark">#FFFFFFFF</color>
<color name="text_color_tertiary_dark">#CCFFFFFF</color>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 6d22951..c668b0c 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -51,7 +51,7 @@
<item name="folderIconBorderColor">?android:attr/colorPrimary</item>
<item name="folderTextColor">?android:attr/textColorPrimary</item>
<item name="isFolderDarkText">true</item>
- <item name="folderHintColor">#89616161</item>
+ <item name="folderHintColor">@color/folder_hint_text_color_dark</item>
<item name="loadingIconColor">#CCFFFFFF</item>
<item name="iconOnlyShortcutColor">?android:attr/textColorSecondary</item>
<item name="workProfileOverlayTextColor">#FF212121</item>
@@ -73,6 +73,7 @@
<item name="folderFillColor">#FF3C4043</item> <!-- 100% GM2 800 -->
<item name="folderTextColor">?attr/workspaceTextColor</item>
<item name="isFolderDarkText">?attr/isWorkspaceDarkText</item>
+ <item name="folderHintColor">@color/folder_hint_text_color_dark</item>
<item name="disabledIconAlpha">.254</item>
</style>
@@ -89,6 +90,7 @@
<item name="folderIconBorderColor">#FF80868B</item>
<item name="folderTextColor">?attr/workspaceTextColor</item>
<item name="isFolderDarkText">true</item>
+ <item name="folderHintColor">@color/folder_hint_text_color_dark</item>
</style>
<style name="LauncherTheme.Dark" parent="@style/LauncherTheme">
@@ -110,7 +112,7 @@
<item name="folderIconBorderColor">?android:attr/colorPrimary</item>
<item name="folderTextColor">?android:attr/textColorPrimary</item>
<item name="isFolderDarkText">false</item>
- <item name="folderHintColor">#89CCCCCC</item>
+ <item name="folderHintColor">@color/folder_hint_text_color_light</item>
<item name="isMainColorDark">true</item>
<item name="loadingIconColor">#99FFFFFF</item>
<item name="iconOnlyShortcutColor">#B3FFFFFF</item>
@@ -123,6 +125,7 @@
<item name="folderFillColor">#FF3C4043</item> <!-- 100% GM2 800 -->
<item name="folderTextColor">@android:color/white</item>
<item name="isFolderDarkText">false</item>
+ <item name="folderHintColor">@color/folder_hint_text_color_light</item>
<item name="disabledIconAlpha">.54</item>
</style>
@@ -131,6 +134,7 @@
<item name="folderFillColor">#CDFFFFFF</item>
<item name="folderTextColor">?attr/workspaceTextColor</item>
<item name="isFolderDarkText">?attr/isWorkspaceDarkText</item>
+ <item name="folderHintColor">@color/folder_hint_text_color_dark</item>
<item name="workspaceTextColor">@color/workspace_text_color_dark</item>
<item name="workspaceShadowColor">@android:color/transparent</item>
<item name="workspaceAmbientShadowColor">@android:color/transparent</item>
diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java
index b3952ca..9100947 100644
--- a/src/com/android/launcher3/AbstractFloatingView.java
+++ b/src/com/android/launcher3/AbstractFloatingView.java
@@ -39,7 +39,6 @@
import com.android.launcher3.util.TouchController;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.BaseDragLayer;
-import com.android.launcher3.widget.LocalColorExtractor;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -112,21 +111,12 @@
protected boolean mIsOpen;
- // Index used to get background color when using local wallpaper color extraction.
- protected int mColorExtractionIndex;
-
public AbstractFloatingView(Context context, AttributeSet attrs) {
super(context, attrs);
- init(context);
}
public AbstractFloatingView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- init(context);
- }
-
- private void init(Context context) {
- mColorExtractionIndex = LocalColorExtractor.getColorIndex(context);
}
/**
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index f5a8ef6..e387627 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -32,8 +32,10 @@
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
+import android.annotation.TargetApi;
import android.appwidget.AppWidgetHostView;
import android.content.Context;
+import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.Insets;
import android.graphics.Path;
@@ -65,6 +67,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
+import androidx.core.graphics.ColorUtils;
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.Alarm;
@@ -157,13 +160,18 @@
private static final float ICON_OVERSCROLL_WIDTH_FACTOR = 0.45f;
private static final int FOLDER_NAME_ANIMATION_DURATION = 633;
- private static final int FOLDER_COLOR_ANIMATION_DURATION = 150;
+ private static final int FOLDER_COLOR_ANIMATION_DURATION = 200;
private static final int REORDER_DELAY = 250;
private static final int ON_EXIT_CLOSE_DELAY = 400;
private static final Rect sTempRect = new Rect();
private static final int MIN_FOLDERS_FOR_HARDWARE_OPTIMIZATION = 10;
+ // Index used to get background color when using local wallpaper color extraction,
+ private static final int DARK_COLOR_EXTRACTION_INDEX = android.R.color.system_neutral1_900;
+ private static final int LIGHT_COLOR_EXTRACTION_INDEX = android.R.color.system_neutral2_500;
+ private static final int LIGHT_COLOR_L_STAR = 98;
+
private final Alarm mReorderAlarm = new Alarm();
private final Alarm mOnExitAlarm = new Alarm();
private final Alarm mOnScrollHintAlarm = new Alarm();
@@ -296,8 +304,7 @@
}
if (Utilities.ATLEAST_S) {
- mColorExtractionIndex = LocalColorExtractor.getColorIndex(
- !Themes.getAttrBoolean(getContext(), R.attr.isFolderDarkText));
+ boolean isFolderDarkText = Themes.getAttrBoolean(getContext(), R.attr.isFolderDarkText);
mColorExtractor = LocalColorExtractor.newInstance(getContext());
mColorListener = (RectF rect, SparseIntArray extractedColors) -> {
mColorChangeRunnable = () -> {
@@ -313,11 +320,14 @@
mOpenAnimationColorChangeAnimator = null;
}
- // Start a new animator to the extracted color.
- int newColor = extractedColors.get(mColorExtractionIndex);
+ // Start a new animator to the extracted color. Clamp down on the alpha
+ // to prevent folder from being transparent for too long.
GradientDrawable bg = (GradientDrawable) getBackground();
- mColorChangeAnimator = ObjectAnimator.ofArgb(bg, "color",
- bg.getColor().getDefaultColor(), newColor).setDuration(duration);
+ int currentColor = ColorUtils.setAlphaComponent(bg.getColor().getDefaultColor(),
+ 255);
+ int newColor = getExtractedColor(extractedColors, isFolderDarkText);
+ mColorChangeAnimator = ObjectAnimator.ofArgb(bg, "color", currentColor,
+ newColor).setDuration(duration);
mColorChangeAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
@@ -337,6 +347,21 @@
}
}
+ /**
+ * Returns an index used to query the color of interest from the list of extracted colors.
+ * @param hasDarkText True when dark index is wanted, False when light index is wanted.
+ */
+ @TargetApi(Build.VERSION_CODES.S)
+ private int getExtractedColor(SparseIntArray colors, boolean hasDarkText) {
+ int color = colors.get(hasDarkText
+ ? LIGHT_COLOR_EXTRACTION_INDEX
+ : DARK_COLOR_EXTRACTION_INDEX);
+ if (hasDarkText) {
+ color = ColorStateList.valueOf(color).withLStar(LIGHT_COLOR_L_STAR).getDefaultColor();
+ }
+ return color;
+ }
+
public boolean onLongClick(View v) {
// Return if global dragging is not enabled
if (!mLauncherDelegate.isDraggingEnabled()) return true;
diff --git a/src/com/android/launcher3/widget/LocalColorExtractor.java b/src/com/android/launcher3/widget/LocalColorExtractor.java
index e479b7d..8ae6b2e 100644
--- a/src/com/android/launcher3/widget/LocalColorExtractor.java
+++ b/src/com/android/launcher3/widget/LocalColorExtractor.java
@@ -28,7 +28,6 @@
import com.android.launcher3.Launcher;
import com.android.launcher3.R;
-import com.android.launcher3.Utilities;
import com.android.launcher3.util.ResourceBasedOverride;
import java.util.List;
@@ -36,10 +35,6 @@
/** Extracts the colors we need from the wallpaper at given locations. */
public class LocalColorExtractor implements ResourceBasedOverride {
- // Index used to get background color when using local wallpaper color extraction,
- private static final int LIGHT_COLOR_EXTRACTION_INDEX = android.R.color.system_accent2_50;
- private static final int DARK_COLOR_EXTRACTION_INDEX = android.R.color.system_accent2_800;
-
/** Listener for color changes on a screen location. */
public interface Listener {
/**
@@ -108,19 +103,4 @@
RectF colorExtractionRectOut) {
// no-op
}
-
- /**
- * Returns an index used to query the color of interest from the list of extracted colors.
- */
- public static int getColorIndex(Context context) {
- return getColorIndex(Utilities.isDarkTheme(context));
- }
-
- /**
- * Returns an index used to query the color of interest from the list of extracted colors.
- * @param getDarkIndex True when dark index is wanted, False when light index is wanted.
- */
- public static int getColorIndex(boolean getDarkIndex) {
- return getDarkIndex ? DARK_COLOR_EXTRACTION_INDEX : LIGHT_COLOR_EXTRACTION_INDEX;
- }
}