Search in sources :

Example 91 with Task

use of com.android.systemui.recents.model.Task in project android_frameworks_base by AOSPA.

the class TaskStackView method onBusEvent.

public final void onBusEvent(final DismissAllTaskViewsEvent event) {
    // Keep track of the tasks which will have their data removed
    ArrayList<Task> tasks = new ArrayList<>(mStack.getStackTasks());
    ArrayList<TaskView> deletedTasks = new ArrayList<>();
    ArrayList<TaskView> taskViews = new ArrayList<>(getTaskViews());
    for (TaskView t : taskViews) {
        if (Recents.sLockedTasks.contains(t.getTask())) {
            deletedTasks.add(t);
        }
    }
    taskViews.removeAll(deletedTasks);
    mAnimationHelper.startDeleteAllTasksAnimation(taskViews, useGridLayout(), event.getAnimationTrigger());
    event.addPostAnimationCallback(new Runnable() {

        @Override
        public void run() {
            // Announce for accessibility
            announceForAccessibility(getContext().getString(R.string.accessibility_recents_all_items_dismissed));
            // Remove all tasks and delete the task data for all tasks
            mStack.removeAllTasks();
            for (int i = tasks.size() - 1; i >= 0; i--) {
                Task t = tasks.get(i);
                if (Recents.sLockedTasks.contains(t))
                    continue;
                EventBus.getDefault().send(new DeleteTaskDataEvent(t));
            }
            MetricsLogger.action(getContext(), MetricsEvent.OVERVIEW_DISMISS_ALL);
        }
    });
}
Also used : Task(com.android.systemui.recents.model.Task) GridTaskView(com.android.systemui.recents.views.grid.GridTaskView) ArrayList(java.util.ArrayList) DeleteTaskDataEvent(com.android.systemui.recents.events.ui.DeleteTaskDataEvent)

Example 92 with Task

use of com.android.systemui.recents.model.Task in project android_frameworks_base by AOSPA.

the class TaskStackView method onInitializeAccessibilityNodeInfo.

@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    List<TaskView> taskViews = getTaskViews();
    int taskViewCount = taskViews.size();
    if (taskViewCount > 1) {
        // Find the accessibility focused task
        Task focusedTask = getAccessibilityFocusedTask();
        info.setScrollable(true);
        int focusedTaskIndex = mStack.indexOfStackTask(focusedTask);
        if (focusedTaskIndex > 0) {
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
        }
        if (0 <= focusedTaskIndex && focusedTaskIndex < mStack.getTaskCount() - 1) {
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
        }
    }
}
Also used : GridTaskView(com.android.systemui.recents.views.grid.GridTaskView) Task(com.android.systemui.recents.model.Task)

Example 93 with Task

use of com.android.systemui.recents.model.Task in project android_frameworks_base by AOSPA.

the class TaskStackViewTouchHandler method updateTaskViewTransforms.

/**
     * Interpolates the non-deleting tasks to their final transforms from their current transforms.
     */
private void updateTaskViewTransforms(float dismissFraction) {
    List<TaskView> taskViews = mSv.getTaskViews();
    int taskViewCount = taskViews.size();
    for (int i = 0; i < taskViewCount; i++) {
        TaskView tv = taskViews.get(i);
        Task task = tv.getTask();
        if (mSv.isIgnoredTask(task)) {
            continue;
        }
        int taskIndex = mCurrentTasks.indexOf(task);
        if (taskIndex == -1) {
            // just ignore it
            continue;
        }
        TaskViewTransform fromTransform = mCurrentTaskTransforms.get(taskIndex);
        TaskViewTransform toTransform = mFinalTaskTransforms.get(taskIndex);
        mTmpTransform.copyFrom(fromTransform);
        // We only really need to interpolate the bounds, progress and translation
        mTmpTransform.rect.set(Utilities.RECTF_EVALUATOR.evaluate(dismissFraction, fromTransform.rect, toTransform.rect));
        mTmpTransform.dimAlpha = fromTransform.dimAlpha + (toTransform.dimAlpha - fromTransform.dimAlpha) * dismissFraction;
        mTmpTransform.viewOutlineAlpha = fromTransform.viewOutlineAlpha + (toTransform.viewOutlineAlpha - fromTransform.viewOutlineAlpha) * dismissFraction;
        mTmpTransform.translationZ = fromTransform.translationZ + (toTransform.translationZ - fromTransform.translationZ) * dismissFraction;
        mSv.updateTaskViewToTransform(tv, mTmpTransform, AnimationProps.IMMEDIATE);
    }
}
Also used : Task(com.android.systemui.recents.model.Task)

Example 94 with Task

use of com.android.systemui.recents.model.Task in project android_frameworks_base by AOSPA.

the class TaskStackViewTouchHandler method canChildBeDismissed.

@Override
public boolean canChildBeDismissed(View v) {
    // Disallow dismissing an already dismissed task
    TaskView tv = (TaskView) v;
    Task task = tv.getTask();
    return !mSwipeHelperAnimations.containsKey(v) && !Recents.sLockedTasks.contains(task) && (mSv.getStack().indexOfStackTask(task) != -1);
}
Also used : Task(com.android.systemui.recents.model.Task)

Example 95 with Task

use of com.android.systemui.recents.model.Task in project android_frameworks_base by crdroidandroid.

the class SwipeHelper method onTouchEvent.

public boolean onTouchEvent(MotionEvent ev) {
    if (mLongPressSent) {
        return true;
    }
    if (!mDragging) {
        if (mCallback.getChildAtPosition(ev) != null) {
            // We are dragging directly over a card, make sure that we also catch the gesture
            // even if nobody else wants the touch event.
            onInterceptTouchEvent(ev);
            return true;
        } else {
            // We are not doing anything, make sure the long press callback
            // is not still ticking like a bomb waiting to go off.
            removeLongPressCallback();
            return false;
        }
    }
    mVelocityTracker.addMovement(ev);
    final int action = ev.getAction();
    switch(action) {
        case MotionEvent.ACTION_OUTSIDE:
        case MotionEvent.ACTION_MOVE:
            if (mCurrView != null) {
                float delta = getPos(ev) - mInitialTouchPos;
                float absDelta = Math.abs(delta);
                if (absDelta >= getFalsingThreshold()) {
                    mTouchAboveFalsingThreshold = true;
                }
                // maxScrollDistance
                if (CONSTRAIN_SWIPE && !mCallback.canChildBeDismissed(mCurrView)) {
                    float size = getSize(mCurrView);
                    float maxScrollDistance = 0.25f * size;
                    if (absDelta >= size) {
                        delta = delta > 0 ? maxScrollDistance : -maxScrollDistance;
                    } else {
                        delta = maxScrollDistance * (float) Math.sin((delta / size) * (Math.PI / 2));
                    }
                }
                setTranslation(mCurrView, mTranslation + delta);
                updateSwipeProgressFromOffset(mCurrView, mCanCurrViewBeDimissed);
                onMoveUpdate(mCurrView, mTranslation + delta, delta);
            }
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            if (mCurrView == null) {
                break;
            }
            mVelocityTracker.computeCurrentVelocity(1000, /* px/sec */
            getMaxVelocity());
            float velocity = getVelocity(mVelocityTracker);
            if (!handleUpEvent(ev, mCurrView, velocity, getTranslation(mCurrView))) {
                if (isDismissGesture(ev)) {
                    // flingadingy
                    TaskView mTaskView = (TaskView) mCurrView;
                    Task mTask = mTaskView.getTask();
                    if (mTask.isLockedTask) {
                        // snappity
                        mCallback.onDragCancelled(mCurrView);
                        snapChild(mCurrView, 0, /* leftTarget */
                        velocity);
                    } else {
                        // flingadingy
                        dismissChild(mCurrView, velocity, !swipedFastEnough());
                    }
                } else {
                    // snappity
                    mCallback.onDragCancelled(mCurrView);
                    snapChild(mCurrView, 0, /* leftTarget */
                    velocity);
                }
                mCurrView = null;
            }
            mDragging = false;
            break;
    }
    return true;
}
Also used : TaskView(com.android.systemui.recents.views.TaskView) Task(com.android.systemui.recents.model.Task)

Aggregations

Task (com.android.systemui.recents.model.Task)225 TaskStack (com.android.systemui.recents.model.TaskStack)56 GridTaskView (com.android.systemui.recents.views.grid.GridTaskView)43 RecentsActivityLaunchState (com.android.systemui.recents.RecentsActivityLaunchState)30 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)25 ArrayList (java.util.ArrayList)23 ActivityOptions (android.app.ActivityOptions)20 RecentsConfiguration (com.android.systemui.recents.RecentsConfiguration)20 RecentsTaskLoadPlan (com.android.systemui.recents.model.RecentsTaskLoadPlan)20 RecentsTaskLoader (com.android.systemui.recents.model.RecentsTaskLoader)20 Resources (android.content.res.Resources)15 AppTransitionAnimationSpec (android.view.AppTransitionAnimationSpec)15 LaunchTaskEvent (com.android.systemui.recents.events.activity.LaunchTaskEvent)11 TimeInterpolator (android.animation.TimeInterpolator)10 ActivityManager (android.app.ActivityManager)10 Bitmap (android.graphics.Bitmap)10 Rect (android.graphics.Rect)10 RectF (android.graphics.RectF)10 Interpolator (android.view.animation.Interpolator)10 PathInterpolator (android.view.animation.PathInterpolator)10