use of com.android.launcher3.compat.ShortcutConfigActivityInfo in project android_packages_apps_Trebuchet by LineageOS.
the class WidgetsModel method update.
/**
* @param packageUser If null, all widgets and shortcuts are updated and returned, otherwise
* only widgets and shortcuts associated with the package/user are.
*/
public List<ComponentWithLabelAndIcon> update(LauncherAppState app, @Nullable PackageUserKey packageUser) {
Preconditions.assertWorkerThread();
Context context = app.getContext();
final ArrayList<WidgetItem> widgetsAndShortcuts = new ArrayList<>();
List<ComponentWithLabelAndIcon> updatedItems = new ArrayList<>();
try {
InvariantDeviceProfile idp = app.getInvariantDeviceProfile();
PackageManager pm = app.getContext().getPackageManager();
// Widgets
WidgetManagerHelper widgetManager = new WidgetManagerHelper(context);
for (AppWidgetProviderInfo widgetInfo : widgetManager.getAllProviders(packageUser)) {
LauncherAppWidgetProviderInfo launcherWidgetInfo = LauncherAppWidgetProviderInfo.fromProviderInfo(context, widgetInfo);
widgetsAndShortcuts.add(new WidgetItem(launcherWidgetInfo, idp, app.getIconCache()));
updatedItems.add(launcherWidgetInfo);
}
// Shortcuts
for (ShortcutConfigActivityInfo info : queryList(context, packageUser)) {
widgetsAndShortcuts.add(new WidgetItem(info, app.getIconCache(), pm));
updatedItems.add(info);
}
setWidgetsAndShortcuts(widgetsAndShortcuts, app, packageUser);
} catch (Exception e) {
if (!FeatureFlags.IS_STUDIO_BUILD && Utilities.isBinderSizeError(e)) {
// the returned value may be incomplete and will not be refreshed until the next
// time Launcher starts.
// TODO: after figuring out a repro step, introduce a dirty bit to check when
// onResume is called to refresh the widget provider list.
} else {
throw e;
}
}
app.getWidgetCache().removeObsoletePreviews(widgetsAndShortcuts, packageUser);
return updatedItems;
}
use of com.android.launcher3.compat.ShortcutConfigActivityInfo in project Neo-Launcher by NeoApplications.
the class Utilities method getFullDrawable.
/**
* Returns the full drawable for {@param info}.
* @param outObj this is set to the internal data associated with {@param info},
* eg {@link LauncherActivityInfo} or {@link ShortcutInfo}.
*/
public static Drawable getFullDrawable(Launcher launcher, ItemInfo info, int width, int height, boolean flattenDrawable, Object[] outObj) {
LauncherAppState appState = LauncherAppState.getInstance(launcher);
IconPackManager.CustomIconEntry customIconEntry = (info instanceof WorkspaceItemInfo) ? ((WorkspaceItemInfo) info).customIconEntry : null;
if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION || customIconEntry != null) {
LauncherActivityInfo activityInfo = LauncherAppsCompat.getInstance(launcher).resolveActivity(info.getIntent(), info.user);
outObj[0] = activityInfo;
return (activityInfo != null) ? appState.getIconCache().getFullResIcon(activityInfo, flattenDrawable) : null;
} 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());
}
ShortcutKey key = ShortcutKey.fromItemInfo(info);
DeepShortcutManager sm = DeepShortcutManager.getInstance(launcher);
List<ShortcutInfo> si = sm.queryForFullDetails(key.componentName.getPackageName(), Arrays.asList(key.getId()), key.user);
if (si.isEmpty()) {
return null;
} else {
outObj[0] = si.get(0);
return sm.getShortcutIconDrawable(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 com.android.launcher3.compat.ShortcutConfigActivityInfo in project Neo-Launcher by NeoApplications.
the class LauncherAppsCompatVL method getCustomShortcutActivityList.
@Override
public List<ShortcutConfigActivityInfo> getCustomShortcutActivityList(@Nullable PackageUserKey packageUser) {
List<ShortcutConfigActivityInfo> result = new ArrayList<>();
if (packageUser != null && !packageUser.mUser.equals(Process.myUserHandle())) {
return result;
}
PackageManager pm = mContext.getPackageManager();
for (ResolveInfo info : pm.queryIntentActivities(new Intent(Intent.ACTION_CREATE_SHORTCUT), 0)) {
if (packageUser == null || packageUser.mPackageName.equals(info.activityInfo.packageName)) {
result.add(new ShortcutConfigActivityInfoVL(info.activityInfo));
}
}
return result;
}
use of com.android.launcher3.compat.ShortcutConfigActivityInfo in project Neo-Launcher by NeoApplications.
the class LauncherAppsCompatVO method getCustomShortcutActivityList.
@Override
public List<ShortcutConfigActivityInfo> getCustomShortcutActivityList(@Nullable PackageUserKey packageUser) {
List<ShortcutConfigActivityInfo> result = new ArrayList<>();
UserHandle myUser = Process.myUserHandle();
final List<UserHandle> users;
final String packageName;
if (packageUser == null) {
users = UserManagerCompat.getInstance(mContext).getUserProfiles();
packageName = null;
} else {
users = new ArrayList<>(1);
users.add(packageUser.mUser);
packageName = packageUser.mPackageName;
}
for (UserHandle user : users) {
boolean ignoreTargetSdk = myUser.equals(user);
List<LauncherActivityInfo> activities = mLauncherApps.getShortcutConfigActivityList(packageName, user);
for (LauncherActivityInfo activityInfo : activities) {
if (ignoreTargetSdk || activityInfo.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.O) {
result.add(new ShortcutConfigActivityInfoVO(activityInfo));
}
}
}
return result;
}
use of com.android.launcher3.compat.ShortcutConfigActivityInfo in project Neo-Launcher by NeoApplications.
the class WidgetsModel method update.
/**
* @param packageUser If null, all widgets and shortcuts are updated and returned, otherwise
* only widgets and shortcuts associated with the package/user are.
*/
public List<ComponentWithLabel> update(LauncherAppState app, @Nullable PackageUserKey packageUser) {
Preconditions.assertWorkerThread();
Context context = app.getContext();
final ArrayList<WidgetItem> widgetsAndShortcuts = new ArrayList<>();
List<ComponentWithLabel> updatedItems = new ArrayList<>();
try {
InvariantDeviceProfile idp = app.getInvariantDeviceProfile();
PackageManager pm = app.getContext().getPackageManager();
// Widgets
AppWidgetManagerCompat widgetManager = AppWidgetManagerCompat.getInstance(context);
for (AppWidgetProviderInfo widgetInfo : widgetManager.getAllProviders(packageUser)) {
LauncherAppWidgetProviderInfo launcherWidgetInfo = LauncherAppWidgetProviderInfo.fromProviderInfo(context, widgetInfo);
widgetsAndShortcuts.add(new WidgetItem(launcherWidgetInfo, idp, app.getIconCache()));
updatedItems.add(launcherWidgetInfo);
}
// Shortcuts
for (ShortcutConfigActivityInfo info : LauncherAppsCompat.getInstance(context).getCustomShortcutActivityList(packageUser)) {
widgetsAndShortcuts.add(new WidgetItem(info, app.getIconCache(), pm));
updatedItems.add(info);
}
setWidgetsAndShortcuts(widgetsAndShortcuts, app, packageUser);
} catch (Exception e) {
if (!FeatureFlags.IS_DOGFOOD_BUILD && Utilities.isBinderSizeError(e)) {
// the returned value may be incomplete and will not be refreshed until the next
// time Launcher starts.
// TODO: after figuring out a repro step, introduce a dirty bit to check when
// onResume is called to refresh the widget provider list.
} else {
throw e;
}
}
app.getWidgetCache().removeObsoletePreviews(widgetsAndShortcuts, packageUser);
return updatedItems;
}
Aggregations