Skip to content

Commit 5501bd5

Browse files
committed
Add utility reconnect button
1 parent 4dc9a93 commit 5501bd5

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

companion/src/main/kotlin/com/fredapp/wbooksutil/MainActivity.kt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,10 @@ private fun CompanionScreen(
212212
Box(modifier = Modifier.padding(padding).fillMaxSize()) {
213213
when {
214214
state.loading && state.books.isEmpty() -> CenteredProgress()
215-
state.noWatch -> CenteredText(stringResource(R.string.no_watch))
215+
state.noWatch -> ReconnectPrompt(
216+
text = stringResource(R.string.no_watch),
217+
onReconnect = vm::refresh,
218+
)
216219
state.books.isEmpty() && state.folders.isEmpty() ->
217220
CenteredText(stringResource(R.string.empty_library))
218221
else -> BoundedBookList(
@@ -992,6 +995,24 @@ private fun CenteredText(text: String) {
992995
) { Text(text) }
993996
}
994997

998+
@Composable
999+
private fun ReconnectPrompt(text: String, onReconnect: () -> Unit) {
1000+
Box(
1001+
modifier = Modifier.fillMaxSize().padding(24.dp),
1002+
contentAlignment = Alignment.Center,
1003+
) {
1004+
Column(
1005+
horizontalAlignment = Alignment.CenterHorizontally,
1006+
verticalArrangement = Arrangement.spacedBy(16.dp),
1007+
) {
1008+
Text(text, textAlign = androidx.compose.ui.text.style.TextAlign.Center)
1009+
Button(onClick = onReconnect) {
1010+
Text(stringResource(R.string.reconnect))
1011+
}
1012+
}
1013+
}
1014+
}
1015+
9951016
/** MIME types that SAF should offer. Matches the parsers in `:app`, plus
9961017
* application/pdf for the experimental PDF→HTML converter (handled in this
9971018
* utility app only; the watch never receives a raw PDF). */

companion/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<string name="cancel">Cancel</string>
1111
<string name="sending">Sending…</string>
1212
<string name="refresh">Refresh</string>
13+
<string name="reconnect">Reconnect</string>
1314
<string name="new_folder">New folder</string>
1415
<string name="folder_name">Folder name</string>
1516
<string name="create">Create</string>

0 commit comments

Comments
 (0)