All Dialog are with color buttons now

This commit is contained in:
Hemanth S 2020-07-19 16:51:15 +05:30
parent 76331eae7d
commit f85c55cf49
19 changed files with 52 additions and 69 deletions

View file

@ -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<WriteTagsAsyncTask.LoadingInfo, Integer, String[]> {
public class WriteTagsAsyncTask extends DialogAsyncTask<WriteTagsAsyncTask.LoadingInfo, Integer, String[]> {
private WeakReference<Activity> activity;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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<GenreDetailsView> {
override fun loadGenreSongs(genreId: Int) {
launch {
val result = repository.getGenre(genreId)
view?.songs(result)
withContext(Main) { view?.songs(result) }
}
}
}

View file

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

View file

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

View file

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

View file

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

View file

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