Merge "Fixed the paddings when replying with inline reply" into pi-dev am: e4c06663c8
am: b909e276f9

Change-Id: I721fb4e4b5d86b4c82a15e0897d4b823bfe22322
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
index 5477468..285f639 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
@@ -315,8 +315,7 @@
      * @return The extra height needed.
      */
     private int getExtraRemoteInputHeight(RemoteInputView remoteInput) {
-        if (remoteInput != null && remoteInput.getVisibility() == VISIBLE
-                && remoteInput.isActive()) {
+        if (remoteInput != null && (remoteInput.isActive() || remoteInput.isSending())) {
             return getResources().getDimensionPixelSize(
                     com.android.internal.R.dimen.notification_content_margin);
         }
@@ -1705,7 +1704,10 @@
         if (mHeadsUpChild == null) {
             viewType = VISIBLE_TYPE_CONTRACTED;
         }
-        return getViewHeight(viewType) + getExtraRemoteInputHeight(mHeadsUpRemoteInput);
+        // The headsUp remote input quickly switches to the expanded one, so lets also include that
+        // one
+        return getViewHeight(viewType) + getExtraRemoteInputHeight(mHeadsUpRemoteInput)
+                + getExtraRemoteInputHeight(mExpandedRemoteInput);
     }
 
     public void setRemoteInputVisible(boolean remoteInputVisible) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java b/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java
index cfc69a8..b0d5536 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/RemoteInputController.java
@@ -165,6 +165,16 @@
         return mSpinning.containsKey(key);
     }
 
+    /**
+     * Same as {@link #isSpinning}, but also verifies that the token is the same
+     * @param key the key that is spinning
+     * @param token the token that needs to be the same
+     * @return if this key with a given token is spinning
+     */
+    public boolean isSpinning(String key, Object token) {
+        return mSpinning.get(key) == token;
+    }
+
     private void apply(NotificationData.Entry entry) {
         mDelegate.setRemoteInputActive(entry, isRemoteInputActive(entry));
         boolean remoteInputActive = isRemoteInputActive();
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 a794e19..59bf982 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
@@ -285,12 +285,12 @@
         if (mWrapper != null) {
             mWrapper.setRemoteInputVisible(true);
         }
-        mController.addRemoteInput(mEntry, mToken);
         mEditText.setInnerFocusable(true);
         mEditText.mShowImeOnInputConnection = true;
         mEditText.setText(mEntry.remoteInputText);
         mEditText.setSelection(mEditText.getText().length());
         mEditText.requestFocus();
+        mController.addRemoteInput(mEntry, mToken);
         updateSendButton();
     }
 
@@ -466,6 +466,10 @@
         }
     }
 
+    public boolean isSending() {
+        return getVisibility() == VISIBLE && mController.isSpinning(mEntry.key, mToken);
+    }
+
     /**
      * An EditText that changes appearance based on whether it's focusable and becomes
      * un-focusable whenever the user navigates away from it or it becomes invisible.