Search in sources :

Example 96 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by ProtonAOSP.

the class AbsSwipeUpHandler method onRecentsAnimationStart.

@Override
public void onRecentsAnimationStart(RecentsAnimationController controller, RecentsAnimationTargets targets) {
    super.onRecentsAnimationStart(controller, targets);
    ActiveGestureLog.INSTANCE.addLog("startRecentsAnimationCallback", targets.apps.length);
    mRemoteTargetHandles = mTargetGluer.assignTargetsForSplitScreen(targets);
    mRecentsAnimationController = controller;
    mRecentsAnimationTargets = targets;
    // configurations targets.homeContentInsets may not be correct.
    if (mActivity == null) {
        RemoteAnimationTargetCompat primaryTaskTarget = targets.apps[0];
        // orientation state is independent of which remote target handle we use since both
        // should be pointing to the same one. Just choose index 0 for now since that works for
        // both split and non-split
        RecentsOrientedState orientationState = mRemoteTargetHandles[0].getTaskViewSimulator().getOrientationState();
        DeviceProfile dp = orientationState.getLauncherDeviceProfile();
        if (targets.minimizedHomeBounds != null && primaryTaskTarget != null) {
            Rect overviewStackBounds = mActivityInterface.getOverviewWindowBounds(targets.minimizedHomeBounds, primaryTaskTarget);
            dp = dp.getMultiWindowProfile(mContext, new WindowBounds(overviewStackBounds, targets.homeContentInsets));
        } else {
            // If we are not in multi-window mode, home insets should be same as system insets.
            dp = dp.copy(mContext);
        }
        dp.updateInsets(targets.homeContentInsets);
        dp.updateIsSeascape(mContext);
        initTransitionEndpoints(dp);
        orientationState.setMultiWindowMode(dp.isMultiWindowMode);
    }
    // Notify when the animation starts
    flushOnRecentsAnimationAndLauncherBound();
    TaskViewUtils.setSplitAuxiliarySurfacesShown(mRecentsAnimationTargets.nonApps, false, /*shown*/
    true);
    // Only add the callback to enable the input consumer after we actually have the controller
    mStateCallback.runOnceAtState(STATE_APP_CONTROLLER_RECEIVED | STATE_GESTURE_STARTED, mRecentsAnimationController::enableInputConsumer);
    mStateCallback.setStateOnUiThread(STATE_APP_CONTROLLER_RECEIVED);
    mPassedOverviewThreshold = false;
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) Rect(android.graphics.Rect) WindowBounds(com.android.launcher3.util.WindowBounds) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) RecentsOrientedState(com.android.quickstep.util.RecentsOrientedState)

Example 97 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by ProtonAOSP.

the class AbsSwipeUpHandler method onLauncherStart.

private void onLauncherStart() {
    final T activity = mActivityInterface.getCreatedActivity();
    if (mActivity != activity) {
        return;
    }
    if (mStateCallback.hasStates(STATE_HANDLER_INVALIDATED)) {
        return;
    }
    // RecentsView never updates the display rotation until swipe-up, force update
    // RecentsOrientedState before passing to TaskViewSimulator.
    mRecentsView.updateRecentsRotation();
    runActionOnRemoteHandles(remoteTargetHandle -> remoteTargetHandle.getTaskViewSimulator().setOrientationState(mRecentsView.getPagedViewOrientedState()));
    // as that will set the state as BACKGROUND_APP, overriding the animation to NORMAL.
    if (mGestureState.getEndTarget() != HOME) {
        Runnable initAnimFactory = () -> {
            mAnimationFactory = mActivityInterface.prepareRecentsUI(mDeviceState, mWasLauncherAlreadyVisible, this::onAnimatorPlaybackControllerCreated);
            maybeUpdateRecentsAttachedState(false);
            if (mGestureState.getEndTarget() != null) {
                // Update the end target in case the gesture ended before we init.
                mAnimationFactory.setEndTarget(mGestureState.getEndTarget());
            }
        };
        if (mWasLauncherAlreadyVisible) {
            // Launcher is visible, but might be about to stop. Thus, if we prepare recents
            // now, it might get overridden by moveToRestState() in onStop(). To avoid this,
            // wait until the next gesture (and possibly launcher) starts.
            mStateCallback.runOnceAtState(STATE_GESTURE_STARTED, initAnimFactory);
        } else {
            initAnimFactory.run();
        }
    }
    AbstractFloatingView.closeAllOpenViewsExcept(activity, mWasLauncherAlreadyVisible, AbstractFloatingView.TYPE_LISTENER);
    if (mWasLauncherAlreadyVisible) {
        mStateCallback.setState(STATE_LAUNCHER_DRAWN);
    } else {
        Object traceToken = TraceHelper.INSTANCE.beginSection("WTS-init");
        View dragLayer = activity.getDragLayer();
        dragLayer.getViewTreeObserver().addOnDrawListener(new OnDrawListener() {

            boolean mHandled = false;

            @Override
            public void onDraw() {
                if (mHandled) {
                    return;
                }
                mHandled = true;
                TraceHelper.INSTANCE.endSection(traceToken);
                dragLayer.post(() -> dragLayer.getViewTreeObserver().removeOnDrawListener(this));
                if (activity != mActivity) {
                    return;
                }
                mStateCallback.setState(STATE_LAUNCHER_DRAWN);
            }
        });
    }
    activity.getRootView().setOnApplyWindowInsetsListener(this);
    mStateCallback.setState(STATE_LAUNCHER_STARTED);
}
Also used : LAUNCHER_QUICKSWITCH_RIGHT(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_QUICKSWITCH_RIGHT) STATE_END_TARGET_SET(com.android.quickstep.GestureState.STATE_END_TARGET_SET) LAUNCHER_QUICKSWITCH_LEFT(com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_QUICKSWITCH_LEFT) LENGTH_SHORT(android.widget.Toast.LENGTH_SHORT) OnDrawListener(android.view.ViewTreeObserver.OnDrawListener) TaskView(com.android.quickstep.views.TaskView) View(android.view.View) RecentsView(com.android.quickstep.views.RecentsView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView)

