Adde search genre

This commit is contained in:
h4h13 2019-12-06 22:43:09 +05:30
parent ee6af2a6d6
commit ff0fccae92
29 changed files with 460 additions and 589 deletions

View file

@ -13,8 +13,8 @@ android {
vectorDrawables.useSupportLibrary = true
applicationId "code.name.monkey.retromusic"
versionCode 391
versionName '3.4.700'
versionCode 392
versionName '3.4.800'
multiDexEnabled true

File diff suppressed because one or more lines are too long

View file

@ -24,6 +24,7 @@ import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.glide.ArtistGlideRequest
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
@ -57,7 +58,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
cab = MaterialCab(this, R.id.cab_stub)
.setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorPrimary)))
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorSurface)))
.start(callback)
return cab as MaterialCab
}
@ -187,16 +188,16 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
}
private fun setColors(color: Int) {
val themeColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color
val themeColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color.ripAlpha()
else ThemeStore.accentColor(this)
songTitle.setTextColor(themeColor)
moreTitle.setTextColor(themeColor)
val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor)
color
color.ripAlpha()
else
ATHUtil.resolveColor(this, R.attr.colorControlNormal)
ATHUtil.resolveColor(this, R.attr.colorSurface)
MaterialUtil.setTint(button = shuffleAction, color = buttonColor)
MaterialUtil.setTint(button = playAction, color = buttonColor)

View file

@ -24,6 +24,7 @@ import code.name.monkey.retromusic.adapter.album.AlbumAdapter
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.glide.ArtistGlideRequest
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
import code.name.monkey.retromusic.helper.MusicPlayerRemote
@ -50,7 +51,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
cab = MaterialCab(this, R.id.cab_stub)
.setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorPrimary)))
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorSurface)))
.start(callback)
return cab as MaterialCab
}
@ -224,21 +225,23 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
}
private fun setColors(color: Int) {
val textColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color
else ThemeStore.accentColor(this)
val textColor = if (PreferenceUtil.getInstance(this).adaptiveColor)
color.ripAlpha()
else
ThemeStore.accentColor(this)
albumTitle.setTextColor(textColor)
songTitle.setTextColor(textColor)
biographyTitle.setTextColor(textColor)
val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor) color
else ATHUtil.resolveColor(this, R.attr.cardBackgroundColor)
val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor)
color.ripAlpha()
else
ATHUtil.resolveColor(this, R.attr.colorSurface)
MaterialUtil.setTint(button = shuffleAction, color = buttonColor)
MaterialUtil.setTint(button = playAction, color = buttonColor)
val toolbarColor = ATHUtil.resolveColor(this, R.attr.colorSurface)
status_bar.setBackgroundColor(toolbarColor)
toolbar.setBackgroundColor(toolbarColor)
@ -272,21 +275,12 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
R.id.action_set_artist_image -> {
val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.type = "image/*"
startActivityForResult(
Intent.createChooser(
intent, getString(R.string.pick_from_local_storage)
), REQUEST_CODE_SELECT_IMAGE
)
startActivityForResult(Intent.createChooser(intent, getString(R.string.pick_from_local_storage)), REQUEST_CODE_SELECT_IMAGE)
return true
}
R.id.action_reset_artist_image -> {
Toast.makeText(
this@ArtistDetailActivity,
resources.getString(R.string.updating),
Toast.LENGTH_SHORT
).show()
CustomArtistImageUtil.getInstance(this@ArtistDetailActivity)
.resetCustomArtistImage(artist)
Toast.makeText(this@ArtistDetailActivity, resources.getString(R.string.updating), Toast.LENGTH_SHORT).show()
CustomArtistImageUtil.getInstance(this@ArtistDetailActivity).resetCustomArtistImage(artist)
forceDownload = true
return true
}

View file

@ -39,7 +39,12 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet
private lateinit var songAdapter: ShuffleButtonSongAdapter
private var cab: MaterialCab? = null
private fun getEmojiByUnicode(unicode: Int): String {
return String(Character.toChars(unicode))
}
private fun checkIsEmpty() {
emptyEmoji.text = getEmojiByUnicode(0x1F631)
empty?.visibility = if (songAdapter.itemCount == 0) View.VISIBLE else View.GONE
}

View file

