Skip to content

Commit f51b6fd

Browse files
committed
输入内容支持base64
1 parent 7443fc3 commit f51b6fd

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

BaseAdbInput/src/main/java/com/bihe0832/android/base/adb/input/ZixieIME.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.content.Intent;
66
import android.content.IntentFilter;
77
import android.inputmethodservice.InputMethodService;
8+
import android.util.Base64;
89
import android.view.View;
910
import android.view.inputmethod.EditorInfo;
1011

@@ -18,8 +19,9 @@
1819

1920
public 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
}

BaseAdbInput/src/main/java/com/bihe0832/android/base/adb/input/settings/InputSettingsFragment.kt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,15 @@ class InputSettingsFragment : BaseFragment() {
6565
})
6666
}
6767

68-
var color = resources.getColor(R.color.colorPrimary)
69-
var tips = "1. 手机通过<b><font color='$color'>ADB</font>连接到电脑</b>,并将手机输入法<b>切换为<font color='$color'>${APKUtils.getAppName(context)}</font></b>" + "<BR>2. 激活需要输入内容的输入框" + "<BR>3. 在电脑端用命令行输入 <b><font color='$color'>adb shell am broadcast -a ZIXIE_ADB_INPUT --es msg \"DATA\"</font></b>,DATA 即为要输入的内容" + "<BR>4. <b>ADB 常用命令使用方法可以点击查看: <font color='$color'>https://blog.bihe0832.com/review_adb.html</font></b>"
68+
69+
var tips = "1. 手机通过<b>${getColorText("ADB")}连接到电脑</b>,并将手机输入法<b>切换为${getColorText(APKUtils.getAppName(context))}</b>" +
70+
"<BR>2. 激活需要输入内容的输入框" +
71+
"<BR>3. 对于<b>${getColorText("简单文本")}</b>,在电脑端用命令行输入 <b>${getColorText("adb shell am broadcast -a ZIXIE_ADB_INPUT_TEXT --es msg \"DATA\"")}</b>,DATA 即为要<b>输入内容</b>" +
72+
"<BR>4. 对于<b>${getColorText("复杂文本")}</b>,在电脑端用命令行输入 <b>${getColorText("adb shell am broadcast -a ZIXIE_ADB_INPUT_BASE64 --es msg \"DATA\"")}</b>,DATA 即为要<b>输入内容的Base64编码</b>" +
73+
"<BR>5. <b>更多使用方法介绍及、ADB 常用命令使用方法可以点击查看: ${getColorText("https://blog.bihe0832.com/input.html")}</b>"
7074
val list = HashMap<String, View.OnClickListener>().apply {
71-
put("https://blog.bihe0832.com/review_adb.html", View.OnClickListener {
72-
openWebPage("https://blog.bihe0832.com/review_adb.html")
75+
put("https://blog.bihe0832.com/input.html", View.OnClickListener {
76+
openWebPage("https://blog.bihe0832.com/input.html")
7377
})
7478
}
7579
input_settings_input_help_tips.apply {
@@ -80,6 +84,11 @@ class InputSettingsFragment : BaseFragment() {
8084
updateView()
8185
}
8286

87+
private fun getColorText(content: String): String {
88+
var color = resources.getColor(R.color.colorPrimary)
89+
return TextFactoryUtils.getSpecialText(content, color)
90+
}
91+
8392
private fun updateView() {
8493
if (InputSwitchTools.hasInstall(context)) {
8594
input_settings_global_input_add.background = ContextCompat.getDrawable(context!!, R.drawable.keyboard_bg)

dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ext.moduleInfo = [
5252
"BaseDebug" : [
5353
"apidependenciesList" : [
5454
"com.bihe0832.android:common-debug:${project.aaf_test_version}",
55-
"Application", "BaseCard", "BaseAdbInput"
55+
"Application", "BaseCard"
5656
// , "BasePuzzleGame","BaseM3U8"
5757
],
5858
specialdependenciesList: [

0 commit comments

Comments
 (0)