From e69b54578d1566e5fc7ea813a0834f1213a2f4f1 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Tue, 10 Nov 2020 17:49:39 -0700 Subject: [PATCH] Replace DOM Storage with Bookmarks for additional app bar icons. https://redmine.stoutner.com/issues/575 --- .../activities/MainWebViewActivity.java | 52 ++++++++----------- .../{bookmarks.xml => bookmarks_day.xml} | 2 +- app/src/main/res/drawable/bookmarks_night.xml | 18 +++++++ app/src/main/res/drawable/close_blue_day.xml | 13 +++++ .../main/res/drawable/close_blue_night.xml | 13 +++++ .../res/layout-w900dp/bookmarks_drawer.xml | 11 ++-- app/src/main/res/layout/bookmarks_drawer.xml | 11 ++-- .../main/res/menu/webview_options_menu.xml | 3 +- app/src/main/res/values-de/strings.xml | 2 - app/src/main/res/values-es/strings.xml | 1 - app/src/main/res/values-fr/strings.xml | 2 - app/src/main/res/values-it/strings.xml | 2 - app/src/main/res/values-night-v23/styles.xml | 3 ++ app/src/main/res/values-night-v27/styles.xml | 3 ++ app/src/main/res/values-night/styles.xml | 3 ++ app/src/main/res/values-pt-rBR/strings.xml | 1 - app/src/main/res/values-ru/strings.xml | 1 - app/src/main/res/values-tr/strings.xml | 1 - app/src/main/res/values-v23/styles.xml | 3 ++ app/src/main/res/values-v27/styles.xml | 3 ++ app/src/main/res/values/attrs.xml | 3 ++ app/src/main/res/values/strings.xml | 19 +++---- app/src/main/res/values/styles.xml | 3 ++ 23 files changed, 114 insertions(+), 59 deletions(-) rename app/src/main/res/drawable/{bookmarks.xml => bookmarks_day.xml} (95%) create mode 100644 app/src/main/res/drawable/bookmarks_night.xml create mode 100644 app/src/main/res/drawable/close_blue_day.xml create mode 100644 app/src/main/res/drawable/close_blue_night.xml 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 ef226d7f..1196fb7a 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -743,9 +743,9 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook updatePrivacyIcons(false); // Get handles for the menu items. + MenuItem bookmarksMenuItem = menu.findItem(R.id.bookmarks); MenuItem toggleFirstPartyCookiesMenuItem = menu.findItem(R.id.toggle_first_party_cookies); MenuItem toggleThirdPartyCookiesMenuItem = menu.findItem(R.id.toggle_third_party_cookies); - MenuItem toggleDomStorageMenuItem = menu.findItem(R.id.toggle_dom_storage); MenuItem toggleSaveFormDataMenuItem = menu.findItem(R.id.toggle_save_form_data); // Form data can be removed once the minimum API >= 26. MenuItem clearFormDataMenuItem = menu.findItem(R.id.clear_form_data); // Form data can be removed once the minimum API >= 26. MenuItem refreshMenuItem = menu.findItem(R.id.refresh); @@ -771,18 +771,18 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Get the shared preferences. SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); - // Get the dark theme and app bar preferences.. - boolean displayAdditionalAppBarIcons = sharedPreferences.getBoolean("display_additional_app_bar_icons", false); + // Get the dark theme and app bar preferences. + boolean displayAdditionalAppBarIcons = sharedPreferences.getBoolean(getString(R.string.display_additional_app_bar_icons_key), false); // Set the status of the additional app bar icons. Setting the refresh menu item to `SHOW_AS_ACTION_ALWAYS` makes it appear even on small devices like phones. if (displayAdditionalAppBarIcons) { - toggleFirstPartyCookiesMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); - toggleDomStorageMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); refreshMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); + bookmarksMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); + toggleFirstPartyCookiesMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } else { //Do not display the additional icons. - toggleFirstPartyCookiesMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); - toggleDomStorageMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); refreshMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); + bookmarksMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); + toggleFirstPartyCookiesMenuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); } // Replace Refresh with Stop if a URL is already loading. @@ -797,9 +797,9 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Set the icon according to the current theme status. if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { - refreshMenuItem.setIcon(R.drawable.close_day); + refreshMenuItem.setIcon(R.drawable.close_blue_day); } else { - refreshMenuItem.setIcon(R.drawable.close_night); + refreshMenuItem.setIcon(R.drawable.close_blue_night); } } } @@ -4392,7 +4392,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Get handles for the menu items. MenuItem privacyMenuItem = optionsMenu.findItem(R.id.toggle_javascript); MenuItem firstPartyCookiesMenuItem = optionsMenu.findItem(R.id.toggle_first_party_cookies); - MenuItem domStorageMenuItem = optionsMenu.findItem(R.id.toggle_dom_storage); MenuItem refreshMenuItem = optionsMenu.findItem(R.id.refresh); // Update the privacy icon. @@ -4418,30 +4417,23 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook } } - // Update the DOM storage icon. - if (currentWebView.getSettings().getJavaScriptEnabled() && currentWebView.getSettings().getDomStorageEnabled()) { // Both JavaScript and DOM storage are enabled. - domStorageMenuItem.setIcon(R.drawable.dom_storage_enabled); - } else if (currentWebView.getSettings().getJavaScriptEnabled()) { // JavaScript is enabled but DOM storage is disabled. + // Update the refresh icon. + if (refreshMenuItem.getTitle() == getString(R.string.refresh)) { // The refresh icon is displayed. + // Set the icon according to the theme. if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { - domStorageMenuItem.setIcon(R.drawable.dom_storage_disabled_day); + refreshMenuItem.setIcon(R.drawable.refresh_enabled_day); } else { - domStorageMenuItem.setIcon(R.drawable.dom_storage_disabled_night); + refreshMenuItem.setIcon(R.drawable.refresh_enabled_night); } - } else { // JavaScript is disabled, so DOM storage is ghosted. + } else { // The stop icon is displayed. + // Set the icon according to the theme. if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { - domStorageMenuItem.setIcon(R.drawable.dom_storage_ghosted_day); + refreshMenuItem.setIcon(R.drawable.close_blue_day); } else { - domStorageMenuItem.setIcon(R.drawable.dom_storage_ghosted_night); + refreshMenuItem.setIcon(R.drawable.close_blue_night); } } - // Update the refresh icon. - if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { - refreshMenuItem.setIcon(R.drawable.refresh_enabled_day); - } else { - refreshMenuItem.setIcon(R.drawable.refresh_enabled_night); - } - // `invalidateOptionsMenu()` calls `onPrepareOptionsMenu()` and redraws the icons in the app bar. if (runInvalidateOptionsMenu) { invalidateOptionsMenu(); @@ -6202,7 +6194,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook refreshMenuItem.setTitle(R.string.stop); // Get the app bar and theme preferences. - boolean displayAdditionalAppBarIcons = sharedPreferences.getBoolean("display_additional_app_bar_icons", false); + boolean displayAdditionalAppBarIcons = sharedPreferences.getBoolean(getString(R.string.display_additional_app_bar_icons_key), false); // If the icon is displayed in the AppBar, set it according to the theme. if (displayAdditionalAppBarIcons) { @@ -6211,9 +6203,9 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Set the stop icon according to the theme. if (currentThemeStatus == Configuration.UI_MODE_NIGHT_NO) { - refreshMenuItem.setIcon(R.drawable.close_day); + refreshMenuItem.setIcon(R.drawable.close_blue_day); } else { - refreshMenuItem.setIcon(R.drawable.close_night); + refreshMenuItem.setIcon(R.drawable.close_blue_night); } } } @@ -6235,7 +6227,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook refreshMenuItem.setTitle(R.string.refresh); // Get the app bar and theme preferences. - boolean displayAdditionalAppBarIcons = sharedPreferences.getBoolean("display_additional_app_bar_icons", false); + boolean displayAdditionalAppBarIcons = sharedPreferences.getBoolean(getString(R.string.display_additional_app_bar_icons_key), false); // If the icon is displayed in the app bar, reset it according to the theme. if (displayAdditionalAppBarIcons) { diff --git a/app/src/main/res/drawable/bookmarks.xml b/app/src/main/res/drawable/bookmarks_day.xml similarity index 95% rename from app/src/main/res/drawable/bookmarks.xml rename to app/src/main/res/drawable/bookmarks_day.xml index 000555df..cca74f55 100644 --- a/app/src/main/res/drawable/bookmarks.xml +++ b/app/src/main/res/drawable/bookmarks_day.xml @@ -13,6 +13,6 @@ diff --git a/app/src/main/res/drawable/bookmarks_night.xml b/app/src/main/res/drawable/bookmarks_night.xml new file mode 100644 index 00000000..4caf3514 --- /dev/null +++ b/app/src/main/res/drawable/bookmarks_night.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/close_blue_day.xml b/app/src/main/res/drawable/close_blue_day.xml new file mode 100644 index 00000000..adb58f68 --- /dev/null +++ b/app/src/main/res/drawable/close_blue_day.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/drawable/close_blue_night.xml b/app/src/main/res/drawable/close_blue_night.xml new file mode 100644 index 00000000..8a1732cd --- /dev/null +++ b/app/src/main/res/drawable/close_blue_night.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/layout-w900dp/bookmarks_drawer.xml b/app/src/main/res/layout-w900dp/bookmarks_drawer.xml index e49aaf9c..9ff91e7c 100644 --- a/app/src/main/res/layout-w900dp/bookmarks_drawer.xml +++ b/app/src/main/res/layout-w900dp/bookmarks_drawer.xml @@ -79,8 +79,9 @@ android:layout_gravity="bottom|end" android:layout_marginEnd="16dp" android:layout_marginBottom="155dp" - android:src="@drawable/bookmarks" - android:tint="?attr/fabIconTintColor" /> + android:src="@drawable/bookmarks_day" + android:tint="?attr/fabIconTintColor" + android:contentDescription="@string/bookmarks" /> + android:tint="?attr/fabIconTintColor" + android:contentDescription="@string/create_folder" /> + android:tint="?attr/fabIconTintColor" + android:contentDescription="@string/create_bookmark" /> \ No newline at end of file diff --git a/app/src/main/res/layout/bookmarks_drawer.xml b/app/src/main/res/layout/bookmarks_drawer.xml index 62955c55..46eb252b 100644 --- a/app/src/main/res/layout/bookmarks_drawer.xml +++ b/app/src/main/res/layout/bookmarks_drawer.xml @@ -78,8 +78,9 @@ android:layout_gravity="bottom|end" android:layout_marginEnd="16dp" android:layout_marginBottom="155dp" - android:src="@drawable/bookmarks" - android:tint="?attr/fabIconTintColor" /> + android:src="@drawable/bookmarks_day" + android:tint="?attr/fabIconTintColor" + android:contentDescription="@string/bookmarks" /> + android:tint="?attr/fabIconTintColor" + android:contentDescription="@string/create_folder" /> + android:tint="?attr/fabIconTintColor" + android:contentDescription="@string/create_bookmark" /> \ No newline at end of file diff --git a/app/src/main/res/menu/webview_options_menu.xml b/app/src/main/res/menu/webview_options_menu.xml index a8dcd39b..a4a8428f 100644 --- a/app/src/main/res/menu/webview_options_menu.xml +++ b/app/src/main/res/menu/webview_options_menu.xml @@ -37,10 +37,12 @@ android:orderInCategory="200" app:showAsAction="never" /> + App-Leiste scrollen Scrollt die App-Leiste mit der URL nach oben, wenn die Webseite gescrollt wird. Weitere Icons in der Titelleiste - Zeigt in der App-Leiste die Icons zum Neu-Laden der Webseite und - sofern Platz vorhanden ist - - zum Umschalten von Cookies und DOM Storage. Erscheinungsbild System-Einstellung diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 877d49c3..6fef35b1 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -591,7 +591,6 @@ Desplazar la barra de aplicaciones Desplazar la barra de aplicaciones desde la parte superior de la pantalla cuando el WebView se desplaza hacia abajo. Mostrar iconos adicionales en la barra de aplicación - Mostrar iconos en la barra de aplicaciones para refrescar el WebView y, si hay espacio, para alternar entre cookies y almacenamiento DOM. Tema de la app Por defecto del sistema diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 60b36f26..3fa3d970 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -591,8 +591,6 @@ Défilement barre d\'applications Faites défiler la barre d\'applications en haut de l\'écran lorsque WebView défile vers le bas. Icônes supplémentaires dans la barre d\'applications - Affichez des icônes dans la barre d\'applications pour actualiser WebView et, le cas échéant, - pour activer/désactiver les cookies et le stockage DOM. Thème de l\'application Par défaut diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 7d279c9a..26cf6c8e 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -590,8 +590,6 @@ Permetti lo scrolling della barra dell\'applicazione Permette lo scorrere della barra dell\'applicazione dalla parte alta dello schermo quando si effettua lo scrolling. Mostra icone addizionali nella barra dell\'applicazione - Mostra nella barra dell\'applicazione le icone per l\'aggiornamento di WebView e, se lo spazio è sufficiente, - per l\'attivazione dei cookie e del DOM storage. Tema Applicazione Predefinito diff --git a/app/src/main/res/values-night-v23/styles.xml b/app/src/main/res/values-night-v23/styles.xml index c3673ce6..55b22074 100644 --- a/app/src/main/res/values-night-v23/styles.xml +++ b/app/src/main/res/values-night-v23/styles.xml @@ -46,6 +46,9 @@ @drawable/list_selector_night + + @drawable/bookmarks_night + @drawable/about_night @drawable/close_night diff --git a/app/src/main/res/values-night-v27/styles.xml b/app/src/main/res/values-night-v27/styles.xml index 759fb1a1..09599e6d 100644 --- a/app/src/main/res/values-night-v27/styles.xml +++ b/app/src/main/res/values-night-v27/styles.xml @@ -48,6 +48,9 @@ @drawable/list_selector_night + + @drawable/bookmarks_night + @drawable/about_night @drawable/close_night diff --git a/app/src/main/res/values-night/styles.xml b/app/src/main/res/values-night/styles.xml index 1f385797..becf6a0f 100644 --- a/app/src/main/res/values-night/styles.xml +++ b/app/src/main/res/values-night/styles.xml @@ -44,6 +44,9 @@ @drawable/list_selector_night + + @drawable/bookmarks_night + @drawable/about_night @drawable/close_night diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index e414528a..7c10a329 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -586,7 +586,6 @@ Role a barra de aplicativos Role a barra de aplicativos para fora da parte superior da tela quando o WebView rola para baixo. Exibir ícones adicionais da barra de aplicativos - Exibe ícones na barra de aplicativos para atualizar o WebView e, se houver espaço, para alternar cookies e armazenamento DOM. Tema do aplicativo Padrão do Sitema diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 0af2e1f7..407caa20 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -584,7 +584,6 @@ Прокручивать панель приложения Прокручивает панель приложения вверху экрана при прокрутке WebView вниз. Отображать дополнительные значки на панели приложения - Отображать значки на панели приложения для обновления WebView и, при наличии места, для переключения файлов cookie и хранилища DOM Тема приложения По умолчанию diff --git a/app/src/main/res/values-tr/strings.xml b/app/src/main/res/values-tr/strings.xml index 6780b43e..3ec2ed66 100644 --- a/app/src/main/res/values-tr/strings.xml +++ b/app/src/main/res/values-tr/strings.xml @@ -515,7 +515,6 @@ Uygulama çubuğunu kaydır WebView aşağı kaydırıldığında, ekranın üst kısmından uygulama çubuğunu kaydırır. Ek uygulama çubuğu simgelerini göster - WebView\'ı yenilemek, yer varsa çerezleri ve DOM depolamayı değiştirmek için simgeleri uygulama çubuğunda gösterir. Geniş ekran Geniş ekran kullanmak, bazı web sayfalarının düzenini masaüstü versiyonları gibi yapar. Web sayfasının görsellerini göster diff --git a/app/src/main/res/values-v23/styles.xml b/app/src/main/res/values-v23/styles.xml index 5c22d038..2a907cc6 100644 --- a/app/src/main/res/values-v23/styles.xml +++ b/app/src/main/res/values-v23/styles.xml @@ -46,6 +46,9 @@ @drawable/list_selector_day + + @drawable/bookmarks_day + @drawable/about_day @drawable/close_day diff --git a/app/src/main/res/values-v27/styles.xml b/app/src/main/res/values-v27/styles.xml index 7fa4b5c8..ec11484a 100644 --- a/app/src/main/res/values-v27/styles.xml +++ b/app/src/main/res/values-v27/styles.xml @@ -48,6 +48,9 @@ @drawable/list_selector_day + + @drawable/bookmarks_day + @drawable/about_day @drawable/close_day diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index ded150ed..79a60c8a 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -39,6 +39,9 @@ + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fb87dbc2..9d6a9bd1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -648,7 +648,7 @@ Scroll the app bar Scroll the app bar off the top of the screen when the WebView scrolls down. Display additional app bar icons - Display icons in the app bar for refreshing the WebView and, if there is room, for toggling cookies and DOM storage. + Display icons in the app bar for refreshing the WebView and, if there is room, for opening the bookmarks drawer and toggling cookies. App theme System default @@ -679,19 +679,20 @@ allow_screenshots clear_logcat + display_additional_app_bar_icons - Privacy Browser + System default PrivacyBrowser/1.0 - https://www.startpage.com/do/search?query= - - None - http://localhost:8118 - https://www.startpage.com/ - Auto + Auto 100 - System default + https://www.startpage.com/ + http://localhost:8118 + None + + https://www.startpage.com/do/search?query= + Privacy Browser System default diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 21d99f63..464b023e 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -44,6 +44,9 @@ @drawable/list_selector_day + + @drawable/bookmarks_day + @drawable/about_day @drawable/close_day -- 2.45.2