Loading app/src/main/java/com/gsnathan/pdfviewer/MainActivity.java +7 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading app/src/main/java/com/gsnathan/pdfviewer/Utils.java +7 −0 Original line number Diff line number Diff line Loading @@ -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"); Loading Loading
app/src/main/java/com/gsnathan/pdfviewer/MainActivity.java +7 −1 Original line number Diff line number Diff line Loading @@ -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) { Loading
app/src/main/java/com/gsnathan/pdfviewer/Utils.java +7 −0 Original line number Diff line number Diff line Loading @@ -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"); Loading