diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/ChatScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/ChatScreen.kt index 42ba37c..b45038c 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/ChatScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/ChatScreen.kt @@ -2,12 +2,10 @@ package com.siriusdevops.onionwire.ui import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement -import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -17,16 +15,11 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.foundation.text.KeyboardActions -import androidx.compose.foundation.text.KeyboardOptions -import androidx.compose.foundation.verticalScroll import androidx.compose.material3.Button import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.IconButton -import androidx.compose.material3.LocalContentColor import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold @@ -41,14 +34,10 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier -import androidx.compose.ui.focus.FocusRequester -import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.platform.testTag import androidx.compose.ui.semantics.contentDescription import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.font.FontFamily -import androidx.compose.ui.text.input.ImeAction -import androidx.compose.ui.text.input.KeyboardCapitalization import androidx.compose.ui.unit.dp import kotlinx.coroutines.delay import uniffi.onionwire_sdk.ChatMessage @@ -84,18 +73,6 @@ fun ChatScreen( var notice by remember { mutableStateOf(null) } val listState = rememberLazyListState() - // The composer is the only place a message can be sent from, so after a - // send the keyboard is left up and the caret goes back into the field — - // the next message is one keystroke away instead of a re-tap. - val inputFocus = remember { FocusRequester() } - val send: () -> Unit = { - if (draft.isNotBlank() && pending == null) { - pending = draft - draft = "" - inputFocus.requestFocus() - } - } - // Poll: the node appends inbound messages in the background and the retry // worker moves queued rows along; there is no push channel into the UI in // v1, so the delivery markers refresh on the same cadence as the bodies. @@ -162,17 +139,8 @@ fun ChatScreen( ), ) }, - // The top bar carries its own status-bar inset; the content root applies - // systemBars + IME once (see `screenContentInsets`) so the navigation - // bar is not counted twice while the keyboard is up. - contentWindowInsets = WindowInsets(0, 0, 0, 0), ) { pad -> - Column( - Modifier - .padding(pad) - .fillMaxSize() - .screenContentInsets(), - ) { + Column(Modifier.padding(pad).fillMaxSize()) { Text( "onion: $onion", style = MaterialTheme.typography.labelSmall, @@ -184,21 +152,14 @@ fun ChatScreen( val list = messages when { list == null -> { - // The body region always claims the leftover height, so the - // composer below it can never be pushed off the bottom — - // least of all by the keyboard. - Box(Modifier.weight(1f).fillMaxWidth(), contentAlignment = Alignment.Center) { - CircularProgressIndicator(Modifier.padding(16.dp)) - } + Spacer(Modifier.height(16.dp)) + CircularProgressIndicator(Modifier.padding(16.dp)) } list.isEmpty() -> { Column( - Modifier - .weight(1f) - .fillMaxWidth() - .verticalScroll(rememberScrollState()) - .padding(24.dp), + Modifier.fillMaxWidth().padding(24.dp), + verticalArrangement = Arrangement.Center, ) { Text("No messages", style = MaterialTheme.typography.titleSmall) Spacer(Modifier.height(6.dp)) @@ -313,52 +274,28 @@ fun ChatScreen( ) } - // The composer sticks to the bottom of the window: `screenContentInsets` - // already lifted it above the keyboard, and its row is never allowed - // to be squeezed out by the messages above it (they hold the weight). Row( - Modifier - .fillMaxWidth() - .padding(8.dp) - .testTag("chat-composer"), - verticalAlignment = Alignment.Bottom, + Modifier.fillMaxWidth().padding(8.dp), + verticalAlignment = Alignment.CenterVertically, ) { OutlinedTextField( value = draft, onValueChange = { draft = it }, - modifier = Modifier - .weight(1f) - .focusRequester(inputFocus) - .testTag("chat-input"), + modifier = Modifier.weight(1f), maxLines = 4, label = { Text("message") }, - // The IME gets its own send affordance: on a phone in - // landscape, or with the keyboard covering the button, the - // action key is the shortest path to sending. - keyboardOptions = KeyboardOptions( - capitalization = KeyboardCapitalization.Sentences, - imeAction = ImeAction.Send, - ), - keyboardActions = KeyboardActions(onSend = { send() }), ) Spacer(Modifier.width(8.dp)) - // Always drawn, never swapped out for a spinner: a button that - // changes size under the thumb — or disappears — is how "I hit - // send and nothing happened" gets reported. - Button( - enabled = draft.isNotBlank() && pending == null, - onClick = send, - modifier = Modifier.testTag("chat-send"), - ) { - if (pending != null) { - CircularProgressIndicator( - modifier = Modifier.size(14.dp), - strokeWidth = 2.dp, - color = LocalContentColor.current, - ) - Spacer(Modifier.width(6.dp)) - } - Text("Send") + if (pending != null) { + CircularProgressIndicator() + } else { + Button( + enabled = draft.isNotBlank(), + onClick = { + pending = draft + draft = "" + }, + ) { Text("Send") } } } } diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt deleted file mode 100644 index fd7802d..0000000 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/Insets.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.siriusdevops.onionwire.ui - -import androidx.compose.foundation.layout.WindowInsets -import androidx.compose.foundation.layout.WindowInsetsSides -import androidx.compose.foundation.layout.ime -import androidx.compose.foundation.layout.only -import androidx.compose.foundation.layout.systemBars -import androidx.compose.foundation.layout.union -import androidx.compose.foundation.layout.windowInsetsPadding -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier - -/** - * The bottom + horizontal window insets one screen's content root must apply - * itself. - * - * `MainActivity` calls `enableEdgeToEdge()`, which means - * `setDecorFitsSystemWindows(window, false)`. On API 30+ that stops the - * framework from resizing the window for the soft keyboard: the manifest's - * `android:windowSoftInputMode="adjustResize"` has nothing left to resize, and - * the IME arrives as a *window inset* instead. `Scaffold`'s - * `contentWindowInsets` only covers `systemBars`, so anything anchored to the - * bottom of the window — the chat composer, a submit button under a text field - * — ends up drawn behind the keyboard, reachable only by dismissing it. - * - * The IME's bottom inset already covers the navigation bar, so the two are - * unioned (per-side `max`), never summed: keyboard height while typing, - * navigation-bar height otherwise, and no double padding in between. - * - * The `Top` side is deliberately excluded — a `Scaffold`'s `pad.top` is the app - * bar's own measured height, and the app bar carries its own status-bar inset - * (`TopAppBarDefaults.windowInsets`). - * - * Pair every use with `Scaffold(contentWindowInsets = WindowInsets(0, 0, 0, 0))` - * so the same inset is not applied twice. - * - * `@Composable` because `WindowInsets.systemBars` / `WindowInsets.ime` are - * composable reads — call it from a composable (every call site is one). - */ -@Composable -fun Modifier.screenContentInsets(): Modifier = - windowInsetsPadding( - WindowInsets.systemBars.union(WindowInsets.ime) - .only(WindowInsetsSides.Horizontal + WindowInsetsSides.Bottom), - ) \ No newline at end of file diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteScreens.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteScreens.kt index b084b27..31da473 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteScreens.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/InviteScreens.kt @@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -63,17 +62,9 @@ fun ShareInviteScreen(ownerInvite: suspend () -> String, onBack: () -> Unit) { ), ) }, - // The root applies systemBars + IME itself (see `screenContentInsets`), - // so Scaffold must not also pad for the navigation bar. - contentWindowInsets = WindowInsets(0, 0, 0, 0), ) { pad -> Column( - Modifier - .padding(pad) - .fillMaxSize() - .screenContentInsets() - .verticalScroll(rememberScrollState()) - .padding(16.dp), + Modifier.padding(pad).fillMaxSize().verticalScroll(rememberScrollState()).padding(16.dp), ) { Text( "Hand this to one person, over a channel you already trust. " + @@ -158,18 +149,9 @@ fun PasteInviteScreen( ), ) }, - // Same inset handoff as the chat composer: with the keyboard up, the - // Verify / Approve buttons under the invite field must still be - // reachable by scrolling, not by dismissing the keyboard. - contentWindowInsets = WindowInsets(0, 0, 0, 0), ) { pad -> Column( - Modifier - .padding(pad) - .fillMaxSize() - .screenContentInsets() - .verticalScroll(rememberScrollState()) - .padding(16.dp), + Modifier.padding(pad).fillMaxSize().verticalScroll(rememberScrollState()).padding(16.dp), ) { OutlinedTextField( value = raw, diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RotateScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/RotateScreen.kt index b1f99b5..e8b4cc1 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/RotateScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/RotateScreen.kt @@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -60,17 +59,9 @@ fun RotateScreen( ), ) }, - // Root owns systemBars + IME (see `screenContentInsets`) so the confirm - // button under the passphrase field stays reachable with the keyboard up. - contentWindowInsets = WindowInsets(0, 0, 0, 0), ) { pad -> Column( - Modifier - .padding(pad) - .fillMaxSize() - .screenContentInsets() - .verticalScroll(rememberScrollState()) - .padding(16.dp), + Modifier.padding(pad).fillMaxSize().verticalScroll(rememberScrollState()).padding(16.dp), ) { Text("Rotate onion address?", style = MaterialTheme.typography.titleLarge) Spacer(Modifier.height(12.dp)) diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/UnlockScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/UnlockScreen.kt index 4e57d5e..7adb6f8 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/UnlockScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/UnlockScreen.kt @@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.safeDrawingPadding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll @@ -69,10 +68,6 @@ fun UnlockScreen( Column( modifier = Modifier .fillMaxSize() - // This screen has no Scaffold, so its root owns every window inset: - // without this the keyboard covers the passphrase field's Open - // button and the status bar overlaps the title. - .safeDrawingPadding() .verticalScroll(rememberScrollState()) .padding(24.dp), verticalArrangement = Arrangement.Center,