File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed
app/src/main/java/com/osfans/trime/ime/core Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -70,15 +70,16 @@ abstract class BaseInputView(
7070 return 0
7171 }
7272 val insets = WindowInsetsCompat .toWindowInsetsCompat(windowInsets)
73- // use navigation bar insets when available
7473 val navBars = insets.getInsets(WindowInsetsCompat .Type .navigationBars())
75- // in case navigation bar insets goes wrong (eg. on LineageOS 21+ with gesture navigation)
76- // use mandatory system gesture insets
7774 val mandatory = insets.getInsets(WindowInsetsCompat .Type .mandatorySystemGestures())
75+ // If navBars is 0 but mandatory is non-zero, likely gesture nav - don't add inset
76+ if (navBars.bottom == 0 && mandatory.bottom > 0 ) {
77+ return 0
78+ }
7879 var insetsBottom = max(navBars.bottom, mandatory.bottom)
7980 if (insetsBottom <= 0 ) {
80- // check system gesture insets and fallback to navigation_bar_frame_height just in case
81- val gesturesBottom = insets.getInsets( WindowInsetsCompat . Type .systemGestures()) .bottom
81+ val gestures = insets.getInsets( WindowInsetsCompat . Type .systemGestures())
82+ val gesturesBottom = gestures .bottom
8283 if (gesturesBottom > 0 ) {
8384 insetsBottom = max(gesturesBottom, navBarFrameHeight)
8485 }
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import android.widget.FrameLayout
3232import androidx.annotation.Keep
3333import androidx.annotation.RequiresApi
3434import androidx.core.content.ContextCompat
35+ import androidx.core.view.WindowInsetsCompat
3536import androidx.core.view.updateLayoutParams
3637import androidx.lifecycle.lifecycleScope
3738import com.osfans.trime.core.KeyModifiers
@@ -449,8 +450,12 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
449450 touchableInsets = Insets .TOUCHABLE_INSETS_VISIBLE
450451 }
451452 } else {
452- val n = decorView.findViewById<View >(android.R .id.navigationBarBackground)?.height ? : 0
453- val h = decorView.height - n
453+ val insets = WindowInsetsCompat .toWindowInsetsCompat(decorView.rootWindowInsets)
454+ val navBarHeight = insets?.getInsets(WindowInsetsCompat .Type .navigationBars())?.bottom ? : 0
455+ val mandatoryHeight = insets?.getInsets(WindowInsetsCompat .Type .mandatorySystemGestures())?.bottom ? : 0
456+ // If navBarHeight is 0 but mandatory is non-zero, likely gesture nav - don't add inset
457+ val finalNavHeight = if (navBarHeight == 0 && mandatoryHeight > 0 ) 0 else maxOf(navBarHeight, mandatoryHeight)
458+ val h = decorView.height - finalNavHeight
454459 outInsets.apply {
455460 contentTopInsets = h
456461 visibleTopInsets = h
You can’t perform that action at this time.
0 commit comments