From cb667da70bdddb05fd05a102234f0ab61c6e7515 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Tue, 18 May 2021 16:53:02 -0400 Subject: [PATCH 1/3] Fix size of RemoteInputView to for a11y Fixes: 164065068 Fixes: 186590902 Test: talkback inspection of targets, etc. Change-Id: I594c9bd0ddccfa436fd8346361afe0449c001710 --- .../drawable/remote_input_view_text_bg.xml | 4 +-- packages/SystemUI/res/layout/remote_input.xml | 32 ++++++++++--------- .../statusbar/policy/RemoteInputView.java | 15 ++------- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/packages/SystemUI/res/drawable/remote_input_view_text_bg.xml b/packages/SystemUI/res/drawable/remote_input_view_text_bg.xml index 5d374a98ae481..535b35497b5c5 100644 --- a/packages/SystemUI/res/drawable/remote_input_view_text_bg.xml +++ b/packages/SystemUI/res/drawable/remote_input_view_text_bg.xml @@ -21,10 +21,10 @@ android:width="@dimen/remote_input_view_text_stroke" android:color="?android:attr/colorAccent"/> + android:top="0dp"/> diff --git a/packages/SystemUI/res/layout/remote_input.xml b/packages/SystemUI/res/layout/remote_input.xml index a909d0d4d3c24..a5b2f80a31587 100644 --- a/packages/SystemUI/res/layout/remote_input.xml +++ b/packages/SystemUI/res/layout/remote_input.xml @@ -28,18 +28,18 @@ android:id="@+id/remote_input_content" android:orientation="vertical" android:clipToPadding="false" - android:layout_marginEnd="20dp" - android:layout_marginStart="20dp" + android:layout_marginEnd="0dp" + android:layout_marginStart="16dp" android:layout_marginTop="5dp" android:layout_marginBottom="16dp" android:layout_weight="1"> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java index c3b9c7bf89f24..ca5d6df4f0a72 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java @@ -35,7 +35,6 @@ import android.graphics.BlendMode; import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.Rect; -import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.GradientDrawable; import android.net.Uri; import android.os.Bundle; @@ -228,8 +227,6 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene alternateTextColor = ta.getColor(3, backgroundColor); } } - mEditText.setAllColors(backgroundColor, editBgColor, - accentColor, textColor, hintTextColor); final ColorStateList accentTint = new ColorStateList(new int[][]{ new int[]{com.android.internal.R.attr.state_enabled}, new int[]{}, @@ -237,6 +234,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene accentColor, accentColor & 0x4DFFFFFF // %30 opacity }); + mEditText.setAllColors(accentColor, textColor, hintTextColor); mContentBackground.setColor(editBgColor); mContentBackground.setStroke(stroke, accentTint); mDelete.setImageTintList(ColorStateList.valueOf(alternateTextColor)); @@ -875,7 +873,6 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene private final OnReceiveContentListener mOnReceiveContentListener = this::onReceiveContent; private RemoteInputView mRemoteInputView; - private ColorDrawable mBackground; boolean mShowImeOnInputConnection; private LightBarController mLightBarController; private InputMethodManager mInputMethodManager; @@ -885,8 +882,6 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene public RemoteEditText(Context context, AttributeSet attrs) { super(context, attrs); mLightBarController = Dependency.get(LightBarController.class); - - mBackground = new ColorDrawable(); } void setSupportedMimeTypes(@Nullable Collection mimeTypes) { @@ -1045,9 +1040,6 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene if (focusable) { requestFocus(); - setBackground(mBackground); - } else { - setBackground(null); } } @@ -1062,10 +1054,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene return remainingItems; } - protected void setAllColors(int backgroundColor, int editBackgroundColor, - int accentColor, int textColor, int hintTextColor) { - setBackgroundColor(editBackgroundColor); - mBackground.setColor(editBackgroundColor); + protected void setAllColors(int accentColor, int textColor, int hintTextColor) { setTextColor(textColor); setHintTextColor(hintTextColor); getTextCursorDrawable().setColorFilter(accentColor, PorterDuff.Mode.SRC_IN); From fafbfcc17681ba242f64e7a8441b99097bd0c755 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Wed, 19 May 2021 10:21:03 -0400 Subject: [PATCH 2/3] Allow sending inline reply of just an image Fixes: 188651569 Test: manual w/ notify Change-Id: I57bc2021562edcedead19a2207781fe8e39f37dc --- .../systemui/statusbar/policy/RemoteInputView.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java index ca5d6df4f0a72..5ed95f6139eca 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java @@ -309,6 +309,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene } else { attachment.setVisibility(VISIBLE); } + updateSendButton(); } /** @@ -330,6 +331,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene results); mEntry.remoteInputText = mEditText.getText(); + // TODO(b/188646667): store attachment to entry mEntry.remoteInputUri = null; mEntry.remoteInputMimeType = null; @@ -366,6 +368,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene : "\"" + attachmentLabel + "\" " + mEditText.getText(); mEntry.remoteInputText = fullText; + // TODO(b/188646667): store attachment to entry mEntry.remoteInputMimeType = contentType; mEntry.remoteInputUri = data; @@ -468,6 +471,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene private void onDefocus(boolean animate, boolean logClose) { mController.removeRemoteInput(mEntry, mToken); mEntry.remoteInputText = mEditText.getText(); + // TODO(b/188646667): store attachment to entry // During removal, we get reattached and lose focus. Not hiding in that // case to prevent flicker. @@ -555,6 +559,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene mEntry.editedSuggestionInfo = editedSuggestionInfo; if (editedSuggestionInfo != null) { mEntry.remoteInputText = editedSuggestionInfo.originalText; + // TODO(b/188646667): store attachment to entry } } @@ -594,9 +599,10 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene mEditText.setInnerFocusable(true); mEditText.mShowImeOnInputConnection = true; mEditText.setText(mEntry.remoteInputText); - mEditText.setSelection(mEditText.getText().length()); + mEditText.setSelection(mEditText.length()); mEditText.requestFocus(); mController.addRemoteInput(mEntry, mToken); + // TODO(b/188646667): restore attachment from entry mRemoteInputQuickSettingsDisabler.setRemoteInputActive(true); @@ -619,6 +625,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene private void reset() { mResetting = true; mEntry.remoteInputTextWhenReset = SpannedString.valueOf(mEditText.getText()); + // TODO(b/188646667): store attachment at time of reset to entry mEditText.getText().clear(); mEditText.setEnabled(true); @@ -627,6 +634,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene mController.removeSpinning(mEntry.getKey(), mToken); updateSendButton(); onDefocus(false /* animate */, false /* logClose */); + // TODO(b/188646667): clear attachment mResetting = false; } @@ -643,7 +651,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene } private void updateSendButton() { - mSendButton.setEnabled(mEditText.getText().length() != 0); + mSendButton.setEnabled(mEditText.length() != 0 || mAttachment != null); } public void close() { @@ -910,6 +918,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene // our focus, so we'll need to save our text here. if (mRemoteInputView != null) { mRemoteInputView.mEntry.remoteInputText = getText(); + // TODO(b/188646667): store attachment to entry } } return; From fd88da4a725012956af71047d86a4912cb57ad80 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Wed, 19 May 2021 12:37:44 -0400 Subject: [PATCH 3/3] Fix colors to match the spec, and resolve contrast issues. Fixes: 164065068 Test: Check reply in colorized, dark, light, including inline images. Change-Id: I905d0ddb2f713f6fdfea8c43511f0fe4edbd8512 --- .../SystemUI/res/color/remote_input_send.xml | 4 +- .../SystemUI/res/color/remote_input_text.xml | 4 +- .../statusbar/policy/RemoteInputView.java | 87 ++++++++++--------- 3 files changed, 48 insertions(+), 47 deletions(-) diff --git a/packages/SystemUI/res/color/remote_input_send.xml b/packages/SystemUI/res/color/remote_input_send.xml index bd91ef9785d16..4dcd3dd229fbd 100644 --- a/packages/SystemUI/res/color/remote_input_send.xml +++ b/packages/SystemUI/res/color/remote_input_send.xml @@ -16,6 +16,6 @@ --> - - + + \ No newline at end of file diff --git a/packages/SystemUI/res/color/remote_input_text.xml b/packages/SystemUI/res/color/remote_input_text.xml index 3622c910b78b4..13bb1d7cbe7da 100644 --- a/packages/SystemUI/res/color/remote_input_text.xml +++ b/packages/SystemUI/res/color/remote_input_text.xml @@ -16,6 +16,6 @@ --> - - + + \ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java index 5ed95f6139eca..7022fb13d2cd9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java @@ -186,6 +186,16 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene ta.recycle(); } + private ColorStateList colorStateListWithDisabledAlpha(int color, int disabledAlpha) { + return new ColorStateList(new int[][]{ + new int[]{-com.android.internal.R.attr.state_enabled}, // disabled + new int[]{}, + }, new int[]{ + ColorUtils.setAlphaComponent(color, disabledAlpha), + color + }); + } + /** * The remote view needs to adapt to colorized notifications when set * It overrides the background of itself as well as all of its childern @@ -196,54 +206,50 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene mColorized = colorized; mTint = backgroundColor; final int editBgColor; - final int alternateBgColor; - final int alternateTextColor; - final int accentColor; - final int textColor; - final int hintTextColor; - final int stroke = mContext.getResources().getDimensionPixelSize( - R.dimen.remote_input_view_text_stroke); + final int deleteBgColor; + final int deleteFgColor; + final ColorStateList accentColor; + final ColorStateList textColor; + final int hintColor; + final int stroke = colorized ? mContext.getResources().getDimensionPixelSize( + R.dimen.remote_input_view_text_stroke) : 0; if (colorized) { final boolean dark = !ContrastColorUtil.isColorLight(backgroundColor); final int foregroundColor = dark ? Color.WHITE : Color.BLACK; + final int inverseColor = dark ? Color.BLACK : Color.WHITE; editBgColor = backgroundColor; - accentColor = foregroundColor; - alternateBgColor = foregroundColor; - alternateTextColor = backgroundColor; - textColor = foregroundColor; - hintTextColor = ColorUtils.setAlphaComponent(foregroundColor, 0x99); + deleteBgColor = foregroundColor; + deleteFgColor = inverseColor; + accentColor = colorStateListWithDisabledAlpha(foregroundColor, 0x4D); // 30% + textColor = colorStateListWithDisabledAlpha(foregroundColor, 0x99); // 60% + hintColor = ColorUtils.setAlphaComponent(foregroundColor, 0x99); } else { - textColor = mContext.getColor(R.color.remote_input_text); - hintTextColor = mContext.getColor(R.color.remote_input_hint); + accentColor = mContext.getColorStateList(R.color.remote_input_send); + textColor = mContext.getColorStateList(R.color.remote_input_text); + hintColor = mContext.getColor(R.color.remote_input_hint); + deleteFgColor = textColor.getDefaultColor(); try (TypedArray ta = getContext().getTheme().obtainStyledAttributes(new int[]{ - com.android.internal.R.attr.colorAccent, - com.android.internal.R.attr.colorSurface, - com.android.internal.R.attr.colorSurfaceVariant, - com.android.internal.R.attr.textColorPrimary + com.android.internal.R.attr.colorSurfaceHighlight, + com.android.internal.R.attr.colorSurfaceVariant })) { - accentColor = ta.getColor(0, textColor); - editBgColor = ta.getColor(1, backgroundColor); - alternateBgColor = ta.getColor(2, textColor); - alternateTextColor = ta.getColor(3, backgroundColor); + editBgColor = ta.getColor(0, backgroundColor); + deleteBgColor = ta.getColor(1, Color.GRAY); } } - final ColorStateList accentTint = new ColorStateList(new int[][]{ - new int[]{com.android.internal.R.attr.state_enabled}, - new int[]{}, - }, new int[]{ - accentColor, - accentColor & 0x4DFFFFFF // %30 opacity - }); - mEditText.setAllColors(accentColor, textColor, hintTextColor); + + mEditText.setTextColor(textColor); + mEditText.setHintTextColor(hintColor); + mEditText.getTextCursorDrawable().setColorFilter( + accentColor.getDefaultColor(), PorterDuff.Mode.SRC_IN); mContentBackground.setColor(editBgColor); - mContentBackground.setStroke(stroke, accentTint); - mDelete.setImageTintList(ColorStateList.valueOf(alternateTextColor)); - mDeleteBg.setImageTintList(ColorStateList.valueOf(alternateBgColor)); - mSendButton.setImageTintList(accentTint); - mProgressBar.setProgressTintList(accentTint); - mProgressBar.setIndeterminateTintList(accentTint); - mProgressBar.setSecondaryProgressTintList(accentTint); - setBackgroundColor(editBgColor); + mContentBackground.setStroke(stroke, accentColor); + mDelete.setImageTintList(ColorStateList.valueOf(deleteFgColor)); + mDeleteBg.setImageTintList(ColorStateList.valueOf(deleteBgColor)); + mSendButton.setImageTintList(accentColor); + mProgressBar.setProgressTintList(accentColor); + mProgressBar.setIndeterminateTintList(accentColor); + mProgressBar.setSecondaryProgressTintList(accentColor); + setBackgroundColor(backgroundColor); } @Override @@ -1063,10 +1069,5 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene return remainingItems; } - protected void setAllColors(int accentColor, int textColor, int hintTextColor) { - setTextColor(textColor); - setHintTextColor(hintTextColor); - getTextCursorDrawable().setColorFilter(accentColor, PorterDuff.Mode.SRC_IN); - } } }