mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-09 16:17:44 +00:00
replace AsyncTask
This commit is contained in:
parent
7dc6279d87
commit
c321c2c684
1 changed files with 9 additions and 8 deletions
|
@ -7,7 +7,7 @@ package helium314.keyboard.latin
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.inputmethodservice.InputMethodService
|
import android.inputmethodservice.InputMethodService
|
||||||
import android.os.AsyncTask
|
import android.os.Build
|
||||||
import android.view.inputmethod.InputMethodInfo
|
import android.view.inputmethod.InputMethodInfo
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.view.inputmethod.InputMethodSubtype
|
import android.view.inputmethod.InputMethodSubtype
|
||||||
|
@ -23,6 +23,8 @@ import helium314.keyboard.latin.utils.SubtypeSettings
|
||||||
import helium314.keyboard.latin.utils.getSecondaryLocales
|
import helium314.keyboard.latin.utils.getSecondaryLocales
|
||||||
import helium314.keyboard.latin.utils.locale
|
import helium314.keyboard.latin.utils.locale
|
||||||
import helium314.keyboard.latin.utils.prefs
|
import helium314.keyboard.latin.utils.prefs
|
||||||
|
import kotlinx.coroutines.GlobalScope
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
/** Enrichment class for InputMethodManager to simplify interaction and add functionality. */
|
/** Enrichment class for InputMethodManager to simplify interaction and add functionality. */
|
||||||
|
@ -125,16 +127,15 @@ class RichInputMethodManager private constructor() {
|
||||||
updateShortcutIme()
|
updateShortcutIme()
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: deprecated
|
|
||||||
fun switchToShortcutIme(inputMethodService: InputMethodService) {
|
fun switchToShortcutIme(inputMethodService: InputMethodService) {
|
||||||
val imiId = shortcutInputMethodInfo?.id ?: return
|
val imiId = shortcutInputMethodInfo?.id ?: return
|
||||||
val token = inputMethodService.window.window?.attributes?.token ?: return
|
val token = inputMethodService.window.window?.attributes?.token ?: return
|
||||||
object : AsyncTask<Void?, Void?, Void?>() {
|
GlobalScope.launch {
|
||||||
override fun doInBackground(vararg params: Void?): Void? {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
|
||||||
imm.setInputMethodAndSubtype(token, imiId, shortcutSubtype)
|
inputMethodService.switchInputMethod(imiId, shortcutSubtype)
|
||||||
return null
|
else
|
||||||
|
@Suppress("Deprecation") imm.setInputMethodAndSubtype(token, imiId, shortcutSubtype)
|
||||||
}
|
}
|
||||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo: is shortcutIme only voice input, or can it be something else?
|
// todo: is shortcutIme only voice input, or can it be something else?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue