Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 输入状态下切换深色模式时,悬浮窗无法关闭 #1420

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading