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

Commit 457a10d2 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Restrict line count for BigTextStyle

Also fixes paddings for the first line for InboxStyle notifications.

Bug: 17161340
Change-Id: I00a92f256d9ccad7cfbcecb591e84bb0d68ba635
parent 5f183f06
Loading
Loading
Loading
Loading
+34 −2
Original line number Diff line number Diff line
@@ -3386,8 +3386,16 @@ public class Notification implements Parcelable
     */
    public static abstract class Style {
        private CharSequence mBigContentTitle;
        private CharSequence mSummaryText = null;
        private boolean mSummaryTextSet = false;

        /**
         * @hide
         */
        protected CharSequence mSummaryText = null;

        /**
         * @hide
         */
        protected boolean mSummaryTextSet = false;

        protected Builder mBuilder;

@@ -3679,6 +3687,11 @@ public class Notification implements Parcelable
     * @see Notification#bigContentView
     */
    public static class BigTextStyle extends Style {

        private static final int MAX_LINES = 13;
        private static final int LINES_CONSUMED_BY_ACTIONS = 3;
        private static final int LINES_CONSUMED_BY_SUMMARY = 2;

        private CharSequence mBigText;

        public BigTextStyle() {
@@ -3745,6 +3758,7 @@ public class Notification implements Parcelable

            contentView.setTextViewText(R.id.big_text, mBuilder.processLegacyText(mBigText));
            contentView.setViewVisibility(R.id.big_text, View.VISIBLE);
            contentView.setInt(R.id.big_text, "setMaxLines", calculateMaxLines());
            contentView.setViewVisibility(R.id.text2, View.GONE);

            applyTopPadding(contentView);
@@ -3756,6 +3770,24 @@ public class Notification implements Parcelable
            return contentView;
        }

        private int calculateMaxLines() {
            int lineCount = MAX_LINES;
            boolean hasActions = mBuilder.mActions.size() > 0;
            boolean hasSummary = (mSummaryTextSet ? mSummaryText : mBuilder.mSubText) != null;
            if (hasActions) {
                lineCount -= LINES_CONSUMED_BY_ACTIONS;
            }
            if (hasSummary) {
                lineCount -= LINES_CONSUMED_BY_SUMMARY;
            }

            // If we have less top padding at the top, we can fit less lines.
            if (!mBuilder.mHasThreeLines) {
                lineCount--;
            }
            return lineCount;
        }

        /**
         * @hide
         */
+1 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@
            android:layout_width="match_parent"
            android:layout_weight="1"
            android:layout_height="0dp"
            android:layout_marginEnd="8dp"
            android:orientation="horizontal"
            >
            <TextView android:id="@+id/inbox_text0"
@@ -60,7 +61,6 @@
                android:layout_height="@dimen/notification_badge_size"
                android:layout_weight="0"
                android:layout_marginStart="4dp"
                android:layout_marginEnd="8dp"
                android:scaleType="fitCenter"
                android:visibility="gone"
                />