From 217f4ad9ca6742d8343b0839fe4a3250018ba6be Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 27 Jun 2026 19:04:59 +0000 Subject: [PATCH] fix: drop confirm dialog on nsite Tor network switch Tapping the "loads over Tor" row on an nSite's pull-down sheet popped a confirm dialog explaining the routing change. Users already know what Tor is, so toggle the routing directly on tap (still relaunches the session to rebuild the proxy + content server) and remove the now-unused strings. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_0177rhf2L93YRcq6NrWkkM4Q --- .../napplethost/NappletHostActivity.kt | 24 +++---------------- nappletHost/src/main/res/values/strings.xml | 6 ----- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/nappletHost/src/main/kotlin/com/vitorpamplona/amethyst/napplethost/NappletHostActivity.kt b/nappletHost/src/main/kotlin/com/vitorpamplona/amethyst/napplethost/NappletHostActivity.kt index cbd602b5b7..868182907d 100644 --- a/nappletHost/src/main/kotlin/com/vitorpamplona/amethyst/napplethost/NappletHostActivity.kt +++ b/nappletHost/src/main/kotlin/com/vitorpamplona/amethyst/napplethost/NappletHostActivity.kt @@ -736,31 +736,13 @@ class NappletHostActivity : ComponentActivity() { title = barTitle(), isSandbox = true, onReload = { if (this::webView.isInitialized) webView.reload() }, - // Website-mode nSites can re-route over Tor; switching rebuilds the session via a confirm - // dialog, so the row taps through rather than toggling inline. + // Website-mode nSites can re-route over Tor; switching rebuilds the session, so the row taps + // through to a full relaunch rather than toggling inline. torInitiallyOn = if (profile.exposesNetwork && proxyPort > 0) useTor else null, - onNetworkTap = if (profile.exposesNetwork && proxyPort > 0) ({ showNetworkDialog() }) else null, + onNetworkTap = if (profile.exposesNetwork && proxyPort > 0) ({ setNetworkMode(!useTor) }) else null, onInfo = { showAccessDialog() }, ) - /** - * Explains the site's current network routing and offers to switch it. Switching persists the - * per-site choice (via the broker, which owns the preference) and relaunches this screen so the new - * routing applies cleanly from [onCreate] — the proxy and content server are rebuilt for the new mode. - */ - private fun showNetworkDialog() { - val titleRes = if (useTor) R.string.napplet_net_tor_title else R.string.napplet_net_open_title - val messageRes = if (useTor) R.string.napplet_net_tor_message else R.string.napplet_net_open_message - val switchRes = if (useTor) R.string.napplet_net_switch_open else R.string.napplet_net_switch_tor - AlertDialog - .Builder(this) - .setTitle(getString(titleRes, barTitle())) - .setMessage(getString(messageRes)) - .setPositiveButton(getString(switchRes)) { _, _ -> setNetworkMode(!useTor) } - .setNegativeButton(android.R.string.cancel, null) - .show() - } - /** Persists the new routing choice in the main process, then relaunches this screen to apply it. */ private fun setNetworkMode(newUseTor: Boolean) { val msg = diff --git a/nappletHost/src/main/res/values/strings.xml b/nappletHost/src/main/res/values/strings.xml index ddd4b168d4..74b715186f 100644 --- a/nappletHost/src/main/res/values/strings.xml +++ b/nappletHost/src/main/res/values/strings.xml @@ -19,12 +19,6 @@ This site loads over Tor. Tap to change. This site loads over the open web. Tap to change. - “%1$s” loads over Tor - This site\'s traffic is routed through Tor, so it can\'t see your IP address. Some sites are slow or broken over Tor — you can switch this site to the open web. Your choice is remembered for this site. - “%1$s” loads over the open web - This site loads directly, so it (and the servers it contacts) can see your IP address. Switch it back to Tor to keep your IP private. Your choice is remembered for this site. - Use open web - Use Tor Loads over Tor Loads over the open web