From cb33f04bfcd29fd05a5ee7f5ce1e4406a8f3cc57 Mon Sep 17 00:00:00 2001 From: Stypox Date: Sat, 6 Apr 2019 20:11:23 +0200 Subject: [PATCH] Add ShareUtils class to share videos or open urls in browser. --- .../org/schabi/newpipe/util/ShareUtils.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 app/src/main/java/org/schabi/newpipe/util/ShareUtils.java diff --git a/app/src/main/java/org/schabi/newpipe/util/ShareUtils.java b/app/src/main/java/org/schabi/newpipe/util/ShareUtils.java new file mode 100644 index 000000000..c5c78a726 --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/util/ShareUtils.java @@ -0,0 +1,22 @@ +package org.schabi.newpipe.util; + +import android.content.Context; +import android.content.Intent; +import android.net.Uri; + +import org.schabi.newpipe.R; + +public class ShareUtils { + public static void openUrlInBrowser(Context context, String url) { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + context.startActivity(Intent.createChooser(intent, context.getString(R.string.share_dialog_title))); + } + + public static void shareUrl(Context context, String subject, String url) { + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType("text/plain"); + intent.putExtra(Intent.EXTRA_SUBJECT, subject); + intent.putExtra(Intent.EXTRA_TEXT, url); + context.startActivity(Intent.createChooser(intent, context.getString(R.string.share_dialog_title))); + } +}