Inline reply multiline + notif pill

Bug: b/182577304
Bug: b/181048615
Fixes: b/183646293
Test: manually test notifications
Change-Id: If2568cb445a3d1c458bbe5ee1fe7d61e6ffa87a8
diff --git a/packages/SystemUI/res/color/remote_input_hint.xml b/packages/SystemUI/res/color/remote_input_hint.xml
new file mode 100644
index 0000000..7fe58db
--- /dev/null
+++ b/packages/SystemUI/res/color/remote_input_hint.xml
@@ -0,0 +1,19 @@
+<!--
+  ~ Copyright (C) 2021 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:color="?android:attr/textColorPrimary" android:alpha=".6" />
+</selector>
\ 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 33eeb77..3622c91 100644
--- a/packages/SystemUI/res/color/remote_input_text.xml
+++ b/packages/SystemUI/res/color/remote_input_text.xml
@@ -16,6 +16,6 @@
   -->
 
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:state_enabled="true" android:color="?android:attr/textColorTertiary" />
-    <item android:color="?android:attr/textColorTertiary" android:alpha=".6" />
+    <item android:state_enabled="true" android:color="?android:attr/textColorPrimary" />
+    <item android:color="?android:attr/textColorPrimary" android:alpha=".6" />
 </selector>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/notif_footer_btn_background.xml b/packages/SystemUI/res/drawable/notif_footer_btn_background.xml
new file mode 100644
index 0000000..f35f5d1
--- /dev/null
+++ b/packages/SystemUI/res/drawable/notif_footer_btn_background.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2021 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+    <solid
+        android:color="@color/notif_pill_background"
+        />
+    <corners android:radius="20dp" />
+
+    <padding
+        android:left="20dp"
+        android:right="20dp">
+    </padding>
+
+</shape>
\ No newline at end of file
diff --git a/packages/SystemUI/res/drawable/remote_input_view_text_bg.xml b/packages/SystemUI/res/drawable/remote_input_view_text_bg.xml
new file mode 100644
index 0000000..5d374a9
--- /dev/null
+++ b/packages/SystemUI/res/drawable/remote_input_view_text_bg.xml
@@ -0,0 +1,31 @@
+<!--
+  ~ Copyright (C) 2021 The Android Open Source Project
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+
+    <solid android:color="?android:attr/colorBackgroundFloating" />
+    <stroke
+        android:width="@dimen/remote_input_view_text_stroke"
+        android:color="?android:attr/colorAccent"/>
+    <padding
+        android:bottom="12dp"
+        android:left="12dp"
+        android:right="12dp"
+        android:top="12dp"/>
+
+    <corners android:radius="24dp" />
+
+</shape>
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/remote_input.xml b/packages/SystemUI/res/layout/remote_input.xml
index 43182eb..ae3adb8 100644
--- a/packages/SystemUI/res/layout/remote_input.xml
+++ b/packages/SystemUI/res/layout/remote_input.xml
@@ -25,26 +25,25 @@
 
     <view class="com.android.systemui.statusbar.policy.RemoteInputView$RemoteEditText"
             android:id="@+id/remote_input_text"
-            android:layout_height="match_parent"
+            android:layout_height="wrap_content"
             android:layout_width="0dp"
             android:layout_weight="1"
             android:paddingTop="2dp"
-            android:paddingBottom="4dp"
             android:paddingStart="16dp"
             android:paddingEnd="12dp"
-            android:layout_marginRight="5dp"
+            android:layout_marginRight="20dp"
             android:layout_marginLeft="20dp"
             android:layout_marginTop="5dp"
-            android:layout_marginBottom="20dp"
-            android:gravity="start|center_vertical"
+            android:layout_marginBottom="16dp"
+            android:layout_gravity="start|center_vertical"
             android:textAppearance="?android:attr/textAppearance"
             android:textColor="@color/remote_input_text"
             android:textColorHint="@color/remote_input_hint"
             android:textSize="16sp"
             android:background="@null"
-            android:singleLine="true"
+            android:maxLines="4"
             android:ellipsize="start"
-            android:inputType="textShortMessage|textAutoCorrect|textCapSentences"
+            android:inputType="textShortMessage|textMultiLine|textAutoCorrect|textCapSentences"
             android:imeOptions="actionSend|flagNoExtractUi|flagNoFullscreen" />
 
     <FrameLayout
@@ -53,12 +52,12 @@
             android:layout_gravity="center_vertical">
 
         <ImageButton
-                android:layout_width="wrap_content"
+        android:layout_width="wrap_content"
                 android:layout_height="match_parent"
                 android:layout_gravity="center"
-                android:paddingBottom="20dp"
-                android:paddingStart="12dp"
-                android:paddingEnd="24dp"
+                android:paddingLeft="10dp"
+                android:layout_marginBottom="12dp"
+                android:layout_marginEnd="12dp"
                 android:id="@+id/remote_input_send"
                 android:src="@drawable/ic_send"
                 android:contentDescription="@*android:string/ime_action_send"
@@ -70,9 +69,8 @@
                 android:id="@+id/remote_input_progress"
                 android:layout_width="24dp"
                 android:layout_height="24dp"
-                android:layout_marginBottom="10dp"
-                android:layout_marginEnd="6dp"
-                android:layout_gravity="center"
+                android:layout_marginBottom="12dp"
+                android:layout_gravity="center_vertical"
                 android:visibility="invisible"
                 android:indeterminate="true"
                 style="?android:attr/progressBarStyleSmall" />
diff --git a/packages/SystemUI/res/layout/status_bar_notification_footer.xml b/packages/SystemUI/res/layout/status_bar_notification_footer.xml
index 5a1e5c4..5c77d16 100644
--- a/packages/SystemUI/res/layout/status_bar_notification_footer.xml
+++ b/packages/SystemUI/res/layout/status_bar_notification_footer.xml
@@ -30,9 +30,11 @@
             style="@style/TextAppearance.NotificationSectionHeaderButton"
             android:id="@+id/manage_text"
             android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
+            android:layout_height="40dp"
             android:layout_gravity="start"
+            android:background="@drawable/notif_footer_btn_background"
             android:focusable="true"
+            android:textColor="@color/notif_pill_text"
             android:contentDescription="@string/manage_notifications_history_text"
             android:text="@string/manage_notifications_history_text"
         />
@@ -40,8 +42,9 @@
             style="@style/TextAppearance.NotificationSectionHeaderButton"
             android:id="@+id/dismiss_text"
             android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
+            android:layout_height="40dp"
             android:layout_gravity="end"
+            android:background="@drawable/notif_footer_btn_background"
             android:focusable="true"
             android:contentDescription="@string/accessibility_clear_all"
             android:text="@string/clear_all_notifications_text"
diff --git a/packages/SystemUI/res/values-night/colors.xml b/packages/SystemUI/res/values-night/colors.xml
index d571f2f..150e58b 100644
--- a/packages/SystemUI/res/values-night/colors.xml
+++ b/packages/SystemUI/res/values-night/colors.xml
@@ -33,6 +33,9 @@
     <!-- The color of the text inside a notification -->
     <color name="notification_primary_text_color">@*android:color/notification_primary_text_color_dark</color>
 
+    <color name="notif_pill_background">@android:color/system_neutral1_800</color>
+    <color name="notif_pill_text">@android:color/system_neutral1_50</color>
+
     <color name="notification_guts_link_icon_tint">@color/GM2_grey_500</color>
     <color name="notification_guts_sub_text_color">@color/GM2_grey_300</color>
     <color name="notification_guts_header_text_color">@color/GM2_grey_200</color>
diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index a773b22..c18ab14 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -151,8 +151,8 @@
     <color name="minimize_dock_shadow_end">#00000000</color>
 
     <color name="default_remote_input_background">@*android:color/notification_default_color</color>
-    <color name="remote_input_hint">#99ffffff</color>
-
+    <color name="notif_pill_background">@android:color/system_neutral2_100</color>
+    <color name="notif_pill_text">@android:color/system_neutral1_900</color>
     <color name="remote_input_accent">?android:attr/colorAccent</color>
 
     <color name="quick_step_track_background_background_dark">#1F000000</color>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 2393b74..f036be0 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -19,6 +19,8 @@
     <!-- Recommended minimum clickable element dimension -->
     <dimen name="min_clickable_item_size">48dp</dimen>
 
+    <dimen name="remote_input_view_text_stroke">3dp</dimen>
+
     <!-- Amount to offset bottom of notification peek window from top of status bar. -->
     <dimen name="peek_window_y_offset">-12dp</dimen>
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FooterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FooterView.java
index 3ec8c23..4ed5056 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FooterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FooterView.java
@@ -93,6 +93,13 @@
     @Override
     protected void onConfigurationChanged(Configuration newConfig) {
         super.onConfigurationChanged(newConfig);
+        mDismissButton.setBackground(
+                getResources().getDrawable(R.drawable.notif_footer_btn_background));
+        mDismissButton.setTextColor(getResources().getColor(R.color.notif_pill_text));
+        mManageButton.setBackground(
+                getResources().getDrawable(R.drawable.notif_footer_btn_background));
+        mManageButton.setTextColor(getResources().getColor(R.color.notif_pill_text));
+        mManageButton = findViewById(R.id.manage_text);
         mDismissButton.setText(R.string.clear_all_notifications_text);
         mDismissButton.setContentDescription(
                 mContext.getString(R.string.accessibility_clear_all));
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
index 55a27b2..c3ccba4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java
@@ -1291,9 +1291,14 @@
                     }
                 }
             }
