From ced19e6d2582c8d6392697f02a18a4ad1c362fa9 Mon Sep 17 00:00:00 2001 From: Mis012 Date: Fri, 28 Mar 2025 19:51:23 +0100 Subject: [PATCH] api-impl: add ATLKeyboardViewer to support launching IMEs --- ...ce_InputMethodService_ATLInputConnection.h | 77 ++++++ .../android_view_MotionEvent.h | 8 + src/api-impl/android/app/Service.java | 5 + .../inputmethodservice/ATLKeyboardViewer.java | 34 +++ .../AbstractInputMethodService.java | 16 ++ .../InputMethodService.java | 245 ++++++++++++++++++ .../android/view/KeyCharacterMap.java | 5 +- .../view/inputmethod/BaseInputConnection.java | 1 + .../view/inputmethod/CompletionInfo.java | 5 + .../view/inputmethod/CorrectionInfo.java | 104 ++++++++ .../android/view/inputmethod/EditorInfo.java | 20 ++ .../inputmethod/ExtractedTextRequest.java | 85 ++++++ .../view/inputmethod/InputBinding.java | 151 +++++++++++ .../view/inputmethod/InputConnection.java | 5 +- .../android/view/inputmethod/InputMethod.java | 7 + .../view/inputmethod/InputMethodInfo.java | 5 + .../view/inputmethod/InputMethodManager.java | 11 +- .../view/inputmethod/InputMethodSession.java | 5 + 18 files changed, 781 insertions(+), 8 deletions(-) create mode 100644 src/api-impl-jni/generated_headers/android_inputmethodservice_InputMethodService_ATLInputConnection.h create mode 100644 src/api-impl/android/inputmethodservice/ATLKeyboardViewer.java create mode 100644 src/api-impl/android/inputmethodservice/AbstractInputMethodService.java create mode 100644 src/api-impl/android/inputmethodservice/InputMethodService.java create mode 100644 src/api-impl/android/view/inputmethod/CompletionInfo.java create mode 100644 src/api-impl/android/view/inputmethod/CorrectionInfo.java create mode 100644 src/api-impl/android/view/inputmethod/EditorInfo.java create mode 100644 src/api-impl/android/view/inputmethod/ExtractedTextRequest.java create mode 100644 src/api-impl/android/view/inputmethod/InputBinding.java create mode 100644 src/api-impl/android/view/inputmethod/InputMethod.java create mode 100644 src/api-impl/android/view/inputmethod/InputMethodInfo.java create mode 100644 src/api-impl/android/view/inputmethod/InputMethodSession.java diff --git a/src/api-impl-jni/generated_headers/android_inputmethodservice_InputMethodService_ATLInputConnection.h b/src/api-impl-jni/generated_headers/android_inputmethodservice_InputMethodService_ATLInputConnection.h new file mode 100644 index 00000000..7b1aeb8c --- /dev/null +++ b/src/api-impl-jni/generated_headers/android_inputmethodservice_InputMethodService_ATLInputConnection.h @@ -0,0 +1,77 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class android_inputmethodservice_InputMethodService_ATLInputConnection */ + +#ifndef _Included_android_inputmethodservice_InputMethodService_ATLInputConnection +#define _Included_android_inputmethodservice_InputMethodService_ATLInputConnection +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: android_inputmethodservice_InputMethodService_ATLInputConnection + * Method: nativeInit + * Signature: ()J + */ +JNIEXPORT jlong JNICALL Java_android_inputmethodservice_InputMethodService_00024ATLInputConnection_nativeInit + (JNIEnv *, jobject); + +/* + * Class: android_inputmethodservice_InputMethodService_ATLInputConnection + * Method: nativeSetCompositingText + * Signature: (JLjava/lang/String;I)Z + */ +JNIEXPORT jboolean JNICALL Java_android_inputmethodservice_InputMethodService_00024ATLInputConnection_nativeSetCompositingText + (JNIEnv *, jobject, jlong, jstring, jint); + +/* + * Class: android_inputmethodservice_InputMethodService_ATLInputConnection + * Method: nativeSetCompositingRegion + * Signature: (JII)Z + */ +JNIEXPORT jboolean JNICALL Java_android_inputmethodservice_InputMethodService_00024ATLInputConnection_nativeSetCompositingRegion + (JNIEnv *, jobject, jlong, jint, jint); + +/* + * Class: android_inputmethodservice_InputMethodService_ATLInputConnection + * Method: nativeFinishComposingText + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL Java_android_inputmethodservice_InputMethodService_00024ATLInputConnection_nativeFinishComposingText + (JNIEnv *, jobject, jlong); + +/* + * Class: android_inputmethodservice_InputMethodService_ATLInputConnection + * Method: nativeCommitText + * Signature: (JLjava/lang/String;I)Z + */ +JNIEXPORT jboolean JNICALL Java_android_inputmethodservice_InputMethodService_00024ATLInputConnection_nativeCommitText + (JNIEnv *, jobject, jlong, jstring, jint); + +/* + * Class: android_inputmethodservice_InputMethodService_ATLInputConnection + * Method: nativeDeleteSurroundingText + * Signature: (JII)Z + */ +JNIEXPORT jboolean JNICALL Java_android_inputmethodservice_InputMethodService_00024ATLInputConnection_nativeDeleteSurroundingText + (JNIEnv *, jobject, jlong, jint, jint); + +/* + * Class: android_inputmethodservice_InputMethodService_ATLInputConnection + * Method: nativeSetSelection + * Signature: (JII)Z + */ +JNIEXPORT jboolean JNICALL Java_android_inputmethodservice_InputMethodService_00024ATLInputConnection_nativeSetSelection + (JNIEnv *, jobject, jlong, jint, jint); + +/* + * Class: android_inputmethodservice_InputMethodService_ATLInputConnection + * Method: nativeSendKeyEvent + * Signature: (JJJJ)Z + */ +JNIEXPORT jboolean JNICALL Java_android_inputmethodservice_InputMethodService_00024ATLInputConnection_nativeSendKeyEvent + (JNIEnv *, jobject, jlong, jlong, jlong, jlong); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/api-impl-jni/generated_headers/android_view_MotionEvent.h b/src/api-impl-jni/generated_headers/android_view_MotionEvent.h index 1e0e0d5a..6229759b 100644 --- a/src/api-impl-jni/generated_headers/android_view_MotionEvent.h +++ b/src/api-impl-jni/generated_headers/android_view_MotionEvent.h @@ -453,6 +453,14 @@ JNIEXPORT void JNICALL Java_android_view_MotionEvent_nativeGetPointerProperties JNIEXPORT void JNICALL Java_android_view_MotionEvent_nativeScale (JNIEnv *, jclass, jint, jfloat); +/* + * Class: android_view_MotionEvent + * Method: nativeTransform + * Signature: (ILandroid/graphics/Matrix;)V + */ +JNIEXPORT void JNICALL Java_android_view_MotionEvent_nativeTransform + (JNIEnv *, jclass, jint, jobject); + #ifdef __cplusplus } #endif diff --git a/src/api-impl/android/app/Service.java b/src/api-impl/android/app/Service.java index df6ba936..e77d5615 100644 --- a/src/api-impl/android/app/Service.java +++ b/src/api-impl/android/app/Service.java @@ -7,6 +7,11 @@ import android.os.IBinder; public abstract class Service extends ContextWrapper { + /* HACK for InputMethodService */ + public Service(Context baseContext) { + super(baseContext); + } + public Service() { super(null); } diff --git a/src/api-impl/android/inputmethodservice/ATLKeyboardViewer.java b/src/api-impl/android/inputmethodservice/ATLKeyboardViewer.java new file mode 100644 index 00000000..26e86ede --- /dev/null +++ b/src/api-impl/android/inputmethodservice/ATLKeyboardViewer.java @@ -0,0 +1,34 @@ +package android.inputmethodservice; + +import android.app.Activity; +import android.os.Bundle; + +import java.lang.reflect.Constructor; + +public class ATLKeyboardViewer extends Activity { + @Override + public void onCreate(Bundle savedState) { + Bundle extras = this.getIntent().getExtras(); + + if (extras == null || !extras.containsKey("kb_class")) { + System.err.println("ATLKeyboardViewer: usage: `-e 'kb_class=com.example.LatinIME'`"); + System.exit(1); + } + + String kb_class = extras.getString("kb_class"); + + InputMethodService ims = null; + + try { + Class cls = Class.forName(kb_class).asSubclass(InputMethodService.class); + Constructor constructor = cls.getConstructor(); + ims = constructor.newInstance(); + } catch (ReflectiveOperationException e) { + System.err.println("ATLKeyboardViewer: failed to instantiate InputMethodService (kb_class: "+kb_class+")"); + e.printStackTrace(); + System.exit(1); + } + + ims.launch_keyboard(); + } +} diff --git a/src/api-impl/android/inputmethodservice/AbstractInputMethodService.java b/src/api-impl/android/inputmethodservice/AbstractInputMethodService.java new file mode 100644 index 00000000..c403119a --- /dev/null +++ b/src/api-impl/android/inputmethodservice/AbstractInputMethodService.java @@ -0,0 +1,16 @@ +package android.inputmethodservice; + +import android.app.Service; +import android.content.Context; +import android.view.inputmethod.InputMethod; + +public abstract class AbstractInputMethodService extends Service { + public AbstractInputMethodService(Context context) { + super(context); + } + + public abstract class AbstractInputMethodImpl implements InputMethod { + public void createSession(SessionCallback callback) { + } + } +} diff --git a/src/api-impl/android/inputmethodservice/InputMethodService.java b/src/api-impl/android/inputmethodservice/InputMethodService.java new file mode 100644 index 00000000..30bd92df --- /dev/null +++ b/src/api-impl/android/inputmethodservice/InputMethodService.java @@ -0,0 +1,245 @@ +package android.inputmethodservice; + +import android.app.Dialog; +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.content.res.Configuration; +import android.content.res.Resources; +import android.graphics.Region; +import android.inputmethodservice.AbstractInputMethodService.AbstractInputMethodImpl; +import android.os.IBinder; +import android.view.KeyEvent; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup.LayoutParams; +import android.view.ViewTreeObserver; +import android.view.Window; +import android.view.inputmethod.BaseInputConnection; +import android.view.inputmethod.CompletionInfo; +import android.view.inputmethod.CorrectionInfo; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputBinding; +import android.view.inputmethod.InputConnection; +import android.widget.LinearLayout; + +public class InputMethodService extends AbstractInputMethodService { + private LinearLayout kb_box; + private View kb_view; + private View candidates_view; + private Dialog kb_dialog; + + class ATLInputConnection extends BaseInputConnection { + ATLInputConnection() { + super(null, false); + } + + @Override + public boolean setComposingText(CharSequence text, int newCursorPosition) { + System.out.println("softkeyboard preview: setComposingText(\""+text+"\", "+newCursorPosition+")"); + return true; + } + + @Override + public boolean finishComposingText() { + System.out.println("softkeyboard preview: finishComposingText()"); + return true; + } + + @Override + public boolean commitText(CharSequence text, int newCursorPosition) { + System.out.println("softkeyboard preview: commitText(\""+text+"\", "+newCursorPosition+")"); + return true; + } + + @Override + public boolean deleteSurroundingText(int beforeLength, int afterLength) { + System.out.println("softkeyboard preview: deleteSurroundingText("+beforeLength+", "+afterLength+")"); + return true; + } + + @Override + public boolean sendKeyEvent(KeyEvent event) { + System.out.println("softkeyboard preview: sendKeyEvent("+event+")"); + return true; + } + + /* these functions are noop on AOSP by default, so we just add a print for debugging purposes and still return false */ + @Override + public boolean commitCompletion(CompletionInfo completionInfo) { + System.out.println("softkeyboard preview: commitCompletion(\""+completionInfo+"\")"); + return false; + } + + @Override + public boolean commitCorrection(CorrectionInfo correctionInfo) { + System.out.println("softkeyboard preview: commitCorrection(\""+correctionInfo+"\")"); + return false; + } + } + + private InputConnection input_connection = new ATLInputConnection(); + + public InputMethodService() { + super(new Context()); + } + + public void launch_keyboard() { + kb_dialog = new Dialog(this); + + View decorview = kb_dialog.getWindow().getDecorView(); + decorview.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); + + onCreate(); + + AbstractInputMethodImpl impl = onCreateInputMethodInterface(); + impl.createSession(null); + + // to force portrait version: + getResources().getConfiguration().orientation = Configuration.ORIENTATION_PORTRAIT; + + onConfigurationChanged(getResources().getConfiguration()); + + onBindInput(); + onStartInput(new EditorInfo(), false); + + kb_box = new LinearLayout(this); + kb_box.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + kb_box.setOrientation(LinearLayout.VERTICAL); + + candidates_view = onCreateCandidatesView(); + kb_view = onCreateInputView(); + + if (candidates_view != null) + kb_box.addView(candidates_view); + kb_box.addView(kb_view); + + kb_dialog.setContentView(kb_box); + kb_dialog.show(); + + onConfigureWindow(kb_dialog.getWindow(), false, false); + + onComputeInsets(new Insets()); + + onStartInputView(new EditorInfo(), false); + + } + + public void sendKeyChar(char c) { + System.out.println("softkeyboard preview: sendKeyChar('"+c+"')"); + } + + public void setInputView(View view) { + kb_view = view; + } + + public void setCandidatesView(View view) { + candidates_view = view; + } + + public InputBinding getCurrentInputBinding() { + return new InputBinding(new ATLInputConnection(), null, 0, 0); + } + + public IBinder onBind(Intent intent) { + return null; + } + + public LayoutInflater getLayoutInflater() { + return (LayoutInflater)getSystemService("layout_inflater"); + } + + public boolean onEvaluateInputViewShown() { + return true; + } + + public void setCandidatesViewShown(boolean shown) { + } + + public void showStatusIcon(int resId) { + } + + public void hideStatusIcon() { + } + + public void updateInputViewShown() { + } + + public void updateFullscreenMode() { + } + + public boolean isFullscreenMode() { + return false; + } + + public int getMaxWidth() { + return (kb_view != null && kb_view.getWidth() > 0) ? kb_view.getWidth() : Resources.getSystem().getDisplayMetrics().widthPixels; + } + + public EditorInfo getCurrentInputEditorInfo() { + return new EditorInfo(); + } + + public void requestHideSelf(int flags) { + } + + + public Dialog getWindow() { + return kb_dialog; + } + + public InputConnection getCurrentInputConnection() { + return input_connection; + } + + /* --- */ + + public AbstractInputMethodImpl onCreateInputMethodInterface() { + return null; + } + + public View onCreateCandidatesView() { + return null; + } + + public View onCreateInputView() { + return null; + } + + public void onConfigurationChanged(Configuration configuration) { + } + + public void onConfigureWindow(Window win, boolean isFullscreen, boolean isCandidatesOnly) { + } + + public void onComputeInsets(Insets insets) { + } + + public void onStartInput(EditorInfo info, boolean restarting) { + } + + public void onFinishInput() { + } + + public void onStartInputView(EditorInfo info, boolean restarting) { + } + + public void onBindInput() { + } + + /* --- */ + + public static final class Insets { + public int contentTopInsets; + public int visibleTopInsets; + public final Region touchableRegion = new Region(); + public static final int TOUCHABLE_INSETS_FRAME = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_FRAME; + public static final int TOUCHABLE_INSETS_CONTENT = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT; + public static final int TOUCHABLE_INSETS_VISIBLE = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_VISIBLE; + public static final int TOUCHABLE_INSETS_REGION = ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION; + public int touchableInsets; + } + + public class InputMethodImpl extends AbstractInputMethodImpl { + } +} diff --git a/src/api-impl/android/view/KeyCharacterMap.java b/src/api-impl/android/view/KeyCharacterMap.java index e92af218..24e094eb 100644 --- a/src/api-impl/android/view/KeyCharacterMap.java +++ b/src/api-impl/android/view/KeyCharacterMap.java @@ -332,7 +332,8 @@ public class KeyCharacterMap { * @return The associated character or combining accent, or 0 if none. */ public int get(int keyCode, int metaState) { - metaState = KeyEvent.normalizeMetaState(metaState); + return 0; + /*metaState = KeyEvent.normalizeMetaState(metaState); char ch = nativeGetCharacter(mPtr, keyCode, metaState); int map = sCombiningToAccent.get(ch); @@ -340,7 +341,7 @@ public class KeyCharacterMap { return map | COMBINING_ACCENT; } else { return ch; - } + }*/ } /** diff --git a/src/api-impl/android/view/inputmethod/BaseInputConnection.java b/src/api-impl/android/view/inputmethod/BaseInputConnection.java index 2a9418ef..07a2a23e 100644 --- a/src/api-impl/android/view/inputmethod/BaseInputConnection.java +++ b/src/api-impl/android/view/inputmethod/BaseInputConnection.java @@ -24,6 +24,7 @@ import android.text.Spannable; import android.text.Spanned; import android.text.TextUtils; import android.util.Log; +import android.view.KeyEvent; import android.view.View; class Editable {} diff --git a/src/api-impl/android/view/inputmethod/CompletionInfo.java b/src/api-impl/android/view/inputmethod/CompletionInfo.java new file mode 100644 index 00000000..99a52112 --- /dev/null +++ b/src/api-impl/android/view/inputmethod/CompletionInfo.java @@ -0,0 +1,5 @@ +package android.view.inputmethod; + +public final class CompletionInfo { + +} diff --git a/src/api-impl/android/view/inputmethod/CorrectionInfo.java b/src/api-impl/android/view/inputmethod/CorrectionInfo.java new file mode 100644 index 00000000..04d3f632 --- /dev/null +++ b/src/api-impl/android/view/inputmethod/CorrectionInfo.java @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2007-2010 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.Parcel; +import android.os.Parcelable; +import android.text.TextUtils; + +/** + * Information about a single text correction that an editor has reported to + * an input method. + */ +public final class CorrectionInfo implements Parcelable { + private final int mOffset; + private final CharSequence mOldText; + private final CharSequence mNewText; + + /** + * @param offset The offset in the edited text where the old and new text start. + * @param oldText The old text that has been replaced. + * @param newText The replacement text. + */ + public CorrectionInfo(int offset, CharSequence oldText, CharSequence newText) { + mOffset = offset; + mOldText = oldText; + mNewText = newText; + } + + private CorrectionInfo(Parcel source) { + mOffset = 0/*source.readInt()*/; + mOldText = null/*TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source)*/; + mNewText = null/*TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source)*/; + } + + /** + * Return the offset position of this correction in the text. Both the {@link #getOldText()} and + * {@link #getNewText()} start at this offset. + */ + public int getOffset() { + return mOffset; + } + + /** + * Return the text that has actually been typed by the user, and which has been corrected. + */ + public CharSequence getOldText() { + return mOldText; + } + + /** + * Return the new text that corrects what was typed by the user. + */ + public CharSequence getNewText() { + return mNewText; + } + + @Override + public String toString() { + return "CorrectionInfo{#" + mOffset + " \"" + mOldText + "\" -> \"" + mNewText + "\"}"; + } + + /** + * Used to package this object into a {@link Parcel}. + * + * @param dest The {@link Parcel} to be written. + * @param flags The flags used for parceling. + */ + public void writeToParcel(Parcel dest, int flags) { + /*dest.writeInt(mOffset); + TextUtils.writeToParcel(mOldText, dest, flags); + TextUtils.writeToParcel(mNewText, dest, flags);*/ + } + + /** + * Used to make this class parcelable. + */ + public static final @android.annotation.NonNull Parcelable.Creator CREATOR = + new Parcelable.Creator() { + public CorrectionInfo createFromParcel(Parcel source) { + return new CorrectionInfo(source); + } + public CorrectionInfo[] newArray(int size) { + return new CorrectionInfo[size]; + } + }; + + public int describeContents() { + return 0; + } +} diff --git a/src/api-impl/android/view/inputmethod/EditorInfo.java b/src/api-impl/android/view/inputmethod/EditorInfo.java new file mode 100644 index 00000000..c6eb7010 --- /dev/null +++ b/src/api-impl/android/view/inputmethod/EditorInfo.java @@ -0,0 +1,20 @@ +package android.view.inputmethod; + +import android.os.Bundle; + +public class EditorInfo { + public int actionId = 0; + public CharSequence actionLabel = null; + public Bundle extras = null; + public int fieldId = 0; + public String fieldName = null; + public CharSequence hintText = null; + public int imeOptions = 0x0; + public int initialCapsMode = 0; + public int initialSelStart = -1; + public int initialSelEnd = -1; + public int inputType = /*0x0*/ 0x00000001; /* TYPE_NULL */ /* TYPE_CLASS_TEXT */ + public CharSequence label = null; + public String packageName = "com.example.FIXME"; + public String privateImeOptions = null; +} diff --git a/src/api-impl/android/view/inputmethod/ExtractedTextRequest.java b/src/api-impl/android/view/inputmethod/ExtractedTextRequest.java new file mode 100644 index 00000000..9df0c791 --- /dev/null +++ b/src/api-impl/android/view/inputmethod/ExtractedTextRequest.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 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.Parcel; +import android.os.Parcelable; + +/** + * Description of what an input method would like from an application when + * extract text from its input editor. + */ +public class ExtractedTextRequest implements Parcelable { + /** + * Arbitrary integer that can be supplied in the request, which will be + * delivered back when reporting updates. + */ + public int token; + + /** + * Additional request flags, having the same possible values as the + * flags parameter of {@link InputConnection#getTextBeforeCursor + * InputConnection.getTextBeforeCursor()}. + */ + public int flags; + + /** + * Hint for the maximum number of lines to return. + */ + public int hintMaxLines; + + /** + * Hint for the maximum number of characters to return. + */ + public int hintMaxChars; + + /** + * Used to package this object into a {@link Parcel}. + * + * @param dest The {@link Parcel} to be written. + * @param flags The flags used for parceling. + */ + public void writeToParcel(Parcel dest, int flags) { + /*dest.writeInt(token); + dest.writeInt(this.flags); + dest.writeInt(hintMaxLines); + dest.writeInt(hintMaxChars);*/ + } + + /** + * Used to make this class parcelable. + */ + public static final @android.annotation.NonNull Parcelable.Creator CREATOR = new Parcelable.Creator() { + public ExtractedTextRequest createFromParcel(Parcel source) { + /*ExtractedTextRequest res = new ExtractedTextRequest(); + res.token = source.readInt(); + res.flags = source.readInt(); + res.hintMaxLines = source.readInt(); + res.hintMaxChars = source.readInt(); + return res;*/ + return null; + } + + public ExtractedTextRequest[] newArray(int size) { + return new ExtractedTextRequest[size]; + } + }; + + public int describeContents() { + return 0; + } +} diff --git a/src/api-impl/android/view/inputmethod/InputBinding.java b/src/api-impl/android/view/inputmethod/InputBinding.java new file mode 100644 index 00000000..2d3f72dd --- /dev/null +++ b/src/api-impl/android/view/inputmethod/InputBinding.java @@ -0,0 +1,151 @@ +/* + * 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.IBinder; +import android.os.Parcel; +import android.os.Parcelable; + +/** + * Information given to an {@link InputMethod} about a client connecting + * to it. + */ + +public final class InputBinding implements Parcelable { + static final String TAG = "InputBinding"; + + /** + * The connection back to the client. + */ + final InputConnection mConnection; + + /** + * A remotable token for the connection back to the client. + */ + final IBinder mConnectionToken; + + /** + * The UID where this binding came from. + */ + final int mUid; + + /** + * The PID where this binding came from. + */ + final int mPid; + + /** + * Constructor. + * + * @param conn The interface for communicating back with the application. + * @param connToken A remoteable token for communicating across processes. + * @param uid The user id of the client of this binding. + * @param pid The process id of where the binding came from. + */ + public InputBinding(InputConnection conn, IBinder connToken, + int uid, int pid) { + mConnection = conn; + mConnectionToken = connToken; + mUid = uid; + mPid = pid; + } + + /** + * Constructor from an existing InputBinding taking a new local input + * connection interface. + * + * @param conn The new connection interface. + * @param binding Existing binding to copy. + */ + public InputBinding(InputConnection conn, InputBinding binding) { + mConnection = conn; + mConnectionToken = binding.getConnectionToken(); + mUid = binding.getUid(); + mPid = binding.getPid(); + } + + InputBinding(Parcel source) { + mConnection = null; + mConnectionToken = null; //source.readStrongBinder(); + mUid = 0; //source.readInt(); + mPid = 0; //source.readInt(); + } + + /** + * Return the connection for interacting back with the application. + */ + public InputConnection getConnection() { + return mConnection; + } + + /** + * Return the token for the connection back to the application. You can + * not use this directly, it must be converted to a {@link InputConnection} + * for you. + */ + public IBinder getConnectionToken() { + return mConnectionToken; + } + + /** + * Return the user id of the client associated with this binding. + */ + public int getUid() { + return mUid; + } + + /** + * Return the process id where this binding came from. + */ + public int getPid() { + return mPid; + } + + @Override + public String toString() { + return "InputBinding{" + mConnectionToken + " / uid " + mUid + " / pid " + mPid + "}"; + } + + /** + * Used to package this object into a {@link Parcel}. + * + * @param dest The {@link Parcel} to be written. + * @param flags The flags used for parceling. + */ + public void writeToParcel(Parcel dest, int flags) { + /*dest.writeStrongBinder(mConnectionToken); + dest.writeInt(mUid); + dest.writeInt(mPid);*/ + } + + /** + * Used to make this class parcelable. + */ + public static final @android.annotation.NonNull Parcelable.Creator CREATOR = new Parcelable.Creator() { + public InputBinding createFromParcel(Parcel source) { + return new InputBinding(source); + } + + public InputBinding[] newArray(int size) { + return new InputBinding[size]; + } + }; + + public int describeContents() { + return 0; + } +} diff --git a/src/api-impl/android/view/inputmethod/InputConnection.java b/src/api-impl/android/view/inputmethod/InputConnection.java index 2b9d174f..d62f8bf6 100644 --- a/src/api-impl/android/view/inputmethod/InputConnection.java +++ b/src/api-impl/android/view/inputmethod/InputConnection.java @@ -15,12 +15,9 @@ */ package android.view.inputmethod; import android.os.Bundle; +import android.view.KeyEvent; class ExtractedText {} -class ExtractedTextRequest {} -class CompletionInfo {} -class CorrectionInfo {} -class KeyEvent {} /** * The InputConnection interface is the communication channel from an diff --git a/src/api-impl/android/view/inputmethod/InputMethod.java b/src/api-impl/android/view/inputmethod/InputMethod.java new file mode 100644 index 00000000..f048f0a5 --- /dev/null +++ b/src/api-impl/android/view/inputmethod/InputMethod.java @@ -0,0 +1,7 @@ +package android.view.inputmethod; + +public interface InputMethod { + public interface SessionCallback { + public void sessionCreated(InputMethodSession session); + } +} diff --git a/src/api-impl/android/view/inputmethod/InputMethodInfo.java b/src/api-impl/android/view/inputmethod/InputMethodInfo.java new file mode 100644 index 00000000..439c3364 --- /dev/null +++ b/src/api-impl/android/view/inputmethod/InputMethodInfo.java @@ -0,0 +1,5 @@ +package android.view.inputmethod; + +public final class InputMethodInfo { + +} diff --git a/src/api-impl/android/view/inputmethod/InputMethodManager.java b/src/api-impl/android/view/inputmethod/InputMethodManager.java index 3ba5ef0d..7a9afdb3 100644 --- a/src/api-impl/android/view/inputmethod/InputMethodManager.java +++ b/src/api-impl/android/view/inputmethod/InputMethodManager.java @@ -1,5 +1,6 @@ package android.view.inputmethod; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -8,6 +9,8 @@ import android.view.View; public class InputMethodManager { + private ArrayList input_method_list = new ArrayList(); + public boolean hideSoftInputFromWindow(IBinder windowToken, int flags) {return false;} public boolean showSoftInput(View view, int flags) {return false;} @@ -16,8 +19,12 @@ public class InputMethodManager { public boolean isActive(View view) {return false;} - public List/**/ getEnabledInputMethodList() { - return Collections.emptyList(); + public List getEnabledInputMethodList() { + return input_method_list; + } + + public List getInputMethodList() { + return input_method_list; } public void restartInput(View view) {} diff --git a/src/api-impl/android/view/inputmethod/InputMethodSession.java b/src/api-impl/android/view/inputmethod/InputMethodSession.java new file mode 100644 index 00000000..f8beb8e9 --- /dev/null +++ b/src/api-impl/android/view/inputmethod/InputMethodSession.java @@ -0,0 +1,5 @@ +package android.view.inputmethod; + +public interface InputMethodSession { + +}