@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { finish(); overridePendingTransition(R.anim.fade_in, R.anim.slide_out_right); return true; } else if (item.getItemId() == R.id.action_browser) { Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( getIntent() .getDataString() .replace(getResources().getString(R.string.IMAGE_SCHEME), "http"))); startActivity(intent); finish(); return true; } else if (item.getItemId() == R.id.action_save) { DownloadManager d = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); if (d != null) { DownloadManager.Request r = new DownloadManager.Request( Uri.parse( getIntent() .getDataString() .replace(getResources().getString(R.string.IMAGE_SCHEME), "http"))); if (Build.VERSION.SDK_INT >= 11) { r.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); r.allowScanningByMediaScanner(); } d.enqueue(r); } return true; } else if (item.getItemId() == R.id.action_copy) { if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboard.setText( getIntent() .getDataString() .replace(getResources().getString(R.string.IMAGE_SCHEME), "http")); } else { @SuppressLint("ServiceCast") android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(CLIPBOARD_SERVICE); android.content.ClipData clip = android.content.ClipData.newRawUri( "IRCCloud Image URL", Uri.parse( getIntent() .getDataString() .replace(getResources().getString(R.string.IMAGE_SCHEME), "http"))); clipboard.setPrimaryClip(clip); } Toast.makeText(ImageViewerActivity.this, "Link copied to clipboard", Toast.LENGTH_SHORT) .show(); } return super.onOptionsItemSelected(item); }
public boolean startDrag(View view, Cursor item, long id, Object extraState) { if (!mDragController.startDrag(item)) { return false; } Uri uri = ContentUris.withAppendedId(BrowserContract.Bookmarks.CONTENT_URI, id); ClipData data = ClipData.newRawUri(BOOKMARK_DRAG_LABEL, uri); BookmarkDragState state = new BookmarkDragState(); state.id = id; state.parent = item.getLong(BookmarksLoader.COLUMN_INDEX_PARENT); state.extraState = extraState; mDragState = state; view.startDrag(data, new View.DragShadowBuilder(view), state, 0); mActionMode = view.startActionMode(this); return true; }