Merge branch 'dev' of https://github.com/h4h13/RetroMusicPlayer into dev
This commit is contained in:
commit
02a735a9ca
379 changed files with 1592 additions and 2283 deletions
|
@ -41,15 +41,6 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
flavorDimensions "default"
|
||||
|
||||
productFlavors {
|
||||
normal {
|
||||
dimension "default"
|
||||
}
|
||||
}
|
||||
|
||||
packagingOptions {
|
||||
exclude 'META-INF/LICENSE'
|
||||
exclude 'META-INF/NOTICE'
|
||||
|
@ -87,17 +78,15 @@ dependencies {
|
|||
|
||||
implementation "androidx.gridlayout:gridlayout:1.0.0"
|
||||
implementation "androidx.cardview:cardview:1.0.0"
|
||||
implementation "androidx.palette:palette:1.0.0"
|
||||
implementation "androidx.viewpager2:viewpager2:1.1.0-alpha01"
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.annotation:annotation:1.1.0'
|
||||
implementation 'androidx.preference:preference:1.1.1'
|
||||
|
||||
implementation 'androidx.preference:preference-ktx:1.1.1'
|
||||
implementation 'androidx.core:core-ktx:1.3.0'
|
||||
implementation 'androidx.fragment:fragment-ktx:1.2.5'
|
||||
implementation 'androidx.palette:palette-ktx:1.0.0'
|
||||
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta8'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||
|
||||
implementation 'com.google.android.material:material:1.3.0-alpha01'
|
||||
|
@ -118,11 +107,8 @@ dependencies {
|
|||
implementation('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.11.0@aar') {
|
||||
transitive = true
|
||||
}
|
||||
/*UI Library*/
|
||||
implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1'
|
||||
|
||||
def kotlin_coroutines_version = "1.3.8"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
def kotlin_coroutines_version = "1.3.3"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_coroutines_version"
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
|
||||
|
||||
|
@ -141,9 +127,13 @@ dependencies {
|
|||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
|
||||
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
|
||||
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
|
||||
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
|
||||
|
||||
implementation 'me.jorgecastillo:androidcolorx:0.2.0'
|
||||
debugImplementation 'com.amitshekhar.android:debug-db:1.0.4'
|
||||
implementation 'com.github.dhaval2404:imagepicker:1.7.1'
|
||||
|
||||
def koin_version = "2.1.5"
|
||||
implementation "org.koin:koin-core:$koin_version"
|
||||
implementation "org.koin:koin-android:$koin_version"
|
||||
implementation "org.koin:koin-android-viewmodel:$koin_version"
|
||||
}
|
20
app/release/output.json
Normal file
20
app/release/output.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"version": 1,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "code.name.monkey.retromusic",
|
||||
"variantName": "release",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"properties": [],
|
||||
"versionCode": 10438,
|
||||
"versionName": "10438",
|
||||
"enabled": true,
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -106,7 +106,7 @@
|
|||
</activity>
|
||||
<activity android:name=".activities.albums.AlbumDetailsActivity" />
|
||||
<activity android:name=".activities.artists.ArtistDetailActivity" />
|
||||
<activity android:name=".activities.PlaylistDetailActivity" />
|
||||
<activity android:name=".activities.playlist.PlaylistDetailActivity" />
|
||||
<activity android:name=".activities.PlayingQueueActivity" />
|
||||
<activity android:name=".activities.AboutActivity" />
|
||||
<activity android:name=".activities.tageditor.AlbumTagEditorActivity" />
|
||||
|
@ -121,7 +121,7 @@
|
|||
<activity android:name=".activities.ShareInstagramStory" />
|
||||
<activity android:name=".activities.DriveModeActivity" />
|
||||
<activity
|
||||
android:name=".activities.SearchActivity"
|
||||
android:name=".activities.search.SearchActivity"
|
||||
android:windowSoftInputMode="stateVisible" />
|
||||
|
||||
<activity
|
||||
|
|
|
@ -31,6 +31,7 @@ object Constants {
|
|||
const val APP_TWITTER_LINK = "https://twitter.com/retromusicapp"
|
||||
const val FAQ_LINK = "https://github.com/h4h13/RetroMusicPlayer/blob/master/FAQ.md"
|
||||
const val PINTEREST = "https://in.pinterest.com/retromusicapp/"
|
||||
const val BASE_URL = "https://ws.audioscrobbler.com/2.0/"
|
||||
|
||||
const val IS_MUSIC =
|
||||
MediaStore.Audio.AudioColumns.IS_MUSIC + "=1" + " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''"
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
package code.name.monkey.retromusic
|
||||
|
||||
import code.name.monkey.retromusic.activities.albums.AlbumDetailsViewModel
|
||||
import code.name.monkey.retromusic.activities.artists.ArtistDetailsViewModel
|
||||
import code.name.monkey.retromusic.activities.genre.GenreDetailsViewModel
|
||||
import code.name.monkey.retromusic.activities.playlist.PlaylistDetailsViewModel
|
||||
import code.name.monkey.retromusic.activities.search.SearchViewModel
|
||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import org.koin.android.viewmodel.dsl.viewModel
|
||||
import org.koin.dsl.module
|
||||
|
||||
|
||||
val mainModule = module {
|
||||
|
||||
viewModel {
|
||||
LibraryViewModel(get())
|
||||
}
|
||||
|
||||
viewModel { (albumId: Int) ->
|
||||
AlbumDetailsViewModel(get(), albumId)
|
||||
}
|
||||
|
||||
viewModel { (artistId: Int) ->
|
||||
ArtistDetailsViewModel(get(), artistId)
|
||||
}
|
||||
|
||||
viewModel { (playlist: Playlist) ->
|
||||
PlaylistDetailsViewModel(get(), playlist)
|
||||
}
|
||||
|
||||
viewModel { (genre: Genre) ->
|
||||
GenreDetailsViewModel(get(), genre)
|
||||
}
|
||||
|
||||
viewModel {
|
||||
SearchViewModel(get())
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package code.name.monkey.retromusic
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
||||
class PeekingLinearLayoutManager : LinearLayoutManager {
|
||||
@JvmOverloads
|
||||
constructor(
|
||||
context: Context?,
|
||||
@RecyclerView.Orientation orientation: Int = RecyclerView.VERTICAL,
|
||||
reverseLayout: Boolean = false
|
||||
) : super(context, orientation, reverseLayout)
|
||||
|
||||
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(
|
||||
context,
|
||||
attrs,
|
||||
defStyleAttr,
|
||||
defStyleRes
|
||||
)
|
||||
|
||||
override fun generateDefaultLayoutParams() =
|
||||
scaledLayoutParams(super.generateDefaultLayoutParams())
|
||||
|
||||
override fun generateLayoutParams(lp: ViewGroup.LayoutParams?) =
|
||||
scaledLayoutParams(super.generateLayoutParams(lp))
|
||||
|
||||
override fun generateLayoutParams(c: Context?, attrs: AttributeSet?) =
|
||||
scaledLayoutParams(super.generateLayoutParams(c, attrs))
|
||||
|
||||
private fun scaledLayoutParams(layoutParams: RecyclerView.LayoutParams) =
|
||||
layoutParams.apply {
|
||||
when (orientation) {
|
||||
HORIZONTAL -> width = (horizontalSpace * ratio).toInt()
|
||||
VERTICAL -> height = (verticalSpace * ratio).toInt()
|
||||
}
|
||||
}
|
||||
|
||||
private val horizontalSpace get() = width - paddingStart - paddingEnd
|
||||
|
||||
private val verticalSpace get() = height - paddingTop - paddingBottom
|
||||
|
||||
private val ratio = 0.8f // change to 0.7f for 70%
|
||||
}
|
|
@ -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 io.github.muntashirakon.music
|
||||
|
||||
/**
|
||||
* Created by hemanths on 2019-10-23.
|
||||
*/
|
||||
|
||||
sealed class Result<out T : Any> {
|
||||
|
||||
class Success<out T : Any>(val data: T) : Result<T>()
|
||||
|
||||
class Error(val exception: Throwable) : Result<Nothing>()
|
||||
}
|
|
@ -88,7 +88,7 @@ class DriveModeActivity : AbsMusicServiceActivity(), Callback {
|
|||
val isFavourite =
|
||||
MusicUtil.isFavorite(this@DriveModeActivity, MusicPlayerRemote.currentSong)
|
||||
withContext(Dispatchers.Main) {
|
||||
songFavourite.setImageResource(if (isFavourite) R.drawable.ic_favorite_white_24dp else R.drawable.ic_favorite_border_white_24dp)
|
||||
songFavourite.setImageResource(if (isFavourite) R.drawable.ic_favorite else R.drawable.ic_favorite_border)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,9 +161,9 @@ class DriveModeActivity : AbsMusicServiceActivity(), Callback {
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
if (MusicPlayerRemote.isPlaying) {
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
} else {
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,18 +183,18 @@ class DriveModeActivity : AbsMusicServiceActivity(), Callback {
|
|||
private fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.view.View
|
|||
import androidx.core.app.ActivityCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.commit
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import io.github.muntashirakon.music.R
|
||||
|
@ -51,6 +50,7 @@ import com.afollestad.materialcab.MaterialCab
|
|||
import com.google.android.material.appbar.AppBarLayout
|
||||
import io.github.muntashirakon.music.*
|
||||
import kotlinx.android.synthetic.main.activity_main_content.*
|
||||
import org.koin.android.ext.android.inject
|
||||
import java.util.*
|
||||
|
||||
class MainActivity : AbsSlidingMusicPanelActivity(),
|
||||
|
@ -60,7 +60,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
|
|||
const val EXPAND_PANEL = "expand_panel"
|
||||
}
|
||||
|
||||
lateinit var libraryViewModel: LibraryViewModel
|
||||
val libraryViewModel: LibraryViewModel by inject()
|
||||
private var cab: MaterialCab? = null
|
||||
private val intentFilter = IntentFilter(Intent.ACTION_SCREEN_OFF)
|
||||
private lateinit var currentFragment: MainActivityFragmentCallbacks
|
||||
|
@ -93,9 +93,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
|
|||
hideStatusBar()
|
||||
setBottomBarVisibility(View.VISIBLE)
|
||||
|
||||
libraryViewModel = ViewModelProvider(this).get(LibraryViewModel::class.java)
|
||||
addMusicServiceEventListener(libraryViewModel)
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
selectedFragment(PreferenceUtil.lastPage)
|
||||
} else {
|
||||
|
@ -142,20 +140,20 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
|
|||
menu ?: return super.onCreateOptionsMenu(menu)
|
||||
if (isPlaylistPage()) {
|
||||
menu.add(0, R.id.action_new_playlist, 1, R.string.new_playlist_title)
|
||||
.setIcon(R.drawable.ic_playlist_add_white_24dp)
|
||||
.setIcon(R.drawable.ic_playlist_add)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM)
|
||||
}
|
||||
if (isHomePage()) {
|
||||
menu.add(0, R.id.action_mic, 1, getString(R.string.action_search))
|
||||
.setIcon(R.drawable.ic_mic_white_24dp)
|
||||
.setIcon(R.drawable.ic_mic)
|
||||
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM)
|
||||
}
|
||||
if (isFolderPage()) {
|
||||
menu.add(0, R.id.action_scan, 0, R.string.scan_media)
|
||||
.setIcon(R.drawable.ic_scanner_white_24dp)
|
||||
.setIcon(R.drawable.ic_scanner)
|
||||
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM)
|
||||
menu.add(0, R.id.action_go_to_start_directory, 1, R.string.action_go_to_start_directory)
|
||||
.setIcon(R.drawable.ic_bookmark_music_white_24dp)
|
||||
.setIcon(R.drawable.ic_bookmark_music)
|
||||
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM)
|
||||
}
|
||||
val fragment: Fragment? = getCurrentFragment()
|
||||
|
@ -173,10 +171,10 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
|
|||
menu.removeItem(R.id.action_sort_order)
|
||||
}
|
||||
menu.add(0, R.id.action_settings, 6, getString(R.string.action_settings))
|
||||
.setIcon(R.drawable.ic_settings_white_24dp)
|
||||
.setIcon(R.drawable.ic_settings)
|
||||
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM)
|
||||
menu.add(0, R.id.action_search, 0, getString(R.string.action_search))
|
||||
.setIcon(R.drawable.ic_search_white_24dp)
|
||||
.setIcon(R.drawable.ic_search)
|
||||
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS)
|
||||
ToolbarContentTintHelper.handleOnCreateOptionsMenu(
|
||||
this,
|
||||
|
@ -534,6 +532,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
|
|||
fragment: Fragment,
|
||||
tag: String
|
||||
) {
|
||||
|
||||
supportFragmentManager.commit {
|
||||
replace(R.id.fragment_container, fragment, tag)
|
||||
}
|
||||
|
@ -682,7 +681,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
|
|||
}
|
||||
cab = MaterialCab(this, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||
.setCloseDrawableRes(R.drawable.ic_close)
|
||||
.setBackgroundColor(
|
||||
RetroColorUtil.shiftBackgroundColorForLightText(
|
||||
resolveColor(
|
||||
|
|
|
@ -10,13 +10,13 @@ import android.view.SubMenu
|
|||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.activities.base.AbsSlidingMusicPanelActivity
|
||||
import io.github.muntashirakon.music.activities.tageditor.AbsTagEditorActivity
|
||||
import io.github.muntashirakon.music.activities.tageditor.AlbumTagEditorActivity
|
||||
|
@ -36,26 +36,26 @@ import io.github.muntashirakon.music.helper.SortOrder.AlbumSongSortOrder
|
|||
import io.github.muntashirakon.music.interfaces.CabHolder
|
||||
import io.github.muntashirakon.music.model.Album
|
||||
import io.github.muntashirakon.music.model.Artist
|
||||
import io.github.muntashirakon.music.mvp.presenter.AlbumDetailsView
|
||||
import io.github.muntashirakon.music.rest.model.LastFmAlbum
|
||||
import io.github.muntashirakon.music.network.model.LastFmAlbum
|
||||
import io.github.muntashirakon.music.util.*
|
||||
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import com.bumptech.glide.Glide
|
||||
import io.github.muntashirakon.music.R
|
||||
import kotlinx.android.synthetic.main.activity_album.*
|
||||
import kotlinx.android.synthetic.main.activity_album_content.*
|
||||
import org.koin.android.viewmodel.ext.android.viewModel
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import java.util.*
|
||||
import android.util.Pair as UtilPair
|
||||
|
||||
class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, CabHolder {
|
||||
class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder {
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
cab?.let {
|
||||
if (it.isActive) it.finish()
|
||||
}
|
||||
cab = MaterialCab(this, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||
.setCloseDrawableRes(R.drawable.ic_close)
|
||||
.setBackgroundColor(
|
||||
RetroColorUtil.shiftBackgroundColorForLightText(
|
||||
ATHUtil.resolveColor(
|
||||
|
@ -68,7 +68,9 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
return cab as MaterialCab
|
||||
}
|
||||
|
||||
private lateinit var viewModel: AlbumDetailsViewModel
|
||||
private val detailsViewModel: AlbumDetailsViewModel by viewModel {
|
||||
parametersOf(extraNotNull<Int>(EXTRA_ALBUM_ID).value)
|
||||
}
|
||||
private lateinit var simpleSongAdapter: SimpleSongAdapter
|
||||
private lateinit var album: Album
|
||||
private lateinit var artistImage: ImageView
|
||||
|
@ -100,19 +102,19 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
window.sharedElementsUseOverlay = true
|
||||
windowEnterTransition()
|
||||
|
||||
val albumId = extraNotNull<Int>(EXTRA_ALBUM_ID).value
|
||||
addMusicServiceEventListener(detailsViewModel)
|
||||
ActivityCompat.postponeEnterTransition(this)
|
||||
val viewModelFactory = AlbumDetailsViewModelFactory(application, albumId)
|
||||
viewModel = ViewModelProvider(this, viewModelFactory).get(AlbumDetailsViewModel::class.java)
|
||||
addMusicServiceEventListener(viewModel)
|
||||
viewModel.getAlbum().observe(this, androidx.lifecycle.Observer {
|
||||
//val viewModelFactory = AlbumDetailsViewModelFactory(application, albumId)
|
||||
//viewModel = ViewModelProvider(this, viewModelFactory).get(AlbumDetailsViewModel::class.java)
|
||||
|
||||
detailsViewModel.getAlbum().observe(this, androidx.lifecycle.Observer {
|
||||
ActivityCompat.startPostponedEnterTransition(this@AlbumDetailsActivity)
|
||||
album(it)
|
||||
})
|
||||
viewModel.getArtist().observe(this, androidx.lifecycle.Observer {
|
||||
detailsViewModel.getArtist().observe(this, androidx.lifecycle.Observer {
|
||||
loadArtistImage(it)
|
||||
})
|
||||
viewModel.getAlbumInfo().observe(this, androidx.lifecycle.Observer {
|
||||
detailsViewModel.getAlbumInfo().observe(this, androidx.lifecycle.Observer {
|
||||
aboutAlbum(it)
|
||||
})
|
||||
setupRecyclerView()
|
||||
|
@ -153,11 +155,11 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
}
|
||||
}
|
||||
|
||||
override fun complete() {
|
||||
fun complete() {
|
||||
ActivityCompat.startPostponedEnterTransition(this)
|
||||
}
|
||||
|
||||
override fun album(album: Album) {
|
||||
fun album(album: Album) {
|
||||
complete()
|
||||
if (album.songs!!.isEmpty()) {
|
||||
finish()
|
||||
|
@ -190,11 +192,11 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
}
|
||||
loadAlbumCover()
|
||||
simpleSongAdapter.swapDataSet(album.songs)
|
||||
viewModel.loadArtist(album.artistId)
|
||||
viewModel.loadAlbumInfo(album)
|
||||
detailsViewModel.loadArtist(album.artistId)
|
||||
detailsViewModel.loadAlbumInfo(album)
|
||||
}
|
||||
|
||||
override fun moreAlbums(albums: List<Album>) {
|
||||
fun moreAlbums(albums: List<Album>) {
|
||||
moreTitle.show()
|
||||
moreRecyclerView.show()
|
||||
moreTitle.text = String.format(getString(R.string.label_more_from), album.artistName)
|
||||
|
@ -209,7 +211,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
moreRecyclerView.adapter = albumAdapter
|
||||
}
|
||||
|
||||
override fun aboutAlbum(lastFmAlbum: LastFmAlbum) {
|
||||
fun aboutAlbum(lastFmAlbum: LastFmAlbum) {
|
||||
if (lastFmAlbum.album != null) {
|
||||
if (lastFmAlbum.album.wiki != null) {
|
||||
aboutAlbumText.show()
|
||||
|
@ -230,7 +232,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
}
|
||||
}
|
||||
|
||||
override fun loadArtistImage(artist: Artist) {
|
||||
fun loadArtistImage(artist: Artist) {
|
||||
ArtistGlideRequest.Builder.from(Glide.with(this), artist)
|
||||
.generatePalette(this)
|
||||
.build()
|
||||
|
@ -391,8 +393,9 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
|
|||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
removeMusicServiceEventListener(viewModel)
|
||||
removeMusicServiceEventListener(detailsViewModel)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
const val EXTRA_ALBUM_ID = "extra_album_id"
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
package io.github.muntashirakon.music.activities.albums
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import io.github.muntashirakon.music.interfaces.MusicServiceEventListener
|
||||
import io.github.muntashirakon.music.model.Album
|
||||
import io.github.muntashirakon.music.model.Artist
|
||||
import io.github.muntashirakon.music.providers.RepositoryImpl
|
||||
import io.github.muntashirakon.music.rest.model.LastFmAlbum
|
||||
import io.github.muntashirakon.music.network.model.LastFmAlbum
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class AlbumDetailsViewModel(
|
||||
application: Application,
|
||||
private val repository: RepositoryImpl,
|
||||
private val albumId: Int
|
||||
) : AndroidViewModel(application), MusicServiceEventListener {
|
||||
private val _repository = RepositoryImpl(application.applicationContext)
|
||||
) : ViewModel(), MusicServiceEventListener {
|
||||
|
||||
private val _album = MutableLiveData<Album>()
|
||||
private val _artist = MutableLiveData<Artist>()
|
||||
private val _lastFmAlbum = MutableLiveData<LastFmAlbum>()
|
||||
|
@ -38,20 +37,18 @@ class AlbumDetailsViewModel(
|
|||
}
|
||||
|
||||
fun loadAlbumInfo(album: Album) = viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
val lastFmAlbum = _repository.albumInfo(album.artistName ?: "-", album.title ?: "-")
|
||||
_lastFmAlbum.postValue(lastFmAlbum)
|
||||
} catch (ignored: Exception) {}
|
||||
val lastFmAlbum = repository.albumInfo(album.artistName ?: "-", album.title ?: "-")
|
||||
_lastFmAlbum.postValue(lastFmAlbum)
|
||||
}
|
||||
|
||||
fun loadArtist(artistId: Int) = viewModelScope.launch(Dispatchers.IO) {
|
||||
val artist = _repository.artistById(artistId)
|
||||
val artist = repository.artistById(artistId)
|
||||
_artist.postValue(artist)
|
||||
}
|
||||
|
||||
private val loadAlbumAsync: Deferred<Album?>
|
||||
get() = viewModelScope.async(Dispatchers.IO) {
|
||||
_repository.albumById(albumId)
|
||||
repository.albumById(albumId)
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package io.github.muntashirakon.music.activities.albums
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
|
||||
class AlbumDetailsViewModelFactory(
|
||||
private val application: Application,
|
||||
private val albumId: Int
|
||||
) :
|
||||
ViewModelProvider.AndroidViewModelFactory(application) {
|
||||
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
|
||||
return if (modelClass.isAssignableFrom(AlbumDetailsViewModel::class.java)) {
|
||||
AlbumDetailsViewModel(application, albumId) as T
|
||||
} else {
|
||||
throw IllegalArgumentException("ViewModel Not Found")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,12 +11,12 @@ import android.view.View
|
|||
import android.widget.Toast
|
||||
import androidx.core.app.ActivityCompat
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.DefaultItemAnimator
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.activities.base.AbsSlidingMusicPanelActivity
|
||||
import io.github.muntashirakon.music.adapter.album.HorizontalAlbumAdapter
|
||||
import io.github.muntashirakon.music.adapter.song.SimpleSongAdapter
|
||||
|
@ -30,26 +30,26 @@ import io.github.muntashirakon.music.glide.RetroMusicColoredTarget
|
|||
import io.github.muntashirakon.music.helper.MusicPlayerRemote
|
||||
import io.github.muntashirakon.music.interfaces.CabHolder
|
||||
import io.github.muntashirakon.music.model.Artist
|
||||
import io.github.muntashirakon.music.mvp.presenter.ArtistDetailsView
|
||||
import io.github.muntashirakon.music.rest.model.LastFmArtist
|
||||
import io.github.muntashirakon.music.network.model.LastFmArtist
|
||||
import io.github.muntashirakon.music.util.*
|
||||
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import com.bumptech.glide.Glide
|
||||
import io.github.muntashirakon.music.R
|
||||
import kotlinx.android.synthetic.main.activity_artist_content.*
|
||||
import kotlinx.android.synthetic.main.activity_artist_details.*
|
||||
import org.koin.android.viewmodel.ext.android.viewModel
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView, CabHolder {
|
||||
class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder {
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
cab?.let {
|
||||
if (it.isActive) it.finish()
|
||||
}
|
||||
cab = MaterialCab(this, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||
.setCloseDrawableRes(R.drawable.ic_close)
|
||||
.setBackgroundColor(
|
||||
RetroColorUtil.shiftBackgroundColorForLightText(
|
||||
ATHUtil.resolveColor(
|
||||
|
@ -68,7 +68,9 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
|
|||
private lateinit var songAdapter: SimpleSongAdapter
|
||||
private lateinit var albumAdapter: HorizontalAlbumAdapter
|
||||
private var forceDownload: Boolean = false
|
||||
private lateinit var viewModel: ArtistDetailsViewModel
|
||||
private val detailsViewModel: ArtistDetailsViewModel by viewModel {
|
||||
parametersOf(extraNotNull<Int>(EXTRA_ARTIST_ID).value)
|
||||
}
|
||||
|
||||
override fun createContentView(): View {
|
||||
return wrapSlidingMusicPanel(R.layout.activity_artist_details)
|
||||
|
@ -93,23 +95,16 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
|
|||
setBottomBarVisibility(View.GONE)
|
||||
window.sharedElementsUseOverlay = true
|
||||
windowEnterTransition()
|
||||
|
||||
val artistId = extraNotNull<Int>(EXTRA_ARTIST_ID).value
|
||||
val viewModelFactory = ArtistDetailsViewModelFactory(application, artistId)
|
||||
viewModel =
|
||||
ViewModelProvider(this, viewModelFactory).get(ArtistDetailsViewModel::class.java)
|
||||
addMusicServiceEventListener(viewModel)
|
||||
viewModel.getArtist().observe(this, androidx.lifecycle.Observer {
|
||||
ActivityCompat.postponeEnterTransition(this)
|
||||
addMusicServiceEventListener(detailsViewModel)
|
||||
detailsViewModel.getArtist().observe(this, androidx.lifecycle.Observer {
|
||||
ActivityCompat.startPostponedEnterTransition(this@ArtistDetailActivity)
|
||||
artist(it)
|
||||
})
|
||||
viewModel.getArtistInfo().observe(this, androidx.lifecycle.Observer {
|
||||
detailsViewModel.getArtistInfo().observe(this, androidx.lifecycle.Observer {
|
||||
artistInfo(it)
|
||||
})
|
||||
ActivityCompat.postponeEnterTransition(this)
|
||||
|
||||
setupRecyclerView()
|
||||
|
||||
playAction.apply {
|
||||
setOnClickListener { MusicPlayerRemote.openQueue(artist.songs, 0, true) }
|
||||
}
|
||||
|
@ -155,14 +150,11 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
|
|||
}
|
||||
}
|
||||
|
||||
override fun showEmptyView() {
|
||||
}
|
||||
|
||||
override fun complete() {
|
||||
fun complete() {
|
||||
ActivityCompat.startPostponedEnterTransition(this)
|
||||
}
|
||||
|
||||
override fun artist(artist: Artist) {
|
||||
fun artist(artist: Artist) {
|
||||
complete()
|
||||
if (artist.songCount <= 0) {
|
||||
finish()
|
||||
|
@ -203,10 +195,10 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
|
|||
) {
|
||||
biography = null
|
||||
this.lang = lang
|
||||
viewModel.loadBiography(name, lang, null)
|
||||
detailsViewModel.loadBiography(name, lang, null)
|
||||
}
|
||||
|
||||
override fun artistInfo(lastFmArtist: LastFmArtist?) {
|
||||
fun artistInfo(lastFmArtist: LastFmArtist?) {
|
||||
if (lastFmArtist != null && lastFmArtist.artist != null) {
|
||||
val bioContent = lastFmArtist.artist.bio.content
|
||||
if (bioContent != null && bioContent.trim { it <= ' ' }.isNotEmpty()) {
|
||||
|
@ -323,7 +315,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
|
|||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
removeMusicServiceEventListener(viewModel)
|
||||
removeMusicServiceEventListener(detailsViewModel)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -1,29 +1,28 @@
|
|||
package io.github.muntashirakon.music.activities.artists
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import io.github.muntashirakon.music.interfaces.MusicServiceEventListener
|
||||
import io.github.muntashirakon.music.model.Artist
|
||||
import io.github.muntashirakon.music.providers.RepositoryImpl
|
||||
import io.github.muntashirakon.music.rest.model.LastFmArtist
|
||||
import io.github.muntashirakon.music.network.model.LastFmArtist
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class ArtistDetailsViewModel(
|
||||
application: Application,
|
||||
private val repository: RepositoryImpl,
|
||||
private val artistId: Int
|
||||
) : AndroidViewModel(application), MusicServiceEventListener {
|
||||
) : ViewModel(), MusicServiceEventListener {
|
||||
|
||||
private val loadArtistDetailsAsync: Deferred<Artist?>
|
||||
get() = viewModelScope.async(Dispatchers.IO) {
|
||||
_repository.artistById(artistId)
|
||||
repository.artistById(artistId)
|
||||
}
|
||||
private val _repository = RepositoryImpl(application.applicationContext)
|
||||
|
||||
private val _artist = MutableLiveData<Artist>()
|
||||
private val _lastFmArtist = MutableLiveData<LastFmArtist>()
|
||||
|
||||
|
@ -41,7 +40,7 @@ class ArtistDetailsViewModel(
|
|||
}
|
||||
|
||||
fun loadBiography(name: String, lang: String?, cache: String?) = viewModelScope.launch {
|
||||
val info = _repository.artistInfo(name, lang, cache)
|
||||
val info = repository.artistInfo(name, lang, cache)
|
||||
_lastFmArtist.postValue(info)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package io.github.muntashirakon.music.activities.artists
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
|
||||
class ArtistDetailsViewModelFactory(
|
||||
private val application: Application,
|
||||
private val artistId: Int
|
||||
) :
|
||||
ViewModelProvider.AndroidViewModelFactory(application) {
|
||||
override fun <T : ViewModel?> create(modelClass: Class<T>): T {
|
||||
return if (modelClass.isAssignableFrom(ArtistDetailsViewModel::class.java)) {
|
||||
ArtistDetailsViewModel(application, artistId) as T
|
||||
} else {
|
||||
throw IllegalArgumentException("ViewModel Not Found")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -94,7 +94,7 @@ open class BugReportActivity : AbsThemeActivity() {
|
|||
sendFab.hide(object : FloatingActionButton.OnVisibilityChangedListener() {
|
||||
override fun onHidden(fab: FloatingActionButton?) {
|
||||
super.onHidden(fab)
|
||||
sendFab.setImageResource(R.drawable.ic_send_white_24dp)
|
||||
sendFab.setImageResource(R.drawable.ic_send)
|
||||
sendFab.show()
|
||||
}
|
||||
})
|
||||
|
@ -110,7 +110,7 @@ open class BugReportActivity : AbsThemeActivity() {
|
|||
sendFab.hide(object : FloatingActionButton.OnVisibilityChangedListener() {
|
||||
override fun onHidden(fab: FloatingActionButton?) {
|
||||
super.onHidden(fab)
|
||||
sendFab.setImageResource(R.drawable.ic_open_in_browser_white_24dp)
|
||||
sendFab.setImageResource(R.drawable.ic_open_in_browser)
|
||||
sendFab.show()
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package io.github.muntashirakon.music.activities
|
||||
package io.github.muntashirakon.music.activities.genre
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
|
@ -17,24 +17,25 @@ import io.github.muntashirakon.music.helper.menu.GenreMenuHelper
|
|||
import io.github.muntashirakon.music.interfaces.CabHolder
|
||||
import io.github.muntashirakon.music.model.Genre
|
||||
import io.github.muntashirakon.music.model.Song
|
||||
import io.github.muntashirakon.music.mvp.presenter.GenreDetailsPresenter
|
||||
import io.github.muntashirakon.music.mvp.presenter.GenreDetailsPresenter.GenreDetailsPresenterImpl
|
||||
import io.github.muntashirakon.music.mvp.presenter.GenreDetailsView
|
||||
import io.github.muntashirakon.music.providers.RepositoryImpl
|
||||
import io.github.muntashirakon.music.util.DensityUtil
|
||||
import io.github.muntashirakon.music.util.RetroColorUtil
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
import kotlinx.android.synthetic.main.activity_playlist_detail.*
|
||||
import org.koin.android.viewmodel.ext.android.viewModel
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
*/
|
||||
|
||||
class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDetailsView {
|
||||
class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder {
|
||||
|
||||
|
||||
private lateinit var genreDetailsPresenter: GenreDetailsPresenter
|
||||
private val detailsViewModel: GenreDetailsViewModel by viewModel {
|
||||
parametersOf(extraNotNull<Genre>(EXTRA_GENRE_ID).value)
|
||||
}
|
||||
|
||||
private lateinit var genre: Genre
|
||||
private lateinit var songAdapter: ShuffleButtonSongAdapter
|
||||
private var cab: MaterialCab? = null
|
||||
|
@ -62,38 +63,25 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet
|
|||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
setBottomBarVisibility(View.GONE)
|
||||
|
||||
genre = extraNotNull<Genre>(EXTRA_GENRE_ID).value
|
||||
|
||||
setUpToolBar()
|
||||
applyToolbar(toolbar)
|
||||
setupRecyclerView()
|
||||
|
||||
genreDetailsPresenter =
|
||||
GenreDetailsPresenterImpl(RepositoryImpl(this))
|
||||
genreDetailsPresenter.attachView(this)
|
||||
}
|
||||
detailsViewModel.getSongs().observe(this, androidx.lifecycle.Observer {
|
||||
songs(it)
|
||||
})
|
||||
|
||||
private fun setUpToolBar() {
|
||||
applyToolbar(toolbar)
|
||||
title = genre.name
|
||||
}
|
||||
detailsViewModel.getGenre().observe(this, androidx.lifecycle.Observer {
|
||||
genre = it
|
||||
supportActionBar?.title = it.name
|
||||
})
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
genreDetailsPresenter.loadGenreSongs(genre.id)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
genreDetailsPresenter.detachView()
|
||||
addMusicServiceEventListener(detailsViewModel)
|
||||
}
|
||||
|
||||
override fun createContentView(): View {
|
||||
return wrapSlidingMusicPanel(R.layout.activity_playlist_detail)
|
||||
}
|
||||
|
||||
override fun showEmptyView() {
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
menuInflater.inflate(R.menu.menu_genre_detail, menu)
|
||||
|
@ -122,14 +110,14 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet
|
|||
})
|
||||
}
|
||||
|
||||
override fun songs(songs: List<Song>) {
|
||||
fun songs(songs: List<Song>) {
|
||||
songAdapter.swapDataSet(songs)
|
||||
}
|
||||
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
if (cab != null && cab!!.isActive) cab?.finish()
|
||||
cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||
.setCloseDrawableRes(R.drawable.ic_close)
|
||||
.setBackgroundColor(
|
||||
RetroColorUtil.shiftBackgroundColorForLightText(
|
||||
ATHUtil.resolveColor(
|
||||
|
@ -149,11 +137,6 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet
|
|||
}
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
super.onMediaStoreChanged()
|
||||
genreDetailsPresenter.loadGenreSongs(genre.id)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val EXTRA_GENRE_ID = "extra_genre_id"
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package code.name.monkey.retromusic.activities.genre
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import code.name.monkey.retromusic.interfaces.MusicServiceEventListener
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.providers.RepositoryImpl
|
||||
import kotlinx.coroutines.Dispatchers.Main
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class GenreDetailsViewModel(
|
||||
private val repository: RepositoryImpl,
|
||||
private val genre: Genre
|
||||
) : ViewModel(), MusicServiceEventListener {
|
||||
|
||||
private val _playListSongs = MutableLiveData<List<Song>>()
|
||||
private val _genre = MutableLiveData<Genre>().apply {
|
||||
postValue(genre)
|
||||
}
|
||||
|
||||
fun getSongs(): LiveData<List<Song>> = _playListSongs
|
||||
|
||||
fun getGenre(): LiveData<Genre> = _genre
|
||||
|
||||
init {
|
||||
loadGenreSongs(genre)
|
||||
}
|
||||
|
||||
private fun loadGenreSongs(genre: Genre) = viewModelScope.launch {
|
||||
val songs = repository.getGenre(genre.id)
|
||||
withContext(Main) { _playListSongs.postValue(songs) }
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
loadGenreSongs(genre)
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {}
|
||||
override fun onServiceDisconnected() {}
|
||||
override fun onQueueChanged() {}
|
||||
override fun onPlayingMetaChanged() {}
|
||||
override fun onPlayStateChanged() {}
|
||||
override fun onRepeatModeChanged() {}
|
||||
override fun onShuffleModeChanged() {}
|
||||
}
|
|
@ -1,12 +1,14 @@
|
|||
package io.github.muntashirakon.music.activities
|
||||
package io.github.muntashirakon.music.activities.playlist
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.activities.base.AbsSlidingMusicPanelActivity
|
||||
import io.github.muntashirakon.music.adapter.song.OrderablePlaylistSongAdapter
|
||||
|
@ -16,14 +18,9 @@ import io.github.muntashirakon.music.extensions.applyToolbar
|
|||
import io.github.muntashirakon.music.extensions.extraNotNull
|
||||
import io.github.muntashirakon.music.helper.menu.PlaylistMenuHelper
|
||||
import io.github.muntashirakon.music.interfaces.CabHolder
|
||||
import io.github.muntashirakon.music.loaders.PlaylistLoader
|
||||
import io.github.muntashirakon.music.model.AbsCustomPlaylist
|
||||
import io.github.muntashirakon.music.model.Playlist
|
||||
import io.github.muntashirakon.music.model.Song
|
||||
import io.github.muntashirakon.music.mvp.presenter.PlaylistSongsPresenter
|
||||
import io.github.muntashirakon.music.mvp.presenter.PlaylistSongsPresenter.PlaylistSongsPresenterImpl
|
||||
import io.github.muntashirakon.music.mvp.presenter.PlaylistSongsView
|
||||
import io.github.muntashirakon.music.providers.RepositoryImpl
|
||||
import io.github.muntashirakon.music.util.DensityUtil
|
||||
import io.github.muntashirakon.music.util.PlaylistsUtil
|
||||
import io.github.muntashirakon.music.util.RetroColorUtil
|
||||
|
@ -32,11 +29,16 @@ import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemA
|
|||
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager
|
||||
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils
|
||||
import kotlinx.android.synthetic.main.activity_playlist_detail.*
|
||||
|
||||
class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, PlaylistSongsView {
|
||||
import org.koin.android.viewmodel.ext.android.viewModel
|
||||
import org.koin.core.parameter.parametersOf
|
||||
|
||||
|
||||
private lateinit var presenter: PlaylistSongsPresenter
|
||||
class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder {
|
||||
|
||||
|
||||
private val viewModel: PlaylistDetailsViewModel by viewModel {
|
||||
parametersOf(extraNotNull<Playlist>(EXTRA_PLAYLIST).value)
|
||||
}
|
||||
private lateinit var playlist: Playlist
|
||||
private var cab: MaterialCab? = null
|
||||
private lateinit var adapter: SongAdapter
|
||||
|
@ -52,13 +54,20 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
setLightNavigationBar(true)
|
||||
setBottomBarVisibility(View.GONE)
|
||||
|
||||
presenter = PlaylistSongsPresenterImpl(RepositoryImpl(this))
|
||||
presenter.attachView(this)
|
||||
|
||||
playlist = extraNotNull<Playlist>(EXTRA_PLAYLIST).value
|
||||
|
||||
setUpToolBar()
|
||||
setUpRecyclerView()
|
||||
|
||||
viewModel.getSongs().observe(this, Observer {
|
||||
songs(it)
|
||||
})
|
||||
|
||||
viewModel.getPlaylist().observe(this, Observer {
|
||||
playlist = it
|
||||
supportActionBar?.title = it.name
|
||||
})
|
||||
addMusicServiceEventListener(viewModel)
|
||||
}
|
||||
|
||||
override fun createContentView(): View {
|
||||
|
@ -66,7 +75,6 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
}
|
||||
|
||||
private fun setUpRecyclerView() {
|
||||
|
||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||
if (playlist is AbsCustomPlaylist) {
|
||||
adapter = PlaylistSongAdapter(this, ArrayList(), R.layout.item_list, this)
|
||||
|
@ -108,11 +116,6 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
})
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
presenter.loadPlaylistSongs(playlist)
|
||||
}
|
||||
|
||||
private fun setUpToolBar() {
|
||||
applyToolbar(toolbar)
|
||||
title = playlist.name
|
||||
|
@ -141,7 +144,7 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
cab!!.finish()
|
||||
}
|
||||
cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||
.setCloseDrawableRes(R.drawable.ic_close)
|
||||
.setBackgroundColor(
|
||||
RetroColorUtil.shiftBackgroundColorForLightText(
|
||||
ATHUtil.resolveColor(
|
||||
|
@ -162,28 +165,6 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
}
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
super.onMediaStoreChanged()
|
||||
if (playlist !is AbsCustomPlaylist) {
|
||||
// Playlist deleted
|
||||
if (!PlaylistsUtil.doesPlaylistExist(this, playlist.id)) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
// Playlist renamed
|
||||
val playlistName = PlaylistsUtil.getNameForPlaylist(this, playlist.id.toLong())
|
||||
if (playlistName != playlist.name) {
|
||||
playlist = PlaylistLoader.getPlaylist(this, playlist.id)
|
||||
setToolbarTitle(playlist.name)
|
||||
}
|
||||
}
|
||||
presenter.loadPlaylistSongs(playlist)
|
||||
}
|
||||
|
||||
private fun setToolbarTitle(title: String) {
|
||||
supportActionBar?.title = title
|
||||
}
|
||||
|
||||
private fun checkForPadding() {
|
||||
val height = DensityUtil.dip2px(this, 52f)
|
||||
recyclerView.setPadding(0, 0, 0, (height))
|
||||
|
@ -223,19 +204,22 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
|
|||
wrappedAdapter = null
|
||||
}
|
||||
super.onDestroy()
|
||||
presenter.detachView()
|
||||
}
|
||||
|
||||
override fun showEmptyView() {
|
||||
fun showEmptyView() {
|
||||
empty.visibility = View.VISIBLE
|
||||
emptyText.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
override fun songs(songs: List<Song>) {
|
||||
adapter.swapDataSet(songs)
|
||||
fun songs(songs: List<Song>) {
|
||||
if (songs.isNotEmpty()) {
|
||||
adapter.swapDataSet(songs)
|
||||
} else {
|
||||
showEmptyView()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
var EXTRA_PLAYLIST = "extra_playlist"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package code.name.monkey.retromusic.activities.playlist
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.interfaces.MusicServiceEventListener
|
||||
import code.name.monkey.retromusic.loaders.PlaylistLoader
|
||||
import code.name.monkey.retromusic.model.AbsCustomPlaylist
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.providers.RepositoryImpl
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||
import kotlinx.coroutines.Dispatchers.Main
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class PlaylistDetailsViewModel(
|
||||
private val repository: RepositoryImpl,
|
||||
private var playlist: Playlist
|
||||
) : ViewModel(), MusicServiceEventListener {
|
||||
private val _playListSongs = MutableLiveData<List<Song>>()
|
||||
|
||||
private val _playlist = MutableLiveData<Playlist>().apply {
|
||||
postValue(playlist)
|
||||
}
|
||||
|
||||
fun getPlaylist(): LiveData<Playlist> = _playlist
|
||||
|
||||
fun getSongs(): LiveData<List<Song>> = _playListSongs
|
||||
|
||||
init {
|
||||
loadPlaylistSongs(playlist)
|
||||
}
|
||||
|
||||
private fun loadPlaylistSongs(playlist: Playlist) = viewModelScope.launch {
|
||||
val songs = repository.getPlaylistSongs(playlist)
|
||||
withContext(Main) { _playListSongs.postValue(songs) }
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
if (playlist !is AbsCustomPlaylist) {
|
||||
// Playlist deleted
|
||||
if (!PlaylistsUtil.doesPlaylistExist(App.getContext(), playlist.id)) {
|
||||
//TODO Finish the page
|
||||
return
|
||||
}
|
||||
// Playlist renamed
|
||||
val playlistName =
|
||||
PlaylistsUtil.getNameForPlaylist(App.getContext(), playlist.id.toLong())
|
||||
if (playlistName != playlist.name) {
|
||||
playlist = PlaylistLoader.getPlaylist(App.getContext(), playlist.id)
|
||||
_playlist.postValue(playlist)
|
||||
}
|
||||
}
|
||||
loadPlaylistSongs(playlist)
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {}
|
||||
override fun onServiceDisconnected() {}
|
||||
override fun onQueueChanged() {}
|
||||
override fun onPlayingMetaChanged() {}
|
||||
override fun onPlayStateChanged() {}
|
||||
override fun onRepeatModeChanged() {}
|
||||
override fun onShuffleModeChanged() {}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package io.github.muntashirakon.music.activities
|
||||
package io.github.muntashirakon.music.activities.search
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Service
|
||||
|
@ -24,19 +24,17 @@ import code.name.monkey.appthemehelper.util.MaterialValueHelper
|
|||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.activities.base.AbsMusicServiceActivity
|
||||
import io.github.muntashirakon.music.adapter.SearchAdapter
|
||||
import io.github.muntashirakon.music.mvp.presenter.SearchPresenter
|
||||
import io.github.muntashirakon.music.mvp.presenter.SearchPresenter.SearchPresenterImpl
|
||||
import io.github.muntashirakon.music.mvp.presenter.SearchView
|
||||
import io.github.muntashirakon.music.providers.RepositoryImpl
|
||||
import io.github.muntashirakon.music.extensions.extra
|
||||
import io.github.muntashirakon.music.util.RetroUtil
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import kotlinx.android.synthetic.main.activity_search.*
|
||||
import org.koin.android.ext.android.inject
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatcher, SearchView {
|
||||
class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatcher {
|
||||
|
||||
private lateinit var presenter: SearchPresenter
|
||||
private val viewModel: SearchViewModel by inject()
|
||||
private var searchAdapter: SearchAdapter? = null
|
||||
private var query: String? = null
|
||||
|
||||
|
@ -49,14 +47,11 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
|
|||
setTaskDescriptionColorAuto()
|
||||
setLightNavigationBar(true)
|
||||
|
||||
presenter = SearchPresenterImpl(RepositoryImpl(this))
|
||||
presenter.attachView(this)
|
||||
|
||||
setupRecyclerView()
|
||||
setUpToolBar()
|
||||
setupSearchView()
|
||||
|
||||
if (intent.getBooleanExtra(EXTRA_SHOW_MIC, false)) {
|
||||
if (extra<Boolean>(EXTRA_SHOW_MIC).value == true) {
|
||||
startMicSearch()
|
||||
}
|
||||
|
||||
|
@ -84,6 +79,10 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
|
|||
if (savedInstanceState != null) {
|
||||
query = savedInstanceState.getString(QUERY)
|
||||
}
|
||||
|
||||
viewModel.getSearchResult().observe(this, androidx.lifecycle.Observer {
|
||||
showData(it)
|
||||
})
|
||||
}
|
||||
|
||||
private fun setupRecyclerView() {
|
||||
|
@ -114,11 +113,6 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
|
|||
searchView.addTextChangedListener(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
presenter.detachView()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
outState.putString(QUERY, query)
|
||||
|
@ -133,7 +127,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
|
|||
TransitionManager.beginDelayedTransition(appBarLayout)
|
||||
voiceSearch.visibility = if (query.isNotEmpty()) View.GONE else View.VISIBLE
|
||||
clearText.visibility = if (query.isNotEmpty()) View.VISIBLE else View.GONE
|
||||
presenter.search(query)
|
||||
viewModel.search(query)
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
|
@ -158,12 +152,16 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
|
|||
}
|
||||
}
|
||||
|
||||
override fun showEmptyView() {
|
||||
private fun showEmptyView() {
|
||||
searchAdapter?.swapDataSet(ArrayList())
|
||||
}
|
||||
|
||||
override fun showData(data: MutableList<Any>) {
|
||||
searchAdapter?.swapDataSet(data)
|
||||
private fun showData(data: MutableList<Any>) {
|
||||
if (data.isNotEmpty()) {
|
||||
searchAdapter?.swapDataSet(data)
|
||||
} else {
|
||||
showEmptyView()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
|
@ -175,7 +173,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
|
|||
data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)
|
||||
query = result?.get(0)
|
||||
searchView.setText(query, BufferType.EDITABLE)
|
||||
presenter.search(query!!)
|
||||
viewModel.search(query!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -190,7 +188,10 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
|
|||
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault())
|
||||
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, getString(R.string.speech_prompt))
|
||||
try {
|
||||
startActivityForResult(intent, REQ_CODE_SPEECH_INPUT)
|
||||
startActivityForResult(
|
||||
intent,
|
||||
REQ_CODE_SPEECH_INPUT
|
||||
)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
e.printStackTrace()
|
||||
Toast.makeText(this, getString(R.string.speech_not_supported), Toast.LENGTH_SHORT)
|
|
@ -0,0 +1,22 @@
|
|||
package code.name.monkey.retromusic.activities.search
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import code.name.monkey.retromusic.providers.RepositoryImpl
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.Dispatchers.Main
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class SearchViewModel(private val repository: RepositoryImpl) : ViewModel() {
|
||||
private val results = MutableLiveData<MutableList<Any>>()
|
||||
|
||||
fun getSearchResult(): LiveData<MutableList<Any>> = results
|
||||
|
||||
fun search(query: String?) = viewModelScope.launch(IO) {
|
||||
val result = repository.search(query)
|
||||
withContext(Main) { results.postValue(result) }
|
||||
}
|
||||
}
|
|
@ -34,8 +34,7 @@ import io.github.muntashirakon.music.misc.UpdateToastMediaScannerCompletionListe
|
|||
import io.github.muntashirakon.music.util.MusicUtil;
|
||||
import io.github.muntashirakon.music.util.SAFUtil;
|
||||
|
||||
public class WriteTagsAsyncTask extends
|
||||
DialogAsyncTask<WriteTagsAsyncTask.LoadingInfo, Integer, String[]> {
|
||||
public class WriteTagsAsyncTask extends DialogAsyncTask<WriteTagsAsyncTask.LoadingInfo, Integer, String[]> {
|
||||
|
||||
private WeakReference<Activity> activity;
|
||||
|
||||
|
|
|
@ -69,8 +69,8 @@ class ContributorAdapter(
|
|||
text.text = contributor.summary
|
||||
Glide.with(image.context)
|
||||
.load(contributor.profileImage)
|
||||
.error(R.drawable.ic_account_white_24dp)
|
||||
.placeholder(R.drawable.ic_account_white_24dp)
|
||||
.error(R.drawable.ic_account)
|
||||
.placeholder(R.drawable.ic_account)
|
||||
.dontAnimate()
|
||||
.into(image)
|
||||
}
|
||||
|
|
|
@ -11,9 +11,12 @@ import androidx.appcompat.widget.AppCompatTextView
|
|||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.HORIZONTAL
|
||||
import code.name.monkey.appthemehelper.ThemeStore
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import io.github.muntashirakon.music.PeekingLinearLayoutManager
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.adapter.album.AlbumFullWidthAdapter
|
||||
import io.github.muntashirakon.music.adapter.album.AlbumAdapter
|
||||
import io.github.muntashirakon.music.adapter.artist.ArtistAdapter
|
||||
import io.github.muntashirakon.music.adapter.song.SongAdapter
|
||||
import io.github.muntashirakon.music.extensions.show
|
||||
|
@ -24,6 +27,7 @@ import io.github.muntashirakon.music.model.*
|
|||
import io.github.muntashirakon.music.model.Playlist
|
||||
import io.github.muntashirakon.music.util.PreferenceUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
|
||||
class HomeAdapter(
|
||||
private val activity: AppCompatActivity,
|
||||
|
@ -41,8 +45,14 @@ class HomeAdapter(
|
|||
.inflate(R.layout.section_recycler_view, parent, false)
|
||||
return when (viewType) {
|
||||
RECENT_ARTISTS, TOP_ARTISTS -> ArtistViewHolder(layout)
|
||||
PLAYLISTS -> PlaylistViewHolder(layout)
|
||||
SUGGESTIONS -> {
|
||||
TOP_ALBUMS, RECENT_ALBUMS -> {
|
||||
AlbumViewHolder(
|
||||
LayoutInflater.from(activity)
|
||||
.inflate(R.layout.metal_section_recycler_view, parent, false)
|
||||
)
|
||||
}
|
||||
FAVOURITES -> PlaylistViewHolder(layout)
|
||||
else -> {
|
||||
SuggestionsViewHolder(
|
||||
LayoutInflater.from(activity).inflate(
|
||||
R.layout.item_suggestions,
|
||||
|
@ -51,15 +61,6 @@ class HomeAdapter(
|
|||
)
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
AlbumViewHolder(
|
||||
LayoutInflater.from(activity).inflate(
|
||||
R.layout.metal_section_recycler_view,
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,19 +91,19 @@ class HomeAdapter(
|
|||
val viewHolder = holder as ArtistViewHolder
|
||||
viewHolder.bindView(list[position].arrayList as List<Artist>, R.string.top_artists)
|
||||
}
|
||||
PLAYLISTS -> {
|
||||
val viewHolder = holder as PlaylistViewHolder
|
||||
viewHolder.bindView(
|
||||
list[position].arrayList as List<Playlist>,
|
||||
R.string.favorites
|
||||
)
|
||||
}
|
||||
SUGGESTIONS -> {
|
||||
val viewHolder = holder as SuggestionsViewHolder
|
||||
viewHolder.bindView(
|
||||
list[position].arrayList as List<Song>
|
||||
)
|
||||
}
|
||||
FAVOURITES -> {
|
||||
val viewHolder = holder as PlaylistViewHolder
|
||||
viewHolder.bindView(
|
||||
list[position].arrayList as List<Playlist>,
|
||||
R.string.favorites
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,7 +118,7 @@ class HomeAdapter(
|
|||
|
||||
companion object {
|
||||
|
||||
@IntDef(RECENT_ALBUMS, TOP_ALBUMS, RECENT_ARTISTS, TOP_ARTISTS, PLAYLISTS, SUGGESTIONS)
|
||||
@IntDef(RECENT_ALBUMS, TOP_ALBUMS, RECENT_ARTISTS, TOP_ARTISTS, SUGGESTIONS, FAVOURITES)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class HomeSection
|
||||
|
||||
|
@ -125,8 +126,8 @@ class HomeAdapter(
|
|||
const val TOP_ALBUMS = 1
|
||||
const val RECENT_ARTISTS = 2
|
||||
const val TOP_ARTISTS = 0
|
||||
const val SUGGESTIONS = 4
|
||||
const val PLAYLISTS = 5
|
||||
const val SUGGESTIONS = 5
|
||||
const val FAVOURITES = 4
|
||||
}
|
||||
|
||||
private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view) {
|
||||
|
@ -134,7 +135,9 @@ class HomeAdapter(
|
|||
if (list.isNotEmpty()) {
|
||||
recyclerView.apply {
|
||||
show()
|
||||
adapter = AlbumFullWidthAdapter(activity, list, displayMetrics)
|
||||
adapter = AlbumAdapter(activity, list, R.layout.pager_item, null)
|
||||
layoutManager =
|
||||
PeekingLinearLayoutManager(activity, HORIZONTAL, false)
|
||||
}
|
||||
title.text = activity.getString(titleRes)
|
||||
}
|
||||
|
@ -176,17 +179,20 @@ class HomeAdapter(
|
|||
fun bindView(arrayList: List<Song>) {
|
||||
val color = ThemeStore.accentColor(activity)
|
||||
itemView.findViewById<TextView>(R.id.text).setTextColor(color)
|
||||
|
||||
images.forEachIndexed { index, i ->
|
||||
itemView.findViewById<View>(i).setOnClickListener {
|
||||
MusicPlayerRemote.playNext(arrayList[index])
|
||||
}
|
||||
SongGlideRequest.Builder.from(Glide.with(activity), arrayList[index])
|
||||
.asBitmap()
|
||||
.build()
|
||||
.into(itemView.findViewById(i))
|
||||
|
||||
itemView.findViewById<MaterialCardView>(R.id.card6).apply {
|
||||
setCardBackgroundColor(ColorUtil.withAlpha(color, 0.2f))
|
||||
}
|
||||
if (arrayList.size > 9)
|
||||
images.forEachIndexed { index, i ->
|
||||
itemView.findViewById<View>(i).setOnClickListener {
|
||||
MusicPlayerRemote.playNext(arrayList[index])
|
||||
}
|
||||
SongGlideRequest.Builder.from(Glide.with(activity), arrayList[index])
|
||||
.asBitmap()
|
||||
.build()
|
||||
.into(itemView.findViewById(i))
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ class SongFileAdapter(
|
|||
if (file.isDirectory) {
|
||||
holder.image?.let {
|
||||
it.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN)
|
||||
it.setImageResource(R.drawable.ic_folder_white_24dp)
|
||||
it.setImageResource(R.drawable.ic_folder)
|
||||
}
|
||||
holder.imageTextContainer?.setCardBackgroundColor(
|
||||
ATHUtil.resolveColor(
|
||||
|
@ -110,7 +110,7 @@ class SongFileAdapter(
|
|||
)
|
||||
} else {
|
||||
val error = RetroUtil.getTintedVectorDrawable(
|
||||
activity, R.drawable.ic_file_music_white_24dp, iconColor
|
||||
activity, R.drawable.ic_file_music, iconColor
|
||||
)
|
||||
Glide.with(activity)
|
||||
.load(AudioFileCover(file.path))
|
||||
|
|
|
@ -1,108 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2017. Alexander Bilchuk <a.bilchuk@sandrlab.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.muntashirakon.music.adapter.album
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.ActivityOptions
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.glide.AlbumGlideRequest
|
||||
import io.github.muntashirakon.music.glide.RetroMusicColoredTarget
|
||||
import io.github.muntashirakon.music.helper.MusicPlayerRemote
|
||||
import io.github.muntashirakon.music.model.Album
|
||||
import io.github.muntashirakon.music.util.NavigationUtil
|
||||
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
|
||||
import io.github.muntashirakon.music.views.MetalRecyclerViewPager
|
||||
import com.bumptech.glide.Glide
|
||||
|
||||
class AlbumFullWidthAdapter(
|
||||
private val activity: Activity,
|
||||
private val dataSet: List<Album>,
|
||||
metrics: DisplayMetrics
|
||||
) : MetalRecyclerViewPager.MetalAdapter<AlbumFullWidthAdapter.FullMetalViewHolder>(metrics) {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FullMetalViewHolder {
|
||||
return FullMetalViewHolder(
|
||||
LayoutInflater.from(parent.context).inflate(
|
||||
R.layout.pager_item,
|
||||
parent,
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: FullMetalViewHolder, position: Int) {
|
||||
// don't forget about calling supper.onBindViewHolder!
|
||||
super.onBindViewHolder(holder, position)
|
||||
val album = dataSet[position]
|
||||
holder.title?.text = getAlbumTitle(album)
|
||||
holder.text?.text = getAlbumText(album)
|
||||
holder.playSongs?.setOnClickListener {
|
||||
album.songs?.let { songs ->
|
||||
MusicPlayerRemote.openQueue(
|
||||
songs,
|
||||
0,
|
||||
true
|
||||
)
|
||||
}
|
||||
}
|
||||
loadAlbumCover(album, holder)
|
||||
}
|
||||
|
||||
private fun getAlbumTitle(album: Album): String? {
|
||||
return album.title
|
||||
}
|
||||
|
||||
private fun getAlbumText(album: Album): String? {
|
||||
return album.artistName
|
||||
}
|
||||
|
||||
private fun loadAlbumCover(album: Album, holder: FullMetalViewHolder) {
|
||||
if (holder.image == null) {
|
||||
return
|
||||
}
|
||||
|
||||
AlbumGlideRequest.Builder.from(Glide.with(activity), album.safeGetFirstSong())
|
||||
.checkIgnoreMediaStore(activity)
|
||||
.generatePalette(activity)
|
||||
.build()
|
||||
.into(object : RetroMusicColoredTarget(holder.image!!) {
|
||||
override fun onColorReady(colors: MediaNotificationProcessor) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return dataSet.size
|
||||
}
|
||||
|
||||
inner class FullMetalViewHolder(itemView: View) :
|
||||
MetalRecyclerViewPager.MetalViewHolder(itemView) {
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||
activity,
|
||||
imageContainerCard ?: image,
|
||||
activity.getString(R.string.transition_album_art)
|
||||
)
|
||||
NavigationUtil.goToAlbumOptions(activity, dataSet[layoutPosition].id, activityOptions)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -94,12 +94,12 @@ class PlaylistAdapter(
|
|||
return if (MusicUtil.isFavoritePlaylist(activity, playlist))
|
||||
TintHelper.createTintedDrawable(
|
||||
activity,
|
||||
R.drawable.ic_favorite_white_24dp,
|
||||
R.drawable.ic_favorite,
|
||||
ThemeStore.accentColor(activity)
|
||||
)
|
||||
else TintHelper.createTintedDrawable(
|
||||
activity,
|
||||
R.drawable.ic_playlist_play_white_24dp,
|
||||
R.drawable.ic_playlist_play,
|
||||
ATHUtil.resolveColor(activity, R.attr.colorControlNormal)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package io.github.muntashirakon.music.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 io.github.muntashirakon.music.model.Song
|
|||
import io.github.muntashirakon.music.util.MusicUtil
|
||||
import io.github.muntashirakon.music.util.NavigationUtil
|
||||
import io.github.muntashirakon.music.util.PreferenceUtil
|
||||
|
||||
import io.github.muntashirakon.music.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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ package io.github.muntashirakon.music.appshortcuts
|
|||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import io.github.muntashirakon.music.activities.SearchActivity
|
||||
import io.github.muntashirakon.music.activities.search.SearchActivity
|
||||
import io.github.muntashirakon.music.appshortcuts.shortcuttype.LastAddedShortcutType
|
||||
import io.github.muntashirakon.music.appshortcuts.shortcuttype.SearchShortCutType
|
||||
import io.github.muntashirakon.music.appshortcuts.shortcuttype.ShuffleAllShortcutType
|
||||
|
|
|
@ -57,7 +57,7 @@ class AppWidgetBig : BaseAppWidget() {
|
|||
R.id.button_next, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
context,
|
||||
R.drawable.ic_skip_next_white_24dp,
|
||||
R.drawable.ic_skip_next,
|
||||
MaterialValueHelper.getPrimaryTextColor(context, false)
|
||||
)!!, 1f
|
||||
)
|
||||
|
@ -66,7 +66,7 @@ class AppWidgetBig : BaseAppWidget() {
|
|||
R.id.button_prev, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
context,
|
||||
R.drawable.ic_skip_previous_white_24dp,
|
||||
R.drawable.ic_skip_previous,
|
||||
MaterialValueHelper.getPrimaryTextColor(context, false)
|
||||
)!!, 1f
|
||||
)
|
||||
|
@ -117,7 +117,7 @@ class AppWidgetBig : BaseAppWidget() {
|
|||
val primaryColor = MaterialValueHelper.getPrimaryTextColor(service, false)
|
||||
// Set correct drawable for pause state
|
||||
val playPauseRes =
|
||||
if (isPlaying) R.drawable.ic_pause_white_24dp else R.drawable.ic_play_arrow_white_32dp
|
||||
if (isPlaying) R.drawable.ic_pause else R.drawable.ic_play_arrow_white_32dp
|
||||
appWidgetView.setImageViewBitmap(
|
||||
R.id.button_toggle_play_pause, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
|
@ -133,7 +133,7 @@ class AppWidgetBig : BaseAppWidget() {
|
|||
R.id.button_next, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
service,
|
||||
R.drawable.ic_skip_next_white_24dp,
|
||||
R.drawable.ic_skip_next,
|
||||
primaryColor
|
||||
)!!, 1f
|
||||
)
|
||||
|
@ -142,7 +142,7 @@ class AppWidgetBig : BaseAppWidget() {
|
|||
R.id.button_prev, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
service,
|
||||
R.drawable.ic_skip_previous_white_24dp,
|
||||
R.drawable.ic_skip_previous,
|
||||
primaryColor
|
||||
)!!, 1f
|
||||
)
|
||||
|
|
|
@ -55,7 +55,7 @@ class AppWidgetCard : BaseAppWidget() {
|
|||
R.id.button_next, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
context,
|
||||
R.drawable.ic_skip_next_white_24dp,
|
||||
R.drawable.ic_skip_next,
|
||||
secondaryColor
|
||||
)!!, 1f
|
||||
)
|
||||
|
@ -64,7 +64,7 @@ class AppWidgetCard : BaseAppWidget() {
|
|||
R.id.button_prev, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
context,
|
||||
R.drawable.ic_skip_previous_white_24dp,
|
||||
R.drawable.ic_skip_previous,
|
||||
secondaryColor
|
||||
)!!, 1f
|
||||
)
|
||||
|
@ -103,7 +103,7 @@ class AppWidgetCard : BaseAppWidget() {
|
|||
|
||||
// Set correct drawable for pause state
|
||||
val playPauseRes =
|
||||
if (isPlaying) R.drawable.ic_pause_white_24dp else R.drawable.ic_play_arrow_white_32dp
|
||||
if (isPlaying) R.drawable.ic_pause else R.drawable.ic_play_arrow_white_32dp
|
||||
appWidgetView.setImageViewBitmap(
|
||||
R.id.button_toggle_play_pause, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
|
@ -119,7 +119,7 @@ class AppWidgetCard : BaseAppWidget() {
|
|||
R.id.button_next, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
service,
|
||||
R.drawable.ic_skip_next_white_24dp,
|
||||
R.drawable.ic_skip_next,
|
||||
MaterialValueHelper.getSecondaryTextColor(service, true)
|
||||
)!!, 1f
|
||||
)
|
||||
|
@ -128,7 +128,7 @@ class AppWidgetCard : BaseAppWidget() {
|
|||
R.id.button_prev, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
service,
|
||||
R.drawable.ic_skip_previous_white_24dp,
|
||||
R.drawable.ic_skip_previous,
|
||||
MaterialValueHelper.getSecondaryTextColor(service, true)
|
||||
)!!, 1f
|
||||
)
|
||||
|
@ -189,14 +189,14 @@ class AppWidgetCard : BaseAppWidget() {
|
|||
appWidgetView.setImageViewBitmap(
|
||||
R.id.button_next, ImageUtil.createBitmap(
|
||||
ImageUtil.getTintedVectorDrawable(
|
||||
service, R.drawable.ic_skip_next_white_24dp, color
|
||||
service, R.drawable.ic_skip_next, color
|
||||
)
|
||||
)
|
||||
)
|
||||
appWidgetView.setImageViewBitmap(
|
||||
R.id.button_prev, ImageUtil.createBitmap(
|
||||
ImageUtil.getTintedVectorDrawable(
|
||||
service, R.drawable.ic_skip_previous_white_24dp, color
|
||||
service, R.drawable.ic_skip_previous, color
|
||||
)
|
||||
)
|
||||
)
|
||||
|
|
|
@ -57,7 +57,7 @@ class AppWidgetClassic : BaseAppWidget() {
|
|||
createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
context,
|
||||
R.drawable.ic_skip_next_white_24dp,
|
||||
R.drawable.ic_skip_next,
|
||||
MaterialValueHelper.getSecondaryTextColor(context, true)
|
||||
)!!, 1f
|
||||
)
|
||||
|
@ -67,7 +67,7 @@ class AppWidgetClassic : BaseAppWidget() {
|
|||
createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
context,
|
||||
R.drawable.ic_skip_previous_white_24dp,
|
||||
R.drawable.ic_skip_previous,
|
||||
MaterialValueHelper.getSecondaryTextColor(context, true)
|
||||
)!!, 1f
|
||||
)
|
||||
|
@ -151,7 +151,7 @@ class AppWidgetClassic : BaseAppWidget() {
|
|||
private fun update(bitmap: Bitmap?, color: Int) {
|
||||
// Set correct drawable for pause state
|
||||
val playPauseRes =
|
||||
if (isPlaying) R.drawable.ic_pause_white_24dp else R.drawable.ic_play_arrow_white_24dp
|
||||
if (isPlaying) R.drawable.ic_pause else R.drawable.ic_play_arrow
|
||||
appWidgetView.setImageViewBitmap(
|
||||
R.id.button_toggle_play_pause,
|
||||
ImageUtil.createBitmap(
|
||||
|
@ -169,7 +169,7 @@ class AppWidgetClassic : BaseAppWidget() {
|
|||
ImageUtil.createBitmap(
|
||||
ImageUtil.getTintedVectorDrawable(
|
||||
service,
|
||||
R.drawable.ic_skip_next_white_24dp,
|
||||
R.drawable.ic_skip_next,
|
||||
color
|
||||
)
|
||||
)
|
||||
|
@ -179,7 +179,7 @@ class AppWidgetClassic : BaseAppWidget() {
|
|||
ImageUtil.createBitmap(
|
||||
ImageUtil.getTintedVectorDrawable(
|
||||
service,
|
||||
R.drawable.ic_skip_previous_white_24dp,
|
||||
R.drawable.ic_skip_previous,
|
||||
color
|
||||
)
|
||||
)
|
||||
|
|
|
@ -54,7 +54,7 @@ class AppWidgetSmall : BaseAppWidget() {
|
|||
createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
context,
|
||||
R.drawable.ic_skip_next_white_24dp,
|
||||
R.drawable.ic_skip_next,
|
||||
MaterialValueHelper.getSecondaryTextColor(context, true)
|
||||
)!!, 1f
|
||||
)
|
||||
|
@ -64,7 +64,7 @@ class AppWidgetSmall : BaseAppWidget() {
|
|||
createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
context,
|
||||
R.drawable.ic_skip_previous_white_24dp,
|
||||
R.drawable.ic_skip_previous,
|
||||
MaterialValueHelper.getSecondaryTextColor(context, true)
|
||||
)!!, 1f
|
||||
)
|
||||
|
@ -150,7 +150,7 @@ class AppWidgetSmall : BaseAppWidget() {
|
|||
|
||||
private fun update(bitmap: Bitmap?, color: Int) {
|
||||
// Set correct drawable for pause state
|
||||
val playPauseRes = if (isPlaying) R.drawable.ic_pause_white_24dp
|
||||
val playPauseRes = if (isPlaying) R.drawable.ic_pause
|
||||
else R.drawable.ic_play_arrow_white_32dp
|
||||
appWidgetView.setImageViewBitmap(
|
||||
R.id.button_toggle_play_pause, createBitmap(
|
||||
|
@ -164,14 +164,14 @@ class AppWidgetSmall : BaseAppWidget() {
|
|||
appWidgetView.setImageViewBitmap(
|
||||
R.id.button_next, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
service, R.drawable.ic_skip_next_white_24dp, color
|
||||
service, R.drawable.ic_skip_next, color
|
||||
)!!, 1f
|
||||
)
|
||||
)
|
||||
appWidgetView.setImageViewBitmap(
|
||||
R.id.button_prev, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
service, R.drawable.ic_skip_previous_white_24dp, color
|
||||
service, R.drawable.ic_skip_previous, color
|
||||
)!!, 1f
|
||||
)
|
||||
)
|
||||
|
|
|
@ -37,7 +37,7 @@ class AppWidgetText : BaseAppWidget() {
|
|||
appWidgetView.setImageViewBitmap(
|
||||
R.id.button_next, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
context, R.drawable.ic_skip_next_white_24dp, ContextCompat.getColor(
|
||||
context, R.drawable.ic_skip_next, ContextCompat.getColor(
|
||||
context, R.color.md_white_1000
|
||||
)
|
||||
)!!, 1f
|
||||
|
@ -46,7 +46,7 @@ class AppWidgetText : BaseAppWidget() {
|
|||
appWidgetView.setImageViewBitmap(
|
||||
R.id.button_prev, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
context, R.drawable.ic_skip_previous_white_24dp, ContextCompat.getColor(
|
||||
context, R.drawable.ic_skip_previous, ContextCompat.getColor(
|
||||
context, R.color.md_white_1000
|
||||
)
|
||||
)!!, 1f
|
||||
|
@ -119,7 +119,7 @@ class AppWidgetText : BaseAppWidget() {
|
|||
linkButtons(service, appWidgetView)
|
||||
|
||||
// Set correct drawable for pause state
|
||||
val playPauseRes = if (isPlaying) R.drawable.ic_pause_white_24dp
|
||||
val playPauseRes = if (isPlaying) R.drawable.ic_pause
|
||||
else R.drawable.ic_play_arrow_white_32dp
|
||||
appWidgetView.setImageViewBitmap(
|
||||
R.id.button_toggle_play_pause, createBitmap(
|
||||
|
@ -134,7 +134,7 @@ class AppWidgetText : BaseAppWidget() {
|
|||
R.id.button_next, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
App.getContext(),
|
||||
R.drawable.ic_skip_next_white_24dp,
|
||||
R.drawable.ic_skip_next,
|
||||
ContextCompat.getColor(
|
||||
App.getContext(), R.color.md_white_1000
|
||||
)
|
||||
|
@ -145,7 +145,7 @@ class AppWidgetText : BaseAppWidget() {
|
|||
R.id.button_prev, createBitmap(
|
||||
RetroUtil.getTintedVectorDrawable(
|
||||
App.getContext(),
|
||||
R.drawable.ic_skip_previous_white_24dp,
|
||||
R.drawable.ic_skip_previous,
|
||||
ContextCompat.getColor(
|
||||
App.getContext(), R.color.md_white_1000
|
||||
)
|
||||
|
|
|
@ -19,11 +19,12 @@ import android.os.Bundle
|
|||
import androidx.fragment.app.DialogFragment
|
||||
import io.github.muntashirakon.music.EXTRA_SONG
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.extensions.colorButtons
|
||||
import io.github.muntashirakon.music.extensions.extraNotNull
|
||||
import io.github.muntashirakon.music.extensions.materialDialog
|
||||
import io.github.muntashirakon.music.loaders.PlaylistLoader
|
||||
import io.github.muntashirakon.music.model.Song
|
||||
import io.github.muntashirakon.music.util.PlaylistsUtil
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
class AddToPlaylistDialog : DialogFragment() {
|
||||
|
||||
|
@ -31,17 +32,13 @@ class AddToPlaylistDialog : DialogFragment() {
|
|||
savedInstanceState: Bundle?
|
||||
): Dialog {
|
||||
val playlists = PlaylistLoader.getAllPlaylists(requireContext())
|
||||
val playlistNames = mutableListOf<CharSequence>()
|
||||
val playlistNames = mutableListOf<String>()
|
||||
playlistNames.add(requireContext().resources.getString(R.string.action_new_playlist))
|
||||
for (p in playlists) {
|
||||
playlistNames.add(p.name)
|
||||
}
|
||||
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(R.string.add_playlist_title)
|
||||
return materialDialog(R.string.add_playlist_title)
|
||||
.setItems(playlistNames.toTypedArray()) { _, which ->
|
||||
val songs = extraNotNull<ArrayList<Song>>(EXTRA_SONG).value
|
||||
if (which == 0) {
|
||||
|
@ -57,7 +54,7 @@ class AddToPlaylistDialog : DialogFragment() {
|
|||
}
|
||||
dismiss()
|
||||
}
|
||||
.create()
|
||||
.create().colorButtons()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -71,9 +71,9 @@ public class BlacklistFolderChooserDialog extends DialogFragment implements Mate
|
|||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
&& ActivityCompat.checkSelfPermission(
|
||||
getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
requireActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
return new MaterialDialog.Builder(getActivity())
|
||||
return new MaterialDialog.Builder(requireActivity())
|
||||
.title(R.string.md_error_label)
|
||||
.content(R.string.md_storage_perm_error)
|
||||
.positiveText(android.R.string.ok)
|
||||
|
@ -89,7 +89,7 @@ public class BlacklistFolderChooserDialog extends DialogFragment implements Mate
|
|||
checkIfCanGoUp();
|
||||
parentContents = listFiles();
|
||||
MaterialDialog.Builder builder =
|
||||
new MaterialDialog.Builder(getActivity())
|
||||
new MaterialDialog.Builder(requireActivity())
|
||||
.title(parentFolder.getAbsolutePath())
|
||||
.items((CharSequence[]) getContentsArray())
|
||||
.itemsCallback(this)
|
||||
|
|
|
@ -23,10 +23,11 @@ import androidx.fragment.app.DialogFragment
|
|||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import io.github.muntashirakon.music.EXTRA_SONG
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.extensions.colorButtons
|
||||
import io.github.muntashirakon.music.extensions.extraNotNull
|
||||
import io.github.muntashirakon.music.extensions.materialDialog
|
||||
import io.github.muntashirakon.music.model.Song
|
||||
import io.github.muntashirakon.music.util.PlaylistsUtil
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import kotlinx.android.synthetic.main.dialog_playlist.view.*
|
||||
|
@ -42,11 +43,7 @@ class CreatePlaylistDialog : DialogFragment() {
|
|||
val playlistContainer: TextInputLayout = view.actionNewPlaylistContainer
|
||||
MaterialUtil.setTint(playlistContainer, false)
|
||||
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireActivity(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(R.string.new_playlist_title)
|
||||
return materialDialog(R.string.new_playlist_title)
|
||||
.setView(view)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(
|
||||
|
@ -65,6 +62,7 @@ class CreatePlaylistDialog : DialogFragment() {
|
|||
}
|
||||
}
|
||||
.create()
|
||||
.colorButtons()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -20,10 +20,11 @@ import androidx.core.text.HtmlCompat
|
|||
import androidx.fragment.app.DialogFragment
|
||||
import io.github.muntashirakon.music.EXTRA_PLAYLIST
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.extensions.colorButtons
|
||||
import io.github.muntashirakon.music.extensions.extraNotNull
|
||||
import io.github.muntashirakon.music.extensions.materialDialog
|
||||
import io.github.muntashirakon.music.model.Playlist
|
||||
import io.github.muntashirakon.music.util.PlaylistsUtil
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
class DeletePlaylistDialog : DialogFragment() {
|
||||
|
||||
|
@ -46,10 +47,7 @@ class DeletePlaylistDialog : DialogFragment() {
|
|||
)
|
||||
}
|
||||
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
return materialDialog(title)
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
|
@ -57,6 +55,7 @@ class DeletePlaylistDialog : DialogFragment() {
|
|||
PlaylistsUtil.deletePlaylists(requireContext(), playlists)
|
||||
}
|
||||
.create()
|
||||
.colorButtons()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -23,12 +23,13 @@ import androidx.fragment.app.DialogFragment
|
|||
import io.github.muntashirakon.music.EXTRA_SONG
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.activities.saf.SAFGuideActivity
|
||||
import io.github.muntashirakon.music.extensions.colorButtons
|
||||
import io.github.muntashirakon.music.extensions.extraNotNull
|
||||
import io.github.muntashirakon.music.extensions.materialDialog
|
||||
import io.github.muntashirakon.music.helper.MusicPlayerRemote
|
||||
import io.github.muntashirakon.music.model.Song
|
||||
import io.github.muntashirakon.music.util.MusicUtil
|
||||
import io.github.muntashirakon.music.util.SAFUtil
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
class DeleteSongsDialog : DialogFragment() {
|
||||
@JvmField
|
||||
|
@ -57,11 +58,7 @@ class DeleteSongsDialog : DialogFragment() {
|
|||
)
|
||||
}
|
||||
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(title)
|
||||
return materialDialog(title)
|
||||
.setMessage(message)
|
||||
.setCancelable(false)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
|
@ -74,6 +71,7 @@ class DeleteSongsDialog : DialogFragment() {
|
|||
deleteSongsAsyncTask?.execute(DeleteSongsAsyncTask.LoadingInfo(songs, null))
|
||||
}
|
||||
.create()
|
||||
.colorButtons()
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
|
|
|
@ -20,9 +20,10 @@ import androidx.core.text.HtmlCompat
|
|||
import androidx.fragment.app.DialogFragment
|
||||
import io.github.muntashirakon.music.EXTRA_SONG
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.extensions.colorButtons
|
||||
import io.github.muntashirakon.music.extensions.materialDialog
|
||||
import io.github.muntashirakon.music.model.PlaylistSong
|
||||
import io.github.muntashirakon.music.util.PlaylistsUtil
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
class RemoveFromPlaylistDialog : DialogFragment() {
|
||||
|
||||
|
@ -50,11 +51,7 @@ class RemoveFromPlaylistDialog : DialogFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(title)
|
||||
return materialDialog(title)
|
||||
.setMessage(message)
|
||||
.setPositiveButton(R.string.remove_action) { _, _ ->
|
||||
PlaylistsUtil.removeFromPlaylist(
|
||||
|
@ -64,6 +61,7 @@ class RemoveFromPlaylistDialog : DialogFragment() {
|
|||
}
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create()
|
||||
.colorButtons()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -22,9 +22,10 @@ import android.view.LayoutInflater
|
|||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.extensions.colorButtons
|
||||
import io.github.muntashirakon.music.extensions.extraNotNull
|
||||
import io.github.muntashirakon.music.extensions.materialDialog
|
||||
import io.github.muntashirakon.music.util.PlaylistsUtil
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
|
||||
|
@ -42,11 +43,7 @@ class RenamePlaylistDialog : DialogFragment() {
|
|||
layout.findViewById(R.id.actionNewPlaylistContainer)
|
||||
MaterialUtil.setTint(nameContainer, false)
|
||||
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(R.string.rename_playlist_title)
|
||||
return materialDialog(R.string.rename_playlist_title)
|
||||
.setView(layout)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(R.string.action_rename) { _, _ ->
|
||||
|
@ -60,6 +57,7 @@ class RenamePlaylistDialog : DialogFragment() {
|
|||
}
|
||||
}
|
||||
.create()
|
||||
.colorButtons()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package code.name.monkey.retromusic.dialogs
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.ArrayAdapter
|
||||
import code.name.monkey.retromusic.R
|
||||
|
||||
class RetroSingleCheckedListAdapter(
|
||||
context: Context,
|
||||
resource: Int = R.layout.dialog_list_item,
|
||||
objects: MutableList<String>
|
||||
) : ArrayAdapter<String>(context, resource, objects) {
|
||||
|
||||
}
|
|
@ -31,6 +31,8 @@ import android.widget.Toast
|
|||
import androidx.fragment.app.DialogFragment
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.extensions.addAccentColor
|
||||
import io.github.muntashirakon.music.extensions.colorButtons
|
||||
import io.github.muntashirakon.music.extensions.materialDialog
|
||||
import io.github.muntashirakon.music.helper.MusicPlayerRemote
|
||||
import io.github.muntashirakon.music.service.MusicService
|
||||
import io.github.muntashirakon.music.service.MusicService.ACTION_PENDING_QUIT
|
||||
|
@ -38,13 +40,12 @@ import io.github.muntashirakon.music.service.MusicService.ACTION_QUIT
|
|||
import io.github.muntashirakon.music.util.PreferenceUtil
|
||||
import com.afollestad.materialdialogs.DialogAction
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
class SleepTimerDialog : DialogFragment() {
|
||||
|
||||
private var seekArcProgress: Int = 0
|
||||
private lateinit var timerUpdater: TimerUpdater
|
||||
private lateinit var materialDialog: MaterialDialog
|
||||
private lateinit var dialog: MaterialDialog
|
||||
private lateinit var shouldFinishLastSong: CheckBox
|
||||
private lateinit var seekBar: SeekBar
|
||||
private lateinit var timerDisplay: TextView
|
||||
|
@ -87,11 +88,7 @@ class SleepTimerDialog : DialogFragment() {
|
|||
PreferenceUtil.lastSleepTimerValue = seekArcProgress
|
||||
}
|
||||
})
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(R.string.action_sleep_timer)
|
||||
return materialDialog(R.string.action_sleep_timer)
|
||||
.setView(layout)
|
||||
.setPositiveButton(R.string.action_set) { _, _ ->
|
||||
PreferenceUtil.isSleepTimerFinishMusic = shouldFinishLastSong.isChecked
|
||||
|
@ -132,6 +129,8 @@ class SleepTimerDialog : DialogFragment() {
|
|||
}
|
||||
}
|
||||
.create()
|
||||
.colorButtons()
|
||||
|
||||
}
|
||||
|
||||
private fun updateTimeDisplayTime() {
|
||||
|
@ -152,10 +151,10 @@ class SleepTimerDialog : DialogFragment() {
|
|||
private fun updateCancelButton() {
|
||||
val musicService = MusicPlayerRemote.musicService
|
||||
if (musicService != null && musicService.pendingQuit) {
|
||||
materialDialog.getActionButton(DialogAction.NEUTRAL).text =
|
||||
materialDialog.context.getString(R.string.cancel_current_timer)
|
||||
dialog.getActionButton(DialogAction.NEUTRAL).text =
|
||||
dialog.context.getString(R.string.cancel_current_timer)
|
||||
} else {
|
||||
materialDialog.getActionButton(DialogAction.NEUTRAL).text = null
|
||||
dialog.getActionButton(DialogAction.NEUTRAL).text = null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,9 +29,10 @@ import androidx.core.text.HtmlCompat
|
|||
import androidx.fragment.app.DialogFragment
|
||||
import io.github.muntashirakon.music.EXTRA_SONG
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.extensions.colorButtons
|
||||
import io.github.muntashirakon.music.extensions.materialDialog
|
||||
import io.github.muntashirakon.music.model.Song
|
||||
import io.github.muntashirakon.music.util.MusicUtil
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import org.jaudiotagger.audio.AudioFileIO
|
||||
import org.jaudiotagger.audio.exceptions.CannotReadException
|
||||
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
|
||||
|
@ -150,13 +151,11 @@ class SongDetailDialog : DialogFragment() {
|
|||
)
|
||||
}
|
||||
}
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
).setTitle(R.string.action_details)
|
||||
return materialDialog(R.string.action_details)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.setView(dialogView)
|
||||
.create()
|
||||
.colorButtons()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -21,9 +21,10 @@ import androidx.fragment.app.DialogFragment
|
|||
import io.github.muntashirakon.music.EXTRA_SONG
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.activities.ShareInstagramStory
|
||||
import io.github.muntashirakon.music.extensions.colorButtons
|
||||
import io.github.muntashirakon.music.extensions.materialDialog
|
||||
import io.github.muntashirakon.music.model.Song
|
||||
import io.github.muntashirakon.music.util.MusicUtil
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
class SongShareDialog : DialogFragment() {
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
|
@ -34,10 +35,7 @@ class SongShareDialog : DialogFragment() {
|
|||
song?.title,
|
||||
song?.artistName
|
||||
)
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
).setTitle(R.string.what_do_you_want_to_share)
|
||||
return materialDialog(R.string.what_do_you_want_to_share)
|
||||
.setItems(
|
||||
arrayOf(
|
||||
getString(R.string.the_audio_file),
|
||||
|
@ -48,6 +46,7 @@ class SongShareDialog : DialogFragment() {
|
|||
withAction(which, song, listening)
|
||||
}
|
||||
.create()
|
||||
.colorButtons()
|
||||
}
|
||||
|
||||
private fun withAction(
|
||||
|
|
|
@ -18,6 +18,7 @@ import android.app.Dialog
|
|||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.widget.Button
|
||||
import android.widget.CheckBox
|
||||
import android.widget.SeekBar
|
||||
import androidx.annotation.AttrRes
|
||||
|
@ -26,6 +27,7 @@ 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 io.github.muntashirakon.music.App
|
||||
import io.github.muntashirakon.music.R
|
||||
|
||||
fun Int.ripAlpha(): Int {
|
||||
|
@ -77,4 +79,8 @@ fun SeekBar.addAccentColor() {
|
|||
val colorState = ColorStateList.valueOf(ThemeStore.accentColor(context))
|
||||
progressTintList = colorState
|
||||
thumbTintList = colorState
|
||||
}
|
||||
|
||||
fun Button.accentTextColor() {
|
||||
setTextColor(ThemeStore.accentColor(App.getContext()))
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package code.name.monkey.retromusic.extensions
|
||||
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.R
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
fun DialogFragment.materialDialog(title: Int): MaterialAlertDialogBuilder {
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
).setTitle(title)
|
||||
}
|
||||
|
||||
fun AlertDialog.colorButtons(): AlertDialog {
|
||||
setOnShowListener {
|
||||
getButton(AlertDialog.BUTTON_POSITIVE).accentTextColor()
|
||||
getButton(AlertDialog.BUTTON_NEGATIVE).accentTextColor()
|
||||
getButton(AlertDialog.BUTTON_NEUTRAL).accentTextColor()
|
||||
}
|
||||
return this
|
||||
}
|
|
@ -1,24 +1,23 @@
|
|||
package io.github.muntashirakon.music.fragments
|
||||
|
||||
import android.app.Application
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import io.github.muntashirakon.music.adapter.HomeAdapter
|
||||
import io.github.muntashirakon.music.fragments.ReloadType.*
|
||||
import io.github.muntashirakon.music.interfaces.MusicServiceEventListener
|
||||
import io.github.muntashirakon.music.model.*
|
||||
import io.github.muntashirakon.music.providers.RepositoryImpl
|
||||
import io.github.muntashirakon.music.providers.interfaces.Repository
|
||||
import kotlinx.coroutines.Deferred
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class LibraryViewModel(application: Application) :
|
||||
AndroidViewModel(application), MusicServiceEventListener {
|
||||
class LibraryViewModel(
|
||||
private val repository: RepositoryImpl
|
||||
) : ViewModel(), MusicServiceEventListener {
|
||||
|
||||
private val _repository: Repository = RepositoryImpl(application.applicationContext)
|
||||
private val _albums = MutableLiveData<List<Album>>()
|
||||
private val _songs = MutableLiveData<List<Song>>()
|
||||
private val _artists = MutableLiveData<List<Artist>>()
|
||||
|
@ -51,16 +50,22 @@ class LibraryViewModel(application: Application) :
|
|||
private fun loadHomeSections() = viewModelScope.launch {
|
||||
val list = mutableListOf<Home>()
|
||||
val result = listOf(
|
||||
_repository.topArtists(),
|
||||
_repository.topAlbums(),
|
||||
_repository.recentArtists(),
|
||||
_repository.recentAlbums(),
|
||||
_repository.favoritePlaylist(),
|
||||
_repository.suggestions()
|
||||
repository.topArtists(),
|
||||
repository.topAlbums(),
|
||||
repository.recentArtists(),
|
||||
repository.recentAlbums(),
|
||||
repository.suggestions(),
|
||||
repository.favoritePlaylist()
|
||||
)
|
||||
for (r in result) {
|
||||
if (r != null) {
|
||||
list.add(r)
|
||||
result.forEach {
|
||||
if (it != null && it.arrayList.isNotEmpty()) {
|
||||
if (it.homeSection == HomeAdapter.SUGGESTIONS) {
|
||||
if (it.arrayList.size > 9) {
|
||||
list.add(it)
|
||||
}
|
||||
} else {
|
||||
list.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
_homeSections.value = list
|
||||
|
@ -68,27 +73,27 @@ class LibraryViewModel(application: Application) :
|
|||
|
||||
private val loadSongs: Deferred<List<Song>>
|
||||
get() = viewModelScope.async(IO) {
|
||||
_repository.allSongs()
|
||||
repository.allSongs()
|
||||
}
|
||||
|
||||
private val loadAlbums: Deferred<List<Album>>
|
||||
get() = viewModelScope.async(IO) {
|
||||
_repository.allAlbums()
|
||||
repository.allAlbums()
|
||||
}
|
||||
|
||||
private val loadArtists: Deferred<List<Artist>>
|
||||
get() = viewModelScope.async(IO) {
|
||||
_repository.allArtists()
|
||||
repository.allArtists()
|
||||
}
|
||||
|
||||
private val loadPlaylists: Deferred<List<Playlist>>
|
||||
get() = viewModelScope.async(IO) {
|
||||
_repository.allPlaylists()
|
||||
repository.allPlaylists()
|
||||
}
|
||||
|
||||
private val loadGenres: Deferred<List<Genre>>
|
||||
get() = viewModelScope.async(IO) {
|
||||
_repository.allGenres()
|
||||
repository.allGenres()
|
||||
}
|
||||
|
||||
fun forceReload(reloadType: ReloadType) = viewModelScope.launch {
|
||||
|
|
|
@ -15,14 +15,12 @@ import io.github.muntashirakon.music.extensions.show
|
|||
import io.github.muntashirakon.music.extensions.textColorPrimary
|
||||
import io.github.muntashirakon.music.extensions.textColorSecondary
|
||||
import io.github.muntashirakon.music.fragments.base.AbsMusicServiceFragment
|
||||
import io.github.muntashirakon.music.glide.SongGlideRequest
|
||||
import io.github.muntashirakon.music.helper.MusicPlayerRemote
|
||||
import io.github.muntashirakon.music.helper.MusicProgressViewUpdateHelper
|
||||
import io.github.muntashirakon.music.helper.PlayPauseButtonOnClickHandler
|
||||
import io.github.muntashirakon.music.util.PreferenceUtil
|
||||
import io.github.muntashirakon.music.util.RetroUtil
|
||||
import io.github.muntashirakon.music.util.ViewUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import kotlinx.android.synthetic.main.fragment_mini_player.*
|
||||
import kotlin.math.abs
|
||||
|
||||
|
@ -63,8 +61,7 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
|
|||
actionPrevious?.show()
|
||||
|
||||
} else {
|
||||
actionNext.visibility =
|
||||
if (PreferenceUtil.isExtraControls) View.VISIBLE else View.GONE
|
||||
actionNext.visibility = if (PreferenceUtil.isExtraControls) View.VISIBLE else View.GONE
|
||||
actionPrevious.visibility =
|
||||
if (PreferenceUtil.isExtraControls) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
@ -97,19 +94,6 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
|
|||
|
||||
miniPlayerTitle.isSelected = true
|
||||
miniPlayerTitle.text = builder
|
||||
|
||||
if (RetroUtil.isTablet()) {
|
||||
image?.let {
|
||||
SongGlideRequest.Builder.from(
|
||||
Glide.with(requireContext()),
|
||||
MusicPlayerRemote.currentSong
|
||||
).checkIgnoreMediaStore(requireContext())
|
||||
.ignoreMediaStore(PreferenceUtil.isAllowedToDownloadMetadata())
|
||||
.asBitmap()
|
||||
.build()
|
||||
.into(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onServiceConnected() {
|
||||
|
@ -145,9 +129,9 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
|
|||
|
||||
protected fun updatePlayPauseDrawableState() {
|
||||
if (MusicPlayerRemote.isPlaying) {
|
||||
miniPlayerPlayPauseButton!!.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
miniPlayerPlayPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
} else {
|
||||
miniPlayerPlayPauseButton!!.setImageResource(R.drawable.ic_play_arrow_white_24dp)
|
||||
miniPlayerPlayPauseButton.setImageResource(R.drawable.ic_play_arrow)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum
|
|||
|
||||
volumeSeekBar.max = maxVolume
|
||||
volumeSeekBar.progress = currentVolume
|
||||
volumeDown.setImageResource(if (currentVolume == 0) R.drawable.ic_volume_off_white_24dp else R.drawable.ic_volume_down_white_24dp)
|
||||
volumeDown.setImageResource(if (currentVolume == 0) R.drawable.ic_volume_off else R.drawable.ic_volume_down)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
@ -74,7 +74,7 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum
|
|||
val audioManager = audioManager
|
||||
audioManager?.setStreamVolume(AudioManager.STREAM_MUSIC, i, 0)
|
||||
setPauseWhenZeroVolume(i < 1)
|
||||
volumeDown?.setImageResource(if (i == 0) R.drawable.ic_volume_off_white_24dp else R.drawable.ic_volume_down_white_24dp)
|
||||
volumeDown?.setImageResource(if (i == 0) R.drawable.ic_volume_off else R.drawable.ic_volume_down)
|
||||
}
|
||||
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar) {
|
||||
|
|
|
@ -15,7 +15,6 @@ class AlbumsFragment :
|
|||
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
|
||||
MainActivityFragmentCallbacks {
|
||||
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
mainActivity.libraryViewModel.allAlbums()
|
||||
|
|
|
@ -197,9 +197,9 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(),
|
|||
|
||||
override fun onPostExecute(isFavorite: Boolean) {
|
||||
val res = if (isFavorite)
|
||||
R.drawable.ic_favorite_white_24dp
|
||||
R.drawable.ic_favorite
|
||||
else
|
||||
R.drawable.ic_favorite_border_white_24dp
|
||||
R.drawable.ic_favorite_border
|
||||
|
||||
val drawable =
|
||||
RetroUtil.getTintedVectorDrawable(requireContext(), res, toolbarIconColor())
|
||||
|
|
|
@ -375,7 +375,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
|
|||
}
|
||||
cab = new MaterialCab(getMainActivity(), R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||
.setCloseDrawableRes(R.drawable.ic_close)
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(
|
||||
ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorSurface)))
|
||||
.start(callback);
|
||||
|
|
|
@ -157,7 +157,7 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
if (MusicPlayerRemote.isPlaying) {
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
} else {
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
|
||||
}
|
||||
|
@ -214,18 +214,18 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
if (MusicPlayerRemote.isPlaying) {
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
} else {
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
|
||||
}
|
||||
|
@ -197,18 +197,18 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
if (MusicPlayerRemote.isPlaying) {
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
} else {
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
|
||||
}
|
||||
|
@ -204,18 +204,18 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
when {
|
||||
MusicPlayerRemote.isPlaying -> playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
MusicPlayerRemote.isPlaying -> playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
else -> playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
|
||||
}
|
||||
}
|
||||
|
@ -177,18 +177,18 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,8 +206,8 @@ class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChanged
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
when {
|
||||
MusicPlayerRemote.isPlaying -> playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
else -> playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_24dp)
|
||||
MusicPlayerRemote.isPlaying -> playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
else -> playPauseButton.setImageResource(R.drawable.ic_play_arrow)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -415,9 +415,9 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
if (MusicPlayerRemote.isPlaying) {
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
} else {
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -466,18 +466,18 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
|
|||
fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,8 +129,8 @@ class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
when {
|
||||
MusicPlayerRemote.isPlaying -> playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
else -> playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_24dp)
|
||||
MusicPlayerRemote.isPlaying -> playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
else -> playPauseButton.setImageResource(R.drawable.ic_play_arrow)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,18 +177,18 @@ class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
if (MusicPlayerRemote.isPlaying) {
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
} else {
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
|
||||
}
|
||||
|
@ -205,18 +205,18 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
if (MusicPlayerRemote.isPlaying) {
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
} else {
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
|
||||
}
|
||||
|
@ -189,18 +189,18 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
if (MusicPlayerRemote.isPlaying) {
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
} else {
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
|
||||
}
|
||||
|
@ -257,18 +257,18 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
@ -309,9 +309,9 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
|
|||
val activity = activity
|
||||
if (activity != null) {
|
||||
val res = if (isFavorite!!)
|
||||
R.drawable.ic_favorite_white_24dp
|
||||
R.drawable.ic_favorite
|
||||
else
|
||||
R.drawable.ic_favorite_border_white_24dp
|
||||
R.drawable.ic_favorite_border
|
||||
|
||||
val drawable = TintHelper.createTintedDrawable(activity, res, Color.WHITE)
|
||||
songFavourite?.setImageDrawable(drawable)
|
||||
|
|
|
@ -355,18 +355,18 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
|
|||
fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
@ -506,9 +506,9 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
|
|||
val activity = activity
|
||||
if (activity != null) {
|
||||
val res = if (isFavorite!!)
|
||||
R.drawable.ic_favorite_white_24dp
|
||||
R.drawable.ic_favorite
|
||||
else
|
||||
R.drawable.ic_favorite_border_white_24dp
|
||||
R.drawable.ic_favorite_border
|
||||
|
||||
val drawable = TintHelper.createTintedDrawable(activity, res, Color.WHITE)
|
||||
songFavourite?.setImageDrawable(drawable)
|
||||
|
|
|
@ -156,7 +156,7 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
if (MusicPlayerRemote.isPlaying) {
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
} else {
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
|
||||
}
|
||||
|
@ -205,18 +205,18 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,18 +190,18 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_sharp_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_sharp)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_sharp_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_sharp)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_sharp_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_sharp)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,9 +153,9 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
if (MusicPlayerRemote.isPlaying) {
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
} else {
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,18 +202,18 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
if (MusicPlayerRemote.isPlaying) {
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
} else {
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
|
||||
}
|
||||
|
@ -203,18 +203,18 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment() {
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -204,18 +204,18 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
if (MusicPlayerRemote.isPlaying) {
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
} else {
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
|
||||
}
|
||||
|
|
|
@ -134,18 +134,18 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
repeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
|
||||
private fun updatePlayPauseDrawableState() {
|
||||
if (MusicPlayerRemote.isPlaying) {
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp)
|
||||
playPauseButton.setImageResource(R.drawable.ic_pause)
|
||||
} else {
|
||||
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
|
||||
}
|
||||
|
|
|
@ -81,18 +81,18 @@ class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
|
|||
override fun updateRepeatState() {
|
||||
when (MusicPlayerRemote.repeatMode) {
|
||||
MusicService.REPEAT_MODE_NONE -> {
|
||||
playerRepeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
playerRepeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
playerRepeatButton.setColorFilter(
|
||||
lastDisabledPlaybackControlsColor,
|
||||
PorterDuff.Mode.SRC_IN
|
||||
)
|
||||
}
|
||||
MusicService.REPEAT_MODE_ALL -> {
|
||||
playerRepeatButton.setImageResource(R.drawable.ic_repeat_white_24dp)
|
||||
playerRepeatButton.setImageResource(R.drawable.ic_repeat)
|
||||
playerRepeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
MusicService.REPEAT_MODE_THIS -> {
|
||||
playerRepeatButton.setImageResource(R.drawable.ic_repeat_one_white_24dp)
|
||||
playerRepeatButton.setImageResource(R.drawable.ic_repeat_one)
|
||||
playerRepeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,9 +36,6 @@ abstract class RetroMusicColoredTarget(view: ImageView) : BitmapPaletteTarget(vi
|
|||
super.onLoadFailed(e, errorDrawable)
|
||||
val colors = MediaNotificationProcessor(App.getContext(), errorDrawable)
|
||||
onColorReady(colors)
|
||||
/* MediaNotificationProcessor(App.getContext()).getPaletteAsync({
|
||||
onColorReady(it)
|
||||
}, errorDrawable)*/
|
||||
}
|
||||
|
||||
override fun onResourceReady(
|
||||
|
|
|
@ -23,7 +23,7 @@ import static io.github.muntashirakon.music.Constants.USER_PROFILE;
|
|||
|
||||
public class UserProfileGlideRequest {
|
||||
private static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.NONE;
|
||||
private static final int DEFAULT_ERROR_IMAGE = R.drawable.ic_account_white_24dp;
|
||||
private static final int DEFAULT_ERROR_IMAGE = R.drawable.ic_account;
|
||||
private static final int DEFAULT_ANIMATION = android.R.anim.fade_in;
|
||||
|
||||
public static File getUserModel() {
|
||||
|
@ -47,7 +47,7 @@ public class UserProfileGlideRequest {
|
|||
private Builder(RequestManager requestManager, File profile) {
|
||||
this.requestManager = requestManager;
|
||||
this.profile = profile;
|
||||
error = TintHelper.createTintedDrawable(App.Companion.getContext(), R.drawable.ic_account_white_24dp, ThemeStore.Companion.accentColor(App.Companion.getContext()));
|
||||
error = TintHelper.createTintedDrawable(App.Companion.getContext(), R.drawable.ic_account, ThemeStore.Companion.accentColor(App.Companion.getContext()));
|
||||
}
|
||||
|
||||
public static Builder from(@NonNull RequestManager requestManager, File profile) {
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
package io.github.muntashirakon.music.glide.artistimage
|
||||
|
||||
import android.content.Context
|
||||
import io.github.muntashirakon.music.deezer.Data
|
||||
import io.github.muntashirakon.music.deezer.DeezerApiService
|
||||
import io.github.muntashirakon.music.deezer.Data
|
||||
import io.github.muntashirakon.music.util.MusicUtil
|
||||
import io.github.muntashirakon.music.util.PreferenceUtil
|
||||
import com.bumptech.glide.Priority
|
||||
|
|
|
@ -181,7 +181,7 @@ public class LrcView extends View {
|
|||
mTimelineColor = ta.getColor(R.styleable.LrcView_lrcTimelineColor, getResources().getColor(R.color.lrc_timeline_color));
|
||||
float timelineHeight = ta.getDimension(R.styleable.LrcView_lrcTimelineHeight, getResources().getDimension(R.dimen.lrc_timeline_height));
|
||||
mPlayDrawable = ta.getDrawable(R.styleable.LrcView_lrcPlayDrawable);
|
||||
mPlayDrawable = (mPlayDrawable == null) ? getResources().getDrawable(R.drawable.ic_play_arrow_white_24dp) : mPlayDrawable;
|
||||
mPlayDrawable = (mPlayDrawable == null) ? getResources().getDrawable(R.drawable.ic_play_arrow) : mPlayDrawable;
|
||||
mTimeTextColor = ta.getColor(R.styleable.LrcView_lrcTimeTextColor, getResources().getColor(R.color.lrc_time_text_color));
|
||||
float timeTextSize = ta.getDimension(R.styleable.LrcView_lrcTimeTextSize, getResources().getDimension(R.dimen.lrc_time_text_size));
|
||||
mTextGravity = ta.getInteger(R.styleable.LrcView_lrcTextGravity, LrcEntry.GRAVITY_CENTER);
|
||||
|
|
|
@ -59,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.asld_home),
|
||||
Songs(R.id.action_song, R.string.songs, R.drawable.asld_music_note),
|
||||
Albums(R.id.action_album, R.string.albums, R.drawable.asld_album),
|
||||
Artists(R.id.action_artist, R.string.artists, R.drawable.ic_artist),
|
||||
Playlists(R.id.action_playlist, R.string.playlists, R.drawable.ic_playlist_play),
|
||||
Genres(R.id.action_genre, R.string.genres, R.drawable.ic_guitar),
|
||||
Queue(R.id.action_playing_queue, R.string.queue, R.drawable.ic_queue_music),
|
||||
Folder(R.id.action_folder, R.string.folders, R.drawable.ic_folder);
|
||||
|
||||
public final int icon;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public abstract class AbsSmartPlaylist extends AbsCustomPlaylist {
|
|||
|
||||
public AbsSmartPlaylist() {
|
||||
super();
|
||||
this.iconRes = R.drawable.ic_queue_music_white_24dp;
|
||||
this.iconRes = R.drawable.ic_queue_music;
|
||||
}
|
||||
|
||||
protected AbsSmartPlaylist(Parcel in) {
|
||||
|
|
|
@ -44,7 +44,7 @@ public class HistoryPlaylist extends AbsSmartPlaylist {
|
|||
};
|
||||
|
||||
public HistoryPlaylist(@NonNull Context context) {
|
||||
super(context.getString(R.string.history), R.drawable.ic_access_time_white_24dp);
|
||||
super(context.getString(R.string.history), R.drawable.ic_history);
|
||||
}
|
||||
|
||||
protected HistoryPlaylist(Parcel in) {
|
||||
|
|
|
@ -41,7 +41,7 @@ public class LastAddedPlaylist extends AbsSmartPlaylist {
|
|||
};
|
||||
|
||||
public LastAddedPlaylist(@NonNull Context context) {
|
||||
super(context.getString(R.string.last_added), R.drawable.ic_library_add_white_24dp);
|
||||
super(context.getString(R.string.last_added), R.drawable.ic_library_add);
|
||||
}
|
||||
|
||||
protected LastAddedPlaylist(Parcel in) {
|
||||
|
|
|
@ -44,7 +44,7 @@ public class MyTopTracksPlaylist extends AbsSmartPlaylist {
|
|||
};
|
||||
|
||||
public MyTopTracksPlaylist(@NonNull Context context) {
|
||||
super(context.getString(R.string.my_top_tracks), R.drawable.ic_trending_up_white_24dp);
|
||||
super(context.getString(R.string.my_top_tracks), R.drawable.ic_trending_up);
|
||||
}
|
||||
|
||||
protected MyTopTracksPlaylist(Parcel in) {
|
||||
|
|
|
@ -29,7 +29,7 @@ public class NotRecentlyPlayedPlaylist extends AbsSmartPlaylist {
|
|||
};
|
||||
|
||||
public NotRecentlyPlayedPlaylist(@NonNull Context context) {
|
||||
super(context.getString(R.string.not_recently_played), R.drawable.ic_watch_later_white_24dp);
|
||||
super(context.getString(R.string.not_recently_played), R.drawable.ic_watch_later);
|
||||
}
|
||||
|
||||
protected NotRecentlyPlayedPlaylist(Parcel in) {
|
||||
|
|
|
@ -40,7 +40,7 @@ public class ShuffleAllPlaylist extends AbsSmartPlaylist {
|
|||
};
|
||||
|
||||
public ShuffleAllPlaylist(@NonNull Context context) {
|
||||
super(context.getString(R.string.action_shuffle_all), R.drawable.ic_shuffle_white_24dp);
|
||||
super(context.getString(R.string.action_shuffle_all), R.drawable.ic_shuffle);
|
||||
}
|
||||
|
||||
protected ShuffleAllPlaylist(Parcel in) {
|
||||
|
|
|
@ -1,24 +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 io.github.muntashirakon.music.mvp
|
||||
|
||||
/**
|
||||
* Created by hemanths on 09/08/17.
|
||||
*/
|
||||
|
||||
interface BaseView {
|
||||
|
||||
fun showEmptyView()
|
||||
}
|
|
@ -1,30 +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 io.github.muntashirakon.music.mvp
|
||||
|
||||
import androidx.annotation.CallSuper
|
||||
|
||||
/**
|
||||
* Created by hemanths on 16/08/17.
|
||||
*/
|
||||
|
||||
|
||||
interface Presenter<T> {
|
||||
@CallSuper
|
||||
fun attachView(view: T)
|
||||
|
||||
@CallSuper
|
||||
fun detachView()
|
||||
}
|
|
@ -1,30 +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 io.github.muntashirakon.music.mvp;
|
||||
|
||||
/**
|
||||
* Created by hemanths on 2019-09-04.
|
||||
*/
|
||||
public abstract class PresenterImpl<T> {
|
||||
protected T view;
|
||||
|
||||
public void attachView(T view) {
|
||||
this.view = view;
|
||||
}
|
||||
|
||||
public void detachView() {
|
||||
view = null;
|
||||
}
|
||||
}
|
|
@ -1,35 +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 io.github.muntashirakon.music.mvp.presenter
|
||||
|
||||
import io.github.muntashirakon.music.model.Album
|
||||
import io.github.muntashirakon.music.model.Artist
|
||||
import io.github.muntashirakon.music.rest.model.LastFmAlbum
|
||||
|
||||
/**
|
||||
* Created by hemanths on 20/08/17.
|
||||
*/
|
||||
interface AlbumDetailsView {
|
||||
|
||||
fun album(album: Album)
|
||||
|
||||
fun complete()
|
||||
|
||||
fun loadArtistImage(artist: Artist)
|
||||
|
||||
fun moreAlbums(albums: List<Album>)
|
||||
|
||||
fun aboutAlbum(lastFmAlbum: LastFmAlbum)
|
||||
}
|
|
@ -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 io.github.muntashirakon.music.mvp.presenter
|
||||
|
||||
import io.github.muntashirakon.music.model.Album
|
||||
import io.github.muntashirakon.music.mvp.BaseView
|
||||
|
||||
/**
|
||||
* Created by hemanths on 12/08/17.
|
||||
*/
|
||||
interface AlbumsView : BaseView {
|
||||
|
||||
fun albums(albums: List<Album>)
|
||||
}
|
|
@ -1,31 +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 io.github.muntashirakon.music.mvp.presenter
|
||||
|
||||
import io.github.muntashirakon.music.model.Artist
|
||||
import io.github.muntashirakon.music.mvp.BaseView
|
||||
import io.github.muntashirakon.music.rest.model.LastFmArtist
|
||||
|
||||
/**
|
||||
* Created by hemanths on 20/08/17.
|
||||
*/
|
||||
interface ArtistDetailsView : BaseView {
|
||||
|
||||
fun artist(artist: Artist)
|
||||
|
||||
fun artistInfo(lastFmArtist: LastFmArtist?)
|
||||
|
||||
fun complete()
|
||||
}
|
|
@ -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 io.github.muntashirakon.music.mvp.presenter
|
||||
|
||||
import io.github.muntashirakon.music.model.Song
|
||||
import io.github.muntashirakon.music.mvp.BaseView
|
||||
import io.github.muntashirakon.music.mvp.Presenter
|
||||
import io.github.muntashirakon.music.mvp.PresenterImpl
|
||||
import io.github.muntashirakon.music.providers.interfaces.Repository
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
/**
|
||||
* Created by hemanths on 20/08/17.
|
||||
*/
|
||||
|
||||
interface GenreDetailsView : BaseView {
|
||||
|
||||
fun songs(songs: List<Song>)
|
||||
}
|
||||
|
||||
interface GenreDetailsPresenter : Presenter<GenreDetailsView> {
|
||||
fun loadGenreSongs(genreId: Int)
|
||||
|
||||
class GenreDetailsPresenterImpl constructor(
|
||||
private val repository: Repository
|
||||
) : PresenterImpl<GenreDetailsView>(), GenreDetailsPresenter, CoroutineScope {
|
||||
|
||||
private val job = Job()
|
||||
|
||||
override val coroutineContext: CoroutineContext
|
||||
get() = Dispatchers.IO + job
|
||||
|
||||
override fun detachView() {
|
||||
super.detachView()
|
||||
job.cancel()
|
||||
}
|
||||
|
||||
override fun loadGenreSongs(genreId: Int) {
|
||||
launch {
|
||||
val result = repository.getGenre(genreId)
|
||||
view?.songs(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,62 +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 io.github.muntashirakon.music.mvp.presenter
|
||||
|
||||
import io.github.muntashirakon.music.model.Playlist
|
||||
import io.github.muntashirakon.music.model.Song
|
||||
import io.github.muntashirakon.music.mvp.BaseView
|
||||
import io.github.muntashirakon.music.mvp.Presenter
|
||||
import io.github.muntashirakon.music.mvp.PresenterImpl
|
||||
import io.github.muntashirakon.music.providers.interfaces.Repository
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
/**
|
||||
* Created by hemanths on 20/08/17.
|
||||
*/
|
||||
interface PlaylistSongsView : BaseView {
|
||||
|
||||
fun songs(songs: List<Song>)
|
||||
}
|
||||
|
||||
interface PlaylistSongsPresenter : Presenter<PlaylistSongsView> {
|
||||
fun loadPlaylistSongs(playlist: Playlist)
|
||||
|
||||
class PlaylistSongsPresenterImpl constructor(
|
||||
private val repository: Repository
|
||||
) : PresenterImpl<PlaylistSongsView>(), PlaylistSongsPresenter, CoroutineScope {
|
||||
|
||||
private var job: Job = Job()
|
||||
|
||||
override val coroutineContext: CoroutineContext
|
||||
get() = Dispatchers.IO + job
|
||||
|
||||
override fun loadPlaylistSongs(playlist: Playlist) {
|
||||
launch {
|
||||
val songs = repository.getPlaylistSongs(playlist)
|
||||
view?.songs(songs)
|
||||
}
|
||||
}
|
||||
|
||||
override fun detachView() {
|
||||
super.detachView()
|
||||
job.cancel()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 io.github.muntashirakon.music.mvp.presenter
|
||||
|
||||
import io.github.muntashirakon.music.mvp.BaseView
|
||||
import io.github.muntashirakon.music.mvp.Presenter
|
||||
import io.github.muntashirakon.music.mvp.PresenterImpl
|
||||
import io.github.muntashirakon.music.providers.interfaces.Repository
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
/**
|
||||
* Created by hemanths on 20/08/17.
|
||||
*/
|
||||
|
||||
interface SearchView : BaseView {
|
||||
|
||||
fun showData(data: MutableList<Any>)
|
||||
}
|
||||
|
||||
interface SearchPresenter : Presenter<SearchView> {
|
||||
|
||||
fun search(query: String?)
|
||||
|
||||
class SearchPresenterImpl constructor(
|
||||
private val repository: Repository
|
||||
) : PresenterImpl<SearchView>(), SearchPresenter, CoroutineScope {
|
||||
|
||||
override val coroutineContext: CoroutineContext
|
||||
get() = Dispatchers.IO + job
|
||||
|
||||
private var job: Job = Job()
|
||||
|
||||
override fun detachView() {
|
||||
super.detachView()
|
||||
job.cancel()
|
||||
}
|
||||
|
||||
override fun search(query: String?) {
|
||||
launch {
|
||||
val result = repository.search(query)
|
||||
withContext(Dispatchers.Main) { view?.showData(result) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -12,10 +12,10 @@
|
|||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package io.github.muntashirakon.music.rest.service
|
||||
package io.github.muntashirakon.music.network
|
||||
|
||||
import io.github.muntashirakon.music.rest.model.LastFmAlbum
|
||||
import io.github.muntashirakon.music.rest.model.LastFmArtist
|
||||
import io.github.muntashirakon.music.network.model.LastFmAlbum
|
||||
import io.github.muntashirakon.music.network.model.LastFmArtist
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Header
|
||||
import retrofit2.http.Query
|
|
@ -0,0 +1,71 @@
|
|||
package code.name.monkey.retromusic.network
|
||||
|
||||
import code.name.monkey.retromusic.App
|
||||
import code.name.monkey.retromusic.Constants.BASE_URL
|
||||
import com.google.gson.Gson
|
||||
import okhttp3.Cache
|
||||
import okhttp3.ConnectionPool
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.OkHttpClient
|
||||
import org.koin.dsl.module
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
import java.io.File
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
private const val TIMEOUT: Long = 700
|
||||
|
||||
val networkModule = module {
|
||||
factory {
|
||||
provideHttpClient(get(), get())
|
||||
}
|
||||
factory {
|
||||
provideCacheControlInterceptor()
|
||||
}
|
||||
factory {
|
||||
provideDefaultCache()
|
||||
}
|
||||
factory {
|
||||
provideLastFmService(get())
|
||||
}
|
||||
single {
|
||||
providerRetrofit(get())
|
||||
}
|
||||
}
|
||||
|
||||
fun provideLastFmService(retrofit: Retrofit): LastFMService =
|
||||
retrofit.create(LastFMService::class.java)
|
||||
|
||||
fun providerRetrofit(okHttpClient: OkHttpClient.Builder): Retrofit = Retrofit.Builder()
|
||||
.baseUrl(BASE_URL)
|
||||
.callFactory(okHttpClient.build())
|
||||
.addConverterFactory(GsonConverterFactory.create(Gson()))
|
||||
.build()
|
||||
|
||||
fun provideHttpClient(
|
||||
cache: Cache,
|
||||
interceptor: Interceptor
|
||||
): OkHttpClient.Builder = OkHttpClient.Builder()
|
||||
.connectionPool(ConnectionPool(0, 1, TimeUnit.NANOSECONDS))
|
||||
.retryOnConnectionFailure(true)
|
||||
.connectTimeout(TIMEOUT, TimeUnit.MINUTES)
|
||||
.writeTimeout(TIMEOUT, TimeUnit.MINUTES)
|
||||
.readTimeout(TIMEOUT, TimeUnit.MINUTES)
|
||||
.cache(cache)
|
||||
.addInterceptor(interceptor)
|
||||
|
||||
|
||||
fun provideCacheControlInterceptor(): Interceptor = Interceptor { chain: Interceptor.Chain ->
|
||||
val modifiedRequest = chain.request().newBuilder()
|
||||
.addHeader("Cache-Control", "max-age=31536000, max-stale=31536000")
|
||||
.build()
|
||||
chain.proceed(modifiedRequest)
|
||||
}
|
||||
|
||||
fun provideDefaultCache(): Cache? {
|
||||
val cacheDir = File(App.getContext().cacheDir.absolutePath, "/okhttp-lastfm/")
|
||||
if (cacheDir.mkdirs() || cacheDir.isDirectory) {
|
||||
return Cache(cacheDir, 1024 * 1024 * 10)
|
||||
}
|
||||
return null
|
||||
}
|
|
@ -12,7 +12,7 @@
|
|||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package io.github.muntashirakon.music.rest.model;
|
||||
package io.github.muntashirakon.music.network.model;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
|
@ -12,7 +12,7 @@
|
|||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package io.github.muntashirakon.music.rest.model;
|
||||
package io.github.muntashirakon.music.network.model;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
|
@ -12,7 +12,7 @@
|
|||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package io.github.muntashirakon.music.rest.model;
|
||||
package io.github.muntashirakon.music.network.model;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
|
@ -31,12 +31,13 @@ import androidx.viewpager.widget.PagerAdapter
|
|||
import androidx.viewpager.widget.ViewPager
|
||||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.extensions.colorButtons
|
||||
import io.github.muntashirakon.music.extensions.colorControlNormal
|
||||
import io.github.muntashirakon.music.extensions.materialDialog
|
||||
import io.github.muntashirakon.music.fragments.AlbumCoverStyle.*
|
||||
import io.github.muntashirakon.music.util.PreferenceUtil
|
||||
import io.github.muntashirakon.music.util.ViewUtil
|
||||
import com.bumptech.glide.Glide
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
class AlbumCoverStylePreference @JvmOverloads constructor(
|
||||
context: Context,
|
||||
|
@ -75,15 +76,14 @@ class AlbumCoverStylePreferenceDialog : DialogFragment(),
|
|||
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
|
||||
viewPager.currentItem = PreferenceUtil.albumCoverStyle.ordinal
|
||||
|
||||
return MaterialAlertDialogBuilder(requireActivity(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert)
|
||||
.setTitle(R.string.pref_title_album_cover_style)
|
||||
return materialDialog(R.string.pref_title_album_cover_style)
|
||||
.setPositiveButton(R.string.set) { _, _ ->
|
||||
val coverStyle = values()[viewPagerPosition]
|
||||
PreferenceUtil.albumCoverStyle = coverStyle
|
||||
}
|
||||
.setView(view)
|
||||
.create()
|
||||
.colorButtons()
|
||||
}
|
||||
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
|
|
|
@ -26,7 +26,9 @@ import androidx.fragment.app.FragmentActivity
|
|||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.dialogs.BlacklistFolderChooserDialog
|
||||
import io.github.muntashirakon.music.extensions.colorButtons
|
||||
import io.github.muntashirakon.music.extensions.colorControlNormal
|
||||
import io.github.muntashirakon.music.extensions.materialDialog
|
||||
import io.github.muntashirakon.music.providers.BlacklistStore
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import java.io.File
|
||||
|
@ -65,25 +67,19 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
|||
childFragmentManager.findFragmentByTag("FOLDER_CHOOSER") as BlacklistFolderChooserDialog?
|
||||
chooserDialog?.setCallback(this)
|
||||
refreshBlacklistData()
|
||||
return MaterialAlertDialogBuilder(
|
||||
mActivity!!,
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(R.string.blacklist)
|
||||
return materialDialog(R.string.blacklist)
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
dismiss()
|
||||
}
|
||||
.setNeutralButton(R.string.clear_action) { _, _ ->
|
||||
MaterialAlertDialogBuilder(
|
||||
mActivity!!,
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(R.string.clear_blacklist)
|
||||
materialDialog(R.string.clear_blacklist)
|
||||
.setMessage(R.string.do_you_want_to_clear_the_blacklist)
|
||||
.setPositiveButton(R.string.clear_action) { _, _ ->
|
||||
BlacklistStore.getInstance(mContext!!).clear()
|
||||
}
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create()
|
||||
.colorButtons()
|
||||
.show()
|
||||
}
|
||||
.setNegativeButton(R.string.add_action) { _, _ ->
|
||||
|
@ -92,11 +88,7 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
|||
dialog.show(mActivity!!.supportFragmentManager, "FOLDER_CHOOSER")
|
||||
}
|
||||
.setItems(paths.toTypedArray()) { _, which ->
|
||||
MaterialAlertDialogBuilder(
|
||||
mActivity!!,
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(R.string.remove_from_blacklist)
|
||||
materialDialog(R.string.remove_from_blacklist)
|
||||
.setMessage(
|
||||
HtmlCompat.fromHtml(
|
||||
String.format(
|
||||
|
@ -114,9 +106,9 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
|
|||
refreshBlacklistData()
|
||||
}
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.show()
|
||||
.show().colorButtons()
|
||||
}
|
||||
.create()
|
||||
.create().colorButtons()
|
||||
}
|
||||
|
||||
private lateinit var paths: ArrayList<String>
|
||||
|
|
|
@ -29,11 +29,11 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
|
||||
import io.github.muntashirakon.music.R
|
||||
import io.github.muntashirakon.music.adapter.CategoryInfoAdapter
|
||||
import io.github.muntashirakon.music.extensions.colorButtons
|
||||
import io.github.muntashirakon.music.extensions.colorControlNormal
|
||||
import io.github.muntashirakon.music.extensions.materialDialog
|
||||
import io.github.muntashirakon.music.model.CategoryInfo
|
||||
import io.github.muntashirakon.music.util.PreferenceUtil
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
|
||||
class LibraryPreference @JvmOverloads constructor(
|
||||
context: Context,
|
||||
|
@ -64,11 +64,7 @@ class LibraryPreferenceDialog : DialogFragment() {
|
|||
categoryAdapter.attachToRecyclerView(recyclerView)
|
||||
|
||||
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(R.string.library_categories)
|
||||
return materialDialog(R.string.library_categories)
|
||||
.setNeutralButton(
|
||||
R.string.reset_action
|
||||
) { _, _ ->
|
||||
|
@ -80,6 +76,7 @@ class LibraryPreferenceDialog : DialogFragment() {
|
|||
) { _, _ -> updateCategories(categoryAdapter.categoryInfos) }
|
||||
.setView(view)
|
||||
.create()
|
||||
.colorButtons()
|
||||
}
|
||||
|
||||
private fun updateCategories(categories: List<CategoryInfo>) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue