diff --git a/app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java b/app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java index 2b5e5ff5..46cc8d2a 100644 --- a/app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java +++ b/app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java @@ -375,6 +375,9 @@ public boolean onOptionsItemSelected(MenuItem item) { case R.id.set_as: setPhotoAs(); break; + case R.id.open_with: + openWith(); + break; case R.id.info: showInfoDialog(); break; @@ -470,6 +473,25 @@ public void setPhotoAs() { } } + public void openWith() { + Uri uri = albumItem.getUri(this); + + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setDataAndType(uri, MediaType.getMimeType(this, albumItem.getPath())); + intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); + + try { + startActivityForResult(Intent.createChooser(intent, + getString(R.string.set_as)), 13); + } catch (SecurityException se) { + Toast.makeText(this, "Error", Toast.LENGTH_SHORT).show(); + se.printStackTrace(); + } catch (ActivityNotFoundException e) { + Toast.makeText(this, "No App found to view your " + albumItem.getType(), Toast.LENGTH_SHORT).show(); + e.printStackTrace(); + } + } + public void sharePhoto() { Uri uri = albumItem.getUri(this); diff --git a/app/src/main/res/menu/item.xml b/app/src/main/res/menu/item.xml index 708238c4..1395a97a 100644 --- a/app/src/main/res/menu/item.xml +++ b/app/src/main/res/menu/item.xml @@ -1,62 +1,67 @@
\ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index aa0af866..2f4cc980 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -201,4 +201,5 @@