Search in sources :

Example 1 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class HotseatEduController method showEdu.

void showEdu() {
    int childCount = mHotseat.getShortcutsAndWidgets().getChildCount();
    CellLayout cellLayout = mLauncher.getWorkspace().getScreenWithId(Workspace.FIRST_SCREEN_ID);
    // hotseat is already empty and does not require migration. show edu tip
    boolean requiresMigration = IntStream.range(0, childCount).anyMatch(i -> {
        View v = mHotseat.getShortcutsAndWidgets().getChildAt(i);
        return v != null && v.getTag() != null && ((ItemInfo) v.getTag()).container != LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
    });
    boolean canMigrateToFirstPage = cellLayout.makeSpaceForHotseatMigration(false);
    if (requiresMigration && canMigrateToFirstPage) {
        showDialog();
    } else {
        new ArrowTipView(mLauncher).show(mLauncher.getString(requiresMigration ? R.string.hotseat_tip_no_empty_slots : R.string.hotseat_auto_enrolled), mHotseat.getTop());
        mLauncher.getStatsLogManager().logger().log(LAUNCHER_HOTSEAT_EDU_ONLY_TIP);
        finishOnboarding();
    }
}
Also used : CellLayout(com.android.launcher3.CellLayout) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ArrowTipView(com.android.launcher3.views.ArrowTipView) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView)

Example 2 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class HotseatEduController method migrateToFolder.

/**
 * This migration places all non folder items in the hotseat into a folder and then moves
 * all folders in the hotseat to a workspace page that has enough empty spots.
 *
 * @return pageId that has accepted the items.
 */
private int migrateToFolder() {
    ArrayDeque<FolderInfo> folders = new ArrayDeque<>();
    ArrayList<WorkspaceItemInfo> putIntoFolder = new ArrayList<>();
    // separate folders and items that can get in folders
    for (int i = 0; i < mLauncher.getDeviceProfile().numShownHotseatIcons; i++) {
        View view = mHotseat.getChildAt(i, 0);
        if (view == null)
            continue;
        ItemInfo info = (ItemInfo) view.getTag();
        if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
            folders.add((FolderInfo) info);
        } else if (info instanceof WorkspaceItemInfo && info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
            putIntoFolder.add((WorkspaceItemInfo) info);
        }
    }
    // create a temp folder and add non folder items to it
    if (!putIntoFolder.isEmpty()) {
        ItemInfo firstItem = putIntoFolder.get(0);
        FolderInfo folderInfo = new FolderInfo();
        mLauncher.getModelWriter().addItemToDatabase(folderInfo, firstItem.container, firstItem.screenId, firstItem.cellX, firstItem.cellY);
        folderInfo.setTitle("", mLauncher.getModelWriter());
        folderInfo.contents.addAll(putIntoFolder);
        for (int i = 0; i < folderInfo.contents.size(); i++) {
            ItemInfo item = folderInfo.contents.get(i);
            item.rank = i;
            mLauncher.getModelWriter().moveItemInDatabase(item, folderInfo.id, 0, item.cellX, item.cellY);
        }
        folders.add(folderInfo);
    }
    mNewItems.addAll(folders);
    return placeFoldersInWorkspace(folders);
}
Also used : ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) ArrayList(java.util.ArrayList) FolderInfo(com.android.launcher3.model.data.FolderInfo) ArrowTipView(com.android.launcher3.views.ArrowTipView) View(android.view.View) ArrayDeque(java.util.ArrayDeque) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 3 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class HotseatPredictionController method pinPrediction.

/**
 * Pins a predicted app icon into place.
 */
public void pinPrediction(ItemInfo info) {
    PredictedAppIcon icon = (PredictedAppIcon) mHotseat.getChildAt(mHotseat.getCellXFromOrder(info.rank), mHotseat.getCellYFromOrder(info.rank));
    if (icon == null) {
        return;
    }
    WorkspaceItemInfo workspaceItemInfo = new WorkspaceItemInfo((WorkspaceItemInfo) info);
    mLauncher.getModelWriter().addItemToDatabase(workspaceItemInfo, LauncherSettings.Favorites.CONTAINER_HOTSEAT, workspaceItemInfo.screenId, workspaceItemInfo.cellX, workspaceItemInfo.cellY);
    ObjectAnimator.ofFloat(icon, SCALE_PROPERTY, 1, 0.8f, 1).start();
    icon.pin(workspaceItemInfo);
    mLauncher.getStatsLogManager().logger().withItemInfo(workspaceItemInfo).log(LAUNCHER_HOTSEAT_PREDICTION_PINNED);
}
Also used : PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 4 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class HotseatPredictionController method logLaunchedAppRankingInfo.

