Skip to content

Commit 1b9d7d9

Browse files
committed
升级基础库,修复输入法设置以后自动检测没有生效的问题
1 parent 03fe32a commit 1b9d7d9

File tree

7 files changed

+35
-23
lines changed

7 files changed

+35
-23
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
public class ZixieIME extends InputMethodService {
2020

2121
public String IME_ADB_INPUT_ACTION = "ZIXIE_ADB_INPUT";
22-
public static final String IME_NAME = "com.bihe0832.android.app.test/com.bihe0832.android.base.adb.input.ZixieIME";
22+
public static final String IME_NAME = "com.bihe0832.adb.input/com.bihe0832.android.base.adb.input.ZixieIME";
2323

2424
public static final String TAG = "InputService";
2525
private InputServiceActionListener mInputServiceActionListener = null;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class InputSettingsActivity : BaseActivity() {
2121
override fun onCreate(savedInstanceState: Bundle?) {
2222
super.onCreate(savedInstanceState)
2323
setContentView(R.layout.activity_input_settings)
24-
initToolbar(R.id.common_toolbar, "输入法设置引导", true)
24+
initToolbar(R.id.common_toolbar, "输入法设置引导", needTitleCenter = false, needBack = true, iconRes = R.mipmap.icon_left_arrow_white)
2525
showInputMethodPicker(intent)
2626
if (findFragment(InputSettingsFragment::class.java) == null) {
2727
loadRootFragment(R.id.common_fragment_content, InputSettingsFragment())

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

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.bihe0832.android.base.adb.input.switcher.InputSwitchTools
1414
import com.bihe0832.android.framework.ZixieContext
1515
import com.bihe0832.android.framework.ui.BaseFragment
1616
import com.bihe0832.android.lib.text.TextFactoryUtils
17+
import com.bihe0832.android.lib.thread.ThreadManager
1718
import com.bihe0832.android.lib.utils.apk.APKUtils
1819
import com.bihe0832.android.lib.utils.intent.IntentUtils
1920
import kotlinx.android.synthetic.main.fragment_input_settings.*
@@ -31,19 +32,18 @@ class InputSettingsFragment : BaseFragment() {
3132

3233
override fun initView(view: View) {
3334
super.initView(view)
34-
if (InputSwitchTools.hasInstall(context)) {
35-
input_settings_global_input_add.setOnClickListener {
36-
ZixieContext.showToast("输入法已添加")
37-
}
38-
input_settings_global_input_add.background = ContextCompat.getDrawable(context!!, R.drawable.keyboard_bg)
39-
} else {
40-
input_settings_global_input_add.setOnClickListener {
41-
IntentUtils.startSettings(activity, Settings.ACTION_INPUT_METHOD_SETTINGS)
42-
}
35+
36+
input_settings_global_input_add.setOnClickListener {
37+
IntentUtils.startSettings(activity, Settings.ACTION_INPUT_METHOD_SETTINGS)
4338
}
4439

4540
input_settings_global_input_switch.setOnClickListener {
4641
(activity?.getSystemService(SupportActivity.INPUT_METHOD_SERVICE) as InputMethodManager).showInputMethodPicker()
42+
ThreadManager.getInstance().start({
43+
ThreadManager.getInstance().runOnUIThread {
44+
updateView()
45+
}
46+
}, 1)
4747
}
4848

4949
input_settings_item_notify_switch.apply {
@@ -65,15 +65,8 @@ class InputSettingsFragment : BaseFragment() {
6565
})
6666
}
6767

68-
if (InputSwitchConfig.canNotify()) {
69-
InputSwitchTools.checkPermissionAndShow(activity!!)
70-
}
71-
7268
var color = resources.getColor(R.color.colorPrimary)
73-
var tips = "1. 手机通过<b><font color='$color'>ADB</font>连接到电脑</b>,并将手机输入法<b>切换为<font color='$color'>${APKUtils.getAppName(context)}</font></b>" +
74-
"<BR>2. 激活需要输入内容的输入框" +
75-
"<BR>3. 在电脑端用命令行输入 <b><font color='$color'>adb shell am broadcast -a ZIXIE_ADB_INPUT --es msg \"DATA\"</font></b>,DATA 即为要输入的内容" +
76-
"<BR>4. <b>ADB 常用命令使用方法可以点击查看: <font color='$color'>https://blog.bihe0832.com/review_adb.html</font></b>"
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>"
7770
val list = HashMap<String, View.OnClickListener>().apply {
7871
put("https://blog.bihe0832.com/review_adb.html", View.OnClickListener {
7972
openWebPage("https://blog.bihe0832.com/review_adb.html")
@@ -83,13 +76,27 @@ class InputSettingsFragment : BaseFragment() {
8376
setText(TextFactoryUtils.getCharSequenceWithClickAction(tips, list))
8477
setMovementMethod(LinkMovementMethod.getInstance())
8578
}
79+
80+
updateView()
8681
}
8782

8883
private fun updateView() {
84+
if (InputSwitchTools.hasInstall(context)) {
85+
input_settings_global_input_add.background = ContextCompat.getDrawable(context!!, R.drawable.keyboard_bg)
86+
} else {
87+
input_settings_global_input_add.background = ContextCompat.getDrawable(context!!, R.drawable.keyboard_enter_bg)
88+
}
89+
90+
if (InputSwitchTools.isSelected(context)) {
91+
input_settings_global_input_switch.background = ContextCompat.getDrawable(context!!, R.drawable.keyboard_bg)
92+
} else {
93+
input_settings_global_input_switch.background = ContextCompat.getDrawable(context!!, R.drawable.keyboard_enter_bg)
94+
}
95+
8996
if (!InputSwitchConfig.canNotify()) {
9097
InputSwitchTools.closeNotify(context)
9198
} else {
92-
InputSwitchTools.showInputSwitchNotify(activity!!)
99+
InputSwitchTools.checkPermissionAndShow(activity!!)
93100
}
94101
}
95102

BaseAdbInput/src/main/java/com/bihe0832/android/base/adb/input/switcher/InputSwitchTools.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ object InputSwitchTools {
3838
return false
3939
}
4040

41+
fun isSelected(context: Context?): Boolean {
42+
return Settings.Secure.getString(context?.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD).equals(ZixieIME.IME_NAME)
43+
44+
}
45+
4146
fun closeNotify(context: Context?) {
4247
context?.let {
4348
NotifyManager.cancelNotify(it, NOTIFYL_ID)

BaseAdbInput/src/main/res/layout/activity_input_settings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
android:id="@+id/about"
1818
android:layout_width="wrap_content"
1919
android:layout_height="wrap_content"
20-
android:layout_gravity="center_vertical"
20+
android:layout_gravity="center_vertical|end"
2121
android:layout_marginRight="16dp"
2222
android:src="@mipmap/ic_menu_white" />
2323

config.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ ext {
4242
//使用kotlin版本
4343
kotlin_version = '1.7.10'
4444

45-
aaf_test_version = '5.10.49'
46-
aaf_version = '5.10.49'
45+
aaf_test_version = '5.10.54'
46+
aaf_version = '5.10.54'
4747
}

demo/getapkinfo.png

-133 KB
Binary file not shown.

0 commit comments

Comments
 (0)