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

Commit 97511bc2 authored by Kenny Guy's avatar Kenny Guy Committed by android-build-merger
Browse files

Merge "Fix issue with compressed smart replies." into pi-dev

am: 895ed11d

Change-Id: I7743b004a7ddc9e46f3366f7c15058aad12686c4
parents 9252fbc7 895ed11d
Loading
Loading
Loading
Loading
+8 −6
Original line number Original line Diff line number Diff line
@@ -495,13 +495,15 @@ public class SmartReplyView extends ViewGroup {
            // measured with the wrong number of lines).
            // measured with the wrong number of lines).
            if (child.getPaddingLeft() != buttonPaddingHorizontal) {
            if (child.getPaddingLeft() != buttonPaddingHorizontal) {
                requiresNewMeasure = true;
                requiresNewMeasure = true;
                if (newWidth != Integer.MAX_VALUE) {
                    if (buttonPaddingHorizontal == mSingleLineButtonPaddingHorizontal) {
                    if (buttonPaddingHorizontal == mSingleLineButtonPaddingHorizontal) {
                    // Decrease padding (2->1 line).
                        // Change padding (2->1 line).
                        newWidth -= mSingleToDoubleLineButtonWidthIncrease;
                        newWidth -= mSingleToDoubleLineButtonWidthIncrease;
                    } else {
                    } else {
                    // Increase padding (1->2 lines).
                        // Change padding (1->2 lines).
                        newWidth += mSingleToDoubleLineButtonWidthIncrease;
                        newWidth += mSingleToDoubleLineButtonWidthIncrease;
                    }
                    }
                }
                child.setPadding(buttonPaddingHorizontal, child.getPaddingTop(),
                child.setPadding(buttonPaddingHorizontal, child.getPaddingTop(),
                        buttonPaddingHorizontal, child.getPaddingBottom());
                        buttonPaddingHorizontal, child.getPaddingBottom());
            }
            }
+32 −4
Original line number Original line Diff line number Diff line
@@ -347,6 +347,30 @@ public class SmartReplyViewTest extends SysuiTestCase {
        assertEqualLayouts(expectedView.getChildAt(2), mView.getChildAt(2));
        assertEqualLayouts(expectedView.getChildAt(2), mView.getChildAt(2));
    }
    }


    @Test
    public void testMeasure_dropLongest() {
        final CharSequence[] choices = new CharSequence[]{"Short", "Short",
                "LooooooongUnbreakableReplyyyyy"};

        // Short choices should be shown as single line views
        ViewGroup expectedView = buildExpectedView(
                new CharSequence[]{"Short", "Short"}, 1);
        expectedView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
        expectedView.layout(10, 10, 10 + expectedView.getMeasuredWidth(),
                10 + expectedView.getMeasuredHeight());

        setRepliesFromRemoteInput(choices);
        mView.measure(
                MeasureSpec.makeMeasureSpec(expectedView.getMeasuredWidth(), MeasureSpec.AT_MOST),
                MeasureSpec.UNSPECIFIED);
        mView.layout(10, 10, 10 + mView.getMeasuredWidth(), 10 + mView.getMeasuredHeight());

        assertEqualLayouts(expectedView, mView);
        assertReplyButtonShownWithEqualMeasures(expectedView.getChildAt(0), mView.getChildAt(0));
        assertReplyButtonShownWithEqualMeasures(expectedView.getChildAt(1), mView.getChildAt(1));
        assertReplyButtonHidden(mView.getChildAt(2));
    }

    private void setRepliesFromRemoteInput(CharSequence[] choices) {
    private void setRepliesFromRemoteInput(CharSequence[] choices) {
        PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0,
        PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0,
                new Intent(TEST_ACTION), 0);
                new Intent(TEST_ACTION), 0);
@@ -407,10 +431,7 @@ public class SmartReplyViewTest extends SysuiTestCase {
    private static void assertReplyButtonShownWithEqualMeasures(View expected, View actual) {
    private static void assertReplyButtonShownWithEqualMeasures(View expected, View actual) {
        assertReplyButtonShown(actual);
        assertReplyButtonShown(actual);
        assertEqualMeasures(expected, actual);
        assertEqualMeasures(expected, actual);
        assertEquals(expected.getPaddingLeft(), actual.getPaddingLeft());
        assertEqualPadding(expected, actual);
        assertEquals(expected.getPaddingTop(), actual.getPaddingTop());
        assertEquals(expected.getPaddingRight(), actual.getPaddingRight());
        assertEquals(expected.getPaddingBottom(), actual.getPaddingBottom());
    }
    }


    private static void assertReplyButtonShown(View view) {
    private static void assertReplyButtonShown(View view) {
@@ -427,4 +448,11 @@ public class SmartReplyViewTest extends SysuiTestCase {
        assertEquals(expected.getRight(), actual.getRight());
        assertEquals(expected.getRight(), actual.getRight());
        assertEquals(expected.getBottom(), actual.getBottom());
        assertEquals(expected.getBottom(), actual.getBottom());
    }
    }

    private static void assertEqualPadding(View expected, View actual) {
        assertEquals(expected.getPaddingLeft(), actual.getPaddingLeft());
        assertEquals(expected.getPaddingTop(), actual.getPaddingTop());
        assertEquals(expected.getPaddingRight(), actual.getPaddingRight());
        assertEquals(expected.getPaddingBottom(), actual.getPaddingBottom());
    }
}
}