/**
 * Logs rank info based on current list of predicted items
 */
public void logLaunchedAppRankingInfo(@NonNull ItemInfo itemInfo, InstanceId instanceId) {
    ComponentName targetCN = itemInfo.getTargetComponent();
    if (targetCN == null) {
        return;
    }
    int rank = -1;
    for (int i = mPredictedItems.size() - 1; i >= 0; i--) {
        ItemInfo info = mPredictedItems.get(i);
        if (targetCN.equals(info.getTargetComponent()) && itemInfo.user.equals(info.user)) {
            rank = i;
            break;
        }
    }
    if (rank < 0) {
        return;
    }
    int cardinality = 0;
    for (PredictedAppIcon icon : getPredictedIcons()) {
        ItemInfo info = (ItemInfo) icon.getTag();
        cardinality |= 1 << info.screenId;
    }
    PredictedHotseatContainer.Builder containerBuilder = PredictedHotseatContainer.newBuilder();
    containerBuilder.setCardinality(cardinality);
    if (itemInfo.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION) {
        containerBuilder.setIndex(rank);
    }
    mLauncher.getStatsLogManager().logger().withInstanceId(instanceId).withRank(rank).withContainerInfo(ContainerInfo.newBuilder().setPredictedHotseatContainer(containerBuilder).build()).log(LAUNCHER_HOTSEAT_RANKED);
}
Also used : PredictedHotseatContainer(com.android.launcher3.logger.LauncherAtom.PredictedHotseatContainer) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) ComponentName(android.content.ComponentName)

Example 5 with ItemInfo

use of com.android.launcher3.ItemInfo in project android_packages_apps_Launcher3 by crdroidandroid.

the class HotseatPredictionModel method convertDataModelToAppTargetBundle.

/**
 * Creates and returns bundle using workspace items
 */
public static Bundle convertDataModelToAppTargetBundle(Context context, BgDataModel dataModel) {
    Bundle bundle = new Bundle();
    ArrayList<AppTargetEvent> events = new ArrayList<>();
    ArrayList<ItemInfo> workspaceItems = dataModel.getAllWorkspaceItems();
    for (ItemInfo item : workspaceItems) {
        AppTarget target = getAppTargetFromInfo(context, item);
        if (target != null && !isTrackedForPrediction(item))
            continue;
        events.add(wrapAppTargetWithLocation(target, AppTargetEvent.ACTION_PIN, item));
    }
    ArrayList<AppTarget> currentTargets = new ArrayList<>();
    FixedContainerItems hotseatItems = dataModel.extraItems.get(CONTAINER_HOTSEAT_PREDICTION);
    if (hotseatItems != null) {
        for (ItemInfo itemInfo : hotseatItems.items) {
            AppTarget target = getAppTargetFromInfo(context, itemInfo);
            if (target != null)
                currentTargets.add(target);
        }
    }
    bundle.putParcelableArrayList(BUNDLE_KEY_PIN_EVENTS, events);
    bundle.putParcelableArrayList(BUNDLE_KEY_CURRENT_ITEMS, currentTargets);
    return bundle;
}
Also used : AppTarget(android.app.prediction.AppTarget) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) FixedContainerItems(com.android.launcher3.model.BgDataModel.FixedContainerItems) AppTargetEvent(android.app.prediction.AppTargetEvent)

Aggregations

ItemInfo (com.android.launcher3.model.data.ItemInfo)457 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)373 View (android.view.View)199 ArrayList (java.util.ArrayList)169 Point (android.graphics.Point)159 FolderInfo (com.android.launcher3.model.data.FolderInfo)113 SuppressLint (android.annotation.SuppressLint)110 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)100 DragView (com.android.launcher3.dragndrop.DragView)98 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)98 AppWidgetHostView (android.appwidget.AppWidgetHostView)94 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)94 BubbleTextView (com.android.launcher3.BubbleTextView)85 Context (android.content.Context)82 List (java.util.List)80 AppInfo (com.android.launcher3.model.data.AppInfo)79 Intent (android.content.Intent)78 Rect (android.graphics.Rect)76 DraggableView (com.android.launcher3.dragndrop.DraggableView)73 ComponentName (android.content.ComponentName)72