Skip to content

Commit

Permalink
fix: 输入状态下切换深色模式时,悬浮窗无法关闭
Browse files Browse the repository at this point in the history
  • Loading branch information
nopdan authored and WhiredPlanck committed Jul 7, 2024
1 parent 81258b3 commit 9a5d296
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ class CompositionPopupWindow(
theme.generalStyle.layout.alpha,
),
)
elevation = ctx.dp(theme.generalStyle.layout.elevation.toFloat())
elevation =
ctx.dp(
theme.generalStyle.layout.elevation
.toFloat(),
)
}

var isCursorUpdated = false // 光標是否移動
Expand Down Expand Up @@ -170,11 +174,12 @@ class CompositionPopupWindow(
}
}

fun isWinFixed(): Boolean {
return Build.VERSION.SDK_INT <= VERSION_CODES.LOLLIPOP ||
popupWindowPos !== PopupPosition.LEFT && popupWindowPos !== PopupPosition.RIGHT &&
popupWindowPos !== PopupPosition.LEFT_UP && popupWindowPos !== PopupPosition.RIGHT_UP
}
fun isWinFixed(): Boolean =
Build.VERSION.SDK_INT <= VERSION_CODES.LOLLIPOP ||
popupWindowPos !== PopupPosition.LEFT &&
popupWindowPos !== PopupPosition.RIGHT &&
popupWindowPos !== PopupPosition.LEFT_UP &&
popupWindowPos !== PopupPosition.RIGHT_UP

private fun updatePopupWindow(
offsetX: Int,
Expand All @@ -195,7 +200,7 @@ class CompositionPopupWindow(
}
}

private fun hideCompositionView() {
fun hideCompositionView() {
mPopupWindow.dismiss()
mPopupHandler.removeCallbacks(mPopupTimer)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
postRimeJob { clearComposition() }
inputView?.composition?.hideCompositionView()
ColorManager.onSystemNightModeChange(newConfig.isNightMode())
}

Expand Down Expand Up @@ -429,6 +430,7 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
}

override fun onCreateInputView(): View {
Timber.d("onCreateInputView")
postRimeJob(Dispatchers.Main) {
recreateInputView()
}
Expand All @@ -438,7 +440,8 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {

override fun setInputView(view: View) {
val inputArea =
window.window!!.decorView
window.window!!
.decorView
.findViewById<FrameLayout>(android.R.id.inputArea)
inputArea.updateLayoutParams<ViewGroup.LayoutParams> {
height = ViewGroup.LayoutParams.MATCH_PARENT
Expand Down Expand Up @@ -541,7 +544,9 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
} else if (attribute.packageName == BuildConfig.APPLICATION_ID ||
prefs
.clipboard
.draftExcludeApp.trim().split('\n')
.draftExcludeApp
.trim()
.split('\n')
.contains(attribute.packageName)
) {
normalTextEditor = false
Expand Down Expand Up @@ -1170,13 +1175,9 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
}
}

fun addEventListener(listener: EventListener): Boolean {
return eventListeners.add(listener)
}
fun addEventListener(listener: EventListener): Boolean = eventListeners.add(listener)

fun removeEventListener(listener: EventListener): Boolean {
return eventListeners.remove(listener)
}
fun removeEventListener(listener: EventListener): Boolean = eventListeners.remove(listener)

interface EventListener {
fun onCreate() {}
Expand All @@ -1197,13 +1198,9 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
var self: TrimeInputMethodService? = null

@JvmStatic
fun getService(): TrimeInputMethodService {
return self ?: throw IllegalStateException("Trime not initialized")
}
fun getService(): TrimeInputMethodService = self ?: throw IllegalStateException("Trime not initialized")

fun getServiceOrNull(): TrimeInputMethodService? {
return self
}
fun getServiceOrNull(): TrimeInputMethodService? = self

private val syncBackgroundHandler =
Handler(
Expand Down

0 comments on commit 9a5d296

Please sign in to comment.