Skip to content
This repository has been archived by the owner on Sep 8, 2019. It is now read-only.

Commit

Permalink
- added "Open with..." button
Browse files Browse the repository at this point in the history
  • Loading branch information
kollerlukas committed Jun 14, 2017
1 parent bc5f1e6 commit d9f63e1
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 41 deletions.
22 changes: 22 additions & 0 deletions app/src/main/java/us/koller/cameraroll/ui/ItemActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
87 changes: 46 additions & 41 deletions app/src/main/res/menu/item.xml
Original file line number Diff line number Diff line change
@@ -1,62 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/set_as"
android:icon="@drawable/ic_wallpaper_white_24dp"
android:title="@string/set_as"
app:showAsAction="never" />
android:id="@+id/set_as"
android:icon="@drawable/ic_wallpaper_white_24dp"
android:title="@string/set_as"
app:showAsAction="never"/>

<item
android:id="@+id/info"
android:icon="@drawable/ic_info_white_24dp"
android:title="@string/info"
android:visible="false"
app:showAsAction="never" />
android:id="@+id/open_with"
android:title="@string/open_with"
app:showAsAction="never"/>

<item
android:id="@+id/share"
android:icon="@drawable/ic_share_white_24dp"
android:title="@string/share"
android:visible="false"
app:showAsAction="never" />
android:id="@+id/info"
android:icon="@drawable/ic_info_white_24dp"
android:title="@string/info"
android:visible="false"
app:showAsAction="never"/>

<item
android:id="@+id/print"
android:icon="@drawable/ic_print_white_24dp"
android:title="@string/print"
app:showAsAction="never" />
android:id="@+id/share"
android:icon="@drawable/ic_share_white_24dp"
android:title="@string/share"
android:visible="false"
app:showAsAction="never"/>

<item
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/print"
android:icon="@drawable/ic_print_white_24dp"
android:title="@string/print"
app:showAsAction="never"/>

<item
android:id="@+id/copy"
android:icon="@drawable/ic_content_copy_white_24dp"
android:title="@string/copy"
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"/>

<item
android:id="@+id/move"
android:icon="@drawable/ic_folder_move_white_24dp"
android:title="@string/move"
app:showAsAction="never" />
android:id="@+id/copy"
android:icon="@drawable/ic_content_copy_white_24dp"
android:title="@string/copy"
app:showAsAction="never"/>

<item
android:id="@+id/rename"
android:title="@string/rename"
app:showAsAction="never"
android:visible="false" />
android:id="@+id/move"
android:icon="@drawable/ic_folder_move_white_24dp"
android:title="@string/move"
app:showAsAction="never"/>

<item
android:id="@+id/delete"
android:icon="@drawable/ic_delete_white_24dp"
android:title="@string/delete"
android:visible="false"
app:showAsAction="never" />
android:id="@+id/rename"
android:title="@string/rename"
app:showAsAction="never"
android:visible="false"/>

<item
android:id="@+id/delete"
android:icon="@drawable/ic_delete_white_24dp"
android:title="@string/delete"
android:visible="false"
app:showAsAction="never"/>
</menu>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,5 @@
<string name="grant_removable_storage_permission_message">Please select the root folder of your
removable Storage device (e.g. SD Card) on the next screen.
</string>
<string name="open_with">Open with...</string>
</resources>

0 comments on commit d9f63e1

Please sign in to comment.