Merge "Fix wrong transition when recents is growing when entering" into nyc-dev

This commit is contained in:
TreeHugger Robot
2016-04-20 01:48:38 +00:00
committed by Android (Google) Code Review
13 changed files with 153 additions and 49 deletions

View File

@@ -21,9 +21,9 @@ import android.view.Display;
import android.view.View; import android.view.View;
public interface RecentsComponent { public interface RecentsComponent {
void showRecents(boolean triggeredFromAltTab, boolean fromHome, View statusBarView); void showRecents(boolean triggeredFromAltTab, boolean fromHome);
void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey); void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
void toggleRecents(Display display, int layoutDirection, View statusBarView); void toggleRecents(Display display);
void preloadRecents(); void preloadRecents();
void cancelPreloadingRecents(); void cancelPreloadingRecents();
void showNextAffiliatedTask(); void showNextAffiliatedTask();

View File

@@ -27,9 +27,9 @@ oneway interface IRecentsNonSystemUserCallbacks {
void preloadRecents(); void preloadRecents();
void cancelPreloadingRecents(); void cancelPreloadingRecents();
void showRecents(boolean triggeredFromAltTab, boolean draggingInRecents, boolean animate, void showRecents(boolean triggeredFromAltTab, boolean draggingInRecents, boolean animate,
boolean reloadTasks, boolean fromHome); boolean reloadTasks, boolean fromHome, int recentsGrowTarget);
void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey); void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
void toggleRecents(); void toggleRecents(int recentsGrowTarget);
void onConfigurationChanged(); void onConfigurationChanged();
void dockTopTask(int topTaskId, int dragMode, int stackCreateMode, void dockTopTask(int topTaskId, int dragMode, int stackCreateMode,
in Rect initialBounds); in Rect initialBounds);

View File

@@ -37,9 +37,7 @@ import android.os.UserHandle;
import android.provider.Settings; import android.provider.Settings;
import android.util.EventLog; import android.util.EventLog;
import android.util.Log; import android.util.Log;
import android.util.MutableBoolean;
import android.view.Display; import android.view.Display;
import android.view.View;
import android.widget.Toast; import android.widget.Toast;
import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsLogger;
@@ -59,6 +57,7 @@ import com.android.systemui.recents.events.ui.RecentsDrawnEvent;
import com.android.systemui.recents.misc.SystemServicesProxy; import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.model.RecentsTaskLoader; import com.android.systemui.recents.model.RecentsTaskLoader;
import com.android.systemui.recents.tv.RecentsTvImpl; import com.android.systemui.recents.tv.RecentsTvImpl;
import com.android.systemui.stackdivider.Divider;
import java.util.ArrayList; import java.util.ArrayList;
@@ -75,6 +74,7 @@ public class Recents extends SystemUI
public final static int EVENT_BUS_PRIORITY = 1; public final static int EVENT_BUS_PRIORITY = 1;
public final static int BIND_TO_SYSTEM_USER_RETRY_DELAY = 5000; public final static int BIND_TO_SYSTEM_USER_RETRY_DELAY = 5000;
public final static int RECENTS_GROW_TARGET_INVALID = -1;
// Purely for experimentation // Purely for experimentation
private final static String RECENTS_OVERRIDE_SYSPROP_KEY = "persist.recents_override_pkg"; private final static String RECENTS_OVERRIDE_SYSPROP_KEY = "persist.recents_override_pkg";
@@ -238,7 +238,7 @@ public class Recents extends SystemUI
* Shows the Recents. * Shows the Recents.
*/ */
@Override @Override
public void showRecents(boolean triggeredFromAltTab, boolean fromHome, View statusBarView) { public void showRecents(boolean triggeredFromAltTab, boolean fromHome) {
// Ensure the device has been provisioned before allowing the user to interact with // Ensure the device has been provisioned before allowing the user to interact with
// recents // recents
if (!isUserSetup()) { if (!isUserSetup()) {
@@ -249,10 +249,12 @@ public class Recents extends SystemUI
return; return;
} }
int recentsGrowTarget = getComponent(Divider.class).getView().growsRecents();
int currentUser = sSystemServicesProxy.getCurrentUser(); int currentUser = sSystemServicesProxy.getCurrentUser();
if (sSystemServicesProxy.isSystemUser(currentUser)) { if (sSystemServicesProxy.isSystemUser(currentUser)) {
mImpl.showRecents(triggeredFromAltTab, false /* draggingInRecents */, mImpl.showRecents(triggeredFromAltTab, false /* draggingInRecents */,
true /* animate */, false /* reloadTasks */, fromHome); true /* animate */, false /* reloadTasks */, fromHome, recentsGrowTarget);
} else { } else {
if (mSystemToUserCallbacks != null) { if (mSystemToUserCallbacks != null) {
IRecentsNonSystemUserCallbacks callbacks = IRecentsNonSystemUserCallbacks callbacks =
@@ -260,7 +262,8 @@ public class Recents extends SystemUI
if (callbacks != null) { if (callbacks != null) {
try { try {
callbacks.showRecents(triggeredFromAltTab, false /* draggingInRecents */, callbacks.showRecents(triggeredFromAltTab, false /* draggingInRecents */,
true /* animate */, false /* reloadTasks */, fromHome); true /* animate */, false /* reloadTasks */, fromHome,
recentsGrowTarget);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Callback failed", e); Log.e(TAG, "Callback failed", e);
} }
@@ -310,7 +313,7 @@ public class Recents extends SystemUI
* Toggles the Recents activity. * Toggles the Recents activity.
*/ */
@Override @Override
public void toggleRecents(Display display, int layoutDirection, View statusBarView) { public void toggleRecents(Display display) {
// Ensure the device has been provisioned before allowing the user to interact with // Ensure the device has been provisioned before allowing the user to interact with
// recents // recents
if (!isUserSetup()) { if (!isUserSetup()) {
@@ -321,16 +324,18 @@ public class Recents extends SystemUI
return; return;
} }
int growTarget = getComponent(Divider.class).getView().growsRecents();
int currentUser = sSystemServicesProxy.getCurrentUser(); int currentUser = sSystemServicesProxy.getCurrentUser();
if (sSystemServicesProxy.isSystemUser(currentUser)) { if (sSystemServicesProxy.isSystemUser(currentUser)) {
mImpl.toggleRecents(); mImpl.toggleRecents(growTarget);
} else { } else {
if (mSystemToUserCallbacks != null) { if (mSystemToUserCallbacks != null) {
IRecentsNonSystemUserCallbacks callbacks = IRecentsNonSystemUserCallbacks callbacks =
mSystemToUserCallbacks.getNonSystemUserRecentsForUser(currentUser); mSystemToUserCallbacks.getNonSystemUserRecentsForUser(currentUser);
if (callbacks != null) { if (callbacks != null) {
try { try {
callbacks.toggleRecents(); callbacks.toggleRecents(growTarget);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Callback failed", e); Log.e(TAG, "Callback failed", e);
} }

View File

@@ -38,8 +38,10 @@ import android.util.MutableBoolean;
import android.view.AppTransitionAnimationSpec; import android.view.AppTransitionAnimationSpec;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.ViewConfiguration; import android.view.ViewConfiguration;
import android.view.WindowManager;
import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.MetricsLogger;
import com.android.internal.policy.DockedDividerUtils;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.SystemUIApplication; import com.android.systemui.SystemUIApplication;
import com.android.systemui.recents.events.EventBus; import com.android.systemui.recents.events.EventBus;
@@ -68,6 +70,7 @@ import com.android.systemui.recents.views.TaskStackView;
import com.android.systemui.recents.views.TaskStackViewScroller; import com.android.systemui.recents.views.TaskStackViewScroller;
import com.android.systemui.recents.views.TaskViewHeader; import com.android.systemui.recents.views.TaskViewHeader;
import com.android.systemui.recents.views.TaskViewTransform; import com.android.systemui.recents.views.TaskViewTransform;
import com.android.systemui.stackdivider.DividerView;
import com.android.systemui.statusbar.BaseStatusBar; import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.phone.NavigationBarGestureHelper; import com.android.systemui.statusbar.phone.NavigationBarGestureHelper;
import com.android.systemui.statusbar.phone.PhoneStatusBar; import com.android.systemui.statusbar.phone.PhoneStatusBar;
@@ -156,7 +159,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
// When this fires, then the user has not released alt-tab for at least // When this fires, then the user has not released alt-tab for at least
// FAST_ALT_TAB_DELAY_MS milliseconds // FAST_ALT_TAB_DELAY_MS milliseconds
showRecents(mTriggeredFromAltTab, false /* draggingInRecents */, true /* animate */, showRecents(mTriggeredFromAltTab, false /* draggingInRecents */, true /* animate */,
false /* reloadTasks */, false /* fromHome */); false /* reloadTasks */, false /* fromHome */,
DividerView.INVALID_RECENTS_GROW_TARGET);
} }
}); });
@@ -230,7 +234,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
} }
public void showRecents(boolean triggeredFromAltTab, boolean draggingInRecents, public void showRecents(boolean triggeredFromAltTab, boolean draggingInRecents,
boolean animate, boolean launchedWhileDockingTask, boolean fromHome) { boolean animate, boolean launchedWhileDockingTask, boolean fromHome,
int growTarget) {
mTriggeredFromAltTab = triggeredFromAltTab; mTriggeredFromAltTab = triggeredFromAltTab;
mDraggingInRecents = draggingInRecents; mDraggingInRecents = draggingInRecents;
mLaunchedWhileDocking = launchedWhileDockingTask; mLaunchedWhileDocking = launchedWhileDockingTask;
@@ -260,7 +265,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
ActivityManager.RunningTaskInfo topTask = ssp.getTopMostTask(); ActivityManager.RunningTaskInfo topTask = ssp.getTopMostTask();
MutableBoolean isTopTaskHome = new MutableBoolean(true); MutableBoolean isTopTaskHome = new MutableBoolean(true);
if (topTask == null || !ssp.isRecentsTopMost(topTask, isTopTaskHome)) { if (topTask == null || !ssp.isRecentsTopMost(topTask, isTopTaskHome)) {
startRecentsActivity(topTask, isTopTaskHome.value || fromHome, animate); startRecentsActivity(topTask, isTopTaskHome.value || fromHome, animate, growTarget);
} }
} catch (ActivityNotFoundException e) { } catch (ActivityNotFoundException e) {
Log.e(TAG, "Failed to launch RecentsActivity", e); Log.e(TAG, "Failed to launch RecentsActivity", e);
@@ -284,7 +289,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
triggeredFromHomeKey)); triggeredFromHomeKey));
} }
public void toggleRecents() { public void toggleRecents(int growTarget) {
// Skip this toggle if we are already waiting to trigger recents via alt-tab // Skip this toggle if we are already waiting to trigger recents via alt-tab
if (mFastAltTabTrigger.isDozing()) { if (mFastAltTabTrigger.isDozing()) {
return; return;
@@ -338,7 +343,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
} }
// Otherwise, start the recents activity // Otherwise, start the recents activity
startRecentsActivity(topTask, isTopTaskHome.value, true /* animate */); startRecentsActivity(topTask, isTopTaskHome.value, true /* animate */, growTarget);
// Only close the other system windows if we are actually showing recents // Only close the other system windows if we are actually showing recents
ssp.sendCloseSystemWindows(BaseStatusBar.SYSTEM_DIALOG_REASON_RECENT_APPS); ssp.sendCloseSystemWindows(BaseStatusBar.SYSTEM_DIALOG_REASON_RECENT_APPS);
@@ -369,7 +374,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
// At this point, we don't know anything about the stack state. So only calculate // At this point, we don't know anything about the stack state. So only calculate
// the dimensions of the thumbnail that we need for the transition into Recents, but // the dimensions of the thumbnail that we need for the transition into Recents, but
// do not draw it until we construct the activity options when we start Recents // do not draw it until we construct the activity options when we start Recents
updateHeaderBarLayout(stack); updateHeaderBarLayout(stack, null /* window rect override*/);
} }
} }
} }
@@ -535,7 +540,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
dragMode == NavigationBarGestureHelper.DRAG_MODE_RECENTS, dragMode == NavigationBarGestureHelper.DRAG_MODE_RECENTS,
false /* animate */, false /* animate */,
true /* launchedWhileDockingTask*/, true /* launchedWhileDockingTask*/,
false /* fromHome */); false /* fromHome */,
DividerView.INVALID_RECENTS_GROW_TARGET);
} }
} }
@@ -574,12 +580,17 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
* since the last call, it will attempt to re-measure and layout the header bar to the new size. * since the last call, it will attempt to re-measure and layout the header bar to the new size.
* *
* @param stack the stack to initialize the stack layout with * @param stack the stack to initialize the stack layout with
* @param windowRectOverride the rectangle to use when calculating the stack state which can
* be different from the current window rect if recents is resizing
* while being launched
*/ */
private void updateHeaderBarLayout(TaskStack stack) { private void updateHeaderBarLayout(TaskStack stack, Rect windowRectOverride) {
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
Rect systemInsets = new Rect(); Rect systemInsets = new Rect();
ssp.getStableInsets(systemInsets); ssp.getStableInsets(systemInsets);
Rect windowRect = ssp.getWindowRect(); Rect windowRect = windowRectOverride != null
? new Rect(windowRectOverride)
: ssp.getWindowRect();
// When docked, the nav bar insets are consumed and the activity is measured without insets. // When docked, the nav bar insets are consumed and the activity is measured without insets.
// However, the window bounds include the insets, so we need to subtract them here to make // However, the window bounds include the insets, so we need to subtract them here to make
// them identical. // them identical.
@@ -682,7 +693,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
* Creates the activity options for an app->recents transition. * Creates the activity options for an app->recents transition.
*/ */
private ActivityOptions getThumbnailTransitionActivityOptions( private ActivityOptions getThumbnailTransitionActivityOptions(
ActivityManager.RunningTaskInfo topTask, TaskStackView stackView) { ActivityManager.RunningTaskInfo topTask, TaskStackView stackView,
Rect windowOverrideRect) {
if (topTask.stackId == FREEFORM_WORKSPACE_STACK_ID) { if (topTask.stackId == FREEFORM_WORKSPACE_STACK_ID) {
ArrayList<AppTransitionAnimationSpec> specs = new ArrayList<>(); ArrayList<AppTransitionAnimationSpec> specs = new ArrayList<>();
ArrayList<Task> tasks = stackView.getStack().getStackTasks(); ArrayList<Task> tasks = stackView.getStack().getStackTasks();
@@ -696,7 +708,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
Task task = tasks.get(i); Task task = tasks.get(i);
if (task.isFreeformTask()) { if (task.isFreeformTask()) {
mTmpTransform = stackLayout.getStackTransformScreenCoordinates(task, mTmpTransform = stackLayout.getStackTransformScreenCoordinates(task,
stackScroller.getStackScroll(), mTmpTransform, null); stackScroller.getStackScroll(), mTmpTransform, null,
windowOverrideRect);
Bitmap thumbnail = drawThumbnailTransitionBitmap(task, mTmpTransform, Bitmap thumbnail = drawThumbnailTransitionBitmap(task, mTmpTransform,
mThumbTransitionBitmapCache); mThumbTransitionBitmapCache);
Rect toTaskRect = new Rect(); Rect toTaskRect = new Rect();
@@ -711,7 +724,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
} else { } else {
// Update the destination rect // Update the destination rect
Task toTask = new Task(); Task toTask = new Task();
TaskViewTransform toTransform = getThumbnailTransitionTransform(stackView, toTask); TaskViewTransform toTransform = getThumbnailTransitionTransform(stackView, toTask,
windowOverrideRect);
Bitmap thumbnail = drawThumbnailTransitionBitmap(toTask, toTransform, Bitmap thumbnail = drawThumbnailTransitionBitmap(toTask, toTransform,
mThumbTransitionBitmapCache); mThumbTransitionBitmapCache);
if (thumbnail != null) { if (thumbnail != null) {
@@ -729,7 +743,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
* Returns the transition rect for the given task id. * Returns the transition rect for the given task id.
*/ */
private TaskViewTransform getThumbnailTransitionTransform(TaskStackView stackView, private TaskViewTransform getThumbnailTransitionTransform(TaskStackView stackView,
Task runningTaskOut) { Task runningTaskOut, Rect windowOverrideRect) {
// Find the running task in the TaskStack // Find the running task in the TaskStack
TaskStack stack = stackView.getStack(); TaskStack stack = stackView.getStack();
Task launchTask = stack.getLaunchTarget(); Task launchTask = stack.getLaunchTarget();
@@ -745,7 +759,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
stackView.updateLayoutAlgorithm(true /* boundScroll */); stackView.updateLayoutAlgorithm(true /* boundScroll */);
stackView.updateToInitialState(); stackView.updateToInitialState();
stackView.getStackAlgorithm().getStackTransformScreenCoordinates(launchTask, stackView.getStackAlgorithm().getStackTransformScreenCoordinates(launchTask,
stackView.getScroller().getStackScroll(), mTmpTransform, null); stackView.getScroller().getStackScroll(), mTmpTransform, null, windowOverrideRect);
return mTmpTransform; return mTmpTransform;
} }
@@ -788,7 +802,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
* Shows the recents activity * Shows the recents activity
*/ */
protected void startRecentsActivity(ActivityManager.RunningTaskInfo topTask, protected void startRecentsActivity(ActivityManager.RunningTaskInfo topTask,
boolean isTopTaskHome, boolean animate) { boolean isTopTaskHome, boolean animate, int growTarget) {
RecentsTaskLoader loader = Recents.getTaskLoader(); RecentsTaskLoader loader = Recents.getTaskLoader();
RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState(); RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
@@ -820,7 +834,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
preloadIcon(topTask); preloadIcon(topTask);
// Update the header bar if necessary // Update the header bar if necessary
updateHeaderBarLayout(stack); Rect windowOverrideRect = getWindowRectOverride(growTarget);
updateHeaderBarLayout(stack, windowOverrideRect);
// Prepare the dummy stack for the transition // Prepare the dummy stack for the transition
TaskStackLayoutAlgorithm.VisibilityReport stackVr = TaskStackLayoutAlgorithm.VisibilityReport stackVr =
@@ -838,7 +853,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
ActivityOptions opts; ActivityOptions opts;
if (useThumbnailTransition) { if (useThumbnailTransition) {
// Try starting with a thumbnail transition // Try starting with a thumbnail transition
opts = getThumbnailTransitionActivityOptions(topTask, mDummyStackView); opts = getThumbnailTransitionActivityOptions(topTask, mDummyStackView,
windowOverrideRect);
} else { } else {
// If there is no thumbnail transition, but is launching from home into recents, then // If there is no thumbnail transition, but is launching from home into recents, then
// use a quick home transition // use a quick home transition
@@ -850,6 +866,18 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
mLastToggleTime = SystemClock.elapsedRealtime(); mLastToggleTime = SystemClock.elapsedRealtime();
} }
private Rect getWindowRectOverride(int growTarget) {
if (growTarget == DividerView.INVALID_RECENTS_GROW_TARGET) {
return null;
}
Rect result = new Rect();
Rect displayRect = Recents.getSystemServices().getDisplayRect();
DockedDividerUtils.calculateBoundsForPosition(growTarget, WindowManager.DOCKED_BOTTOM,
result, displayRect.width(), displayRect.height(),
Recents.getSystemServices().getDockedDividerSize(mContext));
return result;
}
/** /**
* Starts the recents activity. * Starts the recents activity.
*/ */

View File

@@ -57,13 +57,15 @@ public class RecentsImplProxy extends IRecentsNonSystemUserCallbacks.Stub {
@Override @Override
public void showRecents(boolean triggeredFromAltTab, boolean draggingInRecents, boolean animate, public void showRecents(boolean triggeredFromAltTab, boolean draggingInRecents, boolean animate,
boolean reloadTasks, boolean fromHome) throws RemoteException { boolean reloadTasks, boolean fromHome, int growTarget)
throws RemoteException {
SomeArgs args = SomeArgs.obtain(); SomeArgs args = SomeArgs.obtain();
args.argi1 = triggeredFromAltTab ? 1 : 0; args.argi1 = triggeredFromAltTab ? 1 : 0;
args.argi2 = draggingInRecents ? 1 : 0; args.argi2 = draggingInRecents ? 1 : 0;
args.argi3 = animate ? 1 : 0; args.argi3 = animate ? 1 : 0;
args.argi4 = reloadTasks ? 1 : 0; args.argi4 = reloadTasks ? 1 : 0;
args.argi5 = fromHome ? 1 : 0; args.argi5 = fromHome ? 1 : 0;
args.argi6 = growTarget;
mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_RECENTS, args)); mHandler.sendMessage(mHandler.obtainMessage(MSG_SHOW_RECENTS, args));
} }
@@ -75,8 +77,8 @@ public class RecentsImplProxy extends IRecentsNonSystemUserCallbacks.Stub {
} }
@Override @Override
public void toggleRecents() throws RemoteException { public void toggleRecents(int growTarget) throws RemoteException {
mHandler.sendEmptyMessage(MSG_TOGGLE_RECENTS); mHandler.sendMessage(mHandler.obtainMessage(MSG_TOGGLE_RECENTS, growTarget));
} }
@Override @Override
@@ -119,13 +121,13 @@ public class RecentsImplProxy extends IRecentsNonSystemUserCallbacks.Stub {
case MSG_SHOW_RECENTS: case MSG_SHOW_RECENTS:
SomeArgs args = (SomeArgs) msg.obj; SomeArgs args = (SomeArgs) msg.obj;
mImpl.showRecents(args.argi1 != 0, args.argi2 != 0, args.argi3 != 0, mImpl.showRecents(args.argi1 != 0, args.argi2 != 0, args.argi3 != 0,
args.argi4 != 0, args.argi5 != 0); args.argi4 != 0, args.argi5 != 0, args.argi6);
break; break;
case MSG_HIDE_RECENTS: case MSG_HIDE_RECENTS:
mImpl.hideRecents(msg.arg1 != 0, msg.arg2 != 0); mImpl.hideRecents(msg.arg1 != 0, msg.arg2 != 0);
break; break;
case MSG_TOGGLE_RECENTS: case MSG_TOGGLE_RECENTS:
mImpl.toggleRecents(); mImpl.toggleRecents(msg.arg1);
break; break;
case MSG_ON_CONFIGURATION_CHANGED: case MSG_ON_CONFIGURATION_CHANGED:
mImpl.onConfigurationChanged(); mImpl.onConfigurationChanged();

View File

@@ -0,0 +1,26 @@
/*
* Copyright (C) 2016 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.ui;
import com.android.systemui.recents.events.EventBus;
/**
* Sent when recents is about to grow in multi-window mode when entering recents.
*/
public class RecentsGrowingEvent extends EventBus.Event {
}

View File

@@ -49,7 +49,7 @@ public class RecentsTvImpl extends RecentsImpl{
@Override @Override
protected void startRecentsActivity(ActivityManager.RunningTaskInfo topTask, protected void startRecentsActivity(ActivityManager.RunningTaskInfo topTask,
boolean isTopTaskHome, boolean animate) { boolean isTopTaskHome, boolean animate, int growTarget) {
RecentsTaskLoader loader = Recents.getTaskLoader(); RecentsTaskLoader loader = Recents.getTaskLoader();
// In the case where alt-tab is triggered, we never get a preloadRecents() call, so we // In the case where alt-tab is triggered, we never get a preloadRecents() call, so we

View File

@@ -302,7 +302,8 @@ public class RecentsTransitionHelper {
specs.add(composeOffscreenAnimationSpec(task, offscreenTaskRect)); specs.add(composeOffscreenAnimationSpec(task, offscreenTaskRect));
} else { } else {
mTmpTransform.fillIn(taskView); mTmpTransform.fillIn(taskView);
stackLayout.transformToScreenCoordinates(mTmpTransform); stackLayout.transformToScreenCoordinates(mTmpTransform,
null /* windowOverrideRect */);
specs.add(composeAnimationSpec(stackView, taskView, mTmpTransform, specs.add(composeAnimationSpec(stackView, taskView, mTmpTransform,
true /* addHeaderBitmap */)); true /* addHeaderBitmap */));
} }
@@ -324,7 +325,8 @@ public class RecentsTransitionHelper {
specs.add(composeOffscreenAnimationSpec(t, offscreenTaskRect)); specs.add(composeOffscreenAnimationSpec(t, offscreenTaskRect));
} else { } else {
mTmpTransform.fillIn(taskView); mTmpTransform.fillIn(taskView);
stackLayout.transformToScreenCoordinates(mTmpTransform); stackLayout.transformToScreenCoordinates(mTmpTransform,
null /* windowOverrideRect */);
specs.add(composeAnimationSpec(stackView, tv, mTmpTransform, specs.add(composeAnimationSpec(stackView, tv, mTmpTransform,
true /* addHeaderBitmap */)); true /* addHeaderBitmap */));
} }

View File

@@ -830,18 +830,23 @@ public class TaskStackLayoutAlgorithm {
* Like {@link #getStackTransform}, but in screen coordinates * Like {@link #getStackTransform}, but in screen coordinates
*/ */
public TaskViewTransform getStackTransformScreenCoordinates(Task task, float stackScroll, public TaskViewTransform getStackTransformScreenCoordinates(Task task, float stackScroll,
TaskViewTransform transformOut, TaskViewTransform frontTransform) { TaskViewTransform transformOut, TaskViewTransform frontTransform,
Rect windowOverrideRect) {
TaskViewTransform transform = getStackTransform(task, stackScroll, mFocusState, TaskViewTransform transform = getStackTransform(task, stackScroll, mFocusState,
transformOut, frontTransform, true /* forceUpdate */, transformOut, frontTransform, true /* forceUpdate */,
false /* ignoreTaskOverrides */); false /* ignoreTaskOverrides */);
return transformToScreenCoordinates(transform); return transformToScreenCoordinates(transform, windowOverrideRect);
} }
/** /**
* Transforms the given {@param transformOut} to the screen coordinates. * Transforms the given {@param transformOut} to the screen coordinates, overriding the current
* window rectangle with {@param windowOverrideRect} if non-null.
*/ */
public TaskViewTransform transformToScreenCoordinates(TaskViewTransform transformOut) { public TaskViewTransform transformToScreenCoordinates(TaskViewTransform transformOut,
Rect windowRect = Recents.getSystemServices().getWindowRect(); Rect windowOverrideRect) {
Rect windowRect = windowOverrideRect != null
? windowOverrideRect
: Recents.getSystemServices().getWindowRect();
transformOut.rect.offset(windowRect.left, windowRect.top); transformOut.rect.offset(windowRect.left, windowRect.top);
return transformOut; return transformOut;
} }

View File

@@ -72,6 +72,7 @@ import com.android.systemui.recents.events.ui.AllTaskViewsDismissedEvent;
import com.android.systemui.recents.events.ui.DeleteTaskDataEvent; import com.android.systemui.recents.events.ui.DeleteTaskDataEvent;
import com.android.systemui.recents.events.ui.DismissAllTaskViewsEvent; import com.android.systemui.recents.events.ui.DismissAllTaskViewsEvent;
import com.android.systemui.recents.events.ui.DismissTaskViewEvent; import com.android.systemui.recents.events.ui.DismissTaskViewEvent;
import com.android.systemui.recents.events.ui.RecentsGrowingEvent;
import com.android.systemui.recents.events.ui.TaskViewDismissedEvent; import com.android.systemui.recents.events.ui.TaskViewDismissedEvent;
import com.android.systemui.recents.events.ui.UpdateFreeformTaskViewVisibilityEvent; import com.android.systemui.recents.events.ui.UpdateFreeformTaskViewVisibilityEvent;
import com.android.systemui.recents.events.ui.UserInteractionEvent; import com.android.systemui.recents.events.ui.UserInteractionEvent;
@@ -189,6 +190,9 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
private TaskViewTransform mTmpTransform = new TaskViewTransform(); private TaskViewTransform mTmpTransform = new TaskViewTransform();
private ArrayList<TaskViewTransform> mTmpTaskTransforms = new ArrayList<>(); private ArrayList<TaskViewTransform> mTmpTaskTransforms = new ArrayList<>();
private int[] mTmpIntPair = new int[2]; private int[] mTmpIntPair = new int[2];
private boolean mResetToInitialStateWhenResized;
private int mLastWidth;
private int mLastHeight;
// A convenience update listener to request updating clipping of tasks // A convenience update listener to request updating clipping of tasks
private ValueAnimator.AnimatorUpdateListener mRequestUpdateClippingListener = private ValueAnimator.AnimatorUpdateListener mRequestUpdateClippingListener =
@@ -1164,9 +1168,13 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
// If this is the first layout, then scroll to the front of the stack, then update the // If this is the first layout, then scroll to the front of the stack, then update the
// TaskViews with the stack so that we can lay them out // TaskViews with the stack so that we can lay them out
if (mAwaitingFirstLayout || mInitialState != INITIAL_STATE_UPDATE_NONE) { boolean resetToInitialState = (width != mLastWidth || height != mLastHeight)
if (mInitialState != INITIAL_STATE_UPDATE_LAYOUT_ONLY) { && mResetToInitialStateWhenResized;
if (mAwaitingFirstLayout || mInitialState != INITIAL_STATE_UPDATE_NONE
|| resetToInitialState) {
if (mInitialState != INITIAL_STATE_UPDATE_LAYOUT_ONLY || resetToInitialState) {
updateToInitialState(); updateToInitialState();
mResetToInitialStateWhenResized = false;
} }
if (!mAwaitingFirstLayout) { if (!mAwaitingFirstLayout) {
mInitialState = INITIAL_STATE_UPDATE_NONE; mInitialState = INITIAL_STATE_UPDATE_NONE;
@@ -1186,6 +1194,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
} }
setMeasuredDimension(width, height); setMeasuredDimension(width, height);
mLastWidth = width;
mLastHeight = height;
mInMeasureLayout = false; mInMeasureLayout = false;
} }
@@ -1973,6 +1983,10 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
} }
} }
public final void onBusEvent(RecentsGrowingEvent event) {
mResetToInitialStateWhenResized = true;
}
public void reloadOnConfigurationChange() { public void reloadOnConfigurationChange() {
mStableLayoutAlgorithm.reloadOnConfigurationChange(getContext()); mStableLayoutAlgorithm.reloadOnConfigurationChange(getContext());
mLayoutAlgorithm.reloadOnConfigurationChange(getContext()); mLayoutAlgorithm.reloadOnConfigurationChange(getContext());

View File

@@ -32,6 +32,7 @@ import android.graphics.Region.Op;
import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager;
import android.os.Bundle; import android.os.Bundle;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.MutableInt;
import android.view.Display; import android.view.Display;
import android.view.DisplayInfo; import android.view.DisplayInfo;
import android.view.GestureDetector; import android.view.GestureDetector;
@@ -66,6 +67,7 @@ import com.android.systemui.recents.events.activity.DockedTopTaskEvent;
import com.android.systemui.recents.events.activity.RecentsActivityStartingEvent; import com.android.systemui.recents.events.activity.RecentsActivityStartingEvent;
import com.android.systemui.recents.events.activity.UndockingTaskEvent; import com.android.systemui.recents.events.activity.UndockingTaskEvent;
import com.android.systemui.recents.events.ui.RecentsDrawnEvent; import com.android.systemui.recents.events.ui.RecentsDrawnEvent;
import com.android.systemui.recents.events.ui.RecentsGrowingEvent;
import com.android.systemui.recents.misc.SystemServicesProxy; import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.stackdivider.events.StartedDragingEvent; import com.android.systemui.stackdivider.events.StartedDragingEvent;
import com.android.systemui.stackdivider.events.StoppedDragingEvent; import com.android.systemui.stackdivider.events.StoppedDragingEvent;
@@ -81,6 +83,8 @@ public class DividerView extends FrameLayout implements OnTouchListener,
static final long TOUCH_ANIMATION_DURATION = 150; static final long TOUCH_ANIMATION_DURATION = 150;
static final long TOUCH_RELEASE_ANIMATION_DURATION = 200; static final long TOUCH_RELEASE_ANIMATION_DURATION = 200;
public static final int INVALID_RECENTS_GROW_TARGET = -1;
private static final int LOG_VALUE_RESIZE_50_50 = 0; private static final int LOG_VALUE_RESIZE_50_50 = 0;
private static final int LOG_VALUE_RESIZE_DOCKED_SMALLER = 1; private static final int LOG_VALUE_RESIZE_DOCKED_SMALLER = 1;
private static final int LOG_VALUE_RESIZE_DOCKED_LARGER = 2; private static final int LOG_VALUE_RESIZE_DOCKED_LARGER = 2;
@@ -88,7 +92,6 @@ public class DividerView extends FrameLayout implements OnTouchListener,
private static final int LOG_VALUE_UNDOCK_MAX_DOCKED = 0; private static final int LOG_VALUE_UNDOCK_MAX_DOCKED = 0;
private static final int LOG_VALUE_UNDOCK_MAX_OTHER = 1; private static final int LOG_VALUE_UNDOCK_MAX_OTHER = 1;
private static final int TASK_POSITION_SAME = Integer.MAX_VALUE; private static final int TASK_POSITION_SAME = Integer.MAX_VALUE;
private static final boolean SWAPPING_ENABLED = false; private static final boolean SWAPPING_ENABLED = false;
@@ -1028,6 +1031,24 @@ public class DividerView extends FrameLayout implements OnTouchListener,
mBackground.getRight(), mBackground.getBottom(), Op.UNION); mBackground.getRight(), mBackground.getBottom(), Op.UNION);
} }
/**
* Checks whether recents will grow when invoked. This happens in multi-window when recents is
* very small. When invoking recents, we shrink the docked stack so recents has more space.
*
* @return the position of the divider when recents grows, or
* {@link #INVALID_RECENTS_GROW_TARGET} if recents won't grow
*/
public int growsRecents() {
boolean result = mGrowRecents
&& mWindowManagerProxy.getDockSide() == WindowManager.DOCKED_TOP
&& getCurrentPosition() == getSnapAlgorithm().getLastSplitTarget().position;
if (result) {
return getSnapAlgorithm().getMiddleTarget().position;
} else {
return INVALID_RECENTS_GROW_TARGET;
}
}
public final void onBusEvent(RecentsActivityStartingEvent recentsActivityStartingEvent) { public final void onBusEvent(RecentsActivityStartingEvent recentsActivityStartingEvent) {
if (mGrowRecents && getWindowManagerProxy().getDockSide() == WindowManager.DOCKED_TOP if (mGrowRecents && getWindowManagerProxy().getDockSide() == WindowManager.DOCKED_TOP
&& getCurrentPosition() == getSnapAlgorithm().getLastSplitTarget().position) { && getCurrentPosition() == getSnapAlgorithm().getLastSplitTarget().position) {
@@ -1067,7 +1088,8 @@ public class DividerView extends FrameLayout implements OnTouchListener,
if (mGrowAfterRecentsDrawn) { if (mGrowAfterRecentsDrawn) {
mGrowAfterRecentsDrawn = false; mGrowAfterRecentsDrawn = false;
updateDockSide(); updateDockSide();
stopDragging(getCurrentPosition(), mSnapAlgorithm.getMiddleTarget(), 250, EventBus.getDefault().send(new RecentsGrowingEvent());
stopDragging(getCurrentPosition(), mSnapAlgorithm.getMiddleTarget(), 336,
Interpolators.FAST_OUT_SLOW_IN); Interpolators.FAST_OUT_SLOW_IN);
} }
} }

View File

@@ -1318,7 +1318,7 @@ public abstract class BaseStatusBar extends SystemUI implements
protected void showRecents(boolean triggeredFromAltTab, boolean fromHome) { protected void showRecents(boolean triggeredFromAltTab, boolean fromHome) {
if (mRecents != null) { if (mRecents != null) {
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS); sendCloseSystemWindows(SYSTEM_DIALOG_REASON_RECENT_APPS);
mRecents.showRecents(triggeredFromAltTab, fromHome, getStatusBarView()); mRecents.showRecents(triggeredFromAltTab, fromHome);
} }
} }
@@ -1330,7 +1330,7 @@ public abstract class BaseStatusBar extends SystemUI implements
protected void toggleRecents() { protected void toggleRecents() {
if (mRecents != null) { if (mRecents != null) {
mRecents.toggleRecents(mDisplay, mLayoutDirection, getStatusBarView()); mRecents.toggleRecents(mDisplay);
} }
} }

View File

@@ -1364,7 +1364,7 @@ class WindowStateAnimator {
final Task task = w.getTask(); final Task task = w.getTask();
// We got resized, so block all updates until we got the new surface. // We got resized, so block all updates until we got the new surface.
if (w.mResizedWhileNotDragResizing) { if (w.mResizedWhileNotDragResizing && !w.isGoneForLayoutLw()) {
return; return;
} }