diff options
Diffstat (limited to 'libs')
11 files changed, 185 insertions, 114 deletions
diff --git a/libs/WindowManager/Shell/res/drawable/decor_back_button_dark.xml b/libs/WindowManager/Shell/res/drawable/decor_back_button_dark.xml new file mode 100644 index 000000000000..66e5b43d76af --- /dev/null +++ b/libs/WindowManager/Shell/res/drawable/decor_back_button_dark.xml @@ -0,0 +1,32 @@ +<!-- + ~ Copyright (C) 2022 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. + --> + +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="32.0dp" + android:height="32.0dp" + android:viewportWidth="32.0" + android:viewportHeight="32.0" + > + <group android:scaleX="0.5" + android:scaleY="0.5" + android:translateX="8.0" + android:translateY="8.0" > + <path + android:fillColor="@android:color/black" + android:pathData="MM24,40.3 L7.7,24 24,7.7 26.8,10.45 15.3,22H40.3V26H15.3L26.8,37.5Z"/> + + </group> +</vector>
\ No newline at end of file diff --git a/libs/WindowManager/Shell/res/drawable/decor_caption_title.xml b/libs/WindowManager/Shell/res/drawable/decor_caption_title.xml index 8207365a737d..53a8bb18537c 100644 --- a/libs/WindowManager/Shell/res/drawable/decor_caption_title.xml +++ b/libs/WindowManager/Shell/res/drawable/decor_caption_title.xml @@ -15,8 +15,6 @@ ~ limitations under the License. --> <shape android:shape="rectangle" - android:tintMode="multiply" - android:tint="@color/decor_caption_title_color" xmlns:android="http://schemas.android.com/apk/res/android"> - <solid android:color="?android:attr/colorPrimary" /> + <solid android:color="@android:color/white" /> </shape> diff --git a/libs/WindowManager/Shell/res/drawable/decor_close_button_dark.xml b/libs/WindowManager/Shell/res/drawable/decor_close_button_dark.xml index f2f1a1d55dee..851cbf26afc3 100644 --- a/libs/WindowManager/Shell/res/drawable/decor_close_button_dark.xml +++ b/libs/WindowManager/Shell/res/drawable/decor_close_button_dark.xml @@ -18,15 +18,13 @@ android:width="32.0dp" android:height="32.0dp" android:viewportWidth="32.0" - android:viewportHeight="32.0" - android:tint="@color/decor_button_dark_color" - > + android:viewportHeight="32.0"> <group android:scaleX="0.5" android:scaleY="0.5" android:translateX="8.0" android:translateY="8.0" > <path - android:fillColor="@android:color/white" - android:pathData="M6.9,4.0l-2.9,2.9 9.1,9.1 -9.1,9.200001 2.9,2.799999 9.1,-9.1 9.1,9.1 2.9,-2.799999 -9.1,-9.200001 9.1,-9.1 -2.9,-2.9 -9.1,9.2z"/> + android:fillColor="@android:color/black" + android:pathData="M12.45,38.35 L9.65,35.55 21.2,24 9.65,12.45 12.45,9.65 24,21.2 35.55,9.65 38.35,12.45 26.8,24 38.35,35.55 35.55,38.35 24,26.8Z"/> </group> </vector> diff --git a/libs/WindowManager/Shell/res/drawable/decor_handle_dark.xml b/libs/WindowManager/Shell/res/drawable/decor_handle_dark.xml new file mode 100644 index 000000000000..ee0f4663c940 --- /dev/null +++ b/libs/WindowManager/Shell/res/drawable/decor_handle_dark.xml @@ -0,0 +1,23 @@ +<!-- + ~ Copyright (C) 2022 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. + --> +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="24" + android:viewportHeight="24"> + <path + android:fillColor="@android:color/black" android:pathData="M3,5V3H21V5Z"/> +</vector> diff --git a/libs/WindowManager/Shell/res/layout/caption_window_decoration.xml b/libs/WindowManager/Shell/res/layout/caption_window_decoration.xml index d183e42c173b..38cd5702f134 100644 --- a/libs/WindowManager/Shell/res/layout/caption_window_decoration.xml +++ b/libs/WindowManager/Shell/res/layout/caption_window_decoration.xml @@ -17,39 +17,33 @@ <com.android.wm.shell.windowdecor.WindowDecorLinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/caption" - android:layout_width="match_parent" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:gravity="end" + android:gravity="center_horizontal" android:background="@drawable/decor_caption_title"> <Button - android:id="@+id/minimize_window" - android:visibility="gone" + android:id="@+id/back_button" android:layout_width="32dp" android:layout_height="32dp" android:layout_margin="5dp" android:padding="4dp" - android:layout_gravity="top|end" - android:contentDescription="@string/maximize_button_text" - android:background="@drawable/decor_minimize_button_dark" - android:duplicateParentState="true"/> + android:contentDescription="@string/back_button_text" + android:background="@drawable/decor_back_button_dark" + /> <Button - android:id="@+id/maximize_window" - android:layout_width="32dp" + android:id="@+id/caption_handle" + android:layout_width="128dp" android:layout_height="32dp" android:layout_margin="5dp" android:padding="4dp" - android:layout_gravity="center_vertical|end" - android:contentDescription="@string/maximize_button_text" - android:background="@drawable/decor_maximize_button_dark" - android:duplicateParentState="true"/> + android:contentDescription="@string/handle_text" + android:background="@drawable/decor_handle_dark"/> <Button android:id="@+id/close_window" android:layout_width="32dp" android:layout_height="32dp" android:layout_margin="5dp" android:padding="4dp" - android:layout_gravity="center_vertical|end" android:contentDescription="@string/close_button_text" - android:background="@drawable/decor_close_button_dark" - android:duplicateParentState="true"/> -</com.android.wm.shell.windowdecor.WindowDecorLinearLayout> + android:background="@drawable/decor_close_button_dark"/> +</com.android.wm.shell.windowdecor.WindowDecorLinearLayout>
\ No newline at end of file diff --git a/libs/WindowManager/Shell/res/values/strings.xml b/libs/WindowManager/Shell/res/values/strings.xml index b48a508fddb8..4807f08b4bed 100644 --- a/libs/WindowManager/Shell/res/values/strings.xml +++ b/libs/WindowManager/Shell/res/values/strings.xml @@ -198,4 +198,8 @@ <string name="minimize_button_text">Minimize</string> <!-- Accessibility text for the close window button [CHAR LIMIT=NONE] --> <string name="close_button_text">Close</string> + <!-- Accessibility text for the caption back button [CHAR LIMIT=NONE] --> + <string name="back_button_text">Back</string> + <!-- Accessibility text for the caption handle [CHAR LIMIT=NONE] --> + <string name="handle_text">Handle</string> </resources> diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java index 1ec98d3e94f3..f1670cd792cf 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java @@ -191,13 +191,13 @@ public abstract class WMShellModule { SyncTransactionQueue syncQueue, @DynamicOverride DesktopModeController desktopModeController) { return new CaptionWindowDecorViewModel( - context, - mainHandler, - mainChoreographer, - taskOrganizer, - displayController, - syncQueue, - desktopModeController); + context, + mainHandler, + mainChoreographer, + taskOrganizer, + displayController, + syncQueue, + desktopModeController); } // diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java index 3df33f346e84..dca516a327b0 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecorViewModel.java @@ -19,15 +19,20 @@ package com.android.wm.shell.windowdecor; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; -import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import android.app.ActivityManager; import android.app.ActivityManager.RunningTaskInfo; import android.app.ActivityTaskManager; import android.content.Context; +import android.hardware.input.InputManager; import android.os.Handler; +import android.os.SystemClock; +import android.util.Log; import android.util.SparseArray; import android.view.Choreographer; +import android.view.InputDevice; +import android.view.KeyCharacterMap; +import android.view.KeyEvent; import android.view.MotionEvent; import android.view.SurfaceControl; import android.view.View; @@ -47,7 +52,9 @@ import com.android.wm.shell.transition.Transitions; * View model for the window decoration with a caption and shadows. Works with * {@link CaptionWindowDecoration}. */ + public class CaptionWindowDecorViewModel implements WindowDecorViewModel { + private static final String TAG = "CaptionViewModel"; private final ActivityTaskManager mActivityTaskManager; private final ShellTaskOrganizer mTaskOrganizer; private final Context mContext; @@ -107,7 +114,6 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { windowDecoration.setCaptionListeners(touchEventListener, touchEventListener); windowDecoration.setDragResizeCallback(taskPositioner); setupWindowDecorationForTransition(taskInfo, startT, finishT); - setupCaptionColor(taskInfo, windowDecoration); return true; } @@ -117,12 +123,6 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { if (decoration == null) return; decoration.relayout(taskInfo); - setupCaptionColor(taskInfo, decoration); - } - - private void setupCaptionColor(RunningTaskInfo taskInfo, CaptionWindowDecoration decoration) { - int statusBarColor = taskInfo.taskDescription.getStatusBarColor(); - decoration.setCaptionColor(statusBarColor); } @Override @@ -153,6 +153,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { private final DragResizeCallback mDragResizeCallback; private int mDragPointerId = -1; + private boolean mDragActive = false; private CaptionTouchEventListener( RunningTaskInfo taskInfo, @@ -173,42 +174,38 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { } else { mSyncQueue.queue(wct); } - } else if (id == R.id.maximize_window) { - WindowContainerTransaction wct = new WindowContainerTransaction(); - RunningTaskInfo taskInfo = mTaskOrganizer.getRunningTaskInfo(mTaskId); - int targetWindowingMode = taskInfo.getWindowingMode() != WINDOWING_MODE_FULLSCREEN - ? WINDOWING_MODE_FULLSCREEN : WINDOWING_MODE_FREEFORM; - int displayWindowingMode = - taskInfo.configuration.windowConfiguration.getDisplayWindowingMode(); - wct.setWindowingMode(mTaskToken, - targetWindowingMode == displayWindowingMode - ? WINDOWING_MODE_UNDEFINED : targetWindowingMode); - if (targetWindowingMode == WINDOWING_MODE_FULLSCREEN) { - wct.setBounds(mTaskToken, null); - } - if (Transitions.ENABLE_SHELL_TRANSITIONS) { - mTransitionStarter.startWindowingModeTransition(targetWindowingMode, wct); - } else { - mSyncQueue.queue(wct); - } - } else if (id == R.id.minimize_window) { - WindowContainerTransaction wct = new WindowContainerTransaction(); - wct.reorder(mTaskToken, false); - if (Transitions.ENABLE_SHELL_TRANSITIONS) { - mTransitionStarter.startMinimizedModeTransition(wct); - } else { - mSyncQueue.queue(wct); - } + } else if (id == R.id.back_button) { + injectBackKey(); + } + } + private void injectBackKey() { + sendBackEvent(KeyEvent.ACTION_DOWN); + sendBackEvent(KeyEvent.ACTION_UP); + } + + private void sendBackEvent(int action) { + final long when = SystemClock.uptimeMillis(); + final KeyEvent ev = new KeyEvent(when, when, action, KeyEvent.KEYCODE_BACK, + 0 /* repeat */, 0 /* metaState */, KeyCharacterMap.VIRTUAL_KEYBOARD, + 0 /* scancode */, KeyEvent.FLAG_FROM_SYSTEM | KeyEvent.FLAG_VIRTUAL_HARD_KEY, + InputDevice.SOURCE_KEYBOARD); + + ev.setDisplayId(mContext.getDisplay().getDisplayId()); + if (!InputManager.getInstance() + .injectInputEvent(ev, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC)) { + Log.e(TAG, "Inject input event fail"); } } @Override public boolean onTouch(View v, MotionEvent e) { - if (v.getId() != R.id.caption) { + int id = v.getId(); + if (id != R.id.caption_handle && id != R.id.caption) { return false; } - handleEventForMove(e); - + if (id == R.id.caption_handle || mDragActive) { + handleEventForMove(e); + } if (e.getAction() != MotionEvent.ACTION_DOWN) { return false; } @@ -231,6 +228,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { } switch (e.getActionMasked()) { case MotionEvent.ACTION_DOWN: + mDragActive = true; mDragPointerId = e.getPointerId(0); mDragResizeCallback.onDragResizeStart( 0 /* ctrlType */, e.getRawX(0), e.getRawY(0)); @@ -243,6 +241,7 @@ public class CaptionWindowDecorViewModel implements WindowDecorViewModel { } case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: { + mDragActive = false; int dragPointerIdx = e.findPointerIndex(mDragPointerId); int statusBarHeight = mDisplayController.getDisplayLayout(taskInfo.displayId) .stableInsets().top; diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java index 9a9dca05eb33..beace75d9fca 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/CaptionWindowDecoration.java @@ -22,7 +22,6 @@ import android.content.Context; import android.content.res.ColorStateList; import android.graphics.Color; import android.graphics.Rect; -import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.VectorDrawable; import android.os.Handler; import android.view.Choreographer; @@ -39,11 +38,7 @@ import com.android.wm.shell.desktopmode.DesktopModeStatus; /** * Defines visuals and behaviors of a window decoration of a caption bar and shadows. It works with - * {@link CaptionWindowDecorViewModel}. The caption bar contains maximize and close buttons. - * - * {@link CaptionWindowDecorViewModel} can change the color of the caption bar based on the foremost - * app's request through {@link #setCaptionColor(int)}, in which it changes the foreground color of - * caption buttons according to the luminance of the background. + * {@link CaptionWindowDecorViewModel}. The caption bar contains a handle, back button, and close button. * * The shadow's thickness is 20dp when the window is in focus and 5dp when the window isn't. */ @@ -55,6 +50,8 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL // Height of button (32dp) + 2 * margin (5dp each) private static final int DECOR_CAPTION_HEIGHT_IN_DIP = 42; + // Width of buttons (64dp) + handle (128dp) + padding (24dp total) + private static final int DECOR_CAPTION_WIDTH_IN_DIP = 216; private static final int RESIZE_HANDLE_IN_DIP = 30; private static final int RESIZE_CORNER_IN_DIP = 44; @@ -75,6 +72,8 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL private final WindowDecoration.RelayoutResult<WindowDecorLinearLayout> mResult = new WindowDecoration.RelayoutResult<>(); + private boolean mDesktopActive; + CaptionWindowDecoration( Context context, DisplayController displayController, @@ -89,6 +88,7 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL mHandler = handler; mChoreographer = choreographer; mSyncQueue = syncQueue; + mDesktopActive = DesktopModeStatus.isActive(mContext); } void setCaptionListeners( @@ -125,8 +125,8 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL final SurfaceControl oldDecorationSurface = mDecorationContainerSurface; final WindowContainerTransaction wct = new WindowContainerTransaction(); relayout(taskInfo, R.layout.caption_window_decoration, oldRootView, - DECOR_CAPTION_HEIGHT_IN_DIP, outset, shadowRadiusDp, startT, finishT, wct, mResult); - taskInfo = null; // Clear it just in case we use it accidentally + DECOR_CAPTION_HEIGHT_IN_DIP, DECOR_CAPTION_WIDTH_IN_DIP, outset, shadowRadiusDp, + startT, finishT, wct, mResult); mTaskOrganizer.applyTransaction(wct); @@ -139,6 +139,17 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL setupRootView(); } + // If this task is not focused, do not show caption. + setCaptionVisibility(taskInfo.isFocused); + + // Only handle should show if Desktop Mode is inactive. + boolean desktopCurrentStatus = DesktopModeStatus.isActive(mContext); + if (mDesktopActive != desktopCurrentStatus && taskInfo.isFocused) { + mDesktopActive = desktopCurrentStatus; + setButtonVisibility(); + } + taskInfo = null; // Clear it just in case we use it accidentally + if (!isDragResizeable) { closeDragResizeListener(); return; @@ -168,42 +179,46 @@ public class CaptionWindowDecoration extends WindowDecoration<WindowDecorLinearL private void setupRootView() { View caption = mResult.mRootView.findViewById(R.id.caption); caption.setOnTouchListener(mOnCaptionTouchListener); - View maximize = caption.findViewById(R.id.maximize_window); - if (DesktopModeStatus.IS_SUPPORTED) { - // Hide maximize button when desktop mode is available - maximize.setVisibility(View.GONE); - } else { - maximize.setVisibility(View.VISIBLE); - maximize.setOnClickListener(mOnCaptionButtonClickListener); - } View close = caption.findViewById(R.id.close_window); close.setOnClickListener(mOnCaptionButtonClickListener); - View minimize = caption.findViewById(R.id.minimize_window); - minimize.setOnClickListener(mOnCaptionButtonClickListener); + View back = caption.findViewById(R.id.back_button); + back.setOnClickListener(mOnCaptionButtonClickListener); + View handle = caption.findViewById(R.id.caption_handle); + handle.setOnTouchListener(mOnCaptionTouchListener); + setButtonVisibility(); } - void setCaptionColor(int captionColor) { - if (mResult.mRootView == null) { - return; - } - + /** + * Sets caption visibility based on task focus. + * + * @param visible whether or not the caption should be visible + */ + private void setCaptionVisibility(boolean visible) { + int v = visible ? View.VISIBLE : View.GONE; View caption = mResult.mRootView.findViewById(R.id.caption); - GradientDrawable captionDrawable = (GradientDrawable) caption.getBackground(); - captionDrawable.setColor(captionColor); + caption.setVisibility(v); + } + /** + * Sets the visibility of buttons and color of caption based on desktop mode status + * + */ + public void setButtonVisibility() { + int v = mDesktopActive ? View.VISIBLE : View.GONE; + View caption = mResult.mRootView.findViewById(R.id.caption); + View back = caption.findViewById(R.id.back_button); + View close = caption.findViewById(R.id.close_window); + back.setVisibility(v); + close.setVisibility(v); int buttonTintColorRes = - Color.valueOf(captionColor).luminance() < 0.5 - ? R.color.decor_button_light_color - : R.color.decor_button_dark_color; + mDesktopActive ? R.color.decor_button_dark_color + : R.color.decor_button_light_color; ColorStateList buttonTintColor = caption.getResources().getColorStateList(buttonTintColorRes, null /* theme */); - View maximize = caption.findViewById(R.id.maximize_window); - VectorDrawable maximizeBackground = (VectorDrawable) maximize.getBackground(); - maximizeBackground.setTintList(buttonTintColor); - - View close = caption.findViewById(R.id.close_window); - VectorDrawable closeBackground = (VectorDrawable) close.getBackground(); - closeBackground.setTintList(buttonTintColor); + View handle = caption.findViewById(R.id.caption_handle); + VectorDrawable handleBackground = (VectorDrawable) handle.getBackground(); + handleBackground.setTintList(buttonTintColor); + caption.setBackgroundColor(v == View.VISIBLE ? Color.WHITE : Color.TRANSPARENT); } private void closeDragResizeListener() { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java index 3e3a864f48c7..bf863ea2c7ab 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/WindowDecoration.java @@ -143,9 +143,9 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> abstract void relayout(RunningTaskInfo taskInfo); void relayout(RunningTaskInfo taskInfo, int layoutResId, T rootView, float captionHeightDp, - Rect outsetsDp, float shadowRadiusDp, SurfaceControl.Transaction startT, - SurfaceControl.Transaction finishT, WindowContainerTransaction wct, - RelayoutResult<T> outResult) { + float captionWidthDp, Rect outsetsDp, float shadowRadiusDp, + SurfaceControl.Transaction startT, SurfaceControl.Transaction finishT, + WindowContainerTransaction wct, RelayoutResult<T> outResult) { outResult.reset(); final Configuration oldTaskConfig = mTaskInfo.getConfiguration(); @@ -249,8 +249,15 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> } final int captionHeight = (int) Math.ceil(captionHeightDp * outResult.mDensity); + final int captionWidth = (int) Math.ceil(captionWidthDp * outResult.mDensity); + + //Prevent caption from going offscreen if task is too high up + final int captionYPos = taskBounds.top <= captionHeight / 2 ? 0 : captionHeight / 2; + startT.setPosition( - mCaptionContainerSurface, -decorContainerOffsetX, -decorContainerOffsetY) + mCaptionContainerSurface, -decorContainerOffsetX + + taskBounds.width() / 2 - captionWidth / 2, + -decorContainerOffsetY - captionYPos) .setWindowCrop(mCaptionContainerSurface, taskBounds.width(), captionHeight) .show(mCaptionContainerSurface); @@ -264,7 +271,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> // Caption view mCaptionWindowManager.setConfiguration(taskConfig); final WindowManager.LayoutParams lp = - new WindowManager.LayoutParams(taskBounds.width(), captionHeight, + new WindowManager.LayoutParams(captionWidth, captionHeight, WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, PixelFormat.TRANSPARENT); lp.setTitle("Caption of Task=" + mTaskInfo.taskId); @@ -282,7 +289,7 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> // Caption insets mCaptionInsetsRect.set(taskBounds); - mCaptionInsetsRect.bottom = mCaptionInsetsRect.top + captionHeight; + mCaptionInsetsRect.bottom = mCaptionInsetsRect.top + captionHeight - captionYPos; wct.addRectInsetsProvider(mTaskInfo.token, mCaptionInsetsRect, CAPTION_INSETS_TYPES); } else { startT.hide(mCaptionContainerSurface); @@ -388,4 +395,4 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer> return new SurfaceControlViewHost(c, d, wmm); } } -} +}
\ No newline at end of file diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java index ab6ac949d4a3..fa62b9c00fc7 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/WindowDecorationTests.java @@ -77,6 +77,7 @@ import java.util.function.Supplier; @RunWith(AndroidTestingRunner.class) public class WindowDecorationTests extends ShellTestCase { private static final int CAPTION_HEIGHT_DP = 32; + private static final int CAPTION_WIDTH_DP = 216; private static final int SHADOW_RADIUS_DP = 5; private static final Rect TASK_BOUNDS = new Rect(100, 300, 400, 400); private static final Point TASK_POSITION_IN_PARENT = new Point(40, 60); @@ -220,7 +221,7 @@ public class WindowDecorationTests extends ShellTestCase { verify(captionContainerSurfaceBuilder).setParent(decorContainerSurface); verify(captionContainerSurfaceBuilder).setContainerLayer(); - verify(mMockSurfaceControlStartT).setPosition(captionContainerSurface, 20, 40); + verify(mMockSurfaceControlStartT).setPosition(captionContainerSurface, -46, 8); verify(mMockSurfaceControlStartT).setWindowCrop(captionContainerSurface, 300, 64); verify(mMockSurfaceControlStartT).show(captionContainerSurface); @@ -410,7 +411,7 @@ public class WindowDecorationTests extends ShellTestCase { @Override void relayout(ActivityManager.RunningTaskInfo taskInfo) { relayout(null /* taskInfo */, 0 /* layoutResId */, mMockView, CAPTION_HEIGHT_DP, - mOutsetsDp, SHADOW_RADIUS_DP, mMockSurfaceControlStartT, + CAPTION_WIDTH_DP, mOutsetsDp, SHADOW_RADIUS_DP, mMockSurfaceControlStartT, mMockSurfaceControlFinishT, mMockWindowContainerTransaction, mRelayoutResult); } } |