@ -12,11 +12,15 @@ import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
import code.name.monkey.retromusic.fragments.mainactivity.LibraryFragment
import code.name.monkey.retromusic.fragments.mainactivity.folders.FoldersFragment
import code.name.monkey.retromusic.fragments.mainactivity.home.BannerHomeFragment
import code.name.monkey.retromusic.helper.*
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.SearchQueryHelper
import code.name.monkey.retromusic.interfaces.MainActivityFragmentCallbacks
import code.name.monkey.retromusic.loaders.*
import code.name.monkey.retromusic.loaders.AlbumLoader
import code.name.monkey.retromusic.loaders.ArtistLoader
import code.name.monkey.retromusic.loaders.PlaylistSongsLoader
import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.*
import code.name.monkey.retromusic.util.AppRater
import code.name.monkey.retromusic.util.PreferenceUtil
import io.reactivex.disposables.CompositeDisposable
import java.util.*
@ -49,9 +53,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
) {
setDrawUnderStatusBar()
super.onCreate(savedInstanceState)
getBottomNavigationView().selectedItemId = PreferenceUtil.getInstance(this).lastPage
getBottomNavigationView().setOnNavigationItemSelectedListener {
PreferenceUtil.getInstance(this).lastPage = it.itemId
selectedFragment(it.itemId)
@ -65,7 +67,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
}
checkShowChangelog()
AppRater.appLaunched(this);
AppRater.appLaunched(this)
}
private fun checkShowChangelog() {
@ -108,7 +110,6 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
}
private fun setCurrentFragment(fragment: Fragment, tag: String) {
println("setCurrentFragment -> $tag -> ${supportFragmentManager.findFragmentById(R.id.fragment_container)?.tag}")
if (tag != supportFragmentManager.findFragmentById(R.id.fragment_container)?.tag) {
supportFragmentManager.beginTransaction()
.replace(R.id.fragment_container, fragment, tag).commit()
@ -124,7 +125,6 @@ class MainActivity : AbsSlidingMusicPanelActivity(), SharedPreferences.OnSharedP
if (intent == null) {
return
}
val uri = intent.data
val mimeType = intent.type
var handled = false

View file

@ -190,10 +190,15 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
private fun checkIsEmpty() {
checkForPadding()
emptyEmoji.text = getEmojiByUnicode(0x1F631)
empty.visibility = if (adapter.itemCount == 0) View.VISIBLE else View.GONE
emptyText.visibility = if (adapter.itemCount == 0) View.VISIBLE else View.GONE
}
private fun getEmojiByUnicode(unicode: Int): String {
return String(Character.toChars(unicode))
}
public override fun onPause() {
if (recyclerViewDragDropManager != null) {
recyclerViewDragDropManager!!.cancelDrag()

View file

@ -79,7 +79,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
keyboardPopup.iconTint = this
}
if (savedInstanceState != null) {
query = savedInstanceState.getString(QUERY);
query = savedInstanceState.getString(QUERY)
}
}

View file

@ -60,9 +60,7 @@ public class WhatsNewActivity extends AbsBaseActivity {
toolbar = findViewById(R.id.toolbar);
appBarLayout = findViewById(R.id.appBarLayout);
int primaryColor = INSTANCE.resolveColor(this, R.attr.colorSurface);
toolbar.setBackgroundColor(primaryColor);
appBarLayout.setBackgroundColor(primaryColor);
toolbar.setBackgroundColor(INSTANCE.resolveColor(this, R.attr.colorSurface));
//setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(v -> onBackPressed());
@ -79,7 +77,7 @@ public class WhatsNewActivity extends AbsBaseActivity {
// Inject color values for WebView body background and links
final boolean isDark = INSTANCE.isWindowBackgroundDark(this);
final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, android.R.attr.windowBackground, Color.parseColor(isDark ? "#424242" : "#ffffff")));
final String backgroundColor = colorToCSS(INSTANCE.resolveColor(this, R.attr.colorSurface, Color.parseColor(isDark ? "#424242" : "#ffffff")));
final String contentColor = colorToCSS(Color.parseColor(isDark ? "#ffffff" : "#000000"));
final String changeLog = buf.toString()
.replace("{style-placeholder}", String.format("body { background-color: %s; color: %s; }", backgroundColor, contentColor))

View file

@ -2,9 +2,7 @@ package code.name.monkey.retromusic.activities.base
import android.animation.ValueAnimator
import android.graphics.Color
import android.graphics.Rect
import android.os.Bundle
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
@ -338,12 +336,13 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
bottomNavigationView.menu.add(0, menu.id, 0, menu.stringRes).setIcon(menu.icon)
}
}
print("Tabs -> ${currentTabs.size}")
if (currentTabs.size <= 1) {
toggleBottomNavigationView(true)
}
}
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
/*override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
if (ev?.action == MotionEvent.ACTION_DOWN) {
if (panelState == BottomSheetBehavior.STATE_EXPANDED) {
val outRect = Rect()
@ -354,5 +353,5 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(), AbsPlay
}
}
return super.dispatchTouchEvent(ev)
}
}*/
}

