From 1fd6e17736c7e6a410672ce8669241bcf4c4a350 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Fri, 2 Jun 2017 22:10:00 -0700 Subject: [PATCH] Only reload the `WebView` on restart when displaying of images has just been disabled in settings. Fixes https://redmine.stoutner.com/issues/139. --- .../activities/MainWebViewActivity.java | 22 ++++++------- .../fragments/SettingsFragment.java | 10 +++++- app/src/main/res/values-es/strings.xml | 32 ++++++++++++------- app/src/main/res/values-it/strings.xml | 10 ++++++ app/src/main/res/values/strings.xml | 6 ++-- 5 files changed, 53 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index 63617b69..9744eba3 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -138,9 +138,12 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // `webViewTitle` is public static so it can be accessed from `CreateBookmarkDialog` and `CreateHomeScreenShortcutDialog`. It is also used in `onCreate()`. public static String webViewTitle; - // `displayWebpageImagesBoolean` is public static so it can be accessed from `DomainSettingsFragment`. It is also used in `applyAppSettings` and `applyDomainSettings()`. + // `displayWebpageImagesBoolean` is public static so it can be accessed from `DomainSettingsFragment`. It is also used in `applyAppSettings()` and `applyDomainSettings()`. public static boolean displayWebpageImagesBoolean; + // `reloadOnRestartBoolean` is public static so it can be accessed from `SettingsFragment`. It is also used in `onRestart()` + public static boolean reloadOnRestartBoolean; + // `navigatingHistory` is used in `onCreate()`, `onNavigationItemSelected()`, and `applyDomainSettings()`. private boolean navigatingHistory; @@ -237,9 +240,6 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // `onTheFlyDisplayImagesSet` is used in `applyDomainSettings()` and `setDisplayWebpageImages()`. private boolean onTheFlyDisplayImagesSet; - // `loadingNewIntentBoolean` is used in `onNewIntent()` and `onRestart()`. - private boolean loadingNewIntentBoolean; - // `waitingForOrbotData` is used in `onCreate()` and `applyAppSettings()`. private String waitingForOrbotHTMLString; @@ -911,9 +911,6 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation @Override protected void onNewIntent(Intent intent) { - // Set `loadingNewIntentBoolean`. - loadingNewIntentBoolean = true; - // Sets the new intent as the activity intent, so that any future `getIntent()`s pick up this one instead of creating a new activity. setIntent(intent); @@ -948,12 +945,13 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // Set the display webpage images mode. setDisplayWebpageImages(); - // Only reload `mainWebView` if not loading a new intent and not waiting for Orbot. - if (!loadingNewIntentBoolean && !waitingForOrbot) { - // Reload the webpage to remove images if `setDisplayWebpageImages` has turned them off. + // Reload the webpage if displaying of images has been disabled in `SettingsFragment`. + if (reloadOnRestartBoolean) { + // Reload `mainWebView`. mainWebView.reload(); - } else if (loadingNewIntentBoolean) { // Reset `loadingNewIntentBoolean` if this run comes from a new intent. - loadingNewIntentBoolean = false; + + // Reset `reloadOnRestartBoolean`. + reloadOnRestartBoolean = false; } } diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.java b/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.java index 6d317f06..78a92f87 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.java +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.java @@ -30,6 +30,7 @@ import android.view.View; import android.webkit.WebView; import com.stoutner.privacybrowser.R; +import com.stoutner.privacybrowser.activities.MainWebViewActivity; public class SettingsFragment extends PreferenceFragment { private SharedPreferences.OnSharedPreferenceChangeListener preferencesListener; @@ -777,11 +778,18 @@ public class SettingsFragment extends PreferenceFragment { break; case "display_webpage_images": - // Update the icon. if (sharedPreferences.getBoolean("display_webpage_images", true)) { + // Update the icon. displayWebpageImagesPreference.setIcon(R.drawable.images_enabled); + + // `mainWebView` does not need to be reloaded because unloaded images will load automatically. + MainWebViewActivity.reloadOnRestartBoolean = false; } else { + // Update the icon. displayWebpageImagesPreference.setIcon(R.drawable.images_disabled); + + // Set `mainWebView` to reload on restart to remove the current images. + MainWebViewActivity.reloadOnRestartBoolean = true; } break; diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index bc3caf9e..cefb78e8 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -38,9 +38,9 @@ Almacenamiento DOM deshabilitado Datos de formulario habilitados Datos de fromulario deshabilitados - Cookies eliminadas - Almacenamiento DOM eliminado - Datos de formulario eliminados + Cookies borradas + Almacenamiento DOM borrado + Datos de formulario borrado Abrir la caja de navegación Cerrar la caja de navegación Sin título @@ -91,13 +91,13 @@ Atrás Adelante Historial - Eliminar historial + Borrar historial Marcadores Descargas Configuración Guía Acerca de - Eliminar y salir + Borrar y salir Javascript @@ -105,8 +105,8 @@ Cookies de terceras partes Almacenamiento DOM Datos de formulario - Eliminar cookies - Eliminar almacenamiento DOM + Borrar cookies + Borrar almacenamiento DOM Borrar datos de formulario Tamaño de fuente 25% @@ -171,10 +171,10 @@ Subir Bajar Editar - Eliminar + Borrar Selectionar todo - 1 marcador eliminado - Marcadores eliminados + 1 marcador borrado + Marcadores borrados Deshacer @@ -188,7 +188,7 @@ Añadir Nombre de dominio Configuración de dominio guardada - Dominio eliminado + Dominio borrado *. puede ser añadido a un dominio para incluir todos los subdominios (p.ej. *.stoutner.com) Por defecto del sistema @@ -272,6 +272,16 @@ Esconder las barras de estado y de navegación en el modo de navegación a pantalla completa. Esto no funciona bien si el teclado es mostrado durante el modo de navegación a pantalla completa. Barra de navegación translúcida Hacer la barra de navegación translúcida en el modo de navegación a pantalla completa. + Borrar todo + Borra cookies, almacenamiento DOM, datos de formulario y la caché de WebView. A continuación borra manualmente los directorios “app_webview” y “cache”. + Borrar cookies + Borra las cookies de primera y terceras partes. + Borrar almacenamiento DOM + Borra el almacenamiento DOM. + Borrar datos de formulario + Borra los datos de formulario. + Borrar caché + Borra la caché de WebView’. General Página de inicio Tamaño de fuente por defecto diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 3c6a05d4..86786eb6 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -274,6 +274,16 @@ Nasconde la barra di stato e la barra di navigazione durante la navigazione a schermo intero. Questa opzione non funziona perfettamente se si visualizza la tastiera durante la navigazione a schermo intero. Barra di navigazione trasparente Rende la barra di navigazione trasparente durante la navigazione a schermo intero. + Elimina tutto + Cancella i cookies, il DOM storage, i dati dei moduli e la cache di WebView. Cancella completamente le cartelle “app_webview” e “cache”. + Elimina i cookie + Cancella solo i cookie proprietari e di terze parti. + Elimina il DOM storage + Cancella solo il DOM storage. + Elimina i dati dei moduli + Cancella solo i dati dei moduli. + Elimina la cache + Cancella solo la cache di WebView. Generale Homepage Dimensione standard carattere diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d8eb744d..eb7d0ab9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -311,15 +311,15 @@ Translucent navigation bar Make the navigation bar translucent in full screen browsing mode. Clear everything - Clear cookies, DOM storage, form data, and the cache. Then manually delete the entire “app_webview” and “cache” directories. + Clears cookies, DOM storage, form data, and WebView’s cache. Then manually deletes the entire “app_webview” and “cache” directories. Clear cookies Clears first and third-party cookies. Clear DOM storage - Clear DOM storage. + Clears DOM storage. Clear form data Clears form data. Clear cache - Clear WebView’s cache. + Clears WebView’s cache. General Homepage Default font size -- 2.45.2