Modern Apps git

← Modern-Apps.git

library: remove :library:ui -> :library:network edge (#884)

Commit
77ec79e64a54b32c3f364daf38c29d40431b4c66
Author
Vayun Mathur <[email protected]>
When
2026-10-31 19:35 UTC (1 month ago)
Parents
42f03c0
Root cause of most of #884's leak surface: :library:ui depended on
:library:network (which declares ACCESS_NETWORK_STATE) only so its
ConnectivityCompose.kt could wrap ConnectivityMonitor for the offline
banner. build-logic's common-conventions-app adds :library:ui to every
app, so every app - including offline ones like PDF Reader - inherited
a network permission through it.

The connectivity UI (rememberIsOnline / OfflineBanner / OfflineAware)
already lives in :library:network (added in 07388aa7a); this drops the
stale copy from :library:ui and the dependency itself. Every app that
uses those helpers already depends on :library:network directly
(checked: vpn, passwords, web, appstore, office, fooddelivery, taxi,
weather, youpipe, travel, voxels, maps, chess, findfamily, everysync);
openassistant, photos and launcher no longer use them.

User-visible effect: apps that do not use the network no longer get
ACCESS_NETWORK_STATE merged in from the UI shell.

Verified: :library:ui:compileDebugKotlin plus compileDevKotlin for
notes, weather, pdf, findfamily, games:hub and openassistant green.

Diff

library/ui/AGENTS.md
diff --git a/library/ui/AGENTS.md b/library/ui/AGENTS.mdindex b5047ddec0..23327102b8 100644--- a/library/ui/AGENTS.md+++ b/library/ui/AGENTS.md@@ -6,7 +6,9 @@ - Gradle: :library:ui / dir: library/ui/ - Package roots present: ui - Entry files: MaActivity.kt, AppScaffold.kt, Icons.kt (no app MainActivity/Route โ€” this is the shared shell)-- Deps: :library, :library:network+- Deps: :library+- Network: none โ€” offline-banner connectivity UI lives in `:library:network`+  (`util/ConnectivityCompose.kt`); network apps depend on it directly (#884) - Metadata: metadata_data/library-ui.md (absent โ€” libraries have none by design) - Rust: no / screenshotTest: no @@ -20,7 +22,7 @@ **Gotchas:** - One public `@Composable` per file, named as the file; closed package roots still apply inside this library - Never `imePadding()`/`navigationBarsPadding()`/`systemBarsPadding()` in this library-- `ConnectivityCompose.kt` lives in this module under the `com.vayunmathur.library.util` package (offline banner used by apps' `OfflineAware`)+- Connectivity UI (`OfflineAware`/`rememberIsOnline`) lives in `:library:network`, not here (#884) - `MaFragmentActivity(autoSetContent=false)` + `showContent()` is the biometric-gate pattern (passwords, photos)  ## Key files
library/ui/build.gradle.kts
diff --git a/library/ui/build.gradle.kts b/library/ui/build.gradle.ktsindex 7062b0875d..8bbe65df4e 100644--- a/library/ui/build.gradle.kts+++ b/library/ui/build.gradle.kts@@ -4,10 +4,6 @@ plugins {  dependencies {     implementation(project(":library"))-    // ConnectivityMonitor lives here (package com.vayunmathur.library.util, module-    // :library:network) and ConnectivityCompose.kt in this module wraps it. Acyclic:-    // :library:network has no project dependencies of its own.-    implementation(project(":library:network"))      // Expose Material 3 to consumers via `api` so the same-named wrappers/aliases in this     // module compile in app code. Apps depend only on `:library:ui` and must not import
library/ui/src/main/java/com/vayunmathur/library/util/ConnectivityCompose.kt
diff --git a/library/ui/src/main/java/com/vayunmathur/library/util/ConnectivityCompose.kt b/library/ui/src/main/java/com/vayunmathur/library/util/ConnectivityCompose.ktdeleted file mode 100644index c594de421a..0000000000--- a/library/ui/src/main/java/com/vayunmathur/library/util/ConnectivityCompose.kt+++ /dev/null@@ -1,84 +0,0 @@-package com.vayunmathur.library.util--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.Row-import androidx.compose.foundation.layout.fillMaxSize-import androidx.compose.foundation.layout.fillMaxWidth-import androidx.compose.foundation.layout.padding-import androidx.compose.foundation.layout.statusBarsPadding-import androidx.compose.material3.MaterialTheme-import androidx.compose.material3.Text-import androidx.compose.runtime.Composable-import androidx.compose.runtime.State-import androidx.compose.runtime.collectAsState-import androidx.compose.runtime.getValue-import androidx.compose.runtime.remember-import androidx.compose.ui.Alignment-import androidx.compose.ui.Modifier-import androidx.compose.ui.platform.LocalContext-import androidx.compose.ui.unit.dp-import com.vayunmathur.library.ui.IconWarning--/**- * Live "are we online?" state for Compose. Starts [ConnectivityMonitor] on first use.- *- * Requires `<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>`.- */-@Composable-fun rememberIsOnline(): State<Boolean> {-    val context = LocalContext.current-    remember(context) { ConnectivityMonitor.start(context); true }-    return ConnectivityMonitor.isOnline.collectAsState()-}--/**- * Drop-in banner shown while offline. Adopting an offline indicator is then ~2 lines:- * `val online by rememberIsOnline(); OfflineBanner(online)`.- */-@Composable-fun OfflineBanner(online: Boolean, modifier: Modifier = Modifier) {-    if (online) return-    Row(-        modifier = modifier-            .fillMaxWidth()-            .background(MaterialTheme.colorScheme.errorContainer)-            .padding(horizontal = 16.dp, vertical = 8.dp),-        horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.CenterHorizontally),-        verticalAlignment = Alignment.CenterVertically,-    ) {-        IconWarning(tint = MaterialTheme.colorScheme.onErrorContainer)-        Text(-            text = "No internet connection",-            color = MaterialTheme.colorScheme.onErrorContainer,-            style = MaterialTheme.typography.bodyMedium,-        )-    }-}--/**- * Wraps a screen so a full-width offline banner slides in above it whenever validated internet is- * lost, and the wrapped content fills the rest. Adopting the offline indicator in an app is then a- * one-line wrap around the existing top-level navigation:- *- * ```- * DynamicTheme {- *     OfflineAware {- *         Navigation(viewModel)- *     }- * }- * ```- *- * The banner carries [statusBarsPadding] so it clears the status bar under edge-to-edge; the content- * keeps drawing edge-to-edge and manages its own insets exactly as before.- */-@Composable-fun OfflineAware(content: @Composable () -> Unit) {-    val online by rememberIsOnline()-    Column(Modifier.fillMaxSize()) {-        OfflineBanner(online, Modifier.statusBarsPadding())-        Box(Modifier.weight(1f).fillMaxWidth()) { content() }-    }-}