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

Commit 91d065bc authored by Kenny Guy's avatar Kenny Guy Committed by Android (Google) Code Review
Browse files

Merge "Fix notification badge when line 3 not shown." into lmp-dev

parents 17cda4f8 98193ea5
Loading
Loading
Loading
Loading
+41 −7
Original line number Diff line number Diff line
@@ -2579,20 +2579,35 @@ public class Notification implements Parcelable
            return bitmap;
        }

        private boolean addProfileBadge(RemoteViews contentView, int resId) {
            Bitmap profileBadge = getProfileBadge();

            contentView.setViewVisibility(R.id.profile_badge_large_template, View.GONE);
            contentView.setViewVisibility(R.id.profile_badge_line2, View.GONE);
            contentView.setViewVisibility(R.id.profile_badge_line3, View.GONE);

            if (profileBadge != null) {
                contentView.setImageViewBitmap(resId, profileBadge);
                contentView.setViewVisibility(resId, View.VISIBLE);

                // Make sure Line 3 is visible. As badge will be here if there
                // is no text to display.
                if (resId == R.id.profile_badge_line3) {
                    contentView.setViewVisibility(R.id.line3, View.VISIBLE);
                }
                return true;
            }
            return false;
        }

        private RemoteViews applyStandardTemplate(int resId) {
            Bitmap profileIcon = getProfileBadge();
            RemoteViews contentView = new BuilderRemoteViews(mContext.getPackageName(),
                    mOriginatingUserId, resId);

            boolean showLine3 = false;
            boolean showLine2 = false;
            boolean contentTextInLine2 = false;

            if (profileIcon != null) {
                contentView.setImageViewBitmap(R.id.profile_icon, profileIcon);
                contentView.setViewVisibility(R.id.profile_icon, View.VISIBLE);
            } else {
                contentView.setViewVisibility(R.id.profile_icon, View.GONE);
            }
            if (mLargeIcon != null) {
                contentView.setImageViewBitmap(R.id.icon, mLargeIcon);
                processLargeIcon(mLargeIcon, contentView);
@@ -2639,6 +2654,7 @@ public class Notification implements Parcelable
                    contentView.setTextViewText(R.id.text2, processLegacyText(mContentText));
                    contentView.setViewVisibility(R.id.text2, View.VISIBLE);
                    showLine2 = true;
                    contentTextInLine2 = true;
                } else {
                    contentView.setViewVisibility(R.id.text2, View.GONE);
                }
@@ -2681,6 +2697,15 @@ public class Notification implements Parcelable
                    hasThreeLines(), mContext.getResources().getConfiguration().fontScale),
                    0, 0);

            // We want to add badge to first line of text.
            boolean addedBadge = addProfileBadge(contentView,
                    contentTextInLine2 ? R.id.profile_badge_line2 : R.id.profile_badge_line3);
            // If we added the badge to line 3 then we should show line 3.
            if (addedBadge && !contentTextInLine2) {
                showLine3 = true;
            }

            // Note getStandardView may hide line 3 again.
            contentView.setViewVisibility(R.id.line3, showLine3 ? View.VISIBLE : View.GONE);
            contentView.setViewVisibility(R.id.overflow_divider, showLine3 ? View.VISIBLE : View.GONE);
            return contentView;
@@ -3347,6 +3372,8 @@ public class Notification implements Parcelable
                contentView.setViewVisibility(R.id.overflow_divider, View.VISIBLE);
                contentView.setViewVisibility(R.id.line3, View.VISIBLE);
            } else {
                // Clear text in case we use the line to show the profile badge.
                contentView.setTextViewText(R.id.text, "");
                contentView.setViewVisibility(R.id.overflow_divider, View.GONE);
                contentView.setViewVisibility(R.id.line3, View.GONE);
            }
@@ -3507,6 +3534,9 @@ public class Notification implements Parcelable

            applyTopPadding(contentView);

            boolean twoTextLines = mBuilder.mSubText != null && mBuilder.mContentText != null;
            mBuilder.addProfileBadge(contentView,
                    twoTextLines ? R.id.profile_badge_line2 : R.id.profile_badge_line3);
            return contentView;
        }

