mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-04-28 12:17:57 +03:00
api-impl: add ATLKeyboardViewer to support launching IMEs
This commit is contained in:
parent
bb7eb461c8
commit
ced19e6d25
18 changed files with 781 additions and 8 deletions
|
@ -0,0 +1,77 @@
|
|||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* 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
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<? extends InputMethodService> cls = Class.forName(kb_class).asSubclass(InputMethodService.class);
|
||||
Constructor<? extends InputMethodService> 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();
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
}
|
||||
}
|
||||
}
|
245
src/api-impl/android/inputmethodservice/InputMethodService.java
Normal file
245
src/api-impl/android/inputmethodservice/InputMethodService.java
Normal file
|
@ -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 {
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 {}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package android.view.inputmethod;
|
||||
|
||||
public final class CompletionInfo {
|
||||
|
||||
}
|
104
src/api-impl/android/view/inputmethod/CorrectionInfo.java
Normal file
104
src/api-impl/android/view/inputmethod/CorrectionInfo.java
Normal file
|
@ -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<CorrectionInfo> CREATOR =
|
||||
new Parcelable.Creator<CorrectionInfo>() {
|
||||
public CorrectionInfo createFromParcel(Parcel source) {
|
||||
return new CorrectionInfo(source);
|
||||
}
|
||||
public CorrectionInfo[] newArray(int size) {
|
||||
return new CorrectionInfo[size];
|
||||
}
|
||||
};
|
||||
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
}
|
20
src/api-impl/android/view/inputmethod/EditorInfo.java
Normal file
20
src/api-impl/android/view/inputmethod/EditorInfo.java
Normal file
|
@ -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;
|
||||
}
|
|
@ -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<ExtractedTextRequest> CREATOR = new Parcelable.Creator<ExtractedTextRequest>() {
|
||||
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;
|
||||
}
|
||||
}
|
151
src/api-impl/android/view/inputmethod/InputBinding.java
Normal file
151
src/api-impl/android/view/inputmethod/InputBinding.java
Normal file
|
@ -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<InputBinding> CREATOR = new Parcelable.Creator<InputBinding>() {
|
||||
public InputBinding createFromParcel(Parcel source) {
|
||||
return new InputBinding(source);
|
||||
}
|
||||
|
||||
public InputBinding[] newArray(int size) {
|
||||
return new InputBinding[size];
|
||||
}
|
||||
};
|
||||
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
7
src/api-impl/android/view/inputmethod/InputMethod.java
Normal file
7
src/api-impl/android/view/inputmethod/InputMethod.java
Normal file
|
@ -0,0 +1,7 @@
|
|||
package android.view.inputmethod;
|
||||
|
||||
public interface InputMethod {
|
||||
public interface SessionCallback {
|
||||
public void sessionCreated(InputMethodSession session);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package android.view.inputmethod;
|
||||
|
||||
public final class InputMethodInfo {
|
||||
|
||||
}
|
|
@ -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<InputMethodInfo> input_method_list = new ArrayList<InputMethodInfo>();
|
||||
|
||||
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/*<InputMethodInfo>*/ getEnabledInputMethodList() {
|
||||
return Collections.emptyList();
|
||||
public List<InputMethodInfo> getEnabledInputMethodList() {
|
||||
return input_method_list;
|
||||
}
|
||||
|
||||
public List<InputMethodInfo> getInputMethodList() {
|
||||
return input_method_list;
|
||||
}
|
||||
|
||||
public void restartInput(View view) {}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
package android.view.inputmethod;
|
||||
|
||||
public interface InputMethodSession {
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue