@@ -214,26 +214,22 @@ class PrefMainActivity :
214
214
class PrefFragment : PreferenceFragmentCompat () {
215
215
override fun onCreatePreferences (savedInstanceState : Bundle ? , rootKey : String? ) {
216
216
setPreferencesFromResource(R .xml.prefs, rootKey)
217
- if (ImeUtils .checkIfImeIsEnabled (requireContext())) {
217
+ if (InputMethodUtils .checkIsTrimeEnabled (requireContext())) {
218
218
findPreference<Preference >(" pref_enable" )?.isVisible = false
219
219
}
220
- if (ImeUtils .checkIfImeIsSelected (requireContext())) {
220
+ if (InputMethodUtils .checkisTrimeSelected (requireContext())) {
221
221
findPreference<Preference >(" pref_select" )?.isVisible = false
222
222
}
223
223
}
224
224
225
225
override fun onPreferenceTreeClick (preference : Preference ? ): Boolean {
226
226
return when (preference?.key) {
227
227
" pref_enable" -> { // 啓用
228
- val intent = Intent ()
229
- intent.action = Settings .ACTION_INPUT_METHOD_SETTINGS
230
- intent.addCategory(Intent .CATEGORY_DEFAULT )
231
- startActivity(intent)
228
+ InputMethodUtils .showImeEnablerActivity(requireContext())
232
229
true
233
230
}
234
231
" pref_select" -> { // 切換
235
- (activity as PrefMainActivity ).imeManager.showInputMethodPicker()
236
- true
232
+ InputMethodUtils .showImePicker(requireContext())
237
233
}
238
234
" pref_schemas" -> {
239
235
SchemaPickerDialog (requireContext()).show()
@@ -245,10 +241,10 @@ class PrefMainActivity :
245
241
246
242
override fun onResume () { // 如果同文已被启用/选用,则隐藏设置项
247
243
super .onResume()
248
- if (ImeUtils .checkIfImeIsEnabled (requireContext())) {
244
+ if (InputMethodUtils .checkIsTrimeEnabled (requireContext())) {
249
245
findPreference<Preference >(" pref_enable" )?.isVisible = false
250
246
}
251
- if (ImeUtils .checkIfImeIsSelected (requireContext())) {
247
+ if (InputMethodUtils .checkisTrimeSelected (requireContext())) {
252
248
findPreference<Preference >(" pref_select" )?.isVisible = false
253
249
}
254
250
}
0 commit comments