use of com.android.launcher3.util.ComponentKey in project android_packages_apps_404Launcher by P-404.
the class UserLockStateChangedTask method execute.
@Override
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
Context context = app.getContext();
HashMap<ShortcutKey, ShortcutInfo> pinnedShortcuts = new HashMap<>();
if (mIsUserUnlocked) {
QueryResult shortcuts = new ShortcutRequest(context, mUser).query(ShortcutRequest.PINNED);
if (shortcuts.wasSuccess()) {
for (ShortcutInfo shortcut : shortcuts) {
pinnedShortcuts.put(ShortcutKey.fromInfo(shortcut), shortcut);
}
} else {
// Shortcut manager can fail due to some race condition when the lock state
// changes too frequently. For the purpose of the update,
// consider it as still locked.
mIsUserUnlocked = false;
}
}
// Update the workspace to reflect the changes to updated shortcuts residing on it.
ArrayList<WorkspaceItemInfo> updatedWorkspaceItemInfos = new ArrayList<>();
HashSet<ShortcutKey> removedKeys = new HashSet<>();
synchronized (dataModel) {
dataModel.forAllWorkspaceItemInfos(mUser, si -> {
if (si.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
if (mIsUserUnlocked) {
ShortcutKey key = ShortcutKey.fromItemInfo(si);
ShortcutInfo shortcut = pinnedShortcuts.get(key);
// (probably due to clear data), delete the workspace item as well
if (shortcut == null) {
removedKeys.add(key);
return;
}
si.runtimeStatusFlags &= ~FLAG_DISABLED_LOCKED_USER;
si.updateFromDeepShortcutInfo(shortcut, context);
app.getIconCache().getShortcutIcon(si, shortcut);
} else {
si.runtimeStatusFlags |= FLAG_DISABLED_LOCKED_USER;
}
updatedWorkspaceItemInfos.add(si);
}
});
}
bindUpdatedWorkspaceItems(updatedWorkspaceItemInfos);
if (!removedKeys.isEmpty()) {
deleteAndBindComponentsRemoved(ItemInfoMatcher.ofShortcutKeys(removedKeys));
}
// Remove shortcut id map for that user
Iterator<ComponentKey> keysIter = dataModel.deepShortcutMap.keySet().iterator();
while (keysIter.hasNext()) {
if (keysIter.next().user.equals(mUser)) {
keysIter.remove();
}
}
if (mIsUserUnlocked) {
dataModel.updateDeepShortcutCounts(null, mUser, new ShortcutRequest(context, mUser).query(ShortcutRequest.ALL));
}
bindDeepShortcuts(dataModel);
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_404Launcher by P-404.
the class PopupDataProvider method getRecommendedWidgets.
/**
* Returns a list of recommended widgets.
*/
public List<WidgetItem> getRecommendedWidgets() {
HashMap<ComponentKey, WidgetItem> allWidgetItems = new HashMap<>();
mAllWidgets.stream().filter(entry -> entry instanceof WidgetsListContentEntry).forEach(entry -> ((WidgetsListContentEntry) entry).mWidgets.forEach(widget -> allWidgetItems.put(new ComponentKey(widget.componentName, widget.user), widget)));
return mRecommendedWidgets.stream().map(recommendedWidget -> allWidgetItems.get(new ComponentKey(recommendedWidget.getTargetComponent(), recommendedWidget.user))).filter(Objects::nonNull).collect(Collectors.toList());
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_404Launcher by P-404.
the class IconPackManager method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getData() != null) {
String pkg = intent.getData().getEncodedSchemeSpecificPart();
if (pkg != null) {
Log.d(TAG, "Received intent action " + intent.getAction() + " for " + pkg);
AppReloader appReloader = AppReloader.get(mContext);
// Create a list of apps that are using the changed package icon pack,
// either through the global setting or with an override.
Set<ComponentKey> updateKeys = appReloader.withIconPack(pkg);
// Remove the changed package from the providers to reload the application info.
mProviders.remove(pkg);
// This can reset the global preference, so do this after creating the list.
reloadProviders();
// Ensure all icons are up-to-date after this icon pack change.
// Calendar and clock information will automatically be reloaded by this call.
appReloader.reload(updateKeys);
}
}
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_404Launcher by P-404.
the class ThirdPartyDrawableFactory method newIcon.
@Override
public FastBitmapDrawable newIcon(Context context, ItemInfoWithIcon info) {
if (info != null && info.getTargetComponent() != null && info.itemType == ITEM_TYPE_APPLICATION) {
ComponentKey key = new ComponentKey(info.getTargetComponent(), info.user);
IconResolver resolver = mManager.resolve(key);
mCalendars.setIsDynamic(key, (resolver != null && resolver.isCalendar()) || info.getTargetComponent().getPackageName().equals(DynamicCalendar.CALENDAR));
if (Utilities.ATLEAST_OREO) {
if (resolver != null) {
if (resolver.isClock()) {
Drawable drawable = resolver.getIcon(0, () -> null);
if (drawable != null) {
FastBitmapDrawable fb = mCustomClockDrawer.drawIcon(info, drawable, resolver.clockData());
fb.setIsDisabled(info.isDisabled());
return fb;
}
}
} else if (info.getTargetComponent().equals(DynamicClock.DESK_CLOCK)) {
return mDynamicClockDrawer.drawIcon(info);
}
}
}
return super.newIcon(context, info);
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_404Launcher by P-404.
the class LauncherPreviewRenderer method inflateAndAddWidgets.
private void inflateAndAddWidgets(LauncherAppWidgetInfo info, Map<ComponentKey, AppWidgetProviderInfo> widgetProviderInfoMap) {
if (widgetProviderInfoMap == null) {
return;
}
AppWidgetProviderInfo providerInfo = widgetProviderInfoMap.get(new ComponentKey(info.providerName, info.user));
if (providerInfo == null) {
return;
}
inflateAndAddWidgets(info, LauncherAppWidgetProviderInfo.fromProviderInfo(getApplicationContext(), providerInfo));
}
Aggregations