Search in sources :

Example 41 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Trebuchet by LineageOS.

the class WorkspaceAccessibilityHelper method intersectsValidDropTarget.

/**
 * Find the virtual view id corresponding to the top left corner of any drop region by which
 * the passed id is contained. For an icon, this is simply
 */
@Override
protected int intersectsValidDropTarget(int id) {
    int mCountX = mView.getCountX();
    int mCountY = mView.getCountY();
    int x = id % mCountX;
    int y = id / mCountX;
    LauncherAccessibilityDelegate.DragInfo dragInfo = mDelegate.getDragInfo();
    if (dragInfo.dragType == DragType.WIDGET && !mView.acceptsWidget()) {
        return INVALID_POSITION;
    }
    if (dragInfo.dragType == DragType.WIDGET) {
        // For a widget, every cell must be vacant. In addition, we will return any valid
        // drop target by which the passed id is contained.
        boolean fits = false;
        // These represent the amount that we can back off if we hit a problem. They
        // get consumed as we move up and to the right, trying new regions.
        int spanX = dragInfo.info.spanX;
        int spanY = dragInfo.info.spanY;
        for (int m = 0; m < spanX; m++) {
            for (int n = 0; n < spanY; n++) {
                fits = true;
                int x0 = x - m;
                int y0 = y - n;
                if (x0 < 0 || y0 < 0)
                    continue;
                for (int i = x0; i < x0 + spanX; i++) {
                    if (!fits)
                        break;
                    for (int j = y0; j < y0 + spanY; j++) {
                        if (i >= mCountX || j >= mCountY || mView.isOccupied(i, j)) {
                            fits = false;
                            break;
                        }
                    }
                }
                if (fits) {
                    return x0 + mCountX * y0;
                }
            }
        }
        return INVALID_POSITION;
    } else {
        // For an icon, we simply check the view directly below
        View child = mView.getChildAt(x, y);
        if (child == null || child == dragInfo.item) {
            // Empty cell. Good for an icon or folder.
            return id;
        } else if (dragInfo.dragType != DragType.FOLDER) {
            // For icons, we can consider cells that have another icon or a folder.
            ItemInfo info = (ItemInfo) child.getTag();
            if (info instanceof AppInfo || info instanceof FolderInfo || info instanceof WorkspaceItemInfo) {
                return id;
            }
        }
        return INVALID_POSITION;
    }
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) View(android.view.View) FolderInfo(com.android.launcher3.model.data.FolderInfo) AppInfo(com.android.launcher3.model.data.AppInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 42 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Trebuchet by LineageOS.

the class DefaultAppSearchAlgorithmTest method getInfo.

private AppInfo getInfo(String title) {
    AppInfo info = new AppInfo();
    info.title = title;
    info.componentName = new ComponentName("Test", title);
    return info;
}
Also used : ComponentName(android.content.ComponentName) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 43 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Trebuchet by LineageOS.

the class HotseatPredictionController method mapToWorkspaceItemInfo.

private List<WorkspaceItemInfo> mapToWorkspaceItemInfo(List<ComponentKeyMapper> components) {
    AllAppsStore allAppsStore = mLauncher.getAppsView().getAppsStore();
    if (allAppsStore.getApps().length == 0) {
        return Collections.emptyList();
    }
    List<WorkspaceItemInfo> predictedApps = new ArrayList<>();
    for (ComponentKeyMapper mapper : components) {
        ItemInfoWithIcon info = mapper.getApp(allAppsStore);
        if (info instanceof AppInfo) {
            WorkspaceItemInfo predictedApp = new WorkspaceItemInfo((AppInfo) info);
            predictedApp.container = LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
            predictedApps.add(predictedApp);
        } else if (info instanceof WorkspaceItemInfo) {
            WorkspaceItemInfo predictedApp = new WorkspaceItemInfo((WorkspaceItemInfo) info);
            predictedApp.container = LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
            predictedApps.add(predictedApp);
        } else {
            if (DEBUG) {
                Log.e(TAG, "Predicted app not found: " + mapper);
            }
        }
        // Stop at the number of hotseat items
        if (predictedApps.size() == mHotSeatItemsCount) {
            break;
        }
    }
    return predictedApps;
}
Also used : ArrayList(java.util.ArrayList) AllAppsStore(com.android.launcher3.allapps.AllAppsStore) ComponentKeyMapper(com.android.launcher3.appprediction.ComponentKeyMapper) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AppInfo(com.android.launcher3.model.data.AppInfo)

Example 44 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Trebuchet by LineageOS.

the class HotseatPredictionController method showCachedItems.

/**
 * Create WorkspaceItemInfo objects and binds PredictedAppIcon views for cached predicted items.
 */
public void showCachedItems(List<AppInfo> apps, IntArray ranks) {
    if (hasPredictions() && mAppPredictor != null) {
        mAppPredictor.requestPredictionUpdate();
        fillGapsWithPrediction();
        return;
    }
    int count = Math.min(ranks.size(), apps.size());
    List<WorkspaceItemInfo> items = new ArrayList<>(count);
    for (int i = 0; i < count; i++) {
        WorkspaceItemInfo item = new WorkspaceItemInfo(apps.get(i));
        ComponentKey componentKey = new ComponentKey(item.getTargetComponent(), item.user);
        preparePredictionInfo(item, ranks.get(i));
        items.add(item);
        mComponentKeyMappers.add(new ComponentKeyMapper(componentKey, mDynamicItemCache));
    }
    updateDependencies();
    bindItems(items, false, null);
}
Also used : ArrayList(java.util.ArrayList) ComponentKey(com.android.launcher3.util.ComponentKey) ComponentKeyMapper(com.android.launcher3.appprediction.ComponentKeyMapper) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 45 with AppInfo

use of com.android.launcher3.model.data.AppInfo in project android_packages_apps_Trebuchet by LineageOS.

the class PredictionRowView method fillInLogContainerData.

@Override
public void fillInLogContainerData(ItemInfo childInfo, LauncherLogProto.Target child, ArrayList<LauncherLogProto.Target> parents) {
    for (int i = 0; i < mPredictedApps.size(); i++) {
        ItemInfoWithIcon appInfo = mPredictedApps.get(i);
        if (appInfo == childInfo) {
            child.predictedRank = i;
            break;
        }
    }
    parents.add(newContainerTarget(LauncherLogProto.ContainerType.PREDICTION));
    // include where the prediction is coming this used to be Launcher#modifyUserEvent
    LauncherLogProto.Target parent = newTarget(LauncherLogProto.Target.Type.CONTAINER);
    LauncherState state = mLauncher.getStateManager().getState();
    if (state == LauncherState.ALL_APPS) {
        parent.containerType = LauncherLogProto.ContainerType.ALLAPPS;
    } else if (state == OVERVIEW) {
        parent.containerType = LauncherLogProto.ContainerType.TASKSWITCHER;
    }
    parents.add(parent);
}
Also used : LauncherState(com.android.launcher3.LauncherState) LauncherLogProto(com.android.launcher3.userevent.nano.LauncherLogProto) ItemInfoWithIcon(com.android.launcher3.model.data.ItemInfoWithIcon)

Aggregations

AppInfo (com.android.launcher3.model.data.AppInfo)181 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)86 ItemInfo (com.android.launcher3.model.data.ItemInfo)46 ArrayList (java.util.ArrayList)46 ComponentName (android.content.ComponentName)36 AppInfo (com.android.launcher3.AppInfo)33 View (android.view.View)32 LauncherActivityInfo (android.content.pm.LauncherActivityInfo)31 Intent (android.content.Intent)30 FolderInfo (com.android.launcher3.model.data.FolderInfo)30 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)30 UserHandle (android.os.UserHandle)21 PackageItemInfo (com.android.launcher3.model.data.PackageItemInfo)21 PendingAddShortcutInfo (com.android.launcher3.widget.PendingAddShortcutInfo)21 Point (android.graphics.Point)19 BubbleTextView (com.android.launcher3.BubbleTextView)19 LauncherApps (android.content.pm.LauncherApps)17 ItemInfoWithIcon (com.android.launcher3.model.data.ItemInfoWithIcon)17 PendingAddItemInfo (com.android.launcher3.PendingAddItemInfo)15 AppWidgetHostView (android.appwidget.AppWidgetHostView)14