From: Soren Stoutner Date: Thu, 7 May 2026 18:00:26 +0000 (-0700) Subject: Stop displaying the Waiting for Orbot dialog. https://redmine.stoutner.com/issues/814 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=93b57b13af068b1da0bda317132c018110741022;p=PrivacyBrowserAndroid.git Stop displaying the Waiting for Orbot dialog. https://redmine.stoutner.com/issues/814 --- diff --git a/app/build.gradle b/app/build.gradle index 6c2d0240..1edc15e9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -85,7 +85,7 @@ dependencies { implementation 'androidx.preference:preference-ktx:1.2.1' implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.2.0' implementation 'androidx.viewpager:viewpager:1.1.0' - implementation 'androidx.webkit:webkit:1.15.0' + implementation 'androidx.webkit:webkit:1.16.0' // Include the Kotlin standard library. This should be the same version number listed in project build.gradle. implementation 'org.jetbrains.kotlin:kotlin-stdlib:2.2.10' diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt index 003010b4..c70b2c15 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt @@ -26,12 +26,10 @@ import android.annotation.SuppressLint import android.app.DownloadManager import android.app.SearchManager import android.content.ActivityNotFoundException -import android.content.BroadcastReceiver import android.content.ClipData import android.content.ClipboardManager import android.content.Context import android.content.Intent -import android.content.IntentFilter import android.content.SharedPreferences import android.content.pm.PackageManager import android.content.res.Configuration @@ -99,7 +97,6 @@ import androidx.appcompat.app.AppCompatDelegate import androidx.appcompat.content.res.AppCompatResources import androidx.appcompat.widget.Toolbar import androidx.coordinatorlayout.widget.CoordinatorLayout -import androidx.core.content.ContextCompat import androidx.core.graphics.scale import androidx.core.net.toUri import androidx.core.view.GravityCompat @@ -143,7 +140,6 @@ import com.stoutner.privacybrowser.dialogs.SaveDialog import com.stoutner.privacybrowser.dialogs.SslCertificateErrorDialog import com.stoutner.privacybrowser.dialogs.UrlHistoryDialog import com.stoutner.privacybrowser.dialogs.ViewSslCertificateDialog -import com.stoutner.privacybrowser.dialogs.WaitingForProxyDialog import com.stoutner.privacybrowser.fragments.WebViewTabFragment import com.stoutner.privacybrowser.helpers.BLOCK_ALL_THIRD_PARTY_REQUESTS import com.stoutner.privacybrowser.helpers.BOOKMARK_NAME @@ -243,7 +239,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Define the public static variables. var currentBookmarksFolderId = 0L val executorService = Executors.newFixedThreadPool(4)!! - var orbotStatus = "unknown" val pendingDialogsArrayList = ArrayList() var proxyMode = ProxyHelper.NONE var restartFromBookmarksActivity = false @@ -381,7 +376,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook private var navigationDrawerFirstView = true private var objectAnimator = ObjectAnimator() private var optionsMenu: Menu? = null - private var orbotStatusBroadcastReceiver: BroadcastReceiver? = null private var reapplyAppSettingsOnRestart = false private var reapplyDomainSettingsOnRestart = false private var sanitizeAmpRedirects = false @@ -392,7 +386,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook private var savedTabPosition = 0 private var scrollAppBar = false private var sortBookmarksAlphabetically = false - private var waitingForProxy = false // Define the browse file upload activity result launcher. It must be defined before `onCreate()` is run or the app will crash. private val browseFileUploadActivityResultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { activityResult -> @@ -887,7 +880,7 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook if (currentWebView != null) currentWebView!!.resumeTimers() - // Reapply the proxy settings if the system is using a proxy. This redisplays the appropriate alert dialog. + // Reapply the proxy settings if the system is using a proxy. if (proxyMode != ProxyHelper.NONE) applyProxy(false) @@ -997,11 +990,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook } public override fun onDestroy() { - // Unregister the orbot status broadcast receiver if it exists. - if (orbotStatusBroadcastReceiver != null) { - unregisterReceiver(orbotStatusBroadcastReceiver) - } - // Close the bookmarks cursor if it exists. bookmarksCursor?.close() @@ -3584,9 +3572,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Set the proxy according to the mode. proxyHelper.setProxy(applicationContext, appBarLayout, proxyMode) - // Reset the waiting for proxy tracker. - waitingForProxy = false - // Set the proxy. when (proxyMode) { ProxyHelper.NONE -> { @@ -3619,32 +3604,8 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook // Check to see if Orbot is installed. try { - // Get the package manager. - val packageManager = packageManager - // Check to see if Orbot is in the list. This will throw an error and drop to the catch section if it isn't installed. packageManager.getPackageInfo("org.torproject.android", 0) - - // Check to see if the proxy is ready. - if (orbotStatus != ProxyHelper.ORBOT_STATUS_ON) { // Orbot is not ready. - // Set the waiting for proxy status. - waitingForProxy = true - - // Show the waiting for proxy dialog if it isn't already displayed. - if (supportFragmentManager.findFragmentByTag(getString(R.string.waiting_for_proxy_dialog)) == null) { - // Get a handle for the waiting for proxy alert dialog. - val waitingForProxyDialogFragment = WaitingForProxyDialog() - - // Try to show the dialog. Sometimes the window is not yet active if returning from Settings. - try { - // Show the waiting for proxy alert dialog. - waitingForProxyDialogFragment.show(supportFragmentManager, getString(R.string.waiting_for_proxy_dialog)) - } catch (_: Exception) { - // Add the dialog to the pending dialog array list. It will be displayed in `onStart()`. - pendingDialogsArrayList.add(PendingDialogDataClass(waitingForProxyDialogFragment, getString(R.string.waiting_for_proxy_dialog))) - } - } - } } catch (_: PackageManager.NameNotFoundException) { // Orbot is not installed. // Show the Orbot not installed dialog if it is not already displayed. if (supportFragmentManager.findFragmentByTag(getString(R.string.proxy_not_installed_dialog)) == null) { @@ -3683,7 +3644,7 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook } catch (_: PackageManager.NameNotFoundException) { // The Google Play flavor is not installed. // Sow the I2P not installed dialog if it is not already displayed. if (supportFragmentManager.findFragmentByTag(getString(R.string.proxy_not_installed_dialog)) == null) { - // Get a handle for the waiting for proxy alert dialog. + // Get a handle for the I2P not installed alert dialog. val i2pNotInstalledDialogFragment = ProxyNotInstalledDialog.displayDialog(proxyMode) // Try to show the dialog. Sometimes the window is not yet active if returning from Settings. @@ -3710,8 +3671,8 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook } } - // Reload the WebViews if requested and not waiting for the proxy. - if (reloadWebViews && !waitingForProxy) { + // Reload the WebViews if requested. + if (reloadWebViews) { // Reload the WebViews. for (i in 0 until webViewStateAdapter!!.itemCount) { // Get the WebView tab fragment. @@ -4316,68 +4277,6 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook } } - // Create an Orbot status broadcast receiver. - orbotStatusBroadcastReceiver = object : BroadcastReceiver() { - override fun onReceive(context: Context, intent: Intent) { - // Get the content of the status message. - orbotStatus = intent.getStringExtra("org.torproject.android.intent.extra.STATUS")!! - - // If Privacy Browser is waiting on the proxy, load the website now that Orbot is connected. - if ((orbotStatus == ProxyHelper.ORBOT_STATUS_ON) && waitingForProxy) { - // Reset the waiting for proxy status. - waitingForProxy = false - - // Get a list of the current fragments. - val fragmentList = supportFragmentManager.fragments - - // Check each fragment to see if it is a waiting for proxy dialog. Sometimes more than one is displayed. - for (i in fragmentList.indices) { - // Get the fragment tag. - val fragmentTag = fragmentList[i].tag - - // Check to see if it is the waiting for proxy dialog. - if (fragmentTag != null && fragmentTag == getString(R.string.waiting_for_proxy_dialog)) { - // Dismiss the waiting for proxy dialog. - (fragmentList[i] as DialogFragment).dismiss() - } - } - - // Reload existing URLs and load any URLs that are waiting for the proxy. - for (i in 0 until webViewStateAdapter!!.itemCount) { - // Get the WebView tab fragment. - val webViewTabFragment = webViewStateAdapter!!.getPageFragment(i) - - // Get the fragment view. - val fragmentView = webViewTabFragment.view - - // Only process the WebViews if they exist. - if (fragmentView != null) { - // Get the nested scroll WebView from the tab fragment. - val nestedScrollWebView = fragmentView.findViewById(R.id.nestedscroll_webview) - - // Get the waiting for proxy URL string. - val waitingForProxyUrlString = nestedScrollWebView.waitingForProxyUrlString - - // Load the pending URL if it exists. - if (waitingForProxyUrlString.isNotEmpty()) { // A URL is waiting to be loaded. - // Load the URL. - loadUrl(nestedScrollWebView, waitingForProxyUrlString) - - // Reset the waiting for proxy URL string. - nestedScrollWebView.waitingForProxyUrlString = "" - } else { // No URL is waiting to be loaded. - // Reload the existing URL. - nestedScrollWebView.reload() - } - } - } - } - } - } - - // Register the Orbot status broadcast receiver. `ContextCompat` must be used until the minimum API >= 34. - ContextCompat.registerReceiver(this, orbotStatusBroadcastReceiver, IntentFilter("org.torproject.android.intent.action.STATUS"), ContextCompat.RECEIVER_EXPORTED) - // Get handles for views that need to be modified. val bookmarksHeaderLinearLayout = findViewById(R.id.bookmarks_header_linearlayout) val launchBookmarksActivityFab = findViewById(R.id.launch_bookmarks_activity_fab) @@ -5820,12 +5719,8 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook sharedPreferences.getString("homepage", getString(R.string.homepage_default_value)) } - // Load the website if not waiting for the proxy. - if (waitingForProxy) { // Store the URL to be loaded in the Nested Scroll WebView. - nestedScrollWebView.waitingForProxyUrlString = urlToLoadString!! - } else { // Load the URL. - loadUrl(nestedScrollWebView, urlToLoadString!!) - } + // Load the URL. + loadUrl(nestedScrollWebView, urlToLoadString!!) } else { // This is not the first tab. // Load the URL. loadUrl(nestedScrollWebView, urlString) diff --git a/app/src/main/java/com/stoutner/privacybrowser/dialogs/WaitingForProxyDialog.kt b/app/src/main/java/com/stoutner/privacybrowser/dialogs/WaitingForProxyDialog.kt deleted file mode 100644 index 9089c503..00000000 --- a/app/src/main/java/com/stoutner/privacybrowser/dialogs/WaitingForProxyDialog.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later - * SPDX-FileCopyrightText: 2019-2022 Soren Stoutner - * - * This file is part of Privacy Browser Android . - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later - * version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - */ - -package com.stoutner.privacybrowser.dialogs - -import android.app.Dialog -import android.os.Bundle -import android.view.WindowManager - -import androidx.appcompat.app.AlertDialog -import androidx.fragment.app.DialogFragment -import androidx.preference.PreferenceManager - -import com.stoutner.privacybrowser.R - -class WaitingForProxyDialog : DialogFragment() { - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { - // Use a builder to create the alert dialog. - val dialogBuilder = AlertDialog.Builder(requireContext(), R.style.PrivacyBrowserAlertDialog) - - // Set the layout. - dialogBuilder.setView(R.layout.waiting_for_proxy_dialog) - - // Create an alert dialog from the builder. - val alertDialog = dialogBuilder.create() - - // Get a handle for the shared preferences. - val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext()) - - // Get the screenshot preference. - val allowScreenshots = sharedPreferences.getBoolean(getString(R.string.allow_screenshots_key), false) - - // Disable screenshots if not allowed. - if (!allowScreenshots) { - // Disable screenshots. - alertDialog.window!!.addFlags(WindowManager.LayoutParams.FLAG_SECURE) - } - - // Return the alert dialog. - return alertDialog - } -} \ No newline at end of file diff --git a/app/src/main/java/com/stoutner/privacybrowser/helpers/ProxyHelper.kt b/app/src/main/java/com/stoutner/privacybrowser/helpers/ProxyHelper.kt index bbe9507f..1c88bf87 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/helpers/ProxyHelper.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/helpers/ProxyHelper.kt @@ -20,7 +20,6 @@ package com.stoutner.privacybrowser.helpers import android.content.Context -import android.content.Intent import android.view.View import androidx.core.net.toUri @@ -47,7 +46,6 @@ class ProxyHelper { const val TOR = "Tor" const val I2P = "I2P" const val CUSTOM = "Custom" - const val ORBOT_STATUS_ON = "ON" } fun setProxy(context: Context, activityView: View, proxyMode: String) { @@ -59,21 +57,6 @@ class ProxyHelper { TOR -> { // Add the proxy to the builder. The proxy config builder can use a SOCKS proxy. proxyConfigBuilder.addProxyRule("socks://localhost:9050") - - // Ask Orbot to connect if its current status is not `"ON"`. - if (MainWebViewActivity.orbotStatus != ORBOT_STATUS_ON) { - // Create an intent to request Orbot to start. - val orbotIntent = Intent("org.torproject.android.intent.action.START") - - // Send the intent to the Orbot package. - orbotIntent.setPackage("org.torproject.android") - - // Request a status response be sent back to this package. - orbotIntent.putExtra("org.torproject.android.intent.extra.PACKAGE_NAME", context.packageName) - - // Make it so. - context.sendBroadcast(orbotIntent) - } } I2P -> { diff --git a/app/src/main/java/com/stoutner/privacybrowser/views/NestedScrollWebView.kt b/app/src/main/java/com/stoutner/privacybrowser/views/NestedScrollWebView.kt index c3a983e1..25abd9c5 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/views/NestedScrollWebView.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/views/NestedScrollWebView.kt @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-3.0-or-later - * SPDX-FileCopyrightText: 2019-2025 Soren Stoutner + * SPDX-FileCopyrightText: 2019-2026 Soren Stoutner * * This file is part of Privacy Browser Android . * @@ -108,7 +108,6 @@ class NestedScrollWebView @JvmOverloads constructor(context: Context, attributeS var swipeToRefresh = false var ultraListEnabled = true var ultraPrivacyEnabled = true - var waitingForProxyUrlString = "" var webViewFragmentId: Long = 0 // Define the private variables. diff --git a/app/src/main/res/layout/waiting_for_proxy_dialog.xml b/app/src/main/res/layout/waiting_for_proxy_dialog.xml deleted file mode 100644 index 5704d56e..00000000 --- a/app/src/main/res/layout/waiting_for_proxy_dialog.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 843e27d8..9bcc3c5a 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -484,7 +484,6 @@ Der Orbot-Proxy kann erst nach Installation der Orbot-App genutzt werden. I2P ist nicht installiert Der I2P-Proxy kann erst nach Installation der I2P-App genutzt werden. - Warte auf die Verbindung zum Orbot-Proxy. Die benutzerdefinierte Proxy-URL ist ungültig. - Orbot\'un bağlanması bekleniyor. - Privacy Browser Hakkında diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 81cb1479..d7eed555 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -371,7 +371,6 @@ Orbot应用被安装Orbot才会工作. I2P 未下载 I2P应用被安装I2P才会工作. - 等待Orbot链接. 自定义代理无效. Proxy not installed dialog - Waiting for proxy dialog Orbot Not Installed Proxying through Orbot will not work unless the Orbot app is installed. I2P Not Installed Proxying through I2P will not work unless the I2P app is installed. - Waiting for Orbot to connect. The custom proxy URL is invalid.