Merge "Move clock and smartspace complications down." into tm-qpr-dev am: 463531eecc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20426083

Change-Id: Ia0b8ade3189c4f7a803e914c44a7fa518b9a1d46
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Darrell Shi
2022-11-11 23:49:25 +00:00
committed by Automerger Merge Worker
6 changed files with 121 additions and 19 deletions

View File

@@ -1478,10 +1478,12 @@
<!-- Dream overlay complications related dimensions --> <!-- Dream overlay complications related dimensions -->
<dimen name="dream_overlay_complication_clock_time_text_size">86sp</dimen> <dimen name="dream_overlay_complication_clock_time_text_size">86sp</dimen>
<dimen name="dream_overlay_complication_clock_time_padding">20dp</dimen>
<dimen name="dream_overlay_complication_clock_subtitle_text_size">24sp</dimen> <dimen name="dream_overlay_complication_clock_subtitle_text_size">24sp</dimen>
<dimen name="dream_overlay_complication_preview_text_size">36sp</dimen> <dimen name="dream_overlay_complication_preview_text_size">36sp</dimen>
<dimen name="dream_overlay_complication_preview_icon_padding">28dp</dimen> <dimen name="dream_overlay_complication_preview_icon_padding">28dp</dimen>
<dimen name="dream_overlay_complication_shadow_padding">2dp</dimen> <dimen name="dream_overlay_complication_shadow_padding">2dp</dimen>
<dimen name="dream_overlay_complication_smartspace_padding">24dp</dimen>
<!-- The position of the end guide, which dream overlay complications can align their start with <!-- The position of the end guide, which dream overlay complications can align their start with
if their end is aligned with the parent end. Represented as the percentage over from the if their end is aligned with the parent end. Represented as the percentage over from the

View File

@@ -194,7 +194,9 @@ public class ComplicationLayoutEngine implements Complication.VisibilityControll
break; break;
} }
if (!isRoot) { // Add margin if specified by the complication. Otherwise add default margin
// between complications.
if (mLayoutParams.isMarginSpecified() || !isRoot) {
final int margin = mLayoutParams.getMargin(mDefaultMargin); final int margin = mLayoutParams.getMargin(mDefaultMargin);
switch(direction) { switch(direction) {
case ComplicationLayoutParams.DIRECTION_DOWN: case ComplicationLayoutParams.DIRECTION_DOWN:

View File

@@ -260,6 +260,13 @@ public class ComplicationLayoutParams extends ViewGroup.LayoutParams {
return mWeight; return mWeight;
} }
/**
* Returns whether margin has been specified by the complication.
*/
public boolean isMarginSpecified() {
return mMargin != MARGIN_UNSPECIFIED;
}
/** /**
* Returns the margin to apply between complications, or the given default if no margin is * Returns the margin to apply between complications, or the given default if no margin is
* specified. * specified.

View File

@@ -48,9 +48,9 @@ public interface RegisteredComplicationsModule {
int DREAM_CLOCK_TIME_COMPLICATION_WEIGHT = 1; int DREAM_CLOCK_TIME_COMPLICATION_WEIGHT = 1;
int DREAM_SMARTSPACE_COMPLICATION_WEIGHT = 0; int DREAM_SMARTSPACE_COMPLICATION_WEIGHT = 0;
int DREAM_MEDIA_COMPLICATION_WEIGHT = -1; int DREAM_MEDIA_COMPLICATION_WEIGHT = 0;
int DREAM_HOME_CONTROLS_CHIP_COMPLICATION_WEIGHT = 1; int DREAM_HOME_CONTROLS_CHIP_COMPLICATION_WEIGHT = 2;
int DREAM_MEDIA_ENTRY_COMPLICATION_WEIGHT = 0; int DREAM_MEDIA_ENTRY_COMPLICATION_WEIGHT = 1;
/** /**
* Provides layout parameters for the clock time complication. * Provides layout parameters for the clock time complication.
@@ -60,10 +60,11 @@ public interface RegisteredComplicationsModule {
static ComplicationLayoutParams provideClockTimeLayoutParams() { static ComplicationLayoutParams provideClockTimeLayoutParams() {
return new ComplicationLayoutParams(0, return new ComplicationLayoutParams(0,
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
ComplicationLayoutParams.POSITION_TOP ComplicationLayoutParams.POSITION_BOTTOM
| ComplicationLayoutParams.POSITION_START, | ComplicationLayoutParams.POSITION_START,
ComplicationLayoutParams.DIRECTION_DOWN, ComplicationLayoutParams.DIRECTION_UP,
DREAM_CLOCK_TIME_COMPLICATION_WEIGHT); DREAM_CLOCK_TIME_COMPLICATION_WEIGHT,
0 /*margin*/);
} }
/** /**
@@ -77,8 +78,10 @@ public interface RegisteredComplicationsModule {
res.getDimensionPixelSize(R.dimen.keyguard_affordance_fixed_height), res.getDimensionPixelSize(R.dimen.keyguard_affordance_fixed_height),
ComplicationLayoutParams.POSITION_BOTTOM ComplicationLayoutParams.POSITION_BOTTOM
| ComplicationLayoutParams.POSITION_START, | ComplicationLayoutParams.POSITION_START,
ComplicationLayoutParams.DIRECTION_END, ComplicationLayoutParams.DIRECTION_UP,
DREAM_HOME_CONTROLS_CHIP_COMPLICATION_WEIGHT); DREAM_HOME_CONTROLS_CHIP_COMPLICATION_WEIGHT,
// Add margin to the bottom of home controls to horizontally align with smartspace.
res.getDimensionPixelSize(R.dimen.dream_overlay_complication_clock_time_padding));
} }
/** /**
@@ -101,14 +104,13 @@ public interface RegisteredComplicationsModule {
*/ */
@Provides @Provides
@Named(DREAM_SMARTSPACE_LAYOUT_PARAMS) @Named(DREAM_SMARTSPACE_LAYOUT_PARAMS)
static ComplicationLayoutParams provideSmartspaceLayoutParams() { static ComplicationLayoutParams provideSmartspaceLayoutParams(@Main Resources res) {
return new ComplicationLayoutParams(0, return new ComplicationLayoutParams(0,
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
ComplicationLayoutParams.POSITION_TOP ComplicationLayoutParams.POSITION_BOTTOM
| ComplicationLayoutParams.POSITION_START, | ComplicationLayoutParams.POSITION_START,
ComplicationLayoutParams.DIRECTION_DOWN, ComplicationLayoutParams.DIRECTION_END,
DREAM_SMARTSPACE_COMPLICATION_WEIGHT, DREAM_SMARTSPACE_COMPLICATION_WEIGHT,
0, res.getDimensionPixelSize(R.dimen.dream_overlay_complication_smartspace_padding));
true /*snapToGuide*/);
} }
} }

