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

Commit 860b6dac authored by Selim Cinek's avatar Selim Cinek
Browse files

Measuring the notifications at wrap_content height now

The notifications are now measured at wrap_content such
that the layout still looks good even if the text
was ommited instead of arbitrarily making it bigger.
This also fixes some small rounding issues where the
expanded notification was just a pixel bigger than
the collapsed version.

Bug: 26185377
Change-Id: Ie3339ff75680ab512446605055304576e058f588
parent b55386d6
Loading
Loading
Loading
Loading
+19 −6
Original line number Diff line number Diff line
@@ -3001,6 +3001,7 @@ public class Notification implements Parcelable
            resetNotificationHeader(contentView);
            resetContentMargins(contentView);
            contentView.setViewVisibility(R.id.right_icon, View.GONE);
            contentView.setViewVisibility(R.id.title, View.GONE);
            contentView.setTextViewText(R.id.title, null);
            contentView.setTextViewText(R.id.text, null);
            contentView.setViewVisibility(R.id.line3, View.GONE);
@@ -3047,6 +3048,7 @@ public class Notification implements Parcelable
            bindNotificationHeader(contentView);
            bindLargeIcon(contentView);
            if (ex.getCharSequence(EXTRA_TITLE) != null) {
                contentView.setViewVisibility(R.id.title, View.VISIBLE);
                contentView.setTextViewText(R.id.title,
                        processLegacyText(ex.getCharSequence(EXTRA_TITLE)));
            }
@@ -3065,10 +3067,26 @@ public class Notification implements Parcelable
            }
            // Note getStandardView may hide line 3 again.
            contentView.setViewVisibility(R.id.line3, showLine3 ? View.VISIBLE : View.GONE);
            setContentMinHeight(contentView, showProgress || mN.mLargeIcon != null);

            return contentView;
        }

        /**
         * @param remoteView the remote view to update the minheight in
         * @param hasMinHeight does it have a mimHeight
         * @hide
         */
        void setContentMinHeight(RemoteViews remoteView, boolean hasMinHeight) {
            int minHeight = 0;
            if (hasMinHeight) {
                // we need to set the minHeight of the notification
                minHeight = mContext.getResources().getDimensionPixelSize(
                        com.android.internal.R.dimen.notification_min_content_height);
            }
            remoteView.setInt(R.id.notification_main_column, "setMinimumHeight", minHeight);
        }

        private boolean handleProgressBar(boolean hasProgress, RemoteViews contentView, Bundle ex) {
            final int max = ex.getInt(EXTRA_PROGRESS_MAX, 0);
            final int progress = ex.getInt(EXTRA_PROGRESS, 0);
@@ -3832,12 +3850,7 @@ public class Notification implements Parcelable
                contentView.setTextViewText(R.id.text, mBuilder.processLegacyText(mSummaryText));
                contentView.setViewVisibility(R.id.line3, View.VISIBLE);
            }
            int imageMinHeight = mBuilder.mContext.getResources().getDimensionPixelSize(
                    R.dimen.notification_big_picture_content_min_height_with_picture);
            // We need to make space for the right image, so we're enforcing a minheight if there
            // is a picture.
            int minHeight = (mBuilder.mN.mLargeIcon == null) ? 0 : imageMinHeight;
            contentView.setInt(R.id.notification_main_column, "setMinimumHeight", minHeight);
            mBuilder.setContentMinHeight(contentView, mBuilder.mN.mLargeIcon != null);

            if (mBigLargeIconSet) {
                mBuilder.mN.mLargeIcon = oldLargeIcon;
+3 −3
Original line number Diff line number Diff line
@@ -25,12 +25,12 @@
    <LinearLayout
        android:id="@+id/notification_main_column"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:layout_marginStart="@dimen/notification_content_margin_start"
        android:layout_marginEnd="@dimen/notification_content_margin_end"
        android:layout_marginTop="@dimen/notification_content_margin_top"
        android:minHeight="@dimen/notification_min_content_height"
        android:layout_marginBottom="@dimen/notification_content_margin_bottom"
        android:orientation="vertical"
        >
        <include layout="@layout/notification_template_part_line1" />
+2 −2
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@
    <FrameLayout
        android:id="@+id/status_bar_latest_event_content"
        android:layout_width="match_parent"
        android:layout_height="@dimen/notification_min_height"
        android:layout_height="wrap_content"
        android:layout_gravity="top"
        android:tag="base"
        >
@@ -38,7 +38,7 @@
            android:layout_marginStart="@dimen/notification_content_margin_start"
            android:layout_marginEnd="@dimen/notification_content_margin_end"
            android:layout_marginTop="@dimen/notification_content_margin_top"
            android:minHeight="@dimen/notification_min_content_height"
            android:layout_marginBottom="@dimen/notification_content_margin_bottom"
            android:orientation="vertical"
            >
            <include layout="@layout/notification_template_part_line1" />
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/notification_content_margin_top"
        android:layout_marginStart="@dimen/notification_content_margin_start"
        android:layout_marginBottom="@dimen/notification_content_margin_bottom"
        android:layout_marginEnd="24dp"
        android:layout_toStartOf="@id/right_icon"
        android:minHeight="@dimen/notification_min_content_height"
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:paddingBottom="13dp"
            android:paddingBottom="@dimen/notification_content_margin_bottom"
            android:orientation="horizontal"
            android:gravity="top"
            android:layout_weight="1"
Loading