diff --git a/app/src/main/java/code/name/monkey/retromusic/Constants.kt b/app/src/main/java/code/name/monkey/retromusic/Constants.kt index 1f871b58..79e76a37 100644 --- a/app/src/main/java/code/name/monkey/retromusic/Constants.kt +++ b/app/src/main/java/code/name/monkey/retromusic/Constants.kt @@ -32,7 +32,7 @@ object Constants { const val FAQ_LINK = "https://github.com/h4h13/RetroMusicPlayer/blob/master/FAQ.md" 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 + " != ''" val baseProjection = arrayOf( @@ -47,11 +47,9 @@ object Constants { MediaStore.Audio.AudioColumns.ALBUM, // 8 MediaStore.Audio.AudioColumns.ARTIST_ID, // 9 MediaStore.Audio.AudioColumns.ARTIST,// 10 - MediaStore.Audio.AudioColumns.COMPOSER - )// 11 + MediaStore.Audio.AudioColumns.COMPOSER// 11 + ) const val NUMBER_OF_TOP_TRACKS = 99 - - } 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 LAST_ADDED_CUTOFF = "last_added_interval" const val LAST_SLEEP_TIMER_VALUE = "last_sleep_timer_value" -const val NEXT_SLEEP_TIMER_ELAPSED_REALTIME = - "next_sleep_timer_elapsed_real_time" +const val NEXT_SLEEP_TIMER_ELAPSED_REALTIME = "next_sleep_timer_elapsed_real_time" const val IGNORE_MEDIA_STORE_ARTWORK = "ignore_media_store_artwork" const val LAST_CHANGELOG_VERSION = "last_changelog_version" const val AUTO_DOWNLOAD_IMAGES_POLICY = "auto_download_images_policy" diff --git a/app/src/main/java/code/name/monkey/retromusic/LanguageContextWrapper.java b/app/src/main/java/code/name/monkey/retromusic/LanguageContextWrapper.java index 72ae6aba..36f7f565 100644 --- a/app/src/main/java/code/name/monkey/retromusic/LanguageContextWrapper.java +++ b/app/src/main/java/code/name/monkey/retromusic/LanguageContextWrapper.java @@ -1,6 +1,7 @@ package code.name.monkey.retromusic; import android.content.Context; +import android.content.ContextWrapper; import android.content.res.Configuration; import android.content.res.Resources; import android.os.LocaleList; @@ -9,7 +10,7 @@ import java.util.Locale; import code.name.monkey.appthemehelper.util.VersionUtils; -public class LanguageContextWrapper extends android.content.ContextWrapper { +public class LanguageContextWrapper extends ContextWrapper { public LanguageContextWrapper(Context base) { super(base); diff --git a/app/src/main/java/code/name/monkey/retromusic/RetroBottomSheetBehavior.java b/app/src/main/java/code/name/monkey/retromusic/RetroBottomSheetBehavior.java index 9eb5553f..abff707a 100644 --- a/app/src/main/java/code/name/monkey/retromusic/RetroBottomSheetBehavior.java +++ b/app/src/main/java/code/name/monkey/retromusic/RetroBottomSheetBehavior.java @@ -9,10 +9,12 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout; import com.google.android.material.bottomsheet.BottomSheetBehavior; +import org.jetbrains.annotations.NotNull; + public class RetroBottomSheetBehavior extends BottomSheetBehavior { - private static final String TAG = "CustomBottomSheetBehavi"; + private static final String TAG = "RetroBottomSheetBehavior"; private boolean allowDragging = true; @@ -28,7 +30,7 @@ public class RetroBottomSheetBehavior extends BottomSheetBehavio } @Override - public boolean onInterceptTouchEvent(CoordinatorLayout parent, V child, MotionEvent event) { + public boolean onInterceptTouchEvent(@NotNull CoordinatorLayout parent, @NotNull V child, @NotNull MotionEvent event) { if (!allowDragging) { return false; } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt index 224d85e9..c0a7efff 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt @@ -34,7 +34,7 @@ import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.model.lyrics.Lyrics import code.name.monkey.retromusic.util.LyricUtil 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.fragment_lyrics.* import kotlinx.android.synthetic.main.fragment_synced.* @@ -54,7 +54,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, } override fun onPageSelected(position: Int) { - PreferenceUtilKT.lyricsOption = position + PreferenceUtil.lyricsOption = position if (position == 0) fab.text = getString(R.string.synced_lyrics) else if (position == 1) fab.text = getString(R.string.lyrics) } @@ -100,7 +100,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, viewPager.apply { adapter = PagerAdapter(supportFragmentManager) - currentItem = PreferenceUtilKT.lyricsOption + currentItem = PreferenceUtil.lyricsOption addOnPageChangeListener(this@LyricsActivity) } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt index 9b14e3e8..f9560e3c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/MainActivity.kt @@ -47,7 +47,7 @@ import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.util.AppRater.appLaunched 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.RetroUtil import com.afollestad.materialcab.MaterialCab @@ -99,7 +99,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), override fun onReceive(context: Context, intent: Intent) { val action = intent.action if (action != null && action == Intent.ACTION_SCREEN_OFF) { - if (PreferenceUtilKT.isLockScreen && isPlaying) { + if (PreferenceUtil.isLockScreen && isPlaying) { val activity = Intent(context, LockScreenActivity::class.java) activity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) activity.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY) @@ -127,7 +127,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), addMusicServiceEventListener(libraryViewModel) if (savedInstanceState == null) { - selectedFragment(PreferenceUtilKT.lastPage) + selectedFragment(PreferenceUtil.lastPage) } else { restoreCurrentFragment() } @@ -136,9 +136,9 @@ class MainActivity : AbsSlidingMusicPanelActivity(), setupToolbar() checkUpdate() updateTabs() - getBottomNavigationView().selectedItemId = PreferenceUtilKT.lastPage + getBottomNavigationView().selectedItemId = PreferenceUtil.lastPage getBottomNavigationView().setOnNavigationItemSelectedListener { - PreferenceUtilKT.lastPage = it.itemId + PreferenceUtil.lastPage = it.itemId selectedFragment(it.itemId) true } @@ -147,10 +147,10 @@ class MainActivity : AbsSlidingMusicPanelActivity(), override fun onResume() { super.onResume() registerReceiver(broadcastReceiver, intentFilter) - PreferenceUtilKT.registerOnSharedPreferenceChangedListener(this) + PreferenceUtil.registerOnSharedPreferenceChangedListener(this) if (intent.hasExtra(EXPAND_PANEL) && intent.getBooleanExtra(EXPAND_PANEL, false) && - PreferenceUtilKT.isExpandPanel + PreferenceUtil.isExpandPanel ) { expandPanel() intent.removeExtra(EXPAND_PANEL) @@ -179,7 +179,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), override fun onDestroy() { super.onDestroy() unregisterReceiver(broadcastReceiver) - PreferenceUtilKT.unregisterOnSharedPreferenceChangedListener(this) + PreferenceUtil.unregisterOnSharedPreferenceChangedListener(this) } override fun onPrepareOptionsMenu(menu: Menu?): Boolean { diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt index 65b97ee5..5e1e8bba 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/UserInfoActivity.kt @@ -21,7 +21,7 @@ import code.name.monkey.retromusic.extensions.applyToolbar import code.name.monkey.retromusic.glide.ProfileBannerGlideRequest import code.name.monkey.retromusic.glide.UserProfileGlideRequest 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.load.engine.DiskCacheStrategy import com.bumptech.glide.request.RequestListener @@ -50,7 +50,7 @@ class UserInfoActivity : AbsBaseActivity() { applyToolbar(toolbar) MaterialUtil.setTint(nameContainer, false) - name.setText(PreferenceUtilKT.userName) + name.setText(PreferenceUtil.userName) userImage.setOnClickListener { pickNewPhoto() @@ -66,7 +66,7 @@ class UserInfoActivity : AbsBaseActivity() { Toast.makeText(this, "Umm name is empty", Toast.LENGTH_SHORT).show() return@setOnClickListener } - PreferenceUtilKT.userName = nameString + PreferenceUtil.userName = nameString setResult(Activity.RESULT_OK) finish() } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java b/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java index 0e681412..4f1a6ef3 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java +++ b/app/src/main/java/code/name/monkey/retromusic/activities/WhatsNewActivity.java @@ -25,7 +25,7 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper; import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper; import code.name.monkey.retromusic.R; 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 { @@ -38,7 +38,7 @@ public class WhatsNewActivity extends AbsBaseActivity { try { PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); int currentVersion = pInfo.versionCode; - PreferenceUtilKT.INSTANCE.setLastVersion(currentVersion); + PreferenceUtil.INSTANCE.setLastVersion(currentVersion); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/albums/AlbumDetailsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/albums/AlbumDetailsActivity.kt index 956f7788..4095bb7c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/albums/AlbumDetailsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/albums/AlbumDetailsActivity.kt @@ -74,7 +74,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C private lateinit var artistImage: ImageView private var cab: MaterialCab? = null private val savedSortOrder: String - get() = PreferenceUtilKT.albumDetailSongSortOrder + get() = PreferenceUtil.albumDetailSongSortOrder override fun createContentView(): View { return wrapSlidingMusicPanel(R.layout.activity_album) @@ -244,7 +244,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C private fun loadAlbumCover() { AlbumGlideRequest.Builder.from(Glide.with(this), album.safeGetFirstSong()) .checkIgnoreMediaStore(this) - .ignoreMediaStore(PreferenceUtilKT.isIgnoreMediaStoreArtwork) + .ignoreMediaStore(PreferenceUtil.isIgnoreMediaStoreArtwork) .generatePalette(this) .build() .dontAnimate() @@ -257,7 +257,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C } private fun setColors(color: MediaNotificationProcessor) { - val buttonColor = if (PreferenceUtilKT.isAdaptiveColor) + val buttonColor = if (PreferenceUtil.isAdaptiveColor) color.backgroundColor.ripAlpha() else ATHUtil.resolveColor(this, R.attr.colorSurface) @@ -353,7 +353,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C } private fun setSaveSortOrder(sortOrder: String) { - PreferenceUtilKT.albumDetailSongSortOrder = sortOrder + PreferenceUtil.albumDetailSongSortOrder = sortOrder when (sortOrder) { AlbumSongSortOrder.SONG_TRACK_LIST -> album.songs?.sortWith(Comparator { o1, o2 -> o1.trackNumber.compareTo( diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/artists/ArtistDetailActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/artists/ArtistDetailActivity.kt index b5b91d56..7fb6ed1b 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/artists/ArtistDetailActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/artists/ArtistDetailActivity.kt @@ -18,7 +18,6 @@ import androidx.recyclerview.widget.LinearLayoutManager import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.MaterialUtil 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.adapter.album.HorizontalAlbumAdapter import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter @@ -246,7 +245,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView, } private fun setColors(color: MediaNotificationProcessor) { - val buttonColor = if (PreferenceUtilKT.isAdaptiveColor) + val buttonColor = if (PreferenceUtil.isAdaptiveColor) color.backgroundColor.ripAlpha() else ATHUtil.resolveColor(this, R.attr.colorSurface) diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt index 1c8692af..411987f4 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsSlidingMusicPanelActivity.kt @@ -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.model.CategoryInfo 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 com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.shape.MaterialShapeDrawable @@ -117,7 +117,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), override fun onResume() { super.onResume() - if (cps != PreferenceUtilKT.nowPlayingScreen) { + if (cps != PreferenceUtil.nowPlayingScreen) { postRecreate() } behavior.addBottomSheetCallback(bottomSheetCallbackList) @@ -239,7 +239,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), } private fun chooseFragmentForTheme() { - cps = PreferenceUtilKT.nowPlayingScreen + cps = PreferenceUtil.nowPlayingScreen val fragment: Fragment = when (cps) { Blur -> BlurPlayerFragment() Adaptive -> AdaptiveFragment() @@ -310,7 +310,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), val isColorLight = ColorUtil.isColorLight(paletteColor) - if (PreferenceUtilKT.isAdaptiveColor && (cps == Normal || cps == Flat)) { + if (PreferenceUtil.isAdaptiveColor && (cps == Normal || cps == Flat)) { super.setLightNavigationBar(true) super.setLightStatusbar(isColorLight) } else if (cps == Card || cps == Blur || cps == BlurCard) { @@ -374,7 +374,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), fun updateTabs() { bottomNavigationView.menu.clear() - val currentTabs: List = PreferenceUtilKT.libraryCategory + val currentTabs: List = PreferenceUtil.libraryCategory for (tab in currentTabs) { if (tab.visible) { val menu = tab.category diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt index 09b66575..6746329b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/base/AbsThemeActivity.kt @@ -18,7 +18,7 @@ import code.name.monkey.appthemehelper.util.MaterialDialogsUtil import code.name.monkey.appthemehelper.util.VersionUtils import code.name.monkey.retromusic.LanguageContextWrapper 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.theme.ThemeManager import java.util.* @@ -44,7 +44,7 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable { } private fun toggleScreenOn() { - if (PreferenceUtilKT.isScreenOnEnabled) { + if (PreferenceUtil.isScreenOnEnabled) { window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) } else { window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) @@ -63,7 +63,7 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable { } fun hideStatusBar() { - hideStatusBar(PreferenceUtilKT.isFullScreenMode) + hideStatusBar(PreferenceUtil.isFullScreenMode) } private fun hideStatusBar(fullscreen: Boolean) { @@ -166,7 +166,7 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable { 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) - if (PreferenceUtilKT.isFullScreenMode) { + if (PreferenceUtil.isFullScreenMode) { window.decorView.systemUiVisibility = flags } } @@ -199,7 +199,7 @@ abstract class AbsThemeActivity : ATHToolbarActivity(), Runnable { } override fun attachBaseContext(newBase: Context?) { - val code = PreferenceUtilKT.languageCode + val code = PreferenceUtil.languageCode if (code != "auto") { super.attachBaseContext(LanguageContextWrapper.wrap(newBase, Locale(code))) } else super.attachBaseContext(newBase) diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/model/DeviceInfo.java b/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/model/DeviceInfo.java index ee3b73e9..e9eee8a2 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/model/DeviceInfo.java +++ b/app/src/main/java/code/name/monkey/retromusic/activities/bugreport/model/DeviceInfo.java @@ -11,7 +11,7 @@ import androidx.annotation.IntRange; import java.util.Arrays; import java.util.Locale; -import code.name.monkey.retromusic.util.PreferenceUtilKT; +import code.name.monkey.retromusic.util.PreferenceUtil; public class DeviceInfo { @@ -75,10 +75,10 @@ public class DeviceInfo { versionCode = -1; versionName = null; } - baseTheme = PreferenceUtilKT.INSTANCE.getBaseTheme(); - nowPlayingTheme = context.getString(PreferenceUtilKT.INSTANCE.getNowPlayingScreen().getTitleRes()); - isAdaptive = PreferenceUtilKT.INSTANCE.isAdaptiveColor(); - selectedLang = PreferenceUtilKT.INSTANCE.getLanguageCode(); + baseTheme = PreferenceUtil.INSTANCE.getBaseTheme(); + nowPlayingTheme = context.getString(PreferenceUtil.INSTANCE.getNowPlayingScreen().getTitleRes()); + isAdaptive = PreferenceUtil.INSTANCE.isAdaptiveColor(); + selectedLang = PreferenceUtil.INSTANCE.getLanguageCode(); } public String toMarkdown() { diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt index 213f09da..0dcfb0a0 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/HomeAdapter.kt @@ -21,7 +21,7 @@ import code.name.monkey.retromusic.model.Artist import code.name.monkey.retromusic.model.Home import code.name.monkey.retromusic.model.Playlist -import code.name.monkey.retromusic.util.PreferenceUtilKT +import code.name.monkey.retromusic.util.PreferenceUtil class HomeAdapter( private val activity: AppCompatActivity, @@ -118,7 +118,7 @@ class HomeAdapter( val artistAdapter = ArtistAdapter( activity, list, - PreferenceUtilKT.homeGridStyle, + PreferenceUtil.homeGridStyle, null ) recyclerView.apply { diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumAdapter.kt index 691852b5..3841fd9e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumAdapter.kt @@ -22,7 +22,7 @@ import code.name.monkey.retromusic.model.Album import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.MusicUtil 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 com.bumptech.glide.Glide import me.zhanghai.android.fastscroll.PopupTextProvider @@ -153,7 +153,7 @@ open class AlbumAdapter( private fun getSectionName(position: Int): String { var sectionName: String? = null - when (PreferenceUtilKT.albumSortOrder) { + when (PreferenceUtil.albumSortOrder) { SortOrder.AlbumSortOrder.ALBUM_A_Z, SortOrder.AlbumSortOrder.ALBUM_Z_A -> sectionName = dataSet[position].title SortOrder.AlbumSortOrder.ALBUM_ARTIST -> sectionName = dataSet[position].artistName diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumCoverPagerAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumCoverPagerAdapter.kt index 8c15aa59..a504cc81 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumCoverPagerAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/album/AlbumCoverPagerAdapter.kt @@ -16,7 +16,7 @@ import code.name.monkey.retromusic.misc.CustomFragmentStatePagerAdapter import code.name.monkey.retromusic.model.Song 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 com.bumptech.glide.Glide @@ -91,7 +91,7 @@ class AlbumCoverPagerAdapter( } private fun getLayoutWithPlayerTheme(): Int { - return when (PreferenceUtilKT.nowPlayingScreen) { + return when (PreferenceUtil.nowPlayingScreen) { Card, Fit, Tiny, @@ -100,17 +100,17 @@ class AlbumCoverPagerAdapter( Gradient, Full -> R.layout.fragment_album_full_cover else -> { - if (PreferenceUtilKT.isCarouselEffect) { + if (PreferenceUtil.isCarouselEffect) { R.layout.fragment_album_carousel_cover } else { - when (PreferenceUtilKT.albumCoverStyle) { - AlbumCoverStyle.NORMAL -> R.layout.fragment_album_cover - AlbumCoverStyle.FLAT -> R.layout.fragment_album_flat_cover - AlbumCoverStyle.CIRCLE -> R.layout.fragment_album_circle_cover - AlbumCoverStyle.CARD -> R.layout.fragment_album_card_cover - AlbumCoverStyle.MATERIAL -> R.layout.fragment_album_material_cover - AlbumCoverStyle.FULL -> R.layout.fragment_album_full_cover - AlbumCoverStyle.FULL_CARD -> R.layout.fragment_album_full_card_cover + when (PreferenceUtil.albumCoverStyle) { + AlbumCoverStyle.Normal -> R.layout.fragment_album_cover + AlbumCoverStyle.Flat -> R.layout.fragment_album_flat_cover + AlbumCoverStyle.Circle -> R.layout.fragment_album_circle_cover + AlbumCoverStyle.Card -> R.layout.fragment_album_card_cover + AlbumCoverStyle.Material -> R.layout.fragment_album_material_cover + AlbumCoverStyle.Full -> R.layout.fragment_album_full_cover + AlbumCoverStyle.FullCard -> R.layout.fragment_album_full_card_cover } } } diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/song/SongAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/song/SongAdapter.kt index 86fbf94c..2c0caa40 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/song/SongAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/song/SongAdapter.kt @@ -24,7 +24,7 @@ import code.name.monkey.retromusic.interfaces.CabHolder import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.MusicUtil 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 com.afollestad.materialcab.MaterialCab @@ -145,7 +145,7 @@ open class SongAdapter( } 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_ALBUM -> dataSet[position].albumName SortOrder.SongSortOrder.SONG_ARTIST -> dataSet[position].artistName diff --git a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutIconGenerator.kt b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutIconGenerator.kt index fa7fa35a..ff4dbf5a 100644 --- a/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutIconGenerator.kt +++ b/app/src/main/java/code/name/monkey/retromusic/appshortcuts/AppShortcutIconGenerator.kt @@ -25,13 +25,13 @@ import android.util.TypedValue import androidx.annotation.RequiresApi import code.name.monkey.appthemehelper.ThemeStore 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 @RequiresApi(Build.VERSION_CODES.N_MR1) object AppShortcutIconGenerator { fun generateThemedIcon(context: Context, iconId: Int): Icon { - return if (PreferenceUtilKT.isColoredAppShortcuts) { + return if (PreferenceUtil.isColoredAppShortcuts) { generateUserThemedIcon(context, iconId) } else { generateDefaultThemedIcon(context, iconId) diff --git a/app/src/main/java/code/name/monkey/retromusic/dagger/module/PresenterModile.kt b/app/src/main/java/code/name/monkey/retromusic/dagger/module/PresenterModile.kt index 880ecc88..8e29057c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dagger/module/PresenterModile.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dagger/module/PresenterModile.kt @@ -15,18 +15,12 @@ package code.name.monkey.retromusic.dagger.module import android.content.Context -import code.name.monkey.retromusic.mvp.presenter.* -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 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.HomePresenter.HomePresenterImpl +import code.name.monkey.retromusic.mvp.presenter.PlaylistSongsPresenter 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.SongPresenter.SongPresenterImpl import code.name.monkey.retromusic.providers.RepositoryImpl import code.name.monkey.retromusic.providers.interfaces.Repository import dagger.Module @@ -44,58 +38,18 @@ class PresenterModule { 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 fun providesGenreDetailsPresenter(presenter: GenreDetailsPresenterImpl): GenreDetailsPresenter { return presenter } - @Provides - fun providesHomePresenter(presenter: HomePresenterImpl): HomePresenter { - return presenter - } - @Provides fun providesPlaylistSongPresenter(presenter: PlaylistSongsPresenterImpl): PlaylistSongsPresenter { return presenter } - @Provides - fun providesPlaylistsPresenter(presenter: PlaylistsPresenterImpl): PlaylistsPresenter { - return presenter - } - @Provides fun providesSearchPresenter(presenter: SearchPresenterImpl): SearchPresenter { return presenter } - - @Provides - fun providesSongPresenter(presenter: SongPresenterImpl): SongPresenter { - return presenter - } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.kt index a1e946cf..70e69ae5 100755 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.kt @@ -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.ACTION_PENDING_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.MaterialDialog import com.google.android.material.dialog.MaterialAlertDialogBuilder @@ -58,14 +58,14 @@ class SleepTimerDialog : DialogFragment() { seekBar = layout.findViewById(R.id.seekBar) timerDisplay = layout.findViewById(R.id.timerDisplay) - val finishMusic = PreferenceUtilKT.isSleepTimerFinishMusic + val finishMusic = PreferenceUtil.isSleepTimerFinishMusic shouldFinishLastSong.apply { addAccentColor() isChecked = finishMusic } seekBar.apply { addAccentColor() - seekArcProgress = PreferenceUtilKT.lastSleepTimerValue + seekArcProgress = PreferenceUtil.lastSleepTimerValue updateTimeDisplayTime() seekBar.progress = seekArcProgress } @@ -84,7 +84,7 @@ class SleepTimerDialog : DialogFragment() { } override fun onStopTrackingTouch(seekBar: SeekBar) { - PreferenceUtilKT.lastSleepTimerValue = seekArcProgress + PreferenceUtil.lastSleepTimerValue = seekArcProgress } }) return MaterialAlertDialogBuilder( @@ -94,11 +94,11 @@ class SleepTimerDialog : DialogFragment() { .setTitle(R.string.action_sleep_timer) .setView(layout) .setPositiveButton(R.string.action_set) { _, _ -> - PreferenceUtilKT.isSleepTimerFinishMusic = shouldFinishLastSong.isChecked + PreferenceUtil.isSleepTimerFinishMusic = shouldFinishLastSong.isChecked val minutes = seekArcProgress val pi = makeTimerPendingIntent(PendingIntent.FLAG_CANCEL_CURRENT) val nextSleepTimerElapsedTime = SystemClock.elapsedRealtime() + minutes * 60 * 1000 - PreferenceUtilKT.nextSleepTimerElapsedRealTime = nextSleepTimerElapsedTime.toInt() + PreferenceUtil.nextSleepTimerElapsedRealTime = nextSleepTimerElapsedTime.toInt() val am = requireContext().getSystemService(Context.ALARM_SERVICE) as AlarmManager am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, nextSleepTimerElapsedTime, pi) @@ -161,7 +161,7 @@ class SleepTimerDialog : DialogFragment() { private inner class TimerUpdater internal constructor() : CountDownTimer( - PreferenceUtilKT.nextSleepTimerElapsedRealTime - SystemClock.elapsedRealtime(), + PreferenceUtil.nextSleepTimerElapsedRealTime - SystemClock.elapsedRealtime(), 1000 ) { diff --git a/app/src/main/java/code/name/monkey/retromusic/extensions/FragmentExt.kt b/app/src/main/java/code/name/monkey/retromusic/extensions/FragmentExt.kt index 6e724dc1..311b944d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/extensions/FragmentExt.kt +++ b/app/src/main/java/code/name/monkey/retromusic/extensions/FragmentExt.kt @@ -5,7 +5,7 @@ import android.content.res.Configuration import android.os.PowerManager import androidx.annotation.IntegerRes 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 { return resources.getInteger(int) @@ -16,7 +16,7 @@ fun Context.getIntRes(@IntegerRes int: Int): Int { } val Context.generalThemeValue - get() = PreferenceUtilKT.getGeneralThemeValue(isSystemDarkModeEnabled()) + get() = PreferenceUtil.getGeneralThemeValue(isSystemDarkModeEnabled()) fun Context.isSystemDarkModeEnabled(): Boolean { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/AlbumCoverStyle.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/AlbumCoverStyle.kt index 3e2a3727..b8746b2c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/AlbumCoverStyle.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/AlbumCoverStyle.kt @@ -6,16 +6,15 @@ import code.name.monkey.retromusic.R enum class AlbumCoverStyle( - @param:StringRes @field:StringRes - val titleRes: Int, - @param:DrawableRes @field:DrawableRes - val drawableResId: Int, val id: Int + @StringRes val titleRes: Int, + @DrawableRes val drawableResId: Int, + val id: Int ) { - CARD(R.string.card, R.drawable.np_blur_card, 4), - CIRCLE(R.string.circular, R.drawable.np_circle, 2), - FLAT(R.string.flat, R.drawable.np_flat, 1), - FULL_CARD(R.string.full_card, R.drawable.np_adaptive, 6), - FULL(R.string.full, R.drawable.np_full, 5), - MATERIAL(R.string.material, R.drawable.np_material, 3), - NORMAL(R.string.normal, R.drawable.np_normal, 0), + Card(R.string.card, R.drawable.np_blur_card, 4), + Circle(R.string.circular, R.drawable.np_circle, 2), + Flat(R.string.flat, R.drawable.np_flat, 1), + FullCard(R.string.full_card, R.drawable.np_adaptive, 6), + Full(R.string.full, R.drawable.np_full, 5), + Material(R.string.material, R.drawable.np_material, 3), + Normal(R.string.normal, R.drawable.np_normal, 0), } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt index 17c3c9f0..01f25893 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/MiniPlayerFragment.kt @@ -19,7 +19,7 @@ import code.name.monkey.retromusic.glide.SongGlideRequest import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper 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.ViewUtil import com.bumptech.glide.Glide @@ -64,9 +64,9 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda } else { actionNext.visibility = - if (PreferenceUtilKT.isExtraControls) View.VISIBLE else View.GONE + if (PreferenceUtil.isExtraControls) View.VISIBLE else View.GONE actionPrevious.visibility = - if (PreferenceUtilKT.isExtraControls) View.VISIBLE else View.GONE + if (PreferenceUtil.isExtraControls) View.VISIBLE else View.GONE } actionNext.setOnClickListener(this) actionPrevious.setOnClickListener(this) @@ -104,7 +104,7 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda Glide.with(requireContext()), MusicPlayerRemote.currentSong ).checkIgnoreMediaStore(requireContext()) - .ignoreMediaStore(PreferenceUtilKT.isAllowedToDownloadMetadata()) + .ignoreMediaStore(PreferenceUtil.isAllowedToDownloadMetadata()) .asBitmap() .build() .into(it) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/VolumeFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/VolumeFragment.kt index 59bf24dd..0e1228f4 100755 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/VolumeFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/VolumeFragment.kt @@ -14,7 +14,7 @@ import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.retromusic.R import code.name.monkey.retromusic.extensions.applyColor 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.OnAudioVolumeChangedListener import kotlinx.android.synthetic.main.fragment_volume.* @@ -45,7 +45,7 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum if (audioVolumeObserver == null) { audioVolumeObserver = AudioVolumeObserver(requireActivity()) } - audioVolumeObserver!!.register(AudioManager.STREAM_MUSIC, this) + audioVolumeObserver?.register(AudioManager.STREAM_MUSIC, this) val audioManager = audioManager if (audioManager != null) { @@ -67,9 +67,7 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum override fun onDestroyView() { super.onDestroyView() - if (audioVolumeObserver != null) { - audioVolumeObserver!!.unregister() - } + audioVolumeObserver?.unregister() } override fun onProgressChanged(seekBar: SeekBar, i: Int, b: Boolean) { @@ -113,7 +111,7 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum } private fun setPauseWhenZeroVolume(pauseWhenZeroVolume: Boolean) { - if (PreferenceUtilKT.isPauseOnZeroVolume) + if (PreferenceUtil.isPauseOnZeroVolume) if (MusicPlayerRemote.isPlaying && pauseWhenZeroVolume) MusicPlayerRemote.pauseSong() diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt index 86028dfd..249e0fec 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/albums/AlbumsFragment.kt @@ -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.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks -import code.name.monkey.retromusic.util.PreferenceUtilKT +import code.name.monkey.retromusic.util.PreferenceUtil class AlbumsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment(), @@ -50,27 +50,27 @@ class AlbumsFragment : } override fun loadSortOrder(): String { - return PreferenceUtilKT.albumSortOrder + return PreferenceUtil.albumSortOrder } override fun saveSortOrder(sortOrder: String) { - PreferenceUtilKT.albumSortOrder = sortOrder + PreferenceUtil.albumSortOrder = sortOrder } override fun loadGridSize(): Int { - return PreferenceUtilKT.albumGridSize + return PreferenceUtil.albumGridSize } override fun saveGridSize(gridColumns: Int) { - PreferenceUtilKT.albumGridSize = gridColumns + PreferenceUtil.albumGridSize = gridColumns } override fun loadGridSizeLand(): Int { - return PreferenceUtilKT.albumGridSizeLand + return PreferenceUtil.albumGridSizeLand } override fun saveGridSizeLand(gridColumns: Int) { - PreferenceUtilKT.albumGridSizeLand = gridColumns + PreferenceUtil.albumGridSizeLand = gridColumns } override fun setSortOrder(sortOrder: String) { @@ -78,11 +78,11 @@ class AlbumsFragment : } override fun loadLayoutRes(): Int { - return PreferenceUtilKT.albumGridStyle + return PreferenceUtil.albumGridStyle } override fun saveLayoutRes(layoutRes: Int) { - PreferenceUtilKT.albumGridStyle = layoutRes + PreferenceUtil.albumGridStyle = layoutRes } override fun handleBackPress(): Boolean { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt index 4db95193..9b308bbb 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/artists/ArtistsFragment.kt @@ -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.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks -import code.name.monkey.retromusic.util.PreferenceUtilKT +import code.name.monkey.retromusic.util.PreferenceUtil class ArtistsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment(), @@ -52,19 +52,19 @@ class ArtistsFragment : } override fun loadGridSize(): Int { - return PreferenceUtilKT.artistGridSize + return PreferenceUtil.artistGridSize } override fun saveGridSize(gridColumns: Int) { - PreferenceUtilKT.artistGridSize = gridColumns + PreferenceUtil.artistGridSize = gridColumns } override fun loadGridSizeLand(): Int { - return PreferenceUtilKT.artistGridSizeLand + return PreferenceUtil.artistGridSizeLand } override fun saveGridSizeLand(gridColumns: Int) { - PreferenceUtilKT.artistGridSizeLand = gridColumns + PreferenceUtil.artistGridSizeLand = gridColumns } override fun setGridSize(gridSize: Int) { @@ -73,19 +73,19 @@ class ArtistsFragment : } override fun loadSortOrder(): String { - return PreferenceUtilKT.artistSortOrder + return PreferenceUtil.artistSortOrder } override fun saveSortOrder(sortOrder: String) { - PreferenceUtilKT.artistSortOrder = sortOrder + PreferenceUtil.artistSortOrder = sortOrder } override fun loadLayoutRes(): Int { - return PreferenceUtilKT.artistGridStyle + return PreferenceUtil.artistGridStyle } override fun saveLayoutRes(layoutRes: Int) { - PreferenceUtilKT.artistGridStyle = layoutRes + PreferenceUtil.artistGridStyle = layoutRes } companion object { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerControlsFragment.kt index 48794563..ff2a61ba 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerControlsFragment.kt @@ -8,7 +8,7 @@ import code.name.monkey.retromusic.R import code.name.monkey.retromusic.fragments.VolumeFragment 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 /** @@ -63,7 +63,7 @@ abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(), protected var volumeFragment: VolumeFragment? = null private fun hideVolumeIfAvailable() { - if (PreferenceUtilKT.isVolumeVisibilityMode) { + if (PreferenceUtil.isVolumeVisibilityMode) { childFragmentManager.beginTransaction() .replace(R.id.volumeFragmentContainer, VolumeFragment()).commit() childFragmentManager.executePendingTransactions() diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerFragment.kt index b6d6d45f..cba672fc 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/base/AbsPlayerFragment.kt @@ -255,7 +255,7 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(), override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - if (PreferenceUtilKT.isFullScreenMode && + if (PreferenceUtil.isFullScreenMode && view.findViewById(R.id.status_bar) != null ) { view.findViewById(R.id.status_bar).visibility = View.GONE diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/home/BannerHomeFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/home/BannerHomeFragment.kt index 5144f352..5c1af339 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/home/BannerHomeFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/home/BannerHomeFragment.kt @@ -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.MyTopTracksPlaylist 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 kotlinx.android.synthetic.main.abs_playlists.* import kotlinx.android.synthetic.main.fragment_banner_home.* @@ -49,7 +49,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba savedInstanceState: Bundle? ): View? { 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, false ) @@ -112,7 +112,7 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba NavigationUtil.goToUserInfo(requireActivity(), options) } titleWelcome?.text = - String.format("%s", PreferenceUtilKT.userName) + String.format("%s", PreferenceUtil.userName) homeAdapter = HomeAdapter(mainActivity, displayMetrics) recyclerView.apply { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/FoldersFragment.java b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/FoldersFragment.java index 5016ba7a..ad3f55bb 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/FoldersFragment.java +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/mainactivity/FoldersFragment.java @@ -68,7 +68,7 @@ import code.name.monkey.retromusic.misc.WrappedAsyncTaskLoader; import code.name.monkey.retromusic.model.Song; import code.name.monkey.retromusic.util.DensityUtil; 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.ThemedFastScroller; import code.name.monkey.retromusic.views.BreadCrumbLayout; @@ -134,7 +134,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements } public static FoldersFragment newInstance(Context context) { - return newInstance(PreferenceUtilKT.INSTANCE.getStartDirectory()); + return newInstance(PreferenceUtil.INSTANCE.getStartDirectory()); } private static File tryGetCanonicalFile(File file) { @@ -238,7 +238,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements getFileComparator())); return true; case R.id.action_set_as_start_directory: - PreferenceUtilKT.INSTANCE.setStartDirectory(file); + PreferenceUtil.INSTANCE.setStartDirectory(file); Toast.makeText(getActivity(), String.format(getString(R.string.new_start_directory), file.getPath()), Toast.LENGTH_SHORT).show(); @@ -341,7 +341,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements switch (item.getItemId()) { case R.id.action_go_to_start_directory: setCrumb(new BreadCrumbLayout.Crumb( - tryGetCanonicalFile(PreferenceUtilKT.INSTANCE.getStartDirectory())), true); + tryGetCanonicalFile(PreferenceUtil.INSTANCE.getStartDirectory())), true); return true; case R.id.action_scan: BreadCrumbLayout.Crumb crumb = getActiveCrumb(); diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/PlayerAlbumCoverFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/PlayerAlbumCoverFragment.kt index e71dd96a..cdab3015 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/PlayerAlbumCoverFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/PlayerAlbumCoverFragment.kt @@ -14,7 +14,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.transform.CarousalPagerTransformer 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 kotlinx.android.synthetic.main.fragment_player_album_cover.* @@ -46,14 +46,14 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) viewPager.addOnPageChangeListener(this) - val nps = PreferenceUtilKT.nowPlayingScreen + val nps = PreferenceUtil.nowPlayingScreen val metrics = resources.displayMetrics val ratio = metrics.heightPixels.toFloat() / metrics.widthPixels.toFloat() if (nps == Full || nps == Classic || nps == Fit || nps == Gradient) { viewPager.offscreenPageLimit = 2 - } else if (PreferenceUtilKT.isCarouselEffect) { + } else if (PreferenceUtil.isCarouselEffect) { viewPager.clipToPadding = false val padding = if (ratio >= 1.777f) { @@ -68,7 +68,7 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan viewPager.offscreenPageLimit = 2 viewPager.setPageTransformer( true, - PreferenceUtilKT.albumCoverTransform + PreferenceUtil.albumCoverTransform ) } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptivePlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptivePlaybackControlsFragment.kt index 1ed86332..87f83975 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptivePlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/adaptive/AdaptivePlaybackControlsFragment.kt @@ -26,7 +26,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.service.MusicService 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 kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.* @@ -67,7 +67,7 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() { } private fun updateSong() { - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo?.text = getSongInfo(MusicPlayerRemote.currentSong) songInfo.show() } else { @@ -131,7 +131,7 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() { updatePrevNextColor() updatePlayPauseColor() - val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { + val colorFinal = if (PreferenceUtil.isAdaptiveColor) { color.primaryTextColor } else { ThemeStore.accentColor(requireContext()) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlaybackControlsFragment.kt index facbe674..1093e005 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlaybackControlsFragment.kt @@ -25,7 +25,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.service.MusicService 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 kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.* @@ -69,7 +69,7 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() { title.text = song.title text.text = String.format("%s • %s", song.artistName, song.albumName) - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.show() songInfo?.text = getSongInfo(song) } else { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardPlaybackControlsFragment.kt index ef58fe01..80db27d7 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/card/CardPlaybackControlsFragment.kt @@ -25,7 +25,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.service.MusicService 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 kotlinx.android.synthetic.main.fragment_card_player_playback_controls.* import kotlinx.android.synthetic.main.media_button.* @@ -69,7 +69,7 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() { title.text = song.title text.text = song.artistName - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.text = getSongInfo(MusicPlayerRemote.currentSong) songInfo.show() } else { @@ -129,7 +129,7 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() { updatePlayPauseColor() updateProgressTextColor() - val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { + val colorFinal = if (PreferenceUtil.isAdaptiveColor) { color.primaryTextColor } else { ThemeStore.accentColor(requireContext()).ripAlpha() diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurPlaybackControlsFragment.kt index 991e98a6..16d0e873 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurPlaybackControlsFragment.kt @@ -23,7 +23,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.service.MusicService 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 kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.* @@ -114,7 +114,7 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() { } private fun updateSong() { - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.text = getSongInfo(MusicPlayerRemote.currentSong) songInfo.show() } else { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/circle/CirclePlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/circle/CirclePlayerFragment.kt index 4c982d79..4056c4ab 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/circle/CirclePlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/circle/CirclePlayerFragment.kt @@ -44,7 +44,7 @@ import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper.Callback import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener 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.color.MediaNotificationProcessor @@ -196,7 +196,7 @@ class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChanged title.text = song.title text.text = song.artistName - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.text = getSongInfo(song) songInfo.show() } else { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt index 0e7936bb..9285f020 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/classic/ClassicPlayerFragment.kt @@ -1,6 +1,7 @@ package code.name.monkey.retromusic.fragments.player.classic import android.animation.ObjectAnimator +import android.annotation.SuppressLint import android.content.res.ColorStateList import android.graphics.Color 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.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.color.MediaNotificationProcessor import com.google.android.material.bottomsheet.BottomSheetBehavior @@ -85,7 +86,6 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener, override fun onStateChanged(bottomSheet: View, newState: Int) { val activity = requireActivity() as AbsSlidingMusicPanelActivity - val isDark = ATHUtil.isWindowBackgroundDark(requireContext()); when (newState) { BottomSheetBehavior.STATE_EXPANDED, BottomSheetBehavior.STATE_DRAGGING -> { @@ -115,6 +115,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener, return inflater.inflate(R.layout.fragment_classic_player, container, false) } + @SuppressLint("ClickableViewAccessibility") override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) setupPanel() @@ -155,7 +156,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener, } private fun hideVolumeIfAvailable() { - if (PreferenceUtilKT.isVolumeVisibilityMode) { + if (PreferenceUtil.isVolumeVisibilityMode) { childFragmentManager.beginTransaction() .replace(R.id.volumeFragmentContainer, VolumeFragment.newInstance()) .commit() @@ -186,7 +187,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener, title.text = song.title text.text = song.artistName - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.text = getSongInfo(song) songInfo.show() } else { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/color/ColorPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/color/ColorPlaybackControlsFragment.kt index 42bd2dd6..ec5290a6 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/color/ColorPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/color/ColorPlaybackControlsFragment.kt @@ -23,7 +23,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.service.MusicService 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 kotlinx.android.synthetic.main.fragment_color_player_playback_controls.* @@ -69,7 +69,7 @@ class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() { title.text = song.title text.text = song.artistName - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.text = getSongInfo(song) songInfo.show() } else { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitPlaybackControlsFragment.kt index 496d20ee..76ab358f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/fit/FitPlaybackControlsFragment.kt @@ -27,7 +27,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.service.MusicService 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 kotlinx.android.synthetic.main.fragment_fit_playback_controls.* @@ -72,7 +72,7 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() { val song = MusicPlayerRemote.currentSong title.text = song.title text.text = song.artistName - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.text = getSongInfo(song) songInfo.show() } else { @@ -127,7 +127,7 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() { MaterialValueHelper.getPrimaryDisabledTextColor(activity, false) } - val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { + val colorFinal = if (PreferenceUtil.isAdaptiveColor) { color.primaryTextColor } else { ThemeStore.accentColor(requireContext()).ripAlpha() diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlaybackControlsFragment.kt index 2b9f167e..2ab3ee45 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlaybackControlsFragment.kt @@ -28,7 +28,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.service.MusicService 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 kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.* @@ -96,7 +96,7 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback { MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) } - val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { + val colorFinal = if (PreferenceUtil.isAdaptiveColor) { color.primaryTextColor } else { ThemeStore.accentColor(requireContext()).ripAlpha() @@ -166,7 +166,7 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback { val song = MusicPlayerRemote.currentSong title.text = song.title text.text = song.artistName - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.text = getSongInfo(song) songInfo.show() } else { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt index af75154e..35b36c36 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/flat/FlatPlayerFragment.kt @@ -18,7 +18,7 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.helper.MusicPlayerRemote 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.color.MediaNotificationProcessor import code.name.monkey.retromusic.views.DrawableGradient @@ -99,7 +99,7 @@ class FlatPlayerFragment : AbsPlayerFragment() { override fun toolbarIconColor(): Int { val isLight = ColorUtil.isColorLight(paletteColor) - return if (PreferenceUtilKT.isAdaptiveColor) + return if (PreferenceUtil.isAdaptiveColor) MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight) else ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal) @@ -110,12 +110,12 @@ class FlatPlayerFragment : AbsPlayerFragment() { controlsFragment.setColor(color) callbacks?.onPaletteColorChanged() val isLight = ColorUtil.isColorLight(color.backgroundColor) - val iconColor = if (PreferenceUtilKT.isAdaptiveColor) + val iconColor = if (PreferenceUtil.isAdaptiveColor) MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight) else ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal) ToolbarContentTintHelper.colorizeToolbar(playerToolbar, iconColor, requireActivity()) - if (PreferenceUtilKT.isAdaptiveColor) { + if (PreferenceUtil.isAdaptiveColor) { colorize(color.backgroundColor) } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlaybackControlsFragment.kt index 417023d7..9bf28392 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/full/FullPlaybackControlsFragment.kt @@ -29,7 +29,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.service.MusicService 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 kotlinx.android.synthetic.main.fragment_full_player_controls.* @@ -129,7 +129,7 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(), title.text = song.title text.text = song.artistName updateIsFavorite() - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.text = getSongInfo(song) songInfo.show() } else { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/gradient/GradientPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/gradient/GradientPlayerFragment.kt index 161bbe87..cb953f40 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/gradient/GradientPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/gradient/GradientPlayerFragment.kt @@ -1,6 +1,7 @@ package code.name.monkey.retromusic.fragments.player.gradient import android.animation.ObjectAnimator +import android.annotation.SuppressLint import android.content.res.ColorStateList import android.graphics.Color import android.graphics.PorterDuff @@ -18,7 +19,6 @@ import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.ViewCompat import androidx.recyclerview.widget.LinearLayoutManager 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.TintHelper 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.service.MusicService 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.color.MediaNotificationProcessor import com.google.android.material.bottomsheet.BottomSheetBehavior @@ -82,7 +81,6 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe override fun onStateChanged(bottomSheet: View, newState: Int) { val activity = requireActivity() as AbsSlidingMusicPanelActivity - val isDark = ATHUtil.isWindowBackgroundDark(requireContext()); when (newState) { BottomSheetBehavior.STATE_EXPANDED, BottomSheetBehavior.STATE_DRAGGING -> { @@ -145,6 +143,7 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe setupFavourite() } + @SuppressLint("ClickableViewAccessibility") private fun setupSheet() { getQueuePanel().addBottomSheetCallback(bottomSheetCallbackList) playerQueueSheet.setOnTouchListener { _, _ -> @@ -205,7 +204,7 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe callbacks?.onPaletteColorChanged() mask.backgroundTintList = ColorStateList.valueOf(color.backgroundColor) colorBackground.setBackgroundColor(color.backgroundColor) - container.setBackgroundColor(ColorUtil.darkenColor(color.backgroundColor)) + playerQueueSheet.setBackgroundColor(ColorUtil.darkenColor(color.backgroundColor)) lastPlaybackControlsColor = color.primaryTextColor lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(color.primaryTextColor, 0.3f) @@ -244,7 +243,7 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe } private fun hideVolumeIfAvailable() { - if (PreferenceUtilKT.isVolumeVisibilityMode) { + if (PreferenceUtil.isVolumeVisibilityMode) { childFragmentManager.beginTransaction() .replace(R.id.volumeFragmentContainer, VolumeFragment.newInstance()) .commit() @@ -285,7 +284,7 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe title.text = song.title text.text = song.artistName updateLabel() - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.text = getSongInfo(song) songInfo.show() } else { @@ -482,12 +481,13 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong()) songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong()) } - + @SuppressLint("StaticFieldLeak") private fun updateFavorite() { if (updateIsFavoriteTask != null) { updateIsFavoriteTask?.cancel(false) } - updateIsFavoriteTask = object : AsyncTask() { + updateIsFavoriteTask = + object : AsyncTask() { override fun doInBackground(vararg params: Song): Boolean? { val activity = activity return if (activity != null) { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/lockscreen/LockScreenPlayerControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/lockscreen/LockScreenPlayerControlsFragment.kt index 97a1590a..e43703c7 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/lockscreen/LockScreenPlayerControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/lockscreen/LockScreenPlayerControlsFragment.kt @@ -39,7 +39,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.service.MusicService 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 kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.* @@ -126,7 +126,7 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() { MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) } - val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { + val colorFinal = if (PreferenceUtil.isAdaptiveColor) { color.primaryTextColor } else { textColorSecondary() diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialControlsFragment.kt index e112cd98..dd8f20d0 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/material/MaterialControlsFragment.kt @@ -20,7 +20,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.service.MusicService 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 kotlinx.android.synthetic.main.fragment_material_playback_controls.* @@ -57,7 +57,7 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() { title.text = song.title text.text = song.artistName - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.text = getSongInfo(song) songInfo.show() } else { @@ -114,7 +114,7 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() { updateRepeatState() updateShuffleState() - val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { + val colorFinal = if (PreferenceUtil.isAdaptiveColor) { lastPlaybackControlsColor } else { textColorSecondary() diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt index 6de1075a..5e550862 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerFragment.kt @@ -16,7 +16,7 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment import code.name.monkey.retromusic.helper.MusicPlayerRemote 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.color.MediaNotificationProcessor import code.name.monkey.retromusic.views.DrawableGradient @@ -86,7 +86,7 @@ class PlayerFragment : AbsPlayerFragment() { requireActivity() ) - if (PreferenceUtilKT.isAdaptiveColor) { + if (PreferenceUtil.isAdaptiveColor) { colorize(color.backgroundColor) } } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerPlaybackControlsFragment.kt index cc382204..3f1ce6fa 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/normal/PlayerPlaybackControlsFragment.kt @@ -27,7 +27,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.service.MusicService 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 kotlinx.android.synthetic.main.fragment_player_playback_controls.* @@ -78,7 +78,7 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() { MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) } - val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { + val colorFinal = if (PreferenceUtil.isAdaptiveColor) { color.primaryTextColor } else { ThemeStore.accentColor(requireContext()) @@ -105,7 +105,7 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() { title.text = song.title text.text = song.artistName - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.text = getSongInfo(song) songInfo.show() } else { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerControlFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerControlFragment.kt index 60507b55..ef7d29e1 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerControlFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerControlFragment.kt @@ -37,7 +37,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.service.MusicService 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 kotlinx.android.synthetic.main.fragment_peak_control_player.* @@ -90,7 +90,7 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment() { override fun setColor(color: MediaNotificationProcessor) { val controlsColor = - if (PreferenceUtilKT.isAdaptiveColor) { + if (PreferenceUtil.isAdaptiveColor) { color.primaryTextColor } else { ThemeStore.accentColor(requireContext()) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt index f1298949..457de2ad 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/peak/PeakPlayerFragment.kt @@ -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.player.PlayerAlbumCoverFragment 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 kotlinx.android.synthetic.main.fragment_peak_player.* @@ -114,7 +114,7 @@ class PeakPlayerFragment : AbsPlayerFragment() { title.text = song.title text.text = song.artistName - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.text = getSongInfo(song) songInfo.show() } else { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlaybackControlsFragment.kt index ef4194cd..34d2d397 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/plain/PlainPlaybackControlsFragment.kt @@ -27,7 +27,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener import code.name.monkey.retromusic.service.MusicService 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 kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.nextButton @@ -74,7 +74,7 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() { } private fun updateSong() { - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.text = getSongInfo(MusicPlayerRemote.currentSong) songInfo.show() } else { @@ -157,7 +157,7 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() { MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) } - val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { + val colorFinal = if (PreferenceUtil.isAdaptiveColor) { color.primaryTextColor } else { ThemeStore.accentColor(requireContext()) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlaybackControlsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlaybackControlsFragment.kt index 03856f0f..c58eaf57 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlaybackControlsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/simple/SimplePlaybackControlsFragment.kt @@ -21,7 +21,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler import code.name.monkey.retromusic.service.MusicService 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 kotlinx.android.synthetic.main.fragment_simple_controls_fragment.* @@ -156,7 +156,7 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() { title.text = song.title text.text = song.artistName - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.text = getSongInfo(song) songInfo.show() } else { @@ -213,7 +213,7 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() { MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false) } - val colorFinal = if (PreferenceUtilKT.isAdaptiveColor) { + val colorFinal = if (PreferenceUtil.isAdaptiveColor) { color.primaryTextColor } else { ThemeStore.accentColor(requireContext()) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt index 1c992a31..eb8e59ce 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/tiny/TinyPlayerFragment.kt @@ -21,7 +21,7 @@ import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler import code.name.monkey.retromusic.model.Song 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.color.MediaNotificationProcessor @@ -103,7 +103,7 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca title.text = song.title text.text = String.format("%s \nby - %s", song.albumName, song.artistName) - if (PreferenceUtilKT.isSongInfo) { + if (PreferenceUtil.isSongInfo) { songInfo.text = getSongInfo(song) songInfo.show() } else { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NotificationSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NotificationSettingsFragment.kt index e7f99cc3..2df2d2df 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NotificationSettingsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NotificationSettingsFragment.kt @@ -22,7 +22,7 @@ import androidx.preference.Preference import androidx.preference.TwoStatePreference import code.name.monkey.retromusic.CLASSIC_NOTIFICATION 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 } else { classicNotification?.apply { - isChecked = PreferenceUtilKT.isClassicNotification + isChecked = PreferenceUtil.isClassicNotification setOnPreferenceChangeListener { _, newValue -> // Save preference - PreferenceUtilKT.isClassicNotification = newValue as Boolean + PreferenceUtil.isClassicNotification = newValue as Boolean invalidateSettings() true } @@ -59,12 +59,12 @@ class NotificationSettingsFragment : AbsSettingsFragment(), val coloredNotification: TwoStatePreference? = findPreference("colored_notification") if (VERSION.SDK_INT >= VERSION_CODES.O) { - coloredNotification?.isEnabled = PreferenceUtilKT.isClassicNotification + coloredNotification?.isEnabled = PreferenceUtil.isClassicNotification } else { coloredNotification?.apply { - isChecked = PreferenceUtilKT.isColoredNotification + isChecked = PreferenceUtil.isColoredNotification setOnPreferenceChangeListener { _, newValue -> - PreferenceUtilKT.isColoredNotification = newValue as Boolean + PreferenceUtil.isColoredNotification = newValue as Boolean true } } @@ -73,12 +73,12 @@ class NotificationSettingsFragment : AbsSettingsFragment(), override fun onResume() { super.onResume() - PreferenceUtilKT.registerOnSharedPreferenceChangedListener(this) + PreferenceUtil.registerOnSharedPreferenceChangedListener(this) } override fun onDestroyView() { super.onDestroyView() - PreferenceUtilKT.unregisterOnSharedPreferenceChangedListener(this) + PreferenceUtil.unregisterOnSharedPreferenceChangedListener(this) } override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NowPlayingSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NowPlayingSettingsFragment.kt index 7e2b7048..24cd9dfa 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NowPlayingSettingsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/NowPlayingSettingsFragment.kt @@ -20,7 +20,7 @@ import android.view.View import androidx.preference.Preference import androidx.preference.TwoStatePreference import code.name.monkey.retromusic.* -import code.name.monkey.retromusic.util.PreferenceUtilKT +import code.name.monkey.retromusic.util.PreferenceUtil /** * @author Hemanth S (h4h13). @@ -49,17 +49,17 @@ class NowPlayingSettingsFragment : AbsSettingsFragment(), private fun updateAlbumCoverStyleSummary() { val preference: Preference? = findPreference(ALBUM_COVER_STYLE) - preference?.setSummary(PreferenceUtilKT.albumCoverStyle.titleRes) + preference?.setSummary(PreferenceUtil.albumCoverStyle.titleRes) } private fun updateNowPlayingScreenSummary() { 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?) { super.onViewCreated(view, savedInstanceState) - PreferenceUtilKT.registerOnSharedPreferenceChangedListener(this) + PreferenceUtil.registerOnSharedPreferenceChangedListener(this) val preference: Preference? = findPreference("album_cover_transform") preference?.setOnPreferenceChangeListener { albumPrefs, newValue -> setSummary(albumPrefs, newValue) @@ -69,7 +69,7 @@ class NowPlayingSettingsFragment : AbsSettingsFragment(), override fun onDestroyView() { super.onDestroyView() - PreferenceUtilKT.unregisterOnSharedPreferenceChangedListener(this) + PreferenceUtil.unregisterOnSharedPreferenceChangedListener(this) } override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) { diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt index 6568aa74..7ee28261 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/settings/ThemeSettingsFragment.kt @@ -27,7 +27,7 @@ import code.name.monkey.retromusic.App import code.name.monkey.retromusic.DESATURATED_COLOR import code.name.monkey.retromusic.R 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 /** @@ -45,7 +45,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() { ThemeStore.markChanged(requireContext()) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { - requireActivity().setTheme(PreferenceUtilKT.themeResFromPrefValue(theme)) + requireActivity().setTheme(PreferenceUtil.themeResFromPrefValue(theme)) DynamicShortcutManager(requireContext()).updateDynamicShortcuts() } requireActivity().recreate() @@ -74,7 +74,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() { } ThemeStore.markChanged(requireContext()) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { - requireActivity().setTheme(PreferenceUtilKT.themeResFromPrefValue("black")) + requireActivity().setTheme(PreferenceUtil.themeResFromPrefValue("black")) DynamicShortcutManager(requireContext()).updateDynamicShortcuts() } requireActivity().recreate() @@ -88,7 +88,7 @@ class ThemeSettingsFragment : AbsSettingsFragment() { .edit() .putBoolean("desaturated_color", desaturated) .apply() - PreferenceUtilKT.isDesaturatedColor = desaturated + PreferenceUtil.isDesaturatedColor = desaturated requireActivity().recreate() true } @@ -98,9 +98,9 @@ class ThemeSettingsFragment : AbsSettingsFragment() { if (!VersionUtils.hasNougatMR()) { colorAppShortcuts.isVisible = false } else { - colorAppShortcuts.isChecked = PreferenceUtilKT.isColoredAppShortcuts + colorAppShortcuts.isChecked = PreferenceUtil.isColoredAppShortcuts colorAppShortcuts.setOnPreferenceChangeListener { _, newValue -> - PreferenceUtilKT.isColoredAppShortcuts = newValue as Boolean + PreferenceUtil.isColoredAppShortcuts = newValue as Boolean DynamicShortcutManager(requireContext()).updateDynamicShortcuts() true } diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/songs/SongsFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/songs/SongsFragment.kt index add25fc4..38f16a57 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/songs/SongsFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/songs/SongsFragment.kt @@ -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.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks -import code.name.monkey.retromusic.model.Song -import code.name.monkey.retromusic.mvp.presenter.SongView -import code.name.monkey.retromusic.util.PreferenceUtilKT -import java.util.* +import code.name.monkey.retromusic.util.PreferenceUtil class SongsFragment : AbsLibraryPagerRecyclerViewCustomGridSizeFragment(), - SongView, MainActivityFragmentCallbacks { + MainActivityFragmentCallbacks { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) mainActivity.libraryViewModel.allSongs() @@ -57,49 +54,41 @@ class SongsFragment : ) } - override fun songs(songs: List) { - adapter?.swapDataSet(songs) - } - override fun loadGridSize(): Int { - return PreferenceUtilKT.songGridSize + return PreferenceUtil.songGridSize } override fun saveGridSize(gridColumns: Int) { - PreferenceUtilKT.songGridSize = gridColumns + PreferenceUtil.songGridSize = gridColumns } override fun loadGridSizeLand(): Int { - return PreferenceUtilKT.songGridSizeLand + return PreferenceUtil.songGridSizeLand } override fun saveGridSizeLand(gridColumns: Int) { - PreferenceUtilKT.songGridSizeLand = gridColumns + PreferenceUtil.songGridSizeLand = gridColumns } override fun setGridSize(gridSize: Int) { adapter?.notifyDataSetChanged() } - - override fun showEmptyView() { - adapter?.swapDataSet(ArrayList()) - } - + override fun loadSortOrder(): String { - return PreferenceUtilKT.songSortOrder + return PreferenceUtil.songSortOrder } override fun saveSortOrder(sortOrder: String) { - PreferenceUtilKT.songSortOrder = sortOrder + PreferenceUtil.songSortOrder = sortOrder } @LayoutRes override fun loadLayoutRes(): Int { - return PreferenceUtilKT.songGridStyle + return PreferenceUtil.songGridStyle } override fun saveLayoutRes(@LayoutRes layoutRes: Int) { - PreferenceUtilKT.songGridStyle = layoutRes + PreferenceUtil.songGridStyle = layoutRes } override fun setSortOrder(sortOrder: String) { diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java b/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java index 6b90fab2..67d3141f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java +++ b/app/src/main/java/code/name/monkey/retromusic/glide/AlbumGlideRequest.java @@ -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.model.Song; import code.name.monkey.retromusic.util.MusicUtil; -import code.name.monkey.retromusic.util.PreferenceUtilKT; +import code.name.monkey.retromusic.util.PreferenceUtil; public class AlbumGlideRequest { private static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.NONE; @@ -70,7 +70,7 @@ public class AlbumGlideRequest { @NonNull public Builder checkIgnoreMediaStore(@NonNull Context context) { - return ignoreMediaStore(PreferenceUtilKT.INSTANCE.isIgnoreMediaStoreArtwork()); + return ignoreMediaStore(PreferenceUtil.INSTANCE.isIgnoreMediaStoreArtwork()); } @NonNull diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/SongGlideRequest.java b/app/src/main/java/code/name/monkey/retromusic/glide/SongGlideRequest.java index 10078d05..da431c4d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/glide/SongGlideRequest.java +++ b/app/src/main/java/code/name/monkey/retromusic/glide/SongGlideRequest.java @@ -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.model.Song; 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. @@ -88,7 +88,7 @@ public class SongGlideRequest { @NonNull public Builder checkIgnoreMediaStore(@NonNull Context context) { - return ignoreMediaStore(PreferenceUtilKT.INSTANCE.isIgnoreMediaStoreArtwork()); + return ignoreMediaStore(PreferenceUtil.INSTANCE.isIgnoreMediaStoreArtwork()); } @NonNull diff --git a/app/src/main/java/code/name/monkey/retromusic/glide/artistimage/ArtistImageLoader.kt b/app/src/main/java/code/name/monkey/retromusic/glide/artistimage/ArtistImageLoader.kt index 04aa2e22..63647f6c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/glide/artistimage/ArtistImageLoader.kt +++ b/app/src/main/java/code/name/monkey/retromusic/glide/artistimage/ArtistImageLoader.kt @@ -18,7 +18,7 @@ import android.content.Context import code.name.monkey.retromusic.deezer.Data import code.name.monkey.retromusic.deezer.DeezerApiService 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.integration.okhttp3.OkHttpUrlLoader import com.bumptech.glide.load.data.DataFetcher @@ -63,7 +63,7 @@ class ArtistImageFetcher( override fun loadData(priority: Priority?): InputStream? { if (!MusicUtil.isArtistNameUnknown(model.artistName) && - PreferenceUtilKT.isAllowedToDownloadMetadata() + PreferenceUtil.isAllowedToDownloadMetadata() ) { val artists = model.artistName.split(",") val response = deezerApiService.getArtistImage(artists[0]).execute() diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/EqualizerHelper.kt b/app/src/main/java/code/name/monkey/retromusic/helper/EqualizerHelper.kt index 4bb74e9f..0842990e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/helper/EqualizerHelper.kt +++ b/app/src/main/java/code/name/monkey/retromusic/helper/EqualizerHelper.kt @@ -98,7 +98,7 @@ class EqualizerHelper private constructor() : EqualizerInterface { } companion object { - private val TAG = "EqualizerHelper" + private const val TAG = "EqualizerHelper" @Volatile private var ourInstance: EqualizerHelper? = null diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.kt b/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.kt index a84eebec..68f10265 100644 --- a/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.kt +++ b/app/src/main/java/code/name/monkey/retromusic/helper/MusicPlayerRemote.kt @@ -30,7 +30,7 @@ import code.name.monkey.retromusic.loaders.SongLoader import code.name.monkey.retromusic.model.Song 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.util.* @@ -213,7 +213,7 @@ object MusicPlayerRemote { ) && musicService != null ) { musicService?.openQueue(queue, startPosition, startPlaying) - if (PreferenceUtilKT.isShuffleModeOn) + if (PreferenceUtil.isShuffleModeOn) setShuffleMode(MusicService.SHUFFLE_MODE_NONE) } } diff --git a/app/src/main/java/code/name/monkey/retromusic/helper/SuperCerealScrollHelper.kt b/app/src/main/java/code/name/monkey/retromusic/helper/SuperCerealScrollHelper.kt deleted file mode 100644 index e69de29b..00000000 diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.kt index 4694db17..51aa4d7a 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.kt +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/AlbumLoader.kt @@ -19,7 +19,7 @@ import android.provider.MediaStore.Audio.AudioColumns import code.name.monkey.retromusic.helper.SortOrder import code.name.monkey.retromusic.model.Album 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 kotlin.collections.ArrayList @@ -107,7 +107,7 @@ object AlbumLoader { } private fun sortSongsByTrackNumber(album: Album) { - when (PreferenceUtilKT.albumDetailSongSortOrder) { + when (PreferenceUtil.albumDetailSongSortOrder) { SortOrder.AlbumSongSortOrder.SONG_TRACK_LIST -> album.songs?.sortWith(Comparator { o1, o2 -> o1.trackNumber.compareTo( o2.trackNumber @@ -132,7 +132,7 @@ object AlbumLoader { } private fun getSongLoaderSortOrder(): String { - return PreferenceUtilKT.albumSortOrder + ", " + - PreferenceUtilKT.albumSongSortOrder + return PreferenceUtil.albumSortOrder + ", " + + PreferenceUtil.albumSongSortOrder } } diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistLoader.kt index c5056ead..37274c54 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistLoader.kt +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/ArtistLoader.kt @@ -18,13 +18,13 @@ import android.content.Context import android.provider.MediaStore.Audio.AudioColumns import code.name.monkey.retromusic.model.Album import code.name.monkey.retromusic.model.Artist -import code.name.monkey.retromusic.util.PreferenceUtilKT +import code.name.monkey.retromusic.util.PreferenceUtil object ArtistLoader { private fun getSongLoaderSortOrder(): String { - return PreferenceUtilKT.artistSortOrder + ", " + - PreferenceUtilKT.artistAlbumSortOrder + ", " + - PreferenceUtilKT.artistSongSortOrder + return PreferenceUtil.artistSortOrder + ", " + + PreferenceUtil.artistAlbumSortOrder + ", " + + PreferenceUtil.artistSongSortOrder } fun getAllArtists(context: Context): ArrayList { diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.kt index d6ca71b4..3e57ebe0 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.kt +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/GenreLoader.kt @@ -19,11 +19,11 @@ import android.database.Cursor import android.net.Uri import android.provider.BaseColumns 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.model.Genre import code.name.monkey.retromusic.model.Song -import code.name.monkey.retromusic.util.PreferenceUtilKT +import code.name.monkey.retromusic.util.PreferenceUtil object GenreLoader { @@ -95,9 +95,9 @@ object GenreLoader { return context.contentResolver.query( Genres.Members.getContentUri("external", genreId.toLong()), baseProjection, - BASE_SELECTION, + IS_MUSIC, null, - PreferenceUtilKT.songSortOrder + PreferenceUtil.songSortOrder ) } catch (e: SecurityException) { return null @@ -153,7 +153,7 @@ object GenreLoader { projection, null, null, - PreferenceUtilKT.genreSortOrder + PreferenceUtil.genreSortOrder ) } catch (e: SecurityException) { return null diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/LastAddedSongsLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/LastAddedSongsLoader.kt index 327c735f..50c669e9 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/LastAddedSongsLoader.kt +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/LastAddedSongsLoader.kt @@ -20,7 +20,7 @@ import android.provider.MediaStore import code.name.monkey.retromusic.model.Album import code.name.monkey.retromusic.model.Artist 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. @@ -33,7 +33,7 @@ object LastAddedSongsLoader { } private fun makeLastAddedCursor(context: Context): Cursor? { - val cutoff = PreferenceUtilKT.lastAddedCutoff + val cutoff = PreferenceUtil.lastAddedCutoff return SongLoader.makeSongCursor( context, MediaStore.Audio.Media.DATE_ADDED + ">?", diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistSongsLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistSongsLoader.kt index 546f538f..6d94ef1d 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistSongsLoader.kt +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/PlaylistSongsLoader.kt @@ -18,7 +18,7 @@ import android.content.Context import android.database.Cursor import android.provider.MediaStore 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.Playlist import code.name.monkey.retromusic.model.PlaylistSong @@ -105,7 +105,7 @@ object PlaylistSongsLoader { MediaStore.Audio.Playlists.Members._ID,//11 AudioColumns.COMPOSER )// 12 - , BASE_SELECTION, null, + , IS_MUSIC, null, MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER ) } catch (e: SecurityException) { diff --git a/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt b/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt index 38bb5edf..39c191bf 100644 --- a/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt +++ b/app/src/main/java/code/name/monkey/retromusic/loaders/SongLoader.kt @@ -18,12 +18,12 @@ import android.content.Context import android.database.Cursor import android.provider.MediaStore 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.model.Song import code.name.monkey.retromusic.providers.BlacklistStore -import code.name.monkey.retromusic.util.PreferenceUtilKT +import code.name.monkey.retromusic.util.PreferenceUtil import java.util.* /** @@ -107,14 +107,14 @@ object SongLoader { context: Context, selection: String?, selectionValues: Array?, - sortOrder: String = PreferenceUtilKT.songSortOrder + sortOrder: String = PreferenceUtil.songSortOrder ): Cursor? { var selectionFinal = selection var selectionValuesFinal = selectionValues selectionFinal = if (selection != null && selection.trim { it <= ' ' } != "") { - "$BASE_SELECTION AND $selectionFinal" + "$IS_MUSIC AND $selectionFinal" } else { - BASE_SELECTION + IS_MUSIC } // Blacklist @@ -129,7 +129,7 @@ object SongLoader { MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, baseProjection, selectionFinal + " AND " + MediaStore.Audio.Media.DURATION + ">= " + - (PreferenceUtilKT.filterLength * 1000), + (PreferenceUtil.filterLength * 1000), selectionValuesFinal, sortOrder ) diff --git a/app/src/main/java/code/name/monkey/retromusic/misc/AppBarStateChangeListener.kt b/app/src/main/java/code/name/monkey/retromusic/misc/AppBarStateChangeListener.kt index cd42abde..6d57337f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/misc/AppBarStateChangeListener.kt +++ b/app/src/main/java/code/name/monkey/retromusic/misc/AppBarStateChangeListener.kt @@ -15,6 +15,7 @@ package code.name.monkey.retromusic.misc import com.google.android.material.appbar.AppBarLayout +import kotlin.math.abs /** * @author Hemanth S (h4h13). @@ -26,21 +27,25 @@ abstract class AppBarStateChangeListener : AppBarLayout.OnOffsetChangedListener private var mCurrentState = State.IDLE override fun onOffsetChanged(appBarLayout: AppBarLayout, i: Int) { - if (i == 0) { - if (mCurrentState != State.EXPANDED) { - onStateChanged(appBarLayout, State.EXPANDED) + when { + i == 0 -> { + if (mCurrentState != State.EXPANDED) { + onStateChanged(appBarLayout, State.EXPANDED) + } + mCurrentState = State.EXPANDED } - mCurrentState = State.EXPANDED - } else if (Math.abs(i) >= appBarLayout.totalScrollRange) { - if (mCurrentState != State.COLLAPSED) { - onStateChanged(appBarLayout, State.COLLAPSED) + abs(i) >= appBarLayout.totalScrollRange -> { + if (mCurrentState != State.COLLAPSED) { + onStateChanged(appBarLayout, State.COLLAPSED) + } + mCurrentState = State.COLLAPSED } - mCurrentState = State.COLLAPSED - } else { - if (mCurrentState != State.IDLE) { - onStateChanged(appBarLayout, State.IDLE) + else -> { + if (mCurrentState != State.IDLE) { + onStateChanged(appBarLayout, State.IDLE) + } + mCurrentState = State.IDLE } - mCurrentState = State.IDLE } } diff --git a/app/src/main/java/code/name/monkey/retromusic/misc/AsyncSearchResultLoader.kt b/app/src/main/java/code/name/monkey/retromusic/misc/AsyncSearchResultLoader.kt deleted file mode 100644 index 4127292e..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/misc/AsyncSearchResultLoader.kt +++ /dev/null @@ -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>(context) { - - override fun loadInBackground(): List? { - val results = ArrayList() - 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 - } -} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/misc/SimpleAnimatorListener.kt b/app/src/main/java/code/name/monkey/retromusic/misc/SimpleAnimatorListener.kt deleted file mode 100644 index 2ee76b78..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/misc/SimpleAnimatorListener.kt +++ /dev/null @@ -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) { - - } -} diff --git a/app/src/main/java/code/name/monkey/retromusic/model/CategoryInfo.java b/app/src/main/java/code/name/monkey/retromusic/model/CategoryInfo.java index db5b6d63..6fdb6f85 100644 --- a/app/src/main/java/code/name/monkey/retromusic/model/CategoryInfo.java +++ b/app/src/main/java/code/name/monkey/retromusic/model/CategoryInfo.java @@ -17,6 +17,9 @@ package code.name.monkey.retromusic.model; import android.os.Parcel; import android.os.Parcelable; +import androidx.annotation.DrawableRes; +import androidx.annotation.StringRes; + import code.name.monkey.retromusic.R; @@ -56,14 +59,14 @@ public class CategoryInfo implements Parcelable { } public enum Category { - 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), - 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), - 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), - 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); + 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), + 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), + 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), + 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); public final int icon; @@ -71,7 +74,7 @@ public class CategoryInfo implements Parcelable { public final int stringRes; - Category(int id, int stringRes, int icon) { + Category(int id, @StringRes int stringRes, @DrawableRes int icon) { this.stringRes = stringRes; this.id = id; this.icon = icon; diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumDetailsPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumDetailsPresenter.kt index be7e64e4..b032530f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumDetailsPresenter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumDetailsPresenter.kt @@ -16,16 +16,7 @@ package code.name.monkey.retromusic.mvp.presenter import code.name.monkey.retromusic.model.Album 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 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. @@ -41,59 +32,4 @@ interface AlbumDetailsView { fun moreAlbums(albums: List) fun aboutAlbum(lastFmAlbum: LastFmAlbum) -} - -interface AlbumDetailsPresenter : Presenter { - fun loadAlbum(albumId: Int) - - fun loadMore(artistId: Int) - - fun aboutAlbum(artist: String, album: String) - - class AlbumDetailsPresenterImpl @Inject constructor( - private val repository: Repository - ) : PresenterImpl(), 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 - } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumPresenter.kt index 0f97fde0..d574a3b3 100644 --- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumPresenter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumPresenter.kt @@ -16,15 +16,6 @@ package code.name.monkey.retromusic.mvp.presenter import code.name.monkey.retromusic.model.Album 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. @@ -32,31 +23,4 @@ import kotlin.coroutines.CoroutineContext interface AlbumsView : BaseView { fun albums(albums: List) -} - -interface AlbumsPresenter : Presenter { - - fun loadAlbums() - - class AlbumsPresenterImpl @Inject constructor( - private val repository: Repository - ) : PresenterImpl(), 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) - } - } - } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/ArtistDetailsPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/ArtistDetailsPresenter.kt index 4aa9d1d1..cd58717f 100644 --- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/ArtistDetailsPresenter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/ArtistDetailsPresenter.kt @@ -16,17 +16,7 @@ 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 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. @@ -38,44 +28,4 @@ interface ArtistDetailsView : BaseView { fun artistInfo(lastFmArtist: LastFmArtist?) fun complete() -} - -interface ArtistDetailsPresenter : Presenter { - - fun loadArtist(artistId: Int) - - fun loadBiography( - name: String, - lang: String? = Locale.getDefault().language, - cache: String? - ) - - class ArtistDetailsPresenterImpl @Inject constructor( - private val repository: Repository - ) : PresenterImpl(), 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() - } - } } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/ArtistPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/ArtistPresenter.kt deleted file mode 100644 index 54a9481b..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/ArtistPresenter.kt +++ /dev/null @@ -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) -} - -interface ArtistsPresenter : Presenter { - - fun loadArtists() - - class ArtistsPresenterImpl @Inject constructor( - private val repository: Repository - ) : PresenterImpl(), 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) - } - } - } -} diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/GenrePresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/GenrePresenter.kt deleted file mode 100644 index f1908e43..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/GenrePresenter.kt +++ /dev/null @@ -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) -} - -interface GenresPresenter : Presenter { - fun loadGenres() - - class GenresPresenterImpl @Inject constructor( - private val repository: Repository - ) : PresenterImpl(), 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) - } - } - } -} diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/PlaylistPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/PlaylistPresenter.kt deleted file mode 100644 index ce1ab456..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/PlaylistPresenter.kt +++ /dev/null @@ -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) -} - -interface PlaylistsPresenter : Presenter { - - fun playlists() - - class PlaylistsPresenterImpl @Inject constructor( - private val repository: Repository - ) : PresenterImpl(), 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) - } - } - } -} - - diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/SongPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/SongPresenter.kt deleted file mode 100644 index c837ca8d..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/SongPresenter.kt +++ /dev/null @@ -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) - - fun showEmptyView() -} - -interface SongPresenter : Presenter { - - fun loadSongs() - - class SongPresenterImpl @Inject constructor( - private val repository: Repository - ) : PresenterImpl(), 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() - } - } -} - - diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.kt b/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.kt index ec8e6d36..a605b17b 100644 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.kt @@ -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.util.NavigationUtil -import code.name.monkey.retromusic.util.PreferenceUtilKT +import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.ViewUtil import com.bumptech.glide.Glide import com.google.android.material.dialog.MaterialAlertDialogBuilder @@ -77,7 +77,7 @@ class AlbumCoverStylePreferenceDialog : DialogFragment(), viewPager.adapter = AlbumCoverStyleAdapter(requireContext()) viewPager.addOnPageChangeListener(this) viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt() - viewPager.currentItem = PreferenceUtilKT.albumCoverStyle.ordinal + viewPager.currentItem = PreferenceUtil.albumCoverStyle.ordinal return MaterialAlertDialogBuilder(requireActivity(), R.style.ThemeOverlay_MaterialComponents_Dialog_Alert) @@ -89,7 +89,7 @@ class AlbumCoverStylePreferenceDialog : DialogFragment(), Toast.makeText(context, result, Toast.LENGTH_SHORT).show() NavigationUtil.goToProVersion(requireActivity()) } else { - PreferenceUtilKT.albumCoverStyle = coverStyle + PreferenceUtil.albumCoverStyle = coverStyle } } .setView(view) @@ -164,5 +164,5 @@ class AlbumCoverStylePreferenceDialog : DialogFragment(), } 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)) } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/LibraryPreference.kt b/app/src/main/java/code/name/monkey/retromusic/preferences/LibraryPreference.kt index 2a873e06..81452827 100644 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/LibraryPreference.kt +++ b/app/src/main/java/code/name/monkey/retromusic/preferences/LibraryPreference.kt @@ -31,7 +31,7 @@ import code.name.monkey.retromusic.R import code.name.monkey.retromusic.adapter.CategoryInfoAdapter import code.name.monkey.retromusic.extensions.colorControlNormal 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 @@ -57,7 +57,7 @@ class LibraryPreferenceDialog : DialogFragment() { .inflate(R.layout.preference_dialog_library_categories, null) val categoryAdapter = CategoryInfoAdapter() - categoryAdapter.categoryInfos = PreferenceUtilKT.libraryCategory + categoryAdapter.categoryInfos = PreferenceUtil.libraryCategory val recyclerView = view.findViewById(R.id.recycler_view) recyclerView.layoutManager = LinearLayoutManager(activity) recyclerView.adapter = categoryAdapter @@ -72,7 +72,7 @@ class LibraryPreferenceDialog : DialogFragment() { .setNeutralButton( R.string.reset_action ) { _, _ -> - categoryAdapter.categoryInfos = PreferenceUtilKT.defaultCategories + categoryAdapter.categoryInfos = PreferenceUtil.defaultCategories } .setNegativeButton(android.R.string.cancel, null) .setPositiveButton( @@ -88,7 +88,7 @@ class LibraryPreferenceDialog : DialogFragment() { Toast.makeText(context, "Not more than 5 items", Toast.LENGTH_SHORT).show() return } - PreferenceUtilKT.libraryCategory = categories + PreferenceUtil.libraryCategory = categories } private fun getSelected(categories: List): Int { diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/MaterialListPreference.kt b/app/src/main/java/code/name/monkey/retromusic/preferences/MaterialListPreference.kt deleted file mode 100644 index 75c7e83c..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/MaterialListPreference.kt +++ /dev/null @@ -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 - val entriesValues = listPreference.entryValues.toList() as ArrayList - 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 - } - } -} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.kt b/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.kt index c6049401..e7f071a0 100644 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.kt @@ -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.util.NavigationUtil -import code.name.monkey.retromusic.util.PreferenceUtilKT +import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.ViewUtil import com.bumptech.glide.Glide import com.google.android.material.dialog.MaterialAlertDialogBuilder @@ -84,7 +84,7 @@ class NowPlayingScreenPreferenceDialog : DialogFragment(), ViewPager.OnPageChang viewPager.adapter = NowPlayingScreenAdapter(requireContext()) viewPager.addOnPageChangeListener(this) viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt() - viewPager.currentItem = PreferenceUtilKT.nowPlayingScreen.ordinal + viewPager.currentItem = PreferenceUtil.nowPlayingScreen.ordinal return MaterialAlertDialogBuilder( requireContext(), @@ -100,7 +100,7 @@ class NowPlayingScreenPreferenceDialog : DialogFragment(), ViewPager.OnPageChang Toast.makeText(context, result, Toast.LENGTH_SHORT).show() NavigationUtil.goToProVersion(requireContext()) } else { - PreferenceUtilKT.nowPlayingScreen = nowPlayingScreen + PreferenceUtil.nowPlayingScreen = nowPlayingScreen } } .setView(view) diff --git a/app/src/main/java/code/name/monkey/retromusic/providers/BlacklistStore.java b/app/src/main/java/code/name/monkey/retromusic/providers/BlacklistStore.java index ea8928b0..bb775b93 100644 --- a/app/src/main/java/code/name/monkey/retromusic/providers/BlacklistStore.java +++ b/app/src/main/java/code/name/monkey/retromusic/providers/BlacklistStore.java @@ -28,7 +28,7 @@ import java.io.File; import java.util.ArrayList; 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; @@ -47,13 +47,13 @@ public class BlacklistStore extends SQLiteOpenHelper { public static synchronized BlacklistStore getInstance(@NonNull final Context context) { if (sInstance == null) { sInstance = new BlacklistStore(context.getApplicationContext()); - if (!PreferenceUtilKT.INSTANCE.isInitializedBlacklist()) { + if (!PreferenceUtil.INSTANCE.isInitializedBlacklist()) { // blacklisted by default sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_ALARMS)); sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_NOTIFICATIONS)); sInstance.addPathImpl(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_RINGTONES)); - PreferenceUtilKT.INSTANCE.setInitializedBlacklist(true); + PreferenceUtil.INSTANCE.setInitializedBlacklist(true); } } return sInstance; diff --git a/app/src/main/java/code/name/monkey/retromusic/service/MultiPlayer.java b/app/src/main/java/code/name/monkey/retromusic/service/MultiPlayer.java index 5673c643..5f49414c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/MultiPlayer.java +++ b/app/src/main/java/code/name/monkey/retromusic/service/MultiPlayer.java @@ -29,7 +29,7 @@ import androidx.annotation.Nullable; import code.name.monkey.retromusic.R; 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) @@ -130,7 +130,7 @@ public class MultiPlayer implements Playback, MediaPlayer.OnErrorListener, Media if (path == null) { return; } - if (PreferenceUtilKT.INSTANCE.isGapLessPlayback()) { + if (PreferenceUtil.INSTANCE.isGapLessPlayback()) { mNextMediaPlayer = new MediaPlayer(); mNextMediaPlayer.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK); mNextMediaPlayer.setAudioSessionId(getAudioSessionId()); diff --git a/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java b/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java index 7f2b26cd..0f17e55a 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java +++ b/app/src/main/java/code/name/monkey/retromusic/service/MusicService.java @@ -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.playback.Playback; 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 static code.name.monkey.retromusic.ConstantsKt.ALBUM_ART_ON_LOCKSCREEN; @@ -257,7 +257,7 @@ public class MusicService extends Service implements String action = intent.getAction(); if (action != null) { if (BluetoothDevice.ACTION_ACL_CONNECTED.equals(action) && - PreferenceUtilKT.INSTANCE.isBluetoothSpeaker()) { + PreferenceUtil.INSTANCE.isBluetoothSpeaker()) { if (VERSION.SDK_INT >= VERSION_CODES.M) { if (getAudioManager().getDevices(AudioManager.GET_DEVICES_OUTPUTS).length > 0) { play(); @@ -388,7 +388,7 @@ public class MusicService extends Service implements getContentResolver() .registerContentObserver(MediaStore.Audio.Playlists.INTERNAL_CONTENT_URI, true, mediaStoreObserver); - PreferenceUtilKT.INSTANCE.registerOnSharedPreferenceChangedListener(this); + PreferenceUtil.INSTANCE.registerOnSharedPreferenceChangedListener(this); restoreState(); @@ -418,7 +418,7 @@ public class MusicService extends Service implements quit(); releaseResources(); getContentResolver().unregisterContentObserver(mediaStoreObserver); - PreferenceUtilKT.INSTANCE.unregisterOnSharedPreferenceChangedListener(this); + PreferenceUtil.INSTANCE.unregisterOnSharedPreferenceChangedListener(this); wakeLock.release(); sendBroadcast(new Intent("code.name.monkey.retromusic.RETRO_MUSIC_SERVICE_DESTROYED")); @@ -664,7 +664,7 @@ public class MusicService extends Service implements public void initNotification() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && - !PreferenceUtilKT.INSTANCE.isClassicNotification()) { + !PreferenceUtil.INSTANCE.isClassicNotification()) { playingNotification = new PlayingNotificationImpl(); } else { playingNotification = new PlayingNotificationOreo(); @@ -1110,13 +1110,13 @@ public class MusicService extends Service implements .putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, null) .putLong(MediaMetadataCompat.METADATA_KEY_NUM_TRACKS, getPlayingQueue().size()); - if (PreferenceUtilKT.INSTANCE.isAlbumArtOnLockScreen()) { + if (PreferenceUtil.INSTANCE.isAlbumArtOnLockScreen()) { final Point screenSize = RetroUtil.getScreenSize(MusicService.this); final BitmapRequestBuilder request = SongGlideRequest.Builder .from(Glide.with(MusicService.this), song) .checkIgnoreMediaStore(MusicService.this) .asBitmap().build(); - if (PreferenceUtilKT.INSTANCE.isBlurredAlbumArt()) { + if (PreferenceUtil.INSTANCE.isBlurredAlbumArt()) { request.transform(new BlurTransformation.Builder(MusicService.this).build()); } runOnUiThread(new Runnable() { @@ -1259,7 +1259,7 @@ public class MusicService extends Service implements } private void registerHeadsetEvents() { - if (!headsetReceiverRegistered && PreferenceUtilKT.INSTANCE.isHeadsetPlugged()) { + if (!headsetReceiverRegistered && PreferenceUtil.INSTANCE.isHeadsetPlugged()) { registerReceiver(headsetReceiver, headsetReceiverIntentFilter); headsetReceiverRegistered = true; } diff --git a/app/src/main/java/code/name/monkey/retromusic/service/PlaybackHandler.java b/app/src/main/java/code/name/monkey/retromusic/service/PlaybackHandler.java index 8b72c894..39b1258c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/PlaybackHandler.java +++ b/app/src/main/java/code/name/monkey/retromusic/service/PlaybackHandler.java @@ -23,7 +23,7 @@ import androidx.annotation.NonNull; 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.META_CHANGED; @@ -52,7 +52,7 @@ class PlaybackHandler extends Handler { switch (msg.what) { case MusicService.DUCK: - if (PreferenceUtilKT.INSTANCE.isAudioDucking()) { + if (PreferenceUtil.INSTANCE.isAudioDucking()) { currentDuckVolume -= .05f; if (currentDuckVolume > .2f) { sendEmptyMessageDelayed(DUCK, 10); @@ -66,7 +66,7 @@ class PlaybackHandler extends Handler { break; case MusicService.UNDUCK: - if (PreferenceUtilKT.INSTANCE.isAudioDucking()) { + if (PreferenceUtil.INSTANCE.isAudioDucking()) { currentDuckVolume += .03f; if (currentDuckVolume < 1f) { sendEmptyMessageDelayed(MusicService.UNDUCK, 10); diff --git a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.kt b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.kt index 61108be9..cd468038 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.kt +++ b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationImpl.kt @@ -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.util.MusicUtil -import code.name.monkey.retromusic.util.PreferenceUtilKT +import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.RetroColorUtil import com.bumptech.glide.Glide import com.bumptech.glide.request.animation.GlideAnimation @@ -150,7 +150,7 @@ class PlayingNotificationImpl : PlayingNotification() { ) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) if (Build.VERSION.SDK_INT <= - Build.VERSION_CODES.O && PreferenceUtilKT.isColoredNotification + Build.VERSION_CODES.O && PreferenceUtil.isColoredNotification ) { builder.color = color } diff --git a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.kt b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.kt index 6457e42d..31872e22 100644 --- a/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.kt +++ b/app/src/main/java/code/name/monkey/retromusic/service/notification/PlayingNotificationOreo.kt @@ -33,7 +33,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper 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 code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil.createBitmap 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) } setBackgroundColor(bgColorFinal) diff --git a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.kt b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.kt index d01451cc..119918fd 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.kt +++ b/app/src/main/java/code/name/monkey/retromusic/util/PreferenceUtil.kt @@ -23,18 +23,18 @@ import com.google.gson.JsonSyntaxException import com.google.gson.reflect.TypeToken import java.io.File -object PreferenceUtilKT { +object PreferenceUtil { private val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(App.getContext()) val defaultCategories = listOf( - CategoryInfo(CategoryInfo.Category.HOME, true), - CategoryInfo(CategoryInfo.Category.SONGS, true), - CategoryInfo(CategoryInfo.Category.ALBUMS, true), - CategoryInfo(CategoryInfo.Category.ARTISTS, true), - CategoryInfo(CategoryInfo.Category.PLAYLISTS, true), - CategoryInfo(CategoryInfo.Category.GENRES, false), - CategoryInfo(CategoryInfo.Category.QUEUE, false), - CategoryInfo(CategoryInfo.Category.FOLDER, false) + CategoryInfo(CategoryInfo.Category.Home, true), + CategoryInfo(CategoryInfo.Category.Songs, true), + CategoryInfo(CategoryInfo.Category.Albums, true), + CategoryInfo(CategoryInfo.Category.Artists, true), + CategoryInfo(CategoryInfo.Category.Playlists, true), + CategoryInfo(CategoryInfo.Category.Genres, false), + CategoryInfo(CategoryInfo.Category.Queue, false), + CategoryInfo(CategoryInfo.Category.Folder, false) ) var libraryCategory: List @@ -484,7 +484,7 @@ object PreferenceUtilKT { return albumCoverStyle } } - return AlbumCoverStyle.CARD + return AlbumCoverStyle.Card } set(value) = sharedPreferences.edit { putInt(ALBUM_COVER_STYLE, value.id) } diff --git a/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java index 6a62c1cf..6bc801c0 100755 --- a/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/RetroUtil.java @@ -142,7 +142,7 @@ public class RetroUtil { } public static boolean isAllowedToDownloadMetadata(final @NonNull Context context) { - switch (PreferenceUtilKT.INSTANCE.getAutoDownloadImagesPolicy()) { + switch (PreferenceUtil.INSTANCE.getAutoDownloadImagesPolicy()) { case "always": return true; case "only_wifi": diff --git a/app/src/main/java/code/name/monkey/retromusic/util/SAFUtil.java b/app/src/main/java/code/name/monkey/retromusic/util/SAFUtil.java index 72574792..10da6d03 100644 --- a/app/src/main/java/code/name/monkey/retromusic/util/SAFUtil.java +++ b/app/src/main/java/code/name/monkey/retromusic/util/SAFUtil.java @@ -119,19 +119,19 @@ public class SAFUtil { public static void saveTreeUri(Context context, Intent data) { Uri uri = data.getData(); 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) public static boolean isTreeUriSaved(Context context) { - return !TextUtils.isEmpty(PreferenceUtilKT.INSTANCE.getSafSdCardUri()); + return !TextUtils.isEmpty(PreferenceUtil.INSTANCE.getSafSdCardUri()); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static boolean isSDCardAccessGranted(Context context) { if (!isTreeUriSaved(context)) return false; - String sdcardUri = PreferenceUtilKT.INSTANCE.getSafSdCardUri(); + String sdcardUri = PreferenceUtil.INSTANCE.getSafSdCardUri(); List perms = context.getContentResolver().getPersistedUriPermissions(); for (UriPermission perm : perms) { @@ -198,7 +198,7 @@ public class SAFUtil { if (isTreeUriSaved(context)) { List 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); } @@ -271,7 +271,7 @@ public class SAFUtil { if (isTreeUriSaved(context)) { List 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); } diff --git a/app/src/main/java/code/name/monkey/retromusic/views/BottomNavigationBarTinted.kt b/app/src/main/java/code/name/monkey/retromusic/views/BottomNavigationBarTinted.kt index 314e089e..91cb5d53 100644 --- a/app/src/main/java/code/name/monkey/retromusic/views/BottomNavigationBarTinted.kt +++ b/app/src/main/java/code/name/monkey/retromusic/views/BottomNavigationBarTinted.kt @@ -25,7 +25,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.NavigationViewUtil 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 com.google.android.material.bottomnavigation.BottomNavigationView @@ -36,7 +36,7 @@ class BottomNavigationBarTinted @JvmOverloads constructor( ) : BottomNavigationView(context, attrs, defStyleAttr) { init { - labelVisibilityMode = PreferenceUtilKT.tabTitleMode + labelVisibilityMode = PreferenceUtil.tabTitleMode val iconColor = ATHUtil.resolveColor(context, android.R.attr.colorControlNormal) val accentColor = ThemeStore.accentColor(context) diff --git a/app/src/main/java/code/name/monkey/retromusic/views/ColorIconsImageView.kt b/app/src/main/java/code/name/monkey/retromusic/views/ColorIconsImageView.kt index 48e7dd85..378ddff4 100644 --- a/app/src/main/java/code/name/monkey/retromusic/views/ColorIconsImageView.kt +++ b/app/src/main/java/code/name/monkey/retromusic/views/ColorIconsImageView.kt @@ -23,7 +23,7 @@ import androidx.core.content.ContextCompat import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ColorUtil 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 @@ -46,7 +46,7 @@ class ColorIconsImageView @JvmOverloads constructor( fun setIconBackgroundColor(color: Int) { 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) backgroundTintList = ColorStateList.valueOf(desaturatedColor) imageTintList = diff --git a/app/src/main/java/code/name/monkey/retromusic/volume/AudioVolumeObserver.java b/app/src/main/java/code/name/monkey/retromusic/volume/AudioVolumeObserver.java deleted file mode 100644 index e5b002a5..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/volume/AudioVolumeObserver.java +++ /dev/null @@ -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; - } - } -} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/volume/AudioVolumeObserver.kt b/app/src/main/java/code/name/monkey/retromusic/volume/AudioVolumeObserver.kt new file mode 100644 index 00000000..72c1ebb0 --- /dev/null +++ b/app/src/main/java/code/name/monkey/retromusic/volume/AudioVolumeObserver.kt @@ -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 + } + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_gradient_player.xml b/app/src/main/res/layout/fragment_gradient_player.xml index 293030f8..f0690de3 100644 --- a/app/src/main/res/layout/fragment_gradient_player.xml +++ b/app/src/main/res/layout/fragment_gradient_player.xml @@ -16,7 +16,7 @@ android:id="@+id/playerAlbumCoverFragment" android:name="code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment" android:layout_width="0dp" - android:layout_height="wrap_content" + android:layout_height="0dp" app:layout_constrainedHeight="true" app:layout_constraintBottom_toTopOf="@id/playbackControlsFragment" app:layout_constraintEnd_toEndOf="parent" @@ -45,7 +45,6 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/playerAlbumCoverFragment" /> - - @@ -144,6 +141,7 @@ android:id="@+id/recyclerView" android:layout_width="0dp" android:layout_height="0dp" + android:background="?attr/colorSurface" android:overScrollMode="never" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent"