diff --git a/res/color-night-v31/folder_background_dark.xml b/res/color-night-v31/folder_background_dark.xml new file mode 100644 index 0000000000..a5bd6367d5 --- /dev/null +++ b/res/color-night-v31/folder_background_dark.xml @@ -0,0 +1,20 @@ + + + + + diff --git a/res/color-night-v31/popup_color_first.xml b/res/color-night-v31/popup_color_first.xml new file mode 100644 index 0000000000..ba7412859c --- /dev/null +++ b/res/color-night-v31/popup_color_first.xml @@ -0,0 +1,20 @@ + + + + + diff --git a/res/color-night-v31/popup_color_second.xml b/res/color-night-v31/popup_color_second.xml new file mode 100644 index 0000000000..efc620532a --- /dev/null +++ b/res/color-night-v31/popup_color_second.xml @@ -0,0 +1,20 @@ + + + + + diff --git a/res/color-night-v31/popup_color_third.xml b/res/color-night-v31/popup_color_third.xml new file mode 100644 index 0000000000..591c7ede34 --- /dev/null +++ b/res/color-night-v31/popup_color_third.xml @@ -0,0 +1,20 @@ + + + + + diff --git a/res/color-v31/folder_background_light.xml b/res/color-v31/folder_background_light.xml new file mode 100644 index 0000000000..e3c7e7dab1 --- /dev/null +++ b/res/color-v31/folder_background_light.xml @@ -0,0 +1,20 @@ + + + + + diff --git a/res/color-v31/popup_color_first.xml b/res/color-v31/popup_color_first.xml new file mode 100644 index 0000000000..28d9155f5e --- /dev/null +++ b/res/color-v31/popup_color_first.xml @@ -0,0 +1,20 @@ + + + + + diff --git a/res/color-v31/popup_color_second.xml b/res/color-v31/popup_color_second.xml new file mode 100644 index 0000000000..dec562c046 --- /dev/null +++ b/res/color-v31/popup_color_second.xml @@ -0,0 +1,20 @@ + + + + + diff --git a/res/color-v31/popup_color_third.xml b/res/color-v31/popup_color_third.xml new file mode 100644 index 0000000000..582232c536 --- /dev/null +++ b/res/color-v31/popup_color_third.xml @@ -0,0 +1,20 @@ + + + + + diff --git a/res/color/popup_color_first.xml b/res/color/popup_color_first.xml new file mode 100644 index 0000000000..d9999a20c8 --- /dev/null +++ b/res/color/popup_color_first.xml @@ -0,0 +1,18 @@ + + + + + diff --git a/res/color/popup_color_second.xml b/res/color/popup_color_second.xml new file mode 100644 index 0000000000..d9999a20c8 --- /dev/null +++ b/res/color/popup_color_second.xml @@ -0,0 +1,18 @@ + + + + + diff --git a/res/color/popup_color_third.xml b/res/color/popup_color_third.xml new file mode 100644 index 0000000000..d7e9e794e2 --- /dev/null +++ b/res/color/popup_color_third.xml @@ -0,0 +1,18 @@ + + + + + \ No newline at end of file diff --git a/res/values-v31/colors.xml b/res/values-v31/colors.xml index 1785623581..71eaa9eb96 100644 --- a/res/values-v31/colors.xml +++ b/res/values-v31/colors.xml @@ -39,8 +39,6 @@ @android:color/system_neutral2_400 @android:color/system_neutral1_900 - @android:color/system_neutral1_50 - @android:color/system_neutral2_800 - + @android:color/system_accent2_50 diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index d65eb2209a..66f5c87337 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -78,6 +78,9 @@ public final class FeatureFlags { public static final BooleanFlag UNSTABLE_SPRINGS = getDebugFlag( "UNSTABLE_SPRINGS", false, "Enable unstable springs for quickstep animations"); + public static final BooleanFlag ENABLE_LOCAL_COLOR_POPUPS = getDebugFlag( + "ENABLE_LOCAL_COLOR_POPUPS", false, "Enable local color extraction for popups."); + public static final BooleanFlag KEYGUARD_ANIMATION = getDebugFlag( "KEYGUARD_ANIMATION", false, "Enable animation for keyguard going away on wallpaper"); diff --git a/src/com/android/launcher3/popup/ArrowPopup.java b/src/com/android/launcher3/popup/ArrowPopup.java index cb35f74135..a89fb3b618 100644 --- a/src/com/android/launcher3/popup/ArrowPopup.java +++ b/src/com/android/launcher3/popup/ArrowPopup.java @@ -16,9 +16,12 @@ package com.android.launcher3.popup; +import static androidx.core.content.ContextCompat.getColorStateList; + import static com.android.launcher3.anim.Interpolators.ACCELERATED_EASE; import static com.android.launcher3.anim.Interpolators.DECELERATED_EASE; import static com.android.launcher3.anim.Interpolators.LINEAR; +import static com.android.launcher3.config.FeatureFlags.ENABLE_LOCAL_COLOR_POPUPS; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -28,6 +31,7 @@ import android.animation.ValueAnimator; import android.annotation.TargetApi; import android.content.Context; import android.content.res.Resources; +import android.graphics.Color; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.ColorDrawable; @@ -133,6 +137,8 @@ public abstract class ArrowPopup> private final String mIterateChildrenTag; + private final int[] mColors; + public ArrowPopup(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mInflater = LayoutInflater.from(context); @@ -171,9 +177,19 @@ public abstract class ArrowPopup> boolean isAboveAnotherSurface = getTopOpenViewWithType(mLauncher, TYPE_FOLDER) != null || mLauncher.getStateManager().getState() == LauncherState.ALL_APPS; - if (!isAboveAnotherSurface && Utilities.ATLEAST_S) { + if (!isAboveAnotherSurface && Utilities.ATLEAST_S && ENABLE_LOCAL_COLOR_POPUPS.get()) { setupColorExtraction(); } + + if (isAboveAnotherSurface) { + mColors = new int[] { + getColorStateList(context, R.color.popup_color_first).getDefaultColor()}; + } else { + mColors = new int[] { + getColorStateList(context, R.color.popup_color_first).getDefaultColor(), + getColorStateList(context, R.color.popup_color_second).getDefaultColor(), + getColorStateList(context, R.color.popup_color_third).getDefaultColor()}; + } } public ArrowPopup(Context context, AttributeSet attrs) { @@ -220,6 +236,16 @@ public abstract class ArrowPopup> * Set the margins and radius of backgrounds after views are properly ordered. */ public void assignMarginsAndBackgrounds(ViewGroup viewGroup) { + assignMarginsAndBackgrounds(viewGroup, Color.TRANSPARENT); + } + + /** + * @param backgroundColor When Color.TRANSPARENT, we get color from {@link #mColors}. + * Otherwise, we will use this color for all child views. + */ + private void assignMarginsAndBackgrounds(ViewGroup viewGroup, int backgroundColor) { + final boolean getColorFromColorArray = backgroundColor == Color.TRANSPARENT; + int count = viewGroup.getChildCount(); int totalVisibleShortcuts = 0; for (int i = 0; i < count; i++) { @@ -229,8 +255,10 @@ public abstract class ArrowPopup> } } + int numVisibleChild = 0; int numVisibleShortcut = 0; View lastView = null; + AnimatorSet colorAnimator = new AnimatorSet(); for (int i = 0; i < count; i++) { View view = viewGroup.getChildAt(i); if (view.getVisibility() == VISIBLE) { @@ -242,8 +270,14 @@ public abstract class ArrowPopup> MarginLayoutParams mlp = (MarginLayoutParams) lastView.getLayoutParams(); mlp.bottomMargin = 0; + + if (getColorFromColorArray) { + backgroundColor = mColors[numVisibleChild % mColors.length]; + } + if (view instanceof ViewGroup && mIterateChildrenTag.equals(view.getTag())) { - assignMarginsAndBackgrounds((ViewGroup) view); + assignMarginsAndBackgrounds((ViewGroup) view, backgroundColor); + numVisibleChild++; continue; } @@ -261,8 +295,22 @@ public abstract class ArrowPopup> numVisibleShortcut++; } } + + if (!ENABLE_LOCAL_COLOR_POPUPS.get()) { + setChildColor(view, backgroundColor, colorAnimator); + // Arrow color matches the first child or the last child. + if (!mIsAboveIcon && numVisibleChild == 0) { + mArrowColor = backgroundColor; + } else if (mIsAboveIcon) { + mArrowColor = backgroundColor; + } + } + + numVisibleChild++; } } + + colorAnimator.setDuration(0).start(); measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); }