Search in sources :

Example 71 with ItemInfo

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

the class QuickstepModelDelegate method registerSnapshotLoggingCallback.

/**
 * Registers a callback to log launcher workspace layout using Statsd pulled atom.
 */
protected void registerSnapshotLoggingCallback() {
    if (mStatsManager == null) {
        Log.d(TAG, "Failed to get StatsManager");
    }
    try {
        mStatsManager.setPullAtomCallback(SysUiStatsLog.LAUNCHER_LAYOUT_SNAPSHOT, null, /* PullAtomMetadata */
        MODEL_EXECUTOR, (i, eventList) -> {
            InstanceId instanceId = new InstanceIdSequence().newInstanceId();
            IntSparseArrayMap<ItemInfo> itemsIdMap;
            synchronized (mDataModel) {
                itemsIdMap = mDataModel.itemsIdMap.clone();
            }
            for (ItemInfo info : itemsIdMap) {
                FolderInfo parent = getContainer(info, itemsIdMap);
                LauncherAtom.ItemInfo itemInfo = info.buildProto(parent);
                Log.d(TAG, itemInfo.toString());
                StatsEvent statsEvent = StatsLogCompatManager.buildStatsEvent(itemInfo, instanceId);
                eventList.add(statsEvent);
            }
            Log.d(TAG, String.format("Successfully logged %d workspace items with instanceId=%d", itemsIdMap.size(), instanceId.getId()));
            additionalSnapshotEvents(instanceId);
            SettingsChangeLogger.INSTANCE.get(mContext).logSnapshot(instanceId);
            return StatsManager.PULL_SUCCESS;
        });
        Log.d(TAG, "Successfully registered for launcher snapshot logging!");
    } catch (RuntimeException e) {
        Log.e(TAG, "Failed to register launcher snapshot logging callback with StatsManager", e);
    }
}
Also used : InstanceId(com.android.launcher3.logging.InstanceId) InstanceIdSequence(com.android.launcher3.logging.InstanceIdSequence) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) PredictionHelper.getAppTargetFromItemInfo(com.android.launcher3.model.PredictionHelper.getAppTargetFromItemInfo) LauncherAtom(com.android.launcher3.logger.LauncherAtom) StatsEvent(android.util.StatsEvent) FolderInfo(com.android.launcher3.model.data.FolderInfo)

Example 72 with ItemInfo

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

the class HotseatEduController method migrateHotseatWhole.

/**
 * This migration option attempts to move the entire hotseat up to the first workspace that
 * has space to host items. If no such page is found, it moves items to a new page.
 *
 * @return pageId where items are migrated
 */
private int migrateHotseatWhole() {
    Workspace workspace = mLauncher.getWorkspace();
    int pageId = -1;
    int toRow = 0;
    for (int i = 0; i < workspace.getPageCount(); i++) {
        CellLayout target = workspace.getScreenWithId(workspace.getScreenIdForPageIndex(i));
        if (target.makeSpaceForHotseatMigration(true)) {
            toRow = mLauncher.getDeviceProfile().inv.numRows - 1;
            pageId = i;
            break;
        }
    }
    if (pageId == -1) {
        pageId = LauncherSettings.Settings.call(mLauncher.getContentResolver(), LauncherSettings.Settings.METHOD_NEW_SCREEN_ID).getInt(LauncherSettings.Settings.EXTRA_VALUE);
        mNewScreens = IntArray.wrap(pageId);
    }
    boolean isPortrait = !mLauncher.getDeviceProfile().isVerticalBarLayout();
    int hotseatItemsNum = mLauncher.getDeviceProfile().numShownHotseatIcons;
    for (int i = 0; i < hotseatItemsNum; i++) {
        int x = isPortrait ? i : 0;
        int y = isPortrait ? 0 : hotseatItemsNum - i - 1;
        View child = mHotseat.getChildAt(x, y);
        if (child == null || child.getTag() == null)
            continue;
        ItemInfo tag = (ItemInfo) child.getTag();
        if (tag.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION)
            continue;
        mLauncher.getModelWriter().moveItemInDatabase(tag, LauncherSettings.Favorites.CONTAINER_DESKTOP, pageId, i, toRow);
        mNewItems.add(tag);
    }
    return pageId;
}
Also used : CellLayout(com.android.launcher3.CellLayout) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView) Workspace(com.android.launcher3.Workspace)

Example 73 with ItemInfo

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

the class HotseatEduController method showHotseatArrowTip.

/**
 * Finds a child suitable child in hotseat and shows arrow tip pointing at it.
 *
 * @param usePinned used to determine target view. If true, will use the first matching pinned
 *                  item. Otherwise, will use the first predicted child
 * @param message   String to be shown inside the arrowView
 * @return whether suitable child was found and tip was shown
 */
private boolean showHotseatArrowTip(boolean usePinned, String message) {
    int childCount = mHotseat.getShortcutsAndWidgets().getChildCount();
    boolean isPortrait = !mLauncher.getDeviceProfile().isVerticalBarLayout();
    BubbleTextView tipTargetView = null;
    for (int i = childCount - 1; i > -1; i--) {
        int x = isPortrait ? i : 0;
        int y = isPortrait ? 0 : i;
        View v = mHotseat.getShortcutsAndWidgets().getChildAt(x, y);
        if (v instanceof BubbleTextView && v.getTag() instanceof WorkspaceItemInfo) {
            ItemInfo info = (ItemInfo) v.getTag();
            boolean isPinned = info.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT;
            if (isPinned == usePinned) {
                tipTargetView = (BubbleTextView) v;
                break;
            }
        }
    }
    if (tipTargetView == null) {
        Log.e(TAG, "Unable to find suitable view for ArrowTip");
        return false;
    }
    Rect bounds = Utilities.getViewBounds(tipTargetView);
    new ArrowTipView(mLauncher).show(message, Gravity.END, bounds.centerX(), bounds.top);
    return true;
}
Also used : Rect(android.graphics.Rect) ItemInfo(com.android.launcher3.model.data.ItemInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) BubbleTextView(com.android.launcher3.BubbleTextView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView) ArrowTipView(com.android.launcher3.views.ArrowTipView) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 74 with ItemInfo

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

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 {
        if (showHotseatArrowTip(requiresMigration, mLauncher.getString(requiresMigration ? R.string.hotseat_tip_no_empty_slots : R.string.hotseat_auto_enrolled))) {
            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) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView)

Example 75 with ItemInfo

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

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)

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