use of com.android.launcher3.util.ComponentKey in project android_packages_apps_404Launcher by P-404.
the class LauncherPreviewRenderer method populate.
private void populate(BgDataModel dataModel, Map<ComponentKey, AppWidgetProviderInfo> widgetProviderInfoMap) {
// Separate the items that are on the current screen, and the other remaining items.
ArrayList<ItemInfo> currentWorkspaceItems = new ArrayList<>();
ArrayList<ItemInfo> otherWorkspaceItems = new ArrayList<>();
ArrayList<LauncherAppWidgetInfo> currentAppWidgets = new ArrayList<>();
ArrayList<LauncherAppWidgetInfo> otherAppWidgets = new ArrayList<>();
IntSet currentScreenIds = IntSet.wrap(mWorkspaceScreens.keySet());
filterCurrentWorkspaceItems(currentScreenIds, dataModel.workspaceItems, currentWorkspaceItems, otherWorkspaceItems);
filterCurrentWorkspaceItems(currentScreenIds, dataModel.appWidgets, currentAppWidgets, otherAppWidgets);
sortWorkspaceItemsSpatially(mIdp, currentWorkspaceItems);
for (ItemInfo itemInfo : currentWorkspaceItems) {
switch(itemInfo.itemType) {
case Favorites.ITEM_TYPE_APPLICATION:
case Favorites.ITEM_TYPE_SHORTCUT:
case Favorites.ITEM_TYPE_DEEP_SHORTCUT:
inflateAndAddIcon((WorkspaceItemInfo) itemInfo);
break;
case Favorites.ITEM_TYPE_FOLDER:
inflateAndAddFolder((FolderInfo) itemInfo);
break;
default:
break;
}
}
for (ItemInfo itemInfo : currentAppWidgets) {
switch(itemInfo.itemType) {
case Favorites.ITEM_TYPE_APPWIDGET:
case Favorites.ITEM_TYPE_CUSTOM_APPWIDGET:
if (widgetProviderInfoMap != null) {
inflateAndAddWidgets((LauncherAppWidgetInfo) itemInfo, widgetProviderInfoMap);
} else {
inflateAndAddWidgets((LauncherAppWidgetInfo) itemInfo, dataModel.widgetsModel);
}
break;
default:
break;
}
}
IntArray ranks = getMissingHotseatRanks(currentWorkspaceItems, mDp.numShownHotseatIcons);
FixedContainerItems hotseatpredictions = dataModel.extraItems.get(CONTAINER_HOTSEAT_PREDICTION);
List<ItemInfo> predictions = hotseatpredictions == null ? Collections.emptyList() : hotseatpredictions.items;
int count = Math.min(ranks.size(), predictions.size());
for (int i = 0; i < count; i++) {
int rank = ranks.get(i);
WorkspaceItemInfo itemInfo = new WorkspaceItemInfo((WorkspaceItemInfo) predictions.get(i));
itemInfo.container = CONTAINER_HOTSEAT_PREDICTION;
itemInfo.rank = rank;
itemInfo.cellX = mHotseat.getCellXFromOrder(rank);
itemInfo.cellY = mHotseat.getCellYFromOrder(rank);
itemInfo.screenId = rank;
inflateAndAddPredictedIcon(itemInfo);
}
// Add first page QSB
if (FeatureFlags.QSB_ON_FIRST_SCREEN) {
CellLayout firstScreen = mWorkspaceScreens.get(FIRST_SCREEN_ID);
View qsb = mHomeElementInflater.inflate(R.layout.qsb_preview, firstScreen, false);
CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, firstScreen.getCountX(), 1);
lp.canReorder = false;
firstScreen.addViewToCellLayout(qsb, 0, R.id.search_container_workspace, lp, true);
}
measureView(mRootView, mDp.widthPx, mDp.heightPx);
dispatchVisibilityAggregated(mRootView, true);
measureView(mRootView, mDp.widthPx, mDp.heightPx);
// Additional measure for views which use auto text size API
measureView(mRootView, mDp.widthPx, mDp.heightPx);
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_404Launcher by P-404.
the class ThirdPartyIconProvider method getIcon.
@SuppressLint("WrongConstant")
@Override
public Drawable getIcon(LauncherActivityInfo launcherActivityInfo, int iconDpi) {
ComponentKey key = new ComponentKey(launcherActivityInfo.getComponentName(), launcherActivityInfo.getUser());
String packageName = key.componentName.getPackageName();
IconResolver.DefaultDrawableProvider fallback = () -> super.getIcon(launcherActivityInfo, iconDpi);
Drawable icon = ThirdPartyIconUtils.getByKey(mContext, key, iconDpi, fallback);
icon = icon == null ? fallback.get() : icon;
icon.setChangingConfigurations(icon.getChangingConfigurations() | CONFIG_HINT_NO_WRAP);
if (isThemedIconEnabled(mContext)) {
ThemeData td = getThemedIconMap().get(packageName);
icon = td != null ? td.wrapDrawable(icon, ICON_TYPE_DEFAULT) : icon;
}
return icon;
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_404Launcher by P-404.
the class ThirdPartyIconUtils method getByKey.
static Drawable getByKey(Context context, ComponentKey key, int iconDpi, IconResolver.DefaultDrawableProvider fallback) {
IconResolver resolver = IconPackManager.get(context).resolve(key);
Drawable icon = resolver == null ? null : resolver.getIcon(iconDpi, fallback);
if (Utilities.ATLEAST_OREO) {
// Icon pack clocks go first.
if (icon != null && resolver.isClock()) {
return CustomClock.getClock(context, icon, resolver.clockData());
}
// Google Clock goes second, but only if the icon pack does not override it.
if (icon == null && key.componentName.equals(DynamicClock.DESK_CLOCK)) {
return DynamicClock.getClock(context, iconDpi);
}
}
// Google Calendar is checked last. Only applied if the icon pack does not override it.
if (icon == null && key.componentName.getPackageName().equals(DynamicCalendar.CALENDAR)) {
return DynamicCalendar.load(context, key.componentName, iconDpi);
}
return icon;
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_404Launcher by P-404.
the class PinnedAppsAdapter method parseComponentKey.
private ComponentKey parseComponentKey(String string) {
try {
String[] parts = string.split("#");
UserHandle user;
if (parts.length > 2) {
user = UserCache.INSTANCE.get(mLauncher).getUserForSerialNumber(Long.parseLong(parts[2]));
} else {
user = Process.myUserHandle();
}
ComponentName cn = ComponentName.unflattenFromString(parts[0]);
return new ComponentKey(cn, user);
} catch (Exception e) {
return null;
}
}
use of com.android.launcher3.util.ComponentKey in project android_packages_apps_404Launcher by P-404.
the class PinnedAppsAdapter method update.
private void update(ItemInfo info, Function<ComponentKey, Boolean> op) {
ComponentKey key = new ComponentKey(info.getTargetComponent(), info.user);
if (op.apply(key)) {
createFilteredAppsList();
Set<ComponentKey> copy = new HashSet<>(mPinnedApps);
Executors.MODEL_EXECUTOR.submit(() -> mPrefs.edit().putStringSet(PINNED_APPS_KEY, copy.stream().map(this::encode).collect(Collectors.toSet())).apply());
}
}
Aggregations