Skip to content

Commit 1d9becf

Browse files
committed
Prevent bottom inset going negative
This caused the bottom of the game to get cut off on Chromebook (insets.bottom == 0)
1 parent 49f78fb commit 1d9becf

File tree

1 file changed

+2
-1
lines changed
  • app/src/main/kotlin/name/boyle/chris/sgtpuzzles

1 file changed

+2
-1
lines changed

app/src/main/kotlin/name/boyle/chris/sgtpuzzles/GamePlay.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ import java.lang.ref.WeakReference
150150
import java.text.MessageFormat
151151
import java.util.concurrent.Future
152152
import java.util.regex.Pattern
153+
import kotlin.math.max
153154
import kotlin.math.roundToInt
154155

155156
class GamePlay : ActivityWithLoadButton(), OnSharedPreferenceChangeListener, GameGenerator.Callback,
@@ -305,7 +306,7 @@ class GamePlay : ActivityWithLoadButton(), OnSharedPreferenceChangeListener, Gam
305306
if (progress == null && gameView.w > 10 && gameView.h > 10) {
306307
val bottomInsetPx = if (resources.configuration.orientation == ORIENTATION_LANDSCAPE) {
307308
val insets = ViewCompat.getRootWindowInsets(gameView)?.getInsets(systemBars() or displayCutout() or ime())
308-
insets?.bottom?.minus(statusBar.height) ?: 0
309+
max(insets?.bottom?.minus(statusBar.height) ?: 0, 0)
309310
} else 0
310311
val bottomInset = pxToDp(bottomInsetPx.toFloat(), resources.displayMetrics).toInt()
311312
gameEngine.resizeEvent(gameView.wDip, gameView.hDip, bottomInset)

0 commit comments

Comments
 (0)