1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-04 17:16:24 +00:00

Move player-notification files into their package

This commit is contained in:
Stypox 2022-04-14 18:40:55 +02:00
parent 0bba1d95de
commit 90a89f8ca5
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
7 changed files with 60 additions and 56 deletions

View File

@ -29,21 +29,21 @@ import static com.google.android.exoplayer2.Player.REPEAT_MODE_ONE;
import static com.google.android.exoplayer2.Player.RepeatMode;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
import static org.schabi.newpipe.player.PlayerService.ACTION_CLOSE;
import static org.schabi.newpipe.player.PlayerService.ACTION_FAST_FORWARD;
import static org.schabi.newpipe.player.PlayerService.ACTION_FAST_REWIND;
import static org.schabi.newpipe.player.PlayerService.ACTION_PLAY_NEXT;
import static org.schabi.newpipe.player.PlayerService.ACTION_PLAY_PAUSE;
import static org.schabi.newpipe.player.PlayerService.ACTION_PLAY_PREVIOUS;
import static org.schabi.newpipe.player.PlayerService.ACTION_RECREATE_NOTIFICATION;
import static org.schabi.newpipe.player.PlayerService.ACTION_REPEAT;
import static org.schabi.newpipe.player.PlayerService.ACTION_SHUFFLE;
import static org.schabi.newpipe.player.helper.PlayerHelper.isPlaybackResumeEnabled;
import static org.schabi.newpipe.player.helper.PlayerHelper.nextRepeatMode;
import static org.schabi.newpipe.player.helper.PlayerHelper.retrievePlaybackParametersFromPrefs;
import static org.schabi.newpipe.player.helper.PlayerHelper.retrievePlayerTypeFromIntent;
import static org.schabi.newpipe.player.helper.PlayerHelper.retrieveSeekDurationFromPreferences;
import static org.schabi.newpipe.player.helper.PlayerHelper.savePlaybackParametersToPrefs;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_CLOSE;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_FAST_FORWARD;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_FAST_REWIND;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_PLAY_NEXT;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_PLAY_PAUSE;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_PLAY_PREVIOUS;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_RECREATE_NOTIFICATION;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_REPEAT;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_SHUFFLE;
import static org.schabi.newpipe.util.ListHelper.getPopupResolutionIndex;
import static org.schabi.newpipe.util.ListHelper.getResolutionIndex;
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
@ -125,7 +125,7 @@ import org.schabi.newpipe.player.resolver.AudioPlaybackResolver;
import org.schabi.newpipe.player.resolver.VideoPlaybackResolver;
import org.schabi.newpipe.player.resolver.VideoPlaybackResolver.SourceType;
import org.schabi.newpipe.player.ui.MainPlayerUi;
import org.schabi.newpipe.player.ui.NotificationPlayerUi;
import org.schabi.newpipe.player.notification.NotificationPlayerUi;
import org.schabi.newpipe.player.ui.PlayerUi;
import org.schabi.newpipe.player.ui.PlayerUiList;
import org.schabi.newpipe.player.ui.PopupPlayerUi;

View File

@ -28,8 +28,6 @@ import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
import org.schabi.newpipe.App;
import org.schabi.newpipe.player.ui.VideoPlayerUi;
import org.schabi.newpipe.util.ThemeHelper;
@ -52,29 +50,6 @@ public final class PlayerService extends Service {
POPUP
}
/*//////////////////////////////////////////////////////////////////////////
// Notification
//////////////////////////////////////////////////////////////////////////*/
static final String ACTION_CLOSE
= App.PACKAGE_NAME + ".player.MainPlayer.CLOSE";
public static final String ACTION_PLAY_PAUSE
= App.PACKAGE_NAME + ".player.MainPlayer.PLAY_PAUSE";
static final String ACTION_REPEAT
= App.PACKAGE_NAME + ".player.MainPlayer.REPEAT";
static final String ACTION_PLAY_NEXT
= App.PACKAGE_NAME + ".player.MainPlayer.ACTION_PLAY_NEXT";
static final String ACTION_PLAY_PREVIOUS
= App.PACKAGE_NAME + ".player.MainPlayer.ACTION_PLAY_PREVIOUS";
static final String ACTION_FAST_REWIND
= App.PACKAGE_NAME + ".player.MainPlayer.ACTION_FAST_REWIND";
static final String ACTION_FAST_FORWARD
= App.PACKAGE_NAME + ".player.MainPlayer.ACTION_FAST_FORWARD";
static final String ACTION_SHUFFLE
= App.PACKAGE_NAME + ".player.MainPlayer.ACTION_SHUFFLE";
public static final String ACTION_RECREATE_NOTIFICATION
= App.PACKAGE_NAME + ".player.MainPlayer.ACTION_RECREATE_NOTIFICATION";
/*//////////////////////////////////////////////////////////////////////////
// Service's LifeCycle
//////////////////////////////////////////////////////////////////////////*/

