fix(companion): app webview content clears the status bar; HTTPS toggle on add/edit — 0.5.21
- In-app browser pages (node apps) now start below the status bar again:
the WebView stays edge-to-edge (page colour fills the bar) and a
body{padding-top:<statusbar>} injection pushes content down — the
pre-edge-to-edge look without the black bar.
- Add/Edit server in the menu now has a Use HTTPS toggle (was scheme-locked;
edit preserved the old scheme, add forced http).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
c66ef048f4
commit
3b6a32b2f8
@ -11,8 +11,8 @@ android {
|
|||||||
applicationId = "com.archipelago.app"
|
applicationId = "com.archipelago.app"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 40
|
versionCode = 41
|
||||||
versionName = "0.5.20"
|
versionName = "0.5.21"
|
||||||
|
|
||||||
vectorDrawables {
|
vectorDrawables {
|
||||||
useSupportLibrary = true
|
useSupportLibrary = true
|
||||||
|
|||||||
@ -131,14 +131,15 @@ private fun MenuPanel(
|
|||||||
var nm by remember { mutableStateOf("") }
|
var nm by remember { mutableStateOf("") }
|
||||||
var addr by remember { mutableStateOf("") }
|
var addr by remember { mutableStateOf("") }
|
||||||
var pwd by remember { mutableStateOf("") }
|
var pwd by remember { mutableStateOf("") }
|
||||||
|
var https by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
fun resetForm() {
|
fun resetForm() {
|
||||||
nm = ""; addr = ""; pwd = ""; showAdd = false; editing = null
|
nm = ""; addr = ""; pwd = ""; https = false; showAdd = false; editing = null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun startEdit(server: ServerEntry) {
|
fun startEdit(server: ServerEntry) {
|
||||||
editing = server
|
editing = server
|
||||||
nm = server.name; addr = server.address; pwd = server.password
|
nm = server.name; addr = server.address; pwd = server.password; https = server.useHttps
|
||||||
showAdd = false
|
showAdd = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,10 +147,10 @@ private fun MenuPanel(
|
|||||||
if (addr.isBlank()) return
|
if (addr.isBlank()) return
|
||||||
val orig = editing
|
val orig = editing
|
||||||
if (orig != null) {
|
if (orig != null) {
|
||||||
// Preserve fields the compact form doesn't expose (scheme, port).
|
// Preserve port (compact form doesn't expose it); scheme is now editable.
|
||||||
onEditServer(orig, orig.copy(address = addr, password = pwd, name = nm))
|
onEditServer(orig, orig.copy(address = addr, useHttps = https, password = pwd, name = nm))
|
||||||
} else {
|
} else {
|
||||||
onAddServer(ServerEntry(addr, false, password = pwd, name = nm))
|
onAddServer(ServerEntry(addr, https, password = pwd, name = nm))
|
||||||
}
|
}
|
||||||
resetForm()
|
resetForm()
|
||||||
}
|
}
|
||||||
@ -249,6 +250,34 @@ private fun MenuPanel(
|
|||||||
contentAlignment = Alignment.Center,
|
contentAlignment = Alignment.Center,
|
||||||
) { Text("OK", color = BitcoinOrange, fontSize = 14.sp, fontWeight = FontWeight.Bold) }
|
) { Text("OK", color = BitcoinOrange, fontSize = 14.sp, fontWeight = FontWeight.Bold) }
|
||||||
}
|
}
|
||||||
|
// HTTPS scheme toggle (available on both add and edit).
|
||||||
|
Row(
|
||||||
|
Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.clip(RoundedCornerShape(ROW_R))
|
||||||
|
.clickable { https = !https }
|
||||||
|
.padding(vertical = 2.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
) {
|
||||||
|
Text("Use HTTPS", color = TextMuted, fontSize = 13.sp)
|
||||||
|
Box(
|
||||||
|
Modifier
|
||||||
|
.width(46.dp).height(26.dp)
|
||||||
|
.clip(RoundedCornerShape(13.dp))
|
||||||
|
.background(if (https) BitcoinOrange.copy(alpha = 0.9f) else RowBg)
|
||||||
|
.border(1.dp, if (https) BitcoinOrange else RowBorder, RoundedCornerShape(13.dp)),
|
||||||
|
contentAlignment = if (https) Alignment.CenterEnd else Alignment.CenterStart,
|
||||||
|
) {
|
||||||
|
Box(
|
||||||
|
Modifier
|
||||||
|
.padding(horizontal = 3.dp)
|
||||||
|
.size(20.dp)
|
||||||
|
.clip(RoundedCornerShape(10.dp))
|
||||||
|
.background(if (https) Color.White else TextMuted),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||||
|
|||||||
@ -185,6 +185,35 @@ private fun injectSafeAreaVars(view: WebView) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** In-app browser pages (node apps + same-node links) don't consume the
|
||||||
|
* neode-ui `--safe-area-top` var, so with the WebView drawing edge-to-edge
|
||||||
|
* their content ran up under the status bar. Pad the document body down by
|
||||||
|
* the status-bar height: the padded strip shows the page's OWN background
|
||||||
|
* (padding is inside the element), so the bar keeps the page colour while
|
||||||
|
* content starts below it — the pre-edge-to-edge look, without the black bar.
|
||||||
|
* Idempotent; runs on start (early) and finish (after the app rewrites head). */
|
||||||
|
private fun injectTopInset(view: WebView) {
|
||||||
|
val insets = view.rootWindowInsets ?: return
|
||||||
|
val density = view.resources.displayMetrics.density
|
||||||
|
val sat = (insets.getInsets(android.view.WindowInsets.Type.statusBars()).top / density).toInt()
|
||||||
|
if (sat <= 0) return
|
||||||
|
view.evaluateJavascript(
|
||||||
|
"""
|
||||||
|
(function() {
|
||||||
|
var s = document.getElementById('archy-top-inset');
|
||||||
|
if (!s) {
|
||||||
|
s = document.createElement('style');
|
||||||
|
s.id = 'archy-top-inset';
|
||||||
|
(document.head || document.documentElement).appendChild(s);
|
||||||
|
}
|
||||||
|
s.textContent =
|
||||||
|
'body{padding-top:${sat}px!important;box-sizing:border-box!important;}';
|
||||||
|
})();
|
||||||
|
""".trimIndent(),
|
||||||
|
null,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/** True when a TCP listener answers at [base]'s host:port within [timeoutMs]. */
|
/** True when a TCP listener answers at [base]'s host:port within [timeoutMs]. */
|
||||||
private fun tcpAnswers(base: String, timeoutMs: Int): Boolean = try {
|
private fun tcpAnswers(base: String, timeoutMs: Int): Boolean = try {
|
||||||
val u = android.net.Uri.parse(base)
|
val u = android.net.Uri.parse(base)
|
||||||
@ -1011,12 +1040,14 @@ private fun InAppBrowser(
|
|||||||
webViewClient = object : WebViewClient() {
|
webViewClient = object : WebViewClient() {
|
||||||
override fun onPageStarted(view: WebView?, u: String?, favicon: Bitmap?) {
|
override fun onPageStarted(view: WebView?, u: String?, favicon: Bitmap?) {
|
||||||
loading = true
|
loading = true
|
||||||
|
view?.let { injectTopInset(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPageFinished(view: WebView?, u: String?) {
|
override fun onPageFinished(view: WebView?, u: String?) {
|
||||||
loading = false
|
loading = false
|
||||||
canGoBack = view?.canGoBack() == true
|
canGoBack = view?.canGoBack() == true
|
||||||
canGoForward = view?.canGoForward() == true
|
canGoForward = view?.canGoForward() == true
|
||||||
|
view?.let { injectTopInset(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doUpdateVisitedHistory(view: WebView?, u: String?, isReload: Boolean) {
|
override fun doUpdateVisitedHistory(view: WebView?, u: String?, isReload: Boolean) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user