Search in sources :

Example 86 with WorkspaceItemInfo

use of com.android.launcher3.WorkspaceItemInfo 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 87 with WorkspaceItemInfo

use of com.android.launcher3.WorkspaceItemInfo 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 88 with WorkspaceItemInfo

use of com.android.launcher3.WorkspaceItemInfo in project android_packages_apps_Trebuchet by LineageOS.

the class HotseatPredictionController method removePredictedApps.

private void removePredictedApps(List<PredictedAppIcon.PredictedIconOutlineDrawing> outlines, ItemInfo draggedInfo) {
    if (mIconRemoveAnimators != null) {
        mIconRemoveAnimators.end();
    }
    mIconRemoveAnimators = new AnimatorSet();
    removeOutlineDrawings();
    for (PredictedAppIcon icon : getPredictedIcons()) {
        if (!icon.isEnabled()) {
            continue;
        }
        if (icon.getTag().equals(draggedInfo)) {
            mHotseat.removeView(icon);
            continue;
        }
        int rank = ((WorkspaceItemInfo) icon.getTag()).rank;
        outlines.add(new PredictedAppIcon.PredictedIconOutlineDrawing(mHotseat.getCellXFromOrder(rank), mHotseat.getCellYFromOrder(rank), icon));
        icon.setEnabled(false);
        ObjectAnimator animator = ObjectAnimator.ofFloat(icon, SCALE_PROPERTY, 0);
        animator.addListener(new AnimationSuccessListener() {

            @Override
            public void onAnimationSuccess(Animator animator) {
                if (icon.getParent() != null) {
                    mHotseat.removeView(icon);
                }
            }
        });
        mIconRemoveAnimators.play(animator);
    }
    mIconRemoveAnimators.start();
}
Also used : Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ObjectAnimator(android.animation.ObjectAnimator) PredictedAppIcon(com.android.launcher3.uioverrides.PredictedAppIcon) AnimatorSet(android.animation.AnimatorSet) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo) AnimationSuccessListener(com.android.launcher3.anim.AnimationSuccessListener)

Example 89 with WorkspaceItemInfo

use of com.android.launcher3.WorkspaceItemInfo in project android_packages_apps_Trebuchet by LineageOS.

the class PredictionRowView method applyPredictionApps.

private void applyPredictionApps() {
    if (getChildCount() != mNumPredictedAppsPerRow) {
        while (getChildCount() > mNumPredictedAppsPerRow) {
            removeViewAt(0);
        }
        LayoutInflater inflater = mLauncher.getAppsView().getLayoutInflater();
        while (getChildCount() < mNumPredictedAppsPerRow) {
            BubbleTextView icon = (BubbleTextView) inflater.inflate(R.layout.all_apps_icon, this, false);
            icon.setOnClickListener(PREDICTION_CLICK_LISTENER);
            icon.setOnLongClickListener(ItemLongClickListener.INSTANCE_ALL_APPS);
            icon.setLongPressTimeoutFactor(1f);
            icon.setOnFocusChangeListener(mFocusHelper);
            LayoutParams lp = (LayoutParams) icon.getLayoutParams();
            // Ensure the all apps icon height matches the workspace icons in portrait mode.
            lp.height = mLauncher.getDeviceProfile().allAppsCellHeightPx;
            lp.width = 0;
            lp.weight = 1;
            addView(icon);
        }
    }
    int predictionCount = mPredictedApps.size();
    int iconColor = setColorAlphaBound(mIconTextColor, mIconCurrentTextAlpha);
    for (int i = 0; i < getChildCount(); i++) {
        BubbleTextView icon = (BubbleTextView) getChildAt(i);
        icon.reset();
        if (predictionCount > i) {
            icon.setVisibility(View.VISIBLE);
            if (mPredictedApps.get(i) instanceof AppInfo) {
                icon.applyFromApplicationInfo((AppInfo) mPredictedApps.get(i));
            } else if (mPredictedApps.get(i) instanceof WorkspaceItemInfo) {
                icon.applyFromWorkspaceItem((WorkspaceItemInfo) mPredictedApps.get(i));
            }
            icon.setTextColor(iconColor);
        } else {
            icon.setVisibility(predictionCount == 0 ? GONE : INVISIBLE);
        }
    }
    boolean predictionsEnabled = predictionCount > 0;
    if (predictionsEnabled != mPredictionsEnabled) {
        mPredictionsEnabled = predictionsEnabled;
        mLauncher.reapplyUi(false);
        updateVisibility();
    }
    mParent.onHeightUpdated();
}
Also used : LayoutInflater(android.view.LayoutInflater) BubbleTextView(com.android.launcher3.BubbleTextView) AppInfo(com.android.launcher3.model.data.AppInfo) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 90 with WorkspaceItemInfo

use of com.android.launcher3.WorkspaceItemInfo in project android_packages_apps_Trebuchet by LineageOS.

the class BaseSwipeUpHandlerV2 method getItemInfo.

/**
 * Builds proto for logging
 */
public WorkspaceItemInfo getItemInfo(ComponentName componentName) {
    WorkspaceItemInfo placeholderInfo = new WorkspaceItemInfo();
    placeholderInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_TASK;
    placeholderInfo.container = LauncherSettings.Favorites.CONTAINER_TASKFOREGROUND;
    placeholderInfo.intent = new Intent().setComponent(componentName);
    return placeholderInfo;
}
Also used : Intent(android.content.Intent) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Aggregations

WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)418 View (android.view.View)168 ArrayList (java.util.ArrayList)145 ItemInfo (com.android.launcher3.model.data.ItemInfo)125 Intent (android.content.Intent)119 FolderInfo (com.android.launcher3.model.data.FolderInfo)100 AppInfo (com.android.launcher3.model.data.AppInfo)94 BubbleTextView (com.android.launcher3.BubbleTextView)87 AppWidgetHostView (android.appwidget.AppWidgetHostView)84 SuppressLint (android.annotation.SuppressLint)78 DragView (com.android.launcher3.dragndrop.DragView)78 ComponentName (android.content.ComponentName)76 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)73 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)72 Rect (android.graphics.Rect)68 FolderIcon (com.android.launcher3.folder.FolderIcon)68 Context (android.content.Context)62 HashSet (java.util.HashSet)62 Point (android.graphics.Point)59 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)57