diff options
author | Dianne Hackborn <> | 2009-03-24 19:11:41 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-24 19:11:41 -0700 |
commit | 51bf077883df4f5cc816fbfec6d19eedffc26d70 (patch) | |
tree | 1450f41f77bcabee9fd90cb4179969356d60ddfc /core | |
parent | 36197e77c34b33135b4a3dc89d36ce80320dcd72 (diff) | |
download | frameworks_base-51bf077883df4f5cc816fbfec6d19eedffc26d70.zip frameworks_base-51bf077883df4f5cc816fbfec6d19eedffc26d70.tar.gz frameworks_base-51bf077883df4f5cc816fbfec6d19eedffc26d70.tar.bz2 |
Automated import from //branches/master/...@141004,141004
Diffstat (limited to 'core')
6 files changed, 77 insertions, 23 deletions
diff --git a/core/java/android/app/ApplicationContext.java b/core/java/android/app/ApplicationContext.java index ecef38f..55fce49 100644 --- a/core/java/android/app/ApplicationContext.java +++ b/core/java/android/app/ApplicationContext.java @@ -2723,10 +2723,8 @@ class ApplicationContext extends Context { mTimestamp = mFileStatus.mtime; } - // Writing was successful, delete the backup file - if (!mBackupFile.delete()) { - Log.e(TAG, "Couldn't delete new backup file " + mBackupFile); - } + // Writing was successful, delete the backup file if there is one. + mBackupFile.delete(); return true; } catch (XmlPullParserException e) { Log.w(TAG, "writeFileLocked: Got exception:", e); diff --git a/core/java/android/view/inputmethod/BaseInputConnection.java b/core/java/android/view/inputmethod/BaseInputConnection.java index deca910..11de3e2 100644 --- a/core/java/android/view/inputmethod/BaseInputConnection.java +++ b/core/java/android/view/inputmethod/BaseInputConnection.java @@ -51,7 +51,6 @@ public class BaseInputConnection implements InputConnection { static final Object COMPOSING = new ComposingText(); final InputMethodManager mIMM; - final Handler mH; final View mTargetView; final boolean mDummyMode; @@ -60,19 +59,17 @@ public class BaseInputConnection implements InputConnection { Editable mEditable; KeyCharacterMap mKeyCharacterMap; - BaseInputConnection(InputMethodManager mgr, boolean dummyMode) { + BaseInputConnection(InputMethodManager mgr, boolean fullEditor) { mIMM = mgr; mTargetView = null; - mH = null; - mDummyMode = dummyMode; + mDummyMode = !fullEditor; } - public BaseInputConnection(View targetView, boolean dummyMode) { + public BaseInputConnection(View targetView, boolean fullEditor) { mIMM = (InputMethodManager)targetView.getContext().getSystemService( Context.INPUT_METHOD_SERVICE); - mH = targetView.getHandler(); mTargetView = targetView; - mDummyMode = dummyMode; + mDummyMode = !fullEditor; } public static final void removeComposingSpans(Spannable text) { @@ -403,7 +400,7 @@ public class BaseInputConnection implements InputConnection { */ public boolean sendKeyEvent(KeyEvent event) { synchronized (mIMM.mH) { - Handler h = mH; + Handler h = mTargetView != null ? mTargetView.getHandler() : null; if (h == null) { if (mIMM.mServedView != null) { h = mIMM.mServedView.getHandler(); diff --git a/core/java/android/view/inputmethod/InputConnectionWrapper.java b/core/java/android/view/inputmethod/InputConnectionWrapper.java index e3d5e62..210559a 100644 --- a/core/java/android/view/inputmethod/InputConnectionWrapper.java +++ b/core/java/android/view/inputmethod/InputConnectionWrapper.java @@ -24,9 +24,21 @@ import android.view.KeyEvent; * and have fun! */ public class InputConnectionWrapper implements InputConnection { - private final InputConnection mTarget; + private InputConnection mTarget; + final boolean mMutable; - public InputConnectionWrapper(InputConnection target) { + public InputConnectionWrapper(InputConnection target, boolean mutable) { + mMutable = mutable; + mTarget = target; + } + + /** + * Change the target of the input connection. + */ + public void setTarget(InputConnection target) { + if (mTarget != null && !mMutable) { + throw new SecurityException("not mutable"); + } mTarget = target; } diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java index 4de9eef..dc2d3ed 100644 --- a/core/java/android/view/inputmethod/InputMethodManager.java +++ b/core/java/android/view/inputmethod/InputMethodManager.java @@ -188,7 +188,7 @@ import java.util.concurrent.TimeUnit; * </ul> */ public final class InputMethodManager { - static final boolean DEBUG = false; + static final boolean DEBUG = true; static final String TAG = "InputMethodManager"; static final Object mInstanceSync = new Object(); @@ -426,7 +426,7 @@ public final class InputMethodManager { } }; - final InputConnection mDummyInputConnection = new BaseInputConnection(this, true); + final InputConnection mDummyInputConnection = new BaseInputConnection(this, false); InputMethodManager(IInputMethodManager service, Looper looper) { mService = service; diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index 965d900..0563687 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -41,8 +41,10 @@ import android.view.ViewConfiguration; import android.view.ViewDebug; import android.view.ViewGroup; import android.view.ViewTreeObserver; +import android.view.inputmethod.BaseInputConnection; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; +import android.view.inputmethod.InputConnectionWrapper; import android.view.inputmethod.InputMethodManager; import android.view.ContextMenu.ContextMenuInfo; @@ -429,6 +431,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te private float mDensityScale; + private InputConnection mDefInputConnection; + private InputConnectionWrapper mPublicInputConnection; + /** * Interface definition for a callback to be invoked when the list or grid * has been scrolled. @@ -2932,7 +2937,46 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te // InputConnection to proxy to. Unfortunately this means we pretty // much need to make it as soon as a list view gets focus. createTextFilter(false); - return mTextFilter.onCreateInputConnection(outAttrs); + if (mPublicInputConnection == null) { + mDefInputConnection = new BaseInputConnection(this, false); + mPublicInputConnection = new InputConnectionWrapper( + mTextFilter.onCreateInputConnection(outAttrs), true) { + @Override + public boolean reportFullscreenMode(boolean enabled) { + // Use our own input connection, since it is + // the "real" one the IME is talking with. + return mDefInputConnection.reportFullscreenMode(enabled); + } + + @Override + public boolean performEditorAction(int editorAction) { + // The editor is off in its own window; we need to be + // the one that does this. + if (editorAction == EditorInfo.IME_ACTION_DONE) { + InputMethodManager imm = (InputMethodManager) + getContext().getSystemService( + Context.INPUT_METHOD_SERVICE); + if (imm != null) { + imm.hideSoftInputFromWindow(getWindowToken(), 0); + } + return true; + } + return false; + } + + @Override + public boolean sendKeyEvent(KeyEvent event) { + // Use our own input connection, since the filter + // text view may not be shown in a window so has + // no ViewRoot to dispatch events with. + return mDefInputConnection.sendKeyEvent(event); + } + }; + } + outAttrs.inputType = EditorInfo.TYPE_CLASS_TEXT + | EditorInfo.TYPE_TEXT_VARIATION_FILTER; + outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE; + return mPublicInputConnection; } return null; } @@ -3019,14 +3063,16 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te } /** - * For our text watcher that associated with the text filter + * For our text watcher that is associated with the text filter. Does + * nothing. */ public void beforeTextChanged(CharSequence s, int start, int count, int after) { } /** - * For our text watcher that associated with the text filter. Performs the actual - * filtering as the text changes. + * For our text watcher that is associated with the text filter. Performs + * the actual filtering as the text changes, and takes care of hiding and + * showing the popup displaying the currently entered filter text. */ public void onTextChanged(CharSequence s, int start, int before, int count) { if (mPopup != null && isTextFilterEnabled()) { @@ -3038,7 +3084,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te mFiltered = true; } else if (showing && length == 0) { // Remove the filter popup if the user has cleared all text - mPopup.dismiss(); + dismissPopup(); mFiltered = false; } if (mAdapter instanceof Filterable) { @@ -3055,7 +3101,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te } /** - * For our text watcher that associated with the text filter + * For our text watcher that is associated with the text filter. Does + * nothing. */ public void afterTextChanged(Editable s) { } diff --git a/core/java/com/android/internal/widget/EditableInputConnection.java b/core/java/com/android/internal/widget/EditableInputConnection.java index f2ec064..ad329d1 100644 --- a/core/java/com/android/internal/widget/EditableInputConnection.java +++ b/core/java/com/android/internal/widget/EditableInputConnection.java @@ -33,7 +33,7 @@ public class EditableInputConnection extends BaseInputConnection { private final TextView mTextView; public EditableInputConnection(TextView textview) { - super(textview, false); + super(textview, true); mTextView = textview; } |