Skip to content

Commit bdebb62

Browse files
author
UserGreen
committed
fix(debug): move build indicator into inbox bar when signed in
Overlay blocked the settings gear. Keep it as an overlay on sign-in only and render it inline left of the gear once past auth.
1 parent 6cecd35 commit bdebb62

5 files changed

Lines changed: 39 additions & 33 deletions

File tree

app/src/debug/kotlin/org/astermail/android/debugtools/debug_build_banner.kt

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import androidx.compose.foundation.layout.padding
3131
import androidx.compose.foundation.layout.statusBarsPadding
3232
import androidx.compose.foundation.layout.widthIn
3333
import androidx.compose.foundation.shape.RoundedCornerShape
34+
import androidx.compose.material3.DropdownMenu
3435
import androidx.compose.material3.MaterialTheme
3536
import androidx.compose.material3.Text
3637
import androidx.compose.runtime.Composable
@@ -57,46 +58,44 @@ private const val production_release_url = "https://github.com/Aster-Privacy/Ast
5758

5859
@Composable
5960
fun debug_build_banner() {
60-
var expanded by remember { mutableStateOf(false) }
61-
6261
Box(
6362
modifier = Modifier
6463
.fillMaxSize()
6564
.statusBarsPadding()
6665
.padding(horizontal = 8.dp, vertical = 4.dp),
6766
) {
68-
if (expanded) {
69-
debug_build_notice(
70-
modifier = Modifier.align(Alignment.TopCenter),
71-
on_collapse = { expanded = false },
72-
)
73-
} else {
74-
debug_build_pill(
75-
modifier = Modifier.align(Alignment.TopEnd),
76-
on_expand = { expanded = true },
77-
)
78-
}
67+
debug_build_pill_inline(modifier = Modifier.align(Alignment.TopEnd))
7968
}
8069
}
8170

8271
@Composable
83-
private fun debug_build_pill(modifier: Modifier, on_expand: () -> Unit) {
72+
fun debug_build_pill_inline(modifier: Modifier = Modifier) {
73+
var expanded by remember { mutableStateOf(false) }
8474
val colors = AsterMaterial.colors
85-
Text(
86-
text = stringResource(R.string.debug_banner_label),
87-
color = colors.warning,
88-
fontSize = 10.sp,
89-
fontWeight = FontWeight.Bold,
90-
modifier = modifier
91-
.clickable(onClick = on_expand)
92-
.background(colors.bg_card.copy(alpha = 0.9f), RoundedCornerShape(50))
93-
.border(1.dp, colors.warning.copy(alpha = 0.5f), RoundedCornerShape(50))
94-
.padding(horizontal = 8.dp, vertical = 3.dp),
95-
)
75+
76+
Box(modifier = modifier) {
77+
Text(
78+
text = stringResource(R.string.debug_banner_label),
79+
color = colors.warning,
80+
fontSize = 10.sp,
81+
fontWeight = FontWeight.Bold,
82+
modifier = Modifier
83+
.clickable { expanded = true }
84+
.background(colors.bg_card.copy(alpha = 0.9f), RoundedCornerShape(50))
85+
.border(1.dp, colors.warning.copy(alpha = 0.5f), RoundedCornerShape(50))
86+
.padding(horizontal = 8.dp, vertical = 3.dp),
87+
)
88+
DropdownMenu(
89+
expanded = expanded,
90+
onDismissRequest = { expanded = false },
91+
) {
92+
debug_build_notice(on_collapse = { expanded = false })
93+
}
94+
}
9695
}
9796

9897
@Composable
99-
private fun debug_build_notice(modifier: Modifier, on_collapse: () -> Unit) {
98+
private fun debug_build_notice(on_collapse: () -> Unit) {
10099
val colors = AsterMaterial.colors
101100
val link_text = stringResource(R.string.debug_banner_link)
102101
val body = stringResource(R.string.debug_banner_body, link_text)
@@ -125,12 +124,10 @@ private fun debug_build_notice(modifier: Modifier, on_collapse: () -> Unit) {
125124
}
126125

127126
Column(
128-
modifier = modifier
129-
.widthIn(max = 420.dp)
127+
modifier = Modifier
128+
.widthIn(max = 300.dp)
130129
.clickable(onClick = on_collapse)
131-
.background(colors.bg_card, RoundedCornerShape(10.dp))
132-
.border(1.dp, colors.warning.copy(alpha = 0.5f), RoundedCornerShape(10.dp))
133-
.padding(horizontal = 12.dp, vertical = 10.dp),
130+
.padding(horizontal = 12.dp, vertical = 8.dp),
134131
) {
135132
Text(
136133
text = stringResource(R.string.debug_banner_label),

app/src/main/kotlin/org/astermail/android/MainActivity.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import androidx.compose.runtime.saveable.rememberSaveableStateHolder
3232
import androidx.lifecycle.Lifecycle
3333
import androidx.lifecycle.LifecycleEventObserver
3434
import androidx.lifecycle.ProcessLifecycleOwner
35-
import org.astermail.android.debugtools.debug_build_banner
3635
import org.astermail.android.security.AppLockViewModel
3736
import org.astermail.android.security.LockdownStore
3837
import org.astermail.android.ui.common.nav_anim_duration_ms
@@ -292,7 +291,6 @@ private fun AsterRoot() {
292291
.background(colors.bg_primary),
293292
) {
294293
AsterNavHost()
295-
debug_build_banner()
296294
}
297295
}
298296
}

app/src/main/kotlin/org/astermail/android/ui/auth/sign_in_screen.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import androidx.compose.ui.unit.sp
7878
import androidx.hilt.navigation.compose.hiltViewModel
7979
import org.astermail.android.R
8080
import org.astermail.android.auth.AuthUiState
81+
import org.astermail.android.debugtools.debug_build_banner
8182
import org.astermail.android.auth.AuthViewModel
8283
import org.astermail.android.design.SquircleShape
8384
import org.astermail.android.design.AsterMaterial
@@ -359,6 +360,8 @@ fun SignInScreen(
359360
Spacer(Modifier.height(AsterSpacing.xxl))
360361
}
361362
}
363+
364+
debug_build_banner()
362365
}
363366
}
364367

app/src/main/kotlin/org/astermail/android/ui/mail/inbox_screen.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ import androidx.lifecycle.Lifecycle
134134
import androidx.lifecycle.LifecycleEventObserver
135135
import androidx.compose.ui.platform.LocalLifecycleOwner
136136
import org.astermail.android.R
137+
import org.astermail.android.debugtools.debug_build_pill_inline
137138
import org.astermail.android.design.SquircleShape
138139
import org.astermail.android.design.AsterMaterial
139140
import org.astermail.android.design.AsterSpacing
@@ -1177,6 +1178,8 @@ private fun inbox_top_bar(
11771178
}
11781179
}
11791180
}
1181+
debug_build_pill_inline()
1182+
Spacer(Modifier.width(AsterSpacing.xs))
11801183
AsterIconButton(
11811184
icon = Icons.Outlined.Settings,
11821185
content_description = stringResource(R.string.settings),

app/src/release/kotlin/org/astermail/android/debugtools/debug_build_banner.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222
package org.astermail.android.debugtools
2323

2424
import androidx.compose.runtime.Composable
25+
import androidx.compose.ui.Modifier
2526

2627
@Composable
2728
fun debug_build_banner() {
2829
}
30+
31+
@Composable
32+
fun debug_build_pill_inline(modifier: Modifier = Modifier) {
33+
}

0 commit comments

Comments
 (0)