use of com.android.launcher3.FolderInfo in project android_packages_apps_Launcher3 by ProtonAOSP.
the class FirstScreenBroadcast method sendBroadcastToInstaller.
/**
* @param installerPackageName Package name of the package installer.
* @param packages List of packages with active sessions for this package installer.
* @param firstScreenItems List of items on the first screen.
*/
private void sendBroadcastToInstaller(Context context, String installerPackageName, Set<String> packages, List<ItemInfo> firstScreenItems) {
Set<String> folderItems = new HashSet<>();
Set<String> workspaceItems = new HashSet<>();
Set<String> hotseatItems = new HashSet<>();
Set<String> widgetItems = new HashSet<>();
for (ItemInfo info : firstScreenItems) {
if (info instanceof FolderInfo) {
FolderInfo folderInfo = (FolderInfo) info;
String folderItemInfoPackage;
for (ItemInfo folderItemInfo : folderInfo.contents) {
folderItemInfoPackage = getPackageName(folderItemInfo);
if (folderItemInfoPackage != null && packages.contains(folderItemInfoPackage)) {
folderItems.add(folderItemInfoPackage);
}
}
}
String packageName = getPackageName(info);
if (packageName == null || !packages.contains(packageName)) {
continue;
}
if (info instanceof LauncherAppWidgetInfo) {
widgetItems.add(packageName);
} else if (info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
hotseatItems.add(packageName);
} else if (info.container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
workspaceItems.add(packageName);
}
}
if (DEBUG) {
printList(installerPackageName, "Folder item", folderItems);
printList(installerPackageName, "Workspace item", workspaceItems);
printList(installerPackageName, "Hotseat item", hotseatItems);
printList(installerPackageName, "Widget item", widgetItems);
}
context.sendBroadcast(new Intent(ACTION_FIRST_SCREEN_ACTIVE_INSTALLS).setPackage(installerPackageName).putStringArrayListExtra(FOLDER_ITEM_EXTRA, new ArrayList<>(folderItems)).putStringArrayListExtra(WORKSPACE_ITEM_EXTRA, new ArrayList<>(workspaceItems)).putStringArrayListExtra(HOTSEAT_ITEM_EXTRA, new ArrayList<>(hotseatItems)).putStringArrayListExtra(WIDGET_ITEM_EXTRA, new ArrayList<>(widgetItems)).putExtra(VERIFICATION_TOKEN_EXTRA, PendingIntent.getActivity(context, 0, new Intent(), FLAG_ONE_SHOT | FLAG_IMMUTABLE)));
}
use of com.android.launcher3.FolderInfo in project android_packages_apps_Launcher3 by ProtonAOSP.
the class BgDataModel method findOrMakeFolder.
/**
* Return an existing FolderInfo object if we have encountered this ID previously,
* or make a new one.
*/
public synchronized FolderInfo findOrMakeFolder(int id) {
// See if a placeholder was created for us already
FolderInfo folderInfo = folders.get(id);
if (folderInfo == null) {
// No placeholder -- create a new instance
folderInfo = new FolderInfo();
folders.put(id, folderInfo);
}
return folderInfo;
}
use of com.android.launcher3.FolderInfo in project android_packages_apps_Launcher3 by ProtonAOSP.
the class ItemClickHandler method onClick.
private static void onClick(View v) {
// view has detached (it's possible for this to happen if the view is removed mid touch).
if (v.getWindowToken() == null)
return;
Launcher launcher = Launcher.getLauncher(v.getContext());
if (!launcher.getWorkspace().isFinishedSwitchingState())
return;
Object tag = v.getTag();
if (tag instanceof WorkspaceItemInfo) {
onClickAppShortcut(v, (WorkspaceItemInfo) tag, launcher);
} else if (tag instanceof FolderInfo) {
if (v instanceof FolderIcon) {
onClickFolderIcon(v);
}
} else if (tag instanceof AppInfo) {
startAppShortcutOrInfoActivity(v, (AppInfo) tag, launcher);
} else if (tag instanceof LauncherAppWidgetInfo) {
if (v instanceof PendingAppWidgetHostView) {
onClickPendingWidget((PendingAppWidgetHostView) v, launcher);
}
} else if (tag instanceof SearchActionItemInfo) {
onClickSearchAction(launcher, (SearchActionItemInfo) tag);
}
}
use of com.android.launcher3.FolderInfo in project android_packages_apps_Launcher3 by ProtonAOSP.
the class LauncherBindableItemsContainer method updateRestoreItems.
/**
* Called to update restored items as a result of
* {@link com.android.launcher3.model.BgDataModel.Callbacks#bindRestoreItemsChange(HashSet)}}
*/
default void updateRestoreItems(final HashSet<ItemInfo> updates, ActivityContext context) {
ItemOperator op = (info, v) -> {
if (info instanceof WorkspaceItemInfo && v instanceof BubbleTextView && updates.contains(info)) {
((BubbleTextView) v).applyLoadingState(false);
} else if (v instanceof PendingAppWidgetHostView && info instanceof LauncherAppWidgetInfo && updates.contains(info)) {
((PendingAppWidgetHostView) v).applyState();
} else if (v instanceof FolderIcon && info instanceof FolderInfo) {
((FolderIcon) v).updatePreviewItems(updates::contains);
}
// process all the shortcuts
return false;
};
mapOverItems(op);
Folder folder = Folder.getOpen(context);
if (folder != null) {
folder.iterateOverItems(op);
}
}
use of com.android.launcher3.FolderInfo in project android_packages_apps_Launcher3 by ProtonAOSP.
the class LauncherBindableItemsContainer method updateWorkspaceItems.
/**
* Called to update workspace items as a result of
* {@link com.android.launcher3.model.BgDataModel.Callbacks#bindWorkspaceItemsChanged(List)}
*/
default void updateWorkspaceItems(List<WorkspaceItemInfo> shortcuts, ActivityContext context) {
final HashSet<WorkspaceItemInfo> updates = new HashSet<>(shortcuts);
ItemOperator op = (info, v) -> {
if (v instanceof BubbleTextView && updates.contains(info)) {
WorkspaceItemInfo si = (WorkspaceItemInfo) info;
BubbleTextView shortcut = (BubbleTextView) v;
Drawable oldIcon = shortcut.getIcon();
boolean oldPromiseState = (oldIcon instanceof PreloadIconDrawable) && ((PreloadIconDrawable) oldIcon).hasNotCompleted();
shortcut.applyFromWorkspaceItem(si, si.isPromise() != oldPromiseState);
} else if (info instanceof FolderInfo && v instanceof FolderIcon) {
((FolderIcon) v).updatePreviewItems(updates::contains);
}
// Iterate all items
return false;
};
mapOverItems(op);
Folder openFolder = Folder.getOpen(context);
if (openFolder != null) {
openFolder.iterateOverItems(op);
}
}
Aggregations