Merge "Update Desktop Mode handle menu position during rotation" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
71ed62114f
@@ -91,6 +91,16 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
|||||||
private Drawable mAppIcon;
|
private Drawable mAppIcon;
|
||||||
private CharSequence mAppName;
|
private CharSequence mAppName;
|
||||||
|
|
||||||
|
private int mMenuWidth;
|
||||||
|
private int mMarginMenuTop;
|
||||||
|
private int mMarginMenuStart;
|
||||||
|
private int mMarginMenuSpacing;
|
||||||
|
private int mAppInfoPillHeight;
|
||||||
|
private int mWindowingPillHeight;
|
||||||
|
private int mMoreActionsPillHeight;
|
||||||
|
private int mShadowRadius;
|
||||||
|
private int mCornerRadius;
|
||||||
|
|
||||||
DesktopModeWindowDecoration(
|
DesktopModeWindowDecoration(
|
||||||
Context context,
|
Context context,
|
||||||
DisplayController displayController,
|
DisplayController displayController,
|
||||||
@@ -107,6 +117,29 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
|||||||
mSyncQueue = syncQueue;
|
mSyncQueue = syncQueue;
|
||||||
|
|
||||||
loadAppInfo();
|
loadAppInfo();
|
||||||
|
loadHandleMenuDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadHandleMenuDimensions() {
|
||||||
|
final Resources resources = mDecorWindowContext.getResources();
|
||||||
|
mMenuWidth = loadDimensionPixelSize(resources,
|
||||||
|
R.dimen.desktop_mode_handle_menu_width);
|
||||||
|
mMarginMenuTop = loadDimensionPixelSize(resources,
|
||||||
|
R.dimen.desktop_mode_handle_menu_margin_top);
|
||||||
|
mMarginMenuStart = loadDimensionPixelSize(resources,
|
||||||
|
R.dimen.desktop_mode_handle_menu_margin_start);
|
||||||
|
mMarginMenuSpacing = loadDimensionPixelSize(resources,
|
||||||
|
R.dimen.desktop_mode_handle_menu_pill_spacing_margin);
|
||||||
|
mAppInfoPillHeight = loadDimensionPixelSize(resources,
|
||||||
|
R.dimen.desktop_mode_handle_menu_app_info_pill_height);
|
||||||
|
mWindowingPillHeight = loadDimensionPixelSize(resources,
|
||||||
|
R.dimen.desktop_mode_handle_menu_windowing_pill_height);
|
||||||
|
mShadowRadius = loadDimensionPixelSize(resources,
|
||||||
|
R.dimen.desktop_mode_handle_menu_shadow_radius);
|
||||||
|
mCornerRadius = loadDimensionPixelSize(resources,
|
||||||
|
R.dimen.desktop_mode_handle_menu_corner_radius);
|
||||||
|
mMoreActionsPillHeight = loadDimensionPixelSize(resources,
|
||||||
|
R.dimen.desktop_mode_handle_menu_more_actions_pill_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -155,6 +188,22 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
|||||||
taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM;
|
taskInfo.getWindowingMode() == WINDOWING_MODE_FREEFORM;
|
||||||
final boolean isDragResizeable = isFreeform && taskInfo.isResizeable;
|
final boolean isDragResizeable = isFreeform && taskInfo.isResizeable;
|
||||||
|
|
||||||
|
if (mHandleMenuAppInfoPill != null) {
|
||||||
|
updateHandleMenuPillPositions();
|
||||||
|
startT.setPosition(mHandleMenuAppInfoPill.mWindowSurface,
|
||||||
|
mHandleMenuAppInfoPillPosition.x, mHandleMenuAppInfoPillPosition.y);
|
||||||
|
|
||||||
|
// Only show windowing buttons in proto2. Proto1 uses a system-level mode only.
|
||||||
|
final boolean shouldShowWindowingPill = DesktopModeStatus.isProto2Enabled();
|
||||||
|
if (shouldShowWindowingPill) {
|
||||||
|
startT.setPosition(mHandleMenuWindowingPill.mWindowSurface,
|
||||||
|
mHandleMenuWindowingPillPosition.x, mHandleMenuWindowingPillPosition.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
startT.setPosition(mHandleMenuMoreActionsPill.mWindowSurface,
|
||||||
|
mHandleMenuMoreActionsPillPosition.x, mHandleMenuMoreActionsPillPosition.y);
|
||||||
|
}
|
||||||
|
|
||||||
final WindowDecorLinearLayout oldRootView = mResult.mRootView;
|
final WindowDecorLinearLayout oldRootView = mResult.mRootView;
|
||||||
final SurfaceControl oldDecorationSurface = mDecorationContainerSurface;
|
final SurfaceControl oldDecorationSurface = mDecorationContainerSurface;
|
||||||
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
final WindowContainerTransaction wct = new WindowContainerTransaction();
|
||||||
@@ -271,64 +320,17 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
|||||||
*/
|
*/
|
||||||
void createHandleMenu() {
|
void createHandleMenu() {
|
||||||
final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
|
final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
|
||||||
final Resources resources = mDecorWindowContext.getResources();
|
updateHandleMenuPillPositions();
|
||||||
final int captionWidth = mTaskInfo.getConfiguration()
|
|
||||||
.windowConfiguration.getBounds().width();
|
|
||||||
final int menuWidth = loadDimensionPixelSize(resources,
|
|
||||||
R.dimen.desktop_mode_handle_menu_width);
|
|
||||||
final int shadowRadius = loadDimensionPixelSize(resources,
|
|
||||||
R.dimen.desktop_mode_handle_menu_shadow_radius);
|
|
||||||
final int cornerRadius = loadDimensionPixelSize(resources,
|
|
||||||
R.dimen.desktop_mode_handle_menu_corner_radius);
|
|
||||||
final int marginMenuTop = loadDimensionPixelSize(resources,
|
|
||||||
R.dimen.desktop_mode_handle_menu_margin_top);
|
|
||||||
final int marginMenuStart = loadDimensionPixelSize(resources,
|
|
||||||
R.dimen.desktop_mode_handle_menu_margin_start);
|
|
||||||
final int marginMenuSpacing = loadDimensionPixelSize(resources,
|
|
||||||
R.dimen.desktop_mode_handle_menu_pill_spacing_margin);
|
|
||||||
final int appInfoPillHeight = loadDimensionPixelSize(resources,
|
|
||||||
R.dimen.desktop_mode_handle_menu_app_info_pill_height);
|
|
||||||
final int windowingPillHeight = loadDimensionPixelSize(resources,
|
|
||||||
R.dimen.desktop_mode_handle_menu_windowing_pill_height);
|
|
||||||
final int moreActionsPillHeight = loadDimensionPixelSize(resources,
|
|
||||||
R.dimen.desktop_mode_handle_menu_more_actions_pill_height);
|
|
||||||
|
|
||||||
final int menuX, menuY;
|
createAppInfoPill(t);
|
||||||
if (mRelayoutParams.mLayoutResId
|
|
||||||
== R.layout.desktop_mode_app_controls_window_decor) {
|
|
||||||
// Align the handle menu to the left of the caption.
|
|
||||||
menuX = mRelayoutParams.mCaptionX - mResult.mDecorContainerOffsetX + marginMenuStart;
|
|
||||||
menuY = mRelayoutParams.mCaptionY - mResult.mDecorContainerOffsetY + marginMenuTop;
|
|
||||||
} else {
|
|
||||||
// Position the handle menu at the center of the caption.
|
|
||||||
menuX = mRelayoutParams.mCaptionX + (captionWidth / 2) - (menuWidth / 2)
|
|
||||||
- mResult.mDecorContainerOffsetX;
|
|
||||||
menuY = mRelayoutParams.mCaptionY - mResult.mDecorContainerOffsetY + marginMenuStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int appInfoPillY = menuY;
|
|
||||||
createAppInfoPill(t, menuX, appInfoPillY, menuWidth, appInfoPillHeight, shadowRadius,
|
|
||||||
cornerRadius);
|
|
||||||
|
|
||||||
// Only show windowing buttons in proto2. Proto1 uses a system-level mode only.
|
// Only show windowing buttons in proto2. Proto1 uses a system-level mode only.
|
||||||
final boolean shouldShowWindowingPill = DesktopModeStatus.isProto2Enabled();
|
final boolean shouldShowWindowingPill = DesktopModeStatus.isProto2Enabled();
|
||||||
final int windowingPillY = appInfoPillY + appInfoPillHeight + marginMenuSpacing;
|
|
||||||
if (shouldShowWindowingPill) {
|
if (shouldShowWindowingPill) {
|
||||||
createWindowingPill(t, menuX, windowingPillY, menuWidth, windowingPillHeight,
|
createWindowingPill(t);
|
||||||
shadowRadius,
|
|
||||||
cornerRadius);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final int moreActionsPillY;
|
createMoreActionsPill(t);
|
||||||
if (shouldShowWindowingPill) {
|
|
||||||
// Take into account the windowing pill height and margins.
|
|
||||||
moreActionsPillY = windowingPillY + windowingPillHeight + marginMenuSpacing;
|
|
||||||
} else {
|
|
||||||
// Just start after the end of the app info pill + margins.
|
|
||||||
moreActionsPillY = appInfoPillY + appInfoPillHeight + marginMenuSpacing;
|
|
||||||
}
|
|
||||||
createMoreActionsPill(t, menuX, moreActionsPillY, menuWidth, moreActionsPillHeight,
|
|
||||||
shadowRadius, cornerRadius);
|
|
||||||
|
|
||||||
mSyncQueue.runInSync(transaction -> {
|
mSyncQueue.runInSync(transaction -> {
|
||||||
transaction.merge(t);
|
transaction.merge(t);
|
||||||
@@ -337,31 +339,31 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
|||||||
setupHandleMenu(shouldShowWindowingPill);
|
setupHandleMenu(shouldShowWindowingPill);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createAppInfoPill(SurfaceControl.Transaction t, int x, int y, int width,
|
private void createAppInfoPill(SurfaceControl.Transaction t) {
|
||||||
int height, int shadowRadius, int cornerRadius) {
|
final int x = (int) mHandleMenuAppInfoPillPosition.x;
|
||||||
mHandleMenuAppInfoPillPosition.set(x, y);
|
final int y = (int) mHandleMenuAppInfoPillPosition.y;
|
||||||
mHandleMenuAppInfoPill = addWindow(
|
mHandleMenuAppInfoPill = addWindow(
|
||||||
R.layout.desktop_mode_window_decor_handle_menu_app_info_pill,
|
R.layout.desktop_mode_window_decor_handle_menu_app_info_pill,
|
||||||
"Menu's app info pill",
|
"Menu's app info pill",
|
||||||
t, x, y, width, height, shadowRadius, cornerRadius);
|
t, x, y, mMenuWidth, mAppInfoPillHeight, mShadowRadius, mCornerRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createWindowingPill(SurfaceControl.Transaction t, int x, int y, int width,
|
private void createWindowingPill(SurfaceControl.Transaction t) {
|
||||||
int height, int shadowRadius, int cornerRadius) {
|
final int x = (int) mHandleMenuWindowingPillPosition.x;
|
||||||
mHandleMenuWindowingPillPosition.set(x, y);
|
final int y = (int) mHandleMenuWindowingPillPosition.y;
|
||||||
mHandleMenuWindowingPill = addWindow(
|
mHandleMenuWindowingPill = addWindow(
|
||||||
R.layout.desktop_mode_window_decor_handle_menu_windowing_pill,
|
R.layout.desktop_mode_window_decor_handle_menu_windowing_pill,
|
||||||
"Menu's windowing pill",
|
"Menu's windowing pill",
|
||||||
t, x, y, width, height, shadowRadius, cornerRadius);
|
t, x, y, mMenuWidth, mWindowingPillHeight, mShadowRadius, mCornerRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createMoreActionsPill(SurfaceControl.Transaction t, int x, int y, int width,
|
private void createMoreActionsPill(SurfaceControl.Transaction t) {
|
||||||
int height, int shadowRadius, int cornerRadius) {
|
final int x = (int) mHandleMenuMoreActionsPillPosition.x;
|
||||||
mHandleMenuMoreActionsPillPosition.set(x, y);
|
final int y = (int) mHandleMenuMoreActionsPillPosition.y;
|
||||||
mHandleMenuMoreActionsPill = addWindow(
|
mHandleMenuMoreActionsPill = addWindow(
|
||||||
R.layout.desktop_mode_window_decor_handle_menu_more_actions_pill,
|
R.layout.desktop_mode_window_decor_handle_menu_more_actions_pill,
|
||||||
"Menu's more actions pill",
|
"Menu's more actions pill",
|
||||||
t, x, y, width, height, shadowRadius, cornerRadius);
|
t, x, y, mMenuWidth, mMoreActionsPillHeight, mShadowRadius, mCornerRadius);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupHandleMenu(boolean windowingPillShown) {
|
private void setupHandleMenu(boolean windowingPillShown) {
|
||||||
@@ -412,6 +414,45 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
|||||||
closeBtn.setOnClickListener(mOnCaptionButtonClickListener);
|
closeBtn.setOnClickListener(mOnCaptionButtonClickListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the handle menu pills' position variables to reflect their next positions
|
||||||
|
*/
|
||||||
|
private void updateHandleMenuPillPositions() {
|
||||||
|
final int menuX, menuY;
|
||||||
|
final int captionWidth = mTaskInfo.getConfiguration()
|
||||||
|
.windowConfiguration.getBounds().width();
|
||||||
|
if (mRelayoutParams.mLayoutResId
|
||||||
|
== R.layout.desktop_mode_app_controls_window_decor) {
|
||||||
|
// Align the handle menu to the left of the caption.
|
||||||
|
menuX = mRelayoutParams.mCaptionX - mResult.mDecorContainerOffsetX + mMarginMenuStart;
|
||||||
|
menuY = mRelayoutParams.mCaptionY - mResult.mDecorContainerOffsetY + mMarginMenuTop;
|
||||||
|
} else {
|
||||||
|
// Position the handle menu at the center of the caption.
|
||||||
|
menuX = mRelayoutParams.mCaptionX + (captionWidth / 2) - (mMenuWidth / 2)
|
||||||
|
- mResult.mDecorContainerOffsetX;
|
||||||
|
menuY = mRelayoutParams.mCaptionY - mResult.mDecorContainerOffsetY + mMarginMenuStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
// App Info pill setup.
|
||||||
|
final int appInfoPillY = menuY;
|
||||||
|
mHandleMenuAppInfoPillPosition.set(menuX, appInfoPillY);
|
||||||
|
|
||||||
|
// Only show windowing buttons in proto2. Proto1 uses a system-level mode only.
|
||||||
|
final boolean shouldShowWindowingPill = DesktopModeStatus.isProto2Enabled();
|
||||||
|
|
||||||
|
final int windowingPillY, moreActionsPillY;
|
||||||
|
if (shouldShowWindowingPill) {
|
||||||
|
windowingPillY = appInfoPillY + mAppInfoPillHeight + mMarginMenuSpacing;
|
||||||
|
mHandleMenuWindowingPillPosition.set(menuX, windowingPillY);
|
||||||
|
moreActionsPillY = windowingPillY + mWindowingPillHeight + mMarginMenuSpacing;
|
||||||
|
mHandleMenuMoreActionsPillPosition.set(menuX, moreActionsPillY);
|
||||||
|
} else {
|
||||||
|
// Just start after the end of the app info pill + margins.
|
||||||
|
moreActionsPillY = appInfoPillY + mAppInfoPillHeight + mMarginMenuSpacing;
|
||||||
|
mHandleMenuMoreActionsPillPosition.set(menuX, moreActionsPillY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close the handle menu window
|
* Close the handle menu window
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user