Update captions to full-width.
Updates captions to the new full-width spec, adjusts interactivity through status bar to account for the new spec. Bug: 265203860 Test: manual testing, confirm all caption functionality is unchanged. atest WindowDecorationTests Change-Id: Ia0f8341a3714ab6c948729ac3123698a8ee00e5d
This commit is contained in:
@@ -17,5 +17,4 @@
|
||||
<shape android:shape="rectangle"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@android:color/white" />
|
||||
<corners android:radius="20dp" />
|
||||
</shape>
|
||||
|
||||
@@ -17,26 +17,14 @@
|
||||
<com.android.wm.shell.windowdecor.WindowDecorLinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/desktop_mode_caption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:background="@drawable/desktop_mode_decor_title">
|
||||
<Button
|
||||
style="@style/CaptionButtonStyle"
|
||||
android:id="@+id/back_button"
|
||||
android:contentDescription="@string/back_button_text"
|
||||
android:background="@drawable/decor_back_button_dark"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/caption_handle"
|
||||
android:layout_width="128dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_margin="5dp"
|
||||
android:padding="4dp"
|
||||
android:contentDescription="@string/handle_text"
|
||||
android:background="@drawable/decor_handle_dark"/>
|
||||
<Button
|
||||
style="@style/CaptionButtonStyle"
|
||||
android:id="@+id/close_window"
|
||||
android:contentDescription="@string/close_button_text"
|
||||
android:background="@drawable/decor_close_button_dark"/>
|
||||
</com.android.wm.shell.windowdecor.WindowDecorLinearLayout>
|
||||
@@ -331,8 +331,8 @@
|
||||
<!-- Height of button (32dp) + 2 * margin (5dp each). -->
|
||||
<dimen name="freeform_decor_caption_height">42dp</dimen>
|
||||
|
||||
<!-- Width of buttons (64dp) + handle (128dp) + padding (24dp total). -->
|
||||
<dimen name="freeform_decor_caption_width">216dp</dimen>
|
||||
<!-- Width of buttons (32dp each) + padding (128dp total). -->
|
||||
<dimen name="freeform_decor_caption_menu_width">256dp</dimen>
|
||||
|
||||
<dimen name="freeform_resize_handle">30dp</dimen>
|
||||
|
||||
|
||||
@@ -228,11 +228,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
|
||||
public void onClick(View v) {
|
||||
final DesktopModeWindowDecoration decoration = mWindowDecorByTaskId.get(mTaskId);
|
||||
final int id = v.getId();
|
||||
if (id == R.id.close_window) {
|
||||
mTaskOperations.closeTask(mTaskToken);
|
||||
} else if (id == R.id.back_button) {
|
||||
mTaskOperations.injectBackKey();
|
||||
} else if (id == R.id.caption_handle) {
|
||||
if (id == R.id.caption_handle) {
|
||||
decoration.createHandleMenu();
|
||||
} else if (id == R.id.desktop_button) {
|
||||
mDesktopModeController.ifPresent(c -> c.setDesktopModeActive(true));
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.VectorDrawable;
|
||||
import android.os.Handler;
|
||||
import android.view.Choreographer;
|
||||
@@ -60,6 +59,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
||||
private final DragDetector mDragDetector;
|
||||
|
||||
private RelayoutParams mRelayoutParams = new RelayoutParams();
|
||||
private final int mCaptionMenuWidthId = R.dimen.freeform_decor_caption_menu_width;
|
||||
private final WindowDecoration.RelayoutResult<WindowDecorLinearLayout> mResult =
|
||||
new WindowDecoration.RelayoutResult<>();
|
||||
|
||||
@@ -131,22 +131,10 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
||||
mRelayoutParams.mRunningTaskInfo = taskInfo;
|
||||
mRelayoutParams.mLayoutResId = R.layout.desktop_mode_window_decor;
|
||||
mRelayoutParams.mCaptionHeightId = R.dimen.freeform_decor_caption_height;
|
||||
mRelayoutParams.mCaptionWidthId = R.dimen.freeform_decor_caption_width;
|
||||
mRelayoutParams.mShadowRadiusId = shadowRadiusID;
|
||||
if (isDragResizeable) {
|
||||
mRelayoutParams.setOutsets(outsetLeftId, outsetTopId, outsetRightId, outsetBottomId);
|
||||
}
|
||||
final Resources resources = mDecorWindowContext.getResources();
|
||||
final Rect taskBounds = taskInfo.configuration.windowConfiguration.getBounds();
|
||||
final int captionHeight = loadDimensionPixelSize(resources,
|
||||
mRelayoutParams.mCaptionHeightId);
|
||||
final int captionWidth = loadDimensionPixelSize(resources,
|
||||
mRelayoutParams.mCaptionWidthId);
|
||||
final int captionLeft = taskBounds.width() / 2
|
||||
- captionWidth / 2;
|
||||
final int captionTop = taskBounds.top
|
||||
<= captionHeight / 2 ? 0 : -captionHeight / 2;
|
||||
mRelayoutParams.setCaptionPosition(captionLeft, captionTop);
|
||||
|
||||
relayout(mRelayoutParams, startT, finishT, wct, oldRootView, mResult);
|
||||
// After this line, mTaskInfo is up-to-date and should be used instead of taskInfo
|
||||
@@ -212,10 +200,6 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
||||
private void setupRootView() {
|
||||
final View caption = mResult.mRootView.findViewById(R.id.desktop_mode_caption);
|
||||
caption.setOnTouchListener(mOnCaptionTouchListener);
|
||||
final View close = caption.findViewById(R.id.close_window);
|
||||
close.setOnClickListener(mOnCaptionButtonClickListener);
|
||||
final View back = caption.findViewById(R.id.back_button);
|
||||
back.setOnClickListener(mOnCaptionButtonClickListener);
|
||||
final View handle = caption.findViewById(R.id.caption_handle);
|
||||
handle.setOnTouchListener(mOnCaptionTouchListener);
|
||||
handle.setOnClickListener(mOnCaptionButtonClickListener);
|
||||
@@ -230,8 +214,6 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
||||
desktop.setOnClickListener(mOnCaptionButtonClickListener);
|
||||
final View split = menu.findViewById(R.id.split_screen_button);
|
||||
split.setOnClickListener(mOnCaptionButtonClickListener);
|
||||
final View more = menu.findViewById(R.id.more_button);
|
||||
more.setOnClickListener(mOnCaptionButtonClickListener);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -264,10 +246,6 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
||||
void setButtonVisibility(boolean visible) {
|
||||
final int visibility = visible ? View.VISIBLE : View.GONE;
|
||||
final View caption = mResult.mRootView.findViewById(R.id.desktop_mode_caption);
|
||||
final View back = caption.findViewById(R.id.back_button);
|
||||
final View close = caption.findViewById(R.id.close_window);
|
||||
back.setVisibility(visibility);
|
||||
close.setVisibility(visibility);
|
||||
final int buttonTintColorRes =
|
||||
mDesktopActive ? R.color.decor_button_dark_color
|
||||
: R.color.decor_button_light_color;
|
||||
@@ -297,14 +275,18 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
||||
void createHandleMenu() {
|
||||
final SurfaceControl.Transaction t = new SurfaceControl.Transaction();
|
||||
final Resources resources = mDecorWindowContext.getResources();
|
||||
final int x = mRelayoutParams.mCaptionX;
|
||||
final int y = mRelayoutParams.mCaptionY;
|
||||
final int width = loadDimensionPixelSize(resources, mRelayoutParams.mCaptionWidthId);
|
||||
final int height = loadDimensionPixelSize(resources, mRelayoutParams.mCaptionHeightId);
|
||||
final int captionWidth = mTaskInfo.getConfiguration()
|
||||
.windowConfiguration.getBounds().width();
|
||||
final int menuWidth = loadDimensionPixelSize(
|
||||
resources, mCaptionMenuWidthId);
|
||||
final int height = loadDimensionPixelSize(
|
||||
resources, mRelayoutParams.mCaptionHeightId);
|
||||
final int x = mRelayoutParams.mCaptionX + (captionWidth / 2) - (menuWidth / 2)
|
||||
- mResult.mDecorContainerOffsetX;
|
||||
final int y = mRelayoutParams.mCaptionY - mResult.mDecorContainerOffsetY;
|
||||
String namePrefix = "Caption Menu";
|
||||
mHandleMenu = addWindow(R.layout.desktop_mode_decor_handle_menu, namePrefix, t,
|
||||
x - mResult.mDecorContainerOffsetX, y - mResult.mDecorContainerOffsetY,
|
||||
width, height);
|
||||
mHandleMenu = addWindow(R.layout.desktop_mode_decor_handle_menu, namePrefix, t, x, y,
|
||||
menuWidth, height);
|
||||
mSyncQueue.runInSync(transaction -> {
|
||||
transaction.merge(t);
|
||||
t.close();
|
||||
@@ -370,7 +352,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
||||
if (mResult.mRootView == null) return false;
|
||||
final PointF inputPoint = offsetCaptionLocation(ev);
|
||||
final View view = mResult.mRootView.findViewById(layoutId);
|
||||
return view != null && view.pointInView(inputPoint.x, inputPoint.y, 0);
|
||||
return view != null && pointInView(view, inputPoint.x, inputPoint.y);
|
||||
}
|
||||
|
||||
boolean checkTouchEventInHandle(MotionEvent ev) {
|
||||
@@ -387,32 +369,39 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
||||
*/
|
||||
void checkClickEvent(MotionEvent ev) {
|
||||
if (mResult.mRootView == null) return;
|
||||
final View caption = mResult.mRootView.findViewById(R.id.desktop_mode_caption);
|
||||
final PointF inputPoint = offsetCaptionLocation(ev);
|
||||
if (!isHandleMenuActive()) {
|
||||
final View caption = mResult.mRootView.findViewById(R.id.desktop_mode_caption);
|
||||
final View handle = caption.findViewById(R.id.caption_handle);
|
||||
clickIfPointInView(inputPoint, handle);
|
||||
clickIfPointInView(new PointF(ev.getX(), ev.getY()), handle);
|
||||
} else {
|
||||
final View menu = mHandleMenu.mWindowViewHost.getView();
|
||||
final int captionWidth = mTaskInfo.getConfiguration().windowConfiguration
|
||||
.getBounds().width();
|
||||
final int menuX = mRelayoutParams.mCaptionX + (captionWidth / 2)
|
||||
- (menu.getWidth() / 2);
|
||||
final PointF inputPoint = new PointF(ev.getX() - menuX, ev.getY());
|
||||
final View fullscreen = menu.findViewById(R.id.fullscreen_button);
|
||||
if (clickIfPointInView(inputPoint, fullscreen)) return;
|
||||
final View desktop = menu.findViewById(R.id.desktop_button);
|
||||
if (clickIfPointInView(inputPoint, desktop)) return;
|
||||
final View split = menu.findViewById(R.id.split_screen_button);
|
||||
if (clickIfPointInView(inputPoint, split)) return;
|
||||
final View more = menu.findViewById(R.id.more_button);
|
||||
clickIfPointInView(inputPoint, more);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean clickIfPointInView(PointF inputPoint, View v) {
|
||||
if (v.pointInView(inputPoint.x - v.getLeft(), inputPoint.y, 0)) {
|
||||
if (pointInView(v, inputPoint.x, inputPoint.y)) {
|
||||
mOnCaptionButtonClickListener.onClick(v);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean pointInView(View v, float x, float y) {
|
||||
return v != null && v.getLeft() <= x && v.getRight() >= x
|
||||
&& v.getTop() <= y && v.getBottom() >= y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
closeDragResizeListener();
|
||||
|
||||
@@ -252,9 +252,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
|
||||
}
|
||||
|
||||
final int captionHeight = loadDimensionPixelSize(resources, params.mCaptionHeightId);
|
||||
final int captionWidth = params.mCaptionWidthId == Resources.ID_NULL
|
||||
? taskBounds.width()
|
||||
: loadDimensionPixelSize(resources, params.mCaptionWidthId);
|
||||
final int captionWidth = taskBounds.width();
|
||||
|
||||
startT.setPosition(
|
||||
mCaptionContainerSurface,
|
||||
@@ -428,7 +426,6 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
|
||||
RunningTaskInfo mRunningTaskInfo;
|
||||
int mLayoutResId;
|
||||
int mCaptionHeightId;
|
||||
int mCaptionWidthId;
|
||||
int mShadowRadiusId;
|
||||
|
||||
int mOutsetTopId;
|
||||
@@ -454,7 +451,6 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
|
||||
void reset() {
|
||||
mLayoutResId = Resources.ID_NULL;
|
||||
mCaptionHeightId = Resources.ID_NULL;
|
||||
mCaptionWidthId = Resources.ID_NULL;
|
||||
mShadowRadiusId = Resources.ID_NULL;
|
||||
|
||||
mOutsetTopId = Resources.ID_NULL;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<resources>
|
||||
<!-- Resources used in WindowDecorationTests -->
|
||||
<dimen name="test_freeform_decor_caption_height">32dp</dimen>
|
||||
<dimen name="test_freeform_decor_caption_width">216dp</dimen>
|
||||
<dimen name="test_freeform_decor_caption_menu_width">216dp</dimen>
|
||||
<dimen name="test_window_decor_left_outset">10dp</dimen>
|
||||
<dimen name="test_window_decor_top_outset">20dp</dimen>
|
||||
<dimen name="test_window_decor_right_outset">30dp</dimen>
|
||||
|
||||
@@ -107,6 +107,7 @@ public class WindowDecorationTests extends ShellTestCase {
|
||||
private SurfaceControl.Transaction mMockSurfaceControlFinishT;
|
||||
private SurfaceControl.Transaction mMockSurfaceControlAddWindowT;
|
||||
private WindowDecoration.RelayoutParams mRelayoutParams = new WindowDecoration.RelayoutParams();
|
||||
private int mCaptionMenuWidthId;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -116,8 +117,7 @@ public class WindowDecorationTests extends ShellTestCase {
|
||||
|
||||
mRelayoutParams.mLayoutResId = 0;
|
||||
mRelayoutParams.mCaptionHeightId = R.dimen.test_freeform_decor_caption_height;
|
||||
// Caption should have fixed width except in testLayoutResultCalculation_fullWidthCaption()
|
||||
mRelayoutParams.mCaptionWidthId = R.dimen.test_freeform_decor_caption_width;
|
||||
mCaptionMenuWidthId = R.dimen.test_freeform_decor_caption_menu_width;
|
||||
mRelayoutParams.mShadowRadiusId = R.dimen.test_window_decor_shadow_radius;
|
||||
|
||||
doReturn(mMockSurfaceControlViewHost).when(mMockSurfaceControlViewHostFactory)
|
||||
@@ -240,7 +240,7 @@ public class WindowDecorationTests extends ShellTestCase {
|
||||
verify(captionContainerSurfaceBuilder).setParent(decorContainerSurface);
|
||||
verify(captionContainerSurfaceBuilder).setContainerLayer();
|
||||
verify(mMockSurfaceControlStartT).setPosition(captionContainerSurface, 20, 40);
|
||||
verify(mMockSurfaceControlStartT).setWindowCrop(captionContainerSurface, 432, 64);
|
||||
verify(mMockSurfaceControlStartT).setWindowCrop(captionContainerSurface, 300, 64);
|
||||
verify(mMockSurfaceControlStartT).show(captionContainerSurface);
|
||||
|
||||
verify(mMockSurfaceControlViewHostFactory).create(any(), eq(defaultDisplay), any());
|
||||
@@ -248,7 +248,7 @@ public class WindowDecorationTests extends ShellTestCase {
|
||||
verify(mMockSurfaceControlViewHost)
|
||||
.setView(same(mMockView),
|
||||
argThat(lp -> lp.height == 64
|
||||
&& lp.width == 432
|
||||
&& lp.width == 300
|
||||
&& (lp.flags & LayoutParams.FLAG_NOT_FOCUSABLE) != 0));
|
||||
if (ViewRootImpl.CAPTION_ON_SHELL) {
|
||||
verify(mMockView).setTaskFocusState(true);
|
||||
@@ -484,7 +484,6 @@ public class WindowDecorationTests extends ShellTestCase {
|
||||
final SurfaceControl taskSurface = mock(SurfaceControl.class);
|
||||
final TestWindowDecoration windowDecor = createWindowDecoration(taskInfo, taskSurface);
|
||||
|
||||
mRelayoutParams.mCaptionWidthId = Resources.ID_NULL;
|
||||
windowDecor.relayout(taskInfo);
|
||||
|
||||
verify(captionContainerSurfaceBuilder).setParent(decorContainerSurface);
|
||||
@@ -558,7 +557,7 @@ public class WindowDecorationTests extends ShellTestCase {
|
||||
final Resources resources = mDecorWindowContext.getResources();
|
||||
int x = mRelayoutParams.mCaptionX;
|
||||
int y = mRelayoutParams.mCaptionY;
|
||||
int width = loadDimensionPixelSize(resources, mRelayoutParams.mCaptionWidthId);
|
||||
int width = loadDimensionPixelSize(resources, mCaptionMenuWidthId);
|
||||
int height = loadDimensionPixelSize(resources, mRelayoutParams.mCaptionHeightId);
|
||||
String name = "Test Window";
|
||||
WindowDecoration.AdditionalWindow additionalWindow =
|
||||
|
||||
Reference in New Issue
Block a user