Merge "Exit desktop mode on dragging a task to the top of the screen." into tm-qpr-dev
This commit is contained in:
@@ -188,14 +188,16 @@ public abstract class WMShellModule {
|
||||
@ShellMainThread Choreographer mainChoreographer,
|
||||
ShellTaskOrganizer taskOrganizer,
|
||||
DisplayController displayController,
|
||||
SyncTransactionQueue syncQueue) {
|
||||
SyncTransactionQueue syncQueue,
|
||||
@DynamicOverride DesktopModeController desktopModeController) {
|
||||
return new CaptionWindowDecorViewModel(
|
||||
context,
|
||||
mainHandler,
|
||||
mainChoreographer,
|
||||
taskOrganizer,
|
||||
displayController,
|
||||
syncQueue);
|
||||
syncQueue,
|
||||
desktopModeController);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -176,6 +176,25 @@ public class DesktopModeController implements RemoteCallable<DesktopModeControll
|
||||
mShellTaskOrganizer.applyTransaction(wct);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn desktop mode on or off
|
||||
* @param active the desired state for desktop mode setting
|
||||
*/
|
||||
public void setDesktopModeActive(boolean active) {
|
||||
int value = active ? 1 : 0;
|
||||
Settings.System.putInt(mContext.getContentResolver(), Settings.System.DESKTOP_MODE, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the windowing mode of the display area with the specified displayId.
|
||||
* @param displayId
|
||||
* @return
|
||||
*/
|
||||
public int getDisplayAreaWindowingMode(int displayId) {
|
||||
return mRootTaskDisplayAreaOrganizer.getDisplayAreaInfo(displayId)
|
||||
.configuration.windowConfiguration.getWindowingMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* A {@link ContentObserver} for listening to changes to {@link Settings.System#DESKTOP_MODE}
|
||||
*/
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.android.wm.shell.R;
|
||||
import com.android.wm.shell.ShellTaskOrganizer;
|
||||
import com.android.wm.shell.common.DisplayController;
|
||||
import com.android.wm.shell.common.SyncTransactionQueue;
|
||||
import com.android.wm.shell.desktopmode.DesktopModeController;
|
||||
import com.android.wm.shell.desktopmode.DesktopModeStatus;
|
||||
import com.android.wm.shell.freeform.FreeformTaskTransitionStarter;
|
||||
import com.android.wm.shell.transition.Transitions;
|
||||
@@ -54,6 +55,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel<Caption
|
||||
private final DisplayController mDisplayController;
|
||||
private final SyncTransactionQueue mSyncQueue;
|
||||
private FreeformTaskTransitionStarter mTransitionStarter;
|
||||
private DesktopModeController mDesktopModeController;
|
||||
|
||||
public CaptionWindowDecorViewModel(
|
||||
Context context,
|
||||
@@ -61,7 +63,8 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel<Caption
|
||||
Choreographer mainChoreographer,
|
||||
ShellTaskOrganizer taskOrganizer,
|
||||
DisplayController displayController,
|
||||
SyncTransactionQueue syncQueue) {
|
||||
SyncTransactionQueue syncQueue,
|
||||
DesktopModeController desktopModeController) {
|
||||
mContext = context;
|
||||
mMainHandler = mainHandler;
|
||||
mMainChoreographer = mainChoreographer;
|
||||
@@ -69,6 +72,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel<Caption
|
||||
mTaskOrganizer = taskOrganizer;
|
||||
mDisplayController = displayController;
|
||||
mSyncQueue = syncQueue;
|
||||
mDesktopModeController = desktopModeController;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -211,8 +215,10 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel<Caption
|
||||
}
|
||||
|
||||
private void handleEventForMove(MotionEvent e) {
|
||||
if (mTaskOrganizer.getRunningTaskInfo(mTaskId).getWindowingMode()
|
||||
== WINDOWING_MODE_FULLSCREEN) {
|
||||
RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId);
|
||||
int windowingMode = mDesktopModeController
|
||||
.getDisplayAreaWindowingMode(taskInfo.displayId);
|
||||
if (windowingMode == WINDOWING_MODE_FULLSCREEN) {
|
||||
return;
|
||||
}
|
||||
switch (e.getActionMasked()) {
|
||||
@@ -230,8 +236,14 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel<Caption
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL: {
|
||||
int dragPointerIdx = e.findPointerIndex(mDragPointerId);
|
||||
int statusBarHeight = mDisplayController.getDisplayLayout(taskInfo.displayId)
|
||||
.stableInsets().top;
|
||||
mDragResizeCallback.onDragResizeEnd(
|
||||
e.getRawX(dragPointerIdx), e.getRawY(dragPointerIdx));
|
||||
if (e.getRawY(dragPointerIdx) <= statusBarHeight
|
||||
&& windowingMode == WINDOWING_MODE_FREEFORM) {
|
||||
mDesktopModeController.setDesktopModeActive(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user