From 4d7e0bfa2399670591dc585f94a976b904787a9d Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Tue, 30 May 2017 17:16:35 -0700 Subject: [PATCH] Add controls for `Clear and Exit`. Implements https://redmine.stoutner.com/issues/133. --- app/src/main/assets/de/about_licenses.html | 3 + app/src/main/assets/en/about_licenses.html | 3 + .../assets/en/images/ic_delete_forever.png | Bin 0 -> 1153 bytes .../main/assets/en/images/ic_donut_small.png | Bin 0 -> 2184 bytes app/src/main/assets/es/about_licenses.html | 3 + app/src/main/assets/es/about_links.html | 2 +- app/src/main/assets/it/about_licenses.html | 3 + .../main/assets/zh-rTW/about_licenses.html | 3 + .../activities/MainWebViewActivity.java | 103 ++++++++++---- .../fragments/SettingsFragment.java | 128 ++++++++++++++++++ app/src/main/res/drawable/cache_cleared.xml | 18 +++ app/src/main/res/drawable/cache_warning.xml | 18 +++ .../drawable/clear_everything_disabled.xml | 13 ++ .../res/drawable/clear_everything_enabled.xml | 13 ++ app/src/main/res/drawable/cookies_cleared.xml | 18 +++ .../main/res/drawable/dom_storage_cleared.xml | 18 +++ .../main/res/drawable/dom_storage_warning.xml | 18 +++ .../main/res/drawable/form_data_cleared.xml | 18 +++ .../main/res/drawable/form_data_warning.xml | 18 +++ app/src/main/res/values/strings.xml | 10 ++ app/src/main/res/xml/preferences.xml | 39 +++++- 21 files changed, 419 insertions(+), 30 deletions(-) create mode 100644 app/src/main/assets/en/images/ic_delete_forever.png create mode 100644 app/src/main/assets/en/images/ic_donut_small.png create mode 100644 app/src/main/res/drawable/cache_cleared.xml create mode 100644 app/src/main/res/drawable/cache_warning.xml create mode 100644 app/src/main/res/drawable/clear_everything_disabled.xml create mode 100644 app/src/main/res/drawable/clear_everything_enabled.xml create mode 100644 app/src/main/res/drawable/cookies_cleared.xml create mode 100644 app/src/main/res/drawable/dom_storage_cleared.xml create mode 100644 app/src/main/res/drawable/dom_storage_warning.xml create mode 100644 app/src/main/res/drawable/form_data_cleared.xml create mode 100644 app/src/main/res/drawable/form_data_warning.xml diff --git a/app/src/main/assets/de/about_licenses.html b/app/src/main/assets/de/about_licenses.html index 8f99162a..f26e12fb 100644 --- a/app/src/main/assets/de/about_licenses.html +++ b/app/src/main/assets/de/about_licenses.html @@ -79,7 +79,9 @@

ic_create_new_folder.

ic_devices_other.

ic_delete.

+

ic_delete_forever.

ic_dns.

+

ic_donut_small.

ic_edit.

ic_exit_to_app.

ic_expand_less.

@@ -98,6 +100,7 @@

ic_list.

ic_local_activity.

ic_location_off.

+

ic_map.

ic_more.

ic_question_answer.

ic_refresh.

diff --git a/app/src/main/assets/en/about_licenses.html b/app/src/main/assets/en/about_licenses.html index 01ebe5d1..5b858444 100644 --- a/app/src/main/assets/en/about_licenses.html +++ b/app/src/main/assets/en/about_licenses.html @@ -73,7 +73,9 @@

ic_create_new_folder.

ic_devices_other.

ic_delete.

+

ic_delete_forever.

ic_dns.

+

ic_donut_small.

ic_edit.

ic_exit_to_app.

ic_expand_less.

@@ -92,6 +94,7 @@

ic_list.

ic_local_activity.

ic_location_off.

+

ic_map.

ic_more.

ic_question_answer.

ic_refresh.

diff --git a/app/src/main/assets/en/images/ic_delete_forever.png b/app/src/main/assets/en/images/ic_delete_forever.png new file mode 100644 index 0000000000000000000000000000000000000000..a4e87cc9aa32b8109c860619d5441c37b977b458 GIT binary patch literal 1153 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSEX7WqAsj$Z!;#Vf4nJ zsK}c%FK2#n0-?(sOp%^S7?P_TBrO&-=~Uweg{)bG5E2D4~L&<$n)YC)~OGkv_~*xyh*^SLyG_Utt?i_iP(U5-%+Vl;YUSN@ObT>89X2Ac!+HKGlF4n|Hr zU<_pB9o}4Fb)xoMJd+#SZ~pbK8G7j5&4dam0LQ{C+Sr^<%IBs%Kx9rAk zB{Ti6Aq}}xWb&qW+kE&h>MXjTA?mQd7tr~$fYdaFJ-2|=RE0f}9QK-lO&`{ZD-q2Wygwn z50`JX@fMg@{^Oo1hkkm-`i5G`=eJ(=&b=e_hA}Sf-n0)z@>aK}C3L>LcQre@Ne}3Y zC;aPtIhXP7&*j|Jww~!iZpGy(3vz#4o_0V97%K0W@2q3l`S5)R)9MeQ3^{E(B7v&* zhjQv14rkmT{p6TXMC<>2&NU#O>@$f9@0tCDy=vLf>tB1-n_rm!FK@w*K-AQ?dLcvc zciua?JMMpz;`(s7nz?UZb^d}jrkaoU8kE1^1}4IL75N7)X20jX@<8J0f9|s0;~W-A z2K)W8Dp-E--1&U3rFnPA2a$ko=L1&%zMtCHmw&)<^2xIkFCXy#b6B(X4~w7V*_?NC zmi#>Ie@}6$)wM?Bw9B)C+Z(LUT-R??eqbhQ_vZSC#tCa>mj2AR9yu$VtG#jWI_p{Y t@@H|!%+HK_w$EYzht3WZ;Nky|DMZ9`f5&X=1YmK&;OXk;vd$@?2>=4=0fqno literal 0 HcmV?d00001 diff --git a/app/src/main/assets/en/images/ic_donut_small.png b/app/src/main/assets/en/images/ic_donut_small.png new file mode 100644 index 0000000000000000000000000000000000000000..1ec1ca883da23f2c5de32d92a627b9da19a8313d GIT binary patch literal 2184 zcmV;32zU31P)A!rO%L3il}*rAw^TOnoA8WF(f4B zk_sAgh*^scW}#}TA@oIPRa;^xTEslpR5U16M51WX*XNJbM_bo>cMogtbMIYWvi^9< z-FvTf&+px{&)$2j1BPK3hG7_nVHk#C7=~fgKBe3aB%mX(F|aN$r@}V9fNsD%V4;#< zh5{=C2Li)^DZotR0=5864*fJOZqovM3rqt>1IGfJMD*7Pqy+2*TnD_#zZbil`3j(% z%>^a^gMl6q;xHW90k{GA?`-QrX$fFSYX)8d&H;J`MP;XHVigKGHHHdi+&4O)@~v3KV|A)fF8)Q>HdkwtrkuL#*%Q&Af*7h z15YE9KI8v626&7_D~PECuqJY!+al3;)y{#yBP94GNFjjk$n*VX3C5}=4gkiWys4xu zfX>Li`R2;w)GEgTS7{EQDS!sxUZ9WS81=w~z{y&jYYN~J;7G;(>xr9zZ8bX962PIr zrAmF*Bb|V8$QnviGz8Ft1e2FKWFz3t*qz1}Km+3BYLWXjgu{WOV|Ex@0E4krK5cG5 zau%WxQve$R*GBBmC{H)w>R6q{6u=1N^@+Xz<756-Y-BbmDm@7u~x*JnSyh%Kao9( zSae2CI^~Y55?d=`-2b7GwrlYf!F~nyQHZ?(IrES^zV_@eh1maL{{jTqmMsJhQj1JS0&;x{D0=ypbC5cHTC^aiab_uw5sGTDjWOg``2X3nq&td!K%$s@Y?fZw zlHr>>z;gCGuz_CKWqCD{@3E~Jheux5TfoMSpHIa-Bzgo|f?4QMyKnM|L3ioP16XrUU0bu6m|FSsoV}!GqoUq7jrvM z&D4SbzRvAHHB$=$n48;yY9@E7SR*qo0{B(Ui!iblTdsC$K>%y#cA%Q61p(}y+ktAP z76g#w99*s9vU}DA5kb+4KQ$wTC_hU)ZUa*8zKBb~!;qJ7L}xbnmwwCHZ5qM0!+-#P zwN0%u>(l}SSI*{>emnTJNWRB5)$QP!j-O9O>!Hn5x2OI{a%>U#8dy;2hg}7b`abKz z9;8WF?F!tQU>skZu92$%-gEqXYDS=&wAujNO@ZF~SB7^rJFkXg;lH7iy4G5mD|dYD zSy0KCN_e9HLAGaq0>?*;c?IM@KX+V}nEKNAbp;5rQhR{#=ky(c4+;=VCH8q>tQAq@ z=ihSn9qzAjFCj@V6AR$KizP`8Z6w|+-Ba3w4l&+e0DpbVIW5fRJisr&B#(BvS>EBZ zDyM3dnGZba+Q|1n$T-h-h8|BLPe4xi3Sbh&-5sn~#``q#6~OPl0~#vKL*6#(OvstQ zn*!Pzad`lln>iCAfY*WP0qu==jPY$4dMend7=fX}bl`2@#-RduoMP_~)&oI_v7rK3 z1Pl%A!|>-VJSTsx#7GReADIsr>A4tL0rVz@02Uz!F@hX1oOv0T9NI~&)UcOmI*KWPFOf2BhA!U&7sTo;c6RV+s&l8XnivB79IG>p z^zf5`pA`Bvpb2<5W``OA_zpM;dn$;{r^xpj6|Djhda6cr&hTOxJ+|^6h)%u0($}< zB^axgcmg;T<;iraDq-IPeSr@XjaThV1dc$`@Ki}zCT=dUH^omd&COUOzi)nu!BW== zoCEBF?pr;onH!OuM)m*vR&o@IoCh2NT%KXL(&c%u}RIH97dzl*p$R zq@qV32j8NSyHxC5z;?*drh4QVB>rq`CAkFv@_5(>xg|7b_9Yd+AV2r}Va2YOVrOK@ zvzBiG6M=Oce5pH1$d>XPYD)k!kQZ+o719U{C*CA6mjJ#(_C!jqUw|R3j;x3OKy?Y= zBV-rP<+b%j8*~8%10Pdd0W3rkHTI@>HI-|M?UB61Z^$ozg}@8Inb_nmIUSG+p(By( zq_%1p#uUIDBoAT`&^HJtXc1Y26tJGU`0qw!uVGhUYhV+gC;oA^AQjR-M`rP_ zAW1Mu%CQ-7=m=~I^m1s^3)m8yz!`>N7=~dOhG7_nVHk!{6Z{R(B ic_create_new_folder.

