Remove share utilities from BaseStateFragment

Replaced by ShareUtils
This commit is contained in:
Stypox 2019-04-06 20:17:04 +02:00
parent cb33f04bfc
commit aadc8168be
No known key found for this signature in database
GPG key ID: 4BDF1B40A49FDD23
8 changed files with 20 additions and 30 deletions

View file

@ -230,21 +230,4 @@ public abstract class BaseStateFragment<I> extends BaseFragment implements ViewC
ErrorActivity.reportError(getContext(), exception, MainActivity.class, rootView, ErrorActivity.reportError(getContext(), exception, MainActivity.class, rootView,
ErrorActivity.ErrorInfo.make(userAction, serviceName, request, errorId)); ErrorActivity.ErrorInfo.make(userAction, serviceName, request, errorId));
} }
/*//////////////////////////////////////////////////////////////////////////
// Utils
//////////////////////////////////////////////////////////////////////////*/
protected void openUrlInBrowser(String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(Intent.createChooser(intent, activity.getString(R.string.share_dialog_title)));
}
protected void shareUrl(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);
startActivity(Intent.createChooser(intent, getString(R.string.share_dialog_title)));
}
} }

View file

@ -86,6 +86,7 @@ import org.schabi.newpipe.util.ListHelper;
import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PermissionHelper; import org.schabi.newpipe.util.PermissionHelper;
import org.schabi.newpipe.util.ShareUtils;
import org.schabi.newpipe.util.StreamItemAdapter; import org.schabi.newpipe.util.StreamItemAdapter;
import org.schabi.newpipe.util.StreamItemAdapter.StreamSizeWrapper; import org.schabi.newpipe.util.StreamItemAdapter.StreamSizeWrapper;
@ -547,7 +548,7 @@ public class VideoDetailFragment
} }
break; break;
case 3: case 3:
shareUrl(item.getName(), item.getUrl()); ShareUtils.shareUrl(this.getContext(), item.getName(), item.getUrl());
break; break;
default: default:
break; break;
@ -636,13 +637,13 @@ public class VideoDetailFragment
switch (id) { switch (id) {
case R.id.menu_item_share: { case R.id.menu_item_share: {
if (currentInfo != null) { if (currentInfo != null) {
shareUrl(currentInfo.getName(), currentInfo.getOriginalUrl()); ShareUtils.shareUrl(this.getContext(), currentInfo.getName(), currentInfo.getOriginalUrl());
} }
return true; return true;
} }
case R.id.menu_item_openInBrowser: { case R.id.menu_item_openInBrowser: {
if (currentInfo != null) { if (currentInfo != null) {
openUrlInBrowser(currentInfo.getOriginalUrl()); ShareUtils.openUrlInBrowser(this.getContext(), currentInfo.getOriginalUrl());
} }
return true; return true;
} }

View file

@ -34,6 +34,7 @@ import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.OnClickGesture; import org.schabi.newpipe.util.OnClickGesture;
import org.schabi.newpipe.util.ShareUtils;
import org.schabi.newpipe.util.StateSaver; import org.schabi.newpipe.util.StateSaver;
import java.util.Collections; import java.util.Collections;
@ -280,7 +281,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
} }
break; break;
case 4: case 4:
shareUrl(item.getName(), item.getUrl()); ShareUtils.shareUrl(this.getContext(), item.getName(), item.getUrl());
break; break;
default: default:
break; break;

View file

@ -46,6 +46,7 @@ import org.schabi.newpipe.util.ExtractorHelper;
import org.schabi.newpipe.util.ImageDisplayConstants; import org.schabi.newpipe.util.ImageDisplayConstants;
import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.ShareUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -190,7 +191,7 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
} }
break; break;
case 6: case 6:
shareUrl(item.getName(), item.getUrl()); ShareUtils.shareUrl(this.getContext(), item.getName(), item.getUrl());
break; break;
default: default:
break; break;
@ -233,10 +234,10 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
openRssFeed(); openRssFeed();
break; break;
case R.id.menu_item_openInBrowser: case R.id.menu_item_openInBrowser:
openUrlInBrowser(currentInfo.getOriginalUrl()); ShareUtils.openUrlInBrowser(this.getContext(), currentInfo.getOriginalUrl());
break; break;
case R.id.menu_item_share: case R.id.menu_item_share:
shareUrl(name, currentInfo.getOriginalUrl()); ShareUtils.shareUrl(this.getContext(), name, currentInfo.getOriginalUrl());
break; break;
default: default:
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);

