use of android.content.pm.LauncherActivityInfo in project android_packages_apps_Launcher3 by crdroidandroid.
the class AllAppsList method updatePackage.
/**
* Add and remove icons for this package which has been updated.
*/
public List<LauncherActivityInfo> updatePackage(Context context, String packageName, UserHandle user) {
final List<LauncherActivityInfo> matches = context.getSystemService(LauncherApps.class).getActivityList(packageName, user);
if (matches.size() > 0) {
// to the removed list.
for (int i = data.size() - 1; i >= 0; i--) {
final AppInfo applicationInfo = data.get(i);
if (user.equals(applicationInfo.user) && packageName.equals(applicationInfo.componentName.getPackageName())) {
if (!findActivity(matches, applicationInfo.componentName)) {
Log.w(TAG, "Changing shortcut target due to app component name change.");
removeApp(i);
}
}
}
// Also updates existing activities with new labels/icons
for (final LauncherActivityInfo info : matches) {
AppInfo applicationInfo = findAppInfo(info.getComponentName(), user);
if (applicationInfo == null) {
add(new AppInfo(context, info, user), info);
} else {
Intent launchIntent = AppInfo.makeLaunchIntent(info);
mIconCache.getTitleAndIcon(applicationInfo, info, false);
applicationInfo.sectionName = mIndex.computeSectionName(applicationInfo.title);
applicationInfo.setProgressLevel(PackageManagerHelper.getLoadingProgress(info), PackageInstallInfo.STATUS_INSTALLED_DOWNLOADING);
applicationInfo.intent = launchIntent;
mDataChanged = true;
}
}
} else {
// Remove all data for this package.
for (int i = data.size() - 1; i >= 0; i--) {
final AppInfo applicationInfo = data.get(i);
if (user.equals(applicationInfo.user) && packageName.equals(applicationInfo.componentName.getPackageName())) {
mIconCache.remove(applicationInfo.componentName, user);
removeApp(i);
}
}
}
return matches;
}
use of android.content.pm.LauncherActivityInfo in project android_packages_apps_Launcher3 by crdroidandroid.
the class SecondaryDropTarget method getUninstallTarget.
/**
* @return the component name that should be uninstalled or null.
*/
private ComponentName getUninstallTarget(ItemInfo item) {
Intent intent = null;
UserHandle user = null;
if (item != null && item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
intent = item.getIntent();
user = item.user;
}
if (intent != null) {
LauncherActivityInfo info = mLauncher.getSystemService(LauncherApps.class).resolveActivity(intent, user);
if (info != null && (info.getApplicationInfo().flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
return info.getComponentName();
}
}
return null;
}
use of android.content.pm.LauncherActivityInfo in project android_packages_apps_Launcher3 by crdroidandroid.
the class Utilities method loadFullDrawableWithoutTheme.
private static Drawable loadFullDrawableWithoutTheme(Launcher launcher, ItemInfo info, int width, int height, Object[] outObj) {
LauncherAppState appState = LauncherAppState.getInstance(launcher);
if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
LauncherActivityInfo activityInfo = launcher.getSystemService(LauncherApps.class).resolveActivity(info.getIntent(), info.user);
outObj[0] = activityInfo;
return activityInfo == null ? null : LauncherAppState.getInstance(launcher).getIconProvider().getIcon(activityInfo, launcher.getDeviceProfile().inv.fillResIconDpi);
} else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
if (info instanceof PendingAddShortcutInfo) {
ShortcutConfigActivityInfo activityInfo = ((PendingAddShortcutInfo) info).activityInfo;
outObj[0] = activityInfo;
return activityInfo.getFullResIcon(appState.getIconCache());
}
List<ShortcutInfo> si = ShortcutKey.fromItemInfo(info).buildRequest(launcher).query(ShortcutRequest.ALL);
if (si.isEmpty()) {
return null;
} else {
outObj[0] = si.get(0);
return ShortcutCachingLogic.getIcon(launcher, si.get(0), appState.getInvariantDeviceProfile().fillResIconDpi);
}
} else if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
FolderAdaptiveIcon icon = FolderAdaptiveIcon.createFolderAdaptiveIcon(launcher, info.id, new Point(width, height));
if (icon == null) {
return null;
}
outObj[0] = icon;
return icon;
} else {
return null;
}
}
use of android.content.pm.LauncherActivityInfo in project Neo-Launcher by NeoApplications.
the class DefaultAppSearchAlgorithm method getApps.
public static List<AppInfo> getApps(Context context, List<AppInfo> defaultApps, AppFilter filter) {
if (!Utilities.getPrefs(context).getBoolean(SEARCH_HIDDEN_APPS, false)) {
return defaultApps;
}
final List<AppInfo> apps = new ArrayList<>();
final IconCache iconCache = LauncherAppState.getInstance(context).getIconCache();
for (UserHandle user : UserManagerCompat.getInstance(context).getUserProfiles()) {
final List<ComponentName> duplicatePreventionCache = new ArrayList<>();
for (LauncherActivityInfo info : LauncherAppsCompat.getInstance(context).getActivityList(null, user)) {
if (!filter.shouldShowApp(info.getComponentName(), user)) {
continue;
}
if (!duplicatePreventionCache.contains(info.getComponentName())) {
duplicatePreventionCache.add(info.getComponentName());
final AppInfo appInfo = new AppInfo(context, info, user);
iconCache.getTitleAndIcon(appInfo, false);
apps.add(appInfo);
}
}
}
return apps;
}
use of android.content.pm.LauncherActivityInfo in project Neo-Launcher by NeoApplications.
the class LoaderCursor method getAppShortcutInfo.
/**
* Make an WorkspaceItemInfo object for a shortcut that is an application.
*/
public WorkspaceItemInfo getAppShortcutInfo(Intent intent, boolean allowMissingTarget, boolean useLowResIcon) {
if (user == null) {
Log.d(TAG, "Null user found in getShortcutInfo");
return null;
}
ComponentName componentName = intent.getComponent();
if (componentName == null) {
Log.d(TAG, "Missing component found in getShortcutInfo");
return null;
}
Intent newIntent = new Intent(Intent.ACTION_MAIN, null);
newIntent.addCategory(Intent.CATEGORY_LAUNCHER);
newIntent.setComponent(componentName);
LauncherActivityInfo lai = LauncherAppsCompat.getInstance(mContext).resolveActivity(newIntent, user);
if ((lai == null) && !allowMissingTarget) {
Log.d(TAG, "Missing activity found in getShortcutInfo: " + componentName);
return null;
}
final WorkspaceItemInfo info = new WorkspaceItemInfo();
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_APPLICATION;
info.user = user;
info.intent = newIntent;
mIconCache.getTitleAndIcon(info, lai, useLowResIcon);
if (mIconCache.isDefaultIcon(info.iconBitmap, user)) {
loadIcon(info);
}
if (lai != null) {
AppInfo.updateRuntimeFlagsForActivityTarget(info, lai);
}
// from the db
if (TextUtils.isEmpty(info.title)) {
info.title = getTitle();
}
// fall back to the class name of the activity
if (info.title == null) {
info.title = componentName.getClassName();
}
info.contentDescription = mPM.getUserBadgedLabel(info.title, info.user);
return info;
}
Aggregations