summaryrefslogtreecommitdiffstats
path: root/core/java/android/view/inputmethod
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/view/inputmethod')
-rw-r--r--core/java/android/view/inputmethod/BaseInputConnection.java9
-rw-r--r--core/java/android/view/inputmethod/EditorInfo.java34
-rw-r--r--core/java/android/view/inputmethod/ExtractedText.java7
-rw-r--r--core/java/android/view/inputmethod/InputConnection.java3
-rw-r--r--core/java/android/view/inputmethod/InputConnectionWrapper.java105
-rw-r--r--core/java/android/view/inputmethod/InputMethodManager.java37
6 files changed, 161 insertions, 34 deletions
diff --git a/core/java/android/view/inputmethod/BaseInputConnection.java b/core/java/android/view/inputmethod/BaseInputConnection.java
index 52b4107..deca910 100644
--- a/core/java/android/view/inputmethod/BaseInputConnection.java
+++ b/core/java/android/view/inputmethod/BaseInputConnection.java
@@ -386,7 +386,14 @@ public class BaseInputConnection implements InputConnection {
// anyway.
return true;
}
- Selection.setSelection(content, start, end);
+ if (start == end && MetaKeyKeyListener.getMetaState(content,
+ MetaKeyKeyListener.META_SELECTING) != 0) {
+ // If we are in selection mode, then we want to extend the
+ // selection instead of replacing it.
+ Selection.extendSelection(content, start);
+ } else {
+ Selection.setSelection(content, start, end);
+ }
return true;
}
diff --git a/core/java/android/view/inputmethod/EditorInfo.java b/core/java/android/view/inputmethod/EditorInfo.java
index 1c0d42a..b00e565 100644
--- a/core/java/android/view/inputmethod/EditorInfo.java
+++ b/core/java/android/view/inputmethod/EditorInfo.java
@@ -33,43 +33,49 @@ public class EditorInfo implements InputType, Parcelable {
public static final int IME_MASK_ACTION = 0x000000ff;
/**
- * Bits of {@link #IME_MASK_ACTION}: there is no special action
- * associated with this editor.
+ * Bits of {@link #IME_MASK_ACTION}: no specific action has been
+ * associated with this editor, let the editor come up with its own if
+ * it can.
*/
- public static final int IME_ACTION_NONE = 0x00000000;
+ public static final int IME_ACTION_UNSPECIFIED = 0x00000000;
+
+ /**
+ * Bits of {@link #IME_MASK_ACTION}: there is no available action.
+ */
+ public static final int IME_ACTION_NONE = 0x00000001;
/**
* Bits of {@link #IME_MASK_ACTION}: the action key performs a "go"
* operation to take the user to the target of the text they typed.
* Typically used, for example, when entering a URL.
*/
- public static final int IME_ACTION_GO = 0x00000001;
+ public static final int IME_ACTION_GO = 0x00000002;
/**
* Bits of {@link #IME_MASK_ACTION}: the action key performs a "search"
* operation, taking the user to the results of searching for the text
* the have typed (in whatever context is appropriate).
*/
- public static final int IME_ACTION_SEARCH = 0x00000002;
+ public static final int IME_ACTION_SEARCH = 0x00000003;
/**
* Bits of {@link #IME_MASK_ACTION}: the action key performs a "send"
* operation, delivering the text to its target. This is typically used
* when composing a message.
*/
- public static final int IME_ACTION_SEND = 0x00000003;
+ public static final int IME_ACTION_SEND = 0x00000004;
/**
* Bits of {@link #IME_MASK_ACTION}: the action key performs a "next"
* operation, taking the user to the next field that will accept text.
*/
- public static final int IME_ACTION_NEXT = 0x00000004;
+ public static final int IME_ACTION_NEXT = 0x00000005;
/**
* Bits of {@link #IME_MASK_ACTION}: the action key performs a "done"
* operation, typically meaning the IME will be closed.
*/
- public static final int IME_ACTION_DONE = 0x00000005;
+ public static final int IME_ACTION_DONE = 0x00000006;
/**
* Flag of {@link #imeOptions}: used in conjunction with
@@ -82,21 +88,15 @@ public class EditorInfo implements InputType, Parcelable {
public static final int IME_FLAG_NO_ENTER_ACTION = 0x40000000;
/**
- * Generic non-special type for {@link #imeOptions}.
- */
- public static final int IME_NORMAL = 0x00000000;
-
- /**
- * Special code for when the ime option has been undefined. This is not
- * used with the EditorInfo structure, but can be used elsewhere.
+ * Generic unspecified type for {@link #imeOptions}.
*/
- public static final int IME_UNDEFINED = 0x80000000;
+ public static final int IME_NULL = 0x00000000;
/**
* Extended type information for the editor, to help the IME better
* integrate with it.
*/
- public int imeOptions = IME_NORMAL;
+ public int imeOptions = IME_NULL;
/**
* A string supplying additional information options that are
diff --git a/core/java/android/view/inputmethod/ExtractedText.java b/core/java/android/view/inputmethod/ExtractedText.java
index e5d3cae..c2851d6 100644
--- a/core/java/android/view/inputmethod/ExtractedText.java
+++ b/core/java/android/view/inputmethod/ExtractedText.java
@@ -55,6 +55,11 @@ public class ExtractedText implements Parcelable {
public static final int FLAG_SINGLE_LINE = 0x0001;
/**
+ * Bit for {@link #flags}: set if the editor is currently in selection mode.
+ */
+ public static final int FLAG_SELECTING = 0x0002;
+
+ /**
* Additional bit flags of information about the edited text.
*/
public int flags;
@@ -72,7 +77,7 @@ public class ExtractedText implements Parcelable {
dest.writeInt(partialEndOffset);
dest.writeInt(selectionStart);
dest.writeInt(selectionEnd);
- dest.writeInt(flags);
+ dest.writeInt(this.flags);
}
/**
diff --git a/core/java/android/view/inputmethod/InputConnection.java b/core/java/android/view/inputmethod/InputConnection.java
index 32cce35..8b6831e 100644
--- a/core/java/android/view/inputmethod/InputConnection.java
+++ b/core/java/android/view/inputmethod/InputConnection.java
@@ -17,7 +17,6 @@
package android.view.inputmethod;
import android.os.Bundle;
-import android.text.Spanned;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
@@ -135,7 +134,7 @@ public interface InputConnection {
* @return Returns true on success, false if the input connection is no longer
* valid.
*/
- boolean deleteSurroundingText(int leftLength, int rightLength);
+ public boolean deleteSurroundingText(int leftLength, int rightLength);
/**
* Set composing text around the current cursor position with the given text,
diff --git a/core/java/android/view/inputmethod/InputConnectionWrapper.java b/core/java/android/view/inputmethod/InputConnectionWrapper.java
new file mode 100644
index 0000000..e3d5e62
--- /dev/null
+++ b/core/java/android/view/inputmethod/InputConnectionWrapper.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2007-2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package android.view.inputmethod;
+
+import android.os.Bundle;
+import android.view.KeyEvent;
+
+/**
+ * <p>Wrapper class for proxying calls to another InputConnection. Subclass
+ * and have fun!
+ */
+public class InputConnectionWrapper implements InputConnection {
+ private final InputConnection mTarget;
+
+ public InputConnectionWrapper(InputConnection target) {
+ mTarget = target;
+ }
+
+ public CharSequence getTextBeforeCursor(int n, int flags) {
+ return mTarget.getTextBeforeCursor(n, flags);
+ }
+
+ public CharSequence getTextAfterCursor(int n, int flags) {
+ return mTarget.getTextAfterCursor(n, flags);
+ }
+
+ public int getCursorCapsMode(int reqModes) {
+ return mTarget.getCursorCapsMode(reqModes);
+ }
+
+ public ExtractedText getExtractedText(ExtractedTextRequest request,
+ int flags) {
+ return mTarget.getExtractedText(request, flags);
+ }
+
+ public boolean deleteSurroundingText(int leftLength, int rightLength) {
+ return mTarget.deleteSurroundingText(leftLength, rightLength);
+ }
+
+ public boolean setComposingText(CharSequence text, int newCursorPosition) {
+ return mTarget.setComposingText(text, newCursorPosition);
+ }
+
+ public boolean finishComposingText() {
+ return mTarget.finishComposingText();
+ }
+
+ public boolean commitText(CharSequence text, int newCursorPosition) {
+ return mTarget.commitText(text, newCursorPosition);
+ }
+
+ public boolean commitCompletion(CompletionInfo text) {
+ return mTarget.commitCompletion(text);
+ }
+
+ public boolean setSelection(int start, int end) {
+ return mTarget.setSelection(start, end);
+ }
+
+ public boolean performEditorAction(int editorAction) {
+ return mTarget.performEditorAction(editorAction);
+ }
+
+ public boolean performContextMenuAction(int id) {
+ return mTarget.performContextMenuAction(id);
+ }
+
+ public boolean beginBatchEdit() {
+ return mTarget.beginBatchEdit();
+ }
+
+ public boolean endBatchEdit() {
+ return mTarget.endBatchEdit();
+ }
+
+ public boolean sendKeyEvent(KeyEvent event) {
+ return mTarget.sendKeyEvent(event);
+ }
+
+ public boolean clearMetaKeyStates(int states) {
+ return mTarget.clearMetaKeyStates(states);
+ }
+
+ public boolean reportFullscreenMode(boolean enabled) {
+ return mTarget.reportFullscreenMode(enabled);
+ }
+
+ public boolean performPrivateCommand(String action, Bundle data) {
+ return mTarget.performPrivateCommand(action, data);
+ }
+}
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 916ffea..7f2142e 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -529,7 +529,10 @@ public final class InputMethodManager {
public boolean isActive(View view) {
checkFocus();
synchronized (mH) {
- return mServedView == view && mCurrentTextBoxAttribute != null;
+ return (mServedView == view
+ || (mServedView != null
+ && mServedView.checkInputConnectionProxy(view)))
+ && mCurrentTextBoxAttribute != null;
}
}
@@ -620,7 +623,8 @@ public final class InputMethodManager {
public void displayCompletions(View view, CompletionInfo[] completions) {
checkFocus();
synchronized (mH) {
- if (mServedView != view) {
+ if (mServedView != view && (mServedView == null
+ || !mServedView.checkInputConnectionProxy(view))) {
return;
}
@@ -637,7 +641,8 @@ public final class InputMethodManager {
public void updateExtractedText(View view, int token, ExtractedText text) {
checkFocus();
synchronized (mH) {
- if (mServedView != view) {
+ if (mServedView != view && (mServedView == null
+ || !mServedView.checkInputConnectionProxy(view))) {
return;
}
@@ -730,7 +735,8 @@ public final class InputMethodManager {
ResultReceiver resultReceiver) {
checkFocus();
synchronized (mH) {
- if (mServedView != view) {
+ if (mServedView != view && (mServedView == null
+ || !mServedView.checkInputConnectionProxy(view))) {
return false;
}
@@ -871,7 +877,8 @@ public final class InputMethodManager {
public void restartInput(View view) {
checkFocus();
synchronized (mH) {
- if (mServedView != view) {
+ if (mServedView != view && (mServedView == null
+ || !mServedView.checkInputConnectionProxy(view))) {
return;
}
@@ -1032,7 +1039,7 @@ public final class InputMethodManager {
if (DEBUG) Log.v(TAG, "focusOut: " + view
+ " mServedView=" + mServedView
+ " winFocus=" + view.hasWindowFocus());
- if (mServedView == view) {
+ if (mServedView != view) {
// The following code would auto-hide the IME if we end up
// with no more views with focus. This can happen, however,
// whenever we go into touch mode, so it ends up hiding
@@ -1129,8 +1136,9 @@ public final class InputMethodManager {
try {
final boolean isTextEditor = focusedView != null &&
focusedView.onCheckIsTextEditor();
- mService.windowGainedFocus(mClient, focusedView != null,
- isTextEditor, softInputMode, first, windowFlags);
+ mService.windowGainedFocus(mClient, rootView.getWindowToken(),
+ focusedView != null, isTextEditor, softInputMode, first,
+ windowFlags);
} catch (RemoteException e) {
}
}
@@ -1150,8 +1158,9 @@ public final class InputMethodManager {
int candidatesStart, int candidatesEnd) {
checkFocus();
synchronized (mH) {
- if (mServedView != view || mCurrentTextBoxAttribute == null
- || mCurMethod == null) {
+ if ((mServedView != view && (mServedView == null
+ || !mServedView.checkInputConnectionProxy(view)))
+ || mCurrentTextBoxAttribute == null || mCurMethod == null) {
return;
}
@@ -1189,8 +1198,9 @@ public final class InputMethodManager {
public void updateCursor(View view, int left, int top, int right, int bottom) {
checkFocus();
synchronized (mH) {
- if (mServedView != view || mCurrentTextBoxAttribute == null
- || mCurMethod == null) {
+ if ((mServedView != view && (mServedView == null
+ || !mServedView.checkInputConnectionProxy(view)))
+ || mCurrentTextBoxAttribute == null || mCurMethod == null) {
return;
}
@@ -1223,7 +1233,8 @@ public final class InputMethodManager {
public void sendAppPrivateCommand(View view, String action, Bundle data) {
checkFocus();
synchronized (mH) {
- if ((view != null && mServedView != view)
+ if ((mServedView != view && (mServedView == null
+ || !mServedView.checkInputConnectionProxy(view)))
|| mCurrentTextBoxAttribute == null || mCurMethod == null) {
return;
}