diff options
Diffstat (limited to 'src/com/android/launcher3/views/OptionsPopupView.java')
-rw-r--r-- | src/com/android/launcher3/views/OptionsPopupView.java | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/com/android/launcher3/views/OptionsPopupView.java b/src/com/android/launcher3/views/OptionsPopupView.java index 465df448e..c718d74e7 100644 --- a/src/com/android/launcher3/views/OptionsPopupView.java +++ b/src/com/android/launcher3/views/OptionsPopupView.java @@ -18,8 +18,10 @@ package com.android.launcher3.views; import static com.android.launcher3.Utilities.EXTRA_WALLPAPER_FLAVOR; import static com.android.launcher3.Utilities.EXTRA_WALLPAPER_OFFSET; +import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.ResolveInfo; import android.graphics.Rect; import android.graphics.RectF; import android.text.TextUtils; @@ -152,13 +154,13 @@ public class OptionsPopupView extends ArrowPopup RectF target = new RectF(x - halfSize, y - halfSize, x + halfSize, y + halfSize); ArrayList<OptionItem> options = new ArrayList<>(); - int resString = Utilities.existsStyleWallpapers(launcher) ? + int resString = existsStyleWallpapers(launcher) ? R.string.styles_wallpaper_button_text : R.string.wallpaper_button_text; - int resDrawable = Utilities.existsStyleWallpapers(launcher) ? + int resDrawable = existsStyleWallpapers(launcher) ? R.drawable.ic_palette : R.drawable.ic_wallpaper; options.add(new OptionItem(resString, resDrawable, ControlType.WALLPAPER_BUTTON, OptionsPopupView::startWallpaperPicker)); - if (!FeatureFlags.GO_DISABLE_WIDGETS) { + if (!FeatureFlags.GO_DISABLE_WIDGETS && Utilities.isWorkspaceEditAllowed(launcher)) { options.add(new OptionItem(R.string.widget_button_text, R.drawable.ic_widget, ControlType.WIDGETS_BUTTON, OptionsPopupView::onWidgetsClicked)); } @@ -168,6 +170,14 @@ public class OptionsPopupView extends ArrowPopup show(launcher, target, options); } + private static boolean existsStyleWallpapers(Launcher launcher) { + Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER); + intent.setComponent(new ComponentName(launcher.getString(R.string.wallpaper_picker_package), + "com.android.customization.picker.CustomizationPickerActivity")); + ResolveInfo ri = launcher.getPackageManager().resolveActivity(intent, 0); + return ri != null; + } + public static boolean onWidgetsClicked(View view) { return openWidgets(Launcher.getLauncher(view.getContext())) != null; } @@ -205,10 +215,13 @@ public class OptionsPopupView extends ArrowPopup .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) .putExtra(EXTRA_WALLPAPER_OFFSET, launcher.getWorkspace().getWallpaperOffsetForCenterPage()); - if (!Utilities.existsStyleWallpapers(launcher)) { + if (!existsStyleWallpapers(launcher)) { intent.putExtra(EXTRA_WALLPAPER_FLAVOR, "wallpaper_only"); } else { intent.putExtra(EXTRA_WALLPAPER_FLAVOR, "focus_wallpaper"); + intent.setComponent(new ComponentName( + launcher.getString(R.string.wallpaper_picker_package), + "com.android.customization.picker.CustomizationPickerActivity")); } String pickerPackage = launcher.getString(R.string.wallpaper_picker_package); if (!TextUtils.isEmpty(pickerPackage)) { |