diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-02-03 01:29:56 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-02-03 01:29:56 +0000 |
commit | b5c5e27ab6bbbaf69203044bab7b9af61efd79dd (patch) | |
tree | d51ac9fb3e2a72b592dde8472dcf2bae54adce13 /src/com/android/launcher3/views/OptionsPopupView.java | |
parent | 041c765ca5ee78a8b8c21db1882740b81439c1eb (diff) | |
parent | 808fc1574781a8be6700feb728c9ee65426722a8 (diff) | |
download | Launcher3-simpleperf-release.tar.gz |
Merge "Snap for 11400057 from ded14cc2110e39408f74abac8a83e0a0f16608d2 to simpleperf-release" into simpleperf-releasesimpleperf-release
Diffstat (limited to 'src/com/android/launcher3/views/OptionsPopupView.java')
-rw-r--r-- | src/com/android/launcher3/views/OptionsPopupView.java | 52 |
1 files changed, 22 insertions, 30 deletions
diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java index 4641e31b08..b62f60dc12 100644 --- a/src/com/android/launcher3/views/OptionsPopupView.java +++ b/src/com/android/launcher3/views/OptionsPopupView.java @@ -55,7 +55,6 @@ import com.android.launcher3.popup.ArrowPopup; import com.android.launcher3.shortcuts.DeepShortcutView; import com.android.launcher3.testing.TestLogging; import com.android.launcher3.testing.shared.TestProtocol; -import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.widget.picker.WidgetsFullSheet; import java.util.ArrayList; @@ -63,8 +62,10 @@ import java.util.List; /** * Popup shown on long pressing an empty space in launcher + * + * @param <T> The context showing this popup. */ -public class OptionsPopupView extends ArrowPopup<Launcher> +public class OptionsPopupView<T extends Context & ActivityContext> extends ArrowPopup<T> implements OnClickListener, OnLongClickListener { // An intent extra to indicate the horizontal scroll of the wallpaper. @@ -156,21 +157,27 @@ public class OptionsPopupView extends ArrowPopup<Launcher> } } - public static OptionsPopupView show(ActivityContext launcher, RectF targetRect, - List<OptionItem> items, boolean shouldAddArrow) { - return show(launcher, targetRect, items, shouldAddArrow, 0 /* width */); + public static <T extends Context & ActivityContext> OptionsPopupView<T> show( + ActivityContext activityContext, + RectF targetRect, + List<OptionItem> items, + boolean shouldAddArrow) { + return show(activityContext, targetRect, items, shouldAddArrow, 0 /* width */); } - public static OptionsPopupView show(ActivityContext launcher, RectF targetRect, - List<OptionItem> items, boolean shouldAddArrow, int width) { - OptionsPopupView popup = (OptionsPopupView) launcher.getLayoutInflater() - .inflate(R.layout.longpress_options_menu, launcher.getDragLayer(), false); + public static <T extends Context & ActivityContext> OptionsPopupView<T> show( + ActivityContext activityContext, + RectF targetRect, + List<OptionItem> items, + boolean shouldAddArrow, + int width) { + OptionsPopupView<T> popup = (OptionsPopupView<T>) 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; } @@ -190,14 +197,9 @@ public class OptionsPopupView extends ArrowPopup<Launcher> */ public static ArrayList<OptionItem> getOptions(Launcher launcher) { ArrayList<OptionItem> options = new ArrayList<>(); - boolean styleWallpaperExists = styleWallpapersExists(launcher); - int resString = styleWallpaperExists - ? R.string.styles_wallpaper_button_text : R.string.wallpaper_button_text; - int resDrawable = styleWallpaperExists - ? R.drawable.ic_palette : R.drawable.ic_wallpaper; options.add(new OptionItem(launcher, - resString, - resDrawable, + R.string.styles_wallpaper_button_text, + R.drawable.ic_palette, IGNORE, OptionsPopupView::startWallpaperPicker)); if (!WidgetsModel.GO_DISABLE_WIDGETS) { @@ -274,12 +276,8 @@ public class OptionsPopupView extends ArrowPopup<Launcher> .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) .putExtra(EXTRA_WALLPAPER_OFFSET, launcher.getWorkspace().getWallpaperOffsetForCenterPage()) - .putExtra(EXTRA_WALLPAPER_LAUNCH_SOURCE, "app_launched_launcher"); - if (!styleWallpapersExists(launcher)) { - intent.putExtra(EXTRA_WALLPAPER_FLAVOR, "wallpaper_only"); - } else { - intent.putExtra(EXTRA_WALLPAPER_FLAVOR, "focus_wallpaper"); - } + .putExtra(EXTRA_WALLPAPER_LAUNCH_SOURCE, "app_launched_launcher") + .putExtra(EXTRA_WALLPAPER_FLAVOR, "focus_wallpaper"); String pickerPackage = launcher.getString(R.string.wallpaper_picker_package); if (!TextUtils.isEmpty(pickerPackage)) { intent.setPackage(pickerPackage); @@ -290,7 +288,6 @@ public class OptionsPopupView extends ArrowPopup<Launcher> static WorkspaceItemInfo placeholderInfo(Intent intent) { WorkspaceItemInfo placeholderInfo = new WorkspaceItemInfo(); placeholderInfo.intent = intent; - placeholderInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT; placeholderInfo.container = LauncherSettings.Favorites.CONTAINER_SETTINGS; return placeholderInfo; } @@ -323,9 +320,4 @@ public class OptionsPopupView extends ArrowPopup<Launcher> this.clickListener = clickListener; } } - - private static boolean styleWallpapersExists(Context context) { - return context.getPackageManager().resolveActivity( - PackageManagerHelper.getStyleWallpapersIntent(context), 0) != null; - } } |