Search in sources :

Example 46 with DragLayer

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

the class WorkspaceTouchListener method onTouch.

@Override
public boolean onTouch(View view, MotionEvent ev) {
    mGestureDetector.onTouchEvent(ev);
    int action = ev.getActionMasked();
    if (action == ACTION_DOWN) {
        // Check if we can handle long press.
        boolean handleLongPress = canHandleLongPress();
        if (handleLongPress) {
            // Check if the event is not near the edges
            DeviceProfile dp = mLauncher.getDeviceProfile();
            DragLayer dl = mLauncher.getDragLayer();
            Rect insets = dp.getInsets();
            mTempRect.set(insets.left, insets.top, dl.getWidth() - insets.right, dl.getHeight() - insets.bottom);
            mTempRect.inset(dp.edgeMarginPx, dp.edgeMarginPx);
            handleLongPress = mTempRect.contains((int) ev.getX(), (int) ev.getY());
        }
        if (handleLongPress) {
            mLongPressState = STATE_REQUESTED;
            mTouchDownPoint.set(ev.getX(), ev.getY());
        }
        mWorkspace.onTouchEvent(ev);
        // Return true to keep receiving touch events
        return true;
    }
    if (mLongPressState == STATE_PENDING_PARENT_INFORM) {
        // Inform the workspace to cancel touch handling
        ev.setAction(ACTION_CANCEL);
        mWorkspace.onTouchEvent(ev);
        ev.setAction(action);
        mLongPressState = STATE_COMPLETED;
    }
    final boolean result;
    if (mLongPressState == STATE_COMPLETED) {
        // We have handled the touch, so workspace does not need to know anything anymore.
        result = true;
    } else if (mLongPressState == STATE_REQUESTED) {
        mWorkspace.onTouchEvent(ev);
        if (mWorkspace.isHandlingTouch()) {
            cancelLongPress();
        } else if (action == ACTION_MOVE && PointF.length(mTouchDownPoint.x - ev.getX(), mTouchDownPoint.y - ev.getY()) > mTouchSlop) {
            cancelLongPress();
        }
        result = true;
    } else {
        // We don't want to handle touch, let workspace handle it as usual.
        result = false;
    }
    if (action == ACTION_UP || action == ACTION_POINTER_UP) {
        if (!mWorkspace.isHandlingTouch()) {
            final CellLayout currentPage = (CellLayout) mWorkspace.getChildAt(mWorkspace.getCurrentPage());
            if (currentPage != null) {
                mWorkspace.onWallpaperTap(ev);
            }
        }
    }
    if (action == ACTION_UP || action == ACTION_CANCEL) {
        cancelLongPress();
    }
    return result;
}
Also used : DeviceProfile(com.android.launcher3.DeviceProfile) DragLayer(com.android.launcher3.dragndrop.DragLayer) Rect(android.graphics.Rect) CellLayout(com.android.launcher3.CellLayout)

Example 47 with DragLayer

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

the class FloatingTaskView method addAnimation.

public void addAnimation(PendingAnimation animation, RectF startingBounds, Rect endBounds, View viewToCover, boolean fadeWithThumbnail) {
    final BaseDragLayer dragLayer = mActivity.getDragLayer();
    int[] dragLayerBounds = new int[2];
    dragLayer.getLocationOnScreen(dragLayerBounds);
    SplitOverlayProperties prop = new SplitOverlayProperties(endBounds, startingBounds, viewToCover, dragLayerBounds[0], dragLayerBounds[1]);
    ValueAnimator transitionAnimator = ValueAnimator.ofFloat(0, 1);
    animation.add(transitionAnimator);
    long animDuration = animation.getDuration();
    Rect crop = new Rect();
    RectF floatingTaskViewBounds = new RectF();
    final float initialWindowRadius = supportsRoundedCornersOnWindows(getResources()) ? Math.max(crop.width(), crop.height()) / 2f : 0f;
    if (fadeWithThumbnail) {
        animation.addFloat(mSplitPlaceholderView, SplitPlaceholderView.ALPHA_FLOAT, 0, 1, ACCEL);
        animation.addFloat(mImageView, LauncherAnimUtils.VIEW_ALPHA, 1, 0, DEACCEL_3);
    }
    MultiValueUpdateListener listener = new MultiValueUpdateListener() {

        final FloatProp mWindowRadius = new FloatProp(initialWindowRadius, initialWindowRadius, 0, animDuration, LINEAR);

        final FloatProp mDx = new FloatProp(0, prop.dX, 0, animDuration, LINEAR);

        final FloatProp mDy = new FloatProp(0, prop.dY, 0, animDuration, LINEAR);

        final FloatProp mTaskViewScaleX = new FloatProp(prop.initialTaskViewScaleX, prop.finalTaskViewScaleX, 0, animDuration, LINEAR);

        final FloatProp mTaskViewScaleY = new FloatProp(prop.initialTaskViewScaleY, prop.finalTaskViewScaleY, 0, animDuration, LINEAR);

        @Override
        public void onUpdate(float percent, boolean initOnly) {
            // Calculate the icon position.
            floatingTaskViewBounds.set(startingBounds);
            floatingTaskViewBounds.offset(mDx.value, mDy.value);
            Utilities.scaleRectFAboutCenter(floatingTaskViewBounds, mTaskViewScaleX.value, mTaskViewScaleY.value);
            update(floatingTaskViewBounds, percent, mWindowRadius.value * 1);
        }
    };
    transitionAnimator.addUpdateListener(listener);
}
Also used : RectF(android.graphics.RectF) BaseDragLayer(com.android.launcher3.views.BaseDragLayer) Rect(android.graphics.Rect) MultiValueUpdateListener(com.android.quickstep.util.MultiValueUpdateListener) ValueAnimator(android.animation.ValueAnimator)

Example 48 with DragLayer

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

the class FloatingTaskView method getFloatingTaskView.

/**
 * Configures and returns a an instance of {@link FloatingTaskView} initially matching the
 * appearance of {@code originalView}.
 */
public static FloatingTaskView getFloatingTaskView(StatefulActivity launcher, TaskView originalView, RectF positionOut) {
    final BaseDragLayer dragLayer = launcher.getDragLayer();
    ViewGroup parent = (ViewGroup) dragLayer.getParent();
    final FloatingTaskView floatingView = (FloatingTaskView) launcher.getLayoutInflater().inflate(R.layout.floating_split_select_view, parent, false);
    floatingView.init(launcher, originalView, positionOut);
    parent.addView(floatingView);
    return floatingView;
}
Also used : BaseDragLayer(com.android.launcher3.views.BaseDragLayer) ViewGroup(android.view.ViewGroup)

Example 49 with DragLayer

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

the class AllAppsEduView method show.

/**
 * Shows the All Apps education view and plays the animation.
 */
public static void show(Launcher launcher) {
    final DragLayer dragLayer = launcher.getDragLayer();
    AllAppsEduView view = (AllAppsEduView) launcher.getLayoutInflater().inflate(R.layout.all_apps_edu_view, dragLayer, false);
    view.init(launcher);
    launcher.getDragLayer().addView(view);
    launcher.getStatsLogManager().logger().log(LAUNCHER_ALL_APPS_EDU_SHOWN);
    view.requestLayout();
    view.playAnimation();
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer)

Example 50 with DragLayer

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

the class FloatingWidgetView method getFloatingWidgetView.

/**
 * Configures and returns a an instance of {@link FloatingWidgetView} matching the appearance of
 * {@param originalView}.
 *
 * @param widgetBackgroundPosition a {@link RectF} that will be updated with the widget's
 *                                 background bounds
 * @param windowSize               the size of the window when launched
 * @param windowCornerRadius       the corner radius of the window
 */
public static FloatingWidgetView getFloatingWidgetView(Launcher launcher, LauncherAppWidgetHostView originalView, RectF widgetBackgroundPosition, Size windowSize, float windowCornerRadius, boolean appTargetsAreTranslucent, int fallbackBackgroundColor) {
    final DragLayer dragLayer = launcher.getDragLayer();
    ViewGroup parent = (ViewGroup) dragLayer.getParent();
    FloatingWidgetView floatingView = launcher.getViewCache().getView(R.layout.floating_widget_view, launcher, parent);
    floatingView.recycle();
    floatingView.init(dragLayer, originalView, widgetBackgroundPosition, windowSize, windowCornerRadius, appTargetsAreTranslucent, fallbackBackgroundColor);
    parent.addView(floatingView);
    return floatingView;
}
Also used : DragLayer(com.android.launcher3.dragndrop.DragLayer) ViewGroup(android.view.ViewGroup)

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