Skip to content

Commit 59be77e

Browse files
committed
fix: width overflow during landscape viewing
perf: reduce duplicate keyboard loading
1 parent 8123c25 commit 59be77e

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

app/src/main/java/com/osfans/trime/ime/keyboard/Keyboard.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,10 +640,12 @@ class Keyboard() {
640640
val keyboardSidePaddingLandscape = theme.style.getInt("keyboard_padding_land")
641641

642642
val keyboardSidePaddingPx =
643-
when (appContext.resources.configuration.orientation) {
644-
Configuration.ORIENTATION_LANDSCAPE -> keyboardSidePaddingLandscape
645-
else -> keyboardSidePadding
646-
}.apply { appContext.dp(this) }
643+
appContext.dp(
644+
when (appContext.resources.configuration.orientation) {
645+
Configuration.ORIENTATION_LANDSCAPE -> keyboardSidePaddingLandscape
646+
else -> keyboardSidePadding
647+
},
648+
)
647649

648650
mDisplayWidth = ScreenUtils.getAppScreenWidth() - 2 * keyboardSidePaddingPx
649651

app/src/main/java/com/osfans/trime/ime/keyboard/KeyboardSwitcher.kt

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ object KeyboardSwitcher {
1616
private var currentKeyboardId = ".default"
1717
private var lastKeyboardId = ".default"
1818
private var lastLockKeyboardId = ".default"
19-
private var currentDisplayWidth: Int = 0
2019
private val keyboardPrefs = KeyboardPrefs()
2120

2221
lateinit var currentKeyboard: Keyboard
@@ -40,7 +39,6 @@ object KeyboardSwitcher {
4039
currentKeyboardId = ".default"
4140
lastKeyboardId = ".default"
4241
lastLockKeyboardId = ".default"
43-
currentDisplayWidth = 0
4442
keyboardCache.clear()
4543
switchKeyboard(currentKeyboardId)
4644
}
@@ -138,13 +136,4 @@ object KeyboardSwitcher {
138136
Timber.d("Could not find keyboard layout $layout, fallback to default")
139137
return "default"
140138
}
141-
142-
/**
143-
* Change current display width when e.g. rotate the screen.
144-
*/
145-
fun resize(displayWidth: Int) {
146-
if (displayWidth == currentDisplayWidth) return
147-
currentDisplayWidth = displayWidth
148-
newOrReset()
149-
}
150139
}

app/src/main/java/com/osfans/trime/ime/text/TextInputManager.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ class TextInputManager private constructor() :
200200
}
201201

202202
KeyboardSwitcher.run {
203-
resize(trime.maxWidth)
204203
// Select a keyboard based on the input type of the editing field.
205204
switchKeyboard(keyboardType)
206205
}

0 commit comments

Comments
 (0)