- case R.id.copyURL:
- // Make sure that actionBar is not null.
- if (actionBar != null) {
- EditText urlTextBox = (EditText) actionBar.getCustomView().findViewById(R.id.urlTextBox);
- clipboard.setPrimaryClip(ClipData.newPlainText("URL", urlTextBox.getText()));
- }
- return true;
-
- case R.id.pasteURL:
- // Make sure that actionBar is not null.
- if (actionBar != null) {
- ClipData.Item clipboardData = clipboard.getPrimaryClip().getItemAt(0);
- EditText urlTextBox = (EditText) actionBar.getCustomView().findViewById(R.id.urlTextBox);
- urlTextBox.setText(clipboardData.coerceToText(this));
- try {
- loadUrlFromTextBox();
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- return true;
-
- case R.id.shareURL:
- // Make sure that actionBar is not null.
- if (actionBar != null) {
- EditText urlTextBox = (EditText) actionBar.getCustomView().findViewById(R.id.urlTextBox);
- Intent shareIntent = new Intent();
- shareIntent.setAction(Intent.ACTION_SEND);
- shareIntent.putExtra(Intent.EXTRA_TEXT, urlTextBox.getText().toString());
- shareIntent.setType("text/plain");
- 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.
+ case R.id.share:
+ Intent shareIntent = new Intent();
+ shareIntent.setAction(Intent.ACTION_SEND);
+ shareIntent.putExtra(Intent.EXTRA_TEXT, urlTextBox.getText().toString());
+ shareIntent.setType("text/plain");
+ startActivity(Intent.createChooser(shareIntent, "Share URL"));