Modern Apps git

← Modern-Apps.git

web: geolocation settings-fallback parity (open only when both perms permanently denied)

Commit
29c26602df52ed1b4057e72b818dc19ecbdcf234
Author
vayun-mathur <[email protected]>
When
2026-08-16 16:13 UTC (3 months ago)
Parents
b3a0b0f
Both WebView-bridge files now match: geolocation still grants on EITHER
fine OR coarse, and app settings opens ONLY when BOTH fine AND coarse are
permanently denied (denied + !shouldShowRequestPermissionRationale for
both) so the user isn't sent to settings while either is still grantable.
- WebViewBrowser.kt: add the geo settings-fallback (was missing).
- PwaActivity.kt: tighten geo from any-permanently-denied to both.

Diff

web/src/main/java/com/vayunmathur/web/platform/PwaActivity.kt
diff --git a/web/src/main/java/com/vayunmathur/web/platform/PwaActivity.kt b/web/src/main/java/com/vayunmathur/web/platform/PwaActivity.ktindex e4f7ee8a34..53dadb89ee 100644--- a/web/src/main/java/com/vayunmathur/web/platform/PwaActivity.kt+++ b/web/src/main/java/com/vayunmathur/web/platform/PwaActivity.kt@@ -124,13 +124,14 @@ private fun PwaBrowser(      // Geolocation grants on EITHER fine OR coarse, so this keeps the raw multi-permission     // launcher (the shared helper reports all-granted, which would wrongly require both).-    // When both are permanently denied it still routes the user to app settings.-    fun openSettingsIfAnyPermanentlyDenied(result: Map<String, Boolean>) {-        val anyPermanentlyDenied = result.any { (perm, granted) ->+    // Open app settings ONLY when BOTH are permanently denied — if either is still+    // grantable the user isn't blocked.+    fun openSettingsIfBothPermanentlyDenied(result: Map<String, Boolean>) {+        val bothPermanentlyDenied = result.all { (perm, granted) ->             !granted && (activity == null ||                 !ActivityCompat.shouldShowRequestPermissionRationale(activity, perm))         }-        if (anyPermanentlyDenied) openAppSettings(context)+        if (bothPermanentlyDenied) openAppSettings(context)     }      // camera/mic/both use the shared helper, which opens app settings on permanent denial;@@ -169,7 +170,7 @@ private fun PwaBrowser(             pair?.second?.invoke(pair.first, true, false)         } else {             pair?.second?.invoke(pair.first, false, false)-            openSettingsIfAnyPermanentlyDenied(result)+            openSettingsIfBothPermanentlyDenied(result)         }         pendingGeoCallback = null     }
web/src/main/java/com/vayunmathur/web/ui/WebViewBrowser.kt
diff --git a/web/src/main/java/com/vayunmathur/web/ui/WebViewBrowser.kt b/web/src/main/java/com/vayunmathur/web/ui/WebViewBrowser.ktindex 5a8e193f06..544bec9314 100644--- a/web/src/main/java/com/vayunmathur/web/ui/WebViewBrowser.kt+++ b/web/src/main/java/com/vayunmathur/web/ui/WebViewBrowser.kt@@ -29,9 +29,12 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.viewinterop.AndroidView import androidx.core.content.ContextCompat+import androidx.core.app.ActivityCompat import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.webkit.WebSettingsCompat import androidx.webkit.WebViewFeature+import com.vayunmathur.library.ui.findActivity+import com.vayunmathur.library.ui.openAppSettings import com.vayunmathur.library.ui.rememberMultiplePermissionRequest import com.vayunmathur.library.ui.rememberPermissionRequest import com.vayunmathur.web.platform.shields.FarblingConfig@@ -107,6 +110,8 @@ fun WebViewBrowser(      // Geolocation grants on EITHER fine OR coarse, so this keeps the raw multi-permission     // launcher (the shared helper reports all-granted, which would wrongly require both).+    // Open app settings ONLY when BOTH are permanently denied — if either is still+    // grantable the user isn't blocked.     val locationPermissionLauncher = rememberLauncherForActivityResult(         ActivityResultContracts.RequestMultiplePermissions()     ) { result ->@@ -119,6 +124,12 @@ fun WebViewBrowser(             }         } else {             viewModel.denyGeolocation()+            val activity = context.findActivity()+            val bothPermanentlyDenied = result.all { (perm, isGranted) ->+                !isGranted && (activity == null ||+                    !ActivityCompat.shouldShowRequestPermissionRationale(activity, perm))+            }+            if (bothPermanentlyDenied) openAppSettings(context)         }     }