From f02df6d80c7e2f534ecd6497d4161e2c955aa63b Mon Sep 17 00:00:00 2001 From: TiA4f8R <74829229+TiA4f8R@users.noreply.github.com> Date: Sun, 25 Apr 2021 14:14:56 +0200 Subject: [PATCH] Fix an error and add a new method in the ShareUtils class Fix the error due to the rebase on the dev branch of this branch Add a shareText method in the ShareUtils class which has 3 parameters and calls the original shareText method with an empty string for the imagePreviewUrl param. --- .../java/org/schabi/newpipe/RouterActivity.java | 2 +- .../org/schabi/newpipe/error/ErrorActivity.java | 3 ++- .../util/external_communication/ShareUtils.java | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/RouterActivity.java b/app/src/main/java/org/schabi/newpipe/RouterActivity.java index 222b6a3d9..55bb8424f 100644 --- a/app/src/main/java/org/schabi/newpipe/RouterActivity.java +++ b/app/src/main/java/org/schabi/newpipe/RouterActivity.java @@ -234,7 +234,7 @@ public class RouterActivity extends AppCompatActivity { .setPositiveButton(R.string.open_in_browser, (dialog, which) -> ShareUtils.openUrlInBrowser(this, url)) .setNegativeButton(R.string.share, - (dialog, which) -> ShareUtils.shareText(this, "", url, "")) //no subject + (dialog, which) -> ShareUtils.shareText(this, "", url)) // no subject .setNeutralButton(R.string.cancel, null) .setOnDismissListener(dialog -> finish()) .show(); diff --git a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java index 0f9d6569c..c0d88c8ec 100644 --- a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java @@ -195,7 +195,8 @@ public class ErrorActivity extends AppCompatActivity { onBackPressed(); return true; case R.id.menu_item_share_error: - ShareUtils.shareText(this, getString(R.string.error_report_title), buildJson()); + ShareUtils.shareText(getApplicationContext(), + getString(R.string.error_report_title), buildJson()); return true; default: return false; diff --git a/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java b/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java index ff60126ec..b9f96746f 100644 --- a/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java @@ -259,6 +259,23 @@ public final class ShareUtils { openAppChooser(context, shareIntent, false); } + /** + * Open the android share sheet to share a content. + * + * For Android 10+ users, a content preview is shown, which includes the title of the shared + * content. + *

+ * This calls {@link #shareText(Context, String, String, String)} with an empty string for the + * imagePreviewUrl parameter. + * + * @param context the context to use + * @param title the title of the content + * @param content the content to share + */ + public static void shareText(final Context context, final String title, final String content) { + shareText(context, title, content, ""); + } + /** * Copy the text to clipboard, and indicate to the user whether the operation was completed * successfully using a Toast.