mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
Merge and rename into PlayQueueActivity
This commit is contained in:
parent
cece83328a
commit
059bb7622d
@ -53,7 +53,7 @@
|
|||||||
</service>
|
</service>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".player.BackgroundPlayerActivity"
|
android:name=".player.PlayQueueActivity"
|
||||||
android:label="@string/title_activity_play_queue"
|
android:label="@string/title_activity_play_queue"
|
||||||
android:launchMode="singleTask" />
|
android:launchMode="singleTask" />
|
||||||
|
|
||||||
|
@ -1,55 +0,0 @@
|
|||||||
package org.schabi.newpipe.player;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.view.Menu;
|
|
||||||
|
|
||||||
import org.schabi.newpipe.R;
|
|
||||||
|
|
||||||
public final class BackgroundPlayerActivity extends ServicePlayerActivity {
|
|
||||||
|
|
||||||
private static final String TAG = "BackgroundPlayerActivity";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getTag() {
|
|
||||||
return TAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSupportActionTitle() {
|
|
||||||
return getResources().getString(R.string.title_activity_play_queue);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Intent getBindIntent() {
|
|
||||||
return new Intent(this, MainPlayer.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void startPlayerListener() {
|
|
||||||
if (player != null) {
|
|
||||||
player.setActivityListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stopPlayerListener() {
|
|
||||||
if (player != null) {
|
|
||||||
player.removeActivityListener(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getPlayerOptionMenuResource() {
|
|
||||||
return R.menu.menu_play_queue_bg;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setupMenu(final Menu menu) {
|
|
||||||
if (player != null) {
|
|
||||||
menu.findItem(R.id.action_switch_popup)
|
|
||||||
.setVisible(!player.popupPlayerSelected());
|
|
||||||
menu.findItem(R.id.action_switch_background)
|
|
||||||
.setVisible(!player.audioPlayerSelected());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,7 +16,6 @@ import android.widget.PopupMenu;
|
|||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import androidx.recyclerview.widget.ItemTouchHelper;
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
@ -48,9 +47,12 @@ import java.util.List;
|
|||||||
import static org.schabi.newpipe.player.helper.PlayerHelper.formatSpeed;
|
import static org.schabi.newpipe.player.helper.PlayerHelper.formatSpeed;
|
||||||
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
||||||
|
|
||||||
public abstract class ServicePlayerActivity extends AppCompatActivity
|
public final class PlayQueueActivity extends AppCompatActivity
|
||||||
implements PlayerEventListener, SeekBar.OnSeekBarChangeListener,
|
implements PlayerEventListener, SeekBar.OnSeekBarChangeListener,
|
||||||
View.OnClickListener, PlaybackParameterDialog.Callback {
|
View.OnClickListener, PlaybackParameterDialog.Callback {
|
||||||
|
|
||||||
|
private static final String TAG = PlayQueueActivity.class.getSimpleName();
|
||||||
|
|
||||||
private static final int RECYCLER_ITEM_POPUP_MENU_GROUP_ID = 47;
|
private static final int RECYCLER_ITEM_POPUP_MENU_GROUP_ID = 47;
|
||||||
private static final int SMOOTH_SCROLL_MAXIMUM_DISTANCE = 80;
|
private static final int SMOOTH_SCROLL_MAXIMUM_DISTANCE = 80;
|
||||||
|
|
||||||
@ -60,7 +62,6 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||||||
private ServiceConnection serviceConnection;
|
private ServiceConnection serviceConnection;
|
||||||
|
|
||||||
private boolean seeking;
|
private boolean seeking;
|
||||||
private boolean redraw;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// Views
|
// Views
|
||||||
@ -72,24 +73,6 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||||||
|
|
||||||
private Menu menu;
|
private Menu menu;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Abstracts
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public abstract String getTag();
|
|
||||||
|
|
||||||
public abstract String getSupportActionTitle();
|
|
||||||
|
|
||||||
public abstract Intent getBindIntent();
|
|
||||||
|
|
||||||
public abstract void startPlayerListener();
|
|
||||||
|
|
||||||
public abstract void stopPlayerListener();
|
|
||||||
|
|
||||||
public abstract int getPlayerOptionMenuResource();
|
|
||||||
|
|
||||||
public abstract void setupMenu(Menu m);
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
// Activity Lifecycle
|
// Activity Lifecycle
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
@ -106,27 +89,18 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||||||
setSupportActionBar(queueControlBinding.toolbar);
|
setSupportActionBar(queueControlBinding.toolbar);
|
||||||
if (getSupportActionBar() != null) {
|
if (getSupportActionBar() != null) {
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
getSupportActionBar().setTitle(getSupportActionTitle());
|
getSupportActionBar().setTitle(R.string.title_activity_play_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceConnection = getServiceConnection();
|
serviceConnection = getServiceConnection();
|
||||||
bind();
|
bind();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
if (redraw) {
|
|
||||||
ActivityCompat.recreate(this);
|
|
||||||
redraw = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(final Menu m) {
|
public boolean onCreateOptionsMenu(final Menu m) {
|
||||||
this.menu = m;
|
this.menu = m;
|
||||||
getMenuInflater().inflate(R.menu.menu_play_queue, m);
|
getMenuInflater().inflate(R.menu.menu_play_queue, m);
|
||||||
getMenuInflater().inflate(getPlayerOptionMenuResource(), m);
|
getMenuInflater().inflate(R.menu.menu_play_queue_bg, m);
|
||||||
onMaybeMuteChanged();
|
onMaybeMuteChanged();
|
||||||
onPlaybackParameterChanged(player.getPlaybackParameters());
|
onPlaybackParameterChanged(player.getPlaybackParameters());
|
||||||
return true;
|
return true;
|
||||||
@ -135,7 +109,12 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||||||
// Allow to setup visibility of menuItems
|
// Allow to setup visibility of menuItems
|
||||||
@Override
|
@Override
|
||||||
public boolean onPrepareOptionsMenu(final Menu m) {
|
public boolean onPrepareOptionsMenu(final Menu m) {
|
||||||
setupMenu(m);
|
if (player != null) {
|
||||||
|
menu.findItem(R.id.action_switch_popup)
|
||||||
|
.setVisible(!player.popupPlayerSelected());
|
||||||
|
menu.findItem(R.id.action_switch_background)
|
||||||
|
.setVisible(!player.audioPlayerSelected());
|
||||||
|
}
|
||||||
return super.onPrepareOptionsMenu(m);
|
return super.onPrepareOptionsMenu(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +170,8 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
private void bind() {
|
private void bind() {
|
||||||
final boolean success = bindService(getBindIntent(), serviceConnection, BIND_AUTO_CREATE);
|
final Intent bindIntent = new Intent(this, MainPlayer.class);
|
||||||
|
final boolean success = bindService(bindIntent, serviceConnection, BIND_AUTO_CREATE);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
unbindService(serviceConnection);
|
unbindService(serviceConnection);
|
||||||
}
|
}
|
||||||
@ -202,7 +182,9 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||||||
if (serviceBound) {
|
if (serviceBound) {
|
||||||
unbindService(serviceConnection);
|
unbindService(serviceConnection);
|
||||||
serviceBound = false;
|
serviceBound = false;
|
||||||
stopPlayerListener();
|
if (player != null) {
|
||||||
|
player.removeActivityListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
if (player != null && player.getPlayQueueAdapter() != null) {
|
if (player != null && player.getPlayQueueAdapter() != null) {
|
||||||
player.getPlayQueueAdapter().unsetSelectedListener();
|
player.getPlayQueueAdapter().unsetSelectedListener();
|
||||||
@ -221,12 +203,12 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||||||
return new ServiceConnection() {
|
return new ServiceConnection() {
|
||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(final ComponentName name) {
|
public void onServiceDisconnected(final ComponentName name) {
|
||||||
Log.d(getTag(), "Player service is disconnected");
|
Log.d(TAG, "Player service is disconnected");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(final ComponentName name, final IBinder service) {
|
public void onServiceConnected(final ComponentName name, final IBinder service) {
|
||||||
Log.d(getTag(), "Player service is connected");
|
Log.d(TAG, "Player service is connected");
|
||||||
|
|
||||||
if (service instanceof PlayerServiceBinder) {
|
if (service instanceof PlayerServiceBinder) {
|
||||||
player = ((PlayerServiceBinder) service).getPlayerInstance();
|
player = ((PlayerServiceBinder) service).getPlayerInstance();
|
||||||
@ -240,7 +222,9 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
buildComponents();
|
buildComponents();
|
||||||
startPlayerListener();
|
if (player != null) {
|
||||||
|
player.setActivityListener(PlayQueueActivity.this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -463,7 +447,7 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlaybackParameterDialog.newInstance(player.getPlaybackSpeed(), player.getPlaybackPitch(),
|
PlaybackParameterDialog.newInstance(player.getPlaybackSpeed(), player.getPlaybackPitch(),
|
||||||
player.getPlaybackSkipSilence(), this).show(getSupportFragmentManager(), getTag());
|
player.getPlaybackSkipSilence(), this).show(getSupportFragmentManager(), TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -517,10 +501,8 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
|||||||
final PlaylistAppendDialog d = PlaylistAppendDialog.fromPlayQueueItems(playlist);
|
final PlaylistAppendDialog d = PlaylistAppendDialog.fromPlayQueueItems(playlist);
|
||||||
|
|
||||||
PlaylistAppendDialog.onPlaylistFound(getApplicationContext(),
|
PlaylistAppendDialog.onPlaylistFound(getApplicationContext(),
|
||||||
() -> d.show(getSupportFragmentManager(), getTag()),
|
() -> d.show(getSupportFragmentManager(), TAG),
|
||||||
() -> PlaylistCreationDialog.newInstance(d)
|
() -> PlaylistCreationDialog.newInstance(d).show(getSupportFragmentManager(), TAG));
|
||||||
.show(getSupportFragmentManager(), getTag()
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
@ -46,7 +46,7 @@ import org.schabi.newpipe.local.history.StatisticsPlaylistFragment;
|
|||||||
import org.schabi.newpipe.local.playlist.LocalPlaylistFragment;
|
import org.schabi.newpipe.local.playlist.LocalPlaylistFragment;
|
||||||
import org.schabi.newpipe.local.subscription.SubscriptionFragment;
|
import org.schabi.newpipe.local.subscription.SubscriptionFragment;
|
||||||
import org.schabi.newpipe.local.subscription.SubscriptionsImportFragment;
|
import org.schabi.newpipe.local.subscription.SubscriptionsImportFragment;
|
||||||
import org.schabi.newpipe.player.BackgroundPlayerActivity;
|
import org.schabi.newpipe.player.PlayQueueActivity;
|
||||||
import org.schabi.newpipe.player.Player;
|
import org.schabi.newpipe.player.Player;
|
||||||
import org.schabi.newpipe.player.MainPlayer;
|
import org.schabi.newpipe.player.MainPlayer;
|
||||||
import org.schabi.newpipe.player.helper.PlayerHelper;
|
import org.schabi.newpipe.player.helper.PlayerHelper;
|
||||||
@ -530,7 +530,7 @@ public final class NavigationHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Intent getPlayQueueActivityIntent(final Context context) {
|
public static Intent getPlayQueueActivityIntent(final Context context) {
|
||||||
final Intent intent = new Intent(context, BackgroundPlayerActivity.class);
|
final Intent intent = new Intent(context, PlayQueueActivity.class);
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
tools:context="org.schabi.newpipe.player.BackgroundPlayerActivity">
|
tools:context="org.schabi.newpipe.player.PlayQueueActivity">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:id="@+id/appbar"
|
android:id="@+id/appbar"
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true"
|
android:fitsSystemWindows="true"
|
||||||
tools:context="org.schabi.newpipe.player.BackgroundPlayerActivity">
|
tools:context="org.schabi.newpipe.player.PlayQueueActivity">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:id="@+id/appbar"
|
android:id="@+id/appbar"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:context=".player.BackgroundPlayerActivity">
|
tools:context=".player.PlayQueueActivity">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_append_playlist"
|
android:id="@+id/action_append_playlist"
|
||||||
|
Loading…
Reference in New Issue
Block a user