View File

@@ -347,21 +347,22 @@ public class ComplicationLayoutEngineTest extends SysuiTestCase {
addComplication(engine, thirdViewInfo); addComplication(engine, thirdViewInfo);
// The first added view should now be underneath the second view. // The first added view should now be underneath the third view.
verifyChange(firstViewInfo, false, lp -> { verifyChange(firstViewInfo, false, lp -> {
assertThat(lp.topToBottom == thirdViewInfo.view.getId()).isTrue(); assertThat(lp.topToBottom == thirdViewInfo.view.getId()).isTrue();
assertThat(lp.endToEnd == ConstraintLayout.LayoutParams.PARENT_ID).isTrue(); assertThat(lp.endToEnd == ConstraintLayout.LayoutParams.PARENT_ID).isTrue();
assertThat(lp.topMargin).isEqualTo(margin); assertThat(lp.topMargin).isEqualTo(margin);
}); });
// The second view should be in underneath the third view. // The second view should be to the start of the third view.
verifyChange(secondViewInfo, false, lp -> { verifyChange(secondViewInfo, false, lp -> {
assertThat(lp.endToStart == thirdViewInfo.view.getId()).isTrue(); assertThat(lp.endToStart == thirdViewInfo.view.getId()).isTrue();
assertThat(lp.topToTop == ConstraintLayout.LayoutParams.PARENT_ID).isTrue(); assertThat(lp.topToTop == ConstraintLayout.LayoutParams.PARENT_ID).isTrue();
assertThat(lp.getMarginEnd()).isEqualTo(margin); assertThat(lp.getMarginEnd()).isEqualTo(margin);
}); });
// The third view should be in at the top. // The third view should be at the top end corner. No margin should be applied if not
// specified.
verifyChange(thirdViewInfo, true, lp -> { verifyChange(thirdViewInfo, true, lp -> {
assertThat(lp.topToTop == ConstraintLayout.LayoutParams.PARENT_ID).isTrue(); assertThat(lp.topToTop == ConstraintLayout.LayoutParams.PARENT_ID).isTrue();
assertThat(lp.endToEnd == ConstraintLayout.LayoutParams.PARENT_ID).isTrue(); assertThat(lp.endToEnd == ConstraintLayout.LayoutParams.PARENT_ID).isTrue();
@@ -425,14 +426,14 @@ public class ComplicationLayoutEngineTest extends SysuiTestCase {
addComplication(engine, thirdViewInfo); addComplication(engine, thirdViewInfo);
// The first added view should now be underneath the second view. // The first added view should now be underneath the third view.
verifyChange(firstViewInfo, false, lp -> { verifyChange(firstViewInfo, false, lp -> {
assertThat(lp.topToBottom == thirdViewInfo.view.getId()).isTrue(); assertThat(lp.topToBottom == thirdViewInfo.view.getId()).isTrue();
assertThat(lp.endToEnd == ConstraintLayout.LayoutParams.PARENT_ID).isTrue(); assertThat(lp.endToEnd == ConstraintLayout.LayoutParams.PARENT_ID).isTrue();
assertThat(lp.topMargin).isEqualTo(complicationMargin); assertThat(lp.topMargin).isEqualTo(complicationMargin);
}); });
// The second view should be in underneath the third view. // The second view should be to the start of the third view.
verifyChange(secondViewInfo, false, lp -> { verifyChange(secondViewInfo, false, lp -> {
assertThat(lp.endToStart == thirdViewInfo.view.getId()).isTrue(); assertThat(lp.endToStart == thirdViewInfo.view.getId()).isTrue();
assertThat(lp.topToTop == ConstraintLayout.LayoutParams.PARENT_ID).isTrue(); assertThat(lp.topToTop == ConstraintLayout.LayoutParams.PARENT_ID).isTrue();
@@ -440,6 +441,69 @@ public class ComplicationLayoutEngineTest extends SysuiTestCase {
}); });
} }
/**
* Ensures the root complication applies margin if specified.
*/
@Test
public void testRootComplicationSpecifiedMargin() {
final int defaultMargin = 5;
final int complicationMargin = 10;
final ComplicationLayoutEngine engine =
new ComplicationLayoutEngine(mLayout, defaultMargin, mTouchSession, 0, 0);
final ViewInfo firstViewInfo = new ViewInfo(
new ComplicationLayoutParams(
100,
100,
ComplicationLayoutParams.POSITION_TOP
| ComplicationLayoutParams.POSITION_END,
ComplicationLayoutParams.DIRECTION_DOWN,
0),
Complication.CATEGORY_STANDARD,
mLayout);
addComplication(engine, firstViewInfo);
final ViewInfo secondViewInfo = new ViewInfo(
new ComplicationLayoutParams(
100,
100,
ComplicationLayoutParams.POSITION_TOP
| ComplicationLayoutParams.POSITION_END,
ComplicationLayoutParams.DIRECTION_START,
0),
Complication.CATEGORY_SYSTEM,
mLayout);
addComplication(engine, secondViewInfo);
firstViewInfo.clearInvocations();
secondViewInfo.clearInvocations();
final ViewInfo thirdViewInfo = new ViewInfo(
new ComplicationLayoutParams(
100,
100,
ComplicationLayoutParams.POSITION_TOP
| ComplicationLayoutParams.POSITION_END,
ComplicationLayoutParams.DIRECTION_START,
1,
complicationMargin),
Complication.CATEGORY_SYSTEM,
mLayout);
addComplication(engine, thirdViewInfo);
// The third view is the root view and has specified margin, which should be applied based
// on its direction.
verifyChange(thirdViewInfo, true, lp -> {
assertThat(lp.getMarginStart()).isEqualTo(0);
assertThat(lp.getMarginEnd()).isEqualTo(complicationMargin);
assertThat(lp.topMargin).isEqualTo(0);
assertThat(lp.bottomMargin).isEqualTo(0);
});
}
/** /**
* Ensures layout in a particular position updates. * Ensures layout in a particular position updates.
*/ */

View File

@@ -96,6 +96,31 @@ public class ComplicationLayoutParamsTest extends SysuiTestCase {
} }
} }
/**
* Ensures ComplicationLayoutParams correctly returns whether the complication specified margin.
*/
@Test
public void testIsMarginSpecified() {
final ComplicationLayoutParams paramsNoMargin = new ComplicationLayoutParams(
100,
100,
ComplicationLayoutParams.POSITION_TOP
| ComplicationLayoutParams.POSITION_START,
ComplicationLayoutParams.DIRECTION_DOWN,
0);
assertThat(paramsNoMargin.isMarginSpecified()).isFalse();
final ComplicationLayoutParams paramsWithMargin = new ComplicationLayoutParams(
100,
100,
ComplicationLayoutParams.POSITION_TOP
| ComplicationLayoutParams.POSITION_START,
ComplicationLayoutParams.DIRECTION_DOWN,
0,
20 /*margin*/);
assertThat(paramsWithMargin.isMarginSpecified()).isTrue();
}
/** /**
* Ensures unspecified margin uses default. * Ensures unspecified margin uses default.
*/ */