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
21 changes: 13 additions & 8 deletions app/src/main/java/com/anindra/messages/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2093,21 +2093,26 @@ open class MainActivity : FragmentActivity() {
label = stringResource(R.string.access_nav)
) { target ->
if (target == "list") {
// In a two-pane window the list is its own column,
// so this pane is empty until a chat is opened — and
// says so, rather than showing a blank half screen.
androidx.compose.foundation.layout.Box(
Modifier.fillMaxSize().background(MaterialTheme.colorScheme.surface),
contentAlignment = Alignment.Center
) {
if (twoPaneLayout) {
// A phone draws the list underneath this stack, so
// this pane must stay transparent there: an opaque
// surface here covered the whole inbox and left the
// screen black while the list was still composed
// underneath it. Only a split window owns this pane,
// and only it gets the empty-state card.
if (twoPaneLayout) {
androidx.compose.foundation.layout.Box(
Modifier.fillMaxSize().background(MaterialTheme.colorScheme.surface),
contentAlignment = Alignment.Center
) {
androidx.compose.material3.Text(
text = stringResource(R.string.two_pane_empty),
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(horizontal = 24.dp)
)
}
} else {
androidx.compose.foundation.layout.Box(Modifier.fillMaxSize())
}
} else {
androidx.compose.foundation.layout.Box(Modifier.fillMaxSize().background(MaterialTheme.colorScheme.surface)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.anindra.messages.ui

import org.junit.Assert.assertTrue
import org.junit.Test
import java.io.File

/**
* On a phone the conversation list is drawn underneath the route stack, so the
* stack's "list" pane must stay transparent. It once painted an opaque surface
* there and covered the whole inbox: the list was still composed and clickable,
* but the screen was black.
*/
class ListPaneTransparencyTest {

private val activity: String by lazy {
val main = generateSequence(File("").absoluteFile) { it.parentFile }
.map { File(it, "app/src/main") }
.firstOrNull { File(it, "java").isDirectory }
?: error("app/src/main not found")
File(main, "java/com/anindra/messages/MainActivity.kt").readText()
}

@Test
fun theListPaneIsOnlyOpaqueInASplitWindow() {
val branch = activity.substringAfter("""if (target == "list") {""")
val splitPart = branch.substringBefore("} else {")
val phonePart = branch.substringAfter("} else {").substringBefore("} else {")
assertTrue(
"the opaque pane and its empty-state card belong to the split window",
splitPart.contains("if (twoPaneLayout)") &&
splitPart.contains("background(MaterialTheme.colorScheme.surface)") &&
splitPart.contains("R.string.two_pane_empty")
)
assertTrue(
"a phone gets a transparent pane, or the list underneath is hidden",
phonePart.contains("Box(Modifier.fillMaxSize())") &&
!phonePart.contains("colorScheme.surface")
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ class TwoPaneLayoutTest {
@Test
fun anEmptyRightPaneSaysWhatToDo() {
assertTrue(
"with no chat open the right pane is not a blank half screen",
Regex("""if \(twoPaneLayout\) \{[\s\S]{0,400}?R\.string\.two_pane_empty""")
"with no chat open the split window is not a blank half screen",
Regex("""if \(twoPaneLayout\) \{[\s\S]{0,500}?R\.string\.two_pane_empty""")
.containsMatchIn(activity)
)
}
Expand Down