Search in sources :

Example 1 with PredictedAppIcon

use of com.android.launcher3.uioverrides.PredictedAppIcon in project android_packages_apps_Launcher3 by crdroidandroid.

the class HotseatEduDialog method populatePreview.

private void populatePreview(List<WorkspaceItemInfo> predictions) {
    for (int i = 0; i < mActivityContext.getDeviceProfile().numShownHotseatIcons; i++) {
        WorkspaceItemInfo info = predictions.get(i);
        PredictedAppIcon icon = PredictedAppIcon.createIcon(mSampleHotseat, info);
        icon.setEnabled(false);
        icon.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
        icon.verifyHighRes();
        CellLayout.LayoutParams lp = new CellLayout.LayoutParams(i, 0, 1, 1);
        mSampleHotseat.addViewToCellLayout(icon, i, info.getViewId(), lp, true);
    }
}
Also used : CellLayout(com.android.launcher3.CellLayout) PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 2 with PredictedAppIcon

use of com.android.launcher3.uioverrides.PredictedAppIcon in project android_packages_apps_Launcher3 by crdroidandroid.

the class HotseatPredictionController method getPredictedIcons.

private List<PredictedAppIcon> getPredictedIcons() {
    List<PredictedAppIcon> icons = new ArrayList<>();
    ViewGroup vg = mHotseat.getShortcutsAndWidgets();
    for (int i = 0; i < vg.getChildCount(); i++) {
        View child = vg.getChildAt(i);
        if (isPredictedIcon(child)) {
            icons.add((PredictedAppIcon) child);
        }
    }
    return icons;
}
Also used : ViewGroup(android.view.ViewGroup) PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) ArrayList(java.util.ArrayList) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView)

Example 3 with PredictedAppIcon

use of com.android.launcher3.uioverrides.PredictedAppIcon 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 PredictedAppIcon

use of com.android.launcher3.uioverrides.PredictedAppIcon 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 PredictedAppIcon

use of com.android.launcher3.uioverrides.PredictedAppIcon in project android_packages_apps_Launcher3 by crdroidandroid.

the class HotseatPredictionController method fillGapsWithPrediction.

private void fillGapsWithPrediction(boolean animate) {
    if (mPauseFlags != 0) {
        return;
    }
    int predictionIndex = 0;
    ArrayList<WorkspaceItemInfo> newItems = new ArrayList<>();
    // make sure predicted icon removal and filling predictions don't step on each other
    if (mIconRemoveAnimators != null && mIconRemoveAnimators.isRunning()) {
        mIconRemoveAnimators.addListener(new AnimationSuccessListener() {

            @Override
            public void onAnimationSuccess(Animator animator) {
                fillGapsWithPrediction(animate);
                mIconRemoveAnimators.removeListener(this);
            }
        });
        return;
    }
    mPauseFlags |= FLAG_FILL_IN_PROGRESS;
    for (int rank = 0; rank < mHotSeatItemsCount; rank++) {
        View child = mHotseat.getChildAt(mHotseat.getCellXFromOrder(rank), mHotseat.getCellYFromOrder(rank));
        if (child != null && !isPredictedIcon(child)) {
            continue;
        }
        if (mPredictedItems.size() <= predictionIndex) {
            // Remove predicted apps from the past
            if (isPredictedIcon(child)) {
                mHotseat.removeView(child);
            }
            continue;
        }
        WorkspaceItemInfo predictedItem = (WorkspaceItemInfo) mPredictedItems.get(predictionIndex++);
        if (isPredictedIcon(child) && child.isEnabled()) {
            PredictedAppIcon icon = (PredictedAppIcon) child;
            icon.applyFromWorkspaceItem(predictedItem);
            icon.finishBinding(mPredictionLongClickListener);
        } else {
            newItems.add(predictedItem);
        }
        preparePredictionInfo(predictedItem, rank);
    }
    bindItems(newItems, animate);
    mPauseFlags &= ~FLAG_FILL_IN_PROGRESS;
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) ArrayList(java.util.ArrayList) View(android.view.View) ArrowTipView(com.android.launcher3.views.ArrowTipView) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Aggregations

PredictedAppIcon (com.android.launcher3.uioverrides.PredictedAppIcon)7 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)6 Animator (android.animation.Animator)2 AnimatorSet (android.animation.AnimatorSet)2 ObjectAnimator (android.animation.ObjectAnimator)2 View (android.view.View)2 AnimationSuccessListener (com.android.launcher3.anim.AnimationSuccessListener)2 ArrowTipView (com.android.launcher3.views.ArrowTipView)2 ArrayList (java.util.ArrayList)2 ComponentName (android.content.ComponentName)1 ViewGroup (android.view.ViewGroup)1 CellLayout (com.android.launcher3.CellLayout)1 PredictedHotseatContainer (com.android.launcher3.logger.LauncherAtom.PredictedHotseatContainer)1 ItemInfo (com.android.launcher3.model.data.ItemInfo)1