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:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user