From: Soren Stoutner Date: Tue, 14 May 2019 22:30:57 +0000 (-0700) Subject: Fix the current WebView sometimes being set wrong. https://redmine.stoutner.com... X-Git-Tag: v3.1~7 X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=commitdiff_plain;h=2a62b9649cacb6fef3446174750d24014847af7f Fix the current WebView sometimes being set wrong. https://redmine.stoutner.com/issues/441 --- 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 74faf112..43a17fa5 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -1900,13 +1900,8 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Update the swipe refresh layout. if (currentWebView.getSwipeToRefresh()) { // Swipe to refresh is enabled. - if (Build.VERSION.SDK_INT >= 23) { // For API >= 23, the status of the scroll refresh listener is continuously updated by the on scroll change listener. - // Only enable the swipe refresh layout if the WebView is scrolled to the top. - swipeRefreshLayout.setEnabled(currentWebView.getY() == 0); - } else { // For API < 23, the swipe refresh layout is always enabled. - // Enable the swipe refresh layout. - swipeRefreshLayout.setEnabled(true); - } + // Only enable the swipe refresh layout if the WebView is scrolled to the top. It is updated every time the scroll changes. + swipeRefreshLayout.setEnabled(currentWebView.getY() == 0); } else { // Swipe to refresh is disabled. // Disable the swipe refresh layout. swipeRefreshLayout.setEnabled(false); @@ -4283,7 +4278,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook EditText urlEditText = findViewById(R.id.url_edittext); SwipeRefreshLayout swipeRefreshLayout = findViewById(R.id.swiperefreshlayout); - //Stop the swipe to refresh indicator if it is running + // Stop the swipe to refresh indicator if it is running swipeRefreshLayout.setRefreshing(false); // Get the WebView tab fragment. @@ -4293,19 +4288,14 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook View fragmentView = webViewTabFragment.getView(); // Set the current WebView if the fragment view is not null. - if (fragmentView != null) { + if (fragmentView != null) { // The fragment has been populated. // Store the current WebView. currentWebView = fragmentView.findViewById(R.id.nestedscroll_webview); // Update the status of swipe to refresh. if (currentWebView.getSwipeToRefresh()) { // Swipe to refresh is enabled. - if (Build.VERSION.SDK_INT >= 23) { // For API >= 23, swipe refresh layout is continuously updated with an on scroll change listener and only enabled if the WebView is scrolled to the top. - // Enable the swipe refresh layout if the WebView is scrolled all the way to the top. - swipeRefreshLayout.setEnabled(currentWebView.getY() == 0); - } else { - // Enable the swipe refresh layout. - swipeRefreshLayout.setEnabled(true); - } + // Enable the swipe refresh layout if the WebView is scrolled all the way to the top. It is updated every time the scroll changes. + swipeRefreshLayout.setEnabled(currentWebView.getY() == 0); } else { // Swipe to refresh is disabled. // Disable the swipe refresh layout. swipeRefreshLayout.setEnabled(false); @@ -4369,6 +4359,18 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook } else { urlRelativeLayout.setBackground(getResources().getDrawable(R.color.transparent)); } + } else { // The fragment has not been populated. Try again in 100 milliseconds. + // Create a handler to set the current WebView. + Handler setCurrentWebViewHandler = new Handler(); + + // Create a runnable to set the current WebView. + Runnable setCurrentWebWebRunnable = () -> { + // Set the current WebView. + setCurrentWebView(pageNumber); + }; + + // Try setting the current WebView again after 100 milliseconds. + setCurrentWebViewHandler.postDelayed(setCurrentWebWebRunnable, 100); } } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 46801728..54a3f11d 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -139,9 +139,10 @@ Cookies löschen DOM-Speicher löschen Formulardaten löschen - Fanboy’s Annoyance Sperrliste - Fanboy’s Social Blocking Sperrliste - Alle Zugriffe auf Dritt-Anbieter-Inhalte blockieren + Fanboy’s Annoyance Sperrliste + Fanboy’s Social Blocking Sperrliste + Alle Zugriffe auf Dritt-Anbieter-Inhalte blockieren + Seite User Agent Privacy Browser WebView-Standard diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index a56de191..f3dc8833 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -136,9 +136,10 @@ Borrar cookies Borrar almacenamiento DOM Borrar datos de formulario - Lista molesta de Fanboy - Lista de bloqueo social de Fanboy - Bloquear todas las solicitudes de terceros + Lista molesta de Fanboy + Lista de bloqueo social de Fanboy + Bloquear todas las solicitudes de terceros + Página Agente de usuario Navegador Privado WebView por defecto diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index f774fae4..ed934bc7 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -136,9 +136,10 @@ Elimina cookies Elimina DOM storage Elimina dati dei moduli - Fanboy’s annoyance list - Fanboy’s social blocking list - Blocca tutte le richieste di Terze Parti + Fanboy’s annoyance list + Fanboy’s social blocking list + Blocca tutte le richieste di Terze Parti + Pagina User agent Privacy Browser WebView Default @@ -163,6 +164,7 @@ 175% 200% Swipe per aggiornare + Finestra grande Mostra immagini Modalità Notte Cerca nella pagina @@ -313,8 +315,8 @@ Impostazioni di default - Wide viewport enabled - Wide viewport disabled + Finestra grande abilitata + Finestra grande disabilitata Impostazioni di default @@ -575,6 +577,8 @@ La modifica del tema provocherà il riavvio di Privacy Browser. Modalità Notte L\'abilitazione della modalità notte attiva anche JavaScript per tutte le pagine web. + Finestra grande + L\'utilizzo di una finestra grande permette la visualizzazione di alcune pagine web come in modalità desktop. Mostra immagini delle pagine web Disabilita per ridurre il consumo di dati. diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 42c639bf..ab422e04 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -133,9 +133,10 @@ Очистить cookie Очистить DOM-хранилище Очистить данные формы - Fanboy’s annoyance list - Fanboy’s social blocking list - Блокировать все сторонние запросы + Fanboy’s annoyance list + Fanboy’s social blocking list + Блокировать все сторонние запросы + Страница User agent Privacy Browser WebView по умолчанию diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 9994beab..5eda4fab 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -133,9 +133,10 @@ Çerezleri Temizle DOM Depolamasını Temizle Form Verisini Temizle - Fanboy’s Annoyance List - Fanboy’s Social Blocking List - Tüm Üçüncü Taraf İstekleri Engelle + Fanboy’s Annoyance List + Fanboy’s Social Blocking List + Tüm Üçüncü Taraf İstekleri Engelle + Sayfa Kullanıcı aracısı Privacy Browser Varsayılan WebView diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dcff833f..3c8dd00a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -140,9 +140,9 @@ Clear Cookies Clear DOM Storage Clear Form Data - Fanboy’s Annoyance List - Fanboy’s Social Blocking List - Block All Third-Party Requests + Fanboy’s Annoyance List + Fanboy’s Social Blocking List + Block All Third-Party Requests Page User Agent Privacy Browser