Merge "Avoid Spell Checker initialization during anim" into tm-dev am: ae0a72f3c7

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18128982

Change-Id: I8b06908805a48f6f55ff3b254aeaf053dbc94d70
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Lucas Dupin
2022-05-03 05:08:34 +00:00
committed by Automerger Merge Worker
2 changed files with 20 additions and 2 deletions

View File

@@ -118,6 +118,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
private final UiEventLogger mUiEventLogger; private final UiEventLogger mUiEventLogger;
private NotificationEntry mEntry; private NotificationEntry mEntry;
private boolean mRemoved; private boolean mRemoved;
private boolean mSending;
private NotificationViewWrapper mWrapper; private NotificationViewWrapper mWrapper;
// TODO(b/193539698): remove this; views shouldn't have access to their controller, and places // TODO(b/193539698): remove this; views shouldn't have access to their controller, and places
@@ -251,6 +252,10 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
contentView.setBackground(mContentBackground); contentView.setBackground(mContentBackground);
mEditText = findViewById(R.id.remote_input_text); mEditText = findViewById(R.id.remote_input_text);
mEditText.setInnerFocusable(false); mEditText.setInnerFocusable(false);
// TextView initializes the spell checked when the view is attached to a window.
// This causes a couple of IPCs that can jank, especially during animations.
// By default the text view should be disabled, to avoid the unnecessary initialization.
mEditText.setEnabled(false);
mEditText.setWindowInsetsAnimationCallback( mEditText.setWindowInsetsAnimationCallback(
new WindowInsetsAnimation.Callback(DISPATCH_MODE_STOP) { new WindowInsetsAnimation.Callback(DISPATCH_MODE_STOP) {
@NonNull @NonNull
@@ -336,6 +341,7 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
/** Show the "sending in-progress" UI. */ /** Show the "sending in-progress" UI. */
public void startSending() { public void startSending() {
mEditText.setEnabled(false); mEditText.setEnabled(false);
mSending = true;
mSendButton.setVisibility(INVISIBLE); mSendButton.setVisibility(INVISIBLE);
mProgressBar.setVisibility(VISIBLE); mProgressBar.setVisibility(VISIBLE);
mEditText.mShowImeOnInputConnection = false; mEditText.mShowImeOnInputConnection = false;
@@ -444,6 +450,12 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
mController.removeSpinning(mEntry.getKey(), mToken); mController.removeSpinning(mEntry.getKey(), mToken);
} }
@Override
public void onVisibilityAggregated(boolean isVisible) {
super.onVisibilityAggregated(isVisible);
mEditText.setEnabled(isVisible && !mSending);
}
public void setHintText(CharSequence hintText) { public void setHintText(CharSequence hintText) {
mEditText.setHint(hintText); mEditText.setHint(hintText);
} }
@@ -508,10 +520,11 @@ public class RemoteInputView extends LinearLayout implements View.OnClickListene
private void reset() { private void reset() {
mResetting = true; mResetting = true;
mSending = false;
mEntry.remoteInputTextWhenReset = SpannedString.valueOf(mEditText.getText()); mEntry.remoteInputTextWhenReset = SpannedString.valueOf(mEditText.getText());
mEditText.getText().clear(); mEditText.getText().clear();
mEditText.setEnabled(true); mEditText.setEnabled(isAggregatedVisible());
mSendButton.setVisibility(VISIBLE); mSendButton.setVisibility(VISIBLE);
mProgressBar.setVisibility(INVISIBLE); mProgressBar.setVisibility(INVISIBLE);
mController.removeSpinning(mEntry.getKey(), mToken); mController.removeSpinning(mEntry.getKey(), mToken);

View File

@@ -16,6 +16,8 @@ package com.android.systemui.statusbar.policy;
import static android.view.ContentInfo.SOURCE_CLIPBOARD; import static android.view.ContentInfo.SOURCE_CLIPBOARD;
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNotNull;
@@ -174,12 +176,15 @@ public class RemoteInputViewTest extends SysuiTestCase {
toUser); toUser);
RemoteInputView view = RemoteInputView.inflate(mContext, null, row.getEntry(), mController); RemoteInputView view = RemoteInputView.inflate(mContext, null, row.getEntry(), mController);
RemoteInputViewController controller = bindController(view, row.getEntry()); RemoteInputViewController controller = bindController(view, row.getEntry());
EditText editText = view.findViewById(R.id.remote_input_text);
setTestPendingIntent(controller); setTestPendingIntent(controller);
assertThat(editText.isEnabled()).isFalse();
view.onVisibilityAggregated(true);
assertThat(editText.isEnabled()).isTrue();
view.focus(); view.focus();
EditText editText = view.findViewById(R.id.remote_input_text);
EditorInfo editorInfo = new EditorInfo(); EditorInfo editorInfo = new EditorInfo();
editorInfo.packageName = DUMMY_MESSAGE_APP_PKG; editorInfo.packageName = DUMMY_MESSAGE_APP_PKG;
editorInfo.fieldId = editText.getId(); editorInfo.fieldId = editText.getId();