mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 01:53:31 +00:00
Removed UnsafeOptInUsageError annotation after media3 library update
This commit is contained in:
parent
ff8bf4f6bf
commit
490cce53e5
20 changed files with 14 additions and 53 deletions
|
|
@ -37,7 +37,6 @@ public class DownloaderManager {
|
||||||
private final HashMap<Uri, Download> downloads;
|
private final HashMap<Uri, Download> downloads;
|
||||||
private final DownloadIndex downloadIndex;
|
private final DownloadIndex downloadIndex;
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
public DownloaderManager(Context context, DownloadManager downloadManager) {
|
public DownloaderManager(Context context, DownloadManager downloadManager) {
|
||||||
this.context = context.getApplicationContext();
|
this.context = context.getApplicationContext();
|
||||||
|
|
||||||
|
|
@ -47,7 +46,6 @@ public class DownloaderManager {
|
||||||
loadDownloads();
|
loadDownloads();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private DownloadRequest buildDownloadRequest(MediaItem mediaItem) {
|
private DownloadRequest buildDownloadRequest(MediaItem mediaItem) {
|
||||||
return DownloadHelper.forMediaItem(context, mediaItem).getDownloadRequest(Util.getUtf8Bytes(checkNotNull(mediaItem.mediaId)));
|
return DownloadHelper.forMediaItem(context, mediaItem).getDownloadRequest(Util.getUtf8Bytes(checkNotNull(mediaItem.mediaId)));
|
||||||
}
|
}
|
||||||
|
|
@ -58,13 +56,11 @@ public class DownloaderManager {
|
||||||
return download != null && download.state != Download.STATE_FAILED;
|
return download != null && download.state != Download.STATE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
public boolean isDownloaded(MediaItem mediaItem) {
|
public boolean isDownloaded(MediaItem mediaItem) {
|
||||||
@Nullable Download download = downloads.get(checkNotNull(mediaItem.localConfiguration).uri);
|
@Nullable Download download = downloads.get(checkNotNull(mediaItem.localConfiguration).uri);
|
||||||
return download != null && download.state != Download.STATE_FAILED;
|
return download != null && download.state != Download.STATE_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
public boolean areDownloaded(List<MediaItem> mediaItems) {
|
public boolean areDownloaded(List<MediaItem> mediaItems) {
|
||||||
for (MediaItem mediaItem : mediaItems) {
|
for (MediaItem mediaItem : mediaItems) {
|
||||||
@Nullable Download download = downloads.get(checkNotNull(mediaItem.localConfiguration).uri);
|
@Nullable Download download = downloads.get(checkNotNull(mediaItem.localConfiguration).uri);
|
||||||
|
|
@ -76,7 +72,6 @@ public class DownloaderManager {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
public void download(MediaItem mediaItem, com.cappielloantonio.play.model.Download download) {
|
public void download(MediaItem mediaItem, com.cappielloantonio.play.model.Download download) {
|
||||||
DownloadService.sendAddDownload(context, DownloaderService.class, buildDownloadRequest(mediaItem), false);
|
DownloadService.sendAddDownload(context, DownloaderService.class, buildDownloadRequest(mediaItem), false);
|
||||||
downloadDatabase(download);
|
downloadDatabase(download);
|
||||||
|
|
@ -88,7 +83,6 @@ public class DownloaderManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
public void remove(MediaItem mediaItem, com.cappielloantonio.play.model.Download download) {
|
public void remove(MediaItem mediaItem, com.cappielloantonio.play.model.Download download) {
|
||||||
DownloadService.sendRemoveDownload(context, DownloaderService.class, buildDownloadRequest(mediaItem).id, false);
|
DownloadService.sendRemoveDownload(context, DownloaderService.class, buildDownloadRequest(mediaItem).id, false);
|
||||||
removeDatabase(download);
|
removeDatabase(download);
|
||||||
|
|
@ -100,7 +94,6 @@ public class DownloaderManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void loadDownloads() {
|
private void loadDownloads() {
|
||||||
try (DownloadCursor loadedDownloads = downloadIndex.getDownloads()) {
|
try (DownloadCursor loadedDownloads = downloadIndex.getDownloads()) {
|
||||||
while (loadedDownloads.moveToNext()) {
|
while (loadedDownloads.moveToNext()) {
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,11 @@ import com.cappielloantonio.play.util.DownloadUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
public class DownloaderService extends androidx.media3.exoplayer.offline.DownloadService {
|
public class DownloaderService extends androidx.media3.exoplayer.offline.DownloadService {
|
||||||
|
|
||||||
private static final int JOB_ID = 1;
|
private static final int JOB_ID = 1;
|
||||||
private static final int FOREGROUND_NOTIFICATION_ID = 1;
|
private static final int FOREGROUND_NOTIFICATION_ID = 1;
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
public DownloaderService() {
|
public DownloaderService() {
|
||||||
super(FOREGROUND_NOTIFICATION_ID, DEFAULT_FOREGROUND_NOTIFICATION_UPDATE_INTERVAL, DownloadUtil.DOWNLOAD_NOTIFICATION_CHANNEL_ID, R.string.exo_download_notification_channel_name, 0);
|
super(FOREGROUND_NOTIFICATION_ID, DEFAULT_FOREGROUND_NOTIFICATION_UPDATE_INTERVAL, DownloadUtil.DOWNLOAD_NOTIFICATION_CHANNEL_ID, R.string.exo_download_notification_channel_name, 0);
|
||||||
}
|
}
|
||||||
|
|
@ -64,7 +62,6 @@ public class DownloaderService extends androidx.media3.exoplayer.offline.Downloa
|
||||||
nextNotificationId = firstNotificationId;
|
nextNotificationId = firstNotificationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
@Override
|
@Override
|
||||||
public void onDownloadChanged(@NonNull DownloadManager downloadManager, Download download, @Nullable Exception finalException) {
|
public void onDownloadChanged(@NonNull DownloadManager downloadManager, Download download, @Nullable Exception finalException) {
|
||||||
Notification notification;
|
Notification notification;
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,6 @@ public class MainActivity extends BaseActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
// BOTTOM SHEET/NAVIGATION
|
// BOTTOM SHEET/NAVIGATION
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initBottomSheet() {
|
private void initBottomSheet() {
|
||||||
bottomSheetBehavior = BottomSheetBehavior.from(findViewById(R.id.player_bottom_sheet));
|
bottomSheetBehavior = BottomSheetBehavior.from(findViewById(R.id.player_bottom_sheet));
|
||||||
bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallback);
|
bottomSheetBehavior.addBottomSheetCallback(bottomSheetCallback);
|
||||||
|
|
@ -205,7 +204,6 @@ public class MainActivity extends BaseActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initService() {
|
private void initService() {
|
||||||
MediaManager.check(getMediaBrowserListenableFuture(), this);
|
MediaManager.check(getMediaBrowserListenableFuture(), this);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package com.cappielloantonio.play.ui.activity.base;
|
package com.cappielloantonio.play.ui.activity.base;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
@ -19,6 +18,7 @@ import com.cappielloantonio.play.service.DownloaderManager;
|
||||||
import com.cappielloantonio.play.service.DownloaderService;
|
import com.cappielloantonio.play.service.DownloaderService;
|
||||||
import com.cappielloantonio.play.service.MediaService;
|
import com.cappielloantonio.play.service.MediaService;
|
||||||
import com.cappielloantonio.play.util.DownloadUtil;
|
import com.cappielloantonio.play.util.DownloadUtil;
|
||||||
|
import com.cappielloantonio.play.util.UIUtil;
|
||||||
import com.google.android.gms.cast.framework.CastContext;
|
import com.google.android.gms.cast.framework.CastContext;
|
||||||
import com.google.android.material.elevation.SurfaceColors;
|
import com.google.android.material.elevation.SurfaceColors;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
|
|
@ -83,7 +83,6 @@ public class BaseActivity extends AppCompatActivity {
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeBrowser() {
|
private void initializeBrowser() {
|
||||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(this, new SessionToken(this, new ComponentName(this, MediaService.class))).buildAsync();
|
mediaBrowserListenableFuture = new MediaBrowser.Builder(this, new SessionToken(this, new ComponentName(this, MediaService.class))).buildAsync();
|
||||||
}
|
}
|
||||||
|
|
@ -96,7 +95,6 @@ public class BaseActivity extends AppCompatActivity {
|
||||||
return mediaBrowserListenableFuture;
|
return mediaBrowserListenableFuture;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeDownloader() {
|
private void initializeDownloader() {
|
||||||
downloaderManager = DownloadUtil.getDownloadTracker(this);
|
downloaderManager = DownloadUtil.getDownloadTracker(this);
|
||||||
|
|
||||||
|
|
@ -108,7 +106,7 @@ public class BaseActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeCastContext() {
|
private void initializeCastContext() {
|
||||||
CastContext.getSharedInstance(this);
|
if (UIUtil.isCastApiAvailable(this)) CastContext.getSharedInstance(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setNavigationBarColor() {
|
private void setNavigationBarColor() {
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,6 @@ public class AlbumPageFragment extends Fragment {
|
||||||
albumPageViewModel.getAlbumSongLiveList(getViewLifecycleOwner()).observe(getViewLifecycleOwner(), songs -> songHorizontalAdapter.setItems(songs));
|
albumPageViewModel.getAlbumSongLiveList(getViewLifecycleOwner()).observe(getViewLifecycleOwner(), songs -> songHorizontalAdapter.setItems(songs));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeMediaBrowser() {
|
private void initializeMediaBrowser() {
|
||||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,6 @@ public class ArtistPageFragment extends Fragment {
|
||||||
similarArtistSnapHelper.attachToRecyclerView(bind.similarArtistsRecyclerView);
|
similarArtistSnapHelper.attachToRecyclerView(bind.similarArtistsRecyclerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeMediaBrowser() {
|
private void initializeMediaBrowser() {
|
||||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -293,7 +293,6 @@ public class DownloadFragment extends Fragment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeMediaBrowser() {
|
private void initializeMediaBrowser() {
|
||||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,6 @@ public class PlayerBottomSheetFragment extends Fragment {
|
||||||
bind.playerBodyLayout.playerBodyBottomSheetViewPager.setAdapter(new PlayerControllerVerticalPager(this));
|
bind.playerBodyLayout.playerBodyBottomSheetViewPager.setAdapter(new PlayerControllerVerticalPager(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeMediaBrowser() {
|
private void initializeMediaBrowser() {
|
||||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
||||||
}
|
}
|
||||||
|
|
@ -97,7 +96,6 @@ public class PlayerBottomSheetFragment extends Fragment {
|
||||||
MediaController.releaseFuture(mediaBrowserListenableFuture);
|
MediaController.releaseFuture(mediaBrowserListenableFuture);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void bindMediaController() {
|
private void bindMediaController() {
|
||||||
mediaBrowserListenableFuture.addListener(() -> {
|
mediaBrowserListenableFuture.addListener(() -> {
|
||||||
try {
|
try {
|
||||||
|
|
@ -110,7 +108,6 @@ public class PlayerBottomSheetFragment extends Fragment {
|
||||||
}, MoreExecutors.directExecutor());
|
}, MoreExecutors.directExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void setMediaControllerListener(MediaBrowser mediaBrowser) {
|
private void setMediaControllerListener(MediaBrowser mediaBrowser) {
|
||||||
defineProgressBarHandler(mediaBrowser);
|
defineProgressBarHandler(mediaBrowser);
|
||||||
setMediaControllerUI(mediaBrowser);
|
setMediaControllerUI(mediaBrowser);
|
||||||
|
|
@ -145,7 +142,6 @@ public class PlayerBottomSheetFragment extends Fragment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void setMetadata(MediaMetadata mediaMetadata) {
|
private void setMetadata(MediaMetadata mediaMetadata) {
|
||||||
if (mediaMetadata.extras != null)
|
if (mediaMetadata.extras != null)
|
||||||
playerBottomSheetViewModel.setLiveMedia(getViewLifecycleOwner(), mediaMetadata.extras.getString("mediaType"), mediaMetadata.extras.getString("id"));
|
playerBottomSheetViewModel.setLiveMedia(getViewLifecycleOwner(), mediaMetadata.extras.getString("mediaType"), mediaMetadata.extras.getString("id"));
|
||||||
|
|
@ -162,7 +158,6 @@ public class PlayerBottomSheetFragment extends Fragment {
|
||||||
.into(bind.playerHeaderLayout.playerHeaderMediaCoverImage);
|
.into(bind.playerHeaderLayout.playerHeaderMediaCoverImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void setMediaControllerUI(MediaBrowser mediaBrowser) {
|
private void setMediaControllerUI(MediaBrowser mediaBrowser) {
|
||||||
if (mediaBrowser.getMediaMetadata().extras != null) {
|
if (mediaBrowser.getMediaMetadata().extras != null) {
|
||||||
switch (mediaBrowser.getMediaMetadata().extras.getString("mediaType", Media.MEDIA_TYPE_MUSIC)) {
|
switch (mediaBrowser.getMediaMetadata().extras.getString("mediaType", Media.MEDIA_TYPE_MUSIC)) {
|
||||||
|
|
@ -194,7 +189,6 @@ public class PlayerBottomSheetFragment extends Fragment {
|
||||||
runProgressBarHandler(isPlaying);
|
runProgressBarHandler(isPlaying);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void setHeaderMediaController() {
|
private void setHeaderMediaController() {
|
||||||
bind.playerHeaderLayout.playerHeaderButton.setOnClickListener(view -> bind.getRoot().findViewById(R.id.exo_play_pause).performClick());
|
bind.playerHeaderLayout.playerHeaderButton.setOnClickListener(view -> bind.getRoot().findViewById(R.id.exo_play_pause).performClick());
|
||||||
bind.playerHeaderLayout.playerHeaderNextMediaButton.setOnClickListener(view -> bind.getRoot().findViewById(R.id.exo_next).performClick());
|
bind.playerHeaderLayout.playerHeaderNextMediaButton.setOnClickListener(view -> bind.getRoot().findViewById(R.id.exo_next).performClick());
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,6 @@ public class PlayerControllerFragment extends Fragment {
|
||||||
bind = null;
|
bind = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void init() {
|
private void init() {
|
||||||
playerMediaCoverViewPager = bind.getRoot().findViewById(R.id.player_media_cover_view_pager);
|
playerMediaCoverViewPager = bind.getRoot().findViewById(R.id.player_media_cover_view_pager);
|
||||||
buttonFavorite = bind.getRoot().findViewById(R.id.button_favorite);
|
buttonFavorite = bind.getRoot().findViewById(R.id.button_favorite);
|
||||||
|
|
@ -109,7 +108,6 @@ public class PlayerControllerFragment extends Fragment {
|
||||||
playerMediaTranscodedBitrate = bind.getRoot().findViewById(R.id.player_media_transcoded_bitrate);
|
playerMediaTranscodedBitrate = bind.getRoot().findViewById(R.id.player_media_transcoded_bitrate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeBrowser() {
|
private void initializeBrowser() {
|
||||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
||||||
}
|
}
|
||||||
|
|
@ -118,7 +116,6 @@ public class PlayerControllerFragment extends Fragment {
|
||||||
MediaBrowser.releaseFuture(mediaBrowserListenableFuture);
|
MediaBrowser.releaseFuture(mediaBrowserListenableFuture);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void bindMediaController() {
|
private void bindMediaController() {
|
||||||
mediaBrowserListenableFuture.addListener(() -> {
|
mediaBrowserListenableFuture.addListener(() -> {
|
||||||
try {
|
try {
|
||||||
|
|
@ -133,7 +130,6 @@ public class PlayerControllerFragment extends Fragment {
|
||||||
}, MoreExecutors.directExecutor());
|
}, MoreExecutors.directExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void setMediaControllerListener(MediaBrowser mediaBrowser) {
|
private void setMediaControllerListener(MediaBrowser mediaBrowser) {
|
||||||
setMediaControllerUI(mediaBrowser);
|
setMediaControllerUI(mediaBrowser);
|
||||||
setMetadata(mediaBrowser.getMediaMetadata());
|
setMetadata(mediaBrowser.getMediaMetadata());
|
||||||
|
|
@ -149,7 +145,6 @@ public class PlayerControllerFragment extends Fragment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void setMetadata(MediaMetadata mediaMetadata) {
|
private void setMetadata(MediaMetadata mediaMetadata) {
|
||||||
playerMediaTitleLabel.setText(MusicUtil.getReadableString(String.valueOf(mediaMetadata.title)));
|
playerMediaTitleLabel.setText(MusicUtil.getReadableString(String.valueOf(mediaMetadata.title)));
|
||||||
playerArtistNameLabel.setText(MusicUtil.getReadableString(String.valueOf(mediaMetadata.artist)));
|
playerArtistNameLabel.setText(MusicUtil.getReadableString(String.valueOf(mediaMetadata.artist)));
|
||||||
|
|
@ -193,7 +188,6 @@ public class PlayerControllerFragment extends Fragment {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void setMediaControllerUI(MediaBrowser mediaBrowser) {
|
private void setMediaControllerUI(MediaBrowser mediaBrowser) {
|
||||||
initPlaybackSpeedButton(mediaBrowser);
|
initPlaybackSpeedButton(mediaBrowser);
|
||||||
|
|
||||||
|
|
@ -280,7 +274,6 @@ public class PlayerControllerFragment extends Fragment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initPlaybackSpeedButton(MediaBrowser mediaBrowser) {
|
private void initPlaybackSpeedButton(MediaBrowser mediaBrowser) {
|
||||||
playbackSpeedButton.setOnClickListener(view -> {
|
playbackSpeedButton.setOnClickListener(view -> {
|
||||||
float currentSpeed = PreferenceUtil.getInstance(requireContext()).getPlaybackSpeed();
|
float currentSpeed = PreferenceUtil.getInstance(requireContext()).getPlaybackSpeed();
|
||||||
|
|
@ -325,7 +318,6 @@ public class PlayerControllerFragment extends Fragment {
|
||||||
playerMediaCoverViewPager.setCurrentItem(1, true);
|
playerMediaCoverViewPager.setCurrentItem(1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void setPlaybackParameters(MediaBrowser mediaBrowser) {
|
private void setPlaybackParameters(MediaBrowser mediaBrowser) {
|
||||||
Button playbackSpeedButton = bind.getRoot().findViewById(R.id.player_playback_speed_button);
|
Button playbackSpeedButton = bind.getRoot().findViewById(R.id.player_playback_speed_button);
|
||||||
float currentSpeed = PreferenceUtil.getInstance(requireContext()).getPlaybackSpeed();
|
float currentSpeed = PreferenceUtil.getInstance(requireContext()).getPlaybackSpeed();
|
||||||
|
|
@ -338,7 +330,6 @@ public class PlayerControllerFragment extends Fragment {
|
||||||
skipSilenceToggleButton.setChecked(skipSilence);
|
skipSilenceToggleButton.setChecked(skipSilence);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void resetPlaybackParameters(MediaBrowser mediaBrowser) {
|
private void resetPlaybackParameters(MediaBrowser mediaBrowser) {
|
||||||
mediaBrowser.setPlaybackParameters(new PlaybackParameters(Media.MEDIA_PLAYBACK_SPEED_100));
|
mediaBrowser.setPlaybackParameters(new PlaybackParameters(Media.MEDIA_PLAYBACK_SPEED_100));
|
||||||
// TODO Resettare lo skip del silenzio
|
// TODO Resettare lo skip del silenzio
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,6 @@ public class PlayerCoverFragment extends Fragment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeBrowser() {
|
private void initializeBrowser() {
|
||||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
||||||
}
|
}
|
||||||
|
|
@ -160,7 +159,6 @@ public class PlayerCoverFragment extends Fragment {
|
||||||
}, MoreExecutors.directExecutor());
|
}, MoreExecutors.directExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void setMediaBrowserListener(MediaBrowser mediaBrowser) {
|
private void setMediaBrowserListener(MediaBrowser mediaBrowser) {
|
||||||
setCover(mediaBrowser.getMediaMetadata());
|
setCover(mediaBrowser.getMediaMetadata());
|
||||||
|
|
||||||
|
|
@ -173,7 +171,6 @@ public class PlayerCoverFragment extends Fragment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void setCover(MediaMetadata mediaMetadata) {
|
private void setCover(MediaMetadata mediaMetadata) {
|
||||||
CustomGlideRequest.Builder
|
CustomGlideRequest.Builder
|
||||||
.from(requireContext(), mediaMetadata.extras != null ? mediaMetadata.extras.getString("coverArtId") : null, CustomGlideRequest.SONG_PIC, null)
|
.from(requireContext(), mediaMetadata.extras != null ? mediaMetadata.extras.getString("coverArtId") : null, CustomGlideRequest.SONG_PIC, null)
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,6 @@ public class PlayerQueueFragment extends Fragment {
|
||||||
bind = null;
|
bind = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeBrowser() {
|
private void initializeBrowser() {
|
||||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,6 @@ public class PlaylistPageFragment extends Fragment {
|
||||||
playlistPageViewModel.getPlaylistSongLiveList(getViewLifecycleOwner()).observe(getViewLifecycleOwner(), songs -> songHorizontalAdapter.setItems(songs));
|
playlistPageViewModel.getPlaylistSongLiveList(getViewLifecycleOwner()).observe(getViewLifecycleOwner(), songs -> songHorizontalAdapter.setItems(songs));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeMediaBrowser() {
|
private void initializeMediaBrowser() {
|
||||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,6 @@ public class SearchFragment extends Fragment {
|
||||||
bind.persistentSearchView.expand();
|
bind.persistentSearchView.expand();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeMediaBrowser() {
|
private void initializeMediaBrowser() {
|
||||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,6 @@ public class SongListPageFragment extends Fragment {
|
||||||
songListPageViewModel.getSongList(getViewLifecycleOwner()).observe(getViewLifecycleOwner(), songs -> songHorizontalAdapter.setItems(songs));
|
songListPageViewModel.getSongList(getViewLifecycleOwner()).observe(getViewLifecycleOwner(), songs -> songHorizontalAdapter.setItems(songs));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeMediaBrowser() {
|
private void initializeMediaBrowser() {
|
||||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,6 @@ public class AlbumBottomSheetDialog extends BottomSheetDialogFragment implements
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeMediaBrowser() {
|
private void initializeMediaBrowser() {
|
||||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,6 @@ public class ArtistBottomSheetDialog extends BottomSheetDialogFragment implement
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeMediaBrowser() {
|
private void initializeMediaBrowser() {
|
||||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,6 @@ public class PodcastBottomSheetDialog extends BottomSheetDialogFragment implemen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeMediaBrowser() {
|
private void initializeMediaBrowser() {
|
||||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,6 @@ public class SongBottomSheetDialog extends BottomSheetDialogFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private void initializeMediaBrowser() {
|
private void initializeMediaBrowser() {
|
||||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@ public final class DownloadUtil {
|
||||||
private static DownloaderManager downloaderManager;
|
private static DownloaderManager downloaderManager;
|
||||||
private static DownloadNotificationHelper downloadNotificationHelper;
|
private static DownloadNotificationHelper downloadNotificationHelper;
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
public static synchronized HttpDataSource.Factory getHttpDataSourceFactory() {
|
public static synchronized HttpDataSource.Factory getHttpDataSourceFactory() {
|
||||||
if (httpDataSourceFactory == null) {
|
if (httpDataSourceFactory == null) {
|
||||||
CookieManager cookieManager = new CookieManager();
|
CookieManager cookieManager = new CookieManager();
|
||||||
|
|
@ -52,7 +51,6 @@ public final class DownloadUtil {
|
||||||
return httpDataSourceFactory;
|
return httpDataSourceFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
public static synchronized DataSource.Factory getDataSourceFactory(Context context) {
|
public static synchronized DataSource.Factory getDataSourceFactory(Context context) {
|
||||||
if (dataSourceFactory == null) {
|
if (dataSourceFactory == null) {
|
||||||
context = context.getApplicationContext();
|
context = context.getApplicationContext();
|
||||||
|
|
@ -63,7 +61,6 @@ public final class DownloadUtil {
|
||||||
return dataSourceFactory;
|
return dataSourceFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
public static synchronized DownloadNotificationHelper getDownloadNotificationHelper(Context context) {
|
public static synchronized DownloadNotificationHelper getDownloadNotificationHelper(Context context) {
|
||||||
if (downloadNotificationHelper == null) {
|
if (downloadNotificationHelper == null) {
|
||||||
downloadNotificationHelper = new DownloadNotificationHelper(context, DOWNLOAD_NOTIFICATION_CHANNEL_ID);
|
downloadNotificationHelper = new DownloadNotificationHelper(context, DOWNLOAD_NOTIFICATION_CHANNEL_ID);
|
||||||
|
|
@ -82,7 +79,6 @@ public final class DownloadUtil {
|
||||||
return downloaderManager;
|
return downloaderManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private static synchronized Cache getDownloadCache(Context context) {
|
private static synchronized Cache getDownloadCache(Context context) {
|
||||||
if (downloadCache == null) {
|
if (downloadCache == null) {
|
||||||
File downloadContentDirectory = new File(getDownloadDirectory(context), DOWNLOAD_CONTENT_DIRECTORY);
|
File downloadContentDirectory = new File(getDownloadDirectory(context), DOWNLOAD_CONTENT_DIRECTORY);
|
||||||
|
|
@ -92,7 +88,6 @@ public final class DownloadUtil {
|
||||||
return downloadCache;
|
return downloadCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private static synchronized void ensureDownloadManagerInitialized(Context context) {
|
private static synchronized void ensureDownloadManagerInitialized(Context context) {
|
||||||
if (downloadManager == null) {
|
if (downloadManager == null) {
|
||||||
downloadManager =
|
downloadManager =
|
||||||
|
|
@ -107,7 +102,6 @@ public final class DownloadUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private static synchronized DatabaseProvider getDatabaseProvider(Context context) {
|
private static synchronized DatabaseProvider getDatabaseProvider(Context context) {
|
||||||
if (databaseProvider == null) {
|
if (databaseProvider == null) {
|
||||||
databaseProvider = new StandaloneDatabaseProvider(context);
|
databaseProvider = new StandaloneDatabaseProvider(context);
|
||||||
|
|
@ -127,7 +121,6 @@ public final class DownloadUtil {
|
||||||
return downloadDirectory;
|
return downloadDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
private static CacheDataSource.Factory buildReadOnlyCacheDataSource(DataSource.Factory upstreamFactory, Cache cache) {
|
private static CacheDataSource.Factory buildReadOnlyCacheDataSource(DataSource.Factory upstreamFactory, Cache cache) {
|
||||||
return new CacheDataSource.Factory()
|
return new CacheDataSource.Factory()
|
||||||
.setCache(cache)
|
.setCache(cache)
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,6 @@ public class MusicUtil {
|
||||||
return Uri.parse(uri.toString());
|
return Uri.parse(uri.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("UnsafeOptInUsageError")
|
|
||||||
public static Uri getDownloadUri(String id) {
|
public static Uri getDownloadUri(String id) {
|
||||||
Map<String, String> params = App.getSubsonicClientInstance(App.getInstance(), false).getParams();
|
Map<String, String> params = App.getSubsonicClientInstance(App.getInstance(), false).getParams();
|
||||||
|
|
||||||
|
|
@ -124,6 +123,18 @@ public class MusicUtil {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getReadableLyrics(String string) {
|
||||||
|
if (string != null) {
|
||||||
|
return string
|
||||||
|
.replaceAll(""", "\"")
|
||||||
|
.replaceAll("'", "'")
|
||||||
|
.replaceAll("&", "'")
|
||||||
|
.replaceAll("
", "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
public static String normalizedArtistName(String string) {
|
public static String normalizedArtistName(String string) {
|
||||||
if (string != null) {
|
if (string != null) {
|
||||||
if (string.toLowerCase().contains(" feat.")) return Pattern.compile(" feat.", Pattern.CASE_INSENSITIVE).split(string)[0].trim();
|
if (string.toLowerCase().contains(" feat.")) return Pattern.compile(" feat.", Pattern.CASE_INSENSITIVE).split(string)[0].trim();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue