|
@@ -7,6 +7,8 @@ import android.content.Intent
|
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
|
import android.os.Handler
|
|
import android.os.Handler
|
|
|
import android.os.Looper
|
|
import android.os.Looper
|
|
|
|
|
+import androidx.lifecycle.Lifecycle
|
|
|
|
|
+import androidx.lifecycle.ProcessLifecycleOwner
|
|
|
import com.atmob.keyboard_android.util.InputMethodUtil
|
|
import com.atmob.keyboard_android.util.InputMethodUtil
|
|
|
import com.atmob.keyboard_android.util.LogUtil
|
|
import com.atmob.keyboard_android.util.LogUtil
|
|
|
|
|
|
|
@@ -23,10 +25,16 @@ class InputMethodPickerActivity : Activity() {
|
|
|
* 启动
|
|
* 启动
|
|
|
*/
|
|
*/
|
|
|
fun start(context: Context) {
|
|
fun start(context: Context) {
|
|
|
- val intent = Intent(context, InputMethodPickerActivity::class.java)
|
|
|
|
|
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
|
|
|
|
|
- val options = ActivityOptions.makeCustomAnimation(context, 0, 0)
|
|
|
|
|
- context.startActivity(intent, options.toBundle())
|
|
|
|
|
|
|
+ // App在前台,直接显示输入法选择弹窗,如果统一都用透明Activity来处理,在平板下的小窗模式中,会导致透明Activity显示为小窗
|
|
|
|
|
+ if (ProcessLifecycleOwner.get().lifecycle.currentState == Lifecycle.State.RESUMED) {
|
|
|
|
|
+ InputMethodUtil.showInputMethodPicker(context)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 在后台,使用一个透明的Activity来触发输入法选择器
|
|
|
|
|
+ val intent = Intent(context, InputMethodPickerActivity::class.java)
|
|
|
|
|
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
|
|
|
|
|
+ val options = ActivityOptions.makeCustomAnimation(context, 0, 0)
|
|
|
|
|
+ context.startActivity(intent, options.toBundle())
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|