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 @@ + xmlns:app="http://schemas.android.com/apk/res-auto"> + android:id="@+id/set_as" + android:icon="@drawable/ic_wallpaper_white_24dp" + android:title="@string/set_as" + app:showAsAction="never"/> + android:id="@+id/open_with" + android:title="@string/open_with" + app:showAsAction="never"/> + android:id="@+id/info" + android:icon="@drawable/ic_info_white_24dp" + android:title="@string/info" + android:visible="false" + app:showAsAction="never"/> + android:id="@+id/share" + android:icon="@drawable/ic_share_white_24dp" + android:title="@string/share" + android:visible="false" + app:showAsAction="never"/> + android:id="@+id/print" + android:icon="@drawable/ic_print_white_24dp" + android:title="@string/print" + app:showAsAction="never"/> + android:id="@+id/edit" + android:icon="@drawable/ic_mode_edit_white_24dp" + android:title="@string/edit" + android:visible="false" + app:showAsAction="never"/> + android:id="@+id/copy" + android:icon="@drawable/ic_content_copy_white_24dp" + android:title="@string/copy" + app:showAsAction="never"/> + android:id="@+id/move" + android:icon="@drawable/ic_folder_move_white_24dp" + android:title="@string/move" + app:showAsAction="never"/> + android:id="@+id/rename" + android:title="@string/rename" + app:showAsAction="never" + android:visible="false"/> + + \ 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 @@ Please select the root folder of your removable Storage device (e.g. SD Card) on the next screen. + Open with...