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);
|
final Uri uri = Uri.fromFile(file);
|
||||||
intent.setAction(Intent.ACTION_SEND);
|
intent.setAction(Intent.ACTION_SEND);
|
||||||
intent.putExtra(Intent.EXTRA_STREAM, uri);
|
intent.putExtra(Intent.EXTRA_STREAM, uri);
|
||||||
if (medium.getIsVideo()) {
|
intent.setType(getMimeType(medium));
|
||||||
intent.setType("video/*");
|
|
||||||
} else {
|
|
||||||
intent.setType("image/*");
|
|
||||||
}
|
|
||||||
activity.startActivity(Intent.createChooser(intent, shareTitle));
|
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) {
|
public static void showSystemUI(ActionBar actionbar, Window window) {
|
||||||
if (actionbar != null)
|
if (actionbar != null)
|
||||||
actionbar.show();
|
actionbar.show();
|
||||||
|
|
|
@ -149,6 +149,9 @@ public class ViewPagerActivity extends SimpleActivity
|
||||||
case R.id.menu_set_as_wallpaper:
|
case R.id.menu_set_as_wallpaper:
|
||||||
setAsWallpaper();
|
setAsWallpaper();
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.menu_open_with:
|
||||||
|
openWith();
|
||||||
|
return true;
|
||||||
case R.id.menu_share:
|
case R.id.menu_share:
|
||||||
shareMedium();
|
shareMedium();
|
||||||
return true;
|
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
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if (requestCode == EDIT_IMAGE) {
|
if (requestCode == EDIT_IMAGE) {
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
android:id="@+id/menu_set_as_wallpaper"
|
android:id="@+id/menu_set_as_wallpaper"
|
||||||
android:title="@string/set_as_wallpaper"
|
android:title="@string/set_as_wallpaper"
|
||||||
app:showAsAction="never"/>
|
app:showAsAction="never"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_open_with"
|
||||||
|
android:title="@string/open_with"
|
||||||
|
app:showAsAction="never"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_edit"
|
android:id="@+id/menu_edit"
|
||||||
android:icon="@mipmap/edit"
|
android:icon="@mipmap/edit"
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
<string name="descending">Absteigend</string>
|
<string name="descending">Absteigend</string>
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
<string name="cancel">Abbrechen</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">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 Ordner gelöscht</item>
|
<item quantity="one">1 Ordner gelöscht</item>
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
<string name="descending">Descendente</string>
|
<string name="descending">Descendente</string>
|
||||||
<string name="ok">Aceptar</string>
|
<string name="ok">Aceptar</string>
|
||||||
<string name="cancel">Cancelar</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">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 carpeta eliminada</item>
|
<item quantity="one">1 carpeta eliminada</item>
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
<string name="descending">Descending</string>
|
<string name="descending">Descending</string>
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
<string name="cancel">Cancel</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">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 cartella eliminata</item>
|
<item quantity="one">1 cartella eliminata</item>
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
<string name="descending">Descending</string>
|
<string name="descending">Descending</string>
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
<string name="cancel">Cancel</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">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 フォルダーを削除しました</item>
|
<item quantity="one">1 フォルダーを削除しました</item>
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
<string name="descending">Descendente</string>
|
<string name="descending">Descendente</string>
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
<string name="cancel">Cancelar</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">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 pasta eliminada</item>
|
<item quantity="one">1 pasta eliminada</item>
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
<string name="descending">Descending</string>
|
<string name="descending">Descending</string>
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
<string name="cancel">Cancel</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">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 mapp borttagen</item>
|
<item quantity="one">1 mapp borttagen</item>
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
<string name="descending">Descending</string>
|
<string name="descending">Descending</string>
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
<string name="cancel">Cancel</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">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 folder deleted</item>
|
<item quantity="one">1 folder deleted</item>
|
||||||
|
|
Loading…
Reference in a new issue