From 26d18c588e21ecbae41c1fae15c3aee9bf6e52f6 Mon Sep 17 00:00:00 2001 From: Coffeemakr Date: Tue, 31 Oct 2017 09:25:27 +0100 Subject: [PATCH 1/2] Implement channel menu (closes #759) --- .../fragments/list/channel/ChannelFragment.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index 61a97e847..1c0dd894e 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -36,6 +36,7 @@ import org.schabi.newpipe.util.AnimationUtils; import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.KioskTranslator; import org.schabi.newpipe.util.Localization; +import org.schabi.newpipe.util.NavigationHelper; import java.util.List; import java.util.concurrent.TimeUnit; @@ -157,12 +158,22 @@ public class ChannelFragment extends BaseListInfoFragment { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_item_rss: { - Intent intent = new Intent(); - intent.setAction(Intent.ACTION_VIEW); - intent.setData(Uri.parse(currentInfo.feed_url)); + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(currentInfo.feed_url)); startActivity(intent); return true; } + case R.id.menu_item_openInBrowser: { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(currentInfo.url)); + startActivity(intent); + return true; + } + case R.id.menu_item_share: { + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType("text/plain"); + intent.putExtra(Intent.EXTRA_TEXT, currentInfo.url); + startActivity(Intent.createChooser(intent, getString(R.string.share_dialog_title))); + return true; + } default: return super.onOptionsItemSelected(item); } From b52e48a355a2580d6032bb26c6ad71d16fd661db Mon Sep 17 00:00:00 2001 From: Coffeemakr Date: Wed, 1 Nov 2017 16:26:44 +0100 Subject: [PATCH 2/2] Use provided url instead of channelInfo --- .../list/channel/ChannelFragment.java | 50 +++++++++++-------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java index 1c0dd894e..64875b17f 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/list/channel/ChannelFragment.java @@ -26,7 +26,6 @@ import org.schabi.newpipe.R; import org.schabi.newpipe.database.subscription.SubscriptionEntity; import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.NewPipe; -import org.schabi.newpipe.extractor.UrlIdHandler; import org.schabi.newpipe.extractor.channel.ChannelInfo; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.fragments.list.BaseListInfoFragment; @@ -34,9 +33,7 @@ import org.schabi.newpipe.fragments.subscription.SubscriptionService; import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.util.AnimationUtils; import org.schabi.newpipe.util.ExtractorHelper; -import org.schabi.newpipe.util.KioskTranslator; import org.schabi.newpipe.util.Localization; -import org.schabi.newpipe.util.NavigationHelper; import java.util.List; import java.util.concurrent.TimeUnit; @@ -106,8 +103,7 @@ public class ChannelFragment extends BaseListInfoFragment { @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { - View v = inflater.inflate(R.layout.fragment_channel, container, false); - return v; + return inflater.inflate(R.layout.fragment_channel, container, false); } @Override @@ -154,29 +150,43 @@ public class ChannelFragment extends BaseListInfoFragment { } } + private void openRssFeed() { + final ChannelInfo info = currentInfo; + if(info != null) { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(info.feed_url)); + startActivity(intent); + } + } + + private void openChannelUriInBrowser() { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + startActivity(intent); + } + + private void shareChannelUri() { + Intent intent = new Intent(Intent.ACTION_SEND); + intent.setType("text/plain"); + intent.putExtra(Intent.EXTRA_TEXT, url); + startActivity(Intent.createChooser(intent, getString(R.string.share_dialog_title))); + } + @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case R.id.menu_item_rss: { - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(currentInfo.feed_url)); - startActivity(intent); - return true; - } - case R.id.menu_item_openInBrowser: { - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(currentInfo.url)); - startActivity(intent); - return true; - } + case R.id.menu_item_rss: + openRssFeed(); + break; + case R.id.menu_item_openInBrowser: + openChannelUriInBrowser(); + break; case R.id.menu_item_share: { - Intent intent = new Intent(Intent.ACTION_SEND); - intent.setType("text/plain"); - intent.putExtra(Intent.EXTRA_TEXT, currentInfo.url); - startActivity(Intent.createChooser(intent, getString(R.string.share_dialog_title))); - return true; + shareChannelUri(); + break; } default: return super.onOptionsItemSelected(item); } + return true; } /*//////////////////////////////////////////////////////////////////////////