Code refactor

This commit is contained in:
Hemanth S 2020-06-07 00:27:28 +05:30
parent a8f0867c9d
commit 5394f94973
96 changed files with 384 additions and 1068 deletions

View file

@ -32,7 +32,7 @@ object Constants {
const val FAQ_LINK = "https://github.com/h4h13/RetroMusicPlayer/blob/master/FAQ.md" const val FAQ_LINK = "https://github.com/h4h13/RetroMusicPlayer/blob/master/FAQ.md"
const val PINTEREST = "https://in.pinterest.com/retromusicapp/" const val PINTEREST = "https://in.pinterest.com/retromusicapp/"
const val BASE_SELECTION = const val IS_MUSIC =
MediaStore.Audio.AudioColumns.IS_MUSIC + "=1" + " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''" MediaStore.Audio.AudioColumns.IS_MUSIC + "=1" + " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''"
val baseProjection = arrayOf( val baseProjection = arrayOf(
@ -47,11 +47,9 @@ object Constants {
MediaStore.Audio.AudioColumns.ALBUM, // 8 MediaStore.Audio.AudioColumns.ALBUM, // 8
MediaStore.Audio.AudioColumns.ARTIST_ID, // 9 MediaStore.Audio.AudioColumns.ARTIST_ID, // 9
MediaStore.Audio.AudioColumns.ARTIST,// 10 MediaStore.Audio.AudioColumns.ARTIST,// 10
MediaStore.Audio.AudioColumns.COMPOSER MediaStore.Audio.AudioColumns.COMPOSER// 11
)// 11 )
const val NUMBER_OF_TOP_TRACKS = 99 const val NUMBER_OF_TOP_TRACKS = 99
} }
const val EXTRA_SONG = "extra_songs" const val EXTRA_SONG = "extra_songs"
@ -113,8 +111,7 @@ const val COLORED_APP_SHORTCUTS = "colored_app_shortcuts"
const val AUDIO_DUCKING = "audio_ducking" const val AUDIO_DUCKING = "audio_ducking"
const val LAST_ADDED_CUTOFF = "last_added_interval" const val LAST_ADDED_CUTOFF = "last_added_interval"
const val LAST_SLEEP_TIMER_VALUE = "last_sleep_timer_value" const val LAST_SLEEP_TIMER_VALUE = "last_sleep_timer_value"
const val NEXT_SLEEP_TIMER_ELAPSED_REALTIME = const val NEXT_SLEEP_TIMER_ELAPSED_REALTIME = "next_sleep_timer_elapsed_real_time"
"next_sleep_timer_elapsed_real_time"
const val IGNORE_MEDIA_STORE_ARTWORK = "ignore_media_store_artwork" const val IGNORE_MEDIA_STORE_ARTWORK = "ignore_media_store_artwork"
const val LAST_CHANGELOG_VERSION = "last_changelog_version" const val LAST_CHANGELOG_VERSION = "last_changelog_version"
const val AUTO_DOWNLOAD_IMAGES_POLICY = "auto_download_images_policy" const val AUTO_DOWNLOAD_IMAGES_POLICY = "auto_download_images_policy"

View file

@ -1,6 +1,7 @@
package code.name.monkey.retromusic; package code.name.monkey.retromusic;
import android.content.Context; import android.content.Context;
import android.content.ContextWrapper;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.LocaleList; import android.os.LocaleList;
@ -9,7 +10,7 @@ import java.util.Locale;
import code.name.monkey.appthemehelper.util.VersionUtils; import code.name.monkey.appthemehelper.util.VersionUtils;
public class LanguageContextWrapper extends android.content.ContextWrapper { public class LanguageContextWrapper extends ContextWrapper {
public LanguageContextWrapper(Context base) { public LanguageContextWrapper(Context base) {
super(base); super(base);

View file

@ -9,10 +9,12 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.bottomsheet.BottomSheetBehavior; import com.google.android.material.bottomsheet.BottomSheetBehavior;
import org.jetbrains.annotations.NotNull;
public class RetroBottomSheetBehavior<V extends View> extends BottomSheetBehavior<V> { public class RetroBottomSheetBehavior<V extends View> extends BottomSheetBehavior<V> {
private static final String TAG = "CustomBottomSheetBehavi"; private static final String TAG = "RetroBottomSheetBehavior";
private boolean allowDragging = true; private boolean allowDragging = true;
@ -28,7 +30,7 @@ public class RetroBottomSheetBehavior<V extends View> extends BottomSheetBehavio
} }
@Override @Override
public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) { public boolean onInterceptTouchEvent(@NotNull CoordinatorLayout parent, @NotNull V child, @NotNull MotionEvent event) {
if (!allowDragging) { if (!allowDragging) {
return false; return false;
} }

View file

@ -34,7 +34,7 @@ import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.model.lyrics.Lyrics import code.name.monkey.retromusic.model.lyrics.Lyrics
import code.name.monkey.retromusic.util.LyricUtil import code.name.monkey.retromusic.util.LyricUtil
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import kotlinx.android.synthetic.main.activity_lyrics.* import kotlinx.android.synthetic.main.activity_lyrics.*
import kotlinx.android.synthetic.main.fragment_lyrics.* import kotlinx.android.synthetic.main.fragment_lyrics.*
import kotlinx.android.synthetic.main.fragment_synced.* import kotlinx.android.synthetic.main.fragment_synced.*
@ -54,7 +54,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener,
} }
override fun onPageSelected(position: Int) { override fun onPageSelected(position: Int) {
PreferenceUtilKT.lyricsOption = position PreferenceUtil.lyricsOption = position
if (position == 0) fab.text = getString(R.string.synced_lyrics) if (position == 0) fab.text = getString(R.string.synced_lyrics)
else if (position == 1) fab.text = getString(R.string.lyrics) else if (position == 1) fab.text = getString(R.string.lyrics)
} }
@ -100,7 +100,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener,
viewPager.apply { viewPager.apply {
adapter = PagerAdapter(supportFragmentManager) adapter = PagerAdapter(supportFragmentManager)
currentItem = PreferenceUtilKT.lyricsOption currentItem = PreferenceUtil.lyricsOption
addOnPageChangeListener(this@LyricsActivity) addOnPageChangeListener(this@LyricsActivity)
} }

View file

@ -47,7 +47,7 @@ import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.AppRater.appLaunched import code.name.monkey.retromusic.util.AppRater.appLaunched
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroColorUtil import code.name.monkey.retromusic.util.RetroColorUtil
import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil
import com.afollestad.materialcab.MaterialCab import com.afollestad.materialcab.MaterialCab
@ -99,7 +99,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
override fun onReceive(context: Context, intent: Intent) { override fun onReceive(context: Context, intent: Intent) {
val action = intent.action val action = intent.action
if (action != null && action == Intent.ACTION_SCREEN_OFF) { if (action != null && action == Intent.ACTION_SCREEN_OFF) {
if (PreferenceUtilKT.isLockScreen && isPlaying) { if (PreferenceUtil.isLockScreen && isPlaying) {
val activity = Intent(context, LockScreenActivity::class.java) val activity = Intent(context, LockScreenActivity::class.java)
activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
activity.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) activity.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
@ -127,7 +127,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
addMusicServiceEventListener(libraryViewModel) addMusicServiceEventListener(libraryViewModel)
if (savedInstanceState == null) { if (savedInstanceState == null) {
selectedFragment(PreferenceUtilKT.lastPage) selectedFragment(PreferenceUtil.lastPage)
} else { } else {
restoreCurrentFragment() restoreCurrentFragment()
} }
@ -136,9 +136,9 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
setupToolbar() setupToolbar()
checkUpdate() checkUpdate()
updateTabs() updateTabs()
getBottomNavigationView().selectedItemId = PreferenceUtilKT.lastPage getBottomNavigationView().selectedItemId = PreferenceUtil.lastPage
getBottomNavigationView().setOnNavigationItemSelectedListener { getBottomNavigationView().setOnNavigationItemSelectedListener {
PreferenceUtilKT.lastPage = it.itemId PreferenceUtil.lastPage = it.itemId
selectedFragment(it.itemId) selectedFragment(it.itemId)
true true
} }
@ -147,10 +147,10 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
registerReceiver(broadcastReceiver, intentFilter) registerReceiver(broadcastReceiver, intentFilter)
PreferenceUtilKT.registerOnSharedPreferenceChangedListener(this) PreferenceUtil.registerOnSharedPreferenceChangedListener(this)
if (intent.hasExtra(EXPAND_PANEL) && if (intent.hasExtra(EXPAND_PANEL) &&
intent.getBooleanExtra(EXPAND_PANEL, false) && intent.getBooleanExtra(EXPAND_PANEL, false) &&
PreferenceUtilKT.isExpandPanel PreferenceUtil.isExpandPanel
) { ) {
expandPanel() expandPanel()
intent.removeExtra(EXPAND_PANEL) intent.removeExtra(EXPAND_PANEL)
@ -179,7 +179,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
unregisterReceiver(broadcastReceiver) unregisterReceiver(broadcastReceiver)
PreferenceUtilKT.unregisterOnSharedPreferenceChangedListener(this) PreferenceUtil.unregisterOnSharedPreferenceChangedListener(this)
} }
override fun onPrepareOptionsMenu(menu: Menu?): Boolean { override fun onPrepareOptionsMenu(menu: Menu?): Boolean {

View file

@ -21,7 +21,7 @@ import code.name.monkey.retromusic.extensions.applyToolbar
import code.name.monkey.retromusic.glide.ProfileBannerGlideRequest import code.name.monkey.retromusic.glide.ProfileBannerGlideRequest
import code.name.monkey.retromusic.glide.UserProfileGlideRequest import code.name.monkey.retromusic.glide.UserProfileGlideRequest
import code.name.monkey.retromusic.util.ImageUtil import code.name.monkey.retromusic.util.ImageUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestListener import com.bumptech.glide.request.RequestListener
@ -50,7 +50,7 @@ class UserInfoActivity : AbsBaseActivity() {
applyToolbar(toolbar) applyToolbar(toolbar)
MaterialUtil.setTint(nameContainer, false) MaterialUtil.setTint(nameContainer, false)
name.setText(PreferenceUtilKT.userName) name.setText(PreferenceUtil.userName)
userImage.setOnClickListener { userImage.setOnClickListener {
pickNewPhoto() pickNewPhoto()
@ -66,7 +66,7 @@ class UserInfoActivity : AbsBaseActivity() {
Toast.makeText(this, "Umm name is empty", Toast.LENGTH_SHORT).show() Toast.makeText(this, "Umm name is empty", Toast.LENGTH_SHORT).show()
return@setOnClickListener return@setOnClickListener
} }
PreferenceUtilKT.userName = nameString PreferenceUtil.userName = nameString
setResult(Activity.RESULT_OK) setResult(Activity.RESULT_OK)
finish() finish()
} }

View file

@ -25,7 +25,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper;
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper;
import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.activities.base.AbsBaseActivity; import code.name.monkey.retromusic.activities.base.AbsBaseActivity;
import code.name.monkey.retromusic.util.PreferenceUtilKT; import code.name.monkey.retromusic.util.PreferenceUtil;
public class WhatsNewActivity extends AbsBaseActivity { public class WhatsNewActivity extends AbsBaseActivity {
@ -38,7 +38,7 @@ public class WhatsNewActivity extends AbsBaseActivity {
try { try {
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
int currentVersion = pInfo.versionCode; int currentVersion = pInfo.versionCode;
PreferenceUtilKT.INSTANCE.setLastVersion(currentVersion); PreferenceUtil.INSTANCE.setLastVersion(currentVersion);
} catch (PackageManager.NameNotFoundException e) { } catch (PackageManager.NameNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }

View file

@ -74,7 +74,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
private lateinit var artistImage: ImageView private lateinit var artistImage: ImageView
private var cab: MaterialCab? = null private var cab: MaterialCab? = null
private val savedSortOrder: String private val savedSortOrder: String
get() = PreferenceUtilKT.albumDetailSongSortOrder get() = PreferenceUtil.albumDetailSongSortOrder
override fun createContentView(): View { override fun createContentView(): View {
return wrapSlidingMusicPanel(R.layout.activity_album) return wrapSlidingMusicPanel(R.layout.activity_album)
@ -244,7 +244,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
private fun loadAlbumCover() { private fun loadAlbumCover() {
AlbumGlideRequest.Builder.from(Glide.with(this), album.safeGetFirstSong()) AlbumGlideRequest.Builder.from(Glide.with(this), album.safeGetFirstSong())
.checkIgnoreMediaStore(this) .checkIgnoreMediaStore(this)
.ignoreMediaStore(PreferenceUtilKT.isIgnoreMediaStoreArtwork) .ignoreMediaStore(PreferenceUtil.isIgnoreMediaStoreArtwork)
.generatePalette(this) .generatePalette(this)
.build() .build()
.dontAnimate() .dontAnimate()
@ -257,7 +257,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
} }
private fun setColors(color: MediaNotificationProcessor) { private fun setColors(color: MediaNotificationProcessor) {
val buttonColor = if (PreferenceUtilKT.isAdaptiveColor) val buttonColor = if (PreferenceUtil.isAdaptiveColor)
color.backgroundColor.ripAlpha() color.backgroundColor.ripAlpha()
else else
ATHUtil.resolveColor(this, R.attr.colorSurface) ATHUtil.resolveColor(this, R.attr.colorSurface)
@ -353,7 +353,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
} }
private fun setSaveSortOrder(sortOrder: String) { private fun setSaveSortOrder(sortOrder: String) {
PreferenceUtilKT.albumDetailSongSortOrder = sortOrder PreferenceUtil.albumDetailSongSortOrder = sortOrder
when (sortOrder) { when (sortOrder) {
AlbumSongSortOrder.SONG_TRACK_LIST -> album.songs?.sortWith(Comparator { o1, o2 -> AlbumSongSortOrder.SONG_TRACK_LIST -> album.songs?.sortWith(Comparator { o1, o2 ->
o1.trackNumber.compareTo( o1.trackNumber.compareTo(

View file

@ -18,7 +18,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.MaterialUtil import code.name.monkey.appthemehelper.util.MaterialUtil
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.activities.albums.AlbumDetailsViewModelFactory
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
@ -246,7 +245,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
} }
private fun setColors(color: MediaNotificationProcessor) { private fun setColors(color: MediaNotificationProcessor) {
val buttonColor = if (PreferenceUtilKT.isAdaptiveColor) val buttonColor = if (PreferenceUtil.isAdaptiveColor)
color.backgroundColor.ripAlpha() color.backgroundColor.ripAlpha()
else else
ATHUtil.resolveColor(this, R.attr.colorSurface) ATHUtil.resolveColor(this, R.attr.colorSurface)

View file

@ -39,7 +39,7 @@ import code.name.monkey.retromusic.fragments.player.tiny.TinyPlayerFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.CategoryInfo import code.name.monkey.retromusic.model.CategoryInfo
import code.name.monkey.retromusic.util.DensityUtil import code.name.monkey.retromusic.util.DensityUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.views.BottomNavigationBarTinted import code.name.monkey.retromusic.views.BottomNavigationBarTinted
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.shape.MaterialShapeDrawable import com.google.android.material.shape.MaterialShapeDrawable
@ -117,7 +117,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
if (cps != PreferenceUtilKT.nowPlayingScreen) { if (cps != PreferenceUtil.nowPlayingScreen) {
postRecreate() postRecreate()
} }
behavior.addBottomSheetCallback(bottomSheetCallbackList) behavior.addBottomSheetCallback(bottomSheetCallbackList)
@ -239,7 +239,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
} }
private fun chooseFragmentForTheme() { private fun chooseFragmentForTheme() {
cps = PreferenceUtilKT.nowPlayingScreen cps = PreferenceUtil.nowPlayingScreen
val fragment: Fragment = when (cps) { val fragment: Fragment = when (cps) {
Blur -> BlurPlayerFragment() Blur -> BlurPlayerFragment()
Adaptive -> AdaptiveFragment() Adaptive -> AdaptiveFragment()
@ -310,7 +310,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
val isColorLight = ColorUtil.isColorLight(paletteColor) val isColorLight = ColorUtil.isColorLight(paletteColor)
if (PreferenceUtilKT.isAdaptiveColor && (cps == Normal || cps == Flat)) { if (PreferenceUtil.isAdaptiveColor && (cps == Normal || cps == Flat)) {
super.setLightNavigationBar(true) super.setLightNavigationBar(true)
super.setLightStatusbar(isColorLight) super.setLightStatusbar(isColorLight)
} else if (cps == Card || cps == Blur || cps == BlurCard) { } else if (cps == Card || cps == Blur || cps == BlurCard) {
@ -374,7 +374,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
fun updateTabs() { fun updateTabs() {
bottomNavigationView.menu.clear() bottomNavigationView.menu.clear()
val currentTabs: List<CategoryInfo> = PreferenceUtilKT.libraryCategory val currentTabs: List<CategoryInfo> = PreferenceUtil.libraryCategory
for (tab in currentTabs) { for (tab in currentTabs) {
if (tab.visible) { if (tab.visible) {
val menu = tab.category val menu = tab.category

View file

@ -18,7 +18,7 @@ import code.name.monkey.appthemehelper.util.MaterialDialogsUtil
import code.name.monkey.appthemehelper.util.VersionUtils import code.name.monkey.appthemehelper.util.VersionUtils
import code.name.monkey.retromusic.LanguageContextWrapper import code.name.monkey.retromusic.LanguageContextWrapper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil
import code.name.monkey.retromusic.util.theme.ThemeManager import code.name.monkey.retromusic.util.theme.ThemeManager
import java.util.* import java.util.*
@ -44,7 +44,7 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
} }
private fun toggleScreenOn() { private fun toggleScreenOn() {
if (PreferenceUtilKT.isScreenOnEnabled) { if (PreferenceUtil.isScreenOnEnabled) {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
} else { } else {
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
@ -63,7 +63,7 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
} }
fun hideStatusBar() { fun hideStatusBar() {
hideStatusBar(PreferenceUtilKT.isFullScreenMode) hideStatusBar(PreferenceUtil.isFullScreenMode)
} }
private fun hideStatusBar(fullscreen: Boolean) { private fun hideStatusBar(fullscreen: Boolean) {
@ -166,7 +166,7 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
val flags = val flags =
(View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) (View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)
if (PreferenceUtilKT.isFullScreenMode) { if (PreferenceUtil.isFullScreenMode) {
window.decorView.systemUiVisibility = flags window.decorView.systemUiVisibility = flags
} }
} }
@ -199,7 +199,7 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable {
} }
override fun attachBaseContext(newBase: Context?) { override fun attachBaseContext(newBase: Context?) {
val code = PreferenceUtilKT.languageCode val code = PreferenceUtil.languageCode
if (code != "auto") { if (code != "auto") {
super.attachBaseContext(LanguageContextWrapper.wrap(newBase, Locale(code))) super.attachBaseContext(LanguageContextWrapper.wrap(newBase, Locale(code)))
} else super.attachBaseContext(newBase) } else super.attachBaseContext(newBase)

View file

@ -11,7 +11,7 @@ import androidx.annotation.IntRange;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale; import java.util.Locale;
import code.name.monkey.retromusic.util.PreferenceUtilKT; import code.name.monkey.retromusic.util.PreferenceUtil;
public class DeviceInfo { public class DeviceInfo {
@ -75,10 +75,10 @@ public class DeviceInfo {
versionCode = -1; versionCode = -1;
versionName = null; versionName = null;
} }
baseTheme = PreferenceUtilKT.INSTANCE.getBaseTheme(); baseTheme = PreferenceUtil.INSTANCE.getBaseTheme();
nowPlayingTheme = context.getString(PreferenceUtilKT.INSTANCE.getNowPlayingScreen().getTitleRes()); nowPlayingTheme = context.getString(PreferenceUtil.INSTANCE.getNowPlayingScreen().getTitleRes());
isAdaptive = PreferenceUtilKT.INSTANCE.isAdaptiveColor(); isAdaptive = PreferenceUtil.INSTANCE.isAdaptiveColor();
selectedLang = PreferenceUtilKT.INSTANCE.getLanguageCode(); selectedLang = PreferenceUtil.INSTANCE.getLanguageCode();
} }
public String toMarkdown() { public String toMarkdown() {

View file

@ -21,7 +21,7 @@ import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.model.Home import code.name.monkey.retromusic.model.Home
import code.name.monkey.retromusic.model.Playlist import code.name.monkey.retromusic.model.Playlist
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
class HomeAdapter( class HomeAdapter(
private val activity: AppCompatActivity, private val activity: AppCompatActivity,
@ -118,7 +118,7 @@ class HomeAdapter(
val artistAdapter = ArtistAdapter( val artistAdapter = ArtistAdapter(
activity, activity,
list, list,
PreferenceUtilKT.homeGridStyle, PreferenceUtil.homeGridStyle,
null null
) )
recyclerView.apply { recyclerView.apply {

View file

@ -22,7 +22,7 @@ import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import me.zhanghai.android.fastscroll.PopupTextProvider import me.zhanghai.android.fastscroll.PopupTextProvider
@ -153,7 +153,7 @@ open class AlbumAdapter(
private fun getSectionName(position: Int): String { private fun getSectionName(position: Int): String {
var sectionName: String? = null var sectionName: String? = null
when (PreferenceUtilKT.albumSortOrder) { when (PreferenceUtil.albumSortOrder) {
SortOrder.AlbumSortOrder.ALBUM_A_Z, SortOrder.AlbumSortOrder.ALBUM_Z_A -> sectionName = SortOrder.AlbumSortOrder.ALBUM_A_Z, SortOrder.AlbumSortOrder.ALBUM_Z_A -> sectionName =
dataSet[position].title dataSet[position].title
SortOrder.AlbumSortOrder.ALBUM_ARTIST -> sectionName = dataSet[position].artistName SortOrder.AlbumSortOrder.ALBUM_ARTIST -> sectionName = dataSet[position].artistName

View file

@ -16,7 +16,7 @@ import code.name.monkey.retromusic.misc.CustomFragmentStatePagerAdapter
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
@ -91,7 +91,7 @@ class AlbumCoverPagerAdapter(
} }
private fun getLayoutWithPlayerTheme(): Int { private fun getLayoutWithPlayerTheme(): Int {
return when (PreferenceUtilKT.nowPlayingScreen) { return when (PreferenceUtil.nowPlayingScreen) {
Card, Card,
Fit, Fit,
Tiny, Tiny,
@ -100,17 +100,17 @@ class AlbumCoverPagerAdapter(
Gradient, Gradient,
Full -> R.layout.fragment_album_full_cover Full -> R.layout.fragment_album_full_cover
else -> { else -> {
if (PreferenceUtilKT.isCarouselEffect) { if (PreferenceUtil.isCarouselEffect) {
R.layout.fragment_album_carousel_cover R.layout.fragment_album_carousel_cover
} else { } else {
when (PreferenceUtilKT.albumCoverStyle) { when (PreferenceUtil.albumCoverStyle) {
AlbumCoverStyle.NORMAL -> R.layout.fragment_album_cover AlbumCoverStyle.Normal -> R.layout.fragment_album_cover
AlbumCoverStyle.FLAT -> R.layout.fragment_album_flat_cover AlbumCoverStyle.Flat -> R.layout.fragment_album_flat_cover
AlbumCoverStyle.CIRCLE -> R.layout.fragment_album_circle_cover AlbumCoverStyle.Circle -> R.layout.fragment_album_circle_cover
AlbumCoverStyle.CARD -> R.layout.fragment_album_card_cover AlbumCoverStyle.Card -> R.layout.fragment_album_card_cover
AlbumCoverStyle.MATERIAL -> R.layout.fragment_album_material_cover AlbumCoverStyle.Material -> R.layout.fragment_album_material_cover
AlbumCoverStyle.FULL -> R.layout.fragment_album_full_cover AlbumCoverStyle.Full -> R.layout.fragment_album_full_cover
AlbumCoverStyle.FULL_CARD -> R.layout.fragment_album_full_card_cover AlbumCoverStyle.FullCard -> R.layout.fragment_album_full_card_cover
} }
} }
} }

View file

@ -24,7 +24,7 @@ import code.name.monkey.retromusic.interfaces.CabHolder
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import com.afollestad.materialcab.MaterialCab import com.afollestad.materialcab.MaterialCab
@ -145,7 +145,7 @@ open class SongAdapter(
} }
override fun getPopupText(position: Int): String { override fun getPopupText(position: Int): String {
val sectionName: String? = when (PreferenceUtilKT.songSortOrder) { val sectionName: String? = when (PreferenceUtil.songSortOrder) {
SortOrder.SongSortOrder.SONG_A_Z, SortOrder.SongSortOrder.SONG_Z_A -> dataSet[position].title SortOrder.SongSortOrder.SONG_A_Z, SortOrder.SongSortOrder.SONG_Z_A -> dataSet[position].title
SortOrder.SongSortOrder.SONG_ALBUM -> dataSet[position].albumName SortOrder.SongSortOrder.SONG_ALBUM -> dataSet[position].albumName
SortOrder.SongSortOrder.SONG_ARTIST -> dataSet[position].artistName SortOrder.SongSortOrder.SONG_ARTIST -> dataSet[position].artistName

View file

@ -25,13 +25,13 @@ import android.util.TypedValue
import androidx.annotation.RequiresApi import androidx.annotation.RequiresApi
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil
@RequiresApi(Build.VERSION_CODES.N_MR1) @RequiresApi(Build.VERSION_CODES.N_MR1)
object AppShortcutIconGenerator { object AppShortcutIconGenerator {
fun generateThemedIcon(context: Context, iconId: Int): Icon { fun generateThemedIcon(context: Context, iconId: Int): Icon {
return if (PreferenceUtilKT.isColoredAppShortcuts) { return if (PreferenceUtil.isColoredAppShortcuts) {
generateUserThemedIcon(context, iconId) generateUserThemedIcon(context, iconId)
} else { } else {
generateDefaultThemedIcon(context, iconId) generateDefaultThemedIcon(context, iconId)

View file

@ -15,18 +15,12 @@
package code.name.monkey.retromusic.dagger.module package code.name.monkey.retromusic.dagger.module
import android.content.Context import android.content.Context
import code.name.monkey.retromusic.mvp.presenter.* import code.name.monkey.retromusic.mvp.presenter.GenreDetailsPresenter
import code.name.monkey.retromusic.mvp.presenter.AlbumDetailsPresenter.AlbumDetailsPresenterImpl
import code.name.monkey.retromusic.mvp.presenter.AlbumsPresenter.AlbumsPresenterImpl
import code.name.monkey.retromusic.mvp.presenter.ArtistDetailsPresenter.ArtistDetailsPresenterImpl
import code.name.monkey.retromusic.mvp.presenter.ArtistsPresenter.ArtistsPresenterImpl
import code.name.monkey.retromusic.mvp.presenter.GenreDetailsPresenter.GenreDetailsPresenterImpl import code.name.monkey.retromusic.mvp.presenter.GenreDetailsPresenter.GenreDetailsPresenterImpl
import code.name.monkey.retromusic.mvp.presenter.GenresPresenter.GenresPresenterImpl import code.name.monkey.retromusic.mvp.presenter.PlaylistSongsPresenter
import code.name.monkey.retromusic.mvp.presenter.HomePresenter.HomePresenterImpl
import code.name.monkey.retromusic.mvp.presenter.PlaylistSongsPresenter.PlaylistSongsPresenterImpl import code.name.monkey.retromusic.mvp.presenter.PlaylistSongsPresenter.PlaylistSongsPresenterImpl
import code.name.monkey.retromusic.mvp.presenter.PlaylistsPresenter.PlaylistsPresenterImpl import code.name.monkey.retromusic.mvp.presenter.SearchPresenter
import code.name.monkey.retromusic.mvp.presenter.SearchPresenter.SearchPresenterImpl import code.name.monkey.retromusic.mvp.presenter.SearchPresenter.SearchPresenterImpl
import code.name.monkey.retromusic.mvp.presenter.SongPresenter.SongPresenterImpl
import code.name.monkey.retromusic.providers.RepositoryImpl import code.name.monkey.retromusic.providers.RepositoryImpl
import code.name.monkey.retromusic.providers.interfaces.Repository import code.name.monkey.retromusic.providers.interfaces.Repository
import dagger.Module import dagger.Module
@ -44,58 +38,18 @@ class PresenterModule {
return RepositoryImpl(context) return RepositoryImpl(context)
} }
@Provides
fun providesAlbumsPresenter(presenter: AlbumsPresenterImpl): AlbumsPresenter {
return presenter
}
@Provides
fun providesAlbumDetailsPresenter(presenter: AlbumDetailsPresenterImpl): AlbumDetailsPresenter {
return presenter
}
@Provides
fun providesArtistDetailsPresenter(presenter: ArtistDetailsPresenterImpl): ArtistDetailsPresenter {
return presenter
}
@Provides
fun providesArtistsPresenter(presenter: ArtistsPresenterImpl): ArtistsPresenter {
return presenter
}
@Provides
fun providesGenresPresenter(presenter: GenresPresenterImpl): GenresPresenter {
return presenter
}
@Provides @Provides
fun providesGenreDetailsPresenter(presenter: GenreDetailsPresenterImpl): GenreDetailsPresenter { fun providesGenreDetailsPresenter(presenter: GenreDetailsPresenterImpl): GenreDetailsPresenter {
return presenter return presenter
} }
@Provides
fun providesHomePresenter(presenter: HomePresenterImpl): HomePresenter {
return presenter
}
@Provides @Provides
fun providesPlaylistSongPresenter(presenter: PlaylistSongsPresenterImpl): PlaylistSongsPresenter { fun providesPlaylistSongPresenter(presenter: PlaylistSongsPresenterImpl): PlaylistSongsPresenter {
return presenter return presenter
} }
@Provides
fun providesPlaylistsPresenter(presenter: PlaylistsPresenterImpl): PlaylistsPresenter {
return presenter
}
@Provides @Provides
fun providesSearchPresenter(presenter: SearchPresenterImpl): SearchPresenter { fun providesSearchPresenter(presenter: SearchPresenterImpl): SearchPresenter {
return presenter return presenter
} }
@Provides
fun providesSongPresenter(presenter: SongPresenterImpl): SongPresenter {
return presenter
}
} }

View file

@ -35,7 +35,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.service.MusicService.ACTION_PENDING_QUIT import code.name.monkey.retromusic.service.MusicService.ACTION_PENDING_QUIT
import code.name.monkey.retromusic.service.MusicService.ACTION_QUIT import code.name.monkey.retromusic.service.MusicService.ACTION_QUIT
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import com.afollestad.materialdialogs.DialogAction import com.afollestad.materialdialogs.DialogAction
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
@ -58,14 +58,14 @@ class SleepTimerDialog : DialogFragment() {
seekBar = layout.findViewById(R.id.seekBar) seekBar = layout.findViewById(R.id.seekBar)
timerDisplay = layout.findViewById(R.id.timerDisplay) timerDisplay = layout.findViewById(R.id.timerDisplay)
val finishMusic = PreferenceUtilKT.isSleepTimerFinishMusic val finishMusic = PreferenceUtil.isSleepTimerFinishMusic
shouldFinishLastSong.apply { shouldFinishLastSong.apply {
addAccentColor() addAccentColor()
isChecked = finishMusic isChecked = finishMusic
} }
seekBar.apply { seekBar.apply {
addAccentColor() addAccentColor()
seekArcProgress = PreferenceUtilKT.lastSleepTimerValue seekArcProgress = PreferenceUtil.lastSleepTimerValue
updateTimeDisplayTime() updateTimeDisplayTime()
seekBar.progress = seekArcProgress seekBar.progress = seekArcProgress
} }
@ -84,7 +84,7 @@ class SleepTimerDialog : DialogFragment() {
} }
override fun onStopTrackingTouch(seekBar: SeekBar) { override fun onStopTrackingTouch(seekBar: SeekBar) {
PreferenceUtilKT.lastSleepTimerValue = seekArcProgress PreferenceUtil.lastSleepTimerValue = seekArcProgress
} }
}) })
return MaterialAlertDialogBuilder( return MaterialAlertDialogBuilder(
@ -94,11 +94,11 @@ class SleepTimerDialog : DialogFragment() {
.setTitle(R.string.action_sleep_timer) .setTitle(R.string.action_sleep_timer)
.setView(layout) .setView(layout)
.setPositiveButton(R.string.action_set) { _, _ -> .setPositiveButton(R.string.action_set) { _, _ ->
PreferenceUtilKT.isSleepTimerFinishMusic = shouldFinishLastSong.isChecked PreferenceUtil.isSleepTimerFinishMusic = shouldFinishLastSong.isChecked
val minutes = seekArcProgress val minutes = seekArcProgress
val pi = makeTimerPendingIntent(PendingIntent.FLAG_CANCEL_CURRENT) val pi = makeTimerPendingIntent(PendingIntent.FLAG_CANCEL_CURRENT)
val nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000 val nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000
PreferenceUtilKT.nextSleepTimerElapsedRealTime = nextSleepTimerElapsedTime.toInt() PreferenceUtil.nextSleepTimerElapsedRealTime = nextSleepTimerElapsedTime.toInt()
val am = requireContext().getSystemService(Context.ALARM_SERVICE) as AlarmManager val am = requireContext().getSystemService(Context.ALARM_SERVICE) as AlarmManager
am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextSleepTimerElapsedTime, pi) am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextSleepTimerElapsedTime, pi)
@ -161,7 +161,7 @@ class SleepTimerDialog : DialogFragment() {
private inner class TimerUpdater internal constructor() : private inner class TimerUpdater internal constructor() :
CountDownTimer( CountDownTimer(
PreferenceUtilKT.nextSleepTimerElapsedRealTime - SystemClock.elapsedRealtime(), PreferenceUtil.nextSleepTimerElapsedRealTime - SystemClock.elapsedRealtime(),
1000 1000
) { ) {

View file

@ -5,7 +5,7 @@ import android.content.res.Configuration
import android.os.PowerManager import android.os.PowerManager
import androidx.annotation.IntegerRes import androidx.annotation.IntegerRes
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
fun Fragment.getIntRes(@IntegerRes int: Int): Int { fun Fragment.getIntRes(@IntegerRes int: Int): Int {
return resources.getInteger(int) return resources.getInteger(int)
@ -16,7 +16,7 @@ fun Context.getIntRes(@IntegerRes int: Int): Int {
} }
val Context.generalThemeValue val Context.generalThemeValue
get() = PreferenceUtilKT.getGeneralThemeValue(isSystemDarkModeEnabled()) get() = PreferenceUtil.getGeneralThemeValue(isSystemDarkModeEnabled())
fun Context.isSystemDarkModeEnabled(): Boolean { fun Context.isSystemDarkModeEnabled(): Boolean {

View file

@ -6,16 +6,15 @@ import code.name.monkey.retromusic.R
enum class AlbumCoverStyle( enum class AlbumCoverStyle(
@param:StringRes @field:StringRes @StringRes val titleRes: Int,
val titleRes: Int, @DrawableRes val drawableResId: Int,
@param:DrawableRes @field:DrawableRes val id: Int
val drawableResId: Int, val id: Int
) { ) {
CARD(R.string.card, R.drawable.np_blur_card, 4), Card(R.string.card, R.drawable.np_blur_card, 4),
CIRCLE(R.string.circular, R.drawable.np_circle, 2), Circle(R.string.circular, R.drawable.np_circle, 2),
FLAT(R.string.flat, R.drawable.np_flat, 1), Flat(R.string.flat, R.drawable.np_flat, 1),
FULL_CARD(R.string.full_card, R.drawable.np_adaptive, 6), FullCard(R.string.full_card, R.drawable.np_adaptive, 6),
FULL(R.string.full, R.drawable.np_full, 5), Full(R.string.full, R.drawable.np_full, 5),
MATERIAL(R.string.material, R.drawable.np_material, 3), Material(R.string.material, R.drawable.np_material, 3),
NORMAL(R.string.normal, R.drawable.np_normal, 0), Normal(R.string.normal, R.drawable.np_normal, 0),
} }

View file

@ -19,7 +19,7 @@ import code.name.monkey.retromusic.glide.SongGlideRequest
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
@ -64,9 +64,9 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
} else { } else {
actionNext.visibility = actionNext.visibility =
if (PreferenceUtilKT.isExtraControls) View.VISIBLE else View.GONE if (PreferenceUtil.isExtraControls) View.VISIBLE else View.GONE
actionPrevious.visibility = actionPrevious.visibility =
if (PreferenceUtilKT.isExtraControls) View.VISIBLE else View.GONE if (PreferenceUtil.isExtraControls) View.VISIBLE else View.GONE
} }
actionNext.setOnClickListener(this) actionNext.setOnClickListener(this)
actionPrevious.setOnClickListener(this) actionPrevious.setOnClickListener(this)
@ -104,7 +104,7 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
Glide.with(requireContext()), Glide.with(requireContext()),
MusicPlayerRemote.currentSong MusicPlayerRemote.currentSong
).checkIgnoreMediaStore(requireContext()) ).checkIgnoreMediaStore(requireContext())
.ignoreMediaStore(PreferenceUtilKT.isAllowedToDownloadMetadata()) .ignoreMediaStore(PreferenceUtil.isAllowedToDownloadMetadata())
.asBitmap() .asBitmap()
.build() .build()
.into(it) .into(it)

View file

@ -14,7 +14,7 @@ import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.applyColor import code.name.monkey.retromusic.extensions.applyColor
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.volume.AudioVolumeObserver import code.name.monkey.retromusic.volume.AudioVolumeObserver
import code.name.monkey.retromusic.volume.OnAudioVolumeChangedListener import code.name.monkey.retromusic.volume.OnAudioVolumeChangedListener
import kotlinx.android.synthetic.main.fragment_volume.* import kotlinx.android.synthetic.main.fragment_volume.*
@ -45,7 +45,7 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum
if (audioVolumeObserver == null) { if (audioVolumeObserver == null) {
audioVolumeObserver = AudioVolumeObserver(requireActivity()) audioVolumeObserver = AudioVolumeObserver(requireActivity())
} }
audioVolumeObserver!!.register(AudioManager.STREAM_MUSIC, this) audioVolumeObserver?.register(AudioManager.STREAM_MUSIC, this)
val audioManager = audioManager val audioManager = audioManager
if (audioManager != null) { if (audioManager != null) {
@ -67,9 +67,7 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum
override fun onDestroyView() { override fun onDestroyView() {
super.onDestroyView() super.onDestroyView()
if (audioVolumeObserver != null) { audioVolumeObserver?.unregister()
audioVolumeObserver!!.unregister()
}
} }
override fun onProgressChanged(seekBar: SeekBar, i: Int, b: Boolean) { override fun onProgressChanged(seekBar: SeekBar, i: Int, b: Boolean) {
@ -113,7 +111,7 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum
} }
private fun setPauseWhenZeroVolume(pauseWhenZeroVolume: Boolean) { private fun setPauseWhenZeroVolume(pauseWhenZeroVolume: Boolean) {
if (PreferenceUtilKT.isPauseOnZeroVolume) if (PreferenceUtil.isPauseOnZeroVolume)
if (MusicPlayerRemote.isPlaying && pauseWhenZeroVolume) if (MusicPlayerRemote.isPlaying && pauseWhenZeroVolume)
MusicPlayerRemote.pauseSong() MusicPlayerRemote.pauseSong()

View file

@ -9,7 +9,7 @@ import code.name.monkey.retromusic.adapter.album.AlbumAdapter
import code.name.monkey.retromusic.fragments.ReloadType import code.name.monkey.retromusic.fragments.ReloadType
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
class AlbumsFragment : class AlbumsFragment :
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(), AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
@ -50,27 +50,27 @@ class AlbumsFragment :
} }
override fun loadSortOrder(): String { override fun loadSortOrder(): String {
return PreferenceUtilKT.albumSortOrder return PreferenceUtil.albumSortOrder
} }
override fun saveSortOrder(sortOrder: String) { override fun saveSortOrder(sortOrder: String) {
PreferenceUtilKT.albumSortOrder = sortOrder PreferenceUtil.albumSortOrder = sortOrder
} }
override fun loadGridSize(): Int { override fun loadGridSize(): Int {
return PreferenceUtilKT.albumGridSize return PreferenceUtil.albumGridSize
} }
override fun saveGridSize(gridColumns: Int) { override fun saveGridSize(gridColumns: Int) {
PreferenceUtilKT.albumGridSize = gridColumns PreferenceUtil.albumGridSize = gridColumns
} }
override fun loadGridSizeLand(): Int { override fun loadGridSizeLand(): Int {
return PreferenceUtilKT.albumGridSizeLand return PreferenceUtil.albumGridSizeLand
} }
override fun saveGridSizeLand(gridColumns: Int) { override fun saveGridSizeLand(gridColumns: Int) {
PreferenceUtilKT.albumGridSizeLand = gridColumns PreferenceUtil.albumGridSizeLand = gridColumns
} }
override fun setSortOrder(sortOrder: String) { override fun setSortOrder(sortOrder: String) {
@ -78,11 +78,11 @@ class AlbumsFragment :
} }
override fun loadLayoutRes(): Int { override fun loadLayoutRes(): Int {
return PreferenceUtilKT.albumGridStyle return PreferenceUtil.albumGridStyle
} }
override fun saveLayoutRes(layoutRes: Int) { override fun saveLayoutRes(layoutRes: Int) {
PreferenceUtilKT.albumGridStyle = layoutRes PreferenceUtil.albumGridStyle = layoutRes
} }
override fun handleBackPress(): Boolean { override fun handleBackPress(): Boolean {

View file

@ -9,7 +9,7 @@ import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
import code.name.monkey.retromusic.fragments.ReloadType import code.name.monkey.retromusic.fragments.ReloadType
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
class ArtistsFragment : class ArtistsFragment :
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(), AbsLibraryPagerRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(),
@ -52,19 +52,19 @@ class ArtistsFragment :
} }
override fun loadGridSize(): Int { override fun loadGridSize(): Int {
return PreferenceUtilKT.artistGridSize return PreferenceUtil.artistGridSize
} }
override fun saveGridSize(gridColumns: Int) { override fun saveGridSize(gridColumns: Int) {
PreferenceUtilKT.artistGridSize = gridColumns PreferenceUtil.artistGridSize = gridColumns
} }
override fun loadGridSizeLand(): Int { override fun loadGridSizeLand(): Int {
return PreferenceUtilKT.artistGridSizeLand return PreferenceUtil.artistGridSizeLand
} }
override fun saveGridSizeLand(gridColumns: Int) { override fun saveGridSizeLand(gridColumns: Int) {
PreferenceUtilKT.artistGridSizeLand = gridColumns PreferenceUtil.artistGridSizeLand = gridColumns
} }
override fun setGridSize(gridSize: Int) { override fun setGridSize(gridSize: Int) {
@ -73,19 +73,19 @@ class ArtistsFragment :
} }
override fun loadSortOrder(): String { override fun loadSortOrder(): String {
return PreferenceUtilKT.artistSortOrder return PreferenceUtil.artistSortOrder
} }
override fun saveSortOrder(sortOrder: String) { override fun saveSortOrder(sortOrder: String) {
PreferenceUtilKT.artistSortOrder = sortOrder PreferenceUtil.artistSortOrder = sortOrder
} }
override fun loadLayoutRes(): Int { override fun loadLayoutRes(): Int {
return PreferenceUtilKT.artistGridStyle return PreferenceUtil.artistGridStyle
} }
override fun saveLayoutRes(layoutRes: Int) { override fun saveLayoutRes(layoutRes: Int) {
PreferenceUtilKT.artistGridStyle = layoutRes PreferenceUtil.artistGridStyle = layoutRes
} }
companion object { companion object {

View file

@ -8,7 +8,7 @@ import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.fragments.VolumeFragment import code.name.monkey.retromusic.fragments.VolumeFragment
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
/** /**
@ -63,7 +63,7 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(),
protected var volumeFragment: VolumeFragment? = null protected var volumeFragment: VolumeFragment? = null
private fun hideVolumeIfAvailable() { private fun hideVolumeIfAvailable() {
if (PreferenceUtilKT.isVolumeVisibilityMode) { if (PreferenceUtil.isVolumeVisibilityMode) {
childFragmentManager.beginTransaction() childFragmentManager.beginTransaction()
.replace(R.id.volumeFragmentContainer, VolumeFragment()).commit() .replace(R.id.volumeFragmentContainer, VolumeFragment()).commit()
childFragmentManager.executePendingTransactions() childFragmentManager.executePendingTransactions()

View file

@ -255,7 +255,7 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(),
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
if (PreferenceUtilKT.isFullScreenMode && if (PreferenceUtil.isFullScreenMode &&
view.findViewById<View>(R.id.status_bar) != null view.findViewById<View>(R.id.status_bar) != null
) { ) {
view.findViewById<View>(R.id.status_bar).visibility = View.GONE view.findViewById<View>(R.id.status_bar).visibility = View.GONE

View file

@ -34,7 +34,7 @@ import code.name.monkey.retromusic.model.smartplaylist.HistoryPlaylist
import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist import code.name.monkey.retromusic.model.smartplaylist.MyTopTracksPlaylist
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.abs_playlists.* import kotlinx.android.synthetic.main.abs_playlists.*
import kotlinx.android.synthetic.main.fragment_banner_home.* import kotlinx.android.synthetic.main.fragment_banner_home.*
@ -49,7 +49,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View? { ): View? {
return inflater.inflate( return inflater.inflate(
if (PreferenceUtilKT.isHomeBanner) R.layout.fragment_banner_home else R.layout.fragment_home, if (PreferenceUtil.isHomeBanner) R.layout.fragment_banner_home else R.layout.fragment_home,
viewGroup, viewGroup,
false false
) )
@ -112,7 +112,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
NavigationUtil.goToUserInfo(requireActivity(), options) NavigationUtil.goToUserInfo(requireActivity(), options)
} }
titleWelcome?.text = titleWelcome?.text =
String.format("%s", PreferenceUtilKT.userName) String.format("%s", PreferenceUtil.userName)
homeAdapter = HomeAdapter(mainActivity, displayMetrics) homeAdapter = HomeAdapter(mainActivity, displayMetrics)
recyclerView.apply { recyclerView.apply {

View file

@ -68,7 +68,7 @@ import code.name.monkey.retromusic.misc.WrappedAsyncTaskLoader;
import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.util.DensityUtil; import code.name.monkey.retromusic.util.DensityUtil;
import code.name.monkey.retromusic.util.FileUtil; import code.name.monkey.retromusic.util.FileUtil;
import code.name.monkey.retromusic.util.PreferenceUtilKT; import code.name.monkey.retromusic.util.PreferenceUtil;
import code.name.monkey.retromusic.util.RetroColorUtil; import code.name.monkey.retromusic.util.RetroColorUtil;
import code.name.monkey.retromusic.util.ThemedFastScroller; import code.name.monkey.retromusic.util.ThemedFastScroller;
import code.name.monkey.retromusic.views.BreadCrumbLayout; import code.name.monkey.retromusic.views.BreadCrumbLayout;
@ -134,7 +134,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
} }
public static FoldersFragment newInstance(Context context) { public static FoldersFragment newInstance(Context context) {
return newInstance(PreferenceUtilKT.INSTANCE.getStartDirectory()); return newInstance(PreferenceUtil.INSTANCE.getStartDirectory());
} }
private static File tryGetCanonicalFile(File file) { private static File tryGetCanonicalFile(File file) {
@ -238,7 +238,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
getFileComparator())); getFileComparator()));
return true; return true;
case R.id.action_set_as_start_directory: case R.id.action_set_as_start_directory:
PreferenceUtilKT.INSTANCE.setStartDirectory(file); PreferenceUtil.INSTANCE.setStartDirectory(file);
Toast.makeText(getActivity(), Toast.makeText(getActivity(),
String.format(getString(R.string.new_start_directory), file.getPath()), String.format(getString(R.string.new_start_directory), file.getPath()),
Toast.LENGTH_SHORT).show(); Toast.LENGTH_SHORT).show();
@ -341,7 +341,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.action_go_to_start_directory: case R.id.action_go_to_start_directory:
setCrumb(new BreadCrumbLayout.Crumb( setCrumb(new BreadCrumbLayout.Crumb(
tryGetCanonicalFile(PreferenceUtilKT.INSTANCE.getStartDirectory())), true); tryGetCanonicalFile(PreferenceUtil.INSTANCE.getStartDirectory())), true);
return true; return true;
case R.id.action_scan: case R.id.action_scan:
BreadCrumbLayout.Crumb crumb = getActiveCrumb(); BreadCrumbLayout.Crumb crumb = getActiveCrumb();

View file

@ -14,7 +14,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.transform.CarousalPagerTransformer import code.name.monkey.retromusic.transform.CarousalPagerTransformer
import code.name.monkey.retromusic.transform.ParallaxPagerTransformer import code.name.monkey.retromusic.transform.ParallaxPagerTransformer
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_player_album_cover.* import kotlinx.android.synthetic.main.fragment_player_album_cover.*
@ -46,14 +46,14 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
viewPager.addOnPageChangeListener(this) viewPager.addOnPageChangeListener(this)
val nps = PreferenceUtilKT.nowPlayingScreen val nps = PreferenceUtil.nowPlayingScreen
val metrics = resources.displayMetrics val metrics = resources.displayMetrics
val ratio = metrics.heightPixels.toFloat() / metrics.widthPixels.toFloat() val ratio = metrics.heightPixels.toFloat() / metrics.widthPixels.toFloat()
if (nps == Full || nps == Classic || nps == Fit || nps == Gradient) { if (nps == Full || nps == Classic || nps == Fit || nps == Gradient) {
viewPager.offscreenPageLimit = 2 viewPager.offscreenPageLimit = 2
} else if (PreferenceUtilKT.isCarouselEffect) { } else if (PreferenceUtil.isCarouselEffect) {
viewPager.clipToPadding = false viewPager.clipToPadding = false
val padding = val padding =
if (ratio >= 1.777f) { if (ratio >= 1.777f) {
@ -68,7 +68,7 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
viewPager.offscreenPageLimit = 2 viewPager.offscreenPageLimit = 2
viewPager.setPageTransformer( viewPager.setPageTransformer(
true, true,
PreferenceUtilKT.albumCoverTransform PreferenceUtil.albumCoverTransform
) )
} }
} }

View file

@ -26,7 +26,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.*
@ -67,7 +67,7 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
} }
private fun updateSong() { private fun updateSong() {
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo?.text = getSongInfo(MusicPlayerRemote.currentSong) songInfo?.text = getSongInfo(MusicPlayerRemote.currentSong)
songInfo.show() songInfo.show()
} else { } else {
@ -131,7 +131,7 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
updatePrevNextColor() updatePrevNextColor()
updatePlayPauseColor() updatePlayPauseColor()
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { val colorFinal = if (PreferenceUtil.isAdaptiveColor) {
color.primaryTextColor color.primaryTextColor
} else { } else {
ThemeStore.accentColor(requireContext()) ThemeStore.accentColor(requireContext())

View file

@ -25,7 +25,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.*
@ -69,7 +69,7 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
title.text = song.title title.text = song.title
text.text = String.format("%s • %s", song.artistName, song.albumName) text.text = String.format("%s • %s", song.artistName, song.albumName)
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.show() songInfo.show()
songInfo?.text = getSongInfo(song) songInfo?.text = getSongInfo(song)
} else { } else {

View file

@ -25,7 +25,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.*
import kotlinx.android.synthetic.main.media_button.* import kotlinx.android.synthetic.main.media_button.*
@ -69,7 +69,7 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.text = getSongInfo(MusicPlayerRemote.currentSong) songInfo.text = getSongInfo(MusicPlayerRemote.currentSong)
songInfo.show() songInfo.show()
} else { } else {
@ -129,7 +129,7 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
updatePlayPauseColor() updatePlayPauseColor()
updateProgressTextColor() updateProgressTextColor()
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { val colorFinal = if (PreferenceUtil.isAdaptiveColor) {
color.primaryTextColor color.primaryTextColor
} else { } else {
ThemeStore.accentColor(requireContext()).ripAlpha() ThemeStore.accentColor(requireContext()).ripAlpha()

View file

@ -23,7 +23,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.*
@ -114,7 +114,7 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
} }
private fun updateSong() { private fun updateSong() {
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.text = getSongInfo(MusicPlayerRemote.currentSong) songInfo.text = getSongInfo(MusicPlayerRemote.currentSong)
songInfo.show() songInfo.show()
} else { } else {

View file

@ -44,7 +44,7 @@ import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper.Callback
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
@ -196,7 +196,7 @@ class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChanged
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.text = getSongInfo(song) songInfo.text = getSongInfo(song)
songInfo.show() songInfo.show()
} else { } else {

View file

@ -1,6 +1,7 @@
package code.name.monkey.retromusic.fragments.player.classic package code.name.monkey.retromusic.fragments.player.classic
import android.animation.ObjectAnimator import android.animation.ObjectAnimator
import android.annotation.SuppressLint
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.graphics.PorterDuff import android.graphics.PorterDuff
@ -37,7 +38,7 @@ import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
@ -85,7 +86,6 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
override fun onStateChanged(bottomSheet: View, newState: Int) { override fun onStateChanged(bottomSheet: View, newState: Int) {
val activity = requireActivity() as AbsSlidingMusicPanelActivity val activity = requireActivity() as AbsSlidingMusicPanelActivity
val isDark = ATHUtil.isWindowBackgroundDark(requireContext());
when (newState) { when (newState) {
BottomSheetBehavior.STATE_EXPANDED, BottomSheetBehavior.STATE_EXPANDED,
BottomSheetBehavior.STATE_DRAGGING -> { BottomSheetBehavior.STATE_DRAGGING -> {
@ -115,6 +115,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
return inflater.inflate(R.layout.fragment_classic_player, container, false) return inflater.inflate(R.layout.fragment_classic_player, container, false)
} }
@SuppressLint("ClickableViewAccessibility")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
setupPanel() setupPanel()
@ -155,7 +156,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
} }
private fun hideVolumeIfAvailable() { private fun hideVolumeIfAvailable() {
if (PreferenceUtilKT.isVolumeVisibilityMode) { if (PreferenceUtil.isVolumeVisibilityMode) {
childFragmentManager.beginTransaction() childFragmentManager.beginTransaction()
.replace(R.id.volumeFragmentContainer, VolumeFragment.newInstance()) .replace(R.id.volumeFragmentContainer, VolumeFragment.newInstance())
.commit() .commit()
@ -186,7 +187,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.text = getSongInfo(song) songInfo.text = getSongInfo(song)
songInfo.show() songInfo.show()
} else { } else {

View file

@ -23,7 +23,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.*
@ -69,7 +69,7 @@ class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.text = getSongInfo(song) songInfo.text = getSongInfo(song)
songInfo.show() songInfo.show()
} else { } else {

View file

@ -27,7 +27,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.* import kotlinx.android.synthetic.main.fragment_fit_playback_controls.*
@ -72,7 +72,7 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
val song = MusicPlayerRemote.currentSong val song = MusicPlayerRemote.currentSong
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.text = getSongInfo(song) songInfo.text = getSongInfo(song)
songInfo.show() songInfo.show()
} else { } else {
@ -127,7 +127,7 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
MaterialValueHelper.getPrimaryDisabledTextColor(activity, false) MaterialValueHelper.getPrimaryDisabledTextColor(activity, false)
} }
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { val colorFinal = if (PreferenceUtil.isAdaptiveColor) {
color.primaryTextColor color.primaryTextColor
} else { } else {
ThemeStore.accentColor(requireContext()).ripAlpha() ThemeStore.accentColor(requireContext()).ripAlpha()

View file

@ -28,7 +28,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.*
@ -96,7 +96,7 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
} }
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { val colorFinal = if (PreferenceUtil.isAdaptiveColor) {
color.primaryTextColor color.primaryTextColor
} else { } else {
ThemeStore.accentColor(requireContext()).ripAlpha() ThemeStore.accentColor(requireContext()).ripAlpha()
@ -166,7 +166,7 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
val song = MusicPlayerRemote.currentSong val song = MusicPlayerRemote.currentSong
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.text = getSongInfo(song) songInfo.text = getSongInfo(song)
songInfo.show() songInfo.show()
} else { } else {

View file

@ -18,7 +18,7 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import code.name.monkey.retromusic.views.DrawableGradient import code.name.monkey.retromusic.views.DrawableGradient
@ -99,7 +99,7 @@ class FlatPlayerFragment : AbsPlayerFragment() {
override fun toolbarIconColor(): Int { override fun toolbarIconColor(): Int {
val isLight = ColorUtil.isColorLight(paletteColor) val isLight = ColorUtil.isColorLight(paletteColor)
return if (PreferenceUtilKT.isAdaptiveColor) return if (PreferenceUtil.isAdaptiveColor)
MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight) MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight)
else else
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal) ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
@ -110,12 +110,12 @@ class FlatPlayerFragment : AbsPlayerFragment() {
controlsFragment.setColor(color) controlsFragment.setColor(color)
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
val isLight = ColorUtil.isColorLight(color.backgroundColor) val isLight = ColorUtil.isColorLight(color.backgroundColor)
val iconColor = if (PreferenceUtilKT.isAdaptiveColor) val iconColor = if (PreferenceUtil.isAdaptiveColor)
MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight) MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight)
else else
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal) ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, iconColor, requireActivity()) ToolbarContentTintHelper.colorizeToolbar(playerToolbar, iconColor, requireActivity())
if (PreferenceUtilKT.isAdaptiveColor) { if (PreferenceUtil.isAdaptiveColor) {
colorize(color.backgroundColor) colorize(color.backgroundColor)
} }
} }

View file

@ -29,7 +29,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_full_player_controls.* import kotlinx.android.synthetic.main.fragment_full_player_controls.*
@ -129,7 +129,7 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
updateIsFavorite() updateIsFavorite()
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.text = getSongInfo(song) songInfo.text = getSongInfo(song)
songInfo.show() songInfo.show()
} else { } else {

View file

@ -1,6 +1,7 @@
package code.name.monkey.retromusic.fragments.player.gradient package code.name.monkey.retromusic.fragments.player.gradient
import android.animation.ObjectAnimator import android.animation.ObjectAnimator
import android.annotation.SuppressLint
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.graphics.PorterDuff import android.graphics.PorterDuff
@ -18,7 +19,6 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.ViewCompat import androidx.core.view.ViewCompat
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
@ -38,8 +38,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
@ -82,7 +81,6 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
override fun onStateChanged(bottomSheet: View, newState: Int) { override fun onStateChanged(bottomSheet: View, newState: Int) {
val activity = requireActivity() as AbsSlidingMusicPanelActivity val activity = requireActivity() as AbsSlidingMusicPanelActivity
val isDark = ATHUtil.isWindowBackgroundDark(requireContext());
when (newState) { when (newState) {
BottomSheetBehavior.STATE_EXPANDED, BottomSheetBehavior.STATE_EXPANDED,
BottomSheetBehavior.STATE_DRAGGING -> { BottomSheetBehavior.STATE_DRAGGING -> {
@ -145,6 +143,7 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
setupFavourite() setupFavourite()
} }
@SuppressLint("ClickableViewAccessibility")
private fun setupSheet() { private fun setupSheet() {
getQueuePanel().addBottomSheetCallback(bottomSheetCallbackList) getQueuePanel().addBottomSheetCallback(bottomSheetCallbackList)
playerQueueSheet.setOnTouchListener { _, _ -> playerQueueSheet.setOnTouchListener { _, _ ->
@ -205,7 +204,7 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
callbacks?.onPaletteColorChanged() callbacks?.onPaletteColorChanged()
mask.backgroundTintList = ColorStateList.valueOf(color.backgroundColor) mask.backgroundTintList = ColorStateList.valueOf(color.backgroundColor)
colorBackground.setBackgroundColor(color.backgroundColor) colorBackground.setBackgroundColor(color.backgroundColor)
container.setBackgroundColor(ColorUtil.darkenColor(color.backgroundColor)) playerQueueSheet.setBackgroundColor(ColorUtil.darkenColor(color.backgroundColor))
lastPlaybackControlsColor = color.primaryTextColor lastPlaybackControlsColor = color.primaryTextColor
lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(color.primaryTextColor, 0.3f) lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(color.primaryTextColor, 0.3f)
@ -244,7 +243,7 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
} }
private fun hideVolumeIfAvailable() { private fun hideVolumeIfAvailable() {
if (PreferenceUtilKT.isVolumeVisibilityMode) { if (PreferenceUtil.isVolumeVisibilityMode) {
childFragmentManager.beginTransaction() childFragmentManager.beginTransaction()
.replace(R.id.volumeFragmentContainer, VolumeFragment.newInstance()) .replace(R.id.volumeFragmentContainer, VolumeFragment.newInstance())
.commit() .commit()
@ -285,7 +284,7 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
updateLabel() updateLabel()
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.text = getSongInfo(song) songInfo.text = getSongInfo(song)
songInfo.show() songInfo.show()
} else { } else {
@ -482,12 +481,13 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong()) songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong()) songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
} }
@SuppressLint("StaticFieldLeak")
private fun updateFavorite() { private fun updateFavorite() {
if (updateIsFavoriteTask != null) { if (updateIsFavoriteTask != null) {
updateIsFavoriteTask?.cancel(false) updateIsFavoriteTask?.cancel(false)
} }
updateIsFavoriteTask = object : AsyncTask<Song, Void, Boolean>() { updateIsFavoriteTask =
object : AsyncTask<Song, Void, Boolean>() {
override fun doInBackground(vararg params: Song): Boolean? { override fun doInBackground(vararg params: Song): Boolean? {
val activity = activity val activity = activity
return if (activity != null) { return if (activity != null) {

View file

@ -39,7 +39,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.* import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.*
@ -126,7 +126,7 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
} }
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { val colorFinal = if (PreferenceUtil.isAdaptiveColor) {
color.primaryTextColor color.primaryTextColor
} else { } else {
textColorSecondary() textColorSecondary()

View file

@ -20,7 +20,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_material_playback_controls.* import kotlinx.android.synthetic.main.fragment_material_playback_controls.*
@ -57,7 +57,7 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.text = getSongInfo(song) songInfo.text = getSongInfo(song)
songInfo.show() songInfo.show()
} else { } else {
@ -114,7 +114,7 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
updateRepeatState() updateRepeatState()
updateShuffleState() updateShuffleState()
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { val colorFinal = if (PreferenceUtil.isAdaptiveColor) {
lastPlaybackControlsColor lastPlaybackControlsColor
} else { } else {
textColorSecondary() textColorSecondary()

View file

@ -16,7 +16,7 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import code.name.monkey.retromusic.views.DrawableGradient import code.name.monkey.retromusic.views.DrawableGradient
@ -86,7 +86,7 @@ class PlayerFragment : AbsPlayerFragment() {
requireActivity() requireActivity()
) )
if (PreferenceUtilKT.isAdaptiveColor) { if (PreferenceUtil.isAdaptiveColor) {
colorize(color.backgroundColor) colorize(color.backgroundColor)
} }
} }

View file

@ -27,7 +27,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_player_playback_controls.*
@ -78,7 +78,7 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
} }
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { val colorFinal = if (PreferenceUtil.isAdaptiveColor) {
color.primaryTextColor color.primaryTextColor
} else { } else {
ThemeStore.accentColor(requireContext()) ThemeStore.accentColor(requireContext())
@ -105,7 +105,7 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.text = getSongInfo(song) songInfo.text = getSongInfo(song)
songInfo.show() songInfo.show()
} else { } else {

View file

@ -37,7 +37,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_peak_control_player.* import kotlinx.android.synthetic.main.fragment_peak_control_player.*
@ -90,7 +90,7 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment() {
override fun setColor(color: MediaNotificationProcessor) { override fun setColor(color: MediaNotificationProcessor) {
val controlsColor = val controlsColor =
if (PreferenceUtilKT.isAdaptiveColor) { if (PreferenceUtil.isAdaptiveColor) {
color.primaryTextColor color.primaryTextColor
} else { } else {
ThemeStore.accentColor(requireContext()) ThemeStore.accentColor(requireContext())

View file

@ -27,7 +27,7 @@ import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_peak_player.* import kotlinx.android.synthetic.main.fragment_peak_player.*
@ -114,7 +114,7 @@ class PeakPlayerFragment : AbsPlayerFragment() {
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.text = getSongInfo(song) songInfo.text = getSongInfo(song)
songInfo.show() songInfo.show()
} else { } else {

View file

@ -27,7 +27,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.*
import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.nextButton import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.nextButton
@ -74,7 +74,7 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() {
} }
private fun updateSong() { private fun updateSong() {
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.text = getSongInfo(MusicPlayerRemote.currentSong) songInfo.text = getSongInfo(MusicPlayerRemote.currentSong)
songInfo.show() songInfo.show()
} else { } else {
@ -157,7 +157,7 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() {
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
} }
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { val colorFinal = if (PreferenceUtil.isAdaptiveColor) {
color.primaryTextColor color.primaryTextColor
} else { } else {
ThemeStore.accentColor(requireContext()) ThemeStore.accentColor(requireContext())

View file

@ -21,7 +21,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.* import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.*
@ -156,7 +156,7 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
title.text = song.title title.text = song.title
text.text = song.artistName text.text = song.artistName
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.text = getSongInfo(song) songInfo.text = getSongInfo(song)
songInfo.show() songInfo.show()
} else { } else {
@ -213,7 +213,7 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
} }
val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { val colorFinal = if (PreferenceUtil.isAdaptiveColor) {
color.primaryTextColor color.primaryTextColor
} else { } else {
ThemeStore.accentColor(requireContext()) ThemeStore.accentColor(requireContext())

View file

@ -21,7 +21,7 @@ import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
@ -103,7 +103,7 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
title.text = song.title title.text = song.title
text.text = String.format("%s \nby - %s", song.albumName, song.artistName) text.text = String.format("%s \nby - %s", song.albumName, song.artistName)
if (PreferenceUtilKT.isSongInfo) { if (PreferenceUtil.isSongInfo) {
songInfo.text = getSongInfo(song) songInfo.text = getSongInfo(song)
songInfo.show() songInfo.show()
} else { } else {

View file

@ -22,7 +22,7 @@ import androidx.preference.Preference
import androidx.preference.TwoStatePreference import androidx.preference.TwoStatePreference
import code.name.monkey.retromusic.CLASSIC_NOTIFICATION import code.name.monkey.retromusic.CLASSIC_NOTIFICATION
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
/** /**
@ -47,10 +47,10 @@ class NotificationSettingsFragment : AbsSettingsFragment(),
classicNotification?.isVisible = false classicNotification?.isVisible = false
} else { } else {
classicNotification?.apply { classicNotification?.apply {
isChecked = PreferenceUtilKT.isClassicNotification isChecked = PreferenceUtil.isClassicNotification
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
// Save preference // Save preference
PreferenceUtilKT.isClassicNotification = newValue as Boolean PreferenceUtil.isClassicNotification = newValue as Boolean
invalidateSettings() invalidateSettings()
true true
} }
@ -59,12 +59,12 @@ class NotificationSettingsFragment : AbsSettingsFragment(),
val coloredNotification: TwoStatePreference? = findPreference("colored_notification") val coloredNotification: TwoStatePreference? = findPreference("colored_notification")
if (VERSION.SDK_INT >= VERSION_CODES.O) { if (VERSION.SDK_INT >= VERSION_CODES.O) {
coloredNotification?.isEnabled = PreferenceUtilKT.isClassicNotification coloredNotification?.isEnabled = PreferenceUtil.isClassicNotification
} else { } else {
coloredNotification?.apply { coloredNotification?.apply {
isChecked = PreferenceUtilKT.isColoredNotification isChecked = PreferenceUtil.isColoredNotification
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
PreferenceUtilKT.isColoredNotification = newValue as Boolean PreferenceUtil.isColoredNotification = newValue as Boolean
true true
} }
} }
@ -73,12 +73,12 @@ class NotificationSettingsFragment : AbsSettingsFragment(),
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
PreferenceUtilKT.registerOnSharedPreferenceChangedListener(this) PreferenceUtil.registerOnSharedPreferenceChangedListener(this)
} }
override fun onDestroyView() { override fun onDestroyView() {
super.onDestroyView() super.onDestroyView()
PreferenceUtilKT.unregisterOnSharedPreferenceChangedListener(this) PreferenceUtil.unregisterOnSharedPreferenceChangedListener(this)
} }
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {

View file

@ -20,7 +20,7 @@ import android.view.View
import androidx.preference.Preference import androidx.preference.Preference
import androidx.preference.TwoStatePreference import androidx.preference.TwoStatePreference
import code.name.monkey.retromusic.* import code.name.monkey.retromusic.*
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
/** /**
* @author Hemanth S (h4h13). * @author Hemanth S (h4h13).
@ -49,17 +49,17 @@ class NowPlayingSettingsFragment : AbsSettingsFragment(),
private fun updateAlbumCoverStyleSummary() { private fun updateAlbumCoverStyleSummary() {
val preference: Preference? = findPreference(ALBUM_COVER_STYLE) val preference: Preference? = findPreference(ALBUM_COVER_STYLE)
preference?.setSummary(PreferenceUtilKT.albumCoverStyle.titleRes) preference?.setSummary(PreferenceUtil.albumCoverStyle.titleRes)
} }
private fun updateNowPlayingScreenSummary() { private fun updateNowPlayingScreenSummary() {
val preference: Preference? = findPreference(NOW_PLAYING_SCREEN_ID) val preference: Preference? = findPreference(NOW_PLAYING_SCREEN_ID)
preference?.setSummary(PreferenceUtilKT.nowPlayingScreen.titleRes) preference?.setSummary(PreferenceUtil.nowPlayingScreen.titleRes)
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
PreferenceUtilKT.registerOnSharedPreferenceChangedListener(this) PreferenceUtil.registerOnSharedPreferenceChangedListener(this)
val preference: Preference? = findPreference("album_cover_transform") val preference: Preference? = findPreference("album_cover_transform")
preference?.setOnPreferenceChangeListener { albumPrefs, newValue -> preference?.setOnPreferenceChangeListener { albumPrefs, newValue ->
setSummary(albumPrefs, newValue) setSummary(albumPrefs, newValue)
@ -69,7 +69,7 @@ class NowPlayingSettingsFragment : AbsSettingsFragment(),
override fun onDestroyView() { override fun onDestroyView() {
super.onDestroyView() super.onDestroyView()
PreferenceUtilKT.unregisterOnSharedPreferenceChangedListener(this) PreferenceUtil.unregisterOnSharedPreferenceChangedListener(this)
} }
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {

View file

@ -27,7 +27,7 @@ import code.name.monkey.retromusic.App
import code.name.monkey.retromusic.DESATURATED_COLOR import code.name.monkey.retromusic.DESATURATED_COLOR
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager import code.name.monkey.retromusic.appshortcuts.DynamicShortcutManager
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import com.afollestad.materialdialogs.color.ColorChooserDialog import com.afollestad.materialdialogs.color.ColorChooserDialog
/** /**
@ -45,7 +45,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
ThemeStore.markChanged(requireContext()) ThemeStore.markChanged(requireContext())
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
requireActivity().setTheme(PreferenceUtilKT.themeResFromPrefValue(theme)) requireActivity().setTheme(PreferenceUtil.themeResFromPrefValue(theme))
DynamicShortcutManager(requireContext()).updateDynamicShortcuts() DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
} }
requireActivity().recreate() requireActivity().recreate()
@ -74,7 +74,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
} }
ThemeStore.markChanged(requireContext()) ThemeStore.markChanged(requireContext())
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
requireActivity().setTheme(PreferenceUtilKT.themeResFromPrefValue("black")) requireActivity().setTheme(PreferenceUtil.themeResFromPrefValue("black"))
DynamicShortcutManager(requireContext()).updateDynamicShortcuts() DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
} }
requireActivity().recreate() requireActivity().recreate()
@ -88,7 +88,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
.edit() .edit()
.putBoolean("desaturated_color", desaturated) .putBoolean("desaturated_color", desaturated)
.apply() .apply()
PreferenceUtilKT.isDesaturatedColor = desaturated PreferenceUtil.isDesaturatedColor = desaturated
requireActivity().recreate() requireActivity().recreate()
true true
} }
@ -98,9 +98,9 @@ class ThemeSettingsFragment : AbsSettingsFragment() {
if (!VersionUtils.hasNougatMR()) { if (!VersionUtils.hasNougatMR()) {
colorAppShortcuts.isVisible = false colorAppShortcuts.isVisible = false
} else { } else {
colorAppShortcuts.isChecked = PreferenceUtilKT.isColoredAppShortcuts colorAppShortcuts.isChecked = PreferenceUtil.isColoredAppShortcuts
colorAppShortcuts.setOnPreferenceChangeListener { _, newValue -> colorAppShortcuts.setOnPreferenceChangeListener { _, newValue ->
PreferenceUtilKT.isColoredAppShortcuts = newValue as Boolean PreferenceUtil.isColoredAppShortcuts = newValue as Boolean
DynamicShortcutManager(requireContext()).updateDynamicShortcuts() DynamicShortcutManager(requireContext()).updateDynamicShortcuts()
true true
} }

View file

@ -10,14 +10,11 @@ import code.name.monkey.retromusic.adapter.song.SongAdapter
import code.name.monkey.retromusic.fragments.ReloadType import code.name.monkey.retromusic.fragments.ReloadType
import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment import code.name.monkey.retromusic.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.mvp.presenter.SongView
import code.name.monkey.retromusic.util.PreferenceUtilKT
import java.util.*
class SongsFragment : class SongsFragment :
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>(), AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>(),
SongView, MainActivityFragmentCallbacks { MainActivityFragmentCallbacks {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
mainActivity.libraryViewModel.allSongs() mainActivity.libraryViewModel.allSongs()
@ -57,49 +54,41 @@ class SongsFragment :
) )
} }
override fun songs(songs: List<Song>) {
adapter?.swapDataSet(songs)
}
override fun loadGridSize(): Int { override fun loadGridSize(): Int {
return PreferenceUtilKT.songGridSize return PreferenceUtil.songGridSize
} }
override fun saveGridSize(gridColumns: Int) { override fun saveGridSize(gridColumns: Int) {
PreferenceUtilKT.songGridSize = gridColumns PreferenceUtil.songGridSize = gridColumns
} }
override fun loadGridSizeLand(): Int { override fun loadGridSizeLand(): Int {
return PreferenceUtilKT.songGridSizeLand return PreferenceUtil.songGridSizeLand
} }
override fun saveGridSizeLand(gridColumns: Int) { override fun saveGridSizeLand(gridColumns: Int) {
PreferenceUtilKT.songGridSizeLand = gridColumns PreferenceUtil.songGridSizeLand = gridColumns
} }
override fun setGridSize(gridSize: Int) { override fun setGridSize(gridSize: Int) {
adapter?.notifyDataSetChanged() adapter?.notifyDataSetChanged()
} }
override fun showEmptyView() {
adapter?.swapDataSet(ArrayList())
}
override fun loadSortOrder(): String { override fun loadSortOrder(): String {
return PreferenceUtilKT.songSortOrder return PreferenceUtil.songSortOrder
} }
override fun saveSortOrder(sortOrder: String) { override fun saveSortOrder(sortOrder: String) {
PreferenceUtilKT.songSortOrder = sortOrder PreferenceUtil.songSortOrder = sortOrder
} }
@LayoutRes @LayoutRes
override fun loadLayoutRes(): Int { override fun loadLayoutRes(): Int {
return PreferenceUtilKT.songGridStyle return PreferenceUtil.songGridStyle
} }
override fun saveLayoutRes(@LayoutRes layoutRes: Int) { override fun saveLayoutRes(@LayoutRes layoutRes: Int) {
PreferenceUtilKT.songGridStyle = layoutRes PreferenceUtil.songGridStyle = layoutRes
} }
override fun setSortOrder(sortOrder: String) { override fun setSortOrder(sortOrder: String) {

View file

@ -20,7 +20,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteTranscoder;
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper; import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper;
import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.util.MusicUtil; import code.name.monkey.retromusic.util.MusicUtil;
import code.name.monkey.retromusic.util.PreferenceUtilKT; import code.name.monkey.retromusic.util.PreferenceUtil;
public class AlbumGlideRequest { public class AlbumGlideRequest {
private static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.NONE; private static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.NONE;
@ -70,7 +70,7 @@ public class AlbumGlideRequest {
@NonNull @NonNull
public Builder checkIgnoreMediaStore(@NonNull Context context) { public Builder checkIgnoreMediaStore(@NonNull Context context) {
return ignoreMediaStore(PreferenceUtilKT.INSTANCE.isIgnoreMediaStoreArtwork()); return ignoreMediaStore(PreferenceUtil.INSTANCE.isIgnoreMediaStoreArtwork());
} }
@NonNull @NonNull

View file

@ -34,7 +34,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteTranscoder;
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper; import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper;
import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.util.MusicUtil; import code.name.monkey.retromusic.util.MusicUtil;
import code.name.monkey.retromusic.util.PreferenceUtilKT; import code.name.monkey.retromusic.util.PreferenceUtil;
/** /**
* Created by hemanths on 2019-09-15. * Created by hemanths on 2019-09-15.
@ -88,7 +88,7 @@ public class SongGlideRequest {
@NonNull @NonNull
public Builder checkIgnoreMediaStore(@NonNull Context context) { public Builder checkIgnoreMediaStore(@NonNull Context context) {
return ignoreMediaStore(PreferenceUtilKT.INSTANCE.isIgnoreMediaStoreArtwork()); return ignoreMediaStore(PreferenceUtil.INSTANCE.isIgnoreMediaStoreArtwork());
} }
@NonNull @NonNull

View file

@ -18,7 +18,7 @@ import android.content.Context
import code.name.monkey.retromusic.deezer.Data import code.name.monkey.retromusic.deezer.Data
import code.name.monkey.retromusic.deezer.DeezerApiService import code.name.monkey.retromusic.deezer.DeezerApiService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import com.bumptech.glide.Priority import com.bumptech.glide.Priority
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader
import com.bumptech.glide.load.data.DataFetcher import com.bumptech.glide.load.data.DataFetcher
@ -63,7 +63,7 @@ class ArtistImageFetcher(
override fun loadData(priority: Priority?): InputStream? { override fun loadData(priority: Priority?): InputStream? {
if (!MusicUtil.isArtistNameUnknown(model.artistName) && if (!MusicUtil.isArtistNameUnknown(model.artistName) &&
PreferenceUtilKT.isAllowedToDownloadMetadata() PreferenceUtil.isAllowedToDownloadMetadata()
) { ) {
val artists = model.artistName.split(",") val artists = model.artistName.split(",")
val response = deezerApiService.getArtistImage(artists[0]).execute() val response = deezerApiService.getArtistImage(artists[0]).execute()

View file

@ -98,7 +98,7 @@ class EqualizerHelper private constructor() : EqualizerInterface {
} }
companion object { companion object {
private val TAG = "EqualizerHelper" private const val TAG = "EqualizerHelper"
@Volatile @Volatile
private var ourInstance: EqualizerHelper? = null private var ourInstance: EqualizerHelper? = null

View file

@ -30,7 +30,7 @@ import code.name.monkey.retromusic.loaders.SongLoader
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import java.io.File import java.io.File
import java.util.* import java.util.*
@ -213,7 +213,7 @@ object MusicPlayerRemote {
) && musicService != null ) && musicService != null
) { ) {
musicService?.openQueue(queue, startPosition, startPlaying) musicService?.openQueue(queue, startPosition, startPlaying)
if (PreferenceUtilKT.isShuffleModeOn) if (PreferenceUtil.isShuffleModeOn)
setShuffleMode(MusicService.SHUFFLE_MODE_NONE) setShuffleMode(MusicService.SHUFFLE_MODE_NONE)
} }
} }

View file

@ -19,7 +19,7 @@ import android.provider.MediaStore.Audio.AudioColumns
import code.name.monkey.retromusic.helper.SortOrder import code.name.monkey.retromusic.helper.SortOrder
import code.name.monkey.retromusic.model.Album import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import java.util.* import java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
@ -107,7 +107,7 @@ object AlbumLoader {
} }
private fun sortSongsByTrackNumber(album: Album) { private fun sortSongsByTrackNumber(album: Album) {
when (PreferenceUtilKT.albumDetailSongSortOrder) { when (PreferenceUtil.albumDetailSongSortOrder) {
SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST -> album.songs?.sortWith(Comparator { o1, o2 -> SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST -> album.songs?.sortWith(Comparator { o1, o2 ->
o1.trackNumber.compareTo( o1.trackNumber.compareTo(
o2.trackNumber o2.trackNumber
@ -132,7 +132,7 @@ object AlbumLoader {
} }
private fun getSongLoaderSortOrder(): String { private fun getSongLoaderSortOrder(): String {
return PreferenceUtilKT.albumSortOrder + ", " + return PreferenceUtil.albumSortOrder + ", " +
PreferenceUtilKT.albumSongSortOrder PreferenceUtil.albumSongSortOrder
} }
} }

View file

@ -18,13 +18,13 @@ import android.content.Context
import android.provider.MediaStore.Audio.AudioColumns import android.provider.MediaStore.Audio.AudioColumns
import code.name.monkey.retromusic.model.Album import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Artist import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
object ArtistLoader { object ArtistLoader {
private fun getSongLoaderSortOrder(): String { private fun getSongLoaderSortOrder(): String {
return PreferenceUtilKT.artistSortOrder + ", " + return PreferenceUtil.artistSortOrder + ", " +
PreferenceUtilKT.artistAlbumSortOrder + ", " + PreferenceUtil.artistAlbumSortOrder + ", " +
PreferenceUtilKT.artistSongSortOrder PreferenceUtil.artistSongSortOrder
} }
fun getAllArtists(context: Context): ArrayList<Artist> { fun getAllArtists(context: Context): ArrayList<Artist> {

View file

@ -19,11 +19,11 @@ import android.database.Cursor
import android.net.Uri import android.net.Uri
import android.provider.BaseColumns import android.provider.BaseColumns
import android.provider.MediaStore.Audio.Genres import android.provider.MediaStore.Audio.Genres
import code.name.monkey.retromusic.Constants.BASE_SELECTION import code.name.monkey.retromusic.Constants.IS_MUSIC
import code.name.monkey.retromusic.Constants.baseProjection import code.name.monkey.retromusic.Constants.baseProjection
import code.name.monkey.retromusic.model.Genre import code.name.monkey.retromusic.model.Genre
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
object GenreLoader { object GenreLoader {
@ -95,9 +95,9 @@ object GenreLoader {
return context.contentResolver.query( return context.contentResolver.query(
Genres.Members.getContentUri("external", genreId.toLong()), Genres.Members.getContentUri("external", genreId.toLong()),
baseProjection, baseProjection,
BASE_SELECTION, IS_MUSIC,
null, null,
PreferenceUtilKT.songSortOrder PreferenceUtil.songSortOrder
) )
} catch (e: SecurityException) { } catch (e: SecurityException) {
return null return null
@ -153,7 +153,7 @@ object GenreLoader {
projection, projection,
null, null,
null, null,
PreferenceUtilKT.genreSortOrder PreferenceUtil.genreSortOrder
) )
} catch (e: SecurityException) { } catch (e: SecurityException) {
return null return null

View file

@ -20,7 +20,7 @@ import android.provider.MediaStore
import code.name.monkey.retromusic.model.Album import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Artist import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
/** /**
* Created by hemanths on 16/08/17. * Created by hemanths on 16/08/17.
@ -33,7 +33,7 @@ object LastAddedSongsLoader {
} }
private fun makeLastAddedCursor(context: Context): Cursor? { private fun makeLastAddedCursor(context: Context): Cursor? {
val cutoff = PreferenceUtilKT.lastAddedCutoff val cutoff = PreferenceUtil.lastAddedCutoff
return SongLoader.makeSongCursor( return SongLoader.makeSongCursor(
context, context,
MediaStore.Audio.Media.DATE_ADDED + ">?", MediaStore.Audio.Media.DATE_ADDED + ">?",

View file

@ -18,7 +18,7 @@ import android.content.Context
import android.database.Cursor import android.database.Cursor
import android.provider.MediaStore import android.provider.MediaStore
import android.provider.MediaStore.Audio.AudioColumns import android.provider.MediaStore.Audio.AudioColumns
import code.name.monkey.retromusic.Constants.BASE_SELECTION import code.name.monkey.retromusic.Constants.IS_MUSIC
import code.name.monkey.retromusic.model.AbsCustomPlaylist import code.name.monkey.retromusic.model.AbsCustomPlaylist
import code.name.monkey.retromusic.model.Playlist import code.name.monkey.retromusic.model.Playlist
import code.name.monkey.retromusic.model.PlaylistSong import code.name.monkey.retromusic.model.PlaylistSong
@ -105,7 +105,7 @@ object PlaylistSongsLoader {
MediaStore.Audio.Playlists.Members._ID,//11 MediaStore.Audio.Playlists.Members._ID,//11
AudioColumns.COMPOSER AudioColumns.COMPOSER
)// 12 )// 12
, BASE_SELECTION, null, , IS_MUSIC, null,
MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER
) )
} catch (e: SecurityException) { } catch (e: SecurityException) {

View file

@ -18,12 +18,12 @@ import android.content.Context
import android.database.Cursor import android.database.Cursor
import android.provider.MediaStore import android.provider.MediaStore
import android.provider.MediaStore.Audio.AudioColumns import android.provider.MediaStore.Audio.AudioColumns
import code.name.monkey.retromusic.Constants.BASE_SELECTION import code.name.monkey.retromusic.Constants.IS_MUSIC
import code.name.monkey.retromusic.Constants.baseProjection import code.name.monkey.retromusic.Constants.baseProjection
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.providers.BlacklistStore import code.name.monkey.retromusic.providers.BlacklistStore
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import java.util.* import java.util.*
/** /**
@ -107,14 +107,14 @@ object SongLoader {
context: Context, context: Context,
selection: String?, selection: String?,
selectionValues: Array<String>?, selectionValues: Array<String>?,
sortOrder: String = PreferenceUtilKT.songSortOrder sortOrder: String = PreferenceUtil.songSortOrder
): Cursor? { ): Cursor? {
var selectionFinal = selection var selectionFinal = selection
var selectionValuesFinal = selectionValues var selectionValuesFinal = selectionValues
selectionFinal = if (selection != null && selection.trim { it <= ' ' } != "") { selectionFinal = if (selection != null && selection.trim { it <= ' ' } != "") {
"$BASE_SELECTION AND $selectionFinal" "$IS_MUSIC AND $selectionFinal"
} else { } else {
BASE_SELECTION IS_MUSIC
} }
// Blacklist // Blacklist
@ -129,7 +129,7 @@ object SongLoader {
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
baseProjection, baseProjection,
selectionFinal + " AND " + MediaStore.Audio.Media.DURATION + ">= " + selectionFinal + " AND " + MediaStore.Audio.Media.DURATION + ">= " +
(PreferenceUtilKT.filterLength * 1000), (PreferenceUtil.filterLength * 1000),
selectionValuesFinal, selectionValuesFinal,
sortOrder sortOrder
) )

View file

@ -15,6 +15,7 @@
package code.name.monkey.retromusic.misc package code.name.monkey.retromusic.misc
import com.google.android.material.appbar.AppBarLayout import com.google.android.material.appbar.AppBarLayout
import kotlin.math.abs
/** /**
* @author Hemanth S (h4h13). * @author Hemanth S (h4h13).
@ -26,23 +27,27 @@ abstract class AppBarStateChangeListener : AppBarLayout.OnOffsetChangedListener
private var mCurrentState = State.IDLE private var mCurrentState = State.IDLE
override fun onOffsetChanged(appBarLayout: AppBarLayout, i: Int) { override fun onOffsetChanged(appBarLayout: AppBarLayout, i: Int) {
if (i == 0) { when {
i == 0 -> {
if (mCurrentState != State.EXPANDED) { if (mCurrentState != State.EXPANDED) {
onStateChanged(appBarLayout, State.EXPANDED) onStateChanged(appBarLayout, State.EXPANDED)
} }
mCurrentState = State.EXPANDED mCurrentState = State.EXPANDED
} else if (Math.abs(i) >= appBarLayout.totalScrollRange) { }
abs(i) >= appBarLayout.totalScrollRange -> {
if (mCurrentState != State.COLLAPSED) { if (mCurrentState != State.COLLAPSED) {
onStateChanged(appBarLayout, State.COLLAPSED) onStateChanged(appBarLayout, State.COLLAPSED)
} }
mCurrentState = State.COLLAPSED mCurrentState = State.COLLAPSED
} else { }
else -> {
if (mCurrentState != State.IDLE) { if (mCurrentState != State.IDLE) {
onStateChanged(appBarLayout, State.IDLE) onStateChanged(appBarLayout, State.IDLE)
} }
mCurrentState = State.IDLE mCurrentState = State.IDLE
} }
} }
}
abstract fun onStateChanged(appBarLayout: AppBarLayout, state: State) abstract fun onStateChanged(appBarLayout: AppBarLayout, state: State)

View file

@ -1,51 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.misc
import android.content.Context
import android.text.TextUtils
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.loaders.AlbumLoader
import code.name.monkey.retromusic.loaders.ArtistLoader
import code.name.monkey.retromusic.loaders.SongLoader
import java.util.*
internal class AsyncSearchResultLoader(context: Context, private val query: String) :
WrappedAsyncTaskLoader<List<Any>>(context) {
override fun loadInBackground(): List<Any>? {
val results = ArrayList<Any>()
if (!TextUtils.isEmpty(query)) {
val songs = SongLoader.getSongs(context, query.trim { it <= ' ' })
if (!songs.isEmpty()) {
results.add(context.resources.getString(R.string.songs))
results.addAll(songs)
}
val artists = ArtistLoader.getArtists(context, query.trim { it <= ' ' })
if (!artists.isEmpty()) {
results.add(context.resources.getString(R.string.artists))
results.addAll(artists)
}
val albums = AlbumLoader.getAlbums(context, query.trim { it <= ' ' })
if (!albums.isEmpty()) {
results.add(context.resources.getString(R.string.albums))
results.addAll(albums)
}
}
return results
}
}

View file

@ -1,36 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.misc
import android.animation.Animator
abstract class SimpleAnimatorListener : Animator.AnimatorListener {
override fun onAnimationStart(animation: Animator) {
}
override fun onAnimationEnd(animation: Animator) {
}
override fun onAnimationCancel(animation: Animator) {
}
override fun onAnimationRepeat(animation: Animator) {
}
}

View file

@ -17,6 +17,9 @@ package code.name.monkey.retromusic.model;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable; import android.os.Parcelable;
import androidx.annotation.DrawableRes;
import androidx.annotation.StringRes;
import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.R;
@ -56,14 +59,14 @@ public class CategoryInfo implements Parcelable {
} }
public enum Category { public enum Category {
HOME(R.id.action_home, R.string.home, R.drawable.ic_home_white_24dp), Home(R.id.action_home, R.string.home, R.drawable.ic_home_white_24dp),
SONGS(R.id.action_song, R.string.songs, R.drawable.ic_audiotrack_white_24dp), Songs(R.id.action_song, R.string.songs, R.drawable.ic_audiotrack_white_24dp),
ALBUMS(R.id.action_album, R.string.albums, R.drawable.ic_album_white_24dp), Albums(R.id.action_album, R.string.albums, R.drawable.ic_album_white_24dp),
ARTISTS(R.id.action_artist, R.string.artists, R.drawable.ic_artist_white_24dp), Artists(R.id.action_artist, R.string.artists, R.drawable.ic_artist_white_24dp),
PLAYLISTS(R.id.action_playlist, R.string.playlists, R.drawable.ic_playlist_play_white_24dp), Playlists(R.id.action_playlist, R.string.playlists, R.drawable.ic_playlist_play_white_24dp),
GENRES(R.id.action_genre, R.string.genres, R.drawable.ic_guitar_white_24dp), Genres(R.id.action_genre, R.string.genres, R.drawable.ic_guitar_white_24dp),
QUEUE(R.id.action_playing_queue, R.string.queue, R.drawable.ic_queue_music_white_24dp), Queue(R.id.action_playing_queue, R.string.queue, R.drawable.ic_queue_music_white_24dp),
FOLDER(R.id.action_folder, R.string.folders, R.drawable.ic_folder_white_24dp); Folder(R.id.action_folder, R.string.folders, R.drawable.ic_folder_white_24dp);
public final int icon; public final int icon;
@ -71,7 +74,7 @@ public class CategoryInfo implements Parcelable {
public final int stringRes; public final int stringRes;
Category(int id, int stringRes, int icon) { Category(int id, @StringRes int stringRes, @DrawableRes int icon) {
this.stringRes = stringRes; this.stringRes = stringRes;
this.id = id; this.id = id;
this.icon = icon; this.icon = icon;

View file

@ -16,16 +16,7 @@ package code.name.monkey.retromusic.mvp.presenter
import code.name.monkey.retromusic.model.Album import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Artist import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
import code.name.monkey.retromusic.rest.model.LastFmAlbum import code.name.monkey.retromusic.rest.model.LastFmAlbum
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
/** /**
* Created by hemanths on 20/08/17. * Created by hemanths on 20/08/17.
@ -42,58 +33,3 @@ interface AlbumDetailsView {
fun aboutAlbum(lastFmAlbum: LastFmAlbum) fun aboutAlbum(lastFmAlbum: LastFmAlbum)
} }
interface AlbumDetailsPresenter : Presenter<AlbumDetailsView> {
fun loadAlbum(albumId: Int)
fun loadMore(artistId: Int)
fun aboutAlbum(artist: String, album: String)
class AlbumDetailsPresenterImpl @Inject constructor(
private val repository: Repository
) : PresenterImpl<AlbumDetailsView>(), AlbumDetailsPresenter, CoroutineScope {
private val job = Job()
private lateinit var album: Album
override fun loadMore(artistId: Int) {
launch {
val result = repository.artistById(artistId)
showArtistImage(result)
}
}
override fun aboutAlbum(artist: String, album: String) {
launch {
val result = repository.albumInfo(artist, album)
view.aboutAlbum(result)
}
}
private fun showArtistImage(artist: Artist) {
view?.loadArtistImage(artist)
artist.albums?.filter { it.id != album.id }?.let {
if (it.isNotEmpty()) view?.moreAlbums(ArrayList(it))
}
}
override fun loadAlbum(albumId: Int) {
launch {
val result = repository.albumById(albumId)
album = result
view?.album(result)
}
}
override fun detachView() {
super.detachView()
job.cancel()
}
override val coroutineContext: CoroutineContext
get() = Dispatchers.IO + job
}
}

View file

@ -16,15 +16,6 @@ package code.name.monkey.retromusic.mvp.presenter
import code.name.monkey.retromusic.model.Album import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.mvp.BaseView import code.name.monkey.retromusic.mvp.BaseView
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
/** /**
* Created by hemanths on 12/08/17. * Created by hemanths on 12/08/17.
@ -33,30 +24,3 @@ interface AlbumsView : BaseView {
fun albums(albums: List<Album>) fun albums(albums: List<Album>)
} }
interface AlbumsPresenter : Presenter<AlbumsView> {
fun loadAlbums()
class AlbumsPresenterImpl @Inject constructor(
private val repository: Repository
) : PresenterImpl<AlbumsView>(), AlbumsPresenter, CoroutineScope {
private val job = Job()
override val coroutineContext: CoroutineContext
get() = Dispatchers.IO + job
override fun detachView() {
super.detachView()
job.cancel()
}
override fun loadAlbums() {
launch {
val result = repository.allAlbums()
view?.albums(result)
}
}
}
}

View file

@ -16,17 +16,7 @@ package code.name.monkey.retromusic.mvp.presenter
import code.name.monkey.retromusic.model.Artist import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.mvp.BaseView import code.name.monkey.retromusic.mvp.BaseView
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
import code.name.monkey.retromusic.rest.model.LastFmArtist import code.name.monkey.retromusic.rest.model.LastFmArtist
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import java.util.*
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
/** /**
* Created by hemanths on 20/08/17. * Created by hemanths on 20/08/17.
@ -39,43 +29,3 @@ interface ArtistDetailsView : BaseView {
fun complete() fun complete()
} }
interface ArtistDetailsPresenter : Presenter<ArtistDetailsView> {
fun loadArtist(artistId: Int)
fun loadBiography(
name: String,
lang: String? = Locale.getDefault().language,
cache: String?
)
class ArtistDetailsPresenterImpl @Inject constructor(
private val repository: Repository
) : PresenterImpl<ArtistDetailsView>(), ArtistDetailsPresenter, CoroutineScope {
override val coroutineContext: CoroutineContext
get() = Dispatchers.IO + job
private val job = Job()
override fun loadBiography(name: String, lang: String?, cache: String?) {
launch {
val result = repository.artistInfo(name, lang, cache)
view?.artistInfo(result)
}
}
override fun loadArtist(artistId: Int) {
launch {
val result = repository.artistById(artistId)
view?.artist(result)
}
}
override fun detachView() {
super.detachView()
job.cancel()
}
}
}

View file

@ -1,58 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.mvp.presenter
import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.mvp.BaseView
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
interface ArtistsView : BaseView {
fun artists(artists: List<Artist>)
}
interface ArtistsPresenter : Presenter<ArtistsView> {
fun loadArtists()
class ArtistsPresenterImpl @Inject constructor(
private val repository: Repository
) : PresenterImpl<ArtistsView>(), ArtistsPresenter, CoroutineScope {
private val job = Job()
override val coroutineContext: CoroutineContext
get() = Dispatchers.IO + job
override fun detachView() {
super.detachView()
job.cancel()
}
override fun loadArtists() {
launch {
val result = repository.allArtists()
view?.artists(result)
}
}
}
}

View file

@ -1,61 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.mvp.presenter
import code.name.monkey.retromusic.model.Genre
import code.name.monkey.retromusic.mvp.BaseView
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
/**
* @author Hemanth S (h4h13).
*/
interface GenresView : BaseView {
fun genres(genres: List<Genre>)
}
interface GenresPresenter : Presenter<GenresView> {
fun loadGenres()
class GenresPresenterImpl @Inject constructor(
private val repository: Repository
) : PresenterImpl<GenresView>(), GenresPresenter, CoroutineScope {
private val job = Job()
override val coroutineContext: CoroutineContext
get() = Dispatchers.IO + job
override fun detachView() {
super.detachView()
job.cancel()
}
override fun loadGenres() {
launch {
val result = repository.allGenres()
view?.genres(result)
}
}
}
}

View file

@ -1,65 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.mvp.presenter
import code.name.monkey.retromusic.model.Playlist
import code.name.monkey.retromusic.mvp.BaseView
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
/**
* Created by hemanths on 19/08/17.
*/
interface PlaylistView : BaseView {
fun playlists(playlists: List<Playlist>)
}
interface PlaylistsPresenter : Presenter<PlaylistView> {
fun playlists()
class PlaylistsPresenterImpl @Inject constructor(
private val repository: Repository
) : PresenterImpl<PlaylistView>(), PlaylistsPresenter, CoroutineScope {
private val job = Job()
override val coroutineContext: CoroutineContext
get() = Dispatchers.IO + job
override fun detachView() {
super.detachView()
job.cancel()
}
override fun playlists() {
launch {
val result = repository.allPlaylists()
view?.playlists(result)
}
}
}
}

View file

@ -1,65 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.mvp.presenter
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.mvp.Presenter
import code.name.monkey.retromusic.mvp.PresenterImpl
import code.name.monkey.retromusic.providers.interfaces.Repository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
/**
* Created by hemanths on 10/08/17.
*/
interface SongView {
fun songs(songs: List<Song>)
fun showEmptyView()
}
interface SongPresenter : Presenter<SongView> {
fun loadSongs()
class SongPresenterImpl @Inject constructor(
private val repository: Repository
) : PresenterImpl<SongView>(), SongPresenter, CoroutineScope {
private var job: Job = Job()
override val coroutineContext: CoroutineContext
get() = Dispatchers.IO + job
override fun loadSongs() {
launch {
val songs = repository.allSongs()
view?.songs(songs)
}
}
override fun detachView() {
super.detachView()
job.cancel()
}
}
}

View file

@ -37,7 +37,7 @@ import code.name.monkey.retromusic.extensions.colorControlNormal
import code.name.monkey.retromusic.fragments.AlbumCoverStyle import code.name.monkey.retromusic.fragments.AlbumCoverStyle
import code.name.monkey.retromusic.fragments.AlbumCoverStyle.* import code.name.monkey.retromusic.fragments.AlbumCoverStyle.*
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
@ -77,7 +77,7 @@ class AlbumCoverStylePreferenceDialog : DialogFragment(),
viewPager.adapter = AlbumCoverStyleAdapter(requireContext()) viewPager.adapter = AlbumCoverStyleAdapter(requireContext())
viewPager.addOnPageChangeListener(this) viewPager.addOnPageChangeListener(this)
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt() viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
viewPager.currentItem = PreferenceUtilKT.albumCoverStyle.ordinal viewPager.currentItem = PreferenceUtil.albumCoverStyle.ordinal
return MaterialAlertDialogBuilder(requireActivity(), return MaterialAlertDialogBuilder(requireActivity(),
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert) R.style.ThemeOverlay_MaterialComponents_Dialog_Alert)
@ -89,7 +89,7 @@ class AlbumCoverStylePreferenceDialog : DialogFragment(),
Toast.makeText(context, result, Toast.LENGTH_SHORT).show() Toast.makeText(context, result, Toast.LENGTH_SHORT).show()
NavigationUtil.goToProVersion(requireActivity()) NavigationUtil.goToProVersion(requireActivity())
} else { } else {
PreferenceUtilKT.albumCoverStyle = coverStyle PreferenceUtil.albumCoverStyle = coverStyle
} }
} }
.setView(view) .setView(view)
@ -164,5 +164,5 @@ class AlbumCoverStylePreferenceDialog : DialogFragment(),
} }
private fun isAlbumCoverStyle(style: AlbumCoverStyle): Boolean { private fun isAlbumCoverStyle(style: AlbumCoverStyle): Boolean {
return (!App.isProVersion() && (style == CIRCLE || style == CARD || style == FULL_CARD)) return (!App.isProVersion() && (style == Circle || style == Card || style == FullCard))
} }

View file

@ -31,7 +31,7 @@ import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.CategoryInfoAdapter import code.name.monkey.retromusic.adapter.CategoryInfoAdapter
import code.name.monkey.retromusic.extensions.colorControlNormal import code.name.monkey.retromusic.extensions.colorControlNormal
import code.name.monkey.retromusic.model.CategoryInfo import code.name.monkey.retromusic.model.CategoryInfo
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
@ -57,7 +57,7 @@ class LibraryPreferenceDialog : DialogFragment() {
.inflate(R.layout.preference_dialog_library_categories, null) .inflate(R.layout.preference_dialog_library_categories, null)
val categoryAdapter = CategoryInfoAdapter() val categoryAdapter = CategoryInfoAdapter()
categoryAdapter.categoryInfos = PreferenceUtilKT.libraryCategory categoryAdapter.categoryInfos = PreferenceUtil.libraryCategory
val recyclerView = view.findViewById<RecyclerView>(R.id.recycler_view) val recyclerView = view.findViewById<RecyclerView>(R.id.recycler_view)
recyclerView.layoutManager = LinearLayoutManager(activity) recyclerView.layoutManager = LinearLayoutManager(activity)
recyclerView.adapter = categoryAdapter recyclerView.adapter = categoryAdapter
@ -72,7 +72,7 @@ class LibraryPreferenceDialog : DialogFragment() {
.setNeutralButton( .setNeutralButton(
R.string.reset_action R.string.reset_action
) { _, _ -> ) { _, _ ->
categoryAdapter.categoryInfos = PreferenceUtilKT.defaultCategories categoryAdapter.categoryInfos = PreferenceUtil.defaultCategories
} }
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.setPositiveButton( .setPositiveButton(
@ -88,7 +88,7 @@ class LibraryPreferenceDialog : DialogFragment() {
Toast.makeText(context, "Not more than 5 items", Toast.LENGTH_SHORT).show() Toast.makeText(context, "Not more than 5 items", Toast.LENGTH_SHORT).show()
return return
} }
PreferenceUtilKT.libraryCategory = categories PreferenceUtil.libraryCategory = categories
} }
private fun getSelected(categories: List<CategoryInfo>): Int { private fun getSelected(categories: List<CategoryInfo>): Int {

View file

@ -1,135 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.preferences
import android.app.Dialog
import android.content.Context
import android.content.res.TypedArray
import android.os.Bundle
import android.util.AttributeSet
import androidx.core.graphics.BlendModeColorFilterCompat
import androidx.core.graphics.BlendModeCompat.SRC_IN
import androidx.preference.ListPreference
import androidx.preference.PreferenceDialogFragmentCompat
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.colorControlNormal
import com.afollestad.materialdialogs.MaterialDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
class MaterialListPreference @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = -1,
defStyleRes: Int = -1
) : ListPreference(context, attrs, defStyleAttr, defStyleRes) {
private val mLayoutRes = R.layout.ate_preference_list
init {
icon?.colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(
context.colorControlNormal(),
SRC_IN
)
}
override fun getDialogLayoutResource(): Int {
return mLayoutRes
}
override fun onGetDefaultValue(a: TypedArray, index: Int): String {
// Default value from attribute. Fallback value is set to 0.
return a.getString(index)!!
}
fun setCustomValue(any: Any) {
when (any) {
is String -> persistString(any)
is Int -> persistInt(any)
is Boolean -> persistBoolean(any)
}
}
}
class MaterialListPreferenceDialog : PreferenceDialogFragmentCompat() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val materialListPreference = preference as MaterialListPreference
val entries = arguments?.getStringArrayList(EXTRA_ENTRIES)
val entriesValues = arguments?.getStringArrayList(EXTRA_ENTRIES_VALUES)
val position: Int = arguments?.getInt(EXTRA_POSITION) ?: 0
/* materialDialog = MaterialDialog(requireContext())
.title(text = materialListPreference.title.toString())
.positiveButton(R.string.set)
.listItemsSingleChoice(
items = entries,
initialSelection = position,
waitForPositiveButton = true
) { _, index, _ ->
entriesValues?.let {
materialListPreference.callChangeListener(it[index])
materialListPreference.setCustomValue(it[index])
}
entries?.let {
materialListPreference.summary = it[index]
val value = materialListPreference.entryValues[index].toString()
if (materialListPreference.callChangeListener(value)) {
materialListPreference.value = value
}
}
dismiss()
}
materialDialog.getActionButton(WhichButton.POSITIVE)
.updateTextColor(ThemeStore.accentColor(requireContext()))
return materialDialog*/
return MaterialAlertDialogBuilder(requireContext()).create()
}
override fun onDestroyView() {
super.onDestroyView()
materialDialog.dismiss()
}
private lateinit var materialDialog: MaterialDialog
override fun onDialogClosed(positiveResult: Boolean) {
if (positiveResult) {
materialDialog.dismiss()
}
}
companion object {
private const val EXTRA_KEY = "key"
private const val EXTRA_TITLE = "title"
private const val EXTRA_POSITION = "position"
private const val EXTRA_ENTRIES = "extra_entries"
private const val EXTRA_ENTRIES_VALUES = "extra_entries_values"
fun newInstance(listPreference: ListPreference): MaterialListPreferenceDialog {
val entries = listPreference.entries.toList() as ArrayList<String>
val entriesValues = listPreference.entryValues.toList() as ArrayList<String>
val position = listPreference.findIndexOfValue(listPreference.value)
val args = Bundle()
args.putString(ARG_KEY, listPreference.key)
args.putString(EXTRA_TITLE, listPreference.title.toString())
args.putInt(EXTRA_POSITION, position)
args.putStringArrayList(EXTRA_ENTRIES, entries)
args.putStringArrayList(EXTRA_ENTRIES_VALUES, entriesValues)
val fragment = MaterialListPreferenceDialog()
fragment.arguments = args
return fragment
}
}
}

View file

@ -36,7 +36,7 @@ import code.name.monkey.retromusic.extensions.colorControlNormal
import code.name.monkey.retromusic.fragments.NowPlayingScreen import code.name.monkey.retromusic.fragments.NowPlayingScreen
import code.name.monkey.retromusic.fragments.NowPlayingScreen.* import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
import code.name.monkey.retromusic.util.NavigationUtil import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
@ -84,7 +84,7 @@ class NowPlayingScreenPreferenceDialog : DialogFragment(), ViewPager.OnPageChang
viewPager.adapter = NowPlayingScreenAdapter(requireContext()) viewPager.adapter = NowPlayingScreenAdapter(requireContext())
viewPager.addOnPageChangeListener(this) viewPager.addOnPageChangeListener(this)
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt() viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
viewPager.currentItem = PreferenceUtilKT.nowPlayingScreen.ordinal viewPager.currentItem = PreferenceUtil.nowPlayingScreen.ordinal
return MaterialAlertDialogBuilder( return MaterialAlertDialogBuilder(
requireContext(), requireContext(),
@ -100,7 +100,7 @@ class NowPlayingScreenPreferenceDialog : DialogFragment(), ViewPager.OnPageChang
Toast.makeText(context, result, Toast.LENGTH_SHORT).show() Toast.makeText(context, result, Toast.LENGTH_SHORT).show()
NavigationUtil.goToProVersion(requireContext()) NavigationUtil.goToProVersion(requireContext())
} else { } else {
PreferenceUtilKT.nowPlayingScreen = nowPlayingScreen PreferenceUtil.nowPlayingScreen = nowPlayingScreen
} }
} }
.setView(view) .setView(view)

View file

@ -28,7 +28,7 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import code.name.monkey.retromusic.util.FileUtil; import code.name.monkey.retromusic.util.FileUtil;
import code.name.monkey.retromusic.util.PreferenceUtilKT; import code.name.monkey.retromusic.util.PreferenceUtil;
import static code.name.monkey.retromusic.service.MusicService.MEDIA_STORE_CHANGED; import static code.name.monkey.retromusic.service.MusicService.MEDIA_STORE_CHANGED;
@ -47,13 +47,13 @@ public class BlacklistStore extends SQLiteOpenHelper {
public static synchronized BlacklistStore getInstance(@NonNull final Context context) { public static synchronized BlacklistStore getInstance(@NonNull final Context context) {
if (sInstance == null) { if (sInstance == null) {
sInstance = new BlacklistStore(context.getApplicationContext()); sInstance = new BlacklistStore(context.getApplicationContext());
if (!PreferenceUtilKT.INSTANCE.isInitializedBlacklist()) { if (!PreferenceUtil.INSTANCE.isInitializedBlacklist()) {
// blacklisted by default // blacklisted by default
sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS)); sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS));
sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS)); sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS));
sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES)); sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES));
PreferenceUtilKT.INSTANCE.setInitializedBlacklist(true); PreferenceUtil.INSTANCE.setInitializedBlacklist(true);
} }
} }
return sInstance; return sInstance;

View file

@ -29,7 +29,7 @@ import androidx.annotation.Nullable;
import code.name.monkey.retromusic.R; import code.name.monkey.retromusic.R;
import code.name.monkey.retromusic.service.playback.Playback; import code.name.monkey.retromusic.service.playback.Playback;
import code.name.monkey.retromusic.util.PreferenceUtilKT; import code.name.monkey.retromusic.util.PreferenceUtil;
/** /**
* @author Andrew Neal, Karim Abou Zeid (kabouzeid) * @author Andrew Neal, Karim Abou Zeid (kabouzeid)
@ -130,7 +130,7 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media
if (path == null) { if (path == null) {
return; return;
} }
if (PreferenceUtilKT.INSTANCE.isGapLessPlayback()) { if (PreferenceUtil.INSTANCE.isGapLessPlayback()) {
mNextMediaPlayer = new MediaPlayer(); mNextMediaPlayer = new MediaPlayer();
mNextMediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK); mNextMediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK);
mNextMediaPlayer.setAudioSessionId(getAudioSessionId()); mNextMediaPlayer.setAudioSessionId(getAudioSessionId());

View file

@ -81,7 +81,7 @@ import code.name.monkey.retromusic.service.notification.PlayingNotificationImpl;
import code.name.monkey.retromusic.service.notification.PlayingNotificationOreo; import code.name.monkey.retromusic.service.notification.PlayingNotificationOreo;
import code.name.monkey.retromusic.service.playback.Playback; import code.name.monkey.retromusic.service.playback.Playback;
import code.name.monkey.retromusic.util.MusicUtil; import code.name.monkey.retromusic.util.MusicUtil;
import code.name.monkey.retromusic.util.PreferenceUtilKT; import code.name.monkey.retromusic.util.PreferenceUtil;
import code.name.monkey.retromusic.util.RetroUtil; import code.name.monkey.retromusic.util.RetroUtil;
import static code.name.monkey.retromusic.ConstantsKt.ALBUM_ART_ON_LOCKSCREEN; import static code.name.monkey.retromusic.ConstantsKt.ALBUM_ART_ON_LOCKSCREEN;
@ -257,7 +257,7 @@ public class MusicService extends Service implements
String action = intent.getAction(); String action = intent.getAction();
if (action != null) { if (action != null) {
if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action) && if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action) &&
PreferenceUtilKT.INSTANCE.isBluetoothSpeaker()) { PreferenceUtil.INSTANCE.isBluetoothSpeaker()) {
if (VERSION.SDK_INT >= VERSION_CODES.M) { if (VERSION.SDK_INT >= VERSION_CODES.M) {
if (getAudioManager().getDevices(AudioManager.GET_DEVICES_OUTPUTS).length > 0) { if (getAudioManager().getDevices(AudioManager.GET_DEVICES_OUTPUTS).length > 0) {
play(); play();
@ -388,7 +388,7 @@ public class MusicService extends Service implements
getContentResolver() getContentResolver()
.registerContentObserver(MediaStore.Audio.Playlists.INTERNAL_CONTENT_URI, true, mediaStoreObserver); .registerContentObserver(MediaStore.Audio.Playlists.INTERNAL_CONTENT_URI, true, mediaStoreObserver);
PreferenceUtilKT.INSTANCE.registerOnSharedPreferenceChangedListener(this); PreferenceUtil.INSTANCE.registerOnSharedPreferenceChangedListener(this);
restoreState(); restoreState();
@ -418,7 +418,7 @@ public class MusicService extends Service implements
quit(); quit();
releaseResources(); releaseResources();
getContentResolver().unregisterContentObserver(mediaStoreObserver); getContentResolver().unregisterContentObserver(mediaStoreObserver);
PreferenceUtilKT.INSTANCE.unregisterOnSharedPreferenceChangedListener(this); PreferenceUtil.INSTANCE.unregisterOnSharedPreferenceChangedListener(this);
wakeLock.release(); wakeLock.release();
sendBroadcast(new Intent("code.name.monkey.retromusic.RETRO_MUSIC_SERVICE_DESTROYED")); sendBroadcast(new Intent("code.name.monkey.retromusic.RETRO_MUSIC_SERVICE_DESTROYED"));
@ -664,7 +664,7 @@ public class MusicService extends Service implements
public void initNotification() { public void initNotification() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N &&
!PreferenceUtilKT.INSTANCE.isClassicNotification()) { !PreferenceUtil.INSTANCE.isClassicNotification()) {
playingNotification = new PlayingNotificationImpl(); playingNotification = new PlayingNotificationImpl();
} else { } else {
playingNotification = new PlayingNotificationOreo(); playingNotification = new PlayingNotificationOreo();
@ -1110,13 +1110,13 @@ public class MusicService extends Service implements
.putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null) .putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null)
.putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getPlayingQueue().size()); .putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getPlayingQueue().size());
if (PreferenceUtilKT.INSTANCE.isAlbumArtOnLockScreen()) { if (PreferenceUtil.INSTANCE.isAlbumArtOnLockScreen()) {
final Point screenSize = RetroUtil.getScreenSize(MusicService.this); final Point screenSize = RetroUtil.getScreenSize(MusicService.this);
final BitmapRequestBuilder<?, Bitmap> request = SongGlideRequest.Builder final BitmapRequestBuilder<?, Bitmap> request = SongGlideRequest.Builder
.from(Glide.with(MusicService.this), song) .from(Glide.with(MusicService.this), song)
.checkIgnoreMediaStore(MusicService.this) .checkIgnoreMediaStore(MusicService.this)
.asBitmap().build(); .asBitmap().build();
if (PreferenceUtilKT.INSTANCE.isBlurredAlbumArt()) { if (PreferenceUtil.INSTANCE.isBlurredAlbumArt()) {
request.transform(new BlurTransformation.Builder(MusicService.this).build()); request.transform(new BlurTransformation.Builder(MusicService.this).build());
} }
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@ -1259,7 +1259,7 @@ public class MusicService extends Service implements
} }
private void registerHeadsetEvents() { private void registerHeadsetEvents() {
if (!headsetReceiverRegistered && PreferenceUtilKT.INSTANCE.isHeadsetPlugged()) { if (!headsetReceiverRegistered && PreferenceUtil.INSTANCE.isHeadsetPlugged()) {
registerReceiver(headsetReceiver, headsetReceiverIntentFilter); registerReceiver(headsetReceiver, headsetReceiverIntentFilter);
headsetReceiverRegistered = true; headsetReceiverRegistered = true;
} }

View file

@ -23,7 +23,7 @@ import androidx.annotation.NonNull;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import code.name.monkey.retromusic.util.PreferenceUtilKT; import code.name.monkey.retromusic.util.PreferenceUtil;
import static code.name.monkey.retromusic.service.MusicService.DUCK; import static code.name.monkey.retromusic.service.MusicService.DUCK;
import static code.name.monkey.retromusic.service.MusicService.META_CHANGED; import static code.name.monkey.retromusic.service.MusicService.META_CHANGED;
@ -52,7 +52,7 @@ class PlaybackHandler extends Handler {
switch (msg.what) { switch (msg.what) {
case MusicService.DUCK: case MusicService.DUCK:
if (PreferenceUtilKT.INSTANCE.isAudioDucking()) { if (PreferenceUtil.INSTANCE.isAudioDucking()) {
currentDuckVolume -= .05f; currentDuckVolume -= .05f;
if (currentDuckVolume > .2f) { if (currentDuckVolume > .2f) {
sendEmptyMessageDelayed(DUCK, 10); sendEmptyMessageDelayed(DUCK, 10);
@ -66,7 +66,7 @@ class PlaybackHandler extends Handler {
break; break;
case MusicService.UNDUCK: case MusicService.UNDUCK:
if (PreferenceUtilKT.INSTANCE.isAudioDucking()) { if (PreferenceUtil.INSTANCE.isAudioDucking()) {
currentDuckVolume += .03f; currentDuckVolume += .03f;
if (currentDuckVolume < 1f) { if (currentDuckVolume < 1f) {
sendEmptyMessageDelayed(MusicService.UNDUCK, 10); sendEmptyMessageDelayed(MusicService.UNDUCK, 10);

View file

@ -32,7 +32,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.service.MusicService.* import code.name.monkey.retromusic.service.MusicService.*
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroColorUtil import code.name.monkey.retromusic.util.RetroColorUtil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.request.animation.GlideAnimation import com.bumptech.glide.request.animation.GlideAnimation
@ -150,7 +150,7 @@ class PlayingNotificationImpl : PlayingNotification() {
) )
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
if (Build.VERSION.SDK_INT <= if (Build.VERSION.SDK_INT <=
Build.VERSION_CODES.O && PreferenceUtilKT.isColoredNotification Build.VERSION_CODES.O && PreferenceUtil.isColoredNotification
) { ) {
builder.color = color builder.color = color
} }

View file

@ -33,7 +33,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.service.MusicService.* import code.name.monkey.retromusic.service.MusicService.*
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil
import code.name.monkey.retromusic.util.RetroUtil.createBitmap import code.name.monkey.retromusic.util.RetroUtil.createBitmap
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
@ -143,7 +143,7 @@ class PlayingNotificationOreo : PlayingNotification() {
) )
} }
if (!PreferenceUtilKT.isColoredNotification) { if (!PreferenceUtil.isColoredNotification) {
bgColorFinal = resolveColor(service, R.attr.colorPrimary, Color.WHITE) bgColorFinal = resolveColor(service, R.attr.colorPrimary, Color.WHITE)
} }
setBackgroundColor(bgColorFinal) setBackgroundColor(bgColorFinal)

View file

@ -23,18 +23,18 @@ import com.google.gson.JsonSyntaxException
import com.google.gson.reflect.TypeToken import com.google.gson.reflect.TypeToken
import java.io.File import java.io.File
object PreferenceUtilKT { object PreferenceUtil {
private val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(App.getContext()) private val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(App.getContext())
val defaultCategories = listOf( val defaultCategories = listOf(
CategoryInfo(CategoryInfo.Category.HOME, true), CategoryInfo(CategoryInfo.Category.Home, true),
CategoryInfo(CategoryInfo.Category.SONGS, true), CategoryInfo(CategoryInfo.Category.Songs, true),
CategoryInfo(CategoryInfo.Category.ALBUMS, true), CategoryInfo(CategoryInfo.Category.Albums, true),
CategoryInfo(CategoryInfo.Category.ARTISTS, true), CategoryInfo(CategoryInfo.Category.Artists, true),
CategoryInfo(CategoryInfo.Category.PLAYLISTS, true), CategoryInfo(CategoryInfo.Category.Playlists, true),
CategoryInfo(CategoryInfo.Category.GENRES, false), CategoryInfo(CategoryInfo.Category.Genres, false),
CategoryInfo(CategoryInfo.Category.QUEUE, false), CategoryInfo(CategoryInfo.Category.Queue, false),
CategoryInfo(CategoryInfo.Category.FOLDER, false) CategoryInfo(CategoryInfo.Category.Folder, false)
) )
var libraryCategory: List<CategoryInfo> var libraryCategory: List<CategoryInfo>
@ -484,7 +484,7 @@ object PreferenceUtilKT {
return albumCoverStyle return albumCoverStyle
} }
} }
return AlbumCoverStyle.CARD return AlbumCoverStyle.Card
} }
set(value) = sharedPreferences.edit { putInt(ALBUM_COVER_STYLE, value.id) } set(value) = sharedPreferences.edit { putInt(ALBUM_COVER_STYLE, value.id) }

View file

@ -142,7 +142,7 @@ public class RetroUtil {
} }
public static boolean isAllowedToDownloadMetadata(final @NonNull Context context) { public static boolean isAllowedToDownloadMetadata(final @NonNull Context context) {
switch (PreferenceUtilKT.INSTANCE.getAutoDownloadImagesPolicy()) { switch (PreferenceUtil.INSTANCE.getAutoDownloadImagesPolicy()) {
case "always": case "always":
return true; return true;
case "only_wifi": case "only_wifi":

View file

@ -119,19 +119,19 @@ public class SAFUtil {
public static void saveTreeUri(Context context, Intent data) { public static void saveTreeUri(Context context, Intent data) {
Uri uri = data.getData(); Uri uri = data.getData();
context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
PreferenceUtilKT.INSTANCE.setSafSdCardUri(uri.toString()); PreferenceUtil.INSTANCE.setSafSdCardUri(uri.toString());
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static boolean isTreeUriSaved(Context context) { public static boolean isTreeUriSaved(Context context) {
return !TextUtils.isEmpty(PreferenceUtilKT.INSTANCE.getSafSdCardUri()); return !TextUtils.isEmpty(PreferenceUtil.INSTANCE.getSafSdCardUri());
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static boolean isSDCardAccessGranted(Context context) { public static boolean isSDCardAccessGranted(Context context) {
if (!isTreeUriSaved(context)) return false; if (!isTreeUriSaved(context)) return false;
String sdcardUri = PreferenceUtilKT.INSTANCE.getSafSdCardUri(); String sdcardUri = PreferenceUtil.INSTANCE.getSafSdCardUri();
List<UriPermission> perms = context.getContentResolver().getPersistedUriPermissions(); List<UriPermission> perms = context.getContentResolver().getPersistedUriPermissions();
for (UriPermission perm : perms) { for (UriPermission perm : perms) {
@ -198,7 +198,7 @@ public class SAFUtil {
if (isTreeUriSaved(context)) { if (isTreeUriSaved(context)) {
List<String> pathSegments = new ArrayList<>(Arrays.asList(audio.getFile().getAbsolutePath().split("/"))); List<String> pathSegments = new ArrayList<>(Arrays.asList(audio.getFile().getAbsolutePath().split("/")));
Uri sdcard = Uri.parse(PreferenceUtilKT.INSTANCE.getSafSdCardUri()); Uri sdcard = Uri.parse(PreferenceUtil.INSTANCE.getSafSdCardUri());
uri = findDocument(DocumentFile.fromTreeUri(context, sdcard), pathSegments); uri = findDocument(DocumentFile.fromTreeUri(context, sdcard), pathSegments);
} }
@ -271,7 +271,7 @@ public class SAFUtil {
if (isTreeUriSaved(context)) { if (isTreeUriSaved(context)) {
List<String> pathSegments = new ArrayList<>(Arrays.asList(path.split("/"))); List<String> pathSegments = new ArrayList<>(Arrays.asList(path.split("/")));
Uri sdcard = Uri.parse(PreferenceUtilKT.INSTANCE.getSafSdCardUri()); Uri sdcard = Uri.parse(PreferenceUtil.INSTANCE.getSafSdCardUri());
uri = findDocument(DocumentFile.fromTreeUri(context, sdcard), pathSegments); uri = findDocument(DocumentFile.fromTreeUri(context, sdcard), pathSegments);
} }

View file

@ -25,7 +25,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.NavigationViewUtil import code.name.monkey.appthemehelper.util.NavigationViewUtil
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RippleUtils import code.name.monkey.retromusic.util.RippleUtils
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
@ -36,7 +36,7 @@ class BottomNavigationBarTinted @JvmOverloads constructor(
) : BottomNavigationView(context, attrs, defStyleAttr) { ) : BottomNavigationView(context, attrs, defStyleAttr) {
init { init {
labelVisibilityMode = PreferenceUtilKT.tabTitleMode labelVisibilityMode = PreferenceUtil.tabTitleMode
val iconColor = ATHUtil.resolveColor(context, android.R.attr.colorControlNormal) val iconColor = ATHUtil.resolveColor(context, android.R.attr.colorControlNormal)
val accentColor = ThemeStore.accentColor(context) val accentColor = ThemeStore.accentColor(context)

View file

@ -23,7 +23,7 @@ import androidx.core.content.ContextCompat
import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.util.PreferenceUtilKT import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroColorUtil import code.name.monkey.retromusic.util.RetroColorUtil
@ -46,7 +46,7 @@ class ColorIconsImageView @JvmOverloads constructor(
fun setIconBackgroundColor(color: Int) { fun setIconBackgroundColor(color: Int) {
background = ContextCompat.getDrawable(context, R.drawable.color_circle_gradient) background = ContextCompat.getDrawable(context, R.drawable.color_circle_gradient)
if (ATHUtil.isWindowBackgroundDark(context) && PreferenceUtilKT.isDesaturatedColor) { if (ATHUtil.isWindowBackgroundDark(context) && PreferenceUtil.isDesaturatedColor) {
val desaturatedColor = RetroColorUtil.desaturateColor(color, 0.4f) val desaturatedColor = RetroColorUtil.desaturateColor(color, 0.4f)
backgroundTintList = ColorStateList.valueOf(desaturatedColor) backgroundTintList = ColorStateList.valueOf(desaturatedColor)
imageTintList = imageTintList =

View file

@ -1,60 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.volume;
import android.content.Context;
import android.media.AudioManager;
import android.os.Handler;
import androidx.annotation.NonNull;
public class AudioVolumeObserver {
private final Context mContext;
private final AudioManager mAudioManager;
private AudioVolumeContentObserver mAudioVolumeContentObserver;
public AudioVolumeObserver(@NonNull Context context) {
mContext = context;
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
}
public void register(int audioStreamType, @NonNull OnAudioVolumeChangedListener listener) {
Handler handler = new Handler();
// with this handler AudioVolumeContentObserver#onChange()
// will be executed in the main thread
// To execute in another thread you can use a Looper
// +info: https://stackoverflow.com/a/35261443/904907
mAudioVolumeContentObserver = new AudioVolumeContentObserver(
handler,
mAudioManager,
audioStreamType,
listener);
mContext.getContentResolver().registerContentObserver(
android.provider.Settings.System.CONTENT_URI,
true,
mAudioVolumeContentObserver);
}
public void unregister() {
if (mAudioVolumeContentObserver != null) {
mContext.getContentResolver().unregisterContentObserver(mAudioVolumeContentObserver);
mAudioVolumeContentObserver = null;
}
}
}

View file

@ -0,0 +1,51 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package code.name.monkey.retromusic.volume
import android.content.Context
import android.media.AudioManager
import android.os.Handler
import android.provider.Settings
class AudioVolumeObserver(private val context: Context) {
private val mAudioManager: AudioManager =
context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
private var contentObserver: AudioVolumeContentObserver? = null
fun register(audioStreamType: Int, listener: OnAudioVolumeChangedListener) {
val handler = Handler()
// with this handler AudioVolumeContentObserver#onChange()
// will be executed in the main thread
// To execute in another thread you can use a Looper
// +info: https://stackoverflow.com/a/35261443/904907
contentObserver = AudioVolumeContentObserver(
handler,
mAudioManager,
audioStreamType,
listener
)
context.contentResolver.registerContentObserver(
Settings.System.CONTENT_URI,
true,
contentObserver!!
)
}
fun unregister() {
if (contentObserver != null) {
context.contentResolver.unregisterContentObserver(contentObserver!!)
contentObserver = null
}
}
}

View file

@ -16,7 +16,7 @@
android:id="@+id/playerAlbumCoverFragment" android:id="@+id/playerAlbumCoverFragment"
android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment" android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="0dp"
app:layout_constrainedHeight="true" app:layout_constrainedHeight="true"
app:layout_constraintBottom_toTopOf="@id/playbackControlsFragment" app:layout_constraintBottom_toTopOf="@id/playbackControlsFragment"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
@ -45,7 +45,6 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/playerAlbumCoverFragment" /> app:layout_constraintTop_toBottomOf="@id/playerAlbumCoverFragment" />
<FrameLayout <FrameLayout
android:id="@+id/statusBarContainer" android:id="@+id/statusBarContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -57,14 +56,12 @@
<include layout="@layout/status_bar" /> <include layout="@layout/status_bar" />
</FrameLayout> </FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/playerQueueSheet" android:id="@+id/playerQueueSheet"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/colorSurface"
app:behavior_hideable="false" app:behavior_hideable="false"
app:layout_behavior="code.name.monkey.retromusic.RetroBottomSheetBehavior"> app:layout_behavior="code.name.monkey.retromusic.RetroBottomSheetBehavior">
@ -144,6 +141,7 @@
android:id="@+id/recyclerView" android:id="@+id/recyclerView"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
android:background="?attr/colorSurface"
android:overScrollMode="never" android:overScrollMode="never"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"