summaryrefslogtreecommitdiff
path: root/src/com/android/launcher3/ExtendedEditText.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/ExtendedEditText.java')
-rw-r--r--src/com/android/launcher3/ExtendedEditText.java38
1 files changed, 31 insertions, 7 deletions
diff --git a/src/com/android/launcher3/ExtendedEditText.java b/src/com/android/launcher3/ExtendedEditText.java
index 8ec5c18393..ec26f5849c 100644
--- a/src/com/android/launcher3/ExtendedEditText.java
+++ b/src/com/android/launcher3/ExtendedEditText.java
@@ -90,19 +90,34 @@ public class ExtendedEditText extends EditText {
/**
* Synchronously shows the soft input method.
*
- * @param shouldFocus whether this EditText should also request focus.
- * @return true if the keyboard is shown correctly and focus is given to this view (if
- * applicable).
+ * @return true if the keyboard is shown correctly and focus is given to this view.
*/
- public boolean showKeyboard(boolean shouldFocus) {
+ public boolean showKeyboard() {
onKeyboardShown();
- boolean focusResult = !shouldFocus || requestFocus();
- return focusResult && showSoftInputInternal();
+ return requestFocus() && showSoftInputInternal();
+ }
+
+ /**
+ * Requests the framework to show the keyboard in order to ensure that an already registered
+ * controlled keyboard animation is triggered correctly.
+ * Must NEVER be called in any other case than to trigger a pre-registered controlled animation.
+ */
+ public void requestShowKeyboardForControlledAnimation() {
+ // We don't log the keyboard state, as that must happen only after the controlled animation
+ // has completed.
+ // We also must not request focus, as this triggers unwanted side effects.
+ showSoftInputInternal();
}
public void hideKeyboard() {
+ hideKeyboard(/* clearFocus= */ true);
+ }
+
+ public void hideKeyboard(boolean clearFocus) {
ActivityContext.lookupContext(getContext()).hideKeyboard();
- clearFocus();
+ if (clearFocus) {
+ clearFocus();
+ }
}
protected void onKeyboardShown() {
@@ -147,6 +162,15 @@ public class ExtendedEditText extends EditText {
}
}
+ @Override
+ public void setText(CharSequence text, BufferType type) {
+ super.setText(text, type);
+ // With hardware keyboard, there is a possibility that the user types before edit
+ // text is visible during the transition.
+ // So move the cursor to the end of the text.
+ setSelection(getText().length());
+ }
+
/**
* This method should be preferred to {@link #setOnFocusChangeListener(OnFocusChangeListener)},
* as it allows for multiple listeners from different sources.