1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-25 01:20:34 +00:00

Merge pull request #1454 from Somethingweirdhere/dev

Added share option to long tap menu
This commit is contained in:
Christian Schabesberger 2018-06-25 15:28:37 +02:00 committed by GitHub
commit eae7babf93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 4 deletions

View File

@ -542,7 +542,8 @@ public class VideoDetailFragment
final String[] commands = new String[]{ final String[] commands = new String[]{
context.getResources().getString(R.string.enqueue_on_background), context.getResources().getString(R.string.enqueue_on_background),
context.getResources().getString(R.string.enqueue_on_popup), context.getResources().getString(R.string.enqueue_on_popup),
context.getResources().getString(R.string.append_playlist) context.getResources().getString(R.string.append_playlist),
context.getResources().getString(R.string.share)
}; };
final DialogInterface.OnClickListener actions = (DialogInterface dialogInterface, int i) -> { final DialogInterface.OnClickListener actions = (DialogInterface dialogInterface, int i) -> {
@ -559,6 +560,9 @@ public class VideoDetailFragment
.show(getFragmentManager(), TAG); .show(getFragmentManager(), TAG);
} }
break; break;
case 3:
shareUrl(item.getName(), item.getUrl());
break;
default: default:
break; break;
} }

View File

@ -196,7 +196,8 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
final String[] commands = new String[]{ final String[] commands = new String[]{
context.getResources().getString(R.string.enqueue_on_background), context.getResources().getString(R.string.enqueue_on_background),
context.getResources().getString(R.string.enqueue_on_popup), context.getResources().getString(R.string.enqueue_on_popup),
context.getResources().getString(R.string.append_playlist) context.getResources().getString(R.string.append_playlist),
context.getResources().getString(R.string.share)
}; };
final DialogInterface.OnClickListener actions = (dialogInterface, i) -> { final DialogInterface.OnClickListener actions = (dialogInterface, i) -> {
@ -213,6 +214,9 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
.show(getFragmentManager(), TAG); .show(getFragmentManager(), TAG);
} }
break; break;
case 3:
shareUrl(item.getName(), item.getUrl());
break;
default: default:
break; break;
} }

View File

@ -161,7 +161,8 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
context.getResources().getString(R.string.start_here_on_main), context.getResources().getString(R.string.start_here_on_main),
context.getResources().getString(R.string.start_here_on_background), context.getResources().getString(R.string.start_here_on_background),
context.getResources().getString(R.string.start_here_on_popup), context.getResources().getString(R.string.start_here_on_popup),
context.getResources().getString(R.string.append_playlist) context.getResources().getString(R.string.append_playlist),
context.getResources().getString(R.string.share)
}; };
final DialogInterface.OnClickListener actions = new DialogInterface.OnClickListener() { final DialogInterface.OnClickListener actions = new DialogInterface.OnClickListener() {
@ -190,6 +191,9 @@ public class ChannelFragment extends BaseListInfoFragment<ChannelInfo> {
.show(getFragmentManager(), TAG); .show(getFragmentManager(), TAG);
} }
break; break;
case 6:
shareUrl(item.getName(), item.getUrl());
break;
default: default:
break; break;
} }

View File

@ -144,6 +144,7 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
context.getResources().getString(R.string.start_here_on_main), context.getResources().getString(R.string.start_here_on_main),
context.getResources().getString(R.string.start_here_on_background), context.getResources().getString(R.string.start_here_on_background),
context.getResources().getString(R.string.start_here_on_popup), context.getResources().getString(R.string.start_here_on_popup),
context.getResources().getString(R.string.share)
}; };
final DialogInterface.OnClickListener actions = (dialogInterface, i) -> { final DialogInterface.OnClickListener actions = (dialogInterface, i) -> {
@ -164,6 +165,9 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
case 4: case 4:
NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index)); NavigationHelper.playOnPopupPlayer(activity, getPlayQueue(index));
break; break;
case 5:
shareUrl(item.getName(), item.getUrl());
break;
default: default:
break; break;
} }

View File

@ -298,6 +298,7 @@ public class StatisticsPlaylistFragment
context.getResources().getString(R.string.start_here_on_background), context.getResources().getString(R.string.start_here_on_background),
context.getResources().getString(R.string.start_here_on_popup), context.getResources().getString(R.string.start_here_on_popup),
context.getResources().getString(R.string.delete), context.getResources().getString(R.string.delete),
context.getResources().getString(R.string.share)
}; };
final DialogInterface.OnClickListener actions = (dialogInterface, i) -> { final DialogInterface.OnClickListener actions = (dialogInterface, i) -> {
@ -321,6 +322,9 @@ public class StatisticsPlaylistFragment
case 5: case 5:
deleteEntry(index); deleteEntry(index);
break; break;
case 6:
shareUrl(item.toStreamInfoItem().getName(), item.toStreamInfoItem().getUrl());
break;
default: default:
break; break;
} }

View File

@ -520,7 +520,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
context.getResources().getString(R.string.start_here_on_background), context.getResources().getString(R.string.start_here_on_background),
context.getResources().getString(R.string.start_here_on_popup), context.getResources().getString(R.string.start_here_on_popup),
context.getResources().getString(R.string.set_as_playlist_thumbnail), context.getResources().getString(R.string.set_as_playlist_thumbnail),
context.getResources().getString(R.string.delete) context.getResources().getString(R.string.delete),
context.getResources().getString(R.string.share)
}; };
final DialogInterface.OnClickListener actions = (dialogInterface, i) -> { final DialogInterface.OnClickListener actions = (dialogInterface, i) -> {
@ -549,6 +550,9 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
case 6: case 6:
deleteItem(item); deleteItem(item);
break; break;
case 7:
shareUrl(item.toStreamInfoItem().getName(), item.toStreamInfoItem().getUrl());
break;
default: default:
break; break;
} }

View File

@ -340,6 +340,13 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
return true; return true;
}); });
final MenuItem share = menu.getMenu().add(RECYCLER_ITEM_POPUP_MENU_GROUP_ID, /*pos=*/3,
Menu.NONE, R.string.share);
share.setOnMenuItemClickListener(menuItem -> {
shareUrl(item.getTitle(), item.getUrl());
return true;
});
menu.show(); menu.show();
} }
@ -509,6 +516,18 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
.show(getSupportFragmentManager(), getTag()); .show(getSupportFragmentManager(), getTag());
} }
////////////////////////////////////////////////////////////////////////////
// Share
////////////////////////////////////////////////////////////////////////////
private 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)));
}
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Binding Service Listener // Binding Service Listener
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////