Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/src/androidTest/java/org/evsyukov/shareding/QueueUiTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import androidx.compose.ui.semantics.SemanticsActions
import androidx.compose.ui.text.TextLayoutResult
import androidx.compose.ui.test.junit4.v2.createAndroidComposeRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.work.WorkManager
import androidx.work.ExistingWorkPolicy
import androidx.work.OneTimeWorkRequestBuilder
Expand All @@ -43,6 +45,7 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Assume.assumeTrue
import org.junit.Rule
import org.junit.Before
import org.junit.After
Expand Down Expand Up @@ -233,6 +236,20 @@ class QueueUiTest {
compose.onNodeWithText("Add Bookmark").assertDoesNotExist()
}

@Test fun saveButtonStaysAboveNavigationBar() {
clearQueue()
compose.onNodeWithText("Add bookmark").performClick()
compose.waitForIdle()
val decor = compose.activity.window.decorView
val navigationBar = ViewCompat.getRootWindowInsets(decor)
?.getInsets(WindowInsetsCompat.Type.navigationBars())?.bottom ?: 0
// Before Android 15 the system keeps the app out of the bar, so there is nothing to overlap.
assumeTrue("App window is not drawn under the navigation bar", navigationBar > 0)
val button = compose.onNodeWithText("Save bookmark").fetchSemanticsNode().boundsInWindow
assertTrue("Save bookmark ends at ${button.bottom}px, the navigation bar starts at " +
"${decor.height - navigationBar}px", button.bottom <= decor.height - navigationBar)
}

private fun clearQueue() {
val app = compose.activity.application as ShareDingApplication
runBlocking { withContext(Dispatchers.IO) { app.container.db.clearAllTables() } }
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/org/evsyukov/shareding/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.widthIn
Expand Down Expand Up @@ -511,7 +512,10 @@ private fun AddBookmarkScreen(container: AppContainer, availableTags: List<Strin
}
}) },
bottomBar = {
Box(Modifier.fillMaxWidth().imePadding(), contentAlignment = Alignment.Center) {
// Scaffold leaves bottomBar insets to the bar itself; without the navigation bar
// padding the button sits under the three-button bar on Android 15+.
Box(Modifier.fillMaxWidth().navigationBarsPadding().imePadding(),
contentAlignment = Alignment.Center) {
Button(onClick = save, enabled = !saving && !busy,
modifier = Modifier.contentWidth().padding(horizontal = 16.dp, vertical = 12.dp)) {
Text("Save bookmark")
Expand Down
Loading