diff options
| author | 2022-11-11 23:39:38 +0000 | |
|---|---|---|
| committer | 2022-11-11 23:39:38 +0000 | |
| commit | 463531eecc2499c565109640a4d3c834bb5ae3db (patch) | |
| tree | f4c2b1a235620e3c7ec65bdf2d0d839cc943b9bf | |
| parent | 473235f30ba55f5e47de585d4049b8feb8e4329c (diff) | |
| parent | 63dea3676f3aa08ee04959dce047826fc64311a5 (diff) | |
Merge "Move clock and smartspace complications down." into tm-qpr-dev
6 files changed, 121 insertions, 19 deletions
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index e8ae929a6782..691bf89a5313 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1478,10 +1478,12 @@ <!-- Dream overlay complications related dimensions --> <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_preview_text_size">36sp</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_smartspace_padding">24dp</dimen> <!-- 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 diff --git a/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutEngine.java b/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutEngine.java index 5694f6da0ea5..440dcbc18a12 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutEngine.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutEngine.java @@ -194,7 +194,9 @@ public class ComplicationLayoutEngine implements Complication.VisibilityControll 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); switch(direction) { case ComplicationLayoutParams.DIRECTION_DOWN: diff --git a/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutParams.java b/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutParams.java index a21eb19bd548..2b32d349dd67 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutParams.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutParams.java @@ -261,6 +261,13 @@ public class ComplicationLayoutParams extends ViewGroup.LayoutParams { } /** + * 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 * specified. */ diff --git a/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/RegisteredComplicationsModule.java b/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/RegisteredComplicationsModule.java index 7d2ce51ffbf6..69b85b5a5e51 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/RegisteredComplicationsModule.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/RegisteredComplicationsModule.java @@ -48,9 +48,9 @@ public interface RegisteredComplicationsModule { int DREAM_CLOCK_TIME_COMPLICATION_WEIGHT = 1; int DREAM_SMARTSPACE_COMPLICATION_WEIGHT = 0; - int DREAM_MEDIA_COMPLICATION_WEIGHT = -1; - int DREAM_HOME_CONTROLS_CHIP_COMPLICATION_WEIGHT = 1; - int DREAM_MEDIA_ENTRY_COMPLICATION_WEIGHT = 0; + int DREAM_MEDIA_COMPLICATION_WEIGHT = 0; + int DREAM_HOME_CONTROLS_CHIP_COMPLICATION_WEIGHT = 2; + int DREAM_MEDIA_ENTRY_COMPLICATION_WEIGHT = 1; /** * Provides layout parameters for the clock time complication. @@ -60,10 +60,11 @@ public interface RegisteredComplicationsModule { static ComplicationLayoutParams provideClockTimeLayoutParams() { return new ComplicationLayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, - ComplicationLayoutParams.POSITION_TOP + ComplicationLayoutParams.POSITION_BOTTOM | ComplicationLayoutParams.POSITION_START, - ComplicationLayoutParams.DIRECTION_DOWN, - DREAM_CLOCK_TIME_COMPLICATION_WEIGHT); + ComplicationLayoutParams.DIRECTION_UP, + DREAM_CLOCK_TIME_COMPLICATION_WEIGHT, + 0 /*margin*/); } /** @@ -77,8 +78,10 @@ public interface RegisteredComplicationsModule { res.getDimensionPixelSize(R.dimen.keyguard_affordance_fixed_height), ComplicationLayoutParams.POSITION_BOTTOM | ComplicationLayoutParams.POSITION_START, - ComplicationLayoutParams.DIRECTION_END, - DREAM_HOME_CONTROLS_CHIP_COMPLICATION_WEIGHT); + ComplicationLayoutParams.DIRECTION_UP, + 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 @Named(DREAM_SMARTSPACE_LAYOUT_PARAMS) - static ComplicationLayoutParams provideSmartspaceLayoutParams() { + static ComplicationLayoutParams provideSmartspaceLayoutParams(@Main Resources res) { return new ComplicationLayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, - ComplicationLayoutParams.POSITION_TOP + ComplicationLayoutParams.POSITION_BOTTOM | ComplicationLayoutParams.POSITION_START, - ComplicationLayoutParams.DIRECTION_DOWN, + ComplicationLayoutParams.DIRECTION_END, DREAM_SMARTSPACE_COMPLICATION_WEIGHT, - 0, - true /*snapToGuide*/); + res.getDimensionPixelSize(R.dimen.dream_overlay_complication_smartspace_padding)); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/complication/ComplicationLayoutEngineTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/complication/ComplicationLayoutEngineTest.java index 849ac5ef90d7..7a2ba95f74a0 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/complication/ComplicationLayoutEngineTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/complication/ComplicationLayoutEngineTest.java @@ -347,21 +347,22 @@ public class ComplicationLayoutEngineTest extends SysuiTestCase { 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 -> { assertThat(lp.topToBottom == thirdViewInfo.view.getId()).isTrue(); assertThat(lp.endToEnd == ConstraintLayout.LayoutParams.PARENT_ID).isTrue(); 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 -> { assertThat(lp.endToStart == thirdViewInfo.view.getId()).isTrue(); assertThat(lp.topToTop == ConstraintLayout.LayoutParams.PARENT_ID).isTrue(); 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 -> { assertThat(lp.topToTop == 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); - // 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 -> { assertThat(lp.topToBottom == thirdViewInfo.view.getId()).isTrue(); assertThat(lp.endToEnd == ConstraintLayout.LayoutParams.PARENT_ID).isTrue(); 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 -> { assertThat(lp.endToStart == thirdViewInfo.view.getId()).isTrue(); assertThat(lp.topToTop == ConstraintLayout.LayoutParams.PARENT_ID).isTrue(); @@ -441,6 +442,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. */ @Test diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/complication/ComplicationLayoutParamsTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/complication/ComplicationLayoutParamsTest.java index cb7e47b28bcd..ce7561e95f1e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/complication/ComplicationLayoutParamsTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/complication/ComplicationLayoutParamsTest.java @@ -97,6 +97,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. */ @Test |