View file

@ -1,7 +1,9 @@
package code.name.monkey.retromusic.adapter
import android.app.Activity
import android.view.*
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
@ -29,18 +31,8 @@ class GenreAdapter(
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val genre = dataSet[position]
if (holder.title != null) {
holder.title!!.text = genre.name
}
if (holder.text != null) {
holder.text!!.text = String.format(
Locale.getDefault(),
"%d %s",
genre.songCount,
if (genre.songCount > 1) activity.getString(R.string.songs)
else activity.getString(R.string.song)
)
}
holder.title?.text = genre.name
holder.text?.text = String.format(Locale.getDefault(), "%d %s", genre.songCount, if (genre.songCount > 1) activity.getString(R.string.songs) else activity.getString(R.string.song))
}
override fun getItemCount(): Int {

View file

@ -1,18 +1,27 @@
package code.name.monkey.retromusic.adapter
import android.app.ActivityOptions
import android.view.*
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
import code.name.monkey.retromusic.glide.*
import code.name.monkey.retromusic.glide.ArtistGlideRequest
import code.name.monkey.retromusic.glide.SongGlideRequest
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.menu.SongMenuHelper
import code.name.monkey.retromusic.model.*
import code.name.monkey.retromusic.util.*
import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.model.Genre
import code.name.monkey.retromusic.model.Song
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.NavigationUtil
import com.bumptech.glide.Glide
import java.util.*
import kotlin.collections.ArrayList
import android.util.Pair as UtilPair
class SearchAdapter(
@ -27,20 +36,14 @@ class SearchAdapter(
override fun getItemViewType(position: Int): Int {
if (dataSet!![position] is Album) return ALBUM
if (dataSet!![position] is Artist) return ARTIST
if (dataSet!![position] is Genre) return GENRE
return if (dataSet!![position] is Song) SONG else HEADER
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return if (viewType == HEADER) ViewHolder(
LayoutInflater.from(activity).inflate(
R.layout.sub_header,
parent,
false
), viewType
) else ViewHolder(
LayoutInflater.from(activity).inflate(R.layout.item_list, parent, false),
viewType
)
return if (viewType == HEADER) ViewHolder(LayoutInflater.from(activity).inflate(R.layout.sub_header, parent, false), viewType)
else
ViewHolder(LayoutInflater.from(activity).inflate(R.layout.item_list, parent, false), viewType)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
@ -64,6 +67,11 @@ class SearchAdapter(
holder.title?.text = song.title
holder.text?.text = song.albumName
}
GENRE -> {
val genre = dataSet?.get(position) as Genre
holder.title?.text = genre.name
holder.text?.text = String.format(Locale.getDefault(), "%d %s", genre.songCount, if (genre.songCount > 1) activity.getString(R.string.songs) else activity.getString(R.string.song))
}
else -> {
holder.title?.text = dataSet?.get(position).toString()
holder.title?.setTextColor(ThemeStore.accentColor(activity))
@ -103,25 +111,16 @@ class SearchAdapter(
val item = dataSet!![adapterPosition]
when (itemViewType) {
ALBUM -> {
val options = ActivityOptions.makeSceneTransitionAnimation(
activity,
UtilPair.create(
image,
activity.getString(R.string.transition_album_art)
)
)
val options = ActivityOptions.makeSceneTransitionAnimation(activity, UtilPair.create(image, activity.getString(R.string.transition_album_art)))
NavigationUtil.goToAlbumOptions(activity, (item as Album).id, options)
}
ARTIST -> {
val options = ActivityOptions.makeSceneTransitionAnimation(
activity,
UtilPair.create(
image,
activity.getString(R.string.transition_artist_image)
)
)
val options = ActivityOptions.makeSceneTransitionAnimation(activity, UtilPair.create(image, activity.getString(R.string.transition_artist_image)))
NavigationUtil.goToArtistOptions(activity, (item as Artist).id, options)
}
GENRE -> {
NavigationUtil.goToGenre(activity, item as Genre)
}
SONG -> {
val playList = ArrayList<Song>()
playList.add(item as Song)
@ -136,5 +135,6 @@ class SearchAdapter(
private const val ALBUM = 1
private const val ARTIST = 2
private const val SONG = 3
private const val GENRE = 4
}
}

View file

@ -60,14 +60,14 @@ class SimplePlayerFragment : AbsPlayerFragment() {
}
override fun toolbarIconColor(): Int {
return ATHUtil.resolveColor(requireContext(), R.attr.iconColor)
return ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal)
}
override fun onColorChanged(color: Int) {
lastColor = color
callbacks?.onPaletteColorChanged()
simplePlaybackControlsFragment.setDark(color)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.iconColor), requireActivity())
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal), requireActivity())
}
@ -87,7 +87,7 @@ class SimplePlayerFragment : AbsPlayerFragment() {
inflateMenu(R.menu.menu_player)
setNavigationOnClickListener { requireActivity().onBackPressed() }
setOnMenuItemClickListener(this@SimplePlayerFragment)
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.iconColor), requireActivity())
ToolbarContentTintHelper.colorizeToolbar(this, ATHUtil.resolveColor(context, R.attr.colorControlNormal), requireActivity())
}
}
}

