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

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

[Notif redesign] Expander: center numbered layout better

Reduce the end padding when the number is showing, to better account for
the built-in spacing of the expander icon.

Bug: 378660052
Test: visual test with both RTL and LTR languages, screenshot tests to come later
Flag: android.app.notifications_redesign_templates
Change-Id: I3ecede3c0c0ec597d7907d081072c8dbff5a1b89
parent e247cd04
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -27,12 +27,12 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.util.AttributeSet;
import android.view.RemotableViewMethod;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RemoteViews;
import android.widget.TextView;

@@ -49,6 +49,7 @@ public class NotificationExpandButton extends FrameLayout {
    private Drawable mPillDrawable;
    private TextView mNumberView;
    private ImageView mIconView;
    private LinearLayout mPillView;
    private boolean mExpanded;
    private int mNumber;
    private int mDefaultPillColor;
@@ -78,8 +79,8 @@ public class NotificationExpandButton extends FrameLayout {
    protected void onFinishInflate() {
        super.onFinishInflate();

        final View pillView = findViewById(R.id.expand_button_pill);
        final LayerDrawable layeredPill = (LayerDrawable) pillView.getBackground();
        mPillView = findViewById(R.id.expand_button_pill);
        final LayerDrawable layeredPill = (LayerDrawable) mPillView.getBackground();
        mPillDrawable = layeredPill.findDrawableByLayerId(R.id.expand_button_pill_colorized_layer);
        mNumberView = findViewById(R.id.expand_button_number);
        mIconView = findViewById(R.id.expand_button_icon);
@@ -166,8 +167,29 @@ public class NotificationExpandButton extends FrameLayout {
            mNumberView.setVisibility(GONE);
        }

        // changing number can affect the color
        // changing number can affect the color and padding
        updateColors();
        updatePadding();
    }

    private void updatePadding() {
        if (!notificationsRedesignTemplates()) {
            return;
        }

        // Reduce the padding at the end when showing the number, since the arrow icon has more
        // inherent spacing than the number does. This makes the content look more centered.
        // Vertical padding remains unchanged.
        int reducedPadding = getResources().getDimensionPixelSize(
                R.dimen.notification_2025_expand_button_reduced_end_padding);
        int normalPadding = getResources().getDimensionPixelSize(
                R.dimen.notification_2025_expand_button_horizontal_icon_padding);
        mPillView.setPaddingRelative(
                /* start = */ normalPadding,
                /* top = */ mPillView.getPaddingTop(),
                /* end = */ shouldShowNumber() ? reducedPadding : normalPadding,
                /* bottom = */ mPillView.getPaddingBottom()
        );
    }

    private void updateColors() {
+3 −0
Original line number Diff line number Diff line
@@ -408,6 +408,9 @@
    <!-- the padding of the expand icon in the notification header -->
    <dimen name="notification_2025_expand_button_horizontal_icon_padding">6dp</dimen>

    <!-- a smaller padding for the end of the expand button, for use when showing the number -->
    <dimen name="notification_2025_expand_button_reduced_end_padding">4dp</dimen>

    <!-- the size of the notification close button -->
    <dimen name="notification_close_button_size">16dp</dimen>

+2 −0
Original line number Diff line number Diff line
@@ -3246,6 +3246,8 @@
  <java-symbol type="dimen" name="notification_content_margin" />
  <java-symbol type="dimen" name="notification_2025_margin" />
  <java-symbol type="dimen" name="notification_2025_content_margin_top" />
  <java-symbol type="dimen" name="notification_2025_expand_button_horizontal_icon_padding" />
  <java-symbol type="dimen" name="notification_2025_expand_button_reduced_end_padding" />
  <java-symbol type="dimen" name="notification_progress_margin_horizontal" />
  <java-symbol type="dimen" name="notification_header_background_height" />
  <java-symbol type="dimen" name="notification_header_touchable_height" />