-
-            if (existing != null && entry.getSbn().getNotification().isColorized()) {
-                existing.overrideBackgroundTintColor(entry.getSbn().getNotification().color);
+            if (existing != null) {
+                if (entry.getSbn().getNotification().isColorized()) {
+                    existing.setBackgroundTintColor(
+                            entry.getSbn().getNotification().color, true);
+                } else {
+                    existing.setBackgroundTintColor(
+                            entry.getRow().getCurrentBackgroundTint(), false);
+                }
             }
             return existing;
         }
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 f72d2ae..6e78059 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
@@ -32,7 +32,6 @@
 import android.content.pm.PackageManager;
 import android.content.pm.ShortcutManager;
 import android.content.res.ColorStateList;
-import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.graphics.Color;
 import android.graphics.Rect;
@@ -74,6 +73,7 @@
 
 import androidx.annotation.NonNull;
 
+import com.android.internal.graphics.ColorUtils;
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.nano.MetricsProto;
 import com.android.internal.statusbar.IStatusBarService;
@@ -130,6 +130,9 @@
     private int mRevealCy;
     private int mRevealR;
 
+    private boolean mColorized;
+    private int mTint;
+
     private boolean mResetting;
     private NotificationViewWrapper mWrapper;
     private Consumer<Boolean> mOnVisibilityChangedListener;
@@ -143,35 +146,63 @@
         mRemoteInputManager = Dependency.get(NotificationRemoteInputManager.class);
         mStatusBarManagerService = IStatusBarService.Stub.asInterface(
                 ServiceManager.getService(Context.STATUS_BAR_SERVICE));
+        TypedArray ta = getContext().getTheme().obtainStyledAttributes(new int[]{
+                com.android.internal.R.attr.colorAccent,
+                com.android.internal.R.attr.colorBackgroundFloating,
+        });
+        mTint = ta.getColor(0, 0);
+        ta.recycle();
     }
 
     /**
      * The remote view needs to adapt to colorized notifications when set
+     * It overrides the background of itself as well as all of its childern
      * @param color colorized notification color
      */