@@ -3632,6 +3662,8 @@ public class Notification implements Parcelable

            applyTopPadding(contentView);

            mBuilder.addProfileBadge(contentView, R.id.profile_badge_large_template);

            return contentView;
        }

@@ -3769,6 +3801,8 @@ public class Notification implements Parcelable

            applyTopPadding(contentView);

            mBuilder.addProfileBadge(contentView, R.id.profile_badge_large_template);

            return contentView;
        }

+21 −5
Original line number Diff line number Diff line
@@ -37,14 +37,30 @@
        >
        <include layout="@layout/notification_template_part_line1" />
        <include layout="@layout/notification_template_part_line2" />
        <TextView android:id="@+id/big_text"
            android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:orientation="horizontal"
            android:gravity="top"
            >
            <TextView android:id="@+id/big_text"
                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:singleLine="false"
                android:visibility="gone"
                />
            <ImageView android:id="@+id/profile_badge_large_template"
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:layout_weight="0"
                android:layout_marginStart="4dp"
                android:scaleType="fitCenter"
                android:visibility="gone"
                />
        </LinearLayout>
        <include
            layout="@layout/notification_template_part_line3"
            android:layout_width="match_parent"
+21 −4
Original line number Diff line number Diff line
@@ -37,14 +37,31 @@
        >
        <include layout="@layout/notification_template_part_line1" />
        <include layout="@layout/notification_template_part_line2" />
        <TextView android:id="@+id/big_text"
            android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_marginBottom="10dp"
            android:orientation="horizontal"
            android:gravity="top"
            >
            <TextView android:id="@+id/big_text"
                android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:singleLine="false"
                android:visibility="gone"
                />
            <ImageView android:id="@+id/profile_badge_large_template"
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:layout_weight="0"
                android:layout_marginStart="4dp"
                android:scaleType="fitCenter"
                android:visibility="gone"
                />
        </LinearLayout>
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="1dp"
+95 −72
Original line number Diff line number Diff line
@@ -37,6 +37,18 @@
        >
        <include layout="@layout/notification_template_part_line1" />
        <include layout="@layout/notification_template_part_line2" />
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:gravity="top"
            >
            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                >
                <TextView android:id="@+id/inbox_text0"
                    android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent"
                    android:layout_width="match_parent"
@@ -110,6 +122,17 @@
                    android:layout_weight="1"
                    android:text="@android:string/ellipsis"
                    />
            </LinearLayout>
            <ImageView android:id="@+id/profile_badge_large_template"
                android:layout_width="20dp"
                android:layout_height="20dp"
                android:layout_weight="0"
                android:layout_marginStart="4dp"
                android:layout_marginEnd="8dp"
                android:scaleType="fitCenter"
                android:visibility="gone"
                />
        </LinearLayout>
        <FrameLayout
            android:id="@+id/inbox_end_pad"
            android:layout_width="match_parent"
+25 −8
Original line number Diff line number Diff line
@@ -16,20 +16,37 @@
  -->

<merge xmlns:android="http://schemas.android.com/apk/res/android">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
        android:visibility="gone"
        android:layout_weight="0"
        android:orientation="horizontal"
        android:gravity="center_vertical"
        >
        <TextView
            android:id="@+id/text2"
            android:textAppearance="@style/TextAppearance.StatusBar.Material.EventContent.Line2"
        android:layout_width="match_parent"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
        android:layout_marginEnd="8dp"
            android:layout_marginTop="-1dp"
            android:layout_marginBottom="-1dp"
            android:singleLine="true"
            android:fadingEdge="horizontal"
            android:ellipsize="marquee"
            android:visibility="gone"
            android:layout_weight="1"
        />
        <ImageView android:id="@+id/profile_badge_line2"
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:layout_weight="0"
            android:layout_marginStart="4dp"
            android:scaleType="fitCenter"
            android:visibility="gone"
            />
    </LinearLayout>
    <ProgressBar
        android:id="@android:id/progress"
        android:layout_width="match_parent"
Loading