From 06c06b3e285d195833db2ab5b822b0613563d93f Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Tue, 22 Oct 2024 12:23:38 -0700 Subject: [PATCH] Restore edits in the URL bar when switching tabs. https://redmine.stoutner.com/issues/633 --- .../activities/MainWebViewActivity.kt | 22 ++++++++++++++++--- .../views/NestedScrollWebView.kt | 2 +- app/src/main/res/values-es/strings.xml | 6 +++-- app/src/main/res/values-it/strings.xml | 6 +++-- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 6 files changed, 31 insertions(+), 11 deletions(-) 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 c6172edd..4adec9e5 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt @@ -630,6 +630,22 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook urlRelativeLayout = findViewById(R.id.url_relativelayout) urlEditText = findViewById(R.id.url_edittext) + // Store the URL when it is changed. This enables the restoring of partially-typed URLs when tabs change. + urlEditText.addTextChangedListener(object : TextWatcher { + override fun beforeTextChanged(charSequence: CharSequence, start: Int, count: Int, after: Int) { + // Do nothing. + } + + override fun onTextChanged(charSequence: CharSequence, start: Int, before: Int, count: Int) { + // Do nothing. + } + + override fun afterTextChanged(editable: Editable) { + // Store the URL + currentWebView?.currentUrl = editable.toString() + } + }) + // Initially disable the sliding drawers. They will be enabled once the filter lists are loaded. drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED) @@ -4411,7 +4427,7 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook override fun afterTextChanged(editable: Editable) { // Search for the text in the WebView if it is not null. Sometimes on resume after a period of non-use the WebView will be null. - currentWebView?.findAllAsync(findOnPageEditText.text.toString()) + currentWebView?.findAllAsync(editable.toString()) } }) @@ -6242,11 +6258,11 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook updatePrivacyIcons(true) // Get the current URL. - val urlString = currentWebView!!.url + val urlString = currentWebView!!.currentUrl // Update the URL edit text if not loading a new intent. Otherwise, this will be handled by `onPageStarted()` (if called) and `onPageFinished()`. if (!loadingNewIntent) { // A new intent is not being loaded. - if ((urlString == null) || (urlString == "about:blank")) { // The WebView is blank. + if (urlString.isBlank()) { // The WebView is blank. // Display the hint in the URL edit text. urlEditText.text = null 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 b5b805d8..f2ec71d5 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/views/NestedScrollWebView.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/views/NestedScrollWebView.kt @@ -14,7 +14,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with Privacy Browser Android. If not, see . + * along with Privacy Browser Android. If not, see . */ package com.stoutner.privacybrowser.views diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index d9940aa6..37717b41 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -5,7 +5,7 @@ Translation 2017-2024 Jose A. León. Copyright assigned to Soren Stoutner . - This file is part of Privacy Browser Android . + This file is part of Privacy Browser Android . Privacy Browser Android is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Privacy Browser Android. If not, see . --> + along with Privacy Browser Android. If not, see . --> @@ -279,6 +279,8 @@ Seleccionados:\u0020 %1$d Subir Bajar + Ir arriba + Ir abajo Editar Borrar Selectionar todo diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index b573c6bf..b0f0d5d7 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -5,7 +5,7 @@ Translation 2017-2024 Francesco Buratti. Copyright assigned to Soren Stoutner . - This file is part of Privacy Browser Android . + This file is part of Privacy Browser Android . Privacy Browser Android is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,7 +18,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with Privacy Browser Android. If not, see . --> + along with Privacy Browser Android. If not, see . --> @@ -278,6 +278,8 @@ Selezionato:\u0020 %1$d Sposta sopra Sposta sotto + Sposta in Alto + Sposta in Basso Modifica Elimina Seleziona tutto diff --git a/build.gradle b/build.gradle index da3439b9..8088fb4f 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:8.6.1' + classpath 'com.android.tools.build:gradle:8.7.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20" // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 73b15378..ab3102cf 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -13,11 +13,11 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with Privacy Browser Android. If not, see . +# along with Privacy Browser Android. If not, see . #Thu Oct 15 14:40:42 MST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip -- 2.45.2