From 938590c0b1ae4f4f80eb745fd3b39861b3d0b17e Mon Sep 17 00:00:00 2001 From: Howard Chen Date: Wed, 8 Sep 2021 04:29:55 +0000 Subject: [PATCH] Revert "Correct RTL support of Smart Actions" This reverts commit 8dab480298d26cb1a2dec5999f7416763e3bb900. Reason for revert: b/199225554 Bug: 199225554 Change-Id: I207659037c36bd7cf55ad3186e45d3e112f18b8d --- .../res/layout/smart_action_button.xml | 4 ++-- .../SystemUI/res/layout/smart_reply_button.xml | 4 ++-- .../policy/SmartReplyStateInflater.kt | 2 +- .../statusbar/policy/SmartReplyView.java | 18 +++++++++--------- .../statusbar/policy/SmartReplyViewTest.java | 18 ++++++++++++++---- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/packages/SystemUI/res/layout/smart_action_button.xml b/packages/SystemUI/res/layout/smart_action_button.xml index 4e5785d284ee3..488be3a4479e3 100644 --- a/packages/SystemUI/res/layout/smart_action_button.xml +++ b/packages/SystemUI/res/layout/smart_action_button.xml @@ -29,8 +29,8 @@ android:textSize="@dimen/smart_reply_button_font_size" android:lineSpacingExtra="@dimen/smart_reply_button_line_spacing_extra" android:textColor="@color/smart_reply_button_text" - android:paddingStart="@dimen/smart_reply_button_action_padding_left" - android:paddingEnd="@dimen/smart_reply_button_padding_horizontal" + android:paddingLeft="@dimen/smart_reply_button_action_padding_left" + android:paddingRight="@dimen/smart_reply_button_padding_horizontal" android:drawablePadding="@dimen/smart_action_button_icon_padding" android:textStyle="normal" android:ellipsize="none"/> diff --git a/packages/SystemUI/res/layout/smart_reply_button.xml b/packages/SystemUI/res/layout/smart_reply_button.xml index b24362febbdd3..ddf16e0afed77 100644 --- a/packages/SystemUI/res/layout/smart_reply_button.xml +++ b/packages/SystemUI/res/layout/smart_reply_button.xml @@ -31,7 +31,7 @@ android:textSize="@dimen/smart_reply_button_font_size" android:lineSpacingExtra="@dimen/smart_reply_button_line_spacing_extra" android:textColor="@color/smart_reply_button_text" - android:paddingStart="@dimen/smart_reply_button_padding_horizontal" - android:paddingEnd="@dimen/smart_reply_button_padding_horizontal" + android:paddingLeft="@dimen/smart_reply_button_padding_horizontal" + android:paddingRight="@dimen/smart_reply_button_padding_horizontal" android:textStyle="normal" android:ellipsize="none"/> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyStateInflater.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyStateInflater.kt index 21d03386b9e27..b563d86f65b1a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyStateInflater.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyStateInflater.kt @@ -311,7 +311,7 @@ interface SmartActionInflater { setBounds(0, 0, newIconSize, newIconSize) } // Add the action icon to the Smart Action button. - setCompoundDrawablesRelative(iconDrawable, null, null, null) + setCompoundDrawables(iconDrawable, null, null, null) val onClickListener = View.OnClickListener { onSmartActionClick(entry, smartActions, actionIndex, action) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java index a3e27bebd1d58..4e33529f3c36f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java @@ -503,15 +503,15 @@ public class SmartReplyView extends ViewGroup { } /** - * Returns the combined width of the start drawable (the action icon) and the padding between - * the drawable and the button text. + * Returns the combined width of the left drawable (the action icon) and the padding between the + * drawable and the button text. */ - private int getStartCompoundDrawableWidthWithPadding(Button button) { - Drawable[] drawables = button.getCompoundDrawablesRelative(); - Drawable startDrawable = drawables[0]; - if (startDrawable == null) return 0; + private int getLeftCompoundDrawableWidthWithPadding(Button button) { + Drawable[] drawables = button.getCompoundDrawables(); + Drawable leftDrawable = drawables[0]; + if (leftDrawable == null) return 0; - return startDrawable.getBounds().width() + button.getCompoundDrawablePadding(); + return leftDrawable.getBounds().width() + button.getCompoundDrawablePadding(); } private int squeezeButtonToTextWidth(Button button, int heightMeasureSpec, int textWidth) { @@ -520,8 +520,8 @@ public class SmartReplyView extends ViewGroup { // Re-measure the squeezed smart reply button. clearLayoutLineCount(button); final int widthMeasureSpec = MeasureSpec.makeMeasureSpec( - button.getPaddingStart() + button.getPaddingEnd() + textWidth - + getStartCompoundDrawableWidthWithPadding(button), MeasureSpec.AT_MOST); + button.getPaddingLeft() + button.getPaddingRight() + textWidth + + getLeftCompoundDrawableWidthWithPadding(button), MeasureSpec.AT_MOST); button.measure(widthMeasureSpec, heightMeasureSpec); final int newWidth = button.getMeasuredWidth(); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java index ac04fa7e87b1c..32aee2bd6554d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/SmartReplyViewTest.java @@ -581,6 +581,8 @@ public class SmartReplyViewTest extends SysuiTestCase { // devices. layout.setBaselineAligned(false); + final boolean isRtl = mView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL; + // Add smart replies Button previous = null; SmartReplyView.SmartReplies smartReplies = @@ -600,7 +602,11 @@ public class SmartReplyViewTest extends SysuiTestCase { if (previous != null) { ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) previous.getLayoutParams(); - lp.setMarginEnd(mSpacing); + if (isRtl) { + lp.leftMargin = mSpacing; + } else { + lp.rightMargin = mSpacing; + } } layout.addView(current); previous = current; @@ -624,7 +630,11 @@ public class SmartReplyViewTest extends SysuiTestCase { if (previous != null) { ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) previous.getLayoutParams(); - lp.setMarginEnd(mSpacing); + if (isRtl) { + lp.leftMargin = mSpacing; + } else { + lp.rightMargin = mSpacing; + } } layout.addView(current); previous = current; @@ -923,8 +933,8 @@ public class SmartReplyViewTest extends SysuiTestCase { .collect(Collectors.toList()); Button singleLineButton = buttons.get(0); Button doubleLineButton = buttons.get(1); - Drawable singleLineDrawable = singleLineButton.getCompoundDrawablesRelative()[0]; // start - Drawable doubleLineDrawable = doubleLineButton.getCompoundDrawablesRelative()[0]; // start + Drawable singleLineDrawable = singleLineButton.getCompoundDrawables()[0]; // left drawable + Drawable doubleLineDrawable = doubleLineButton.getCompoundDrawables()[0]; // left drawable assertEquals(singleLineDrawable.getBounds().width(), doubleLineDrawable.getBounds().width()); assertEquals(singleLineDrawable.getBounds().height(),