Loading packages/SystemUI/res/values/dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutEngine.java +3 −1 Original line number Diff line number Diff line Loading @@ -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: Loading packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutParams.java +7 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,13 @@ public class ComplicationLayoutParams extends ViewGroup.LayoutParams { 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 * specified. Loading packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/RegisteredComplicationsModule.java +15 −13 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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*/); } /** Loading @@ -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)); } /** Loading @@ -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)); } } packages/SystemUI/tests/src/com/android/systemui/dreams/complication/ComplicationLayoutEngineTest.java +69 −5 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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(); Loading @@ -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. */ Loading Loading
packages/SystemUI/res/values/dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -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 Loading
packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutEngine.java +3 −1 Original line number Diff line number Diff line Loading @@ -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: Loading
packages/SystemUI/src/com/android/systemui/dreams/complication/ComplicationLayoutParams.java +7 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,13 @@ public class ComplicationLayoutParams extends ViewGroup.LayoutParams { 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 * specified. Loading
packages/SystemUI/src/com/android/systemui/dreams/complication/dagger/RegisteredComplicationsModule.java +15 −13 Original line number Diff line number Diff line Loading @@ -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. Loading @@ -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*/); } /** Loading @@ -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)); } /** Loading @@ -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)); } }
packages/SystemUI/tests/src/com/android/systemui/dreams/complication/ComplicationLayoutEngineTest.java +69 −5 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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(); Loading @@ -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. */ Loading