private String formattedUrlString;
// homepage is used in onCreate and onOptionsItemSelected.
private String homepage = "https://www.duckduckgo.com/";
- // enableJavaScript is used onCreate and onOptionsItemSelected.
+ // enableJavaScript is used in onCreate and onOptionsItemSelected.
private boolean enableJavaScript;
+ // enableDomStorage is used in onCreate and onOptionsItemSelected.
+ private boolean enableDomStorage;
// actionBar is used in onCreate and onOptionsItemSelected.
private ActionBar actionBar;
// Set JavaScript initial status.
enableJavaScript = true;
- if (enableJavaScript) {
- mainWebView.getSettings().setJavaScriptEnabled(true);
- } else {
- mainWebView.getSettings().setJavaScriptEnabled(false);
- }
+ mainWebView.getSettings().setJavaScriptEnabled(enableJavaScript);
- // Enable DOM Storage.
- mainWebView.getSettings().setDomStorageEnabled(true);
+ // Set DOM Storage initial status.
+ enableDomStorage = true;
+ mainWebView.getSettings().setDomStorageEnabled(enableDomStorage);
// Get the intent information that started the app.
final Intent intent = getIntent();
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_webview, menu);
MenuItem toggleJavaScriptMenuItem = menu.findItem(R.id.toggleJavaScript);
+ MenuItem toggleDomStorageMenuItem = menu.findItem(R.id.toggleDomStorage);
// Set the JavaScript menu item checkbox initial status.
- if (enableJavaScript) {
- toggleJavaScriptMenuItem.setChecked(true);
- } else {
- toggleJavaScriptMenuItem.setChecked(false);
- }
+ toggleJavaScriptMenuItem.setChecked(enableJavaScript);
+
+ // Set the DOM Storage menu item checkbox initial status.
+ toggleDomStorageMenuItem.setChecked(enableDomStorage);
return true;
}
}
return true;
+ case R.id.toggleDomStorage:
+ if (enableDomStorage) {
+ enableDomStorage = false;
+ menuItem.setChecked(false);
+ mainWebView.getSettings().setDomStorageEnabled(false);
+ mainWebView.loadUrl(formattedUrlString);
+ } else {
+ enableDomStorage = true;
+ menuItem.setChecked(true);
+ mainWebView.getSettings().setDomStorageEnabled(true);
+ mainWebView.loadUrl(formattedUrlString);
+ }
+ return true;
+
case R.id.home:
mainWebView.loadUrl(homepage);
return true;
<!--
- Copyright 2015 Soren Stoutner <soren@stoutner.com>.
+ Copyright 2015-2016 Soren Stoutner <soren@stoutner.com>.
This file is part of Privacy Browser <https://privacybrowser.stoutner.com/>.
android:checkable="true"
app:showAsAction="never" />
+
+ <item
+ android:id="@+id/toggleDomStorage"
+ android:title="@string/domStorage"
+ android:orderInCategory="2"
+ android:checkable="true"
+ app:showAsAction="never" />
+
<item
android:id="@+id/home"
android:title="@string/home"