Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c6fe872b authored by Fs00's avatar Fs00
Browse files

Make sharing downloaded files work by sharing their URL

parent c8d16016
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -203,7 +203,13 @@ public class MainActivity extends CyaneaAppCompatActivity {
    }

    void shareFile() {
        startActivity(Utils.fileShareIntent(getResources().getString(R.string.share), pdfFileName, uri));
        Intent sharingIntent;
        if (uri.getScheme() != null && uri.getScheme().startsWith("http")) {
            sharingIntent = Utils.plainTextShareIntent(getString(R.string.share), uri.toString());
        } else {
            sharingIntent = Utils.fileShareIntent(getString(R.string.share), pdfFileName, uri);
        }
        startActivity(sharingIntent);
    }

    private void openSelectedDocument(Uri selectedDocumentUri) {
+7 −0
Original line number Diff line number Diff line
@@ -70,6 +70,13 @@ public class Utils {
        return email;
    }

    static Intent plainTextShareIntent(String chooserTitle, String text) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, text);
        return Intent.createChooser(intent, chooserTitle);
    }

    static Intent fileShareIntent(String chooserTitle, String fileName, Uri fileUri) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("application/pdf");