use of fr.neamar.kiss.MainActivity in project KISS by Neamar.
the class AppResult method buildPopupMenu.
@Override
protected PopupMenu buildPopupMenu(Context context, final RecordAdapter parent, View parentView) {
PopupMenu menu = inflatePopupMenu(R.menu.menu_item_app, context, parentView);
if ((context instanceof MainActivity) && (!((MainActivity) context).isOnSearchView())) {
menu.getMenu().removeItem(R.id.item_remove);
}
try {
// app installed under /system can't be uninstalled
boolean isSameProfile = true;
ApplicationInfo ai;
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
LauncherApps launcher = (LauncherApps) context.getSystemService(Context.LAUNCHER_APPS_SERVICE);
LauncherActivityInfo info = launcher.getActivityList(this.appPojo.packageName, this.appPojo.userHandle.getRealHandle()).get(0);
ai = info.getApplicationInfo();
isSameProfile = this.appPojo.userHandle.isCurrentUser();
} else {
ai = context.getPackageManager().getApplicationInfo(this.appPojo.packageName, 0);
}
// Need to AND the flags with SYSTEM:
if ((ai.flags & ApplicationInfo.FLAG_SYSTEM) == 0 && isSameProfile) {
menu.getMenuInflater().inflate(R.menu.menu_item_app_uninstall, menu.getMenu());
}
} catch (NameNotFoundException | IndexOutOfBoundsException e) {
// should not happen
}
//append root menu if available
if (KissApplication.getRootHandler(context).isRootActivated() && KissApplication.getRootHandler(context).isRootAvailable()) {
menu.getMenuInflater().inflate(R.menu.menu_item_app_root, menu.getMenu());
}
return menu;
}
Aggregations