55import android .content .Intent ;
66import android .content .IntentFilter ;
77import android .inputmethodservice .InputMethodService ;
8+ import android .util .Base64 ;
89import android .view .View ;
910import android .view .inputmethod .EditorInfo ;
1011
1819
1920public class ZixieIME extends InputMethodService {
2021
21- public String IME_ADB_INPUT_ACTION = "ZIXIE_ADB_INPUT" ;
22-
22+ public String IME_ADB_INPUT_ACTION_TEXT = "ZIXIE_ADB_INPUT_TEXT" ;
23+ public String IME_ADB_INPUT_ACTION_BASE64 = "ZIXIE_ADB_INPUT_BASE64" ;
24+
2325 public static final String TAG = "InputService" ;
2426 private InputServiceActionListener mInputServiceActionListener = null ;
2527
@@ -37,8 +39,9 @@ public View onCreateInputView() {
3739 View mInputView = getLayoutInflater ().inflate (R .layout .layout_input_keyboard_global , null );
3840 initView (mInputView );
3941 if (mReceiver == null ) {
40- IntentFilter filter = new IntentFilter (IME_ADB_INPUT_ACTION );
41- filter .addAction (IME_ADB_INPUT_ACTION );
42+ IntentFilter filter = new IntentFilter (IME_ADB_INPUT_ACTION_TEXT );
43+ filter .addAction (IME_ADB_INPUT_ACTION_TEXT );
44+ filter .addAction (IME_ADB_INPUT_ACTION_BASE64 );
4245 mReceiver = new AdbReceiver ();
4346 registerReceiver (mReceiver , filter );
4447 }
@@ -113,11 +116,16 @@ public void onChangeInputType(int currentInputType) {
113116 class AdbReceiver extends BroadcastReceiver {
114117 @ Override
115118 public void onReceive (Context context , Intent intent ) {
116- if (intent .getAction ().equals (IME_ADB_INPUT_ACTION )) {
119+ if (intent .getAction ().equals (IME_ADB_INPUT_ACTION_TEXT )) {
117120 String msg = intent .getStringExtra ("msg" );
118121 if (msg != null ) {
119122 InputManager .INSTANCE .commitResultText (msg );
120123 }
124+ }else if (intent .getAction ().equals (IME_ADB_INPUT_ACTION_BASE64 )) {
125+ String msg = intent .getStringExtra ("msg" );
126+ if (msg != null ) {
127+ InputManager .INSTANCE .commitResultText (new String (Base64 .decode (msg , Base64 .DEFAULT )));
128+ }
121129 }
122130 }
123131 }
0 commit comments