Merge "Replace View elevation with SC#setShadowRadius in handle menu" into tm-qpr-dev am: 8de511ee49
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21651280 Change-Id: I5208773b06a2fc21a0f522af23a59cac757f377a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -17,6 +17,6 @@
|
|||||||
<shape android:shape="rectangle"
|
<shape android:shape="rectangle"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<solid android:color="@android:color/white" />
|
<solid android:color="@android:color/white" />
|
||||||
<corners android:radius="20dp" />
|
<corners android:radius="@dimen/caption_menu_corner_radius" />
|
||||||
<stroke android:width="1dp" android:color="#b3b3b3"/>
|
<stroke android:width="1dp" android:color="#b3b3b3"/>
|
||||||
</shape>
|
</shape>
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:background="@drawable/desktop_mode_decor_menu_background"
|
android:background="@drawable/desktop_mode_decor_menu_background"
|
||||||
android:elevation="@dimen/caption_menu_elevation"
|
|
||||||
android:divider="?android:attr/dividerHorizontal"
|
android:divider="?android:attr/dividerHorizontal"
|
||||||
android:showDividers="middle"
|
android:showDividers="middle"
|
||||||
android:dividerPadding="18dip">
|
android:dividerPadding="18dip">
|
||||||
|
|||||||
@@ -370,6 +370,10 @@
|
|||||||
|
|
||||||
<dimen name="freeform_resize_corner">44dp</dimen>
|
<dimen name="freeform_resize_corner">44dp</dimen>
|
||||||
|
|
||||||
<dimen name="caption_menu_elevation">4dp</dimen>
|
<!-- The radius of the caption menu shadow. -->
|
||||||
|
<dimen name="caption_menu_shadow_radius">4dp</dimen>
|
||||||
|
|
||||||
|
<!-- The radius of the caption menu corners. -->
|
||||||
|
<dimen name="caption_menu_corner_radius">20dp</dimen>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
|||||||
private boolean mDesktopActive;
|
private boolean mDesktopActive;
|
||||||
private AdditionalWindow mHandleMenu;
|
private AdditionalWindow mHandleMenu;
|
||||||
private final int mHandleMenuWidthId = R.dimen.freeform_decor_caption_menu_width;
|
private final int mHandleMenuWidthId = R.dimen.freeform_decor_caption_menu_width;
|
||||||
|
private final int mHandleMenuShadowRadiusId = R.dimen.caption_menu_shadow_radius;
|
||||||
|
private final int mHandleMenuCornerRadiusId = R.dimen.caption_menu_corner_radius;
|
||||||
private PointF mHandleMenuPosition = new PointF();
|
private PointF mHandleMenuPosition = new PointF();
|
||||||
|
|
||||||
DesktopModeWindowDecoration(
|
DesktopModeWindowDecoration(
|
||||||
@@ -353,19 +355,16 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
|
|||||||
.windowConfiguration.getBounds().width();
|
.windowConfiguration.getBounds().width();
|
||||||
final int menuWidth = loadDimensionPixelSize(resources, mHandleMenuWidthId);
|
final int menuWidth = loadDimensionPixelSize(resources, mHandleMenuWidthId);
|
||||||
final int menuHeight = loadDimensionPixelSize(resources, mCaptionMenuHeightId);
|
final int menuHeight = loadDimensionPixelSize(resources, mCaptionMenuHeightId);
|
||||||
|
final int shadowRadius = loadDimensionPixelSize(resources, mHandleMenuShadowRadiusId);
|
||||||
// Elevation gives the appearance of a changed x/y coordinate; this is to fix that
|
final int cornerRadius = loadDimensionPixelSize(resources, mHandleMenuCornerRadiusId);
|
||||||
int elevationOffset = 2 * loadDimensionPixelSize(resources,
|
|
||||||
R.dimen.caption_menu_elevation);
|
|
||||||
|
|
||||||
final int x = mRelayoutParams.mCaptionX + (captionWidth / 2) - (menuWidth / 2)
|
final int x = mRelayoutParams.mCaptionX + (captionWidth / 2) - (menuWidth / 2)
|
||||||
- mResult.mDecorContainerOffsetX - elevationOffset;
|
- mResult.mDecorContainerOffsetX;
|
||||||
final int y =
|
final int y = mRelayoutParams.mCaptionY - mResult.mDecorContainerOffsetY;
|
||||||
mRelayoutParams.mCaptionY - mResult.mDecorContainerOffsetY - elevationOffset;
|
|
||||||
mHandleMenuPosition.set(x, y);
|
mHandleMenuPosition.set(x, y);
|
||||||
String namePrefix = "Caption Menu";
|
String namePrefix = "Caption Menu";
|
||||||
mHandleMenu = addWindow(R.layout.desktop_mode_decor_handle_menu, namePrefix, t, x, y,
|
mHandleMenu = addWindow(R.layout.desktop_mode_decor_handle_menu, namePrefix, t, x, y,
|
||||||
menuWidth, menuHeight, 2 * elevationOffset);
|
menuWidth, menuHeight, shadowRadius, cornerRadius);
|
||||||
mSyncQueue.runInSync(transaction -> {
|
mSyncQueue.runInSync(transaction -> {
|
||||||
transaction.merge(t);
|
transaction.merge(t);
|
||||||
t.close();
|
t.close();
|
||||||
|
|||||||
@@ -391,11 +391,12 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
|
|||||||
* @param yPos y position of new window
|
* @param yPos y position of new window
|
||||||
* @param width width of new window
|
* @param width width of new window
|
||||||
* @param height height of new window
|
* @param height height of new window
|
||||||
* @param cropPadding padding to add to window crop to ensure shadows display properly
|
* @param shadowRadius radius of the shadow of the new window
|
||||||
* @return
|
* @param cornerRadius radius of the corners of the new window
|
||||||
|
* @return the {@link AdditionalWindow} that was added.
|
||||||
*/
|
*/
|
||||||
AdditionalWindow addWindow(int layoutId, String namePrefix, SurfaceControl.Transaction t,
|
AdditionalWindow addWindow(int layoutId, String namePrefix, SurfaceControl.Transaction t,
|
||||||
int xPos, int yPos, int width, int height, int cropPadding) {
|
int xPos, int yPos, int width, int height, int shadowRadius, int cornerRadius) {
|
||||||
final SurfaceControl.Builder builder = mSurfaceControlBuilderSupplier.get();
|
final SurfaceControl.Builder builder = mSurfaceControlBuilderSupplier.get();
|
||||||
SurfaceControl windowSurfaceControl = builder
|
SurfaceControl windowSurfaceControl = builder
|
||||||
.setName(namePrefix + " of Task=" + mTaskInfo.taskId)
|
.setName(namePrefix + " of Task=" + mTaskInfo.taskId)
|
||||||
@@ -404,9 +405,10 @@ public abstract class WindowDecoration<T extends View & TaskFocusStateConsumer>
|
|||||||
.build();
|
.build();
|
||||||
View v = LayoutInflater.from(mDecorWindowContext).inflate(layoutId, null);
|
View v = LayoutInflater.from(mDecorWindowContext).inflate(layoutId, null);
|
||||||
|
|
||||||
t.setPosition(
|
t.setPosition(windowSurfaceControl, xPos, yPos)
|
||||||
windowSurfaceControl, xPos, yPos)
|
.setWindowCrop(windowSurfaceControl, width, height)
|
||||||
.setWindowCrop(windowSurfaceControl, width + cropPadding, height + cropPadding)
|
.setShadowRadius(windowSurfaceControl, shadowRadius)
|
||||||
|
.setCornerRadius(windowSurfaceControl, cornerRadius)
|
||||||
.show(windowSurfaceControl);
|
.show(windowSurfaceControl);
|
||||||
final WindowManager.LayoutParams lp =
|
final WindowManager.LayoutParams lp =
|
||||||
new WindowManager.LayoutParams(width, height,
|
new WindowManager.LayoutParams(width, height,
|
||||||
|
|||||||
@@ -24,4 +24,6 @@
|
|||||||
<dimen name="test_window_decor_bottom_outset">40dp</dimen>
|
<dimen name="test_window_decor_bottom_outset">40dp</dimen>
|
||||||
<dimen name="test_window_decor_shadow_radius">5dp</dimen>
|
<dimen name="test_window_decor_shadow_radius">5dp</dimen>
|
||||||
<dimen name="test_window_decor_resize_handle">10dp</dimen>
|
<dimen name="test_window_decor_resize_handle">10dp</dimen>
|
||||||
|
<dimen name="test_caption_menu_shadow_radius">4dp</dimen>
|
||||||
|
<dimen name="test_caption_menu_corner_radius">20dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -108,6 +108,8 @@ public class WindowDecorationTests extends ShellTestCase {
|
|||||||
private SurfaceControl.Transaction mMockSurfaceControlAddWindowT;
|
private SurfaceControl.Transaction mMockSurfaceControlAddWindowT;
|
||||||
private WindowDecoration.RelayoutParams mRelayoutParams = new WindowDecoration.RelayoutParams();
|
private WindowDecoration.RelayoutParams mRelayoutParams = new WindowDecoration.RelayoutParams();
|
||||||
private int mCaptionMenuWidthId;
|
private int mCaptionMenuWidthId;
|
||||||
|
private int mCaptionMenuShadowRadiusId;
|
||||||
|
private int mCaptionMenuCornerRadiusId;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -118,6 +120,8 @@ public class WindowDecorationTests extends ShellTestCase {
|
|||||||
mRelayoutParams.mLayoutResId = 0;
|
mRelayoutParams.mLayoutResId = 0;
|
||||||
mRelayoutParams.mCaptionHeightId = R.dimen.test_freeform_decor_caption_height;
|
mRelayoutParams.mCaptionHeightId = R.dimen.test_freeform_decor_caption_height;
|
||||||
mCaptionMenuWidthId = R.dimen.test_freeform_decor_caption_menu_width;
|
mCaptionMenuWidthId = R.dimen.test_freeform_decor_caption_menu_width;
|
||||||
|
mCaptionMenuShadowRadiusId = R.dimen.test_caption_menu_shadow_radius;
|
||||||
|
mCaptionMenuCornerRadiusId = R.dimen.test_caption_menu_corner_radius;
|
||||||
mRelayoutParams.mShadowRadiusId = R.dimen.test_window_decor_shadow_radius;
|
mRelayoutParams.mShadowRadiusId = R.dimen.test_window_decor_shadow_radius;
|
||||||
|
|
||||||
doReturn(mMockSurfaceControlViewHost).when(mMockSurfaceControlViewHostFactory)
|
doReturn(mMockSurfaceControlViewHost).when(mMockSurfaceControlViewHostFactory)
|
||||||
@@ -431,7 +435,19 @@ public class WindowDecorationTests extends ShellTestCase {
|
|||||||
verify(additionalWindowSurfaceBuilder).setParent(decorContainerSurface);
|
verify(additionalWindowSurfaceBuilder).setParent(decorContainerSurface);
|
||||||
verify(additionalWindowSurfaceBuilder).build();
|
verify(additionalWindowSurfaceBuilder).build();
|
||||||
verify(mMockSurfaceControlAddWindowT).setPosition(additionalWindowSurface, 20, 40);
|
verify(mMockSurfaceControlAddWindowT).setPosition(additionalWindowSurface, 20, 40);
|
||||||
verify(mMockSurfaceControlAddWindowT).setWindowCrop(additionalWindowSurface, 442, 74);
|
final int width = WindowDecoration.loadDimensionPixelSize(
|
||||||
|
mContext.getResources(), mCaptionMenuWidthId);
|
||||||
|
final int height = WindowDecoration.loadDimensionPixelSize(
|
||||||
|
mContext.getResources(), mRelayoutParams.mCaptionHeightId);
|
||||||
|
verify(mMockSurfaceControlAddWindowT).setWindowCrop(additionalWindowSurface, width, height);
|
||||||
|
final int shadowRadius = WindowDecoration.loadDimensionPixelSize(mContext.getResources(),
|
||||||
|
mCaptionMenuShadowRadiusId);
|
||||||
|
verify(mMockSurfaceControlAddWindowT)
|
||||||
|
.setShadowRadius(additionalWindowSurface, shadowRadius);
|
||||||
|
final int cornerRadius = WindowDecoration.loadDimensionPixelSize(mContext.getResources(),
|
||||||
|
mCaptionMenuCornerRadiusId);
|
||||||
|
verify(mMockSurfaceControlAddWindowT)
|
||||||
|
.setCornerRadius(additionalWindowSurface, cornerRadius);
|
||||||
verify(mMockSurfaceControlAddWindowT).show(additionalWindowSurface);
|
verify(mMockSurfaceControlAddWindowT).show(additionalWindowSurface);
|
||||||
verify(mMockSurfaceControlViewHostFactory, Mockito.times(2))
|
verify(mMockSurfaceControlViewHostFactory, Mockito.times(2))
|
||||||
.create(any(), eq(defaultDisplay), any());
|
.create(any(), eq(defaultDisplay), any());
|
||||||
@@ -559,13 +575,15 @@ public class WindowDecorationTests extends ShellTestCase {
|
|||||||
int y = mRelayoutParams.mCaptionY;
|
int y = mRelayoutParams.mCaptionY;
|
||||||
int width = loadDimensionPixelSize(resources, mCaptionMenuWidthId);
|
int width = loadDimensionPixelSize(resources, mCaptionMenuWidthId);
|
||||||
int height = loadDimensionPixelSize(resources, mRelayoutParams.mCaptionHeightId);
|
int height = loadDimensionPixelSize(resources, mRelayoutParams.mCaptionHeightId);
|
||||||
|
int shadowRadius = loadDimensionPixelSize(resources, mCaptionMenuShadowRadiusId);
|
||||||
|
int cornerRadius = loadDimensionPixelSize(resources, mCaptionMenuCornerRadiusId);
|
||||||
String name = "Test Window";
|
String name = "Test Window";
|
||||||
WindowDecoration.AdditionalWindow additionalWindow =
|
WindowDecoration.AdditionalWindow additionalWindow =
|
||||||
addWindow(R.layout.desktop_mode_decor_handle_menu, name,
|
addWindow(R.layout.desktop_mode_decor_handle_menu, name,
|
||||||
mMockSurfaceControlAddWindowT,
|
mMockSurfaceControlAddWindowT,
|
||||||
x - mRelayoutResult.mDecorContainerOffsetX,
|
x - mRelayoutResult.mDecorContainerOffsetX,
|
||||||
y - mRelayoutResult.mDecorContainerOffsetY,
|
y - mRelayoutResult.mDecorContainerOffsetY,
|
||||||
width, height, 10);
|
width, height, shadowRadius, cornerRadius);
|
||||||
return additionalWindow;
|
return additionalWindow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user