use of com.android.launcher3.Workspace.ItemOperator in project Neo-Launcher by NeoApplications.
the class Workspace method updateRestoreItems.
public void updateRestoreItems(final HashSet<ItemInfo> updates) {
ItemOperator op = (info, v) -> {
if (info instanceof WorkspaceItemInfo && v instanceof BubbleTextView && updates.contains(info)) {
((BubbleTextView) v).applyPromiseState(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(mLauncher);
if (folder != null) {
folder.iterateOverItems(op);
}
}
use of com.android.launcher3.Workspace.ItemOperator in project Neo-Launcher by NeoApplications.
the class RequestPinItemTest method runTest.
private void runTest(String activityMethod, boolean isWidget, ItemOperator itemMatcher, Intent... commandIntents) throws Throwable {
if (!Utilities.ATLEAST_OREO) {
return;
}
clearHomescreen();
mDevice.pressHome();
// Open Pin item activity
BlockingBroadcastReceiver openMonitor = new BlockingBroadcastReceiver(RequestPinItemActivity.class.getName());
mLauncher.getWorkspace().switchToAllApps().getAppIcon("Test Pin Item").launch(getAppPackageName());
assertNotNull(openMonitor.blockingGetExtraIntent());
// Set callback
PendingIntent callback = PendingIntent.getBroadcast(mTargetContext, 0, new Intent(mCallbackAction), PendingIntent.FLAG_ONE_SHOT);
mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, "setCallback").putExtra(RequestPinItemActivity.EXTRA_PARAM + "0", callback));
for (Intent command : commandIntents) {
mTargetContext.sendBroadcast(command);
}
// call the requested method to start the flow
mTargetContext.sendBroadcast(RequestPinItemActivity.getCommandIntent(RequestPinItemActivity.class, activityMethod));
final AddToHomeScreenPrompt addToHomeScreenPrompt = mLauncher.getAddToHomeScreenPrompt();
// Accept confirmation:
BlockingBroadcastReceiver resultReceiver = new BlockingBroadcastReceiver(mCallbackAction);
addToHomeScreenPrompt.addAutomatically();
Intent result = resultReceiver.blockingGetIntent();
assertNotNull(result);
mAppWidgetId = result.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
if (isWidget) {
assertNotSame(-1, mAppWidgetId);
}
// Go back to home
mLauncher.pressHome();
Wait.atMost(null, new ItemSearchCondition(itemMatcher), DEFAULT_ACTIVITY_TIMEOUT);
}
use of com.android.launcher3.Workspace.ItemOperator in project android_packages_apps_Launcher3 by ArrowOS.
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 ArrowOS.
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 ArrowOS.
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);
}
}
Aggregations