Do not show Style & Wallpaper if the corresponding apk does not exist.

Bug: 128681467
Change-Id: Iff2b1dc5618dda61356203f0b33b4d6efcaaebfb
This commit is contained in:
Hyunyoung Song 2019-03-18 14:43:47 -07:00
parent 9893578356
commit 9e54c29821
1 changed files with 11 additions and 1 deletions

View File

@ -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_FLAVOR;
import static com.android.launcher3.Utilities.EXTRA_WALLPAPER_OFFSET; import static com.android.launcher3.Utilities.EXTRA_WALLPAPER_OFFSET;
import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.RectF; import android.graphics.RectF;
import android.text.TextUtils; import android.text.TextUtils;
@ -150,7 +152,7 @@ public class OptionsPopupView extends ArrowPopup
RectF target = new RectF(x - halfSize, y - halfSize, x + halfSize, y + halfSize); RectF target = new RectF(x - halfSize, y - halfSize, x + halfSize, y + halfSize);
ArrayList<OptionItem> options = new ArrayList<>(); ArrayList<OptionItem> options = new ArrayList<>();
int res = FeatureFlags.STYLE_WALLPAPER.get() ? int res = FeatureFlags.STYLE_WALLPAPER.get() && existsStyleWallpapers(launcher) ?
R.string.styles_wallpaper_button_text : R.string.wallpaper_button_text; R.string.styles_wallpaper_button_text : R.string.wallpaper_button_text;
options.add(new OptionItem(res, R.drawable.ic_wallpaper, options.add(new OptionItem(res, R.drawable.ic_wallpaper,
ControlType.WALLPAPER_BUTTON, OptionsPopupView::startWallpaperPicker)); ControlType.WALLPAPER_BUTTON, OptionsPopupView::startWallpaperPicker));
@ -164,6 +166,14 @@ public class OptionsPopupView extends ArrowPopup
show(launcher, target, options); 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) { public static boolean onWidgetsClicked(View view) {
return openWidgets(Launcher.getLauncher(view.getContext())); return openWidgets(Launcher.getLauncher(view.getContext()));
} }