diff --git a/gauguin-app/src/main/kotlin/org/piepmeyer/gauguin/ui/main/MainActivity.kt b/gauguin-app/src/main/kotlin/org/piepmeyer/gauguin/ui/main/MainActivity.kt index b51b8dd1..352aa050 100644 --- a/gauguin-app/src/main/kotlin/org/piepmeyer/gauguin/ui/main/MainActivity.kt +++ b/gauguin-app/src/main/kotlin/org/piepmeyer/gauguin/ui/main/MainActivity.kt @@ -109,7 +109,8 @@ class MainActivity : AppCompatActivity() { innerPadding.right, 0, ) - insets + + WindowInsetsCompat.CONSUMED } ViewCompat.setOnApplyWindowInsetsListener( diff --git a/gauguin-app/src/main/kotlin/org/piepmeyer/gauguin/ui/newgame/NewGameActivity.kt b/gauguin-app/src/main/kotlin/org/piepmeyer/gauguin/ui/newgame/NewGameActivity.kt index c216aac7..643d21e3 100644 --- a/gauguin-app/src/main/kotlin/org/piepmeyer/gauguin/ui/newgame/NewGameActivity.kt +++ b/gauguin-app/src/main/kotlin/org/piepmeyer/gauguin/ui/newgame/NewGameActivity.kt @@ -3,6 +3,8 @@ package org.piepmeyer.gauguin.ui.newgame import android.os.Bundle import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat import androidx.fragment.app.commit import androidx.lifecycle.ViewModelProvider import com.google.android.material.bottomsheet.BottomSheetBehavior @@ -17,11 +19,11 @@ class NewGameActivity : AppCompatActivity() { private lateinit var viewModel: NewGameViewModel public override fun onCreate(savedInstanceState: Bundle?) { + enableEdgeToEdge() setTheme(R.style.AppTheme) super.onCreate(savedInstanceState) val binding = ActivityNewgameBinding.inflate(layoutInflater) - enableEdgeToEdge() setContentView(binding.root) activityUtils.configureTheme(this) @@ -46,8 +48,39 @@ class NewGameActivity : AppCompatActivity() { val bottomSheetBehavior = BottomSheetBehavior.from(it) bottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED } + + ViewCompat.setOnApplyWindowInsetsListener( + binding.newGameGridShapeOptions, + ) { v, insets -> + val innerPadding = + insets.getInsets( + WindowInsetsCompat.Type.systemBars() + or WindowInsetsCompat.Type.displayCutout(), + ) + + if (hasVerticalBaseLayout(binding)) { + v.setPadding( + innerPadding.left, + innerPadding.top, + innerPadding.right, + 0, + ) + } else { + v.setPadding( + innerPadding.left, + innerPadding.top, + 0, + innerPadding.bottom, + ) + } + + WindowInsetsCompat.CONSUMED + } } + private fun hasVerticalBaseLayout(binding: ActivityNewgameBinding): Boolean = + binding.root.tag == "newGameLayoutDefault" || binding.root.tag == "newGameLayoutW600" + private fun startNewGame() { val gridAlreadyCalculated = viewModel.startNewGame() diff --git a/gauguin-app/src/main/res/layout-h840dp/activity_newgame.xml b/gauguin-app/src/main/res/layout-h840dp/activity_newgame.xml index 4feb332f..b3b5d55e 100644 --- a/gauguin-app/src/main/res/layout-h840dp/activity_newgame.xml +++ b/gauguin-app/src/main/res/layout-h840dp/activity_newgame.xml @@ -3,6 +3,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:tag="newGameLayoutH840" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.newgame.NewGameActivity" > diff --git a/gauguin-app/src/main/res/layout-land/activity_newgame.xml b/gauguin-app/src/main/res/layout-land/activity_newgame.xml index a9dca150..47078ad7 100644 --- a/gauguin-app/src/main/res/layout-land/activity_newgame.xml +++ b/gauguin-app/src/main/res/layout-land/activity_newgame.xml @@ -3,6 +3,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:tag="newGameLayoutLandscape" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.newgame.NewGameActivity" > diff --git a/gauguin-app/src/main/res/layout-w600dp-land/activity_newgame.xml b/gauguin-app/src/main/res/layout-w600dp-land/activity_newgame.xml index f2a0e483..3eb35f4d 100644 --- a/gauguin-app/src/main/res/layout-w600dp-land/activity_newgame.xml +++ b/gauguin-app/src/main/res/layout-w600dp-land/activity_newgame.xml @@ -3,6 +3,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:tag="newGameLayoutW600Landscape" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.newgame.NewGameActivity" > diff --git a/gauguin-app/src/main/res/layout-w600dp/activity_newgame.xml b/gauguin-app/src/main/res/layout-w600dp/activity_newgame.xml index 5932d921..2dd5892a 100644 --- a/gauguin-app/src/main/res/layout-w600dp/activity_newgame.xml +++ b/gauguin-app/src/main/res/layout-w600dp/activity_newgame.xml @@ -3,6 +3,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:tag="newGameLayoutW600" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.newgame.NewGameActivity" > diff --git a/gauguin-app/src/main/res/layout-w840dp-land/activity_newgame.xml b/gauguin-app/src/main/res/layout-w840dp-land/activity_newgame.xml index b4b132cd..8c1bf87f 100644 --- a/gauguin-app/src/main/res/layout-w840dp-land/activity_newgame.xml +++ b/gauguin-app/src/main/res/layout-w840dp-land/activity_newgame.xml @@ -3,6 +3,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + android:tag="newGameLayoutW840Landscape" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.newgame.NewGameActivity" > diff --git a/gauguin-app/src/main/res/layout/activity_newgame.xml b/gauguin-app/src/main/res/layout/activity_newgame.xml index 3937e9fc..409a62a8 100644 --- a/gauguin-app/src/main/res/layout/activity_newgame.xml +++ b/gauguin-app/src/main/res/layout/activity_newgame.xml @@ -3,6 +3,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" + android:tag="newGameLayoutDefault" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"