Skip to content

Commit

Permalink
perf: improve adaptation of setup activity
Browse files Browse the repository at this point in the history
  • Loading branch information
tumuyan authored and Bambooin committed Apr 15, 2022
1 parent 9e59277 commit 1a6d9a8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions app/src/main/java/com/osfans/trime/common/InputMethodUtils.kt
Expand Up @@ -4,11 +4,15 @@ import android.content.Context
import android.content.Intent
import android.provider.Settings
import android.view.inputmethod.InputMethodManager
import com.osfans.trime.BuildConfig
import com.osfans.trime.TrimeApplication
import timber.log.Timber

object InputMethodUtils {
private const val IME_ID: String = "com.osfans.trime/.TrimeImeService"

private const val IME_ID0: String = "com.osfans.trime/.TrimeImeService"
private const val IME_ID1: String = BuildConfig.APPLICATION_ID + "/com.osfans.trime.TrimeImeService"
// var packageName = javaClass.getPackage().name
private val context: Context
get() = TrimeApplication.getInstance().applicationContext

Expand All @@ -17,8 +21,11 @@ object InputMethodUtils {
context.contentResolver,
Settings.Secure.ENABLED_INPUT_METHODS
) ?: "(none)"

Timber.i("List of active IMEs: $activeImeIds")
return activeImeIds.split(":").contains(IME_ID)
if (activeImeIds.split(":").contains(IME_ID0))
return true
return activeImeIds.split(":").contains(IME_ID1)
}

fun checkIsTrimeSelected(): Boolean {
Expand All @@ -27,7 +34,9 @@ object InputMethodUtils {
Settings.Secure.DEFAULT_INPUT_METHOD
) ?: "(none)"
Timber.i("Selected IME: $selectedImeIds")
return selectedImeIds == IME_ID
if (selectedImeIds == IME_ID0)
return true
return selectedImeIds == IME_ID1
}

fun showImeEnablerActivity(context: Context) {
Expand Down

0 comments on commit 1a6d9a8

Please sign in to comment.