mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
close #21, allow opening images and videos with third party apps
This commit is contained in:
parent
4398443a0d
commit
7cd62075e7
10 changed files with 41 additions and 5 deletions
|
@ -102,14 +102,17 @@ public class Utils {
|
|||
final Uri uri = Uri.fromFile(file);
|
||||
intent.setAction(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_STREAM, uri);
|
||||
if (medium.getIsVideo()) {
|
||||
intent.setType("video/*");
|
||||
} else {
|
||||
intent.setType("image/*");
|
||||
}
|
||||
intent.setType(getMimeType(medium));
|
||||
activity.startActivity(Intent.createChooser(intent, shareTitle));
|
||||
}
|
||||
|
||||
public static String getMimeType(Medium medium) {
|
||||
if (medium.getIsVideo())
|
||||
return "video/*";
|
||||
else
|
||||
return "image/*";
|
||||
}
|
||||
|
||||
public static void showSystemUI(ActionBar actionbar, Window window) {
|
||||
if (actionbar != null)
|
||||
actionbar.show();
|
||||
|
|
|
@ -149,6 +149,9 @@ public class ViewPagerActivity extends SimpleActivity
|
|||
case R.id.menu_set_as_wallpaper:
|
||||
setAsWallpaper();
|
||||
return true;
|
||||
case R.id.menu_open_with:
|
||||
openWith();
|
||||
return true;
|
||||
case R.id.menu_share:
|
||||
shareMedium();
|
||||
return true;
|
||||
|
@ -197,6 +200,18 @@ public class ViewPagerActivity extends SimpleActivity
|
|||
}
|
||||
}
|
||||
|
||||
private void openWith() {
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setDataAndType(Uri.fromFile(getCurrentFile()), Utils.getMimeType(getCurrentMedium()));
|
||||
final Intent chooser = Intent.createChooser(intent, getString(R.string.open_with));
|
||||
|
||||
if (intent.resolveActivity(getPackageManager()) != null) {
|
||||
startActivity(chooser);
|
||||
} else {
|
||||
Utils.showToast(getApplicationContext(), R.string.no_app_found);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == EDIT_IMAGE) {
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
android:id="@+id/menu_set_as_wallpaper"
|
||||
android:title="@string/set_as_wallpaper"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/menu_open_with"
|
||||
android:title="@string/open_with"
|
||||
app:showAsAction="never"/>
|
||||
<item
|
||||
android:id="@+id/menu_edit"
|
||||
android:icon="@mipmap/edit"
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
<string name="descending">Absteigend</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Abbrechen</string>
|
||||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 Ordner gelöscht</item>
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
<string name="descending">Descendente</string>
|
||||
<string name="ok">Aceptar</string>
|
||||
<string name="cancel">Cancelar</string>
|
||||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 carpeta eliminada</item>
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
<string name="descending">Descending</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 cartella eliminata</item>
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
<string name="descending">Descending</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 フォルダーを削除しました</item>
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
<string name="descending">Descendente</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancelar</string>
|
||||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 pasta eliminada</item>
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
<string name="descending">Descending</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 mapp borttagen</item>
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
<string name="descending">Descending</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="open_with">Open with</string>
|
||||
<string name="no_app_found">No valid app found</string>
|
||||
|
||||
<plurals name="folders_deleted">
|
||||
<item quantity="one">1 folder deleted</item>
|
||||
|
|
Loading…
Reference in a new issue