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

Commit 87257cbb authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Fix the placement of the work profile and feedback badges.

* Removed some dead code from NotificationTopLineView
* Icons appear left-aligned, as they do with conversations
* Fixed the order (also with conversations) to ensure that
  the 'alerted' icon disappearing doesn't cause movement
  (at least when the header text fits; otherwise some
  amount of movement is unavoidable).

Bug: 163626038
Test: manual
Change-Id: I8e19dd504f8c861f752cd2705048f015ab0e3106
parent 6f96b0b7
Loading
Loading
Loading
Loading
+8 −34
Original line number Diff line number Diff line
@@ -26,9 +26,6 @@ import android.widget.RemoteViews;

import com.android.internal.R;

import java.util.Arrays;
import java.util.List;

/**
 * The top line of content in a notification view.
 * This includes the text views and badges but excludes the icon and the expander.
@@ -39,17 +36,14 @@ import java.util.List;
public class NotificationTopLineView extends ViewGroup {
    private final int mGravityY;
    private final int mChildMinWidth;
    private final int mContentEndMargin;
    @Nullable private View mAppName;
    @Nullable private View mTitle;
    private View mHeaderText;
    private View mSecondaryHeaderText;
    private OnClickListener mFeedbackListener;
    private HeaderTouchListener mTouchListener = new HeaderTouchListener();
    private View mProfileBadge;
    private View mFeedbackIcon;
    private int mHeaderTextMarginEnd;
    private List<View> mIconsAtEnd;

    private int mMaxAscent;
    private int mMaxDescent;
@@ -72,7 +66,6 @@ public class NotificationTopLineView extends ViewGroup {
        super(context, attrs, defStyleAttr, defStyleRes);
        Resources res = getResources();
        mChildMinWidth = res.getDimensionPixelSize(R.dimen.notification_header_shrink_min_width);
        mContentEndMargin = res.getDimensionPixelSize(R.dimen.notification_content_margin_end);

        // NOTE: Implementation only supports TOP, BOTTOM, and CENTER_VERTICAL gravities,
        // with CENTER_VERTICAL being the default.
@@ -96,9 +89,7 @@ public class NotificationTopLineView extends ViewGroup {
        mTitle = findViewById(R.id.title);
        mHeaderText = findViewById(R.id.header_text);
        mSecondaryHeaderText = findViewById(R.id.header_text_secondary);
        mProfileBadge = findViewById(R.id.profile_badge);
        mFeedbackIcon = findViewById(R.id.feedback);
        mIconsAtEnd = Arrays.asList(mProfileBadge, mFeedbackIcon);
    }

    @Override
@@ -111,7 +102,6 @@ public class NotificationTopLineView extends ViewGroup {
        int wrapContentHeightSpec = MeasureSpec.makeMeasureSpec(givenHeight,
                MeasureSpec.AT_MOST);
        int totalWidth = getPaddingStart();
        int iconWidth = getPaddingEnd();
        int maxChildHeight = -1;
        mMaxAscent = -1;
        mMaxDescent = -1;
@@ -127,12 +117,7 @@ public class NotificationTopLineView extends ViewGroup {
            int childHeightSpec = getChildMeasureSpec(wrapContentHeightSpec,
                    lp.topMargin + lp.bottomMargin, lp.height);
            child.measure(childWidthSpec, childHeightSpec);
            // Icons that should go at the end
            if (mIconsAtEnd.contains(child)) {
                iconWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth();
            } else {
            totalWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth();
            }
            int childBaseline = child.getBaseline();
            int childHeight = child.getMeasuredHeight();
            if (childBaseline != -1) {
@@ -143,7 +128,7 @@ public class NotificationTopLineView extends ViewGroup {
        }

        // Ensure that there is at least enough space for the icons
        int endMargin = Math.max(mHeaderTextMarginEnd, iconWidth);
        int endMargin = Math.max(mHeaderTextMarginEnd, getPaddingEnd());
        if (totalWidth > givenWidth - endMargin) {
            int overFlow = totalWidth - givenWidth + endMargin;
            if (mAppName != null) {
@@ -184,7 +169,6 @@ public class NotificationTopLineView extends ViewGroup {
    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        int left = getPaddingStart();
        int end = getMeasuredWidth();
        int childCount = getChildCount();
        int ownHeight = b - t;
        int childSpace = ownHeight - mPaddingTop - mPaddingBottom;
@@ -238,22 +222,12 @@ public class NotificationTopLineView extends ViewGroup {
                    childTop = mPaddingTop;
            }

            // Icons that should go at the end
            if (mIconsAtEnd.contains(child)) {
                if (end == getMeasuredWidth()) {
                    layoutRight = end - mContentEndMargin;
                } else {
                    layoutRight = end - params.getMarginEnd();
                }
                layoutLeft = layoutRight - child.getMeasuredWidth();
                end = layoutLeft - params.getMarginStart();
            } else {
            left += params.getMarginStart();
            int right = left + child.getMeasuredWidth();
            layoutLeft = left;
            layoutRight = right;
            left = right + params.getMarginEnd();
            }

            if (getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
                int ltrLeft = layoutLeft;
                layoutLeft = getWidth() - layoutRight;
+24 −21
Original line number Diff line number Diff line
@@ -207,17 +207,19 @@
                        android:visibility="gone"
                    />

                    <ImageView
                        android:id="@+id/alerted_icon"
                        android:layout_width="@dimen/notification_alerted_size"
                        android:layout_height="@dimen/notification_alerted_size"
                    <ImageButton
                        android:id="@+id/feedback"
                        android:layout_width="@dimen/notification_feedback_size"
                        android:layout_height="@dimen/notification_feedback_size"
                        android:layout_gravity="center"
                        android:layout_marginStart="4dp"
                        android:layout_marginStart="@dimen/notification_header_separating_margin"
                        android:background="?android:selectableItemBackgroundBorderless"
                        android:contentDescription="@string/notification_feedback_indicator"
                        android:paddingTop="2dp"
                        android:scaleType="fitCenter"
                        android:src="@drawable/ic_feedback_indicator"
                        android:visibility="gone"
                        android:contentDescription="@string/notification_alerted_content_description"
                        android:src="@drawable/ic_notifications_alerted"/>
                        />

                    <ImageView
                        android:id="@+id/profile_badge"
@@ -230,6 +232,20 @@
                        android:visibility="gone"
                        android:contentDescription="@string/notification_work_profile_content_description"
                        />

                    <ImageView
                        android:id="@+id/alerted_icon"
                        android:layout_width="@dimen/notification_alerted_size"
                        android:layout_height="@dimen/notification_alerted_size"
                        android:layout_gravity="center"
                        android:layout_marginStart="4dp"
                        android:contentDescription="@string/notification_alerted_content_description"
                        android:paddingTop="2dp"
                        android:scaleType="fitCenter"
                        android:src="@drawable/ic_notifications_alerted"
                        android:visibility="gone"
                        />

                    <LinearLayout
                        android:id="@+id/app_ops"
                        android:layout_height="wrap_content"
@@ -269,19 +285,6 @@
                            android:contentDescription="@string/notification_appops_overlay_active"
                            />
                    </LinearLayout>
                    <ImageButton
                        android:id="@+id/feedback"
                        android:layout_width="@dimen/notification_feedback_size"
                        android:layout_height="@dimen/notification_feedback_size"
                        android:layout_marginStart="@dimen/notification_header_separating_margin"
                        android:paddingTop="2dp"
                        android:layout_gravity="center"
                        android:scaleType="fitCenter"
                        android:src="@drawable/ic_feedback_indicator"
                        android:background="?android:selectableItemBackgroundBorderless"
                        android:visibility="gone"
                        android:contentDescription="@string/notification_feedback_indicator"
                    />
                </LinearLayout>

                <!-- Messages -->
+12 −12
Original line number Diff line number Diff line
@@ -98,18 +98,6 @@
        android:visibility="gone"
        />

    <ImageView
        android:id="@+id/alerted_icon"
        android:layout_width="@dimen/notification_alerted_size"
        android:layout_height="@dimen/notification_alerted_size"
        android:layout_marginStart="4dp"
        android:baseline="10dp"
        android:scaleType="fitCenter"
        android:visibility="gone"
        android:contentDescription="@string/notification_alerted_content_description"
        android:src="@drawable/ic_notifications_alerted"
        />

    <ImageButton
        android:id="@+id/feedback"
        android:layout_width="@dimen/notification_feedback_size"
@@ -134,5 +122,17 @@
        android:visibility="gone"
        android:contentDescription="@string/notification_work_profile_content_description"
        />

    <ImageView
        android:id="@+id/alerted_icon"
        android:layout_width="@dimen/notification_alerted_size"
        android:layout_height="@dimen/notification_alerted_size"
        android:layout_marginStart="4dp"
        android:baseline="10dp"
        android:contentDescription="@string/notification_alerted_content_description"
        android:scaleType="fitCenter"
        android:src="@drawable/ic_notifications_alerted"
        android:visibility="gone"
        />
</merge>