View file

@ -40,6 +40,7 @@ import org.schabi.newpipe.report.UserAction;
import org.schabi.newpipe.util.ExtractorHelper; import org.schabi.newpipe.util.ExtractorHelper;
import org.schabi.newpipe.util.ImageDisplayConstants; import org.schabi.newpipe.util.ImageDisplayConstants;
import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.ShareUtils;
import org.schabi.newpipe.util.ThemeHelper; import org.schabi.newpipe.util.ThemeHelper;
import java.util.ArrayList; import java.util.ArrayList;
@ -168,7 +169,7 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index)); NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index));
break; break;
case 5: case 5:
shareUrl(item.getName(), item.getUrl()); ShareUtils.shareUrl(this.getContext(), item.getName(), item.getUrl());
break; break;
default: default:
break; break;
@ -230,10 +231,10 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.menu_item_openInBrowser: case R.id.menu_item_openInBrowser:
openUrlInBrowser(url); ShareUtils.openUrlInBrowser(this.getContext(), url);
break; break;
case R.id.menu_item_share: case R.id.menu_item_share:
shareUrl(name, url); ShareUtils.shareUrl(this.getContext(), name, url);
break; break;
case R.id.menu_item_bookmark: case R.id.menu_item_bookmark:
onBookmarkClicked(); onBookmarkClicked();

View file

@ -34,6 +34,7 @@ import org.schabi.newpipe.report.UserAction;
import org.schabi.newpipe.settings.SettingsActivity; import org.schabi.newpipe.settings.SettingsActivity;
import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.OnClickGesture; import org.schabi.newpipe.util.OnClickGesture;
import org.schabi.newpipe.util.ShareUtils;
import org.schabi.newpipe.util.ThemeHelper; import org.schabi.newpipe.util.ThemeHelper;
import java.util.ArrayList; import java.util.ArrayList;
@ -394,7 +395,7 @@ public class StatisticsPlaylistFragment
deleteEntry(index); deleteEntry(index);
break; break;
case 6: case 6:
shareUrl(item.toStreamInfoItem().getName(), item.toStreamInfoItem().getUrl()); ShareUtils.shareUrl(this.getContext(), item.toStreamInfoItem().getName(), item.toStreamInfoItem().getUrl());
break; break;
default: default:
break; break;

View file

@ -34,6 +34,7 @@ import org.schabi.newpipe.report.UserAction;
import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.OnClickGesture; import org.schabi.newpipe.util.OnClickGesture;
import org.schabi.newpipe.util.ShareUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -555,7 +556,7 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
deleteItem(item); deleteItem(item);
break; break;
case 7: case 7:
shareUrl(item.toStreamInfoItem().getName(), item.toStreamInfoItem().getUrl()); ShareUtils.shareUrl(this.getContext(), item.toStreamInfoItem().getName(), item.toStreamInfoItem().getUrl());
break; break;
default: default:
break; break;

View file

@ -57,6 +57,7 @@ import org.schabi.newpipe.util.FilePickerActivityHelper;
import org.schabi.newpipe.util.NavigationHelper; import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.OnClickGesture; import org.schabi.newpipe.util.OnClickGesture;
import org.schabi.newpipe.util.ServiceHelper; import org.schabi.newpipe.util.ServiceHelper;
import org.schabi.newpipe.util.ShareUtils;
import org.schabi.newpipe.util.ThemeHelper; import org.schabi.newpipe.util.ThemeHelper;
import org.schabi.newpipe.views.CollapsibleView; import org.schabi.newpipe.views.CollapsibleView;
@ -425,7 +426,7 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
} }
private void shareChannel (ChannelInfoItem selectedItem) { private void shareChannel (ChannelInfoItem selectedItem) {
shareUrl(selectedItem.getName(), selectedItem.getUrl()); ShareUtils.shareUrl(this.getContext(), selectedItem.getName(), selectedItem.getUrl());
} }
@SuppressLint("CheckResult") @SuppressLint("CheckResult")