ic_devices_other.

ic_delete.

+

ic_delete_forever.

ic_dns.

+

ic_donut_small.

ic_edit.

ic_exit_to_app.

ic_expand_less.

@@ -96,6 +98,7 @@

ic_list.

ic_local_activity.

ic_location_off.

+

ic_map.

ic_more.

ic_question_answer.

ic_refresh.

diff --git a/app/src/main/assets/es/about_links.html b/app/src/main/assets/es/about_links.html index c35dc2ea..489d7078 100644 --- a/app/src/main/assets/es/about_links.html +++ b/app/src/main/assets/es/about_links.html @@ -37,7 +37,7 @@

Noticias

-

Roadmap

+

Hoja de ruta

Seguimiento de errores y petición de funciones

diff --git a/app/src/main/assets/it/about_licenses.html b/app/src/main/assets/it/about_licenses.html index 96194b23..585eca4a 100644 --- a/app/src/main/assets/it/about_licenses.html +++ b/app/src/main/assets/it/about_licenses.html @@ -80,7 +80,9 @@

ic_create_new_folder.

ic_devices_other.

ic_delete.

+

ic_delete_forever.

ic_dns.

+

ic_donut_small.

ic_edit.

ic_exit_to_app.

ic_expand_less.

@@ -99,6 +101,7 @@

ic_list.

ic_local_activity.

ic_location_off.

+

ic_map.

ic_more.

ic_question_answer.

ic_refresh.

diff --git a/app/src/main/assets/zh-rTW/about_licenses.html b/app/src/main/assets/zh-rTW/about_licenses.html index 9b32ce20..5226d733 100644 --- a/app/src/main/assets/zh-rTW/about_licenses.html +++ b/app/src/main/assets/zh-rTW/about_licenses.html @@ -73,7 +73,9 @@

