int createMode = data.readInt();
boolean toTop = data.readInt() != 0;
boolean animate = data.readInt() != 0;
- moveTaskToDockedStack(taskId, createMode, toTop, animate);
+ Rect bounds = null;
+ boolean hasBounds = data.readInt() != 0;
+ if (hasBounds) {
+ bounds = Rect.CREATOR.createFromParcel(data);
+ }
+ moveTaskToDockedStack(taskId, createMode, toTop, animate, bounds);
reply.writeNoException();
return true;
}
reply.recycle();
}
@Override
- public void moveTaskToDockedStack(int taskId, int createMode, boolean toTop, boolean animate)
- throws RemoteException
+ public void moveTaskToDockedStack(int taskId, int createMode, boolean toTop, boolean animate,
+ Rect initialBounds) throws RemoteException
{
Parcel data = Parcel.obtain();
Parcel reply = Parcel.obtain();
data.writeInt(createMode);
data.writeInt(toTop ? 1 : 0);
data.writeInt(animate ? 1 : 0);
+ if (initialBounds != null) {
+ data.writeInt(1);
+ initialBounds.writeToParcel(data, 0);
+ } else {
+ data.writeInt(0);
+ }
mRemote.transact(MOVE_TASK_TO_DOCKED_STACK_TRANSACTION, data, reply, 0);
reply.readException();
data.recycle();
public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot) throws RemoteException;
public void moveTaskBackwards(int task) throws RemoteException;
public void moveTaskToStack(int taskId, int stackId, boolean toTop) throws RemoteException;
- public void moveTaskToDockedStack(int taskId, int createMode, boolean toTop, boolean animate)
- throws RemoteException;
+ public void moveTaskToDockedStack(int taskId, int createMode, boolean toTop, boolean animate,
+ Rect initialBounds) throws RemoteException;
public boolean moveTopActivityToPinnedStack(int stackId, Rect bounds) throws RemoteException;
public void resizeStack(int stackId, Rect bounds, boolean allowResizeInDockedMode) throws RemoteException;
public void positionTaskInStack(int taskId, int stackId, int position) throws RemoteException;
package com.android.systemui;
+import android.graphics.Rect;
import android.view.Display;
import android.view.View;
/**
* Docks the top-most task and opens recents.
*/
- void dockTopTask(boolean draggingInRecents);
+ void dockTopTask(boolean draggingInRecents, Rect initialBounds);
/**
* Called during a drag-from-navbar-in gesture.
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.res.Configuration;
+import android.graphics.Rect;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
}
@Override
- public void dockTopTask(boolean draggingInRecents) {
- mImpl.dockTopTask(draggingInRecents);
+ public void dockTopTask(boolean draggingInRecents, Rect initialBounds) {
+ mImpl.dockTopTask(draggingInRecents, initialBounds);
if (draggingInRecents) {
mDraggingInRecentsCurrentUser = sSystemServicesProxy.getCurrentUser();
}
showRelativeAffiliatedTask(false);
}
- public void dockTopTask(boolean draggingInRecents) {
+ public void dockTopTask(boolean draggingInRecents, Rect initialBounds) {
SystemServicesProxy ssp = Recents.getSystemServices();
ActivityManager.RunningTaskInfo topTask = ssp.getTopMostTask();
if (topTask != null && !SystemServicesProxy.isHomeStack(topTask.stackId)) {
ssp.moveTaskToDockedStack(topTask.id,
- ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT);
+ ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT, initialBounds);
showRecents(false /* triggeredFromAltTab */, draggingInRecents, false /* animate */);
}
}
}
/** Docks an already resumed task to the side of the screen. */
- public void moveTaskToDockedStack(int taskId, int createMode) {
+ public void moveTaskToDockedStack(int taskId, int createMode, Rect initialBounds) {
if (mIam == null) return;
try {
- mIam.moveTaskToDockedStack(taskId, createMode, true /* onTop */, false /* animate */);
+ mIam.moveTaskToDockedStack(taskId, createMode, true /* onTop */, false /* animate */,
+ initialBounds);
} catch (RemoteException e) {
e.printStackTrace();
}
return mStartPosition + touchY - mStartY;
}
- public void resizeStack(int position) {
- mTmpRect.set(0, 0, mDisplayWidth, mDisplayHeight);
- switch (mDockSide) {
+ public void calculateBoundsForPosition(int position, int dockSide, Rect outRect) {
+ outRect.set(0, 0, mDisplayWidth, mDisplayHeight);
+ switch (dockSide) {
case WindowManager.DOCKED_LEFT:
- mTmpRect.right = position;
+ outRect.right = position;
break;
case WindowManager.DOCKED_TOP:
- mTmpRect.bottom = position;
+ outRect.bottom = position;
break;
case WindowManager.DOCKED_RIGHT:
- mTmpRect.left = position + mDividerWindowWidth - 2 * mDividerInsets;
+ outRect.left = position + mDividerWindowWidth - 2 * mDividerInsets;
break;
case WindowManager.DOCKED_BOTTOM:
- mTmpRect.top = position + mDividerWindowWidth - 2 * mDividerInsets;
+ outRect.top = position + mDividerWindowWidth - 2 * mDividerInsets;
break;
}
+ }
+
+ public void resizeStack(int position) {
+ calculateBoundsForPosition(position, mDockSide, mTmpRect);
if (mTmpRect.equals(mLastResizeRect)) {
return;
}
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.graphics.Rect;
import android.os.SystemProperties;
import android.view.GestureDetector;
import android.view.MotionEvent;
if (touchSlopExceeded && mDivider.getView().getWindowManagerProxy().getDockSide()
== DOCKED_INVALID) {
mDragMode = calculateDragMode();
- mRecentsComponent.dockTopTask(mDragMode == DRAG_MODE_RECENTS);
+ Rect initialBounds = null;
+ if (mDragMode == DRAG_MODE_DIVIDER) {
+ initialBounds = new Rect();
+ mDivider.getView().calculateBoundsForPosition(mIsVertical
+ ? (int) event.getRawX()
+ : (int) event.getRawY(),
+ mDivider.getView().isHorizontalDivision()
+ ? DOCKED_TOP
+ : DOCKED_LEFT,
+ initialBounds);
+ }
+ mRecentsComponent.dockTopTask(mDragMode == DRAG_MODE_RECENTS, initialBounds);
if (mDragMode == DRAG_MODE_DIVIDER) {
mDivider.getView().startDragging();
}
mVelocityTracker.computeCurrentVelocity(1000);
if (mDockWindowTouchSlopExceeded) {
if (mDragMode == DRAG_MODE_DIVIDER) {
- mDivider.getView().stopDragging(!mIsVertical
- ? (int) event.getRawY()
- : (int) event.getRawX(),
- !mIsVertical
- ? mVelocityTracker.getYVelocity()
- : mVelocityTracker.getXVelocity());
+ mDivider.getView().stopDragging(mIsVertical
+ ? (int) event.getRawX()
+ : (int) event.getRawY(),
+ mIsVertical
+ ? mVelocityTracker.getXVelocity()
+ : mVelocityTracker.getYVelocity());
} else if (mDragMode == DRAG_MODE_RECENTS) {
mRecentsComponent.onDraggingInRecentsEnded(mVelocityTracker.getYVelocity());
}
@Override
public boolean onLongClick(View v) {
if (mRecents != null) {
- mRecents.dockTopTask(false /* draggingInRecents */);
+ mRecents.dockTopTask(false /* draggingInRecents */, null /* initialBounds */);
return true;
}
return false;
if (launchStackId != INVALID_STACK_ID) {
if (launchStackId == DOCKED_STACK_ID && bOptions != null) {
ActivityOptions activityOptions = new ActivityOptions(bOptions);
- mWindowManager.setDockedStackCreateMode(activityOptions.getDockCreateMode());
+ mWindowManager.setDockedStackCreateState(activityOptions.getDockCreateMode(),
+ null /* initialBounds */);
}
if (task.stack.mStackId != launchStackId) {
mStackSupervisor.moveTaskToStackLocked(
* {@link android.app.ActivityManager#DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT}
* @param toTop If the task and stack should be moved to the top.
* @param animate Whether we should play an animation for the moving the task
+ * @param initialBounds If the docked stack gets created, it will use these bounds for the
+ * docked stack. Pass {@code null} to use default bounds.
*/
@Override
- public void moveTaskToDockedStack(int taskId, int createMode, boolean toTop, boolean animate) {
+ public void moveTaskToDockedStack(int taskId, int createMode, boolean toTop, boolean animate,
+ Rect initialBounds) {
enforceCallingPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS,
"moveTaskToDockedStack()");
synchronized (this) {
try {
if (DEBUG_STACK) Slog.d(TAG_STACK, "moveTaskToDockedStack: moving task=" + taskId
+ " to createMode=" + createMode + " toTop=" + toTop);
- mWindowManager.setDockedStackCreateMode(createMode);
- mStackSupervisor.moveTaskToStackLocked(
- taskId, DOCKED_STACK_ID, toTop, !FORCE_FOCUS, "moveTaskToDockedStack",
- animate);
+ mWindowManager.setDockedStackCreateState(createMode, initialBounds);
+ mStackSupervisor.moveTaskToStackLocked(taskId, DOCKED_STACK_ID, toTop, !FORCE_FOCUS,
+ "moveTaskToDockedStack", animate);
} finally {
Binder.restoreCallingIdentity(ident);
}
? DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT
: DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT;
mService.mActivityManager.moveTaskToDockedStack(
- mTask.mTaskId, createMode, true /*toTop*/, true /* animate */);
+ mTask.mTaskId, createMode, true /*toTop*/, true /* animate */,
+ null /* initialBounds */);
}
} catch(RemoteException e) {}
if (dockedStack != null) {
dockedStack.getRawBounds(mTmpRect2);
}
- final boolean dockedOnTopOrLeft = WindowManagerService.sDockedStackCreateMode
+ final boolean dockedOnTopOrLeft = mService.mDockedStackCreateMode
== DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
getStackDockedModeBounds(mTmpRect, bounds, mStackId, mTmpRect2,
mDisplayContent.mDividerControllerLocked.getContentWidth(),
* close to the side of the dock.
* @param dockOnTopOrLeft If the docked stack is on the top or left side of the screen.
*/
- private static void getStackDockedModeBounds(
+ private void getStackDockedModeBounds(
Rect displayRect, Rect outBounds, int stackId, Rect dockedBounds, int dockDividerWidth,
boolean dockOnTopOrLeft) {
final boolean dockedStack = stackId == DOCKED_STACK_ID;
outBounds.set(displayRect);
if (dockedStack) {
+ if (mService.mDockedStackCreateBounds != null) {
+ outBounds.set(mService.mDockedStackCreateBounds);
+ return;
+ }
// The initial bounds of the docked stack when it is created half the screen space and
// its bounds can be adjusted after that. The bounds of all other stacks are adjusted
// to occupy whatever screen space the docked stack isn't occupying.
final Rect bounds = new Rect();
mDisplayContent.getLogicalDisplayRect(bounds);
if (!fullscreen) {
- final boolean dockedOnTopOrLeft = WindowManagerService.sDockedStackCreateMode
+ final boolean dockedOnTopOrLeft = mService.mDockedStackCreateMode
== DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
getStackDockedModeBounds(bounds, bounds, FULLSCREEN_WORKSPACE_STACK_ID, dockedBounds,
mDisplayContent.mDividerControllerLocked.getContentWidth(), dockedOnTopOrLeft);
private boolean mKeyguardWaitingForActivityDrawn;
- static int sDockedStackCreateMode = DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
+ int mDockedStackCreateMode = DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT;
+ Rect mDockedStackCreateBounds;
private final SparseIntArray mTmpTaskIds = new SparseIntArray();
return (stack != null && stack.isVisibleLocked());
}
- public void setDockedStackCreateMode(int mode) {
+ public void setDockedStackCreateState(int mode, Rect bounds) {
synchronized (mWindowMap) {
- sDockedStackCreateMode = mode;
+ mDockedStackCreateMode = mode;
+ mDockedStackCreateBounds = bounds;
}
}