View file

@ -19,34 +19,21 @@ import android.database.Cursor
import android.net.Uri
import android.provider.BaseColumns
import android.provider.MediaStore.Audio.Genres
import code.name.monkey.retromusic.Constants.baseProjection
import code.name.monkey.retromusic.Constants.BASE_SELECTION
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.PreferenceUtil
import io.reactivex.Observable
import java.util.*
object GenreLoader {
fun getAllGenresFlowable(context: Context): Observable<ArrayList<Genre>> {
return getGenresFromCursorFlowable(context, makeGenreCursor(context))
}
fun getAllGenres(context: Context): ArrayList<Genre> {
return getGenresFromCursor(context, makeGenreCursor(context))
}
fun getSongsFlowable(context: Context, genreId: Int): Observable<ArrayList<Song>> {
// The genres table only stores songs that have a genre specified,
// so we need to get songs without a genre a different way.
return if (genreId == -1) {
getSongsWithNoGenreFlowable(context)
} else SongLoader.getSongsFlowable(makeGenreSongCursor(context, genreId))
}
fun getSongs(context: Context, genreId: Int): ArrayList<Song> {
// The genres table only stores songs that have a genre specified,
// so we need to get songs without a genre a different way.
@ -64,12 +51,6 @@ object GenreLoader {
}
private fun getSongsWithNoGenreFlowable(context: Context): Observable<ArrayList<Song>> {
val selection = BaseColumns._ID + " NOT IN " +
"(SELECT " + Genres.Members.AUDIO_ID + " FROM audio_genres_map)"
return SongLoader.getSongsFlowable(SongLoader.makeSongCursor(context, selection, null))
}
private fun getSongsWithNoGenre(context: Context): ArrayList<Song> {
val selection = BaseColumns._ID + " NOT IN " +
"(SELECT " + Genres.Members.AUDIO_ID + " FROM audio_genres_map)"
@ -112,34 +93,6 @@ object GenreLoader {
}
private fun getGenresFromCursorFlowable(context: Context, cursor: Cursor?): Observable<ArrayList<Genre>> {
return Observable.create { e ->
val genres = ArrayList<Genre>()
if (cursor != null) {
if (cursor.moveToFirst()) {
do {
val genre = getGenreFromCursor(context, cursor)
if (genre.songCount > 0) {
genres.add(genre)
} else {
// try to remove the empty genre from the media store
try {
context.contentResolver.delete(Genres.EXTERNAL_CONTENT_URI, Genres._ID + " == " + genre.id, null)
} catch (ex: Exception) {
ex.printStackTrace()
// nothing we can do then
}
}
} while (cursor.moveToNext())
}
cursor.close()
}
e.onNext(genres)
e.onComplete()
}
}
private fun getGenresFromCursor(context: Context, cursor: Cursor?): ArrayList<Genre> {
val genres = arrayListOf<Genre>()
if (cursor != null) {

View file

@ -16,31 +16,40 @@ package code.name.monkey.retromusic.loaders
import android.content.Context
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.model.Genre
import java.util.*
object SearchLoader {
fun searchAll(context: Context, query: String?): MutableList<Any> {
val results = mutableListOf<Any>()
query?.let {
val songs = SongLoader.getSongs(context, it)
query?.let { searchString ->
val songs = SongLoader.getSongs(context, searchString)
if (songs.isNotEmpty()) {
results.add(context.resources.getString(R.string.songs))
results.addAll(songs)
}
val artists = ArtistLoader.getArtists(context, it)
val artists = ArtistLoader.getArtists(context, searchString)
if (artists.isNotEmpty()) {
results.add(context.resources.getString(R.string.artists))
results.addAll(artists)
}
val albums = AlbumLoader.getAlbums(context, it)
val albums = AlbumLoader.getAlbums(context, searchString)
if (albums.isNotEmpty()) {
results.add(context.resources.getString(R.string.albums))
results.addAll(albums)
}
val genres: List<Genre> = GenreLoader.getAllGenres(context).filter { genre -> genre.name.toLowerCase(Locale.getDefault()).contains(searchString.toLowerCase(Locale.getDefault())) }
genres.forEach {
println(it.name)
}
if (genres.isNotEmpty()) {
results.add(context.resources.getString(R.string.genres))
results.addAll(genres)
}
}
return results
}
}

View file

@ -53,9 +53,7 @@ interface SearchPresenter : Presenter<SearchView> {
override fun search(query: String?) {
launch {
when (val result = repository.search(query)) {
is Success -> withContext(Dispatchers.Main) {
view?.showData(result.data)
}
is Success -> withContext(Dispatchers.Main) { view?.showData(result.data) }
is Error -> withContext(Dispatchers.Main) { view?.showEmptyView() }
}
}

View file

@ -247,12 +247,6 @@ class RepositoryImpl(private val context: Context) : Repository {
}
}
override fun getSongFlowable(id: Int): Observable<Song> {
return SongLoader.getSongFlowable(context, id)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
}
override fun getAlbumFlowable(albumId: Int): Observable<Album> {
return AlbumLoader.getAlbumFlowable(context, albumId)
.subscribeOn(Schedulers.io())
@ -271,70 +265,12 @@ class RepositoryImpl(private val context: Context) : Repository {
.observeOn(AndroidSchedulers.mainThread())
}
override fun getGenreFlowable(genreId: Int): Observable<ArrayList<Song>> {
return GenreLoader.getSongsFlowable(context, genreId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
}
override val favoritePlaylistFlowable: Observable<ArrayList<Playlist>>
get() = PlaylistLoader.getFavoritePlaylistFlowable(context)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
override val allSongsFlowable: Observable<ArrayList<Song>>
get() = SongLoader.getAllSongsFlowable(context)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
override val suggestionSongsFlowable: Observable<ArrayList<Song>>
get() = SongLoader.suggestSongs(context)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
override val allAlbumsFlowable: Observable<ArrayList<Album>>
get() = AlbumLoader.getAllAlbumsFlowable(context)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
override val recentAlbumsFlowable: Observable<ArrayList<Album>>
get() = LastAddedSongsLoader.getLastAddedAlbumsFlowable(context)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
override val topAlbumsFlowable: Observable<ArrayList<Album>>
get() = TopAndRecentlyPlayedTracksLoader.getTopAlbumsFlowable(context)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
override val allArtistsFlowable: Observable<ArrayList<Artist>>
get() = ArtistLoader.getAllArtistsFlowable(context)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
override val recentArtistsFlowable: Observable<ArrayList<Artist>>
get() = LastAddedSongsLoader.getLastAddedArtistsFlowable(context)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
override val topArtistsFlowable: Observable<ArrayList<Artist>>
get() = TopAndRecentlyPlayedTracksLoader.getTopArtistsFlowable(context)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
override val allPlaylistsFlowable: Observable<ArrayList<Playlist>>
get() = PlaylistLoader.getAllPlaylistsFlowoable(context)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
override val allGenresFlowable: Observable<ArrayList<Genre>>
get() = GenreLoader.getAllGenresFlowable(context)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
override fun getSong(id: Int): Song {
return SongLoader.getSong(context, id)
}
@ -347,11 +283,10 @@ class RepositoryImpl(private val context: Context) : Repository {
return ArtistLoader.getArtist(context, artistId.toInt())
}
}
suspend fun <T : Any> safeApiCall(call: suspend () -> Result<T>, errorMessage: String): Result<T> = try {
call.invoke()
} catch (e: Exception) {
Result.Error(IOException(errorMessage, e))
Error(IOException(errorMessage, e))
}

View file

@ -55,28 +55,6 @@ interface Repository {
suspend fun artistById(artistId: Int): Result<Artist>
val allSongsFlowable: Observable<ArrayList<Song>>
val suggestionSongsFlowable: Observable<ArrayList<Song>>
val allAlbumsFlowable: Observable<ArrayList<Album>>
val recentAlbumsFlowable: Observable<ArrayList<Album>>
val topAlbumsFlowable: Observable<ArrayList<Album>>
val allArtistsFlowable: Observable<ArrayList<Artist>>
val recentArtistsFlowable: Observable<ArrayList<Artist>>
val topArtistsFlowable: Observable<ArrayList<Artist>>
val allPlaylistsFlowable: Observable<ArrayList<Playlist>>
val allGenresFlowable: Observable<ArrayList<Genre>>
fun getSongFlowable(id: Int): Observable<Song>
fun getSong(id: Int): Song
fun getAlbumFlowable(albumId: Int): Observable<Album>
@ -89,10 +67,6 @@ interface Repository {
fun getPlaylistSongsFlowable(playlist: Playlist): Observable<ArrayList<Song>>
fun getGenreFlowable(genreId: Int): Observable<ArrayList<Song>>
val favoritePlaylistFlowable: Observable<ArrayList<Playlist>>
}

View file

@ -16,6 +16,7 @@ package code.name.monkey.retromusic.views
import android.content.Context
import android.content.res.ColorStateList
import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.RippleDrawable
import android.util.AttributeSet
import androidx.core.content.ContextCompat
@ -45,7 +46,7 @@ class BottomNavigationBarTinted @JvmOverloads constructor(
itemBackground = RippleDrawable(RippleUtils.convertToRippleDrawableColor(ColorStateList.valueOf(ThemeStore.accentColor(context).addAlpha())), ContextCompat.getDrawable(context, R.drawable.bottom_navigation_item_background), ContextCompat.getDrawable(context, R.drawable.bottom_navigation_item_background_mask))
setOnApplyWindowInsetsListener(null)
//itemRippleColor = ColorStateList.valueOf(accentColor)
backgroundTintList = ColorStateList.valueOf(ATHUtil.resolveColor(context, android.R.attr.windowBackground))
background = ColorDrawable(ATHUtil.resolveColor(context, R.attr.colorSurface))
}
}

View file

@ -65,21 +65,22 @@
android:visibility="gone"
tools:visibility="visible">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="96dp"
android:layout_height="96dp"
app:srcCompat="@drawable/ic_disc_full_black_24dp"
app:tint="?colorOnBackground" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/emptyEmoji"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="@string/empty_text_emoji"
android:textAppearance="@style/TextViewHeadline3" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/emptyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/playlist_empty_text"
android:textAppearance="@style/TextViewNormal"
android:textColor="?colorOnBackground"
android:visibility="gone"
android:text="@string/no_songs"
android:textAppearance="@style/TextViewHeadline5"
android:textColor="?android:attr/textColorSecondary"
tools:visibility="visible" />
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -105,8 +105,8 @@
android:layout_margin="16dp"
android:gravity="center"
android:padding="12dp"
android:src="@drawable/ic_add_photo_white_24dp"
app:tint="?iconColor" />
app:tint="?attr/colorControlNormal"
android:src="@drawable/ic_add_photo_white_24dp" />
</FrameLayout>
<com.google.android.material.textfield.TextInputLayout

View file

@ -23,6 +23,9 @@
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:elevation="0dp"
app:elevation="0dp"
app:liftOnScroll="true">
<com.google.android.material.appbar.MaterialToolbar

View file

@ -13,7 +13,7 @@
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextViewNormal"
android:textColor="?attr/colorOnPrimary"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp" />
<com.google.android.material.textview.MaterialTextView
@ -24,7 +24,7 @@
android:paddingTop="16dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextViewNormal"
android:textColor="?attr/colorOnPrimary"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp" />
<com.google.android.material.textview.MaterialTextView
@ -35,7 +35,7 @@
android:paddingTop="16dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextViewNormal"
android:textColor="?attr/colorOnPrimary"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp" />
<com.google.android.material.textview.MaterialTextView
@ -46,7 +46,7 @@
android:paddingTop="16dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextViewNormal"
android:textColor="?attr/colorOnPrimary"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp" />
<com.google.android.material.textview.MaterialTextView
@ -57,7 +57,7 @@
android:paddingTop="16dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextViewNormal"
android:textColor="?attr/colorOnPrimary"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp" />
<com.google.android.material.textview.MaterialTextView
@ -68,7 +68,7 @@
android:paddingTop="16dp"
android:paddingEnd="16dp"
android:textAppearance="@style/TextViewNormal"
android:textColor="?attr/colorOnPrimary"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp" />
<com.google.android.material.textview.MaterialTextView
@ -80,7 +80,7 @@
android:paddingEnd="16dp"
android:paddingBottom="16dp"
android:textAppearance="@style/TextViewNormal"
android:textColor="?attr/colorOnPrimary"
android:textColor="?android:attr/textColorPrimary"
android:textSize="16sp" />
</LinearLayout>

View file

@ -39,6 +39,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:elevation="0dp"
app:elevation="0dp"
app:liftOnScroll="true">
<com.google.android.material.card.MaterialCardView

View file

@ -40,7 +40,7 @@
android:layout_gravity="center"
android:text="@string/empty"
android:textAppearance="@style/TextViewHeadline5"
android:textColor="?attr/colorOnSecondary"
android:textColor="?android:attr/textColorSecondary"
tools:visibility="visible" />
</LinearLayout>
</FrameLayout>

View file

@ -28,6 +28,7 @@
android:layout_marginEnd="4dp"
android:layout_weight="1"
android:text="@string/action_play_all"
app:backgroundTint="?attr/colorSurface"
app:icon="@drawable/ic_play_arrow_white_24dp" />
<com.google.android.material.button.MaterialButton
@ -38,6 +39,7 @@
android:layout_marginEnd="4dp"
android:layout_weight="1"
android:text="@string/shuffle"
app:backgroundTint="?attr/colorSurface"
app:icon="@drawable/ic_shuffle_white_24dp" />
</LinearLayout>

View file

@ -29,7 +29,7 @@
android:maxLines="1"
android:minHeight="40dp"
android:textAppearance="@style/TextViewNormal"
android:textColor="?attr/colorOnSecondary"
android:textColor="?android:attr/textColorSecondary"
tools:text="@tools:sample/date/hhmm" />
</FrameLayout>
@ -55,7 +55,7 @@
android:layout_weight="0"
android:fontFeatureSettings="onum"
android:padding="4dp"
android:textColor="?attr/colorOnSecondary"
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/menu"
app:layout_constraintTop_toTopOf="parent"

View file

@ -53,7 +53,6 @@
android:layout_gravity="bottom"
android:elevation="0dp"
android:visibility="gone"
app:backgroundTint="?android:attr/windowBackground"
app:itemHorizontalTranslationEnabled="false"
app:itemIconTint="@drawable/bottom_navigation_item_colors"
app:itemTextAppearanceActive="@style/BottomSheetItemTextAppearanceActive"

View file

@ -5,7 +5,7 @@
<item name="md_font_title">@font/circular</item>
<item name="md_font_body">@font/circular</item>
<item name="md_font_button">@font/circular</item>
<item name="md_background_color">@color/md_red_500</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowActivityTransitions">true</item>
<item name="android:fontFamily">@font/circular</item>
@ -20,6 +20,7 @@
<item name="rectSelector">@drawable/rect_selector</item>
<item name="rectSelectorStrong">@drawable/rect_selector_strong</item>
</style>
<style name="Theme.RetroMusic.Base" parent="Theme.MaterialComponents.NoActionBar">
@ -158,7 +159,6 @@
<item name="cornerRadius">8dp</item>
<item name="iconGravity">textStart</item>
<item name="iconTint">?attr/colorControlNormal</item>
<item name="backgroundTint">?attr/colorSurface</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:textAppearance">@style/TextViewNormal</item>
<item name="android:textAllCaps">false</item>