View File

@ -1,4 +1,4 @@
package org.schabi.newpipe.player;
package org.schabi.newpipe.player.notification;
import android.content.Context;
import android.content.SharedPreferences;
@ -7,6 +7,7 @@ import androidx.annotation.DrawableRes;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import org.schabi.newpipe.App;
import org.schabi.newpipe.R;
import org.schabi.newpipe.util.Localization;
@ -20,7 +21,34 @@ import java.util.TreeSet;
public final class NotificationConstants {
private NotificationConstants() { }
private NotificationConstants() {
}
/*//////////////////////////////////////////////////////////////////////////
// Intent actions
//////////////////////////////////////////////////////////////////////////*/
public static final String ACTION_CLOSE
= App.PACKAGE_NAME + ".player.MainPlayer.CLOSE";
public static final String ACTION_PLAY_PAUSE
= App.PACKAGE_NAME + ".player.MainPlayer.PLAY_PAUSE";
public static final String ACTION_REPEAT
= App.PACKAGE_NAME + ".player.MainPlayer.REPEAT";
public static final String ACTION_PLAY_NEXT
= App.PACKAGE_NAME + ".player.MainPlayer.ACTION_PLAY_NEXT";
public static final String ACTION_PLAY_PREVIOUS
= App.PACKAGE_NAME + ".player.MainPlayer.ACTION_PLAY_PREVIOUS";
public static final String ACTION_FAST_REWIND
= App.PACKAGE_NAME + ".player.MainPlayer.ACTION_FAST_REWIND";
public static final String ACTION_FAST_FORWARD
= App.PACKAGE_NAME + ".player.MainPlayer.ACTION_FAST_FORWARD";
public static final String ACTION_SHUFFLE
= App.PACKAGE_NAME + ".player.MainPlayer.ACTION_SHUFFLE";
public static final String ACTION_RECREATE_NOTIFICATION
= App.PACKAGE_NAME + ".player.MainPlayer.ACTION_RECREATE_NOTIFICATION";
public static final int NOTHING = 0;

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.player.ui;
package org.schabi.newpipe.player.notification;
import static org.schabi.newpipe.player.PlayerService.ACTION_RECREATE_NOTIFICATION;
import static org.schabi.newpipe.player.helper.PlayerHelper.MinimizeMode.MINIMIZE_ON_EXIT_MODE_NONE;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_RECREATE_NOTIFICATION;
import android.content.Intent;
import android.graphics.Bitmap;
@ -12,9 +12,9 @@ import androidx.annotation.Nullable;
import com.google.android.exoplayer2.Player.RepeatMode;
import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.player.NotificationUtil;
import org.schabi.newpipe.player.Player;
import org.schabi.newpipe.player.helper.PlayerHelper;
import org.schabi.newpipe.player.ui.PlayerUi;
public final class NotificationPlayerUi extends PlayerUi {
private boolean foregroundNotificationAlreadyCreated = false;

View File

@ -1,8 +1,7 @@
package org.schabi.newpipe.player;
package org.schabi.newpipe.player.notification;
import android.annotation.SuppressLint;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.content.pm.ServiceInfo;
import android.graphics.Bitmap;
@ -19,6 +18,7 @@ import androidx.core.content.ContextCompat;
import org.schabi.newpipe.MainActivity;
import org.schabi.newpipe.R;
import org.schabi.newpipe.player.Player;
import org.schabi.newpipe.util.NavigationHelper;
import java.util.List;
@ -26,14 +26,14 @@ import java.util.List;
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
import static com.google.android.exoplayer2.Player.REPEAT_MODE_ALL;
import static com.google.android.exoplayer2.Player.REPEAT_MODE_ONE;
import static org.schabi.newpipe.player.PlayerService.ACTION_CLOSE;
import static org.schabi.newpipe.player.PlayerService.ACTION_FAST_FORWARD;
import static org.schabi.newpipe.player.PlayerService.ACTION_FAST_REWIND;
import static org.schabi.newpipe.player.PlayerService.ACTION_PLAY_NEXT;
import static org.schabi.newpipe.player.PlayerService.ACTION_PLAY_PAUSE;
import static org.schabi.newpipe.player.PlayerService.ACTION_PLAY_PREVIOUS;
import static org.schabi.newpipe.player.PlayerService.ACTION_REPEAT;
import static org.schabi.newpipe.player.PlayerService.ACTION_SHUFFLE;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_CLOSE;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_FAST_FORWARD;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_FAST_REWIND;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_PLAY_NEXT;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_PLAY_PAUSE;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_PLAY_PREVIOUS;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_REPEAT;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_SHUFFLE;
/**
* This is a utility class for player notifications.
@ -51,7 +51,7 @@ public final class NotificationUtil {
private NotificationManagerCompat notificationManager;
private NotificationCompat.Builder notificationBuilder;
private Player player;
private final Player player;
public NotificationUtil(final Player player) {
this.player = player;
@ -205,12 +205,11 @@ public final class NotificationUtil {
private void updateActions(final NotificationCompat.Builder builder) {
builder.mActions.clear();
for (int i = 0; i < 5; ++i) {
addAction(builder, player, notificationSlots[i]);
addAction(builder, notificationSlots[i]);
}
}
private void addAction(final NotificationCompat.Builder builder,
final Player player,
@NotificationConstants.Action final int slot) {
final NotificationCompat.Action action = getAction(slot);
if (action != null) {

View File

@ -5,13 +5,13 @@ import static org.schabi.newpipe.QueueItemMenuUtil.openPopupMenu;
import static org.schabi.newpipe.ktx.ViewUtils.animate;
import static org.schabi.newpipe.player.Player.STATE_COMPLETED;
import static org.schabi.newpipe.player.Player.STATE_PAUSED;
import static org.schabi.newpipe.player.PlayerService.ACTION_PLAY_PAUSE;
import static org.schabi.newpipe.player.helper.PlayerHelper.MinimizeMode.MINIMIZE_ON_EXIT_MODE_BACKGROUND;
import static org.schabi.newpipe.player.helper.PlayerHelper.MinimizeMode.MINIMIZE_ON_EXIT_MODE_NONE;
import static org.schabi.newpipe.player.helper.PlayerHelper.MinimizeMode.MINIMIZE_ON_EXIT_MODE_POPUP;
import static org.schabi.newpipe.player.helper.PlayerHelper.getMinimizeOnExitAction;
import static org.schabi.newpipe.player.helper.PlayerHelper.getTimeString;
import static org.schabi.newpipe.player.helper.PlayerHelper.globalScreenOrientationLocked;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_PLAY_PAUSE;
import android.app.Activity;
import android.content.Context;

View File

@ -1,5 +1,7 @@
package org.schabi.newpipe.settings.custom;
import static org.schabi.newpipe.player.notification.NotificationConstants.ACTION_RECREATE_NOTIFICATION;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -27,7 +29,7 @@ import org.schabi.newpipe.R;
import org.schabi.newpipe.databinding.ListRadioIconItemBinding;
import org.schabi.newpipe.databinding.SingleChoiceDialogViewBinding;
import org.schabi.newpipe.player.PlayerService;
import org.schabi.newpipe.player.NotificationConstants;
import org.schabi.newpipe.player.notification.NotificationConstants;
import org.schabi.newpipe.util.DeviceUtils;
import org.schabi.newpipe.util.ThemeHelper;
import org.schabi.newpipe.views.FocusOverlayView;
@ -61,7 +63,7 @@ public class NotificationActionsPreference extends Preference {
public void onDetached() {
super.onDetached();
saveChanges();
getContext().sendBroadcast(new Intent(PlayerService.ACTION_RECREATE_NOTIFICATION));
getContext().sendBroadcast(new Intent(ACTION_RECREATE_NOTIFICATION));
}