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

Commit 132876cf authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge "RTL for NotificationHeader now working correctly."

parents 0c35fbcf cb445686
Loading
Loading
Loading
Loading
+34 −15
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ import java.util.ArrayList;
 * @hide
 */
@RemoteViews.RemoteView
public class NotificationHeaderView extends LinearLayout {
public class NotificationHeaderView extends ViewGroup {
    public static final int NO_COLOR = -1;
    private final int mHeaderMinWidth;
    private final int mExpandTopPadding;
@@ -134,27 +134,46 @@ public class NotificationHeaderView extends LinearLayout {

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        super.onLayout(changed, l, t, r, b);
        if (mProfileBadge.getVisibility() != View.GONE) {
        int left = getPaddingStart();
        int childCount = getChildCount();
        int ownHeight = getHeight() - getPaddingTop() - getPaddingBottom();
        for (int i = 0; i < childCount; i++) {
            View child = getChildAt(i);
            if (child.getVisibility() == GONE) {
                continue;
            }
            int childHeight = child.getMeasuredHeight();
            MarginLayoutParams params = (MarginLayoutParams) child.getLayoutParams();
            left += params.getMarginStart();
            int right = left + child.getMeasuredWidth();
            int top = (int) (getPaddingTop() + (ownHeight - childHeight) / 2.0f);
            int bottom = top + childHeight;
            int layoutLeft = left;
            int layoutRight = right;
            if (child == mProfileBadge) {
                int paddingEnd = getPaddingEnd();
                if (mShowWorkBadgeAtEnd) {
                    paddingEnd = mContentEndMargin;
                }
                layoutRight = getWidth() - paddingEnd;
                layoutLeft = layoutRight - child.getMeasuredWidth();
            }
            if (getLayoutDirection() == LAYOUT_DIRECTION_RTL) {
                mProfileBadge.layout(paddingEnd,
                        mProfileBadge.getTop(),
                        paddingEnd + mProfileBadge.getMeasuredWidth(),
                        mProfileBadge.getBottom());
            } else {
                mProfileBadge.layout(getWidth() - paddingEnd - mProfileBadge.getMeasuredWidth(),
                        mProfileBadge.getTop(),
                        getWidth() - paddingEnd,
                        mProfileBadge.getBottom());
                int ltrLeft = layoutLeft;
                layoutLeft = getWidth() - layoutRight;
                layoutRight = getWidth() - ltrLeft;
            }
            child.layout(layoutLeft, top, layoutRight, bottom);
            left = right + params.getMarginEnd();
        }
        updateTouchListener();
    }

    @Override
    public LayoutParams generateLayoutParams(AttributeSet attrs) {
        return new ViewGroup.MarginLayoutParams(getContext(), attrs);
    }

    private void updateTouchListener() {
        if (mExpandClickListener != null) {
            mTouchListener.bindTouchRects();
+0 −2
Original line number Diff line number Diff line
@@ -22,8 +22,6 @@
    android:layout_width="wrap_content"
    android:layout_height="48dp"
    android:clipChildren="false"
    android:layout_gravity="start|top"
    android:gravity="center_vertical"
    android:paddingTop="5dp"
    android:paddingBottom="16dp"
    android:paddingStart="@dimen/notification_content_margin_start"
+12 −4
Original line number Diff line number Diff line
@@ -197,9 +197,13 @@ public class NotificationContentView extends FrameLayout {
                if (expandedSize != collapsedSize) {
                    int paddingEnd = contractedHeader.getMeasuredWidth() - expandedSize;
                    contractedHeader.setPadding(
                            isLayoutRtl() ? paddingEnd : contractedHeader.getPaddingLeft(),
                            contractedHeader.isLayoutRtl()
                                    ? paddingEnd
                                    : contractedHeader.getPaddingLeft(),
                            contractedHeader.getPaddingTop(),
                            isLayoutRtl() ? contractedHeader.getPaddingLeft() : paddingEnd,
                            contractedHeader.isLayoutRtl()
                                    ? contractedHeader.getPaddingLeft()
                                    : paddingEnd,
                            contractedHeader.getPaddingBottom());
                    contractedHeader.setShowWorkBadgeAtEnd(true);
                    return true;
@@ -208,9 +212,13 @@ public class NotificationContentView extends FrameLayout {
                int paddingEnd = mNotificationContentMarginEnd;
                if (contractedHeader.getPaddingEnd() != paddingEnd) {
                    contractedHeader.setPadding(
                            isLayoutRtl() ? paddingEnd : contractedHeader.getPaddingLeft(),
                            contractedHeader.isLayoutRtl()
                                    ? paddingEnd
                                    : contractedHeader.getPaddingLeft(),
                            contractedHeader.getPaddingTop(),
                            isLayoutRtl() ? contractedHeader.getPaddingLeft() : paddingEnd,
                            contractedHeader.isLayoutRtl()
                                    ? contractedHeader.getPaddingLeft()
                                    : paddingEnd,
                            contractedHeader.getPaddingBottom());
                    contractedHeader.setShowWorkBadgeAtEnd(false);
                    return true;