Example 98 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by ProtonAOSP.

the class Folder method onDropCompleted.

@Override
public void onDropCompleted(final View target, final DragObject d, final boolean success) {
    if (success) {
        if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelfViaIcon && target != this) {
            replaceFolderWithFinalItem();
        }
    } else {
        // The drag failed, we need to return the item to the folder
        WorkspaceItemInfo info = (WorkspaceItemInfo) d.dragInfo;
        View icon = (mCurrentDragView != null && mCurrentDragView.getTag() == info) ? mCurrentDragView : mContent.createNewView(info);
        ArrayList<View> views = getIconsInReadingOrder();
        info.rank = Utilities.boundToRange(info.rank, 0, views.size());
        views.add(info.rank, icon);
        mContent.arrangeChildren(views);
        mItemsInvalidated = true;
        try (SuppressInfoChanges s = new SuppressInfoChanges()) {
            mFolderIcon.onDrop(d, true);
        }
    }
    if (target != this) {
        if (mOnExitAlarm.alarmPending()) {
            mOnExitAlarm.cancelAlarm();
            if (!success) {
                mSuppressFolderDeletion = true;
            }
            mScrollPauseAlarm.cancelAlarm();
            completeDragExit();
        }
    }
    mDeleteFolderOnDropCompleted = false;
    mDragInProgress = false;
    mItemAddedBackToSelfViaIcon = false;
    mCurrentDragView = null;
    // Reordering may have occured, and we need to save the new item locations. We do this once
    // at the end to prevent unnecessary database operations.
    updateItemLocationsInDatabaseBatch(false);
    // been refreshed yet.
    if (getItemCount() <= mContent.itemsPerPage()) {
        // Show the animation, next time something is added to the folder.
        mInfo.setOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION, false, mLauncherDelegate.getModelWriter());
    }
}
Also used : ClipPathView(com.android.launcher3.views.ClipPathView) BubbleTextView(com.android.launcher3.BubbleTextView) View(android.view.View) TextView(android.widget.TextView) AppWidgetHostView(android.appwidget.AppWidgetHostView) PagedView(com.android.launcher3.PagedView) AbstractFloatingView(com.android.launcher3.AbstractFloatingView) WorkspaceItemInfo(com.android.launcher3.model.data.WorkspaceItemInfo)

Example 99 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by ProtonAOSP.

the class DragController method findDropTarget.

private DropTarget findDropTarget(int x, int y, int[] dropCoordinates) {
    mDragObject.x = x;
    mDragObject.y = y;
    final Rect r = mRectTemp;
    final ArrayList<DropTarget> dropTargets = mDropTargets;
    final int count = dropTargets.size();
    for (int i = count - 1; i >= 0; i--) {
        DropTarget target = dropTargets.get(i);
        if (!target.isDropEnabled())
            continue;
        target.getHitRectRelativeToDragLayer(r);
        if (r.contains(x, y)) {
            dropCoordinates[0] = x;
            dropCoordinates[1] = y;
            mActivity.getDragLayer().mapCoordInSelfToDescendant((View) target, dropCoordinates);
            return target;
        }
    }
    // Pass all unhandled drag to workspace. Workspace finds the correct
    // cell layout to drop to in the existing drag/drop logic.
    dropCoordinates[0] = x;
    dropCoordinates[1] = y;
    return getDefaultDropTarget(dropCoordinates);
}
Also used : Rect(android.graphics.Rect) DropTarget(com.android.launcher3.DropTarget) Point(android.graphics.Point)

