use of com.android.launcher3.FolderInfo in project android_packages_apps_Launcher3 by AOSPA.
the class WorkspaceAccessibilityHelper method getConfirmationForIconDrop.
@Override
protected String getConfirmationForIconDrop(int id) {
int x = id % mView.getCountX();
int y = id / mView.getCountX();
LauncherAccessibilityDelegate.DragInfo dragInfo = mDelegate.getDragInfo();
View child = mView.getChildAt(x, y);
if (child == null || child == dragInfo.item) {
return mContext.getString(R.string.item_moved);
} else {
ItemInfo info = (ItemInfo) child.getTag();
if (info instanceof AppInfo || info instanceof WorkspaceItemInfo) {
return mContext.getString(R.string.folder_created);
} else if (info instanceof FolderInfo) {
return mContext.getString(R.string.added_to_folder);
}
}
return "";
}
use of com.android.launcher3.FolderInfo in project android_packages_apps_Launcher3 by AOSPA.
the class Launcher method removeItem.
/**
* Unbinds the view for the specified item, and removes the item and all its children.
*
* @param v the view being removed.
* @param itemInfo the {@link ItemInfo} for this view.
* @param deleteFromDb whether or not to delete this item from the db.
*/
public boolean removeItem(View v, final ItemInfo itemInfo, boolean deleteFromDb) {
if (itemInfo instanceof WorkspaceItemInfo) {
// Remove the shortcut from the folder before removing it from launcher
View folderIcon = mWorkspace.getHomescreenIconByItemId(itemInfo.container);
if (folderIcon instanceof FolderIcon) {
((FolderInfo) folderIcon.getTag()).remove((WorkspaceItemInfo) itemInfo, true);
} else {
mWorkspace.removeWorkspaceItem(v);
}
if (deleteFromDb) {
getModelWriter().deleteItemFromDatabase(itemInfo);
}
} else if (itemInfo instanceof FolderInfo) {
final FolderInfo folderInfo = (FolderInfo) itemInfo;
if (v instanceof FolderIcon) {
((FolderIcon) v).removeListeners();
}
mWorkspace.removeWorkspaceItem(v);
if (deleteFromDb) {
getModelWriter().deleteFolderAndContentsFromDatabase(folderInfo);
}
} else if (itemInfo instanceof LauncherAppWidgetInfo) {
final LauncherAppWidgetInfo widgetInfo = (LauncherAppWidgetInfo) itemInfo;
mWorkspace.removeWorkspaceItem(v);
if (deleteFromDb) {
getModelWriter().deleteWidgetInfo(widgetInfo, getAppWidgetHost());
}
} else {
return false;
}
return true;
}
use of com.android.launcher3.FolderInfo in project android_packages_apps_Launcher3 by AOSPA.
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);
}
}
use of com.android.launcher3.FolderInfo in project android_packages_apps_Launcher3 by AOSPA.
the class DefaultLayoutProviderTest method testCustomProfileLoaded_with_folder.
@Test
public void testCustomProfileLoaded_with_folder() throws Exception {
writeLayoutAndLoad(new LauncherLayoutBuilder().atHotseat(0).putFolder(android.R.string.copy).addApp(TEST_PACKAGE, TEST_ACTIVITY).addApp(TEST_PACKAGE, TEST_ACTIVITY).addApp(TEST_PACKAGE, TEST_ACTIVITY).build());
// Verify folder
assertEquals(1, mModelHelper.getBgDataModel().workspaceItems.size());
ItemInfo info = mModelHelper.getBgDataModel().workspaceItems.get(0);
assertEquals(LauncherSettings.Favorites.ITEM_TYPE_FOLDER, info.itemType);
assertEquals(3, ((FolderInfo) info).contents.size());
}
use of com.android.launcher3.FolderInfo in project android_packages_apps_Launcher3 by AOSPA.
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)));
}
Aggregations