From e90fe1c8be4ede280e8f9e4b17710330f11f9355 Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Fri, 29 Jan 2016 17:16:53 -0700 Subject: [PATCH] Set toggleJavaScript MenuItem as showAsAction="always". Update AboutDialog to close on URL load. --- app/src/main/AndroidManifest.xml | 4 +-- app/src/main/assets/about_text.html | 9 ++++++ .../stoutner/privacybrowser/AboutDialog.java | 15 ++++++++-- .../CreateHomeScreenShortcut.java | 2 +- .../{Webview.java => MainWebView.java} | 22 +++++++++----- app/src/main/res/drawable-hdpi/ic_back.png | Bin 220 -> 0 bytes app/src/main/res/drawable-hdpi/ic_forward.png | Bin 225 -> 0 bytes .../res/drawable-hdpi/ic_home_black_24dp.png | Bin 313 -> 0 bytes app/src/main/res/drawable-mdpi/ic_back.png | Bin 170 -> 0 bytes app/src/main/res/drawable-mdpi/ic_forward.png | Bin 180 -> 0 bytes .../res/drawable-mdpi/ic_home_black_24dp.png | Bin 249 -> 0 bytes app/src/main/res/drawable-xhdpi/ic_back.png | Bin 248 -> 0 bytes .../main/res/drawable-xhdpi/ic_forward.png | Bin 255 -> 0 bytes .../res/drawable-xhdpi/ic_home_black_24dp.png | Bin 481 -> 0 bytes app/src/main/res/drawable-xxhdpi/ic_back.png | Bin 368 -> 0 bytes .../main/res/drawable-xxhdpi/ic_forward.png | Bin 384 -> 0 bytes .../drawable-xxhdpi/ic_home_black_24dp.png | Bin 463 -> 0 bytes app/src/main/res/drawable/javascript_off.xml | 14 +++++++++ app/src/main/res/drawable/javascript_on.xml | 14 +++++++++ app/src/main/res/menu/menu_webview.xml | 27 +++++++----------- app/src/main/res/values/strings.xml | 18 ++++++------ 21 files changed, 88 insertions(+), 37 deletions(-) rename app/src/main/java/com/stoutner/privacybrowser/{Webview.java => MainWebView.java} (96%) delete mode 100644 app/src/main/res/drawable-hdpi/ic_back.png delete mode 100644 app/src/main/res/drawable-hdpi/ic_forward.png delete mode 100644 app/src/main/res/drawable-hdpi/ic_home_black_24dp.png delete mode 100644 app/src/main/res/drawable-mdpi/ic_back.png delete mode 100644 app/src/main/res/drawable-mdpi/ic_forward.png delete mode 100644 app/src/main/res/drawable-mdpi/ic_home_black_24dp.png delete mode 100644 app/src/main/res/drawable-xhdpi/ic_back.png delete mode 100644 app/src/main/res/drawable-xhdpi/ic_forward.png delete mode 100644 app/src/main/res/drawable-xhdpi/ic_home_black_24dp.png delete mode 100644 app/src/main/res/drawable-xxhdpi/ic_back.png delete mode 100644 app/src/main/res/drawable-xxhdpi/ic_forward.png delete mode 100644 app/src/main/res/drawable-xxhdpi/ic_home_black_24dp.png create mode 100644 app/src/main/res/drawable/javascript_off.xml create mode 100644 app/src/main/res/drawable/javascript_on.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 61a4c6f2..9d41c67a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ diff --git a/app/src/main/assets/about_text.html b/app/src/main/assets/about_text.html index ac8865e0..482a1f6f 100644 --- a/app/src/main/assets/about_text.html +++ b/app/src/main/assets/about_text.html @@ -6,7 +6,16 @@

Privacy Browser is released under the GPLv3+ license. The full text of the license is below.

+

/app/src/main/res/drawable/javascript_on.xml is part of the Android Material icon set, where it is named ic_visibility. + It is released under the CC-BY license. Changes to fill color were made by Soren Stoutner in 2016.

+ +

/app/src/main/res/drawable/javascript_off.xml is part of the Android Material icon set, where it is named ic_visibility_off. + It is released under the CC-BY license. Changes to fill color were made by Soren Stoutner in 2016.

+
+
+
+

GNU GENERAL PUBLIC LICENSE

Version 3, 29 June 2007

diff --git a/app/src/main/java/com/stoutner/privacybrowser/AboutDialog.java b/app/src/main/java/com/stoutner/privacybrowser/AboutDialog.java index 5cedfd6d..44d3ac08 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/AboutDialog.java +++ b/app/src/main/java/com/stoutner/privacybrowser/AboutDialog.java @@ -1,5 +1,5 @@ /** - * Copyright 2015 Soren Stoutner . + * Copyright 2015-2016 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -26,10 +26,11 @@ import android.support.annotation.NonNull; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatDialogFragment; import android.webkit.WebView; +import android.webkit.WebViewClient; public class AboutDialog extends AppCompatDialogFragment { - // onCreateDialog requires @NonNull. @Override + // onCreateDialog requires @NonNull. @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { // Create a WebView to display about_text.html @@ -51,6 +52,16 @@ public class AboutDialog extends AppCompatDialogFragment { final AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); + aboutDialogWebView.setWebViewClient(new WebViewClient() { + // shouldOverrideUrlLoading lets us close AboutDialog when a link is touched. Otherwise the dialog covers the website that loads beneath in Privacy Browser. + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + MainWebView.mainWebView.loadUrl(url); + alertDialog.dismiss(); + return true; + } + }); + // onCreateDialog requires the return of an AlertDialog. return alertDialog; } diff --git a/app/src/main/java/com/stoutner/privacybrowser/CreateHomeScreenShortcut.java b/app/src/main/java/com/stoutner/privacybrowser/CreateHomeScreenShortcut.java index 9057433e..0d437e28 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/CreateHomeScreenShortcut.java +++ b/app/src/main/java/com/stoutner/privacybrowser/CreateHomeScreenShortcut.java @@ -60,7 +60,7 @@ public class CreateHomeScreenShortcut extends AppCompatDialogFragment { @NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { // Create a drawable version of the favorite icon. - Drawable favoriteIconDrawable = new BitmapDrawable(getResources(), Webview.favoriteIcon); + Drawable favoriteIconDrawable = new BitmapDrawable(getResources(), MainWebView.favoriteIcon); // Use AlertDialog.Builder to create the AlertDialog AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity()); diff --git a/app/src/main/java/com/stoutner/privacybrowser/Webview.java b/app/src/main/java/com/stoutner/privacybrowser/MainWebView.java similarity index 96% rename from app/src/main/java/com/stoutner/privacybrowser/Webview.java rename to app/src/main/java/com/stoutner/privacybrowser/MainWebView.java index 53311f7a..3582df9f 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/Webview.java +++ b/app/src/main/java/com/stoutner/privacybrowser/MainWebView.java @@ -57,12 +57,12 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; -public class Webview extends AppCompatActivity implements CreateHomeScreenShortcut.CreateHomeScreenSchortcutListener { +public class MainWebView extends AppCompatActivity implements CreateHomeScreenShortcut.CreateHomeScreenSchortcutListener { // favoriteIcon is public static so it can be accessed from CreateHomeScreenShortcut. public static Bitmap favoriteIcon; + // mainWebView is public static so it can be accessed from AboutDialog. It is also used in onCreate and onOptionsItemSelected. + public static WebView mainWebView; - // mainWebView is used in onCreate and onOptionsItemSelected. - private WebView mainWebView; // formattedUrlString is used in onCreate, onOptionsItemSelected, onCreateHomeScreenShortcutCreate, and loadUrlFromTextBox. private String formattedUrlString; // homepage is used in onCreate and onOptionsItemSelected. @@ -332,8 +332,14 @@ public class Webview extends AppCompatActivity implements CreateHomeScreenShortc */ MenuItem toggleCookies = menu.findItem(R.id.toggleCookies); + // Set the initial icon for toggleJavaScript + if (enableJavaScript) { + toggleJavaScript.setIcon(R.drawable.javascript_on); + } else { + toggleJavaScript.setIcon(R.drawable.javascript_off); + } + // Set the initial status of the menu item checkboxes. - toggleJavaScript.setChecked(enableJavaScript); toggleDomStorage.setChecked(enableDomStorage); /* toggleSaveFormData does nothing until database storage is implemented. toggleSaveFormData.setChecked(enableSaveFormData); @@ -380,14 +386,16 @@ public class Webview extends AppCompatActivity implements CreateHomeScreenShortc case R.id.toggleJavaScript: if (enableJavaScript) { enableJavaScript = false; - menuItem.setChecked(false); + menuItem.setIcon(R.drawable.javascript_off); mainWebView.getSettings().setJavaScriptEnabled(false); mainWebView.reload(); + Toast.makeText(getApplicationContext(), "JavaScript Disabled", Toast.LENGTH_SHORT).show(); } else { enableJavaScript = true; - menuItem.setChecked(true); + menuItem.setIcon(R.drawable.javascript_on); mainWebView.getSettings().setJavaScriptEnabled(true); mainWebView.reload(); + Toast.makeText(getApplicationContext(), "JavaScript Enabled", Toast.LENGTH_SHORT).show(); } return true; @@ -524,7 +532,7 @@ public class Webview extends AppCompatActivity implements CreateHomeScreenShortc aboutDialog.show(getSupportFragmentManager(), "aboutDialog"); return true; - case R.id.exit: + case R.id.clearAndExit: // Clear DOM storage. WebStorage domStorage = WebStorage.getInstance(); domStorage.deleteAllData(); diff --git a/app/src/main/res/drawable-hdpi/ic_back.png b/app/src/main/res/drawable-hdpi/ic_back.png deleted file mode 100644 index 2e13b17c878f0bc2486d2863e2d07d9afc3c7be1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 220 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpUt#hxyXAr-gY&amcc3E**!?e?yi zpC=MKbMDs59h+}^CUiM&2!431SV6(;-V<5TOC~@q;uDJNrUtQ{{Ghq?T-N7JZf-kI zRu|0vcl`AF?6rGSD)e`M-^LatnX7VG-lr~*uiq@A8H5_Q{xscCB^*B8w%W?}&)ihW zXV1+P)(3PXk+a-^SU?gdUT()^QExPJ1JqVNAzQm(&dU{E+L&S@XR;Ln}h3$&ZT M)78&qol`;+0Lh3~U;qFB diff --git a/app/src/main/res/drawable-hdpi/ic_forward.png b/app/src/main/res/drawable-hdpi/ic_forward.png deleted file mode 100644 index 0258cbed56a11ac6ddf9cbbc4442facc1aa32dcf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 225 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpUt6`n4RAr-gY&hX`GHV|+t7VDod zf3B!)WO?lM-Yd7Q8d;9y-hLo{ubDCYaLt*+Ef(wy3?JN+dWty`r^wu6i{JBoeh~l4 zhrwRKa(B!&JU?|mX!Zt%X5Ky57-Cx|Tw2*uQNEM2#7P~5c5U~&_GIR4^A&Gp9;DCS zz_vd7@wBg{96uR8aTTh4`6E5m?!*PQTo79JfA_vWmy>p$eP#D9Y{~rVj0_LH$^1GP V!yvO|H9yeJ44$rjF6*2UngDL6U*iA( diff --git a/app/src/main/res/drawable-hdpi/ic_home_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_home_black_24dp.png deleted file mode 100644 index a1ba11a43708133b1cf681ecff818f56cfa12cc3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 313 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezr3(Ffw?$IEGZ*dOLL^Uz34|t6^b5 zQAz2wg`BLHwsJ3?{jcF4!{&84yIwea$*qvg)EW3&qzqFRd@H)*)5%o=dvQ|L!K6lhSm*T3+ z-*@eqd3~>q%XiMbcVj32n0@opEQK>$uLTQP{ZYtIJD>e~+Wdh#0fjFN^7~X-92mf;;U6=|a%D3)SG_z(tHrt)78&q Iol`;+00{zumjD0& diff --git a/app/src/main/res/drawable-mdpi/ic_back.png b/app/src/main/res/drawable-mdpi/ic_back.png deleted file mode 100644 index 6f6cd2008c76b9c3ba7e2eb2dbefdbf63772a258..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 170 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJLQfaRkcwN$2@TOQka*Nl9IxGq-sin z!UMJAMXM5xjg7Y+eBZ#>-{d%v!(GbP0l+XkKRewF+ diff --git a/app/src/main/res/drawable-mdpi/ic_forward.png b/app/src/main/res/drawable-mdpi/ic_forward.png deleted file mode 100644 index 1c249eff378d6be24365598c09378597c7e956b3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 180 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJYEKu(kcwN$2@yn>cGmhC9y=W;PqHwh}*ytu_>a z5@I@}U>2KOR#1?@7&V9Ii19)TP8B!()0RCwJzNuX*pnwnc=RosHhcE$&y2dOoVLrH z6bw}`HQ5;B@9)o(;mECbdZNt5q>Ky=uh7$tY^S89rN0Yol4)zq+U;1iBFXZC`z!}$ zb)js_Ny=(XUxHFBF9;MX%=23H)T3_(mr=70P|psgT7%}8(-SYToZt!Xa%ze>y>c1{ v`%>l;fyS>I0@-~)z2(T&zW*H?@pI1Sx_Q}N zFGWJ@q}m=DvhQf``k)!F?$Z+gsr1?F?Lns$m;8D5p5fDzlatl`=h;+(827jQ`Mvqu z*XhqMosbEinxA{D(58K=c*0ADhw_Z=3$8EVQ0h=s>o` lYD9AG)#7GgXke>gny{n9^Y`=4nLrmYc)I$ztaD0e0s#1>Y4HF6 diff --git a/app/src/main/res/drawable-xhdpi/ic_forward.png b/app/src/main/res/drawable-xhdpi/ic_forward.png deleted file mode 100644 index 6e81f733b026c0d26cf810cb7f22986ccb09886c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=$2?seLn>~)y>*cDkb{83#W`yn zHgvG^&(^8l#G<`HKDg=D+SiH`oNYWkQtq`|>i?gtqv&&;5vXzY#2~Adspl=@f9>19 z-Lh>;{%4uChgX?;7Al>2x|~yZ;kBx)Mg2Q#c5rz6H*hF*C^R7v)m<0(Y`5=xn`l?x zKaFXP)WRu6f6HFnOPk8^UnF5F2a`)Z>!J9jeXJ)YtNYKhsr>ZhB#80neZ<6VN#_K0`)pAyf!(jOqNGI+ZBxvXu;=Zy0tL*}56lCjEHny<}1cK?J+eFF6f9p9AVF(L>Joc6I z!G$H6y>ri**_qpD2qAL7_IVHlFAP5KmG~%%j(y+nd7k&p;By?uM|&Z@ z*=$}x@EcbC*9`u~|7tD1-ELpBTCI18O*0Hg5q*xSrT8!m?;&uwEIh-AA;;EAyz9Dm z5H`m5K3`=3$6)LS->HN41IKY5A#Acrct%Y4E^|~;`Dipc#3}|@&14Pn|DQv`9L!ZI z@hJQR@r;kJ{b(y>L-5n0G*Q{%93p*iY?$UOR z*ru0@?ry$q@k=*Ek8_pkq(}2|jp7Eo5}skiV9_-ee?y?NyJZKLmw4lo=);7YLa(_+ zclVXIc*BHG)=K(!1ILI@#*5JCtcL}mB` XS~+-OXG5he00000NkvXXu0mjf=PK4r diff --git a/app/src/main/res/drawable-xxhdpi/ic_back.png b/app/src/main/res/drawable-xxhdpi/ic_back.png deleted file mode 100644 index 99615cccfbd9d036f42363194e5acc9b4dce4a0e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 368 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>U^Mr1aSW-r_4bZ$*C7XihKo60 zwVE1L+=>+S6<&zO?EJ)@pUo=Lw7`1zX~Bz diff --git a/app/src/main/res/drawable-xxhdpi/ic_forward.png b/app/src/main/res/drawable-xxhdpi/ic_forward.png deleted file mode 100644 index fc68e9530282cb603fc90f57fd05a2b582e7790a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 384 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>V08C%aSW-r_4bZ!Uz3AGLt^ya zu1=K(3B4z*K3}+^bD#R}Su5Xq?9h(O56(RLtTs8f(C+!cr3q$}RXitw(J%J3i+8OH zFH>^Pyw#|;vc;)jW{f@Yu)NMXV|;W-s8Fd=l3)FwTl&NI_8Sc{%^r) zA+>VVs%hun?2&GoY~WOT|9o;We?2dQ`{Q5xJ!F~s+-x{EZv1^k5vcHxU|&Itvdlvc zcRb7~aW&c73NP9RM}DlV6J`%!b1xL!eT948qf_TDZs%99c4wO~Q<>R-fn_IW`X0{T zlCSnBoo}`2n$TW&L$GXv@|y(r8wdL~G|MKkTi-ayR|aIgNq{nq7w*}zzG2U{O+CLG v#J7tT3GLangQai7WW)9Ar^5n4wVZi^LXe$P>7@u@$TE1k`njxgN@xNA&~>CF diff --git a/app/src/main/res/drawable-xxhdpi/ic_home_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_home_black_24dp.png deleted file mode 100644 index fc2bd7ef08ee88d9daf84ef320f4381da9af3520..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 463 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>V4UXZ;uunK>+OxbUWWr1+&^|T z>-Fv0CDO&$xXkssUTw>shJ6j2*U8Sc5~+=TFWMR*;yX(^fA;-GZq+Z$|CX!H>2m{` z1qabGXVW%o&HHgf#x^MQ>c<+p{ru0rKE87_d)mv!qe+EP)1Er#{`oGvzW4ZJVQ$qF zqnUGBH_qR7e7$Ey&-slZOkIn1a4@g0liIJAXgb&LyzVu{#0#ejHrM{k{c~P;zI1%@ z&b(v$`I^`Lx2p3!Wc5dCoz4#C#3Q#0%zS}HbgbXIF@^h3!RZgYb(z+6Z|4czPtLs9 z*0}Zchx>n|SfaZRy!yqlZCT^huYx(cOxles2d|lI5b_Yn@nzON*ju^d;59QKS0Zl1 zTd4?66(02)ySUb{d~a#y-=@;2dgBv^&cSc@fea%cW13?E=QbXu>sI$f{-60AOdJXg3_v2`KFgCokt_lZ42*aPcmRSJ3*7H9?1)~iu3Nv< P3B>nw^>bP0l+XkKnEbV` diff --git a/app/src/main/res/drawable/javascript_off.xml b/app/src/main/res/drawable/javascript_off.xml new file mode 100644 index 00000000..0965c3ea --- /dev/null +++ b/app/src/main/res/drawable/javascript_off.xml @@ -0,0 +1,14 @@ + + + + + diff --git a/app/src/main/res/drawable/javascript_on.xml b/app/src/main/res/drawable/javascript_on.xml new file mode 100644 index 00000000..306bf042 --- /dev/null +++ b/app/src/main/res/drawable/javascript_on.xml @@ -0,0 +1,14 @@ + + + + + diff --git a/app/src/main/res/menu/menu_webview.xml b/app/src/main/res/menu/menu_webview.xml index d0042d98..fe01a0bd 100644 --- a/app/src/main/res/menu/menu_webview.xml +++ b/app/src/main/res/menu/menu_webview.xml @@ -20,19 +20,17 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" - tools:context=".Webview"> + tools:context=".MainWebView"> - + app:showAsAction="always" /> @@ -55,13 +53,13 @@ @@ -69,7 +67,6 @@ android:id="@+id/home" android:title="@string/home" android:orderInCategory="10" - android:icon="@drawable/ic_home_black_24dp" app:showAsAction="never" /> @@ -103,14 +98,14 @@ @@ -133,8 +128,8 @@ app:showAsAction="never" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8c2c531b..49b5e94a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -24,23 +24,23 @@ Favorite Icon - JavaScript - DOM Storage - Save Form Data + JavaScript + DOM Storage + Save Form Data Cookies - Clear DOM Storage - Clear Cookies + Clear DOM Storage + Clear Cookies Home Refresh Back Forward - Copy URL - Paste URL - Share URL + Copy URL + Paste URL + Share URL Add to Home Screen Downloads About - Exit + Clear and Exit Shortcut name -- 2.43.0