Merge "Line number of modifier keys is relying on the height of keys' view" into main am: 148d2ae86e am: 5a3294e0dc
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Virtualization/+/3537140
Change-Id: I48807a29487184b76738b05fd1a11a23e9eccc7e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/ModifierKeysController.kt b/android/TerminalApp/java/com/android/virtualization/terminal/ModifierKeysController.kt
index ed340d2..7c3eb69 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/ModifierKeysController.kt
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/ModifierKeysController.kt
@@ -115,10 +115,12 @@
activeTerminalView!!.hasFocus() &&
!(activity.resources.configuration.keyboard == Configuration.KEYBOARD_QWERTY)
- // If terminal's height is less than 30% of the screen height, we need to show modifier keys in
- // a single line to save the vertical space
- private fun needsKeysInSingleLine(): Boolean =
- activeTerminalView!!.height.div(activity.window.decorView.height.toFloat()) < 0.3f
+ // If terminal's height including height of modifier keys is less than 40% of the screen
+ // height, we need to show modifier keys in a single line to save the vertical space
+ private fun needsKeysInSingleLine(): Boolean {
+ val keys = if (keysInSingleLine) keysSingleLine else keysDoubleLine
+ return activeTerminalView!!.height + keys.height < 0.4f * activity.window.decorView.height
+ }
companion object {
private val BTN_KEY_CODE_MAP =