Merge branch 'fix-open-channel-url-in-browser' of https://github.com/coffeemakr/NewPipe into chan

This commit is contained in:
Christian Schabesberger 2017-11-02 20:36:31 +01:00
commit ff38ae202b
1 changed files with 31 additions and 10 deletions

View File

@ -26,7 +26,6 @@ import org.schabi.newpipe.R;
import org.schabi.newpipe.database.subscription.SubscriptionEntity; import org.schabi.newpipe.database.subscription.SubscriptionEntity;
import org.schabi.newpipe.extractor.ListExtractor; import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.UrlIdHandler;
import org.schabi.newpipe.extractor.channel.ChannelInfo; import org.schabi.newpipe.extractor.channel.ChannelInfo;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.fragments.list.BaseListInfoFragment; import org.schabi.newpipe.fragments.list.BaseListInfoFragment;
@ -34,7 +33,6 @@ import org.schabi.newpipe.fragments.subscription.SubscriptionService;
import org.schabi.newpipe.report.UserAction; import org.schabi.newpipe.report.UserAction;
import org.schabi.newpipe.util.AnimationUtils; import org.schabi.newpipe.util.AnimationUtils;
import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.ExtractorHelper;
import org.schabi.newpipe.util.KioskTranslator;
import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.Localization;
import java.util.List; import java.util.List;
@ -105,8 +103,7 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_channel, container, false); return inflater.inflate(R.layout.fragment_channel, container, false);
return v;
} }
@Override @Override
@ -153,19 +150,43 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
} }
} }
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 @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.menu_item_rss: { case R.id.menu_item_rss:
Intent intent = new Intent(); openRssFeed();
intent.setAction(Intent.ACTION_VIEW); break;
intent.setData(Uri.parse(currentInfo.feed_url)); case R.id.menu_item_openInBrowser:
startActivity(intent); openChannelUriInBrowser();
return true; break;
case R.id.menu_item_share: {
shareChannelUri();
break;
} }
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
return true;
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////