File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
app/src/main/java/com/osfans/trime/ime/keyboard Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change 44
55package com.osfans.trime.ime.keyboard
66
7+ import android.graphics.Point
8+ import android.os.Build
79import android.view.KeyEvent
810import android.view.WindowInsets
911import android.view.WindowManager
@@ -98,12 +100,19 @@ class Keyboard(
98100 if (appContext.isLandscapeMode()) keyboardPaddingLand else keyboardPadding
99101 }
100102
101- val windowMetrics = appContext.windowManager.currentWindowMetrics
102- val insets = windowMetrics.windowInsets.getInsetsIgnoringVisibility(
103- WindowInsets .Type .systemBars() or WindowInsets .Type .displayCutout(),
104- )
105-
106- val safeWidth = windowMetrics.bounds.width() - insets.left - insets.right
103+ val safeWidth = if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .R ) {
104+ val windowMetrics = appContext.windowManager.currentWindowMetrics
105+ val insets = windowMetrics.windowInsets.getInsetsIgnoringVisibility(
106+ WindowInsets .Type .systemBars() or WindowInsets .Type .displayCutout(),
107+ )
108+ windowMetrics.bounds.width() - insets.left - insets.right
109+ } else {
110+ @Suppress(" DEPRECATION" )
111+ val size = Point ()
112+ @Suppress(" DEPRECATION" )
113+ appContext.windowManager.defaultDisplay.getSize(size)
114+ size.x
115+ }
107116 return safeWidth - 2 * appContext.dp(padding)
108117 }
109118
You can’t perform that action at this time.
0 commit comments