-    public void overrideBackgroundTintColor(int color) {
-        mEditText.setBackgroundTintColor(color);
-        final boolean dark = !ContrastColorUtil.isColorLight(color);
-        int[][] states = new int[][] {
-                new int[] {android.R.attr.state_enabled},
-                new int[] {},
+    public void setBackgroundTintColor(int color, boolean colorized) {
+        if (colorized == mColorized && color == mTint) return;
+        mColorized = colorized;
+        mTint = color;
+        final int[][] states = new int[][]{
+                new int[]{com.android.internal.R.attr.state_enabled},
+                new int[]{},
         };
+        final int[] colors;
+        if (colorized) {
+            final boolean dark = !ContrastColorUtil.isColorLight(color);
+            final int finalColor = dark
+                    ? Color.WHITE
+                    : Color.BLACK;
+            colors = new int[]{
+                    finalColor,
+                    finalColor & 0x4DFFFFFF // %30 opacity
+            };
+            mEditText.setUniformBackgroundTintColor(color);
+            mEditText.setUniformForegroundColor(finalColor);
 
-        final int finalColor = dark
-                ? Color.WHITE
-                : Color.BLACK;
-
-        int[] colors = new int[] {
-                finalColor,
-                finalColor & 0x4DFFFFFF // %30 opacity
-        };
-
-        final ColorStateList tint = new ColorStateList(states, colors);
+        } else {
+            mEditText.setTextColor(mContext.getColor(R.color.remote_input_text));
+            mEditText.setHintTextColor(mContext.getColorStateList(R.color.remote_input_hint));
+            TypedArray ta = getContext().getTheme().obtainStyledAttributes(new int[]{
+                    com.android.internal.R.attr.colorAccent,
+                    com.android.internal.R.attr.colorBackgroundFloating,
+            });
+            int colorAccent = ta.getColor(0, 0);
+            int colorBackgroundFloating = ta.getColor(1, 0);
+            ta.recycle();
+            mEditText.setTextBackgroundColors(colorAccent, colorBackgroundFloating);
+            colors = new int[]{
+                    colorAccent,
+                    colorBackgroundFloating & 0x4DFFFFFF // %30 opacity
+            };
+        }
+        mEditText.setBackgroundColor(color);
+        final ColorStateList  tint = new ColorStateList(states, colors);
         mSendButton.setImageTintList(tint);
         mProgressBar.setProgressTintList(tint);
         mProgressBar.setIndeterminateTintList(tint);
         mProgressBar.setSecondaryProgressTintList(tint);
-        mEditText.setForegroundColor(finalColor);
+        setBackgroundColor(color);
     }
 
     @Override
@@ -326,7 +357,7 @@
                 reveal.addListener(new AnimatorListenerAdapter() {
                     @Override
                     public void onAnimationEnd(Animator animation) {
-                        setVisibility(INVISIBLE);
+                        setVisibility(GONE);
                         if (mWrapper != null) {
                             mWrapper.setRemoteInputVisible(false);
                         }
@@ -334,7 +365,7 @@
                 });
                 reveal.start();
             } else {
-                setVisibility(INVISIBLE);
+                setVisibility(GONE);
                 if (mWrapper != null) {
                     mWrapper.setRemoteInputVisible(false);
                 }
@@ -398,12 +429,6 @@
         }
     }
 
-    @Override
-    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
-        mEditText.updateCornerRadius(heightMeasureSpec / 2);
-    }
-
     /** Populates the text field of the remote input with the given content. */
     public void setEditTextContent(@Nullable CharSequence editTextContent) {
         mEditText.setText(editTextContent);
@@ -700,40 +725,15 @@
         boolean mShowImeOnInputConnection;
         private LightBarController mLightBarController;
         private InputMethodManager mInputMethodManager;
-        private int mColor = Notification.COLOR_DEFAULT;
         UserHandle mUser;
-        private int mStokeWidth;
 
         public RemoteEditText(Context context, AttributeSet attrs) {
             super(context, attrs);
             mLightBarController = Dependency.get(LightBarController.class);
-            mTextBackground = createBackground(context, attrs);
+            mTextBackground = (GradientDrawable)
+                    context.getDrawable(R.drawable.remote_input_view_text_bg).mutate();
             mBackgroundColor = new ColorDrawable();
             mBackground = new LayerDrawable(new Drawable[] {mBackgroundColor, mTextBackground});
-            float density = context.getResources().getDisplayMetrics().density;
-            mStokeWidth = (int) (2 * density);
-            setDefaultColors();
-        }
-
-        private void setDefaultColors() {
-            Resources.Theme theme = getContext().getTheme();
-            TypedArray ta = theme.obtainStyledAttributes(
-                    new int[]{android.R.attr.colorAccent,
-                            com.android.internal.R.attr.colorBackgroundFloating});
-            mTextBackground.setStroke(mStokeWidth,
-                    ta.getColor(0, Notification.COLOR_DEFAULT));
-            mColor = ta.getColor(1, Notification.COLOR_DEFAULT);
-            mTextBackground.setColor(mColor);
-        }
-
-        private GradientDrawable createBackground(Context context, AttributeSet attrs) {
-            float density = context.getResources().getDisplayMetrics().density;
-            int padding = (int) (12 * density);
-            GradientDrawable d = new GradientDrawable();
-            d.setShape(GradientDrawable.RECTANGLE);
-            d.setPadding(padding, padding, padding, padding);
-            d.setCornerRadius(padding);
-            return d;
         }
 
         void setSupportedMimeTypes(@Nullable Collection<String> mimeTypes) {
@@ -796,16 +796,17 @@
             }
         }
 
-        protected void setBackgroundTintColor(int color) {
+        protected void setUniformBackgroundTintColor(int color) {
             mBackgroundColor.setColor(color);
             mTextBackground.setColor(color);
         }
 
-        protected void setForegroundColor(int color) {
-            mTextBackground.setStroke(mStokeWidth, color);
+        protected void setUniformForegroundColor(int color) {
+            int stroke = getContext().getResources()
+                    .getDimensionPixelSize(R.dimen.remote_input_view_text_stroke);
+            mTextBackground.setStroke(stroke, color);
             setTextColor(color);
-            // %60
-            setHintTextColor(color & 0x99FFFFFF);
+            setHintTextColor(ColorUtils.setAlphaComponent(color, 0x99));
             setTextCursorDrawable(null);
         }
 
@@ -896,10 +897,6 @@
             setSelection(getText().length());
         }
 
-        void updateCornerRadius(float radius) {
-            mTextBackground.setCornerRadius(radius);
-        }
-
         void setInnerFocusable(boolean focusable) {
             setFocusableInTouchMode(focusable);
             setFocusable(focusable);
@@ -935,5 +932,12 @@
             }
             return remainingItems;
         }
+
+        protected void setTextBackgroundColors(int strokeColor, int textBackground) {
+            mTextBackground.setColor(textBackground);
+            int stroke = getContext().getResources()
+                    .getDimensionPixelSize(R.dimen.remote_input_view_text_stroke);
+            mTextBackground.setStroke(stroke, strokeColor);
+        }
     }
 }