Skip to content

Commit

Permalink
Use android share sheet when sharing links and files
Browse files Browse the repository at this point in the history
  • Loading branch information
abelgardep committed Sep 16, 2020
1 parent 894bb4c commit dfe1f8d
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Build;
import android.webkit.MimeTypeMap;

import androidx.fragment.app.DialogFragment;
Expand Down Expand Up @@ -192,9 +193,13 @@ public void sendDownloadedFile(OCFile file) {

// Show dialog, without the own app
String[] packagesToExclude = new String[]{mFileActivity.getPackageName()};
DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude);
chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
mFileActivity.startActivity(Intent.createChooser(sendIntent, ""));
} else {
DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude);
chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
}
} else {
Timber.e("Trying to send a NULL OCFile");
}
Expand Down Expand Up @@ -441,7 +446,12 @@ private void shareLink(String link) {
}

String[] packagesToExclude = new String[]{mFileActivity.getPackageName()};
DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intentToShareLink, packagesToExclude);
chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
mFileActivity.startActivity(Intent.createChooser(intentToShareLink, ""));
} else {
DialogFragment chooserDialog = ShareLinkToDialog.newInstance(intentToShareLink, packagesToExclude);
chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG);
}
}
}

0 comments on commit dfe1f8d

Please sign in to comment.