Example 100 with Target

use of com.android.launcher3.userevent.nano.LauncherLogProto.Target in project android_packages_apps_Launcher3 by ProtonAOSP.

the class AppWidgetResizeFrame method snapToWidget.

private void snapToWidget(boolean animate) {
    getSnappedRectRelativeToDragLayer(sTmpRect);
    int newWidth = sTmpRect.width();
    int newHeight = sTmpRect.height();
    int newX = sTmpRect.left;
    int newY = sTmpRect.top;
    // down accordingly to provide a proper touch target.
    if (newY < 0) {
        // In this case we shift the touch region down to start at the top of the DragLayer
        mTopTouchRegionAdjustment = -newY;
    } else {
        mTopTouchRegionAdjustment = 0;
    }
    if (newY + newHeight > mDragLayer.getHeight()) {
        // In this case we shift the touch region up to end at the bottom of the DragLayer
        mBottomTouchRegionAdjustment = -(newY + newHeight - mDragLayer.getHeight());
    } else {
        mBottomTouchRegionAdjustment = 0;
    }
    final DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
    final CellLayout pairedCellLayout;
    if (mCellLayout.getParent() instanceof Workspace) {
        Workspace workspace = (Workspace) mCellLayout.getParent();
        pairedCellLayout = workspace.getScreenPair(mCellLayout);
    } else {
        pairedCellLayout = null;
    }
    if (!animate) {
        lp.width = newWidth;
        lp.height = newHeight;
        lp.x = newX;
        lp.y = newY;
        for (int i = 0; i < HANDLE_COUNT; i++) {
            mDragHandles[i].setAlpha(1f);
        }
        if (pairedCellLayout != null) {
            updateInvalidResizeEffect(mCellLayout, pairedCellLayout, /* alpha= */
            1f, /* springLoadedProgress= */
            0f);
        }
        requestLayout();
    } else {
        ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(lp, PropertyValuesHolder.ofInt(LAYOUT_WIDTH, lp.width, newWidth), PropertyValuesHolder.ofInt(LAYOUT_HEIGHT, lp.height, newHeight), PropertyValuesHolder.ofInt(LAYOUT_X, lp.x, newX), PropertyValuesHolder.ofInt(LAYOUT_Y, lp.y, newY));
        mFirstFrameAnimatorHelper.addTo(oa).addUpdateListener(a -> requestLayout());
        AnimatorSet set = new AnimatorSet();
        set.play(oa);
        for (int i = 0; i < HANDLE_COUNT; i++) {
            set.play(mFirstFrameAnimatorHelper.addTo(ObjectAnimator.ofFloat(mDragHandles[i], ALPHA, 1f)));
        }
        if (pairedCellLayout != null) {
            updateInvalidResizeEffect(mCellLayout, pairedCellLayout, /* alpha= */
            1f, /* springLoadedProgress= */
            0f, /* animatorSet= */
            set);
        }
        set.setDuration(SNAP_DURATION);
        set.start();
    }
    setFocusableInTouchMode(true);
    requestFocus();
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet)

Aggregations

View (android.view.View)85 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)59 Point (android.graphics.Point)42 Rect (android.graphics.Rect)41 AppWidgetHostView (android.appwidget.AppWidgetHostView)40 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)38 ItemInfo (com.android.launcher3.model.data.ItemInfo)37 Animator (android.animation.Animator)35 ValueAnimator (android.animation.ValueAnimator)35 Target (com.android.launcher3.userevent.nano.LauncherLogProto.Target)35 BubbleTextView (com.android.launcher3.BubbleTextView)34 DropTarget (com.android.launcher3.DropTarget)32 DragView (com.android.launcher3.dragndrop.DragView)30 LauncherAppWidgetHostView (com.android.launcher3.widget.LauncherAppWidgetHostView)30 AnimatorSet (android.animation.AnimatorSet)29 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)29 ComponentName (android.content.ComponentName)28 ObjectAnimator (android.animation.ObjectAnimator)27 DraggableView (com.android.launcher3.dragndrop.DraggableView)26 AppInfo (com.android.launcher3.model.data.AppInfo)26