fix #6, allow sharing files

This commit is contained in:
tibbi
2016-08-22 22:12:55 +02:00
parent 81433c670c
commit ca7c6c886c
5 changed files with 33 additions and 3 deletions

View File

@ -318,6 +318,8 @@ public class ItemsFragment extends android.support.v4.app.Fragment
mode.finish();
return true;
case R.id.cab_share:
shareFiles();
mode.finish();
return true;
case R.id.cab_copy:
displayCopyDialog();
@ -332,6 +334,26 @@ public class ItemsFragment extends android.support.v4.app.Fragment
}
}
private void shareFiles() {
final List<Integer> itemIndexes = getSelectedItemIndexes();
if (itemIndexes.isEmpty())
return;
final ArrayList<Uri> uris = new ArrayList<>(itemIndexes.size());
for (int i : itemIndexes) {
final File file = new File(mItems.get(i).getPath());
uris.add(Uri.fromFile(file));
}
final String shareTitle = getResources().getString(R.string.share_via);
final Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.shared_files));
sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
sendIntent.setType("*/*");
startActivity(Intent.createChooser(sendIntent, shareTitle));
}
private void displayRenameDialog() {
final List<Integer> itemIndexes = getSelectedItemIndexes();
if (itemIndexes.isEmpty())