public boolean onOptionsItemSelected(MenuItem menuItem) {
int menuItemId = menuItem.getItemId();
- // Some options need to access the clipboard.
- ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
-
// Some options need to update the drawable for toggleJavaScript.
MenuItem toggleJavaScript = mainMenu.findItem(R.id.toggleJavaScript);
- // Sets the commands that relate to the menu entries.
+ // Set the commands that relate to the menu entries.
switch (menuItemId) {
case R.id.toggleJavaScript:
if (javaScriptEnabled) {
Toast.makeText(getApplicationContext(), "Cookies deleted", Toast.LENGTH_SHORT).show();
return true;
+ case R.id.addToHomescreen:
+ // Show the CreateHomeScreenShortcut AlertDialog and name this instance createShortcut.
+ AppCompatDialogFragment shortcutDialog = new CreateHomeScreenShortcut();
+ shortcutDialog.show(getSupportFragmentManager(), "createShortcut");
+
+ //Everything else will be handled by CreateHomeScreenShortcut and the associated listeners below.
+ return true;
+
+ case R.id.downloads:
+ // Launch the system Download Manager.
+ Intent downloadManangerIntent = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS);
+
+ // Launch as a new task so that Download Manager and Privacy Browser show as separate windows in the recent tasks list.
+ downloadManangerIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+ startActivity(downloadManangerIntent);
+ return true;
+
case R.id.home:
mainWebView.loadUrl(homepage);
return true;
mainWebView.goForward();
return true;
- case R.id.copyURL:
- clipboard.setPrimaryClip(ClipData.newPlainText("URL", urlTextBox.getText()));
- return true;
-
- case R.id.pasteURL:
- ClipData.Item clipboardData = clipboard.getPrimaryClip().getItemAt(0);
- urlTextBox.setText(clipboardData.coerceToText(this));
- try {
- loadUrlFromTextBox();
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- return true;
-
- case R.id.shareURL:
+ case R.id.share:
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, urlTextBox.getText().toString());
startActivity(Intent.createChooser(shareIntent, "Share URL"));
return true;
- case R.id.addToHomescreen:
- // Show the CreateHomeScreenShortcut AlertDialog and name this instance createShortcut.
- AppCompatDialogFragment shortcutDialog = new CreateHomeScreenShortcut();
- shortcutDialog.show(getSupportFragmentManager(), "createShortcut");
-
- //Everything else will be handled by CreateHomeScreenShortcut and the associated listeners below.
- return true;
-
- case R.id.downloads:
- // Launch the system Download Manager.
- Intent downloadManangerIntent = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS);
-
- // Launch as a new task so that Download Manager and Privacy Browser show as separate windows in the recent tasks list.
- downloadManangerIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
- startActivity(downloadManangerIntent);
- return true;
-
case R.id.settings:
// Start the Settings activity.
Intent intent = new Intent(this, Settings.class);