use of com.android.launcher3.Workspace.ItemOperator in project android_packages_apps_Launcher3 by ProtonAOSP.
the class PromiseIconUiTest method testPromiseIcon_notAddedFromIneligibleSession.
@Test
public void testPromiseIcon_notAddedFromIneligibleSession() throws Throwable {
final String appLabel = "Test Promise App " + UUID.randomUUID().toString();
final ItemOperator findPromiseApp = (info, view) -> info != null && TextUtils.equals(info.title, appLabel);
// Create and add test session without icon or label
mSessionId = createSession(null, null);
// Sleep for duration of animation if a view was to be added + some buffer time.
Thread.sleep(Launcher.NEW_APPS_PAGE_MOVE_DELAY + Launcher.NEW_APPS_ANIMATION_DELAY + 500);
// Verify promise icon is not added
waitForLauncherCondition("Test Promise App not found on workspace", launcher -> launcher.getWorkspace().getFirstMatch(findPromiseApp) == null);
}
use of com.android.launcher3.Workspace.ItemOperator in project android_packages_apps_Launcher3 by ProtonAOSP.
the class PromiseIconUiTest method testPromiseIcon_addedFromEligibleSession.
@Test
public void testPromiseIcon_addedFromEligibleSession() throws Throwable {
final String appLabel = "Test Promise App " + UUID.randomUUID().toString();
final ItemOperator findPromiseApp = (info, view) -> info != null && TextUtils.equals(info.title, appLabel);
// Create and add test session
mSessionId = createSession(appLabel, Bitmap.createBitmap(100, 100, Bitmap.Config.ALPHA_8));
// Verify promise icon is added
waitForLauncherCondition("Test Promise App not found on workspace", launcher -> launcher.getWorkspace().getFirstMatch(findPromiseApp) != null);
// Remove session
mTargetContext.getPackageManager().getPackageInstaller().abandonSession(mSessionId);
mSessionId = -1;
// Verify promise icon is removed
waitForLauncherCondition("Test Promise App not removed from workspace", launcher -> launcher.getWorkspace().getFirstMatch(findPromiseApp) == null);
}
use of com.android.launcher3.Workspace.ItemOperator in project android_packages_apps_Launcher3 by AOSPA.
the class Workspace method updateNotificationDots.
public void updateNotificationDots(Predicate<PackageUserKey> updatedDots) {
final PackageUserKey packageUserKey = new PackageUserKey(null, null);
Predicate<ItemInfo> matcher = info -> !packageUserKey.updateFromItemInfo(info) || updatedDots.test(packageUserKey);
ItemOperator op = (info, v) -> {
if (info instanceof WorkspaceItemInfo && v instanceof BubbleTextView) {
if (matcher.test(info)) {
((BubbleTextView) v).applyDotState(info, true);
}
} else if (info instanceof FolderInfo && v instanceof FolderIcon) {
FolderInfo fi = (FolderInfo) info;
if (fi.contents.stream().anyMatch(matcher)) {
FolderDotInfo folderDotInfo = new FolderDotInfo();
for (WorkspaceItemInfo si : fi.contents) {
folderDotInfo.addDotInfo(mLauncher.getDotInfoForItem(si));
}
((FolderIcon) v).setDotInfo(folderDotInfo);
}
}
// process all the shortcuts
return false;
};
mapOverItems(op);
Folder folder = Folder.getOpen(mLauncher);
if (folder != null) {
folder.iterateOverItems(op);
}
}
use of com.android.launcher3.Workspace.ItemOperator in project android_packages_apps_Launcher3 by AOSPA.
the class Workspace method widgetsRestored.
public void widgetsRestored(final ArrayList<LauncherAppWidgetInfo> changedInfo) {
if (!changedInfo.isEmpty()) {
DeferredWidgetRefresh widgetRefresh = new DeferredWidgetRefresh(changedInfo, mLauncher.getAppWidgetHost());
LauncherAppWidgetInfo item = changedInfo.get(0);
final AppWidgetProviderInfo widgetInfo;
WidgetManagerHelper widgetHelper = new WidgetManagerHelper(getContext());
if (item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_ID_NOT_VALID)) {
widgetInfo = widgetHelper.findProvider(item.providerName, item.user);
} else {
widgetInfo = widgetHelper.getLauncherAppWidgetInfo(item.appWidgetId);
}
if (widgetInfo != null) {
// Re-inflate the widgets which have changed status
widgetRefresh.run();
} else {
// widgetRefresh will automatically run when the packages are updated.
// For now just update the progress bars
mapOverItems(new ItemOperator() {
@Override
public boolean evaluate(ItemInfo info, View view) {
if (view instanceof PendingAppWidgetHostView && changedInfo.contains(info)) {
((LauncherAppWidgetInfo) info).installProgress = 100;
((PendingAppWidgetHostView) view).applyState();
}
// process all the shortcuts
return false;
}
});
}
}
}
use of com.android.launcher3.Workspace.ItemOperator in project android_packages_apps_Launcher3 by AOSPA.
the class Workspace method mapOverCellLayout.
private View mapOverCellLayout(CellLayout layout, ItemOperator op) {
// TODO(b/128460496) Potential race condition where layout is not yet loaded
if (layout == null) {
return null;
}
ShortcutAndWidgetContainer container = layout.getShortcutsAndWidgets();
// map over all the shortcuts on the workspace
final int itemCount = container.getChildCount();
for (int itemIdx = 0; itemIdx < itemCount; itemIdx++) {
View item = container.getChildAt(itemIdx);
if (op.evaluate((ItemInfo) item.getTag(), item)) {
return item;
}
}
return null;
}
Aggregations