Removed app context for PreferenceUtil class
This commit is contained in:
parent
5df5f6c93e
commit
2bbe39eab7
97 changed files with 397 additions and 456 deletions
|
@ -129,7 +129,7 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media
|
|||
if (path == null) {
|
||||
return;
|
||||
}
|
||||
if (PreferenceUtil.getInstance().gaplessPlayback()) {
|
||||
if (PreferenceUtil.getInstance(context).gaplessPlayback()) {
|
||||
mNextMediaPlayer = new MediaPlayer();
|
||||
mNextMediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK);
|
||||
mNextMediaPlayer.setAudioSessionId(getAudioSessionId());
|
||||
|
|
|
@ -341,7 +341,7 @@ public class MusicService extends MediaBrowserServiceCompat implements SharedPre
|
|||
getContentResolver().registerContentObserver(
|
||||
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, true, mediaStoreObserver);
|
||||
|
||||
PreferenceUtil.getInstance().registerOnSharedPreferenceChangedListener(this);
|
||||
PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this);
|
||||
|
||||
restoreState();
|
||||
|
||||
|
@ -477,7 +477,7 @@ public class MusicService extends MediaBrowserServiceCompat implements SharedPre
|
|||
quit();
|
||||
releaseResources();
|
||||
getContentResolver().unregisterContentObserver(mediaStoreObserver);
|
||||
PreferenceUtil.getInstance().unregisterOnSharedPreferenceChangedListener(this);
|
||||
PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this);
|
||||
wakeLock.release();
|
||||
|
||||
sendBroadcast(new Intent("code.name.monkey.retromusic.RETRO_MUSIC_SERVICE_DESTROYED"));
|
||||
|
@ -676,7 +676,7 @@ public class MusicService extends MediaBrowserServiceCompat implements SharedPre
|
|||
}
|
||||
|
||||
public void initNotification() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && !PreferenceUtil.getInstance().classicNotification()) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && !PreferenceUtil.getInstance(this).classicNotification()) {
|
||||
playingNotification = new PlayingNotificationImpl24();
|
||||
} else {
|
||||
playingNotification = new PlayingNotificationOreo();
|
||||
|
@ -745,14 +745,14 @@ public class MusicService extends MediaBrowserServiceCompat implements SharedPre
|
|||
metaData.putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getPlayingQueue().size());
|
||||
}
|
||||
|
||||
if (PreferenceUtil.getInstance().albumArtOnLockscreen()) {
|
||||
if (PreferenceUtil.getInstance(this).albumArtOnLockscreen()) {
|
||||
final Point screenSize = RetroUtil.getScreenSize(MusicService.this);
|
||||
GlideRequest request = GlideApp.with(MusicService.this)
|
||||
.asBitmap()
|
||||
.load(RetroGlideExtension.getSongModel(song))
|
||||
.transition(RetroGlideExtension.getDefaultTransition())
|
||||
.songOptions(song);
|
||||
if (PreferenceUtil.getInstance().blurredAlbumArt()) {
|
||||
if (PreferenceUtil.getInstance(this).blurredAlbumArt()) {
|
||||
request.transform(new BlurTransformation.Builder(MusicService.this).build());
|
||||
}
|
||||
runOnUiThread(new Runnable() {
|
||||
|
@ -1271,7 +1271,7 @@ public class MusicService extends MediaBrowserServiceCompat implements SharedPre
|
|||
}
|
||||
|
||||
private void registerHeadsetEvents() {
|
||||
if (!headsetReceiverRegistered && PreferenceUtil.getInstance().getHeadsetPlugged()) {
|
||||
if (!headsetReceiverRegistered && PreferenceUtil.getInstance(this).getHeadsetPlugged()) {
|
||||
registerReceiver(headsetReceiver, headsetReceiverIntentFilter);
|
||||
headsetReceiverRegistered = true;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ class PlaybackHandler extends Handler {
|
|||
|
||||
switch (msg.what) {
|
||||
case MusicService.DUCK:
|
||||
if (PreferenceUtil.getInstance().audioDucking()) {
|
||||
if (PreferenceUtil.getInstance(service).audioDucking()) {
|
||||
currentDuckVolume -= .05f;
|
||||
if (currentDuckVolume > .2f) {
|
||||
sendEmptyMessageDelayed(DUCK, 10);
|
||||
|
@ -65,7 +65,7 @@ class PlaybackHandler extends Handler {
|
|||
break;
|
||||
|
||||
case MusicService.UNDUCK:
|
||||
if (PreferenceUtil.getInstance().audioDucking()) {
|
||||
if (PreferenceUtil.getInstance(service).audioDucking()) {
|
||||
currentDuckVolume += .03f;
|
||||
if (currentDuckVolume < 1f) {
|
||||
sendEmptyMessageDelayed(MusicService.UNDUCK, 10);
|
||||
|
|
|
@ -113,7 +113,7 @@ class PlayingNotificationImpl : PlayingNotification() {
|
|||
bigNotificationImageSize) {
|
||||
override fun onResourceReady(resource: BitmapPaletteWrapper, transition: Transition<in BitmapPaletteWrapper>?) {
|
||||
update(resource.bitmap,
|
||||
if (PreferenceUtil.getInstance().isDominantColor)
|
||||
if (PreferenceUtil.getInstance(service).isDominantColor)
|
||||
RetroColorUtil.getDominantColor(resource.bitmap, Color.TRANSPARENT)
|
||||
else
|
||||
RetroColorUtil.getColor(resource.palette, Color.TRANSPARENT))
|
||||
|
@ -135,7 +135,7 @@ class PlayingNotificationImpl : PlayingNotification() {
|
|||
.setImageViewResource(R.id.image, R.drawable.default_album_art)
|
||||
}
|
||||
|
||||
if (!PreferenceUtil.getInstance().coloredNotification()) {
|
||||
if (!PreferenceUtil.getInstance(service).coloredNotification()) {
|
||||
bgColorFinal = Color.WHITE
|
||||
}
|
||||
setBackgroundColor(bgColorFinal)
|
||||
|
|
|
@ -84,7 +84,7 @@ class PlayingNotificationImpl24 : PlayingNotification() {
|
|||
.into(object : RetroSimpleTarget<BitmapPaletteWrapper>(bigNotificationImageSize, bigNotificationImageSize) {
|
||||
override fun onResourceReady(resource: BitmapPaletteWrapper, transition: Transition<in BitmapPaletteWrapper>?) {
|
||||
update(resource.bitmap, when {
|
||||
PreferenceUtil.getInstance().isDominantColor -> RetroColorUtil.getDominantColor(resource.bitmap, Color.TRANSPARENT)
|
||||
PreferenceUtil.getInstance(service).isDominantColor -> RetroColorUtil.getDominantColor(resource.bitmap, Color.TRANSPARENT)
|
||||
else -> RetroColorUtil.getColor(resource.palette, Color.TRANSPARENT)
|
||||
})
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ class PlayingNotificationImpl24 : PlayingNotification() {
|
|||
.setMediaSession(service.mediaSession.sessionToken)
|
||||
.setShowActionsInCompactView( 1, 2, 3))
|
||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O && PreferenceUtil.getInstance().coloredNotification()) {
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.O && PreferenceUtil.getInstance(service).coloredNotification()) {
|
||||
builder.color = color
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ class PlayingNotificationOreo : PlayingNotification() {
|
|||
notificationLayoutBig.setImageViewResource(R.id.largeIcon, R.drawable.default_album_art)
|
||||
}
|
||||
|
||||
if (!PreferenceUtil.getInstance().coloredNotification()) {
|
||||
if (!PreferenceUtil.getInstance(service).coloredNotification()) {
|
||||
bgColorFinal = Color.WHITE
|
||||
}
|
||||
setBackgroundColor(bgColorFinal)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue