Search in sources :

Example 61 with ComponentKey

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);
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) IntSet(com.android.launcher3.util.IntSet) ArrayList(java.util.ArrayList) LauncherAppWidgetInfo(com.android.launcher3.model.data.LauncherAppWidgetInfo) FixedContainerItems(com.android.launcher3.model.BgDataModel.FixedContainerItems) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) BaseLauncherAppWidgetHostView(com.android.launcher3.widget.BaseLauncherAppWidgetHostView) NavigableAppWidgetHostView(com.android.launcher3.widget.NavigableAppWidgetHostView) AppWidgetHostView(android.appwidget.AppWidgetHostView) SparseIntArray(android.util.SparseIntArray) IntArray(com.android.launcher3.util.IntArray) CellLayout(com.android.launcher3.CellLayout) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 62 with ComponentKey

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;
}
Also used : ThemeData(com.android.launcher3.icons.ThemedIconDrawable.ThemeData) IconResolver(com.android.launcher3.icons.pack.IconResolver) ComponentKey(com.android.launcher3.util.ComponentKey) Drawable(android.graphics.drawable.Drawable) SuppressLint(android.annotation.SuppressLint)

Example 63 with ComponentKey

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;
}
Also used : IconResolver(com.android.launcher3.icons.pack.IconResolver) Drawable(android.graphics.drawable.Drawable)

Example 64 with ComponentKey

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;
    }
}
Also used : UserHandle(android.os.UserHandle) ComponentKey(com.android.launcher3.util.ComponentKey) ComponentName(android.content.ComponentName)

Example 65 with ComponentKey

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());
    }
}
Also used : ComponentKey(com.android.launcher3.util.ComponentKey) HashSet(java.util.HashSet)

Aggregations

ComponentKey (com.android.launcher3.util.ComponentKey)98 ComponentName (android.content.ComponentName)40 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)26 ArrayList (java.util.ArrayList)26 ShortcutInfo (android.content.pm.ShortcutInfo)21 UserHandle (android.os.UserHandle)20 HashMap (java.util.HashMap)19 ShortcutKey (com.android.launcher3.shortcuts.ShortcutKey)17 PackageUserKey (com.android.launcher3.util.PackageUserKey)17 Intent (android.content.Intent)16 HashSet (java.util.HashSet)16 Context (android.content.Context)15 ItemInfo (com.android.launcher3.model.data.ItemInfo)14 List (java.util.List)13 AppWidgetProviderInfo (android.appwidget.AppWidgetProviderInfo)12 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)11 AppTarget (android.app.prediction.AppTarget)10 FixedContainerItems (com.android.launcher3.model.BgDataModel.FixedContainerItems)10 ShortcutRequest (com.android.launcher3.shortcuts.ShortcutRequest)10 QueryResult (com.android.launcher3.shortcuts.ShortcutRequest.QueryResult)10