Merge "Update popup colors. Add local color extraction behind a flag." into sc-dev am: bd51e6e3f3
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15065087
Change-Id: I900c337c3fb3bd6296b95102ec55d4e6c7057e29
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 0000000..a5bd636
--- /dev/null
+++ b/res/color-night-v31/folder_background_dark.xml
@@ -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>
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 0000000..ba74128
--- /dev/null
+++ b/res/color-night-v31/popup_color_first.xml
@@ -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="?attr/popupColorPrimary"
+ android:lStar="20" />
+</selector>
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 0000000..efc6205
--- /dev/null
+++ b/res/color-night-v31/popup_color_second.xml
@@ -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="?attr/popupColorPrimary"
+ android:lStar="15" />
+</selector>
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 0000000..591c7ed
--- /dev/null
+++ b/res/color-night-v31/popup_color_third.xml
@@ -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="?attr/popupColorPrimary"
+ android:lStar="10" />
+</selector>
diff --git a/res/color-v31/folder_background_light.xml b/res/color-v31/folder_background_light.xml
new file mode 100644
index 0000000..e3c7e7d
--- /dev/null
+++ b/res/color-v31/folder_background_light.xml
@@ -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_neutral1_50"
+ android:lStar="98" />
+</selector>
diff --git a/res/color-v31/popup_color_first.xml b/res/color-v31/popup_color_first.xml
new file mode 100644
index 0000000..28d9155
--- /dev/null
+++ b/res/color-v31/popup_color_first.xml
@@ -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="?attr/popupColorPrimary"
+ android:lStar="98" />
+</selector>
diff --git a/res/color-v31/popup_color_second.xml b/res/color-v31/popup_color_second.xml
new file mode 100644
index 0000000..dec562c
--- /dev/null
+++ b/res/color-v31/popup_color_second.xml
@@ -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="?attr/popupColorPrimary"
+ android:lStar="95" />
+</selector>
diff --git a/res/color-v31/popup_color_third.xml b/res/color-v31/popup_color_third.xml
new file mode 100644
index 0000000..582232c
--- /dev/null
+++ b/res/color-v31/popup_color_third.xml
@@ -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="?attr/popupColorPrimary"
+ android:lStar="90" />
+</selector>
diff --git a/res/color/popup_color_first.xml b/res/color/popup_color_first.xml
new file mode 100644
index 0000000..d9999a2
--- /dev/null
+++ b/res/color/popup_color_first.xml
@@ -0,0 +1,18 @@
+<?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="?attr/popupColorPrimary" />
+</selector>
diff --git a/res/color/popup_color_second.xml b/res/color/popup_color_second.xml
new file mode 100644
index 0000000..d9999a2
--- /dev/null
+++ b/res/color/popup_color_second.xml
@@ -0,0 +1,18 @@
+<?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="?attr/popupColorPrimary" />
+</selector>
diff --git a/res/color/popup_color_third.xml b/res/color/popup_color_third.xml
new file mode 100644
index 0000000..d7e9e79
--- /dev/null
+++ b/res/color/popup_color_third.xml
@@ -0,0 +1,18 @@
+<?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="?attr/popupColorPrimary" />
+</selector>
\ No newline at end of file
diff --git a/res/values-v31/colors.xml b/res/values-v31/colors.xml
index 5aae1c7..26ee123 100644
--- a/res/values-v31/colors.xml
+++ b/res/values-v31/colors.xml
@@ -39,9 +39,7 @@
<color name="text_color_tertiary_dark">@android:color/system_neutral2_400</color>
<color name="wallpaper_popup_scrim">@android:color/system_neutral1_900</color>
- <color name="folder_background_light" android:lstar="98">@android:color/system_neutral1_50</color>
- <color name="folder_background_dark" android:lstar="30">@android:color/system_neutral2_800</color>
-
+
<color name="folder_dot_color">@android:color/system_accent2_50</color>
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index 5087c2c..b918826 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -78,6 +78,9 @@
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 cb35f74..a89fb3b 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.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 @@
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 @@
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 @@
* 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 @@
}
}
+ 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 @@
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 @@
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);
}