Update popup colors. Add local color extraction behind a flag.
- Also updating folder backgrounds, lStar only works in ColorStateList. Bug: 191496301 Test: test wallpaper with light text, in light mode test again in dark mode test wallpaper with dark text, in light mode test again in dark mode Change-Id: I2d43d874e7e2fad6a9a0e039058beb58b204fa96
This commit is contained in:
parent
61bc5c6c93
commit
27de7d2643
|
@ -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="?attr/popupColorPrimary"
|
||||
android:lStar="20" />
|
||||
</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="?attr/popupColorPrimary"
|
||||
android:lStar="15" />
|
||||
</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="?attr/popupColorPrimary"
|
||||
android:lStar="10" />
|
||||
</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_neutral1_50"
|
||||
android:lStar="98" />
|
||||
</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="?attr/popupColorPrimary"
|
||||
android:lStar="98" />
|
||||
</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="?attr/popupColorPrimary"
|
||||
android:lStar="95" />
|
||||
</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="?attr/popupColorPrimary"
|
||||
android:lStar="90" />
|
||||
</selector>
|
|
@ -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>
|
|
@ -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>
|
|
@ -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>
|
|
@ -39,8 +39,6 @@
|
|||
<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>
|
||||
</resources>
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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<T extends StatefulActivity<LauncherState>>
|
|||
|
||||
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<T extends StatefulActivity<LauncherState>>
|
|||
|
||||
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<T extends StatefulActivity<LauncherState>>
|
|||
* 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<T extends StatefulActivity<LauncherState>>
|
|||
}
|
||||
}
|
||||
|
||||
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<T extends StatefulActivity<LauncherState>>
|
|||
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<T extends StatefulActivity<LauncherState>>
|
|||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue