private String formattedUrlString;
// homepage is used in onCreate and onOptionsItemSelected.
private String homepage = "https://www.duckduckgo.com/";
- // enableJavaScript is used in onCreate and onOptionsItemSelected.
+ // enableJavaScript is used in onCreate, onCreateOptionsMenu, and onOptionsItemSelected.
private boolean enableJavaScript;
- // enableDomStorage is used in onCreate and onOptionsItemSelected.
+ // enableDomStorage is used in onCreate, onCreateOptionsMenu, and onOptionsItemSelected.
private boolean enableDomStorage;
+
+ /* enableSaveFormData does nothing until database storage is implemented.
+ // enableSaveFormData is used in onCreate, onCreateOptionsMenu, and onOptionsItemSelected.
+ private boolean enableSaveFormData;
+ */
+
// actionBar is used in onCreate and onOptionsItemSelected.
private ActionBar actionBar;
enableDomStorage = true;
mainWebView.getSettings().setDomStorageEnabled(enableDomStorage);
+ /* Save Form Data does nothing until database storage is implemented.
+ // Set Save Form Data initial status.
+ enableSaveFormData = true;
+ mainWebView.getSettings().setSaveFormData(enableSaveFormData);
+ */
+
// Get the intent information that started the app.
final Intent intent = getIntent();
getMenuInflater().inflate(R.menu.menu_webview, menu);
MenuItem toggleJavaScriptMenuItem = menu.findItem(R.id.toggleJavaScript);
MenuItem toggleDomStorageMenuItem = menu.findItem(R.id.toggleDomStorage);
+ /* toggleSaveFormData does nothing until database storage is implemented.
+ MenuItem toggleSaveFormDataMenuItem = menu.findItem(R.id.toggleSaveFormData);
+ */
- // Set the JavaScript menu item checkbox initial status.
+ // Set the initial status of the menu item checkboxes.
toggleJavaScriptMenuItem.setChecked(enableJavaScript);
-
- // Set the DOM Storage menu item checkbox initial status.
toggleDomStorageMenuItem.setChecked(enableDomStorage);
+ /* toggleSaveFormData does nothing until database storage is implemented.
+ toggleSaveFormDataMenuItem.setChecked(enableSaveFormData);
+ */
return true;
}
enableJavaScript = false;
menuItem.setChecked(false);
mainWebView.getSettings().setJavaScriptEnabled(false);
- mainWebView.loadUrl(formattedUrlString);
+ mainWebView.reload();
} else {
enableJavaScript = true;
menuItem.setChecked(true);
mainWebView.getSettings().setJavaScriptEnabled(true);
- mainWebView.loadUrl(formattedUrlString);
+ mainWebView.reload();
}
return true;
enableDomStorage = false;
menuItem.setChecked(false);
mainWebView.getSettings().setDomStorageEnabled(false);
- mainWebView.loadUrl(formattedUrlString);
+ mainWebView.reload();
} else {
enableDomStorage = true;
menuItem.setChecked(true);
mainWebView.getSettings().setDomStorageEnabled(true);
- mainWebView.loadUrl(formattedUrlString);
+ mainWebView.reload();
}
return true;
+ /* toggleSaveFormData does nothing until database storage is implemented.
+ case R.id.toggleSaveFormData:
+ if (enableSaveFormData) {
+ enableSaveFormData = false;
+ menuItem.setChecked(false);
+ mainWebView.getSettings().setSaveFormData(false);
+ mainWebView.reload();
+ } else {
+ enableSaveFormData = true;
+ menuItem.setChecked(true);
+ mainWebView.getSettings().setSaveFormData(true);
+ mainWebView.reload();
+ }
+ return true;
+ */
+
case R.id.home:
mainWebView.loadUrl(homepage);
return true;
case R.id.refresh:
- mainWebView.loadUrl(formattedUrlString);
+ mainWebView.reload();
return true;
case R.id.back:
android:checkable="true"
app:showAsAction="never" />
+ <!-- toggleSaveFormData does nothing until database storage is implemented
+ <item
+ android:id="@+id/toggleSaveFormData"
+ android:title="@string/saveFormData"
+ android:orderInCategory="3"
+ android:checkable="true"
+ app:showAsAction="never" />
+ -->
+
<item
android:id="@+id/home"
android:title="@string/home"
- android:orderInCategory="2"
+ android:orderInCategory="10"
android:icon="@drawable/ic_home_black_24dp"
app:showAsAction="never" />
<item
android:id="@+id/refresh"
android:title="@string/refresh"
- android:orderInCategory="3"
+ android:orderInCategory="20"
app:showAsAction="never" />
<item
android:id="@+id/back"
android:title="@string/back"
- android:orderInCategory="4"
+ android:orderInCategory="30"
android:icon="@drawable/ic_back"
app:showAsAction="never" />
<item
android:id="@+id/forward"
android:title="@string/forward"
- android:orderInCategory="5"
+ android:orderInCategory="40"
android:icon="@drawable/ic_forward"
app:showAsAction="never" />
<item
android:id="@+id/copyURL"
android:title="@string/copy_URL"
- android:orderInCategory="6"
+ android:orderInCategory="50"
tools:targetApi="11"
app:showAsAction="never" />
<item
android:id="@+id/pasteURL"
android:title="@string/paste_URL"
- android:orderInCategory="7"
+ android:orderInCategory="60"
tools:targetApi="11"
app:showAsAction="never" />
<item
android:id="@+id/shareURL"
android:title="@string/share_URL"
- android:orderInCategory="8"
+ android:orderInCategory="70"
app:showAsAction="never" />
<item
android:id="@+id/addToHomescreen"
android:title="@string/add_to_home_screen"
- android:orderInCategory="9"
+ android:orderInCategory="80"
app:showAsAction="never" />
<item
android:id="@+id/downloads"
android:title="@string/downloads"
- android:orderInCategory="10"
+ android:orderInCategory="90"
app:showAsAction="never" />
<item
android:id="@+id/about"
android:title="@string/about"
- android:orderInCategory="11"
+ android:orderInCategory="100"
app:showAsAction="never" />
</menu>