Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 463531ee authored by Darrell Shi's avatar Darrell Shi Committed by Android (Google) Code Review
Browse files

Merge "Move clock and smartspace complications down." into tm-qpr-dev

parents 473235f3 63dea367
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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
+3 −1
Original line number Diff line number Diff line
@@ -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:
+7 −0
Original line number Diff line number Diff line
@@ -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.
+15 −13
Original line number Diff line number Diff line
@@ -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));
    }
}
+69 −5
Original line number Diff line number Diff line
@@ -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();
@@ -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