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

Commit fa2c7b5f authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

[Notif redesign] Change top margin calculation

Although obtainStyledAttributes is a valid way of obtaining the font
size, it's a final method and causing a bunch of issues with tests that
use a mocked/fake context and try to build notifications. Let's use the
size dimension directly instead.

Bug: 396421144
Test: CarrierServiceStateTrackerTest
Flag: android.app.notifications_redesign_templates
Change-Id: I3e4367eb5aeee2cc5fc4bcaa74f63a0e87c356c1
parent a52e9e11
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -6594,13 +6594,8 @@ public class Notification implements Parcelable
            int notifMargin = resources.getDimensionPixelSize(R.dimen.notification_2025_margin);
            // Spacing between the text lines, scaling with the font size (originally in sp)
            int spacing = resources.getDimensionPixelSize(spacingRes);
            // Size of the text in the notification top line (originally in sp)
            int[] textSizeAttr = new int[] { android.R.attr.textSize };
            TypedArray typedArray = context.obtainStyledAttributes(
                    R.style.TextAppearance_DeviceDefault_Notification_Info, textSizeAttr);
            int textSize = typedArray.getDimensionPixelSize(0 /* index */, -1 /* default */);
            typedArray.recycle();
            int textSize = resources.getDimensionPixelSize(R.dimen.notification_subtext_size);
            // Adding up all the values as pixels
            return notifMargin + spacing + textSize;