diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/WriteTagsAsyncTask.java b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/WriteTagsAsyncTask.java index 81a8a7a5..7dfa6f7a 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/WriteTagsAsyncTask.java +++ b/app/src/main/java/code/name/monkey/retromusic/activities/tageditor/WriteTagsAsyncTask.java @@ -34,8 +34,7 @@ import code.name.monkey.retromusic.misc.UpdateToastMediaScannerCompletionListene import code.name.monkey.retromusic.util.MusicUtil; import code.name.monkey.retromusic.util.SAFUtil; -public class WriteTagsAsyncTask extends - DialogAsyncTask { +public class WriteTagsAsyncTask extends DialogAsyncTask { private WeakReference activity; diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/song/SongAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/song/SongAdapter.kt index 2c0caa40..1fa9f52c 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/song/SongAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/song/SongAdapter.kt @@ -3,7 +3,6 @@ package code.name.monkey.retromusic.adapter.song import android.app.ActivityOptions import android.content.res.ColorStateList import android.content.res.Resources -import android.graphics.drawable.Drawable import android.view.LayoutInflater import android.view.MenuItem import android.view.View @@ -25,12 +24,10 @@ 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.PreferenceUtil - import code.name.monkey.retromusic.util.color.MediaNotificationProcessor import com.afollestad.materialcab.MaterialCab import com.bumptech.glide.Glide import me.zhanghai.android.fastscroll.PopupTextProvider -import java.util.* /** * Created by hemanths on 13/08/17. @@ -56,7 +53,7 @@ open class SongAdapter( } open fun swapDataSet(dataSet: List) { - this.dataSet = dataSet.toMutableList() + this.dataSet = ArrayList(dataSet) notifyDataSetChanged() } @@ -109,11 +106,6 @@ open class SongAdapter( .checkIgnoreMediaStore(activity) .generatePalette(activity).build() .into(object : RetroMusicColoredTarget(holder.image!!) { - override fun onLoadCleared(placeholder: Drawable?) { - super.onLoadCleared(placeholder) - - } - override fun onColorReady(colors: MediaNotificationProcessor) { setColors(colors, holder) } @@ -210,7 +202,6 @@ open class SongAdapter( } companion object { - val TAG: String = SongAdapter::class.java.simpleName } } diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.kt index 009cd5b3..346d5e31 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/AddToPlaylistDialog.kt @@ -19,6 +19,7 @@ import android.os.Bundle import androidx.fragment.app.DialogFragment import code.name.monkey.retromusic.EXTRA_SONG import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.extensions.colorButtons import code.name.monkey.retromusic.extensions.extraNotNull import code.name.monkey.retromusic.loaders.PlaylistLoader import code.name.monkey.retromusic.model.Song @@ -57,7 +58,7 @@ class AddToPlaylistDialog : DialogFragment() { } dismiss() } - .create() + .create().colorButtons() } companion object { diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/CreatePlaylistDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/CreatePlaylistDialog.kt index 4b232c4c..91709505 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/CreatePlaylistDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/CreatePlaylistDialog.kt @@ -23,6 +23,7 @@ import androidx.fragment.app.DialogFragment import code.name.monkey.appthemehelper.util.MaterialUtil import code.name.monkey.retromusic.EXTRA_SONG import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.extensions.colorButtons import code.name.monkey.retromusic.extensions.extraNotNull import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.PlaylistsUtil @@ -65,6 +66,7 @@ class CreatePlaylistDialog : DialogFragment() { } } .create() + .colorButtons() } companion object { diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/DeletePlaylistDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/DeletePlaylistDialog.kt index a3026e81..a3f01f58 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/DeletePlaylistDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/DeletePlaylistDialog.kt @@ -20,6 +20,7 @@ import androidx.core.text.HtmlCompat import androidx.fragment.app.DialogFragment import code.name.monkey.retromusic.EXTRA_PLAYLIST import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.extensions.colorButtons import code.name.monkey.retromusic.extensions.extraNotNull import code.name.monkey.retromusic.model.Playlist import code.name.monkey.retromusic.util.PlaylistsUtil @@ -57,6 +58,7 @@ class DeletePlaylistDialog : DialogFragment() { PlaylistsUtil.deletePlaylists(requireContext(), playlists) } .create() + .colorButtons() } companion object { diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsDialog.kt index 2151104b..6c751b97 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/DeleteSongsDialog.kt @@ -23,6 +23,7 @@ import androidx.fragment.app.DialogFragment import code.name.monkey.retromusic.EXTRA_SONG import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.saf.SAFGuideActivity +import code.name.monkey.retromusic.extensions.colorButtons import code.name.monkey.retromusic.extensions.extraNotNull import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.model.Song @@ -74,6 +75,7 @@ class DeleteSongsDialog : DialogFragment() { deleteSongsAsyncTask?.execute(DeleteSongsAsyncTask.LoadingInfo(songs, null)) } .create() + .colorButtons() } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/RemoveFromPlaylistDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/RemoveFromPlaylistDialog.kt index 206a89e7..74279284 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/RemoveFromPlaylistDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/RemoveFromPlaylistDialog.kt @@ -21,6 +21,7 @@ import androidx.fragment.app.DialogFragment import code.name.monkey.retromusic.EXTRA_SONG import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R.string +import code.name.monkey.retromusic.extensions.colorButtons import code.name.monkey.retromusic.model.PlaylistSong import code.name.monkey.retromusic.util.PlaylistsUtil import com.google.android.material.dialog.MaterialAlertDialogBuilder @@ -65,6 +66,7 @@ class RemoveFromPlaylistDialog : DialogFragment() { } .setNegativeButton(android.R.string.cancel, null) .create() + .colorButtons() } companion object { diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/RenamePlaylistDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/RenamePlaylistDialog.kt index ba11e6ef..91951fa6 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/RenamePlaylistDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/RenamePlaylistDialog.kt @@ -22,6 +22,7 @@ import android.view.LayoutInflater import androidx.fragment.app.DialogFragment import code.name.monkey.appthemehelper.util.MaterialUtil import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.extensions.colorButtons import code.name.monkey.retromusic.extensions.extraNotNull import code.name.monkey.retromusic.util.PlaylistsUtil import com.google.android.material.dialog.MaterialAlertDialogBuilder @@ -60,6 +61,7 @@ class RenamePlaylistDialog : DialogFragment() { } } .create() + .colorButtons() } companion object { diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.kt index 70e69ae5..5f7e72b1 100755 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/SleepTimerDialog.kt @@ -31,6 +31,7 @@ import android.widget.Toast import androidx.fragment.app.DialogFragment import code.name.monkey.retromusic.R import code.name.monkey.retromusic.extensions.addAccentColor +import code.name.monkey.retromusic.extensions.colorButtons import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService.ACTION_PENDING_QUIT @@ -132,6 +133,7 @@ class SleepTimerDialog : DialogFragment() { } } .create() + .colorButtons() } private fun updateTimeDisplayTime() { diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/SongDetailDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/SongDetailDialog.kt index 5bc2aba3..2ac82aff 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/SongDetailDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/SongDetailDialog.kt @@ -29,6 +29,7 @@ import androidx.core.text.HtmlCompat import androidx.fragment.app.DialogFragment import code.name.monkey.retromusic.EXTRA_SONG import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.extensions.colorButtons import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.MusicUtil import com.google.android.material.dialog.MaterialAlertDialogBuilder @@ -157,6 +158,7 @@ class SongDetailDialog : DialogFragment() { .setPositiveButton(android.R.string.ok, null) .setView(dialogView) .create() + .colorButtons() } companion object { diff --git a/app/src/main/java/code/name/monkey/retromusic/dialogs/SongShareDialog.kt b/app/src/main/java/code/name/monkey/retromusic/dialogs/SongShareDialog.kt index 2f039e63..c85d7449 100644 --- a/app/src/main/java/code/name/monkey/retromusic/dialogs/SongShareDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/dialogs/SongShareDialog.kt @@ -21,6 +21,7 @@ import androidx.fragment.app.DialogFragment import code.name.monkey.retromusic.EXTRA_SONG import code.name.monkey.retromusic.R import code.name.monkey.retromusic.activities.ShareInstagramStory +import code.name.monkey.retromusic.extensions.colorButtons import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.util.MusicUtil import com.google.android.material.dialog.MaterialAlertDialogBuilder @@ -48,6 +49,7 @@ class SongShareDialog : DialogFragment() { withAction(which, song, listening) } .create() + .colorButtons() } private fun withAction( diff --git a/app/src/main/java/code/name/monkey/retromusic/extensions/ColorExt.kt b/app/src/main/java/code/name/monkey/retromusic/extensions/ColorExt.kt index b5d37920..00a55240 100644 --- a/app/src/main/java/code/name/monkey/retromusic/extensions/ColorExt.kt +++ b/app/src/main/java/code/name/monkey/retromusic/extensions/ColorExt.kt @@ -21,11 +21,13 @@ import android.graphics.Color import android.widget.CheckBox import android.widget.SeekBar import androidx.annotation.AttrRes +import androidx.appcompat.app.AlertDialog import androidx.appcompat.widget.Toolbar import androidx.fragment.app.Fragment import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ColorUtil +import code.name.monkey.retromusic.App import code.name.monkey.retromusic.R fun Int.ripAlpha(): Int { @@ -77,4 +79,14 @@ fun SeekBar.addAccentColor() { val colorState = ColorStateList.valueOf(ThemeStore.accentColor(context)) progressTintList = colorState thumbTintList = colorState +} + +fun AlertDialog.colorButtons(): AlertDialog { + setOnShowListener { + getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(ThemeStore.accentColor(App.getContext())) + getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(ThemeStore.accentColor(App.getContext())) + getButton(AlertDialog.BUTTON_NEUTRAL).setTextColor(ThemeStore.accentColor(App.getContext())) + + } + return this } \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumPresenter.kt deleted file mode 100644 index d574a3b3..00000000 --- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/AlbumPresenter.kt +++ /dev/null @@ -1,26 +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.Album -import code.name.monkey.retromusic.mvp.BaseView - -/** - * Created by hemanths on 12/08/17. - */ -interface AlbumsView : BaseView { - - fun albums(albums: List) -} \ No newline at end of file diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/GenreDetailsPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/GenreDetailsPresenter.kt index 9775a11f..a3782fd1 100644 --- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/GenreDetailsPresenter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/GenreDetailsPresenter.kt @@ -19,10 +19,8 @@ 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 kotlinx.coroutines.* +import kotlinx.coroutines.Dispatchers.Main import kotlin.coroutines.CoroutineContext /** @@ -54,7 +52,7 @@ interface GenreDetailsPresenter : Presenter { override fun loadGenreSongs(genreId: Int) { launch { val result = repository.getGenre(genreId) - view?.songs(result) + withContext(Main) { view?.songs(result) } } } } diff --git a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/PlaylistSongsPresenter.kt b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/PlaylistSongsPresenter.kt index 7c66df1d..df7d2e52 100644 --- a/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/PlaylistSongsPresenter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/mvp/presenter/PlaylistSongsPresenter.kt @@ -21,10 +21,11 @@ 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.Dispatchers.IO +import kotlinx.coroutines.Dispatchers.Main import kotlinx.coroutines.Job import kotlinx.coroutines.launch - +import kotlinx.coroutines.withContext import kotlin.coroutines.CoroutineContext /** @@ -45,12 +46,12 @@ interface PlaylistSongsPresenter : Presenter { private var job: Job = Job() override val coroutineContext: CoroutineContext - get() = Dispatchers.IO + job + get() = IO + job override fun loadPlaylistSongs(playlist: Playlist) { launch { val songs = repository.getPlaylistSongs(playlist) - view?.songs(songs) + withContext(Main) { view?.songs(songs) } } } diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.kt b/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.kt index a605b17b..51f70e06 100644 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/preferences/AlbumCoverStylePreferenceDialog.kt @@ -33,6 +33,7 @@ import androidx.viewpager.widget.ViewPager import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference import code.name.monkey.retromusic.App import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.extensions.colorButtons import code.name.monkey.retromusic.extensions.colorControlNormal import code.name.monkey.retromusic.fragments.AlbumCoverStyle import code.name.monkey.retromusic.fragments.AlbumCoverStyle.* @@ -94,6 +95,7 @@ class AlbumCoverStylePreferenceDialog : DialogFragment(), } .setView(view) .create() + .colorButtons() } override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/BlacklistPreferenceDialog.kt b/app/src/main/java/code/name/monkey/retromusic/preferences/BlacklistPreferenceDialog.kt index e43b778d..df7a9a64 100644 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/BlacklistPreferenceDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/preferences/BlacklistPreferenceDialog.kt @@ -25,6 +25,7 @@ import androidx.fragment.app.DialogFragment import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference import code.name.monkey.retromusic.R import code.name.monkey.retromusic.dialogs.BlacklistFolderChooserDialog +import code.name.monkey.retromusic.extensions.colorButtons import code.name.monkey.retromusic.extensions.colorControlNormal import code.name.monkey.retromusic.providers.BlacklistStore import com.google.android.material.dialog.MaterialAlertDialogBuilder @@ -80,6 +81,8 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog ).clear() } .setNegativeButton(android.R.string.cancel, null) + .create() + .colorButtons() .show() } .setNegativeButton(R.string.add_action) { _, _ -> @@ -91,8 +94,7 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog MaterialAlertDialogBuilder( requireActivity(), R.style.ThemeOverlay_MaterialComponents_Dialog_Alert - ) - .setTitle(R.string.remove_from_blacklist) + ).setTitle(R.string.remove_from_blacklist) .setMessage( HtmlCompat.fromHtml( String.format( @@ -110,9 +112,9 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog refreshBlacklistData() } .setNegativeButton(android.R.string.cancel, null) - .show() + .show().colorButtons() } - .create() + .create().colorButtons() } private lateinit var paths: ArrayList diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/LibraryPreference.kt b/app/src/main/java/code/name/monkey/retromusic/preferences/LibraryPreference.kt index 81452827..f0ed957e 100644 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/LibraryPreference.kt +++ b/app/src/main/java/code/name/monkey/retromusic/preferences/LibraryPreference.kt @@ -29,6 +29,7 @@ import androidx.recyclerview.widget.RecyclerView import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference import code.name.monkey.retromusic.R import code.name.monkey.retromusic.adapter.CategoryInfoAdapter +import code.name.monkey.retromusic.extensions.colorButtons import code.name.monkey.retromusic.extensions.colorControlNormal import code.name.monkey.retromusic.model.CategoryInfo import code.name.monkey.retromusic.util.PreferenceUtil @@ -80,6 +81,7 @@ class LibraryPreferenceDialog : DialogFragment() { ) { _, _ -> updateCategories(categoryAdapter.categoryInfos) } .setView(view) .create() + .colorButtons() } private fun updateCategories(categories: List) { diff --git a/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.kt b/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.kt index e7f071a0..fe078aa7 100644 --- a/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.kt +++ b/app/src/main/java/code/name/monkey/retromusic/preferences/NowPlayingScreenPreferenceDialog.kt @@ -32,6 +32,7 @@ import androidx.viewpager.widget.ViewPager import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference import code.name.monkey.retromusic.App import code.name.monkey.retromusic.R +import code.name.monkey.retromusic.extensions.colorButtons import code.name.monkey.retromusic.extensions.colorControlNormal import code.name.monkey.retromusic.fragments.NowPlayingScreen import code.name.monkey.retromusic.fragments.NowPlayingScreen.* @@ -105,23 +106,7 @@ class NowPlayingScreenPreferenceDialog : DialogFragment(), ViewPager.OnPageChang } .setView(view) .create() - /*.show { - title(R.string.pref_title_now_playing_screen_appearance) - positiveButton(R.string.set) { - val nowPlayingScreen = values()[viewPagerPosition] - if (isNowPlayingThemes(nowPlayingScreen)) { - val result = - getString(nowPlayingScreen.titleRes) + " theme is Pro version feature." - Toast.makeText(context, result, Toast.LENGTH_SHORT).show() - NavigationUtil.goToProVersion(requireContext()) - } else { - PreferenceUtilKT.nowPlayingScreen = nowPlayingScreen - } - } - - negativeButton(android.R.string.cancel) - customView(view = view, scrollable = false, noVerticalPadding = false) - }*/ + .colorButtons() } companion object {