Code refactor

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

View file

@ -32,7 +32,7 @@ object Constants {
const val FAQ_LINK = "https://github.com/h4h13/RetroMusicPlayer/blob/master/FAQ.md"
const val 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"

View file

@ -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);

View file

@ -9,10 +9,12 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import org.jetbrains.annotations.NotNull;
public class RetroBottomSheetBehavior<V extends View> extends BottomSheetBehavior<V> {
private static final String TAG = "CustomBottomSheetBehavi";
private static final String TAG = "RetroBottomSheetBehavior";
private boolean allowDragging = true;
@ -28,7 +30,7 @@ public class RetroBottomSheetBehavior<V extends View> 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;
}

View file

@ -34,7 +34,7 @@ import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.model.lyrics.Lyrics
import code.name.monkey.retromusic.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)
}

View file

@ -47,7 +47,7 @@ import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.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 {

View file

@ -21,7 +21,7 @@ import code.name.monkey.retromusic.extensions.applyToolbar
import code.name.monkey.retromusic.glide.ProfileBannerGlideRequest
import code.name.monkey.retromusic.glide.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()
}

View file

@ -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();
}

View file

@ -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(

View file

@ -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)

View file

@ -39,7 +39,7 @@ import code.name.monkey.retromusic.fragments.player.tiny.TinyPlayerFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.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<CategoryInfo> = PreferenceUtilKT.libraryCategory
val currentTabs: List<CategoryInfo> = PreferenceUtil.libraryCategory
for (tab in currentTabs) {
if (tab.visible) {
val menu = tab.category

View file

@ -18,7 +18,7 @@ import code.name.monkey.appthemehelper.util.MaterialDialogsUtil
import code.name.monkey.appthemehelper.util.VersionUtils
import code.name.monkey.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)

View file

@ -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() {

View file

@ -21,7 +21,7 @@ import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.model.Home
import code.name.monkey.retromusic.model.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 {

View file

@ -22,7 +22,7 @@ import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.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

View file

@ -16,7 +16,7 @@ import code.name.monkey.retromusic.misc.CustomFragmentStatePagerAdapter
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.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
}
}
}

View file

@ -24,7 +24,7 @@ import code.name.monkey.retromusic.interfaces.CabHolder
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.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

View file

@ -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)

View file

@ -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
}
}

View file

@ -35,7 +35,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.service.MusicService.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
) {

View file

@ -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 {

View file

@ -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),
}

View file

@ -19,7 +19,7 @@ import code.name.monkey.retromusic.glide.SongGlideRequest
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.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)

View file

@ -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()

View file

@ -9,7 +9,7 @@ import code.name.monkey.retromusic.adapter.album.AlbumAdapter
import code.name.monkey.retromusic.fragments.ReloadType
import code.name.monkey.retromusic.fragments.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<AlbumAdapter, GridLayoutManager>(),
@ -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 {

View file

@ -9,7 +9,7 @@ import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
import code.name.monkey.retromusic.fragments.ReloadType
import code.name.monkey.retromusic.fragments.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<ArtistAdapter, GridLayoutManager>(),
@ -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 {

View file

@ -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()

View file

@ -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<View>(R.id.status_bar) != null
) {
view.findViewById<View>(R.id.status_bar).visibility = View.GONE

View file

@ -34,7 +34,7 @@ import code.name.monkey.retromusic.model.smartplaylist.HistoryPlaylist
import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
import code.name.monkey.retromusic.model.smartplaylist.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 {

View file

@ -68,7 +68,7 @@ import code.name.monkey.retromusic.misc.WrappedAsyncTaskLoader;
import code.name.monkey.retromusic.model.Song;
import code.name.monkey.retromusic.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();

View file

@ -14,7 +14,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.transform.CarousalPagerTransformer
import code.name.monkey.retromusic.transform.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
)
}
}

View file

@ -26,7 +26,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.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())

View file

