You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
api-impl: add ATLKeyboardViewer to support launching IMEs
This commit is contained in:
@@ -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 {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user