diff --git a/res/values-v31/colors.xml b/res/values-v31/colors.xml
index 5ade64cb28..7b37001ade 100644
--- a/res/values-v31/colors.xml
+++ b/res/values-v31/colors.xml
@@ -28,6 +28,9 @@
@android:color/system_neutral1_0
@android:color/system_neutral1_1000
+ @android:color/system_neutral1_50
+ @android:color/system_neutral2_700
+
@android:color/system_neutral1_50
@android:color/system_neutral2_200
@android:color/system_neutral2_400
diff --git a/res/values/colors.xml b/res/values/colors.xml
index e6553a22bc..ae55485fb7 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -52,6 +52,9 @@
#FFF
#FF000000
+ #FFF
+ #FF000000
+
#FFFFFFFF
#FFFFFFFF
#CCFFFFFF
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 6d22951209..c668b0ccec 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -51,7 +51,7 @@
- ?android:attr/colorPrimary
- ?android:attr/textColorPrimary
- true
- - #89616161
+ - @color/folder_hint_text_color_dark
- #CCFFFFFF
- ?android:attr/textColorSecondary
- #FF212121
@@ -73,6 +73,7 @@
- #FF3C4043
- ?attr/workspaceTextColor
- ?attr/isWorkspaceDarkText
+ - @color/folder_hint_text_color_dark
- .254
@@ -89,6 +90,7 @@
- #FF80868B
- ?attr/workspaceTextColor
- true
+ - @color/folder_hint_text_color_dark
@@ -131,6 +134,7 @@
- #CDFFFFFF
- ?attr/workspaceTextColor
- ?attr/isWorkspaceDarkText
+ - @color/folder_hint_text_color_dark
- @color/workspace_text_color_dark
- @android:color/transparent
- @android:color/transparent
diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java
index b3952ca1bc..910094769a 100644
--- a/src/com/android/launcher3/AbstractFloatingView.java
+++ b/src/com/android/launcher3/AbstractFloatingView.java
@@ -39,7 +39,6 @@ import com.android.launcher3.anim.PendingAnimation;
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 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
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 f5a8ef6f1d..e3876278b2 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -32,8 +32,10 @@ import android.animation.AnimatorListenerAdapter;
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 android.widget.TextView;
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 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
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 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
}
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 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
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 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
}
}
+ /**
+ * 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 e479b7d049..8ae6b2e435 100644
--- a/src/com/android/launcher3/widget/LocalColorExtractor.java
+++ b/src/com/android/launcher3/widget/LocalColorExtractor.java
@@ -28,7 +28,6 @@ import androidx.annotation.Nullable;
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 @@ import java.util.List;
/** 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 @@ public class LocalColorExtractor implements ResourceBasedOverride {
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;
- }
}