Search in sources :

Example 96 with DragLayer

use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by crdroidandroid.

the class ArrowPopup method onLayout.

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    // enforce contained is within screen
    BaseDragLayer dragLayer = getPopupContainer();
    Rect insets = dragLayer.getInsets();
    if (getTranslationX() + l < insets.left || getTranslationX() + r > dragLayer.getWidth() - insets.right) {
        // If we are still off screen, center horizontally too.
        mGravity |= Gravity.CENTER_HORIZONTAL;
    }
    if (Gravity.isHorizontal(mGravity)) {
        setX(dragLayer.getWidth() / 2 - getMeasuredWidth() / 2);
        mArrow.setVisibility(INVISIBLE);
    }
    if (Gravity.isVertical(mGravity)) {
        setY(dragLayer.getHeight() / 2 - getMeasuredHeight() / 2);
    }
}
Also used : BaseDragLayer(com.android.launcher3.views.BaseDragLayer) Rect(android.graphics.Rect)

Example 97 with DragLayer

use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by crdroidandroid.

the class StatefulActivity method onStop.

@Override
protected void onStop() {
    BaseDragLayer dragLayer = getDragLayer();
    final boolean wasActive = isUserActive();
    final STATE_TYPE origState = getStateManager().getState();
    final int origDragLayerChildCount = dragLayer.getChildCount();
    super.onStop();
    if (!isChangingConfigurations()) {
        getStateManager().moveToRestState();
    }
    // Workaround for b/78520668, explicitly trim memory once UI is hidden
    onTrimMemory(TRIM_MEMORY_UI_HIDDEN);
    if (wasActive) {
        // The expected condition is that this activity is stopped because the device goes to
        // sleep and the UI may have noticeable changes.
        dragLayer.post(() -> {
            if ((!getStateManager().isInStableState(origState) || // The drag layer may be animating (e.g. dismissing QSB).
            dragLayer.getAlpha() < 1 || // Maybe an ArrowPopup is closed.
            dragLayer.getChildCount() != origDragLayerChildCount)) {
                onUiChangedWhileSleeping();
            }
        });
    }
}
Also used : BaseDragLayer(com.android.launcher3.views.BaseDragLayer)

Example 98 with DragLayer

use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by crdroidandroid.

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();
    mTaskViewSimulator.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 (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 99 with DragLayer

use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by crdroidandroid.

the class LauncherAppWidgetHostView method onLongClick.

@Override
public boolean onLongClick(View view) {
    if (!Utilities.isWorkspaceEditAllowed(mLauncher.getApplicationContext()))
        return true;
    if (mIsScrollable) {
        DragLayer dragLayer = mLauncher.getDragLayer();
        dragLayer.requestDisallowInterceptTouchEvent(false);
    }
    view.performLongClick();
    return true;
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer)

Example 100 with DragLayer

use of com.android.launcher3.dragndrop.DragLayer in project android_packages_apps_Launcher3 by crdroidandroid.

the class ButtonDropTarget method onDrop.

/**
 * On drop animate the dropView to the icon.
 */
@Override
public void onDrop(final DragObject d, final DragOptions options) {
    if (options.isFlingToDelete) {
        // FlingAnimation handles the animation and then calls completeDrop().
        return;
    }
    final DragLayer dragLayer = mLauncher.getDragLayer();
    final DragView dragView = d.dragView;
    final Rect from = new Rect();
    dragLayer.getViewRectRelativeToSelf(d.dragView, from);
    final Rect to = getIconRect(d);
    final float scale = (float) to.width() / from.width();
    dragView.disableColorExtraction();
    dragView.detachContentView(/* reattachToPreviousParent= */
    true);
    mDropTargetBar.deferOnDragEnd();
    Runnable onAnimationEndRunnable = () -> {
        completeDrop(d);
        mDropTargetBar.onDragEnd();
        mLauncher.getStateManager().goToState(NORMAL);
        // Only re-enable updates once the workspace is back to normal, which will be after the
        // current frame.
        post(dragView::resumeColorExtraction);
    };
    dragLayer.animateView(d.dragView, from, to, scale, 1f, 1f, 0.1f, 0.1f, DRAG_VIEW_DROP_DURATION, Interpolators.DEACCEL_2, Interpolators.LINEAR, onAnimationEndRunnable, DragLayer.ANIMATION_END_DISAPPEAR, null);
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) Rect(android.graphics.Rect) DragView(com.android.launcher3.dragndrop.DragView)

Aggregations

DragLayer (com.android.launcher3.dragndrop.DragLayer)100 Rect (android.graphics.Rect)67 BaseDragLayer (com.android.launcher3.views.BaseDragLayer)33 ViewGroup (android.view.ViewGroup)23 Resources (android.content.res.Resources)22 AnimatorSet (android.animation.AnimatorSet)20 View (android.view.View)18 SuppressLint (android.annotation.SuppressLint)16 AbstractFloatingView (com.android.launcher3.AbstractFloatingView)15 DeviceProfile (com.android.launcher3.DeviceProfile)15 Workspace (com.android.launcher3.Workspace)15 Animator (android.animation.Animator)14 ObjectAnimator (android.animation.ObjectAnimator)14 Point (android.graphics.Point)12 ItemInfo (com.android.launcher3.model.data.ItemInfo)12 CellLayout (com.android.launcher3.CellLayout)11 DragView (com.android.launcher3.dragndrop.DragView)11 ArrayList (java.util.ArrayList)11 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)10 Drawable (android.graphics.drawable.Drawable)10