Search in sources :

Example 41 with Workspace

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

the class NoButtonQuickSwitchTouchController method setupAnimators.

private void setupAnimators() {
    // Animate the non-overview components (e.g. workspace, shelf) out of the way.
    StateAnimationConfig nonOverviewBuilder = new StateAnimationConfig();
    nonOverviewBuilder.setInterpolator(ANIM_WORKSPACE_FADE, FADE_OUT_INTERPOLATOR);
    nonOverviewBuilder.setInterpolator(ANIM_ALL_APPS_FADE, FADE_OUT_INTERPOLATOR);
    nonOverviewBuilder.setInterpolator(ANIM_WORKSPACE_SCALE, FADE_OUT_INTERPOLATOR);
    nonOverviewBuilder.setInterpolator(ANIM_DEPTH, FADE_OUT_INTERPOLATOR);
    nonOverviewBuilder.setInterpolator(ANIM_VERTICAL_PROGRESS, TRANSLATE_OUT_INTERPOLATOR);
    updateNonOverviewAnim(QUICK_SWITCH, nonOverviewBuilder);
    mNonOverviewAnim.dispatchOnStart();
    if (mRecentsView.getTaskViewCount() == 0) {
        mRecentsView.setOnEmptyMessageUpdatedListener(isEmpty -> {
            if (!isEmpty && mSwipeDetector.isDraggingState()) {
                // We have loaded tasks, update the animators to start at the correct scale etc.
                setupOverviewAnimators();
            }
        });
    }
    setupOverviewAnimators();
}
Also used : StateAnimationConfig(com.android.launcher3.states.StateAnimationConfig)

Example 42 with Workspace

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

the class ArrowPopup method initColorExtractionLocations.

private void initColorExtractionLocations(Launcher launcher) {
    if (mColorExtractors == null) {
        return;
    }
    Workspace workspace = launcher.getWorkspace();
    if (workspace == null) {
        return;
    }
    boolean firstVisibleChild = true;
    int screenId = workspace.getScreenIdForPageIndex(workspace.getCurrentPage());
    DragLayer dragLayer = launcher.getDragLayer();
    final View[] viewAlignedWithArrow = new View[1];
    // Order matters here, since we need the arrow to match the color of its adjacent view.
    for (final View view : getChildrenForColorExtraction()) {
        if (view != null && view.getVisibility() == VISIBLE) {
            Rect pos = new Rect();
            dragLayer.getDescendantRectRelativeToSelf(view, pos);
            if (!pos.isEmpty()) {
                LocalColorExtractor extractor = LocalColorExtractor.newInstance(launcher);
                extractor.setWorkspaceLocation(pos, dragLayer, screenId);
                extractor.setListener(extractedColors -> {
                    AnimatorSet colors = new AnimatorSet();
                    int newColor = getExtractedColor(extractedColors);
                    setChildColor(view, newColor, colors);
                    int numChildren = view instanceof ViewGroup ? ((ViewGroup) view).getChildCount() : 0;
                    for (int i = 0; i < numChildren; ++i) {
                        View childView = ((ViewGroup) view).getChildAt(i);
                        setChildColor(childView, newColor, colors);
                    }
                    if (viewAlignedWithArrow[0] == view) {
                        mArrowColor = newColor;
                        updateArrowColor();
                    }
                    colors.setDuration(150);
                    view.post(colors::start);
                });
                mColorExtractors.add(extractor);
                if (mIsAboveIcon || firstVisibleChild) {
                    viewAlignedWithArrow[0] = view;
                }
                firstVisibleChild = false;
            }
        }
    }
}
Also used : BaseDragLayer(com.android.launcher3.views.BaseDragLayer) DragLayer(com.android.launcher3.dragndrop.DragLayer) Rect(android.graphics.Rect) ViewGroup(android.view.ViewGroup) AnimatorSet(android.animation.AnimatorSet) LocalColorExtractor(com.android.launcher3.widget.LocalColorExtractor) View(android.view.View) DeepShortcutView(com.android.launcher3.shortcuts.DeepShortcutView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) Workspace(com.android.launcher3.Workspace)

Example 43 with Workspace

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

the class SpringLoadedState method getWorkspaceScaleAndTranslation.

@Override
public ScaleAndTranslation getWorkspaceScaleAndTranslation(Launcher launcher) {
    DeviceProfile grid = launcher.getDeviceProfile();
    Workspace ws = launcher.getWorkspace();
    if (ws.getChildCount() == 0) {
        return super.getWorkspaceScaleAndTranslation(launcher);
    }
    if (grid.isVerticalBarLayout()) {
        float scale = grid.workspaceSpringLoadShrinkFactor;
        return new ScaleAndTranslation(scale, 0, 0);
    }
    float scale = grid.workspaceSpringLoadShrinkFactor;
    Rect insets = launcher.getDragLayer().getInsets();
    float scaledHeight = scale * ws.getNormalChildHeight();
    float shrunkTop = insets.top + grid.dropTargetBarSizePx;
    float shrunkBottom = ws.getMeasuredHeight() - insets.bottom - grid.workspacePadding.bottom - grid.workspaceSpringLoadedBottomSpace;
    float totalShrunkSpace = shrunkBottom - shrunkTop;
    float desiredCellTop = shrunkTop + (totalShrunkSpace - scaledHeight) / 2;
    float halfHeight = ws.getHeight() / 2;
    float myCenter = ws.getTop() + halfHeight;
    float cellTopFromCenter = halfHeight - ws.getChildAt(0).getTop();
    float actualCellTop = myCenter - cellTopFromCenter * scale;
    return new ScaleAndTranslation(scale, 0, (desiredCellTop - actualCellTop) / scale);
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) Rect(android.graphics.Rect) Workspace(com.android.launcher3.Workspace)

Example 44 with Workspace

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

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(ItemClickHandler.INSTANCE);
            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();
    for (int i = 0; i < getChildCount(); i++) {
        BubbleTextView icon = (BubbleTextView) getChildAt(i);
        icon.reset();
        if (predictionCount > i) {
            icon.setVisibility(View.VISIBLE);
            icon.applyFromWorkspaceItem(mPredictedApps.get(i));
        } 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)

Example 45 with Workspace

use of com.android.launcher3.Workspace 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)

Aggregations

View (android.view.View)143 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)124 Point (android.graphics.Point)115 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)97 Rect (android.graphics.Rect)93 ArrayList (java.util.ArrayList)91 ItemInfo (com.android.launcher3.model.data.ItemInfo)86 DragView (com.android.launcher3.dragndrop.DragView)77 PendingAppWidgetHostView (com.android.launcher3.widget.PendingAppWidgetHostView)73 AppWidgetHostView (android.appwidget.AppWidgetHostView)72 Workspace (com.android.launcher3.Workspace)63 SuppressLint (android.annotation.SuppressLint)58 DraggableView (com.android.launcher3.dragndrop.DraggableView)58 Test (org.junit.Test)57 FolderInfo (com.android.launcher3.model.data.FolderInfo)55 CellLayout (com.android.launcher3.CellLayout)51 LauncherAppWidgetInfo (com.android.launcher3.model.data.LauncherAppWidgetInfo)47 IntArray (com.android.launcher3.util.IntArray)45 Intent (android.content.Intent)43 ValueAnimator (android.animation.ValueAnimator)41