Search in sources :

Example 1 with LaunchTaskEvent

use of com.android.systemui.recents.events.activity.LaunchTaskEvent in project platform_frameworks_base by android.

the class RecentsView method launchFocusedTask.

/** Launches the focused task from the first stack if possible */
public boolean launchFocusedTask(int logEvent) {
    if (mTaskStackView != null) {
        Task task = mTaskStackView.getFocusedTask();
        if (task != null) {
            TaskView taskView = mTaskStackView.getChildViewForTask(task);
            EventBus.getDefault().send(new LaunchTaskEvent(taskView, task, null, INVALID_STACK_ID, false));
            if (logEvent != 0) {
                MetricsLogger.action(getContext(), logEvent, task.key.getComponent().toString());
            }
            return true;
        }
    }
    return false;
}
Also used : Task(com.android.systemui.recents.model.Task) LaunchTaskEvent(com.android.systemui.recents.events.activity.LaunchTaskEvent)

Example 2 with LaunchTaskEvent

use of com.android.systemui.recents.events.activity.LaunchTaskEvent in project platform_frameworks_base by android.

the class TaskStackView method onBusEvent.

public final void onBusEvent(LaunchNextTaskRequestEvent event) {
    if (mAwaitingFirstLayout) {
        mLaunchNextAfterFirstMeasure = true;
        return;
    }
    int launchTaskIndex = mStack.indexOfStackTask(mStack.getLaunchTarget());
    if (launchTaskIndex != -1) {
        launchTaskIndex = Math.max(0, launchTaskIndex - 1);
    } else {
        launchTaskIndex = mStack.getTaskCount() - 1;
    }
    if (launchTaskIndex != -1) {
        // Stop all animations
        cancelAllTaskViewAnimations();
        final Task launchTask = mStack.getStackTasks().get(launchTaskIndex);
        float curScroll = mStackScroller.getStackScroll();
        float targetScroll = mLayoutAlgorithm.getStackScrollForTaskAtInitialOffset(launchTask);
        float absScrollDiff = Math.abs(targetScroll - curScroll);
        if (getChildViewForTask(launchTask) == null || absScrollDiff > 0.35f) {
            int duration = (int) (LAUNCH_NEXT_SCROLL_BASE_DURATION + absScrollDiff * LAUNCH_NEXT_SCROLL_INCR_DURATION);
            mStackScroller.animateScroll(targetScroll, duration, new Runnable() {

                @Override
                public void run() {
                    EventBus.getDefault().send(new LaunchTaskEvent(getChildViewForTask(launchTask), launchTask, null, INVALID_STACK_ID, false));
                }
            });
        } else {
            EventBus.getDefault().send(new LaunchTaskEvent(getChildViewForTask(launchTask), launchTask, null, INVALID_STACK_ID, false));
        }
        MetricsLogger.action(getContext(), MetricsEvent.OVERVIEW_LAUNCH_PREVIOUS_TASK, launchTask.key.getComponent().toString());
    } else if (mStack.getTaskCount() == 0) {
        // If there are no tasks, then just hide recents back to home.
        EventBus.getDefault().send(new HideRecentsEvent(false, true));
    }
}
Also used : Task(com.android.systemui.recents.model.Task) HideRecentsEvent(com.android.systemui.recents.events.activity.HideRecentsEvent) LaunchTaskEvent(com.android.systemui.recents.events.activity.LaunchTaskEvent)

Example 3 with LaunchTaskEvent

use of com.android.systemui.recents.events.activity.LaunchTaskEvent in project platform_frameworks_base by android.

the class TaskView method onClick.

/**** View.OnClickListener Implementation ****/
@Override
public void onClick(final View v) {
    if (mIsDisabledInSafeMode) {
        Context context = getContext();
        String msg = context.getString(R.string.recents_launch_disabled_message, mTask.title);
        if (mDisabledAppToast != null) {
            mDisabledAppToast.cancel();
        }
        mDisabledAppToast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
        mDisabledAppToast.show();
        return;
    }
    boolean screenPinningRequested = false;
    if (v == mActionButtonView) {
        // Reset the translation of the action button before we animate it out
        mActionButtonView.setTranslationZ(0f);
        screenPinningRequested = true;
    }
    EventBus.getDefault().send(new LaunchTaskEvent(this, mTask, null, INVALID_STACK_ID, screenPinningRequested));
    MetricsLogger.action(v.getContext(), MetricsEvent.ACTION_OVERVIEW_SELECT, mTask.key.getComponent().toString());
}
Also used : Context(android.content.Context) LaunchTaskEvent(com.android.systemui.recents.events.activity.LaunchTaskEvent)

Example 4 with LaunchTaskEvent

use of com.android.systemui.recents.events.activity.LaunchTaskEvent in project platform_frameworks_base by android.

the class TaskViewHeader method onClick.

@Override
public void onClick(View v) {
    if (v == mIconView) {
        // In accessibility, a single click on the focused app info button will show it
        EventBus.getDefault().send(new ShowApplicationInfoEvent(mTask));
    } else if (v == mDismissButton) {
        TaskView tv = Utilities.findParent(this, TaskView.class);
        tv.dismissTask();
        // Keep track of deletions by the dismiss button
        MetricsLogger.histogram(getContext(), "overview_task_dismissed_source", Constants.Metrics.DismissSourceHeaderButton);
    } else if (v == mMoveTaskButton) {
        TaskView tv = Utilities.findParent(this, TaskView.class);
        Rect bounds = mMoveTaskTargetStackId == FREEFORM_WORKSPACE_STACK_ID ? new Rect(mTaskViewRect) : new Rect();
        EventBus.getDefault().send(new LaunchTaskEvent(tv, mTask, bounds, mMoveTaskTargetStackId, false));
    } else if (v == mAppInfoView) {
        EventBus.getDefault().send(new ShowApplicationInfoEvent(mTask));
    } else if (v == mAppIconView) {
        hideAppOverlay(false);
    }
}
Also used : Rect(android.graphics.Rect) LaunchTaskEvent(com.android.systemui.recents.events.activity.LaunchTaskEvent) ShowApplicationInfoEvent(com.android.systemui.recents.events.ui.ShowApplicationInfoEvent)

Example 5 with LaunchTaskEvent

use of com.android.systemui.recents.events.activity.LaunchTaskEvent in project android_frameworks_base by DirtyUnicorns.

the class RecentsView method launchPreviousTask.

/** Launches the task that recents was launched from if possible */
public boolean launchPreviousTask() {
    if (mTaskStackView != null) {
        Task task = getStack().getLaunchTarget();
        if (task != null) {
            TaskView taskView = mTaskStackView.getChildViewForTask(task);
            EventBus.getDefault().send(new LaunchTaskEvent(taskView, task, null, INVALID_STACK_ID, false));
            return true;
        }
    }
    return false;
}
Also used : Task(com.android.systemui.recents.model.Task) LaunchTaskEvent(com.android.systemui.recents.events.activity.LaunchTaskEvent)

Aggregations

LaunchTaskEvent (com.android.systemui.recents.events.activity.LaunchTaskEvent)32 Task (com.android.systemui.recents.model.Task)11 Context (android.content.Context)5 ShowApplicationInfoEvent (com.android.systemui.recents.events.ui.ShowApplicationInfoEvent)5 Rect (android.graphics.Rect)1 HideRecentsEvent (com.android.systemui.recents.events.activity.HideRecentsEvent)1 LockTaskStateChangedEvent (com.android.systemui.recents.events.ui.LockTaskStateChangedEvent)1 TaskStack (com.android.systemui.recents.model.TaskStack)1