@@ -14,6 +14,7 @@ import com.bihe0832.android.base.adb.input.switcher.InputSwitchTools
1414import com.bihe0832.android.framework.ZixieContext
1515import com.bihe0832.android.framework.ui.BaseFragment
1616import com.bihe0832.android.lib.text.TextFactoryUtils
17+ import com.bihe0832.android.lib.thread.ThreadManager
1718import com.bihe0832.android.lib.utils.apk.APKUtils
1819import com.bihe0832.android.lib.utils.intent.IntentUtils
1920import 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
0 commit comments