Loading packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +17 −8 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import com.android.systemui.recents.events.activity.DockedTopTaskEvent; import com.android.systemui.recents.events.activity.EnterRecentsWindowLastAnimationFrameEvent; import com.android.systemui.recents.events.activity.HideRecentsEvent; import com.android.systemui.recents.events.activity.IterateRecentsEvent; import com.android.systemui.recents.events.activity.LaunchMostRecentTaskRequestEvent; import com.android.systemui.recents.events.activity.LaunchNextTaskRequestEvent; import com.android.systemui.recents.events.activity.RecentsActivityStartingEvent; import com.android.systemui.recents.events.activity.ToggleRecentsEvent; Loading Loading @@ -303,16 +304,24 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener RecentsConfiguration config = Recents.getConfiguration(); RecentsActivityLaunchState launchState = config.getLaunchState(); if (!launchState.launchedWithAltTab) { // If the user taps quickly if (!debugFlags.isPagingEnabled() || (ViewConfiguration.getDoubleTapMinTime() < elapsedTime && elapsedTime < ViewConfiguration.getDoubleTapTimeout())) { // Has the user tapped quickly? boolean isQuickTap = ViewConfiguration.getDoubleTapMinTime() < elapsedTime && elapsedTime < ViewConfiguration.getDoubleTapTimeout(); if (Recents.getConfiguration().isGridEnabled) { if (isQuickTap) { EventBus.getDefault().post(new LaunchNextTaskRequestEvent()); } else { EventBus.getDefault().post(new LaunchMostRecentTaskRequestEvent()); } } else { if (!debugFlags.isPagingEnabled() || isQuickTap) { // Launch the next focused task EventBus.getDefault().post(new LaunchNextTaskRequestEvent()); } else { // Notify recents to move onto the next task EventBus.getDefault().post(new IterateRecentsEvent()); } } } else { // If the user has toggled it too quickly, then just eat up the event here (it's // better than showing a janky screenshot). Loading packages/SystemUI/src/com/android/systemui/recents/events/activity/LaunchMostRecentTaskRequestEvent.java 0 → 100644 +26 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.recents.events.activity; import com.android.systemui.recents.events.EventBus; /** * This event is sent to request that the most recent task is launched. */ public class LaunchMostRecentTaskRequestEvent extends EventBus.Event { // Simple event } packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +34 −23 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationC import com.android.systemui.recents.events.activity.HideRecentsEvent; import com.android.systemui.recents.events.activity.HideStackActionButtonEvent; import com.android.systemui.recents.events.activity.IterateRecentsEvent; import com.android.systemui.recents.events.activity.LaunchMostRecentTaskRequestEvent; import com.android.systemui.recents.events.activity.LaunchNextTaskRequestEvent; import com.android.systemui.recents.events.activity.LaunchTaskEvent; import com.android.systemui.recents.events.activity.LaunchTaskStartedEvent; Loading Loading @@ -1733,6 +1734,13 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal mUIDozeTrigger.stopDozing(); } public final void onBusEvent(LaunchMostRecentTaskRequestEvent event) { if (mStack.getTaskCount() > 0) { Task mostRecentTask = mStack.getStackFrontMostTask(true /* includeFreefromTasks */); launchTask(mostRecentTask); } } public final void onBusEvent(LaunchNextTaskRequestEvent event) { if (mAwaitingFirstLayout) { mLaunchNextAfterFirstMeasure = true; Loading @@ -1741,29 +1749,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal final Task launchTask = mStack.getNextLaunchTarget(); if (launchTask != null) { // Stop all animations cancelAllTaskViewAnimations(); 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 /* screenPinningRequested */)); } }); } else { EventBus.getDefault().send(new LaunchTaskEvent(getChildViewForTask(launchTask), launchTask, null, INVALID_STACK_ID, false /* screenPinningRequested */)); } launchTask(launchTask); MetricsLogger.action(getContext(), MetricsEvent.OVERVIEW_LAUNCH_PREVIOUS_TASK, launchTask.key.getComponent().toString()); } else if (mStack.getTaskCount() == 0) { Loading Loading @@ -2215,6 +2201,31 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal return -1; } private void launchTask(Task task) { // Stop all animations cancelAllTaskViewAnimations(); float curScroll = mStackScroller.getStackScroll(); float targetScroll = mLayoutAlgorithm.getStackScrollForTaskAtInitialOffset(task); float absScrollDiff = Math.abs(targetScroll - curScroll); if (getChildViewForTask(task) == 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(task), task, null, INVALID_STACK_ID, false /* screenPinningRequested */)); } }); } else { EventBus.getDefault().send(new LaunchTaskEvent(getChildViewForTask(task), task, null, INVALID_STACK_ID, false /* screenPinningRequested */)); } } /** * Check whether we should use the grid layout. */ Loading Loading
packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java +17 −8 Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ import com.android.systemui.recents.events.activity.DockedTopTaskEvent; import com.android.systemui.recents.events.activity.EnterRecentsWindowLastAnimationFrameEvent; import com.android.systemui.recents.events.activity.HideRecentsEvent; import com.android.systemui.recents.events.activity.IterateRecentsEvent; import com.android.systemui.recents.events.activity.LaunchMostRecentTaskRequestEvent; import com.android.systemui.recents.events.activity.LaunchNextTaskRequestEvent; import com.android.systemui.recents.events.activity.RecentsActivityStartingEvent; import com.android.systemui.recents.events.activity.ToggleRecentsEvent; Loading Loading @@ -303,16 +304,24 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener RecentsConfiguration config = Recents.getConfiguration(); RecentsActivityLaunchState launchState = config.getLaunchState(); if (!launchState.launchedWithAltTab) { // If the user taps quickly if (!debugFlags.isPagingEnabled() || (ViewConfiguration.getDoubleTapMinTime() < elapsedTime && elapsedTime < ViewConfiguration.getDoubleTapTimeout())) { // Has the user tapped quickly? boolean isQuickTap = ViewConfiguration.getDoubleTapMinTime() < elapsedTime && elapsedTime < ViewConfiguration.getDoubleTapTimeout(); if (Recents.getConfiguration().isGridEnabled) { if (isQuickTap) { EventBus.getDefault().post(new LaunchNextTaskRequestEvent()); } else { EventBus.getDefault().post(new LaunchMostRecentTaskRequestEvent()); } } else { if (!debugFlags.isPagingEnabled() || isQuickTap) { // Launch the next focused task EventBus.getDefault().post(new LaunchNextTaskRequestEvent()); } else { // Notify recents to move onto the next task EventBus.getDefault().post(new IterateRecentsEvent()); } } } else { // If the user has toggled it too quickly, then just eat up the event here (it's // better than showing a janky screenshot). Loading
packages/SystemUI/src/com/android/systemui/recents/events/activity/LaunchMostRecentTaskRequestEvent.java 0 → 100644 +26 −0 Original line number Diff line number Diff line /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.recents.events.activity; import com.android.systemui.recents.events.EventBus; /** * This event is sent to request that the most recent task is launched. */ public class LaunchMostRecentTaskRequestEvent extends EventBus.Event { // Simple event }
packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java +34 −23 Original line number Diff line number Diff line Loading @@ -64,6 +64,7 @@ import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationC import com.android.systemui.recents.events.activity.HideRecentsEvent; import com.android.systemui.recents.events.activity.HideStackActionButtonEvent; import com.android.systemui.recents.events.activity.IterateRecentsEvent; import com.android.systemui.recents.events.activity.LaunchMostRecentTaskRequestEvent; import com.android.systemui.recents.events.activity.LaunchNextTaskRequestEvent; import com.android.systemui.recents.events.activity.LaunchTaskEvent; import com.android.systemui.recents.events.activity.LaunchTaskStartedEvent; Loading Loading @@ -1733,6 +1734,13 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal mUIDozeTrigger.stopDozing(); } public final void onBusEvent(LaunchMostRecentTaskRequestEvent event) { if (mStack.getTaskCount() > 0) { Task mostRecentTask = mStack.getStackFrontMostTask(true /* includeFreefromTasks */); launchTask(mostRecentTask); } } public final void onBusEvent(LaunchNextTaskRequestEvent event) { if (mAwaitingFirstLayout) { mLaunchNextAfterFirstMeasure = true; Loading @@ -1741,29 +1749,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal final Task launchTask = mStack.getNextLaunchTarget(); if (launchTask != null) { // Stop all animations cancelAllTaskViewAnimations(); 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 /* screenPinningRequested */)); } }); } else { EventBus.getDefault().send(new LaunchTaskEvent(getChildViewForTask(launchTask), launchTask, null, INVALID_STACK_ID, false /* screenPinningRequested */)); } launchTask(launchTask); MetricsLogger.action(getContext(), MetricsEvent.OVERVIEW_LAUNCH_PREVIOUS_TASK, launchTask.key.getComponent().toString()); } else if (mStack.getTaskCount() == 0) { Loading Loading @@ -2215,6 +2201,31 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal return -1; } private void launchTask(Task task) { // Stop all animations cancelAllTaskViewAnimations(); float curScroll = mStackScroller.getStackScroll(); float targetScroll = mLayoutAlgorithm.getStackScrollForTaskAtInitialOffset(task); float absScrollDiff = Math.abs(targetScroll - curScroll); if (getChildViewForTask(task) == 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(task), task, null, INVALID_STACK_ID, false /* screenPinningRequested */)); } }); } else { EventBus.getDefault().send(new LaunchTaskEvent(getChildViewForTask(task), task, null, INVALID_STACK_ID, false /* screenPinningRequested */)); } } /** * Check whether we should use the grid layout. */ Loading