@ -25,7 +25,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.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 {

View file

@ -25,7 +25,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.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()

View file

@ -23,7 +23,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.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 {

View file

@ -44,7 +44,7 @@ import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper.Callback
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.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 {

View file

@ -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 {

View file

@ -23,7 +23,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.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 {

View file

@ -27,7 +27,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.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()

View file

@ -28,7 +28,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.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 {

View file

@ -18,7 +18,7 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.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)
}
}

View file

@ -29,7 +29,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.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 {

View file

@ -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<Song, Void, Boolean>() {
updateIsFavoriteTask =
object : AsyncTask<Song, Void, Boolean>() {
override fun doInBackground(vararg params: Song): Boolean? {
val activity = activity
return if (activity != null) {

View file

@ -39,7 +39,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.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()

View file

@ -20,7 +20,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.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()

View file

@ -16,7 +16,7 @@ import code.name.monkey.retromusic.fragments.player.PlayerAlbumCoverFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.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)
}
}

View file

@ -27,7 +27,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.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 {

View file

@ -37,7 +37,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.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())

View file

@ -27,7 +27,7 @@ import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.fragments.base.AbsPlayerFragment
import code.name.monkey.retromusic.fragments.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 {

View file

@ -27,7 +27,7 @@ import code.name.monkey.retromusic.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.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())

View file

@ -21,7 +21,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.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())

View file

@ -21,7 +21,7 @@ import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.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 {

View file

@ -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?) {

View file

@ -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) {

View file

@ -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
}

View file

@ -10,14 +10,11 @@ import code.name.monkey.retromusic.adapter.song.SongAdapter
import code.name.monkey.retromusic.fragments.ReloadType
import code.name.monkey.retromusic.fragments.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<SongAdapter, GridLayoutManager>(),
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<Song>) {
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) {

View file

@ -20,7 +20,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteTranscoder;
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper;
import code.name.monkey.retromusic.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

View file

@ -34,7 +34,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteTranscoder;
import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper;
import code.name.monkey.retromusic.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

View file

@ -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()

View file

@ -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

View file

@ -30,7 +30,7 @@ import code.name.monkey.retromusic.loaders.SongLoader
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.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)
}
}

View file

@ -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
}
}

View file

@ -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<Artist> {

View file

@ -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

View file

@ -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 + ">?",

View file

@ -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) {

View file

@ -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<String>?,
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
)

View file

@ -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
}
}

View file

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

View file

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

View file

@ -17,6 +17,9 @@ package code.name.monkey.retromusic.model;
import android.os.Parcel;
import android.os.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;

View file

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

View file

@ -16,15 +16,6 @@ package code.name.monkey.retromusic.mvp.presenter
import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.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.
@ -33,30 +24,3 @@ interface AlbumsView : BaseView {
fun albums(albums: List<Album>)
}
interface AlbumsPresenter : Presenter<AlbumsView> {
fun loadAlbums()
class AlbumsPresenterImpl @Inject constructor(
private val repository: Repository
) : PresenterImpl<AlbumsView>(), AlbumsPresenter, CoroutineScope {
private val job = Job()
override val coroutineContext: CoroutineContext
get() = Dispatchers.IO + job
override fun detachView() {
super.detachView()
job.cancel()
}
override fun loadAlbums() {
launch {
val result = repository.allAlbums()
view?.albums(result)
}
}
}
}

View file

@ -16,17 +16,7 @@ package code.name.monkey.retromusic.mvp.presenter
import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.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.
@ -39,43 +29,3 @@ interface ArtistDetailsView : BaseView {
fun complete()
}
interface ArtistDetailsPresenter : Presenter<ArtistDetailsView> {
fun loadArtist(artistId: Int)
fun loadBiography(
name: String,
lang: String? = Locale.getDefault().language,
cache: String?
)
class ArtistDetailsPresenterImpl @Inject constructor(
private val repository: Repository
) : PresenterImpl<ArtistDetailsView>(), ArtistDetailsPresenter, CoroutineScope {
override val coroutineContext: CoroutineContext
get() = Dispatchers.IO + job
private val job = Job()
override fun loadBiography(name: String, lang: String?, cache: String?) {
launch {
val result = repository.artistInfo(name, lang, cache)
view?.artistInfo(result)
}
}
override fun loadArtist(artistId: Int) {
launch {
val result = repository.artistById(artistId)
view?.artist(result)
}
}
override fun detachView() {
super.detachView()
job.cancel()
}
}
}

