Skip to content

Commit

Permalink
fix: adjust InitializationUi's inset to unblock the whole screen
Browse files Browse the repository at this point in the history
  • Loading branch information
goofyz authored and WhiredPlanck committed Mar 22, 2024
1 parent 5d7ebbe commit 8d1ba86
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import android.view.inputmethod.ExtractedTextRequest
import android.widget.FrameLayout
import android.widget.LinearLayout
import androidx.annotation.Keep
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.lifecycle.lifecycleScope
import com.osfans.trime.BuildConfig
Expand Down Expand Up @@ -91,6 +92,7 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
private var mTabRoot: ScrollView? = null
private var tabView: TabView? = null
var inputView: InputView? = null
private var initializationUi: InitializationUi? = null
private var eventListeners = WeakHashSet<EventListener>()
private var mIntentReceiver: IntentReceiver? = null
private var isWindowShown = false // 键盘窗口是否已显示
Expand Down Expand Up @@ -333,6 +335,7 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
bindKeyboardToInputView()
updateComposing() // 切換主題時刷新候選
setInputView(inputView!!)
initializationUi = null
}

override fun onDestroy() {
Expand Down Expand Up @@ -422,7 +425,14 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
}

override fun onComputeInsets(outInsets: Insets) {
val (_, y) = intArrayOf(0, 0).also { inputView?.keyboardView?.getLocationInWindow(it) }
val (_, y) =
intArrayOf(0, 0).also {
if (inputView?.keyboardView?.isVisible == true) {
inputView?.keyboardView?.getLocationInWindow(it)
} else {
initializationUi?.initial?.getLocationInWindow(it)
}
}
outInsets.apply {
contentTopInsets = y
touchableInsets = Insets.TOUCHABLE_INSETS_CONTENT
Expand All @@ -432,12 +442,11 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
}

override fun onCreateInputView(): View {
Timber.d("onCreateInputView")
RimeWrapper.runAfterStarted {
recreateInputView()
}
Timber.d("onCreateInputView() finish")
return InitializationUi(this).root
initializationUi = InitializationUi(this)
return initializationUi!!.root
}

override fun setInputView(view: View) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import splitties.views.textResource
* TODO: Add a help or info button to show what's problem is behind the scene.
*/
class InitializationUi(override val ctx: Context) : Ui {
private val initial =
val initial =
constraintLayout {
backgroundColor = color(R.color.colorPrimaryDark)
val textView =
Expand Down

0 comments on commit 8d1ba86

Please sign in to comment.