From 40c96b4049cf5ab9390d9cad4b22535f60d8fb19 Mon Sep 17 00:00:00 2001 From: Brian Isganitis Date: Mon, 17 Jul 2023 14:20:44 -0400 Subject: [PATCH] Have OptionsPopupView depend on ActivityContext. Only certain static methods in this class require Launcher at this point. Test: Manual Bug: 291615281 Flag: No Change-Id: I27bda70bd4f9da75e112d4f68a383447bcc3c32c --- .../launcher3/views/OptionsPopupView.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java index 55febc7352..b62f60dc12 100644 --- a/src/com/android/launcher3/views/OptionsPopupView.java +++ b/src/com/android/launcher3/views/OptionsPopupView.java @@ -62,8 +62,10 @@ import java.util.List; /** * Popup shown on long pressing an empty space in launcher + * + * @param The context showing this popup. */ -public class OptionsPopupView extends ArrowPopup +public class OptionsPopupView extends ArrowPopup implements OnClickListener, OnLongClickListener { // An intent extra to indicate the horizontal scroll of the wallpaper. @@ -155,21 +157,27 @@ public class OptionsPopupView extends ArrowPopup } } - public static OptionsPopupView show(ActivityContext launcher, RectF targetRect, - List items, boolean shouldAddArrow) { - return show(launcher, targetRect, items, shouldAddArrow, 0 /* width */); + public static OptionsPopupView show( + ActivityContext activityContext, + RectF targetRect, + List items, + boolean shouldAddArrow) { + return show(activityContext, targetRect, items, shouldAddArrow, 0 /* width */); } - public static OptionsPopupView show(ActivityContext launcher, RectF targetRect, - List items, boolean shouldAddArrow, int width) { - OptionsPopupView popup = (OptionsPopupView) launcher.getLayoutInflater() - .inflate(R.layout.longpress_options_menu, launcher.getDragLayer(), false); + public static OptionsPopupView show( + ActivityContext activityContext, + RectF targetRect, + List items, + boolean shouldAddArrow, + int width) { + OptionsPopupView popup = (OptionsPopupView) activityContext.getLayoutInflater() + .inflate(R.layout.longpress_options_menu, activityContext.getDragLayer(), false); popup.mTargetRect = targetRect; popup.setShouldAddArrow(shouldAddArrow); for (OptionItem item : items) { - DeepShortcutView view = - (DeepShortcutView) popup.inflateAndAdd(R.layout.system_shortcut, popup); + DeepShortcutView view = popup.inflateAndAdd(R.layout.system_shortcut, popup); if (width > 0) { view.getLayoutParams().width = width; }