Removing ENABLE_LOCAL_COLOR_POPUPS feature flag
The feature has been disabled for a while and is not working correctly.
Also there is no UX plan to revisit this currently
Bug: 206508141
Bug: 259733681
Test: Presubmit
Change-Id: If1279c22b9d074592ba181c7caa0cf38f9cb842e
diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java
index 9607da8..d522d88 100644
--- a/src/com/android/launcher3/config/FeatureFlags.java
+++ b/src/com/android/launcher3/config/FeatureFlags.java
@@ -79,10 +79,6 @@
public static final BooleanFlag PROMISE_APPS_IN_ALL_APPS = getDebugFlag(
"PROMISE_APPS_IN_ALL_APPS", false, "Add promise icon in all-apps");
- // TODO: b/206508141: Long pressing on some icons on home screen cause launcher to crash.
- 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 196cc56..9a745ab 100644
--- a/src/com/android/launcher3/popup/ArrowPopup.java
+++ b/src/com/android/launcher3/popup/ArrowPopup.java
@@ -21,14 +21,12 @@
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;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
-import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
@@ -36,15 +34,12 @@
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
-import android.os.Build;
import android.util.AttributeSet;
import android.util.Pair;
-import android.util.SparseIntArray;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.view.ViewTreeObserver;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
@@ -52,21 +47,17 @@
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.InsettableFrameLayout;
-import com.android.launcher3.Launcher;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
-import com.android.launcher3.Workspace;
import com.android.launcher3.dragndrop.DragLayer;
import com.android.launcher3.shortcuts.DeepShortcutView;
import com.android.launcher3.util.Themes;
import com.android.launcher3.views.ActivityContext;
import com.android.launcher3.views.BaseDragLayer;
-import com.android.launcher3.widget.LocalColorExtractor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.List;
/**
* A container for shortcuts to deep links and notifications associated with an app.
@@ -89,10 +80,6 @@
protected int CLOSE_CHILD_FADE_START_DELAY = 0;
protected int CLOSE_CHILD_FADE_DURATION = 140;
- // Index used to get background color when using local wallpaper color extraction,
- private static final int DARK_COLOR_EXTRACTION_INDEX = android.R.color.system_neutral2_800;
- private static final int LIGHT_COLOR_EXTRACTION_INDEX = android.R.color.system_accent2_50;
-
protected final Rect mTempRect = new Rect();
protected final LayoutInflater mInflater;
@@ -124,10 +111,8 @@
// The rect string of the view that the arrow is attached to, in screen reference frame.
protected int mArrowColor;
- protected final List<LocalColorExtractor> mColorExtractors;
protected final float mElevation;
- private final int mBackgroundColor;
private final String mIterateChildrenTag;
@@ -140,8 +125,8 @@
mActivityContext = ActivityContext.lookupContext(context);
mIsRtl = Utilities.isRtl(getResources());
- mBackgroundColor = Themes.getAttrColor(context, R.attr.popupColorPrimary);
- mArrowColor = mBackgroundColor;
+ int backgroundColor = Themes.getAttrColor(context, R.attr.popupColorPrimary);
+ mArrowColor = backgroundColor;
mElevation = getResources().getDimension(R.dimen.deep_shortcuts_elevation);
// Initialize arrow view
@@ -158,25 +143,18 @@
int smallerRadius = resources.getDimensionPixelSize(R.dimen.popup_smaller_radius);
mRoundedTop = new GradientDrawable();
- mRoundedTop.setColor(mBackgroundColor);
+ mRoundedTop.setColor(backgroundColor);
mRoundedTop.setCornerRadii(new float[] { mOutlineRadius, mOutlineRadius, mOutlineRadius,
mOutlineRadius, smallerRadius, smallerRadius, smallerRadius, smallerRadius});
mRoundedBottom = new GradientDrawable();
- mRoundedBottom.setColor(mBackgroundColor);
+ mRoundedBottom.setColor(backgroundColor);
mRoundedBottom.setCornerRadii(new float[] { smallerRadius, smallerRadius, smallerRadius,
smallerRadius, mOutlineRadius, mOutlineRadius, mOutlineRadius, mOutlineRadius});
mIterateChildrenTag = getContext().getString(R.string.popup_container_iterate_children);
- boolean shouldUseColorExtraction = mActivityContext.shouldUseColorExtractionForPopup();
- if (shouldUseColorExtraction && Utilities.ATLEAST_S && ENABLE_LOCAL_COLOR_POPUPS.get()) {
- mColorExtractors = new ArrayList<>();
- } else {
- mColorExtractors = null;
- }
-
- if (shouldUseColorExtraction) {
+ if (mActivityContext.shouldUseColorExtractionForPopup()) {
mColorIds = new int[]{R.color.popup_shade_first, R.color.popup_shade_second,
R.color.popup_shade_third};
} else {
@@ -220,11 +198,6 @@
}
/**
- * Called when all view inflation and reordering in complete.
- */
- protected void onInflationComplete(boolean isReversed) { }
-
- /**
* Set the margins and radius of backgrounds after views are properly ordered.
*/
public void assignMarginsAndBackgrounds(ViewGroup viewGroup) {
@@ -271,13 +244,9 @@
backgroundColor = colors[numVisibleChild % colors.length];
}
- if (!ENABLE_LOCAL_COLOR_POPUPS.get()) {
- // Arrow color matches the first child or the last child.
- if (!mIsAboveIcon && numVisibleChild == 0 && viewGroup == this) {
- mArrowColor = backgroundColor;
- } else if (mIsAboveIcon) {
- mArrowColor = backgroundColor;
- }
+ // Arrow color matches the first child or the last child.
+ if (mIsAboveIcon || (numVisibleChild == 0 && viewGroup == this)) {
+ mArrowColor = backgroundColor;
}
if (view instanceof ViewGroup && mIterateChildrenTag.equals(view.getTag())) {
@@ -301,10 +270,7 @@
}
}
- if (!ENABLE_LOCAL_COLOR_POPUPS.get()) {
- setChildColor(view, backgroundColor, colorAnimator);
- }
-
+ setChildColor(view, backgroundColor, colorAnimator);
numVisibleChild++;
}
}
@@ -320,85 +286,6 @@
return view instanceof DeepShortcutView;
}
- @TargetApi(Build.VERSION_CODES.S)
- private int getExtractedColor(SparseIntArray colors) {
- int index = Utilities.isDarkTheme(getContext())
- ? DARK_COLOR_EXTRACTION_INDEX
- : LIGHT_COLOR_EXTRACTION_INDEX;
- return colors.get(index, mBackgroundColor);
- }
-
- protected void addPreDrawForColorExtraction(Launcher launcher) {
- getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
- @Override
- public boolean onPreDraw() {
- getViewTreeObserver().removeOnPreDrawListener(this);
- initColorExtractionLocations(launcher);
- return true;
- }
- });
- }
-
- /**
- * Returns list of child views that will receive local color extraction treatment.
- * Note: Order should match the view hierarchy.
- */
- protected List<View> getChildrenForColorExtraction() {
- return Collections.emptyList();
- }
-
- private void initColorExtractionLocations(Launcher launcher) {
- if (mColorExtractors == null) {
- return;
- }
- Workspace<?> workspace = launcher.getWorkspace();
- if (workspace == null) {
- return;
- }
-
- boolean firstVisibleChild = true;
- int screenId = workspace.getScreenIdForPageIndex(workspace.getCurrentPage());
- DragLayer dragLayer = launcher.getDragLayer();
-
- final View[] viewAlignedWithArrow = new View[1];
-
- // Order matters here, since we need the arrow to match the color of its adjacent view.
- for (final View view : getChildrenForColorExtraction()) {
- if (view != null && view.getVisibility() == VISIBLE) {
- Rect pos = new Rect();
- dragLayer.getDescendantRectRelativeToSelf(view, pos);
- if (!pos.isEmpty()) {
- LocalColorExtractor extractor = LocalColorExtractor.newInstance(launcher);
- extractor.setWorkspaceLocation(pos, dragLayer, screenId);
- extractor.setListener(extractedColors -> {
- AnimatorSet colors = new AnimatorSet();
- int newColor = getExtractedColor(extractedColors);
- setChildColor(view, newColor, colors);
- int numChildren = view instanceof ViewGroup
- ? ((ViewGroup) view).getChildCount() : 0;
- for (int i = 0; i < numChildren; ++i) {
- View childView = ((ViewGroup) view).getChildAt(i);
- setChildColor(childView, newColor, colors);
- }
- if (viewAlignedWithArrow[0] == view) {
- mArrowColor = newColor;
- updateArrowColor();
- }
- colors.setDuration(150);
- view.post(colors::start);
- });
- mColorExtractors.add(extractor);
-
- if (mIsAboveIcon || firstVisibleChild) {
- viewAlignedWithArrow[0] = view;
- }
- firstVisibleChild = false;
- }
- }
- }
-
- }
-
/**
* Sets the background color of the child.
*/
@@ -425,7 +312,6 @@
if (reverseOrder) {
reverseOrder(viewsToFlip);
}
- onInflationComplete(reverseOrder);
assignMarginsAndBackgrounds(this);
if (shouldAddArrow()) {
addArrow();
@@ -438,7 +324,6 @@
*/
public void show() {
setupForDisplay();
- onInflationComplete(false);
assignMarginsAndBackgrounds(this);
if (shouldAddArrow()) {
addArrow();
@@ -819,9 +704,6 @@
if (mOnCloseCallback != null) {
mOnCloseCallback.run();
}
- if (mColorExtractors != null) {
- mColorExtractors.forEach(e -> e.setListener(null));
- }
}
/**
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index 8e7a10c..4da588e 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -69,7 +69,6 @@
import com.android.launcher3.views.BaseDragLayer;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
@@ -236,13 +235,6 @@
mPopupItemDragHandler = new LauncherPopupItemDragHandler(launcher, this);
mAccessibilityDelegate = new ShortcutMenuAccessibilityDelegate(launcher);
launcher.getDragController().addDragListener(this);
- addPreDrawForColorExtraction(launcher);
- }
-
- @Override
- protected List<View> getChildrenForColorExtraction() {
- return Arrays.asList(mSystemShortcutContainer, mWidgetContainer, mDeepShortcutContainer,
- mNotificationContainer);
}
private void initializeSystemShortcuts(List<SystemShortcut> shortcuts) {
diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java
index b3c376f..622516f 100644
--- a/src/com/android/launcher3/views/OptionsPopupView.java
+++ b/src/com/android/launcher3/views/OptionsPopupView.java
@@ -139,14 +139,13 @@
mTargetRect.roundOut(outPos);
}
- public static OptionsPopupView show(
- Launcher launcher, RectF targetRect, List<OptionItem> items, boolean shouldAddArrow) {
+ public static OptionsPopupView show(AppLauncher launcher, RectF targetRect,
+ List<OptionItem> items, boolean shouldAddArrow) {
return show(launcher, targetRect, items, shouldAddArrow, 0 /* width */);
}
- public static OptionsPopupView show(
- Launcher launcher, RectF targetRect, List<OptionItem> items, boolean shouldAddArrow,
- int width) {
+ public static OptionsPopupView show(AppLauncher launcher, RectF targetRect,
+ List<OptionItem> items, boolean shouldAddArrow, int width) {
OptionsPopupView popup = (OptionsPopupView) launcher.getLayoutInflater()
.inflate(R.layout.longpress_options_menu, launcher.getDragLayer(), false);
popup.mTargetRect = targetRect;
@@ -165,21 +164,10 @@
popup.mItemMap.put(view, item);
}
- popup.addPreDrawForColorExtraction(launcher);
popup.show();
return popup;
}
- @Override
- protected List<View> getChildrenForColorExtraction() {
- int childCount = getChildCount();
- ArrayList<View> children = new ArrayList<>(childCount);
- for (int i = 0; i < childCount; ++i) {
- children.add(getChildAt(i));
- }
- return children;
- }
-
/**
* Returns the list of supported actions
*/