View file

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

View file

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

View file

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

View file

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

View file

@ -37,7 +37,7 @@ import code.name.monkey.retromusic.extensions.colorControlNormal
import code.name.monkey.retromusic.fragments.AlbumCoverStyle
import code.name.monkey.retromusic.fragments.AlbumCoverStyle.*
import code.name.monkey.retromusic.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))
}

View file

@ -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<RecyclerView>(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<CategoryInfo>): Int {

View file

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

View file

@ -36,7 +36,7 @@ import code.name.monkey.retromusic.extensions.colorControlNormal
import code.name.monkey.retromusic.fragments.NowPlayingScreen
import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
import code.name.monkey.retromusic.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)

View file

@ -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;

View file

@ -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());

View file

@ -81,7 +81,7 @@ import code.name.monkey.retromusic.service.notification.PlayingNotificationImpl;
import code.name.monkey.retromusic.service.notification.PlayingNotificationOreo;
import code.name.monkey.retromusic.service.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<?, Bitmap> 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;
}

View file

@ -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);

View file

@ -32,7 +32,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.service.MusicService.*
import code.name.monkey.retromusic.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
}

View file

@ -33,7 +33,7 @@ import code.name.monkey.retromusic.glide.palette.BitmapPaletteWrapper
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.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)

View file

@ -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<CategoryInfo>
@ -484,7 +484,7 @@ object PreferenceUtilKT {
return albumCoverStyle
}
}
return AlbumCoverStyle.CARD
return AlbumCoverStyle.Card
}
set(value) = sharedPreferences.edit { putInt(ALBUM_COVER_STYLE, value.id) }

View file

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

View file

@ -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<UriPermission> perms = context.getContentResolver().getPersistedUriPermissions();
for (UriPermission perm : perms) {
@ -198,7 +198,7 @@ public class SAFUtil {
if (isTreeUriSaved(context)) {
List<String> pathSegments = new ArrayList<>(Arrays.asList(audio.getFile().getAbsolutePath().split("/")));
Uri sdcard = Uri.parse(PreferenceUtilKT.INSTANCE.getSafSdCardUri());
Uri sdcard = Uri.parse(PreferenceUtil.INSTANCE.getSafSdCardUri());
uri = findDocument(DocumentFile.fromTreeUri(context, sdcard), pathSegments);
}
@ -271,7 +271,7 @@ public class SAFUtil {
if (isTreeUriSaved(context)) {
List<String> pathSegments = new ArrayList<>(Arrays.asList(path.split("/")));
Uri sdcard = Uri.parse(PreferenceUtilKT.INSTANCE.getSafSdCardUri());
Uri sdcard = Uri.parse(PreferenceUtil.INSTANCE.getSafSdCardUri());
uri = findDocument(DocumentFile.fromTreeUri(context, sdcard), pathSegments);
}

View file

@ -25,7 +25,7 @@ import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.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)

View file

@ -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 =

View file

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

View file

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

View file

@ -16,7 +16,7 @@
android:id="@+id/playerAlbumCoverFragment"
android: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" />
<FrameLayout
android:id="@+id/statusBarContainer"
android:layout_width="match_parent"
@ -57,14 +56,12 @@
<include layout="@layout/status_bar" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/playerQueueSheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorSurface"
app:behavior_hideable="false"
app:layout_behavior="code.name.monkey.retromusic.RetroBottomSheetBehavior">
@ -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"