From efbad5fb90fe990d42bf30c63e42558bd9bdb5d8 Mon Sep 17 00:00:00 2001 From: Gilles Debunne Date: Wed, 16 Nov 2011 17:08:42 +0100 Subject: [PATCH] IME action (done, next...) correctly handled Bugs 5599728 and 5319237. mInputContentType should be set for a "modern" cupcake environment says a comment in TextView. However, it is possible to call onEditorAction on a TextView that didn't use any of the method that lazily create that field. This is for instance achieved using the extracted mode in landscape (Done, Next actions) or in Contacts, that feature a Next/Done button in the IME. As a result, the action is ignored. The patch is to force the creation of the mInputContentType when the EditText is associated to the IME. Change-Id: I5beec5a52e9eec0c209af37d68791bb6ff83d6f6 --- core/java/android/widget/TextView.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index b106cc520ce0f..2aa1232698dc8 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -3786,7 +3786,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return; } } - + // This is the handling for some default action. // Note that for backwards compatibility we don't do this // default handling if explicit ime options have not been given, @@ -5599,6 +5599,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener outAttrs.extras = mInputContentType.extras; } else { outAttrs.imeOptions = EditorInfo.IME_NULL; + // May not be defined otherwise and needed by onEditorAction + mInputContentType = new InputContentType(); } if (focusSearch(FOCUS_DOWN) != null) { outAttrs.imeOptions |= EditorInfo.IME_FLAG_NAVIGATE_NEXT;