ic_create_new_folder.

ic_devices_other.

ic_delete.

+

ic_delete_forever.

ic_dns.

+

ic_donut_small.

ic_edit.

ic_exit_to_app.

ic_expand_less.

@@ -92,6 +94,7 @@

ic_list.

ic_local_activity.

ic_location_off.

+

ic_map.

ic_more.

ic_question_answer.

ic_refresh.

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 f21cae48..63617b69 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -1547,30 +1547,83 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation break; case R.id.clearAndExit: - // Clear cookies. The commands changed slightly in API 21. - if (Build.VERSION.SDK_INT >= 21) { - cookieManager.removeAllCookies(null); - } else { - cookieManager.removeAllCookie(); + // Get a handle for `sharedPreferences`. `this` references the current context. + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); + + boolean clearEverything = sharedPreferences.getBoolean("clear_everything", true); + + // Clear cookies. + if (clearEverything || sharedPreferences.getBoolean("clear_cookies", true)) { + // The command to remove cookies changed slightly in API 21. + if (Build.VERSION.SDK_INT >= 21) { + cookieManager.removeAllCookies(null); + } else { + cookieManager.removeAllCookie(); + } + + // Manually delete the cookies database, as `CookieManager` sometimes will not flush its changes to disk before `System.exit(0)` is run. + try { + // We have to use two commands because `Runtime.exec()` does not like `*`. + privacyBrowserRuntime.exec("rm -f " + privateDataDirectoryString + "/app_webview/Cookies"); + privacyBrowserRuntime.exec("rm -f " + privateDataDirectoryString + "/app_webview/Cookies-journal"); + } catch (IOException e) { + // Do nothing if an error is thrown. + } } // Clear DOM storage. - WebStorage domStorage = WebStorage.getInstance(); - domStorage.deleteAllData(); + if (clearEverything || sharedPreferences.getBoolean("clear_dom_storage", true)) { + // Ask `WebStorage` to clear the DOM storage. + WebStorage webStorage = WebStorage.getInstance(); + webStorage.deleteAllData(); + + // Manually delete the DOM storage directory, as `WebStorage` sometimes will not flush its changes to disk before `System.exit(0)` is run. + try { + // We have to use a `String[]` because the directory contains a space and `Runtime.exec` will not escape the string correctly otherwise. + privacyBrowserRuntime.exec(new String[] {"rm", "-rf", privateDataDirectoryString + "/app_webview/Local Storage/"}); + } catch (IOException e) { + // Do nothing if an error is thrown. + } + } // Clear form data. - WebViewDatabase webViewDatabase = WebViewDatabase.getInstance(this); - webViewDatabase.clearFormData(); + if (clearEverything || sharedPreferences.getBoolean("clear_form_data", true)) { + WebViewDatabase webViewDatabase = WebViewDatabase.getInstance(this); + webViewDatabase.clearFormData(); - // Clear the cache. `true` includes disk files. - mainWebView.clearCache(true); + // Manually delete the form data database, as `WebViewDatabase` sometimes will not flush its changes to disk before `System.exit(0)` is run. + try { + // We have to use a `String[]` because the database contains a space and `Runtime.exec` will not escape the string correctly otherwise. + privacyBrowserRuntime.exec(new String[] {"rm", "-f", privateDataDirectoryString + "/app_webview/Web Data"}); + privacyBrowserRuntime.exec(new String[] {"rm", "-f", privateDataDirectoryString + "/app_webview/Web Data-journal"}); + } catch (IOException e) { + // Do nothing if an error is thrown. + } + } - // Clear the back/forward history. - mainWebView.clearHistory(); + // Clear the cache. + if (clearEverything || sharedPreferences.getBoolean("clear_cache", true)) { + // `true` includes disk files. + mainWebView.clearCache(true); + + // Manually delete the cache directories. + try { + // Delete the main cache directory. + privacyBrowserRuntime.exec("rm -rf " + privateDataDirectoryString + "/cache"); + + // Delete the secondary `Service Worker` cache directory. We have to use a `String[]` because the directory contains a space and `Runtime.exec` will not escape the string correctly otherwise. + privacyBrowserRuntime.exec(new String[] {"rm", "-rf", privateDataDirectoryString + "/app_webview/Service Worker/"}); + } catch (IOException e) { + // Do nothing if an error is thrown. + } + } - // Clear any SSL certificate preferences. + // Clear SSL certificate preferences. mainWebView.clearSslPreferences(); + // Clear the back/forward history. + mainWebView.clearHistory(); + // Clear `formattedUrlString`. formattedUrlString = null; @@ -1583,15 +1636,14 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // Destroy the internal state of `mainWebView`. mainWebView.destroy(); - // Manually delete cache folders. - try { - // Delete the main `cache` folder. - privacyBrowserRuntime.exec("rm -rf " + privateDataDirectoryString + "/cache"); - - // Delete the `app_webview` folder, which contains an additional `WebView` cache. See `https://code.google.com/p/android/issues/detail?id=233826&thanks=233826&ts=1486670530`. - privacyBrowserRuntime.exec("rm -rf " + privateDataDirectoryString + "/app_webview"); - } catch (IOException e) { - // Do nothing if an error is thrown. + // Manually delete the `app_webview` folder, which contains the cookies, DOM storage, form data, and `Service Worker` cache. + // See `https://code.google.com/p/android/issues/detail?id=233826&thanks=233826&ts=1486670530`. + if (clearEverything) { + try { + privacyBrowserRuntime.exec("rm -rf " + privateDataDirectoryString + "/app_webview"); + } catch (IOException e) { + // Do nothing if an error is thrown. + } } // Close Privacy Browser. `finishAndRemoveTask` also removes Privacy Browser from the recent app list. @@ -1604,9 +1656,6 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation // Remove the terminated program from RAM. The status code is `0`. System.exit(0); break; - - default: - break; } // Close the navigation drawer. @@ -2073,7 +2122,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation } private void applyAppSettings() { - // Get the shared preference values. `this` references the current context. + // Get a handle for `sharedPreferences`. `this` references the current context. SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); // Store the values from `sharedPreferences` in variables. 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 2ca68461..6d317f06 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.java +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/SettingsFragment.java @@ -63,6 +63,11 @@ public class SettingsFragment extends PreferenceFragment { final Preference fullScreenBrowsingModePreference = findPreference("full_screen_browsing_mode"); final Preference hideSystemBarsPreference = findPreference("hide_system_bars"); final Preference translucentNavigationBarPreference = findPreference("translucent_navigation_bar"); + final Preference clearEverythingPreference = findPreference("clear_everything"); + final Preference clearCookiesPreference = findPreference("clear_cookies"); + final Preference clearDomStoragePreference = findPreference("clear_dom_storage"); + final Preference clearFormDataPreference = findPreference("clear_form_data"); + final Preference clearCachePreference = findPreference("clear_cache"); final Preference homepagePreference = findPreference("homepage"); final Preference defaultFontSizePreference = findPreference("default_font_size"); final Preference swipeToRefreshPreference = findPreference("swipe_to_refresh"); @@ -86,6 +91,7 @@ public class SettingsFragment extends PreferenceFragment { boolean proxyThroughOrbotBoolean = savedPreferences.getBoolean("proxy_through_orbot", false); boolean fullScreenBrowsingModeBoolean = savedPreferences.getBoolean("full_screen_browsing_mode", false); boolean hideSystemBarsBoolean = savedPreferences.getBoolean("hide_system_bars", false); + boolean clearEverythingBoolean = savedPreferences.getBoolean("clear_everything", true); // Only enable `thirdPartyCookiesPreference` if `firstPartyCookiesEnabledBoolean` is `true` and API >= 21. thirdPartyCookiesPreference.setEnabled(firstPartyCookiesEnabledBoolean && (Build.VERSION.SDK_INT >= 21)); @@ -156,6 +162,11 @@ public class SettingsFragment extends PreferenceFragment { // Enable `translucentNavigationBarPreference` only if full screen browsing mode is enabled and `hide_system_bars` is disabled. translucentNavigationBarPreference.setEnabled(fullScreenBrowsingModeBoolean && !hideSystemBarsBoolean); + // Set the status of the `Clear and Exit` preferences. + clearCookiesPreference.setEnabled(!clearEverythingBoolean); + clearDomStoragePreference.setEnabled(!clearEverythingBoolean); + clearFormDataPreference.setEnabled(!clearEverythingBoolean); + clearCachePreference.setEnabled(!clearEverythingBoolean); // Set the homepage URL as the summary text for the `Homepage` preference when the preference screen is loaded. The default is `https://duckduckgo.com`. homepagePreference.setSummary(savedPreferences.getString("homepage", "https://duckduckgo.com")); @@ -295,6 +306,41 @@ public class SettingsFragment extends PreferenceFragment { translucentNavigationBarPreference.setIcon(R.drawable.translucent_bar_ghosted); } + // Set the `clearEverythingPreference` icon. + if (clearEverythingBoolean) { + clearEverythingPreference.setIcon(R.drawable.clear_everything_enabled); + } else { + clearEverythingPreference.setIcon(R.drawable.clear_everything_disabled); + } + + // Set the `clearCookiesPreference` icon. + if (clearEverythingBoolean || savedPreferences.getBoolean("clear_cookies", true)) { + clearCookiesPreference.setIcon(R.drawable.cookies_cleared); + } else { + clearCookiesPreference.setIcon(R.drawable.cookies_warning); + } + + // Set the `clearDomStoragePreference` icon. + if (clearEverythingBoolean || savedPreferences.getBoolean("clear_dom_storage", true)) { + clearDomStoragePreference.setIcon(R.drawable.dom_storage_cleared); + } else { + clearDomStoragePreference.setIcon(R.drawable.dom_storage_warning); + } + + // Set the `clearFormDataPreference` icon. + if (clearEverythingBoolean || savedPreferences.getBoolean("clear_form_data", true)) { + clearFormDataPreference.setIcon(R.drawable.form_data_cleared); + } else { + clearFormDataPreference.setIcon(R.drawable.form_data_warning); + } + + // Set the `clearCachePreference` icon. + if (clearEverythingBoolean || savedPreferences.getBoolean("clear_cache", true)) { + clearCachePreference.setIcon(R.drawable.cache_cleared); + } else { + clearCachePreference.setIcon(R.drawable.cache_warning); + } + // Set the `swipeToRefreshPreference` icon. if (savedPreferences.getBoolean("swipe_to_refresh", false)) { swipeToRefreshPreference.setIcon(R.drawable.refresh_enabled); @@ -620,6 +666,88 @@ public class SettingsFragment extends PreferenceFragment { } break; + case "clear_everything": + // Store the new `clear_everything` status + boolean newClearEverythingBoolean = sharedPreferences.getBoolean("clear_everything", true); + + // Update the status of the `Clear and Exit` preferences. + clearCookiesPreference.setEnabled(!newClearEverythingBoolean); + clearDomStoragePreference.setEnabled(!newClearEverythingBoolean); + clearFormDataPreference.setEnabled(!newClearEverythingBoolean); + clearCachePreference.setEnabled(!newClearEverythingBoolean); + + // Update the `clearEverythingPreference` icon. + if (newClearEverythingBoolean) { + clearEverythingPreference.setIcon(R.drawable.clear_everything_enabled); + } else { + clearEverythingPreference.setIcon(R.drawable.clear_everything_disabled); + } + + // Update the `clearCookiesPreference` icon. + if (newClearEverythingBoolean || sharedPreferences.getBoolean("clear_cookies", true)) { + clearCookiesPreference.setIcon(R.drawable.cookies_cleared); + } else { + clearCookiesPreference.setIcon(R.drawable.cookies_warning); + } + + // Update the `clearDomStoragePreference` icon. + if (newClearEverythingBoolean || sharedPreferences.getBoolean("clear_dom_storage", true)) { + clearDomStoragePreference.setIcon(R.drawable.dom_storage_cleared); + } else { + clearDomStoragePreference.setIcon(R.drawable.dom_storage_warning); + } + + // Update the `clearFormDataPreference` icon. + if (newClearEverythingBoolean || sharedPreferences.getBoolean("clear_form_data", true)) { + clearFormDataPreference.setIcon(R.drawable.form_data_cleared); + } else { + clearFormDataPreference.setIcon(R.drawable.form_data_warning); + } + + // Update the `clearCachePreference` icon. + if (newClearEverythingBoolean || sharedPreferences.getBoolean("clear_cache", true)) { + clearCachePreference.setIcon(R.drawable.cache_cleared); + } else { + clearCachePreference.setIcon(R.drawable.cache_warning); + } + break; + + case "clear_cookies": + // Update the icon. + if (sharedPreferences.getBoolean("clear_cookies", true)) { + clearCookiesPreference.setIcon(R.drawable.cookies_cleared); + } else { + clearCookiesPreference.setIcon(R.drawable.cookies_warning); + } + break; + + case "clear_dom_storage": + // Update the icon. + if (sharedPreferences.getBoolean("clear_dom_storage", true)) { + clearDomStoragePreference.setIcon(R.drawable.dom_storage_cleared); + } else { + clearDomStoragePreference.setIcon(R.drawable.dom_storage_warning); + } + break; + + case "clear_form_data": + // Update the icon. + if (sharedPreferences.getBoolean("clear_form_data", true)) { + clearFormDataPreference.setIcon(R.drawable.form_data_cleared); + } else { + clearFormDataPreference.setIcon(R.drawable.form_data_warning); + } + break; + + case "clear_cache": + // Update the icon. + if (sharedPreferences.getBoolean("clear_cache", true)) { + clearCachePreference.setIcon(R.drawable.cache_cleared); + } else { + clearCachePreference.setIcon(R.drawable.cache_warning); + } + break; + case "homepage": // Set the new homepage URL as the summary text for the Homepage preference. The default is `https://www.duckduckgo.com`. homepagePreference.setSummary(sharedPreferences.getString("homepage", "https://www.duckduckgo.com")); diff --git a/app/src/main/res/drawable/cache_cleared.xml b/app/src/main/res/drawable/cache_cleared.xml new file mode 100644 index 00000000..4edfd872 --- /dev/null +++ b/app/src/main/res/drawable/cache_cleared.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/cache_warning.xml b/app/src/main/res/drawable/cache_warning.xml new file mode 100644 index 00000000..add2185f --- /dev/null +++ b/app/src/main/res/drawable/cache_warning.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/clear_everything_disabled.xml b/app/src/main/res/drawable/clear_everything_disabled.xml new file mode 100644 index 00000000..fcf007af --- /dev/null +++ b/app/src/main/res/drawable/clear_everything_disabled.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/drawable/clear_everything_enabled.xml b/app/src/main/res/drawable/clear_everything_enabled.xml new file mode 100644 index 00000000..6c901aba --- /dev/null +++ b/app/src/main/res/drawable/clear_everything_enabled.xml @@ -0,0 +1,13 @@ + + + + + + diff --git a/app/src/main/res/drawable/cookies_cleared.xml b/app/src/main/res/drawable/cookies_cleared.xml new file mode 100644 index 00000000..f0ba32b1 --- /dev/null +++ b/app/src/main/res/drawable/cookies_cleared.xml @@ -0,0 +1,18 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/dom_storage_cleared.xml b/app/src/main/res/drawable/dom_storage_cleared.xml new file mode 100644 index 00000000..a20c8ca2 --- /dev/null +++ b/app/src/main/res/drawable/dom_storage_cleared.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/dom_storage_warning.xml b/app/src/main/res/drawable/dom_storage_warning.xml new file mode 100644 index 00000000..ee18ccf1 --- /dev/null +++ b/app/src/main/res/drawable/dom_storage_warning.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/form_data_cleared.xml b/app/src/main/res/drawable/form_data_cleared.xml new file mode 100644 index 00000000..4437a3e0 --- /dev/null +++ b/app/src/main/res/drawable/form_data_cleared.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/app/src/main/res/drawable/form_data_warning.xml b/app/src/main/res/drawable/form_data_warning.xml new file mode 100644 index 00000000..71d77a71 --- /dev/null +++ b/app/src/main/res/drawable/form_data_warning.xml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5d1b86ae..d8eb744d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -310,6 +310,16 @@ Hide the status and navigation bars in full screen browsing mode. This doesn’t work well if the keyboard is displayed during full screen browsing mode. 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. + Clear cookies + Clears first and third-party cookies. + Clear DOM storage + Clear DOM storage. + Clear form data + Clears form data. + Clear cache + Clear WebView’s cache. General Homepage Default font size diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 87b2eac2..162d932b 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -119,7 +119,7 @@ + android:title="@string/search" > + android:title="@string/full_screen" > + + + + + + + + + + + + + -- 2.45.2