1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-24 00:50:32 +00:00

-Added dropdown to start play for all StreamInfoItem.

-Refactored NavigationHelper to allow service player control to open anywhere.
-Refactored NavigationHelper to allow starting player at anywhere.
This commit is contained in:
John Zhen Mo 2017-11-01 22:33:13 -07:00
parent 38b2ffd450
commit 87febf8679
25 changed files with 240 additions and 48 deletions

View File

@ -36,6 +36,7 @@ import android.widget.FrameLayout;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.PopupMenu;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
@ -459,6 +460,9 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
public void selected(StreamInfoItem selectedItem) { public void selected(StreamInfoItem selectedItem) {
selectAndLoadVideo(selectedItem.service_id, selectedItem.url, selectedItem.name); selectAndLoadVideo(selectedItem.service_id, selectedItem.url, selectedItem.name);
} }
@Override
public void dropdownClicked(StreamInfoItem selectedItem, PopupMenu menu) {}
}); });
videoTitleRoot.setOnClickListener(this); videoTitleRoot.setOnClickListener(this);
@ -792,16 +796,12 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
((HistoryListener) activity).onVideoPlayed(currentInfo, getSelectedVideoStream()); ((HistoryListener) activity).onVideoPlayed(currentInfo, getSelectedVideoStream());
} }
final PlayQueue playQueue = new SinglePlayQueue(currentInfo); final PlayQueue itemQueue = new SinglePlayQueue(currentInfo);
final Intent intent;
if (append) { if (append) {
Toast.makeText(activity, R.string.popup_playing_append, Toast.LENGTH_SHORT).show(); NavigationHelper.enqueueOnPopupPlayer(activity, itemQueue);
intent = NavigationHelper.getPlayerEnqueueIntent(activity, PopupVideoPlayer.class, playQueue);
} else { } else {
Toast.makeText(activity, R.string.popup_playing_toast, Toast.LENGTH_SHORT).show(); NavigationHelper.playOnPopupPlayer(activity, itemQueue);
intent = NavigationHelper.getPlayerIntent(activity, PopupVideoPlayer.class, playQueue, getSelectedVideoStream().resolution);
} }
activity.startService(intent);
} }
private void openVideoPlayer() { private void openVideoPlayer() {
@ -820,13 +820,11 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
private void openNormalBackgroundPlayer(final boolean append) { private void openNormalBackgroundPlayer(final boolean append) {
final PlayQueue playQueue = new SinglePlayQueue(currentInfo); final PlayQueue itemQueue = new SinglePlayQueue(currentInfo);
if (append) { if (append) {
activity.startService(NavigationHelper.getPlayerEnqueueIntent(activity, BackgroundPlayer.class, playQueue)); NavigationHelper.enqueueOnBackgroundPlayer(activity, itemQueue);
Toast.makeText(activity, R.string.background_player_append, Toast.LENGTH_SHORT).show();
} else { } else {
activity.startService(NavigationHelper.getPlayerIntent(activity, BackgroundPlayer.class, playQueue)); NavigationHelper.playOnBackgroundPlayer(activity, itemQueue);
Toast.makeText(activity, R.string.background_player_playing_toast, Toast.LENGTH_SHORT).show();
} }
} }
@ -865,22 +863,20 @@ public class VideoDetailFragment extends BaseStateFragment<StreamInfo> implement
} }
private void openNormalPlayer(VideoStream selectedVideoStream) { private void openNormalPlayer(VideoStream selectedVideoStream) {
Intent mIntent;
boolean useOldPlayer = PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(getString(R.string.use_old_player_key), false) boolean useOldPlayer = PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(getString(R.string.use_old_player_key), false)
|| (Build.VERSION.SDK_INT < 16); || (Build.VERSION.SDK_INT < 16);
if (!useOldPlayer) { if (!useOldPlayer) {
// ExoPlayer // ExoPlayer
final PlayQueue playQueue = new SinglePlayQueue(currentInfo); NavigationHelper.playOnMainPlayer(activity, new SinglePlayQueue(currentInfo));
mIntent = NavigationHelper.getPlayerIntent(activity, MainVideoPlayer.class, playQueue, getSelectedVideoStream().resolution);
} else { } else {
// Internal Player // Internal Player
mIntent = new Intent(activity, PlayVideoActivity.class) final Intent mIntent = new Intent(activity, PlayVideoActivity.class)
.putExtra(PlayVideoActivity.VIDEO_TITLE, currentInfo.name) .putExtra(PlayVideoActivity.VIDEO_TITLE, currentInfo.name)
.putExtra(PlayVideoActivity.STREAM_URL, selectedVideoStream.url) .putExtra(PlayVideoActivity.STREAM_URL, selectedVideoStream.url)
.putExtra(PlayVideoActivity.VIDEO_URL, currentInfo.url) .putExtra(PlayVideoActivity.VIDEO_URL, currentInfo.url)
.putExtra(PlayVideoActivity.START_POSITION, currentInfo.start_position); .putExtra(PlayVideoActivity.START_POSITION, currentInfo.start_position);
startActivity(mIntent);
} }
startActivity(mIntent);
} }
private void openExternalVideoPlayer(VideoStream selectedVideoStream) { private void openExternalVideoPlayer(VideoStream selectedVideoStream) {

View File

@ -10,6 +10,7 @@ import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.View; import android.view.View;
import android.widget.PopupMenu;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
@ -139,6 +140,9 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
useAsFrontPage?getParentFragment().getFragmentManager():getFragmentManager(), useAsFrontPage?getParentFragment().getFragmentManager():getFragmentManager(),
selectedItem.service_id, selectedItem.url, selectedItem.name); selectedItem.service_id, selectedItem.url, selectedItem.name);
} }
@Override
public void dropdownClicked(StreamInfoItem selectedItem, PopupMenu menu) {}
}); });
infoListAdapter.setOnChannelSelectedListener(new InfoItemBuilder.OnInfoItemSelectedListener<ChannelInfoItem>() { infoListAdapter.setOnChannelSelectedListener(new InfoItemBuilder.OnInfoItemSelectedListener<ChannelInfoItem>() {
@ -149,6 +153,9 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
useAsFrontPage?getParentFragment().getFragmentManager():getFragmentManager(), useAsFrontPage?getParentFragment().getFragmentManager():getFragmentManager(),
selectedItem.service_id, selectedItem.url, selectedItem.name); selectedItem.service_id, selectedItem.url, selectedItem.name);
} }
@Override
public void dropdownClicked(ChannelInfoItem selectedItem, PopupMenu menu) {}
}); });
infoListAdapter.setOnPlaylistSelectedListener(new InfoItemBuilder.OnInfoItemSelectedListener<PlaylistInfoItem>() { infoListAdapter.setOnPlaylistSelectedListener(new InfoItemBuilder.OnInfoItemSelectedListener<PlaylistInfoItem>() {
@ -159,6 +166,9 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I> implem
useAsFrontPage?getParentFragment().getFragmentManager():getFragmentManager(), useAsFrontPage?getParentFragment().getFragmentManager():getFragmentManager(),
selectedItem.service_id, selectedItem.url, selectedItem.name); selectedItem.service_id, selectedItem.url, selectedItem.name);
} }
@Override
public void dropdownClicked(PlaylistInfoItem selectedItem, PopupMenu menu) {}
}); });
itemsList.clearOnScrollListeners(); itemsList.clearOnScrollListeners();

View File

@ -160,7 +160,7 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
headerPlayAllButton.setOnClickListener(new View.OnClickListener() { headerPlayAllButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
startActivity(buildPlaylistIntent(MainVideoPlayer.class)); NavigationHelper.playOnMainPlayer(activity, getPlayQueue());
} }
}); });
headerPopupButton.setOnClickListener(new View.OnClickListener() { headerPopupButton.setOnClickListener(new View.OnClickListener() {
@ -173,26 +173,25 @@ public class PlaylistFragment extends BaseListInfoFragment<PlaylistInfo> {
toast.show(); toast.show();
return; return;
} }
activity.startService(buildPlaylistIntent(PopupVideoPlayer.class)); NavigationHelper.playOnPopupPlayer(activity, getPlayQueue());
} }
}); });
headerBackgroundButton.setOnClickListener(new View.OnClickListener() { headerBackgroundButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
activity.startService(buildPlaylistIntent(BackgroundPlayer.class)); NavigationHelper.playOnBackgroundPlayer(activity, getPlayQueue());
} }
}); });
} }
private Intent buildPlaylistIntent(final Class targetClazz) { private PlayQueue getPlayQueue() {
final PlayQueue playQueue = new ExternalPlayQueue( return new ExternalPlayQueue(
currentInfo.service_id, currentInfo.service_id,
currentInfo.url, currentInfo.url,
currentInfo.next_streams_url, currentInfo.next_streams_url,
infoListAdapter.getItemsList(), infoListAdapter.getItemsList(),
0 0
); );
return NavigationHelper.getPlayerIntent(activity, targetClazz, playQueue);
} }
@Override @Override

View File

@ -10,6 +10,7 @@ import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.PopupMenu;
import org.schabi.newpipe.R; import org.schabi.newpipe.R;
import org.schabi.newpipe.database.subscription.SubscriptionEntity; import org.schabi.newpipe.database.subscription.SubscriptionEntity;
@ -134,6 +135,9 @@ public class SubscriptionFragment extends BaseStateFragment<List<SubscriptionEnt
NavigationHelper.openChannelFragment(getParentFragment().getFragmentManager(), selectedItem.service_id, selectedItem.url, selectedItem.name); NavigationHelper.openChannelFragment(getParentFragment().getFragmentManager(), selectedItem.service_id, selectedItem.url, selectedItem.name);
} }
@Override
public void dropdownClicked(ChannelInfoItem selectedItem, PopupMenu menu) {}
}); });
headerRootLayout.setOnClickListener(new View.OnClickListener() { headerRootLayout.setOnClickListener(new View.OnClickListener() {

View File

@ -5,6 +5,7 @@ import android.support.annotation.NonNull;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.PopupMenu;
import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.ImageLoader;
@ -44,6 +45,7 @@ public class InfoItemBuilder {
public interface OnInfoItemSelectedListener<T extends InfoItem> { public interface OnInfoItemSelectedListener<T extends InfoItem> {
void selected(T selectedItem); void selected(T selectedItem);
void dropdownClicked(T selectedItem, PopupMenu menu);
} }
private final Context context; private final Context context;

View File

@ -1,10 +1,16 @@
package org.schabi.newpipe.info_list.holder; package org.schabi.newpipe.info_list.holder;
import android.content.Context;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.PopupMenu;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.DisplayImageOptions;
@ -13,7 +19,12 @@ import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamType; import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.info_list.InfoItemBuilder; import org.schabi.newpipe.info_list.InfoItemBuilder;
import org.schabi.newpipe.player.BackgroundPlayer;
import org.schabi.newpipe.player.PopupVideoPlayer;
import org.schabi.newpipe.playlist.PlayQueue;
import org.schabi.newpipe.playlist.SinglePlayQueue;
import org.schabi.newpipe.util.Localization; import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.NavigationHelper;
public class StreamMiniInfoItemHolder extends InfoItemHolder { public class StreamMiniInfoItemHolder extends InfoItemHolder {
@ -21,6 +32,7 @@ public class StreamMiniInfoItemHolder extends InfoItemHolder {
public final TextView itemVideoTitleView; public final TextView itemVideoTitleView;
public final TextView itemUploaderView; public final TextView itemUploaderView;
public final TextView itemDurationView; public final TextView itemDurationView;
public final ImageButton itemActionDropdown;
StreamMiniInfoItemHolder(InfoItemBuilder infoItemBuilder, int layoutId, ViewGroup parent) { StreamMiniInfoItemHolder(InfoItemBuilder infoItemBuilder, int layoutId, ViewGroup parent) {
super(infoItemBuilder, layoutId, parent); super(infoItemBuilder, layoutId, parent);
@ -29,6 +41,7 @@ public class StreamMiniInfoItemHolder extends InfoItemHolder {
itemVideoTitleView = itemView.findViewById(R.id.itemVideoTitleView); itemVideoTitleView = itemView.findViewById(R.id.itemVideoTitleView);
itemUploaderView = itemView.findViewById(R.id.itemUploaderView); itemUploaderView = itemView.findViewById(R.id.itemUploaderView);
itemDurationView = itemView.findViewById(R.id.itemDurationView); itemDurationView = itemView.findViewById(R.id.itemDurationView);
itemActionDropdown = itemView.findViewById(R.id.itemActionDropdown);
} }
public StreamMiniInfoItemHolder(InfoItemBuilder infoItemBuilder, ViewGroup parent) { public StreamMiniInfoItemHolder(InfoItemBuilder infoItemBuilder, ViewGroup parent) {
@ -67,6 +80,84 @@ public class StreamMiniInfoItemHolder extends InfoItemHolder {
} }
} }
}); });
switch (item.stream_type) {
case AUDIO_STREAM:
case VIDEO_STREAM:
case FILE:
enableActionDropdown(item);
break;
case LIVE_STREAM:
case AUDIO_LIVE_STREAM:
case NONE:
default:
break;
}
}
private void enableActionDropdown(final StreamInfoItem item) {
itemActionDropdown.setVisibility(View.VISIBLE);
itemActionDropdown.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final PopupMenu actionMenu = getStreamDropdown(itemBuilder.getContext(), itemActionDropdown, item);
if (itemBuilder.getOnStreamSelectedListener() != null) {
itemBuilder.getOnStreamSelectedListener().dropdownClicked(item, actionMenu);
}
actionMenu.show();
}
});
}
private PopupMenu getStreamDropdown(final Context context, final View anchor, final StreamInfoItem infoItem) {
PopupMenu actionMenu = new PopupMenu(context, anchor);
final MenuItem mainPlay = actionMenu.getMenu().add(R.string.play_btn_text);
mainPlay.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
NavigationHelper.playOnMainPlayer(context, new SinglePlayQueue(infoItem));
return true;
}
});
final MenuItem popupPlay = actionMenu.getMenu().add(R.string.controls_popup_title);
popupPlay.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
NavigationHelper.playOnPopupPlayer(context, new SinglePlayQueue(infoItem));
return true;
}
});
final MenuItem backgroundPlay = actionMenu.getMenu().add(R.string.controls_background_title);
backgroundPlay.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
NavigationHelper.playOnBackgroundPlayer(context, new SinglePlayQueue(infoItem));
return true;
}
});
final MenuItem backgroundEnqueue = actionMenu.getMenu().add(R.string.enqueue_on_background);
backgroundEnqueue.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
NavigationHelper.enqueueOnBackgroundPlayer(context, new SinglePlayQueue(infoItem));
return true;
}
});
final MenuItem popupEnqueue = actionMenu.getMenu().add(R.string.enqueue_on_popup);
popupEnqueue.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
NavigationHelper.enqueueOnPopupPlayer(context, new SinglePlayQueue(infoItem));
return true;
}
});
return actionMenu;
} }
/** /**

View File

@ -48,6 +48,7 @@ import org.schabi.newpipe.player.event.PlayerEventListener;
import org.schabi.newpipe.player.helper.LockManager; import org.schabi.newpipe.player.helper.LockManager;
import org.schabi.newpipe.playlist.PlayQueueItem; import org.schabi.newpipe.playlist.PlayQueueItem;
import org.schabi.newpipe.util.ListHelper; import org.schabi.newpipe.util.ListHelper;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.ThemeHelper; import org.schabi.newpipe.util.ThemeHelper;
import static org.schabi.newpipe.player.helper.PlayerHelper.getTimeString; import static org.schabi.newpipe.player.helper.PlayerHelper.getTimeString;
@ -130,16 +131,6 @@ public final class BackgroundPlayer extends Service {
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
// Actions // Actions
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
public void openControl(final Context context) {
Intent intent = new Intent(context, BackgroundPlayerActivity.class);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
context.startActivity(intent);
context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
}
private void onClose() { private void onClose() {
if (DEBUG) Log.d(TAG, "onClose() called"); if (DEBUG) Log.d(TAG, "onClose() called");
@ -470,7 +461,7 @@ public final class BackgroundPlayer extends Service {
onVideoPlayPause(); onVideoPlayPause();
break; break;
case ACTION_OPEN_CONTROLS: case ACTION_OPEN_CONTROLS:
openControl(getApplicationContext()); NavigationHelper.openBackgroundPlayerControl(getApplicationContext());
break; break;
case ACTION_REPEAT: case ACTION_REPEAT:
onRepeatClicked(); onRepeatClicked();

View File

@ -318,15 +318,6 @@ public final class PopupVideoPlayer extends Service {
stopSelf(); stopSelf();
} }
public void openControl(final Context context) {
Intent intent = new Intent(context, PopupVideoPlayerActivity.class);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
context.startActivity(intent);
context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
}
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
// Utils // Utils
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
@ -622,7 +613,7 @@ public final class PopupVideoPlayer extends Service {
onVideoPlayPause(); onVideoPlayPause();
break; break;
case ACTION_OPEN_CONTROLS: case ACTION_OPEN_CONTROLS:
openControl(getApplicationContext()); NavigationHelper.openPopupPlayerControl(getApplicationContext());
break; break;
case ACTION_REPEAT: case ACTION_REPEAT:
onRepeatClicked(); onRepeatClicked();

View File

@ -1,12 +1,21 @@
package org.schabi.newpipe.playlist; package org.schabi.newpipe.playlist;
import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import java.util.Collections; import java.util.Collections;
public final class SinglePlayQueue extends PlayQueue { public final class SinglePlayQueue extends PlayQueue {
public SinglePlayQueue(final StreamInfoItem item) {
this(new PlayQueueItem(item));
}
public SinglePlayQueue(final StreamInfo info) { public SinglePlayQueue(final StreamInfo info) {
super(0, Collections.singletonList(new PlayQueueItem(info))); this(new PlayQueueItem(info));
}
private SinglePlayQueue(final PlayQueueItem playQueueItem) {
super(0, Collections.singletonList(playQueueItem));
} }
@Override @Override

View File

@ -5,10 +5,11 @@ import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity; import android.widget.Toast;
import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.ImageLoader;
@ -28,7 +29,12 @@ import org.schabi.newpipe.fragments.list.kiosk.KioskFragment;
import org.schabi.newpipe.fragments.list.playlist.PlaylistFragment; import org.schabi.newpipe.fragments.list.playlist.PlaylistFragment;
import org.schabi.newpipe.fragments.list.search.SearchFragment; import org.schabi.newpipe.fragments.list.search.SearchFragment;
import org.schabi.newpipe.history.HistoryActivity; import org.schabi.newpipe.history.HistoryActivity;
import org.schabi.newpipe.player.BackgroundPlayer;
import org.schabi.newpipe.player.BackgroundPlayerActivity;
import org.schabi.newpipe.player.BasePlayer; import org.schabi.newpipe.player.BasePlayer;
import org.schabi.newpipe.player.MainVideoPlayer;
import org.schabi.newpipe.player.PopupVideoPlayer;
import org.schabi.newpipe.player.PopupVideoPlayerActivity;
import org.schabi.newpipe.player.VideoPlayer; import org.schabi.newpipe.player.VideoPlayer;
import org.schabi.newpipe.playlist.PlayQueue; import org.schabi.newpipe.playlist.PlayQueue;
import org.schabi.newpipe.settings.SettingsActivity; import org.schabi.newpipe.settings.SettingsActivity;
@ -77,6 +83,29 @@ public class NavigationHelper {
.putExtra(BasePlayer.PLAYBACK_PITCH, playbackPitch); .putExtra(BasePlayer.PLAYBACK_PITCH, playbackPitch);
} }
public static void playOnMainPlayer(final Context context, final PlayQueue queue) {
context.startActivity(getPlayerIntent(context, MainVideoPlayer.class, queue));
}
public static void playOnPopupPlayer(final Context context, final PlayQueue queue) {
Toast.makeText(context, R.string.popup_playing_toast, Toast.LENGTH_SHORT).show();
context.startService(getPlayerIntent(context, PopupVideoPlayer.class, queue));
}
public static void playOnBackgroundPlayer(final Context context, final PlayQueue queue) {
Toast.makeText(context, R.string.background_player_playing_toast, Toast.LENGTH_SHORT).show();
context.startService(getPlayerIntent(context, BackgroundPlayer.class, queue));
}
public static void enqueueOnPopupPlayer(final Context context, final PlayQueue queue) {
Toast.makeText(context, R.string.popup_playing_append, Toast.LENGTH_SHORT).show();
context.startService(getPlayerEnqueueIntent(context, PopupVideoPlayer.class, queue));
}
public static void enqueueOnBackgroundPlayer(final Context context, final PlayQueue queue) {
Toast.makeText(context, R.string.background_player_append, Toast.LENGTH_SHORT).show();
context.startService(getPlayerEnqueueIntent(context, BackgroundPlayer.class, queue));
}
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
// Through FragmentManager // Through FragmentManager
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
@ -230,6 +259,23 @@ public class NavigationHelper {
return true; return true;
} }
public static void openBackgroundPlayerControl(final Context context) {
openServicePlayerControl(context, BackgroundPlayerActivity.class);
}
public static void openPopupPlayerControl(final Context context) {
openServicePlayerControl(context, PopupVideoPlayerActivity.class);
}
private static void openServicePlayerControl(final Context context, final Class clazz) {
final Intent intent = new Intent(context, clazz);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
context.startActivity(intent);
context.sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
}
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
// Link handling // Link handling
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 216 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

View File

@ -7,7 +7,9 @@
android:layout_height="@dimen/video_item_search_height" android:layout_height="@dimen/video_item_search_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:clickable="true" android:clickable="true"
android:padding="@dimen/video_item_search_padding"> android:focusable="true"
android:paddingTop="@dimen/video_item_search_padding"
android:paddingBottom="@dimen/video_item_search_padding">
<ImageView <ImageView
android:id="@+id/itemThumbnailView" android:id="@+id/itemThumbnailView"
@ -16,6 +18,7 @@
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_marginLeft="@dimen/video_item_search_padding"
android:layout_marginRight="@dimen/video_item_search_image_right_margin" android:layout_marginRight="@dimen/video_item_search_image_right_margin"
android:contentDescription="@string/list_thumbnail_view_description" android:contentDescription="@string/list_thumbnail_view_description"
android:scaleType="centerCrop" android:scaleType="centerCrop"
@ -42,12 +45,30 @@
tools:ignore="RtlHardcoded" tools:ignore="RtlHardcoded"
tools:text="1:09:10"/> tools:text="1:09:10"/>
<ImageButton
android:id="@+id/itemActionDropdown"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginLeft="@dimen/video_item_search_image_right_margin"
android:layout_marginStart="@dimen/video_item_search_image_right_margin"
android:background="?attr/selectableItemBackground"
android:src="?attr/more_vertical"
android:visibility="gone"
tools:visibility="visible"
tools:ignore="ContentDescription"/>
<TextView <TextView
android:id="@+id/itemVideoTitleView" android:id="@+id/itemVideoTitleView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_toLeftOf="@id/itemActionDropdown"
android:layout_toStartOf="@id/itemActionDropdown"
android:layout_toRightOf="@+id/itemThumbnailView" android:layout_toRightOf="@+id/itemThumbnailView"
android:layout_toEndOf="@+id/itemThumbnailView"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"
@ -59,7 +80,10 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/itemVideoTitleView" android:layout_below="@+id/itemVideoTitleView"
android:layout_toLeftOf="@id/itemActionDropdown"
android:layout_toStartOf="@id/itemActionDropdown"
android:layout_toRightOf="@+id/itemThumbnailView" android:layout_toRightOf="@+id/itemThumbnailView"
android:layout_toEndOf="@+id/itemThumbnailView"
android:lines="1" android:lines="1"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="@dimen/video_item_search_uploader_text_size" android:textSize="@dimen/video_item_search_uploader_text_size"
@ -70,7 +94,10 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:layout_toLeftOf="@id/itemActionDropdown"
android:layout_toStartOf="@id/itemActionDropdown"
android:layout_toRightOf="@+id/itemThumbnailView" android:layout_toRightOf="@+id/itemThumbnailView"
android:layout_toEndOf="@+id/itemThumbnailView"
android:lines="1" android:lines="1"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="@dimen/video_item_search_upload_date_text_size" android:textSize="@dimen/video_item_search_upload_date_text_size"

View File

@ -7,7 +7,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:clickable="true" android:clickable="true"
android:padding="@dimen/video_item_search_padding"> android:focusable="true"
android:paddingTop="@dimen/video_item_search_padding"
android:paddingBottom="@dimen/video_item_search_padding">
<ImageView <ImageView
android:id="@+id/itemThumbnailView" android:id="@+id/itemThumbnailView"
@ -16,6 +18,7 @@
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_marginLeft="@dimen/video_item_search_padding"
android:layout_marginRight="@dimen/video_item_search_image_right_margin" android:layout_marginRight="@dimen/video_item_search_image_right_margin"
android:contentDescription="@string/list_thumbnail_view_description" android:contentDescription="@string/list_thumbnail_view_description"
android:scaleType="centerCrop" android:scaleType="centerCrop"
@ -41,13 +44,28 @@
tools:ignore="RtlHardcoded" tools:ignore="RtlHardcoded"
tools:text="1:09:10"/> tools:text="1:09:10"/>
<ImageButton
android:id="@+id/itemActionDropdown"
android:layout_width="wrap_content"
android:layout_height="55dp"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="?attr/selectableItemBackground"
android:src="?attr/more_vertical"
android:visibility="gone"
tools:visibility="visible"
tools:ignore="ContentDescription"/>
<TextView <TextView
android:id="@+id/itemVideoTitleView" android:id="@+id/itemVideoTitleView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_toLeftOf="@id/itemActionDropdown"
android:layout_toStartOf="@id/itemActionDropdown"
android:layout_toRightOf="@+id/itemThumbnailView" android:layout_toRightOf="@+id/itemThumbnailView"
android:layout_toEndOf="@+id/itemThumbnailView"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" android:maxLines="2"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"
@ -59,7 +77,10 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/itemVideoTitleView" android:layout_below="@+id/itemVideoTitleView"
android:layout_toLeftOf="@id/itemActionDropdown"
android:layout_toStartOf="@id/itemActionDropdown"
android:layout_toRightOf="@+id/itemThumbnailView" android:layout_toRightOf="@+id/itemThumbnailView"
android:layout_toEndOf="@+id/itemThumbnailView"
android:lines="1" android:lines="1"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="@dimen/video_item_search_uploader_text_size" android:textSize="@dimen/video_item_search_uploader_text_size"

View File

@ -20,6 +20,7 @@
<attr name="history" format="reference"/> <attr name="history" format="reference"/>
<attr name="drag_handle" format="reference"/> <attr name="drag_handle" format="reference"/>
<attr name="selected" format="reference"/> <attr name="selected" format="reference"/>
<attr name="more_vertical" format="reference"/>
<!-- Can't refer to colors directly into drawable's xml--> <!-- Can't refer to colors directly into drawable's xml-->
<attr name="toolbar_shadow_drawable" format="reference"/> <attr name="toolbar_shadow_drawable" format="reference"/>

View File

@ -310,4 +310,6 @@
<string name="play_queue_stream_detail">Details</string> <string name="play_queue_stream_detail">Details</string>
<string name="play_queue_audio_settings">Audio Settings</string> <string name="play_queue_audio_settings">Audio Settings</string>
<string name="hold_to_append">Hold To Enqueue</string> <string name="hold_to_append">Hold To Enqueue</string>
<string name="enqueue_on_background">Enqueue on Background</string>
<string name="enqueue_on_popup">Enqueue on Popup</string>
</resources> </resources>

View File

@ -27,6 +27,7 @@
<item name="history">@drawable/ic_history_black_24dp</item> <item name="history">@drawable/ic_history_black_24dp</item>
<item name="drag_handle">@drawable/ic_drag_handle_black_24dp</item> <item name="drag_handle">@drawable/ic_drag_handle_black_24dp</item>
<item name="selected">@drawable/ic_fiber_manual_record_black_24dp</item> <item name="selected">@drawable/ic_fiber_manual_record_black_24dp</item>
<item name="more_vertical">@drawable/ic_more_vert_black_24dp</item>
<item name="separator_color">@color/light_separator_color</item> <item name="separator_color">@color/light_separator_color</item>
<item name="contrast_background_color">@color/light_contrast_background_color</item> <item name="contrast_background_color">@color/light_contrast_background_color</item>
@ -65,6 +66,7 @@
<item name="history">@drawable/ic_history_white_24dp</item> <item name="history">@drawable/ic_history_white_24dp</item>
<item name="drag_handle">@drawable/ic_drag_handle_white_24dp</item> <item name="drag_handle">@drawable/ic_drag_handle_white_24dp</item>
<item name="selected">@drawable/ic_fiber_manual_record_white_24dp</item> <item name="selected">@drawable/ic_fiber_manual_record_white_24dp</item>
<item name="more_vertical">@drawable/ic_more_vert_white_24dp</item>
<item name="separator_color">@color/dark_separator_color</item> <item name="separator_color">@color/dark_separator_color</item>
<item name="contrast_background_color">@color/dark_contrast_background_color</item> <item name="contrast_background_color">@color/dark_contrast_background_color</item>