This commit is contained in:
Muntashir Al-Islam 2020-07-22 02:00:36 +06:00
commit 02a735a9ca
379 changed files with 1592 additions and 2283 deletions

View file

@ -41,15 +41,6 @@ android {
} }
} }
flavorDimensions "default"
productFlavors {
normal {
dimension "default"
}
}
packagingOptions { packagingOptions {
exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE'
@ -87,17 +78,15 @@ dependencies {
implementation "androidx.gridlayout:gridlayout:1.0.0" implementation "androidx.gridlayout:gridlayout:1.0.0"
implementation "androidx.cardview:cardview: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.viewpager2:viewpager2:1.1.0-alpha01"
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.annotation:annotation: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.core:core-ktx:1.3.0'
implementation 'androidx.fragment:fragment-ktx:1.2.5' implementation 'androidx.fragment:fragment-ktx:1.2.5'
implementation 'androidx.palette:palette-ktx:1.0.0' 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 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.3.0-alpha01' 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') { implementation('com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.11.0@aar') {
transitive = true transitive = true
} }
/*UI Library*/ def kotlin_coroutines_version = "1.3.8"
implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" 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-core:$kotlin_coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$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-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
implementation 'me.jorgecastillo:androidcolorx:0.2.0' implementation 'me.jorgecastillo:androidcolorx:0.2.0'
debugImplementation 'com.amitshekhar.android:debug-db:1.0.4' debugImplementation 'com.amitshekhar.android:debug-db:1.0.4'
implementation 'com.github.dhaval2404:imagepicker:1.7.1' 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
View 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"
}
]
}

View file

@ -106,7 +106,7 @@
</activity> </activity>
<activity android:name=".activities.albums.AlbumDetailsActivity" /> <activity android:name=".activities.albums.AlbumDetailsActivity" />
<activity android:name=".activities.artists.ArtistDetailActivity" /> <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.PlayingQueueActivity" />
<activity android:name=".activities.AboutActivity" /> <activity android:name=".activities.AboutActivity" />
<activity android:name=".activities.tageditor.AlbumTagEditorActivity" /> <activity android:name=".activities.tageditor.AlbumTagEditorActivity" />
@ -121,7 +121,7 @@
<activity android:name=".activities.ShareInstagramStory" /> <activity android:name=".activities.ShareInstagramStory" />
<activity android:name=".activities.DriveModeActivity" /> <activity android:name=".activities.DriveModeActivity" />
<activity <activity
android:name=".activities.SearchActivity" android:name=".activities.search.SearchActivity"
android:windowSoftInputMode="stateVisible" /> android:windowSoftInputMode="stateVisible" />
<activity <activity

View file

@ -31,6 +31,7 @@ object Constants {
const val APP_TWITTER_LINK = "https://twitter.com/retromusicapp" const val APP_TWITTER_LINK = "https://twitter.com/retromusicapp"
const val FAQ_LINK = "https://github.com/h4h13/RetroMusicPlayer/blob/master/FAQ.md" const val FAQ_LINK = "https://github.com/h4h13/RetroMusicPlayer/blob/master/FAQ.md"
const val PINTEREST = "https://in.pinterest.com/retromusicapp/" const val PINTEREST = "https://in.pinterest.com/retromusicapp/"
const val BASE_URL = "https://ws.audioscrobbler.com/2.0/"
const val IS_MUSIC = const val IS_MUSIC =
MediaStore.Audio.AudioColumns.IS_MUSIC + "=1" + " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''" MediaStore.Audio.AudioColumns.IS_MUSIC + "=1" + " AND " + MediaStore.Audio.AudioColumns.TITLE + " != ''"

View file

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

View file

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

View file

@ -1,26 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package 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>()
}

View file

@ -88,7 +88,7 @@ class DriveModeActivity : AbsMusicServiceActivity(), Callback {
val isFavourite = val isFavourite =
MusicUtil.isFavorite(this@DriveModeActivity, MusicPlayerRemote.currentSong) MusicUtil.isFavorite(this@DriveModeActivity, MusicPlayerRemote.currentSong)
withContext(Dispatchers.Main) { 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() { private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp) playPauseButton.setImageResource(R.drawable.ic_pause)
} else { } 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() { private fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }

View file

@ -12,7 +12,6 @@ import android.view.View
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.commit import androidx.fragment.app.commit
import androidx.lifecycle.ViewModelProvider
import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor import code.name.monkey.appthemehelper.util.ATHUtil.resolveColor
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import io.github.muntashirakon.music.R import io.github.muntashirakon.music.R
@ -51,6 +50,7 @@ import com.afollestad.materialcab.MaterialCab
import com.google.android.material.appbar.AppBarLayout import com.google.android.material.appbar.AppBarLayout
import io.github.muntashirakon.music.* import io.github.muntashirakon.music.*
import kotlinx.android.synthetic.main.activity_main_content.* import kotlinx.android.synthetic.main.activity_main_content.*
import org.koin.android.ext.android.inject
import java.util.* import java.util.*
class MainActivity : AbsSlidingMusicPanelActivity(), class MainActivity : AbsSlidingMusicPanelActivity(),
@ -60,7 +60,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
const val EXPAND_PANEL = "expand_panel" const val EXPAND_PANEL = "expand_panel"
} }
lateinit var libraryViewModel: LibraryViewModel val libraryViewModel: LibraryViewModel by inject()
private var cab: MaterialCab? = null private var cab: MaterialCab? = null
private val intentFilter = IntentFilter(Intent.ACTION_SCREEN_OFF) private val intentFilter = IntentFilter(Intent.ACTION_SCREEN_OFF)
private lateinit var currentFragment: MainActivityFragmentCallbacks private lateinit var currentFragment: MainActivityFragmentCallbacks
@ -93,9 +93,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
hideStatusBar() hideStatusBar()
setBottomBarVisibility(View.VISIBLE) setBottomBarVisibility(View.VISIBLE)
libraryViewModel = ViewModelProvider(this).get(LibraryViewModel::class.java)
addMusicServiceEventListener(libraryViewModel) addMusicServiceEventListener(libraryViewModel)
if (savedInstanceState == null) { if (savedInstanceState == null) {
selectedFragment(PreferenceUtil.lastPage) selectedFragment(PreferenceUtil.lastPage)
} else { } else {
@ -142,20 +140,20 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
menu ?: return super.onCreateOptionsMenu(menu) menu ?: return super.onCreateOptionsMenu(menu)
if (isPlaylistPage()) { if (isPlaylistPage()) {
menu.add(0, R.id.action_new_playlist, 1, R.string.new_playlist_title) 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) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM)
} }
if (isHomePage()) { if (isHomePage()) {
menu.add(0, R.id.action_mic, 1, getString(R.string.action_search)) 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) .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM)
} }
if (isFolderPage()) { if (isFolderPage()) {
menu.add(0, R.id.action_scan, 0, R.string.scan_media) 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) .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) 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) .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM)
} }
val fragment: Fragment? = getCurrentFragment() val fragment: Fragment? = getCurrentFragment()
@ -173,10 +171,10 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
menu.removeItem(R.id.action_sort_order) menu.removeItem(R.id.action_sort_order)
} }
menu.add(0, R.id.action_settings, 6, getString(R.string.action_settings)) 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) .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM)
menu.add(0, R.id.action_search, 0, getString(R.string.action_search)) 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) .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS)
ToolbarContentTintHelper.handleOnCreateOptionsMenu( ToolbarContentTintHelper.handleOnCreateOptionsMenu(
this, this,
@ -534,6 +532,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
fragment: Fragment, fragment: Fragment,
tag: String tag: String
) { ) {
supportFragmentManager.commit { supportFragmentManager.commit {
replace(R.id.fragment_container, fragment, tag) replace(R.id.fragment_container, fragment, tag)
} }
@ -682,7 +681,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
} }
cab = MaterialCab(this, R.id.cab_stub) cab = MaterialCab(this, R.id.cab_stub)
.setMenu(menuRes) .setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp) .setCloseDrawableRes(R.drawable.ic_close)
.setBackgroundColor( .setBackgroundColor(
RetroColorUtil.shiftBackgroundColorForLightText( RetroColorUtil.shiftBackgroundColorForLightText(
resolveColor( resolveColor(

View file

@ -10,13 +10,13 @@ import android.view.SubMenu
import android.view.View import android.view.View
import android.widget.ImageView import android.widget.ImageView
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.MaterialUtil import code.name.monkey.appthemehelper.util.MaterialUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper 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.base.AbsSlidingMusicPanelActivity
import io.github.muntashirakon.music.activities.tageditor.AbsTagEditorActivity import io.github.muntashirakon.music.activities.tageditor.AbsTagEditorActivity
import io.github.muntashirakon.music.activities.tageditor.AlbumTagEditorActivity 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.interfaces.CabHolder
import io.github.muntashirakon.music.model.Album import io.github.muntashirakon.music.model.Album
import io.github.muntashirakon.music.model.Artist import io.github.muntashirakon.music.model.Artist
import io.github.muntashirakon.music.mvp.presenter.AlbumDetailsView import io.github.muntashirakon.music.network.model.LastFmAlbum
import io.github.muntashirakon.music.rest.model.LastFmAlbum
import io.github.muntashirakon.music.util.* import io.github.muntashirakon.music.util.*
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import com.afollestad.materialcab.MaterialCab import com.afollestad.materialcab.MaterialCab
import com.bumptech.glide.Glide 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.*
import kotlinx.android.synthetic.main.activity_album_content.* 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 java.util.*
import android.util.Pair as UtilPair import android.util.Pair as UtilPair
class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, CabHolder { class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder {
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab { override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
cab?.let { cab?.let {
if (it.isActive) it.finish() if (it.isActive) it.finish()
} }
cab = MaterialCab(this, R.id.cab_stub) cab = MaterialCab(this, R.id.cab_stub)
.setMenu(menuRes) .setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp) .setCloseDrawableRes(R.drawable.ic_close)
.setBackgroundColor( .setBackgroundColor(
RetroColorUtil.shiftBackgroundColorForLightText( RetroColorUtil.shiftBackgroundColorForLightText(
ATHUtil.resolveColor( ATHUtil.resolveColor(
@ -68,7 +68,9 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
return cab as MaterialCab 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 simpleSongAdapter: SimpleSongAdapter
private lateinit var album: Album private lateinit var album: Album
private lateinit var artistImage: ImageView private lateinit var artistImage: ImageView
@ -100,19 +102,19 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
window.sharedElementsUseOverlay = true window.sharedElementsUseOverlay = true
windowEnterTransition() windowEnterTransition()
val albumId = extraNotNull<Int>(EXTRA_ALBUM_ID).value addMusicServiceEventListener(detailsViewModel)
ActivityCompat.postponeEnterTransition(this) ActivityCompat.postponeEnterTransition(this)
val viewModelFactory = AlbumDetailsViewModelFactory(application, albumId) //val viewModelFactory = AlbumDetailsViewModelFactory(application, albumId)
viewModel = ViewModelProvider(this, viewModelFactory).get(AlbumDetailsViewModel::class.java) //viewModel = ViewModelProvider(this, viewModelFactory).get(AlbumDetailsViewModel::class.java)
addMusicServiceEventListener(viewModel)
viewModel.getAlbum().observe(this, androidx.lifecycle.Observer { detailsViewModel.getAlbum().observe(this, androidx.lifecycle.Observer {
ActivityCompat.startPostponedEnterTransition(this@AlbumDetailsActivity) ActivityCompat.startPostponedEnterTransition(this@AlbumDetailsActivity)
album(it) album(it)
}) })
viewModel.getArtist().observe(this, androidx.lifecycle.Observer { detailsViewModel.getArtist().observe(this, androidx.lifecycle.Observer {
loadArtistImage(it) loadArtistImage(it)
}) })
viewModel.getAlbumInfo().observe(this, androidx.lifecycle.Observer { detailsViewModel.getAlbumInfo().observe(this, androidx.lifecycle.Observer {
aboutAlbum(it) aboutAlbum(it)
}) })
setupRecyclerView() setupRecyclerView()
@ -153,11 +155,11 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
} }
} }
override fun complete() { fun complete() {
ActivityCompat.startPostponedEnterTransition(this) ActivityCompat.startPostponedEnterTransition(this)
} }
override fun album(album: Album) { fun album(album: Album) {
complete() complete()
if (album.songs!!.isEmpty()) { if (album.songs!!.isEmpty()) {
finish() finish()
@ -190,11 +192,11 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
} }
loadAlbumCover() loadAlbumCover()
simpleSongAdapter.swapDataSet(album.songs) simpleSongAdapter.swapDataSet(album.songs)
viewModel.loadArtist(album.artistId) detailsViewModel.loadArtist(album.artistId)
viewModel.loadAlbumInfo(album) detailsViewModel.loadAlbumInfo(album)
} }
override fun moreAlbums(albums: List<Album>) { fun moreAlbums(albums: List<Album>) {
moreTitle.show() moreTitle.show()
moreRecyclerView.show() moreRecyclerView.show()
moreTitle.text = String.format(getString(R.string.label_more_from), album.artistName) moreTitle.text = String.format(getString(R.string.label_more_from), album.artistName)
@ -209,7 +211,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
moreRecyclerView.adapter = albumAdapter moreRecyclerView.adapter = albumAdapter
} }
override fun aboutAlbum(lastFmAlbum: LastFmAlbum) { fun aboutAlbum(lastFmAlbum: LastFmAlbum) {
if (lastFmAlbum.album != null) { if (lastFmAlbum.album != null) {
if (lastFmAlbum.album.wiki != null) { if (lastFmAlbum.album.wiki != null) {
aboutAlbumText.show() 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) ArtistGlideRequest.Builder.from(Glide.with(this), artist)
.generatePalette(this) .generatePalette(this)
.build() .build()
@ -391,8 +393,9 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, C
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
removeMusicServiceEventListener(viewModel) removeMusicServiceEventListener(detailsViewModel)
} }
companion object { companion object {
const val EXTRA_ALBUM_ID = "extra_album_id" const val EXTRA_ALBUM_ID = "extra_album_id"

View file

@ -1,25 +1,24 @@
package io.github.muntashirakon.music.activities.albums package io.github.muntashirakon.music.activities.albums
import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import io.github.muntashirakon.music.interfaces.MusicServiceEventListener import io.github.muntashirakon.music.interfaces.MusicServiceEventListener
import io.github.muntashirakon.music.model.Album import io.github.muntashirakon.music.model.Album
import io.github.muntashirakon.music.model.Artist import io.github.muntashirakon.music.model.Artist
import io.github.muntashirakon.music.providers.RepositoryImpl 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.Deferred
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
class AlbumDetailsViewModel( class AlbumDetailsViewModel(
application: Application, private val repository: RepositoryImpl,
private val albumId: Int private val albumId: Int
) : AndroidViewModel(application), MusicServiceEventListener { ) : ViewModel(), MusicServiceEventListener {
private val _repository = RepositoryImpl(application.applicationContext)
private val _album = MutableLiveData<Album>() private val _album = MutableLiveData<Album>()
private val _artist = MutableLiveData<Artist>() private val _artist = MutableLiveData<Artist>()
private val _lastFmAlbum = MutableLiveData<LastFmAlbum>() private val _lastFmAlbum = MutableLiveData<LastFmAlbum>()
@ -38,20 +37,18 @@ class AlbumDetailsViewModel(
} }
fun loadAlbumInfo(album: Album) = viewModelScope.launch(Dispatchers.IO) { fun loadAlbumInfo(album: Album) = viewModelScope.launch(Dispatchers.IO) {
try { val lastFmAlbum = repository.albumInfo(album.artistName ?: "-", album.title ?: "-")
val lastFmAlbum = _repository.albumInfo(album.artistName ?: "-", album.title ?: "-") _lastFmAlbum.postValue(lastFmAlbum)
_lastFmAlbum.postValue(lastFmAlbum)
} catch (ignored: Exception) {}
} }
fun loadArtist(artistId: Int) = viewModelScope.launch(Dispatchers.IO) { fun loadArtist(artistId: Int) = viewModelScope.launch(Dispatchers.IO) {
val artist = _repository.artistById(artistId) val artist = repository.artistById(artistId)
_artist.postValue(artist) _artist.postValue(artist)
} }
private val loadAlbumAsync: Deferred<Album?> private val loadAlbumAsync: Deferred<Album?>
get() = viewModelScope.async(Dispatchers.IO) { get() = viewModelScope.async(Dispatchers.IO) {
_repository.albumById(albumId) repository.albumById(albumId)
} }
override fun onMediaStoreChanged() { override fun onMediaStoreChanged() {

View file

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

View file

@ -11,12 +11,12 @@ import android.view.View
import android.widget.Toast import android.widget.Toast
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.text.HtmlCompat import androidx.core.text.HtmlCompat
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.MaterialUtil 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.activities.base.AbsSlidingMusicPanelActivity
import io.github.muntashirakon.music.adapter.album.HorizontalAlbumAdapter import io.github.muntashirakon.music.adapter.album.HorizontalAlbumAdapter
import io.github.muntashirakon.music.adapter.song.SimpleSongAdapter 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.helper.MusicPlayerRemote
import io.github.muntashirakon.music.interfaces.CabHolder import io.github.muntashirakon.music.interfaces.CabHolder
import io.github.muntashirakon.music.model.Artist import io.github.muntashirakon.music.model.Artist
import io.github.muntashirakon.music.mvp.presenter.ArtistDetailsView import io.github.muntashirakon.music.network.model.LastFmArtist
import io.github.muntashirakon.music.rest.model.LastFmArtist
import io.github.muntashirakon.music.util.* import io.github.muntashirakon.music.util.*
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import com.afollestad.materialcab.MaterialCab import com.afollestad.materialcab.MaterialCab
import com.bumptech.glide.Glide 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_content.*
import kotlinx.android.synthetic.main.activity_artist_details.* 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 java.util.*
import kotlin.collections.ArrayList import kotlin.collections.ArrayList
class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView, CabHolder { class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder {
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab { override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
cab?.let { cab?.let {
if (it.isActive) it.finish() if (it.isActive) it.finish()
} }
cab = MaterialCab(this, R.id.cab_stub) cab = MaterialCab(this, R.id.cab_stub)
.setMenu(menuRes) .setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp) .setCloseDrawableRes(R.drawable.ic_close)
.setBackgroundColor( .setBackgroundColor(
RetroColorUtil.shiftBackgroundColorForLightText( RetroColorUtil.shiftBackgroundColorForLightText(
ATHUtil.resolveColor( ATHUtil.resolveColor(
@ -68,7 +68,9 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
private lateinit var songAdapter: SimpleSongAdapter private lateinit var songAdapter: SimpleSongAdapter
private lateinit var albumAdapter: HorizontalAlbumAdapter private lateinit var albumAdapter: HorizontalAlbumAdapter
private var forceDownload: Boolean = false 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 { override fun createContentView(): View {
return wrapSlidingMusicPanel(R.layout.activity_artist_details) return wrapSlidingMusicPanel(R.layout.activity_artist_details)
@ -93,23 +95,16 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
setBottomBarVisibility(View.GONE) setBottomBarVisibility(View.GONE)
window.sharedElementsUseOverlay = true window.sharedElementsUseOverlay = true
windowEnterTransition() windowEnterTransition()
ActivityCompat.postponeEnterTransition(this)
val artistId = extraNotNull<Int>(EXTRA_ARTIST_ID).value addMusicServiceEventListener(detailsViewModel)
val viewModelFactory = ArtistDetailsViewModelFactory(application, artistId) detailsViewModel.getArtist().observe(this, androidx.lifecycle.Observer {
viewModel =
ViewModelProvider(this, viewModelFactory).get(ArtistDetailsViewModel::class.java)
addMusicServiceEventListener(viewModel)
viewModel.getArtist().observe(this, androidx.lifecycle.Observer {
ActivityCompat.startPostponedEnterTransition(this@ArtistDetailActivity) ActivityCompat.startPostponedEnterTransition(this@ArtistDetailActivity)
artist(it) artist(it)
}) })
viewModel.getArtistInfo().observe(this, androidx.lifecycle.Observer { detailsViewModel.getArtistInfo().observe(this, androidx.lifecycle.Observer {
artistInfo(it) artistInfo(it)
}) })
ActivityCompat.postponeEnterTransition(this)
setupRecyclerView() setupRecyclerView()
playAction.apply { playAction.apply {
setOnClickListener { MusicPlayerRemote.openQueue(artist.songs, 0, true) } setOnClickListener { MusicPlayerRemote.openQueue(artist.songs, 0, true) }
} }
@ -155,14 +150,11 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
} }
} }
override fun showEmptyView() { fun complete() {
}
override fun complete() {
ActivityCompat.startPostponedEnterTransition(this) ActivityCompat.startPostponedEnterTransition(this)
} }
override fun artist(artist: Artist) { fun artist(artist: Artist) {
complete() complete()
if (artist.songCount <= 0) { if (artist.songCount <= 0) {
finish() finish()
@ -203,10 +195,10 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
) { ) {
biography = null biography = null
this.lang = lang 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) { if (lastFmArtist != null && lastFmArtist.artist != null) {
val bioContent = lastFmArtist.artist.bio.content val bioContent = lastFmArtist.artist.bio.content
if (bioContent != null && bioContent.trim { it <= ' ' }.isNotEmpty()) { if (bioContent != null && bioContent.trim { it <= ' ' }.isNotEmpty()) {
@ -323,7 +315,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView,
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()
removeMusicServiceEventListener(viewModel) removeMusicServiceEventListener(detailsViewModel)
} }
companion object { companion object {

View file

@ -1,29 +1,28 @@
package io.github.muntashirakon.music.activities.artists package io.github.muntashirakon.music.activities.artists
import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import io.github.muntashirakon.music.interfaces.MusicServiceEventListener import io.github.muntashirakon.music.interfaces.MusicServiceEventListener
import io.github.muntashirakon.music.model.Artist import io.github.muntashirakon.music.model.Artist
import io.github.muntashirakon.music.providers.RepositoryImpl 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.Deferred
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
class ArtistDetailsViewModel( class ArtistDetailsViewModel(
application: Application, private val repository: RepositoryImpl,
private val artistId: Int private val artistId: Int
) : AndroidViewModel(application), MusicServiceEventListener { ) : ViewModel(), MusicServiceEventListener {
private val loadArtistDetailsAsync: Deferred<Artist?> private val loadArtistDetailsAsync: Deferred<Artist?>
get() = viewModelScope.async(Dispatchers.IO) { get() = viewModelScope.async(Dispatchers.IO) {
_repository.artistById(artistId) repository.artistById(artistId)
} }
private val _repository = RepositoryImpl(application.applicationContext)
private val _artist = MutableLiveData<Artist>() private val _artist = MutableLiveData<Artist>()
private val _lastFmArtist = MutableLiveData<LastFmArtist>() private val _lastFmArtist = MutableLiveData<LastFmArtist>()
@ -41,7 +40,7 @@ class ArtistDetailsViewModel(
} }
fun loadBiography(name: String, lang: String?, cache: String?) = viewModelScope.launch { 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) _lastFmArtist.postValue(info)
} }

View file

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

View file

@ -94,7 +94,7 @@ open class BugReportActivity : AbsThemeActivity() {
sendFab.hide(object : FloatingActionButton.OnVisibilityChangedListener() { sendFab.hide(object : FloatingActionButton.OnVisibilityChangedListener() {
override fun onHidden(fab: FloatingActionButton?) { override fun onHidden(fab: FloatingActionButton?) {
super.onHidden(fab) super.onHidden(fab)
sendFab.setImageResource(R.drawable.ic_send_white_24dp) sendFab.setImageResource(R.drawable.ic_send)
sendFab.show() sendFab.show()
} }
}) })
@ -110,7 +110,7 @@ open class BugReportActivity : AbsThemeActivity() {
sendFab.hide(object : FloatingActionButton.OnVisibilityChangedListener() { sendFab.hide(object : FloatingActionButton.OnVisibilityChangedListener() {
override fun onHidden(fab: FloatingActionButton?) { override fun onHidden(fab: FloatingActionButton?) {
super.onHidden(fab) super.onHidden(fab)
sendFab.setImageResource(R.drawable.ic_open_in_browser_white_24dp) sendFab.setImageResource(R.drawable.ic_open_in_browser)
sendFab.show() sendFab.show()
} }
}) })

View file

@ -1,4 +1,4 @@
package io.github.muntashirakon.music.activities package io.github.muntashirakon.music.activities.genre
import android.os.Bundle import android.os.Bundle
import android.view.Menu 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.interfaces.CabHolder
import io.github.muntashirakon.music.model.Genre import io.github.muntashirakon.music.model.Genre
import io.github.muntashirakon.music.model.Song 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.DensityUtil
import io.github.muntashirakon.music.util.RetroColorUtil import io.github.muntashirakon.music.util.RetroColorUtil
import com.afollestad.materialcab.MaterialCab import com.afollestad.materialcab.MaterialCab
import kotlinx.android.synthetic.main.activity_playlist_detail.* 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.* import java.util.*
/** /**
* @author Hemanth S (h4h13). * @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 genre: Genre
private lateinit var songAdapter: ShuffleButtonSongAdapter private lateinit var songAdapter: ShuffleButtonSongAdapter
private var cab: MaterialCab? = null private var cab: MaterialCab? = null
@ -62,38 +63,25 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet
setTaskDescriptionColorAuto() setTaskDescriptionColorAuto()
setLightNavigationBar(true) setLightNavigationBar(true)
setBottomBarVisibility(View.GONE) setBottomBarVisibility(View.GONE)
applyToolbar(toolbar)
genre = extraNotNull<Genre>(EXTRA_GENRE_ID).value
setUpToolBar()
setupRecyclerView() setupRecyclerView()
genreDetailsPresenter = detailsViewModel.getSongs().observe(this, androidx.lifecycle.Observer {
GenreDetailsPresenterImpl(RepositoryImpl(this)) songs(it)
genreDetailsPresenter.attachView(this) })
}
private fun setUpToolBar() { detailsViewModel.getGenre().observe(this, androidx.lifecycle.Observer {
applyToolbar(toolbar) genre = it
title = genre.name supportActionBar?.title = it.name
} })
override fun onResume() { addMusicServiceEventListener(detailsViewModel)
super.onResume()
genreDetailsPresenter.loadGenreSongs(genre.id)
}
override fun onDestroy() {
super.onDestroy()
genreDetailsPresenter.detachView()
} }
override fun createContentView(): View { override fun createContentView(): View {
return wrapSlidingMusicPanel(R.layout.activity_playlist_detail) return wrapSlidingMusicPanel(R.layout.activity_playlist_detail)
} }
override fun showEmptyView() {
}
override fun onCreateOptionsMenu(menu: Menu): Boolean { override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_genre_detail, menu) 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) songAdapter.swapDataSet(songs)
} }
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab { override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
if (cab != null && cab!!.isActive) cab?.finish() if (cab != null && cab!!.isActive) cab?.finish()
cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes) cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp) .setCloseDrawableRes(R.drawable.ic_close)
.setBackgroundColor( .setBackgroundColor(
RetroColorUtil.shiftBackgroundColorForLightText( RetroColorUtil.shiftBackgroundColorForLightText(
ATHUtil.resolveColor( ATHUtil.resolveColor(
@ -149,11 +137,6 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet
} }
} }
override fun onMediaStoreChanged() {
super.onMediaStoreChanged()
genreDetailsPresenter.loadGenreSongs(genre.id)
}
companion object { companion object {
const val EXTRA_GENRE_ID = "extra_genre_id" const val EXTRA_GENRE_ID = "extra_genre_id"
} }

View file

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

View file

@ -1,12 +1,14 @@
package io.github.muntashirakon.music.activities package io.github.muntashirakon.music.activities.playlist
import android.os.Bundle import android.os.Bundle
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ATHUtil
import io.github.muntashirakon.music.R import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.activities.base.AbsSlidingMusicPanelActivity import io.github.muntashirakon.music.activities.base.AbsSlidingMusicPanelActivity
import io.github.muntashirakon.music.adapter.song.OrderablePlaylistSongAdapter 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.extensions.extraNotNull
import io.github.muntashirakon.music.helper.menu.PlaylistMenuHelper import io.github.muntashirakon.music.helper.menu.PlaylistMenuHelper
import io.github.muntashirakon.music.interfaces.CabHolder 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.AbsCustomPlaylist
import io.github.muntashirakon.music.model.Playlist import io.github.muntashirakon.music.model.Playlist
import io.github.muntashirakon.music.model.Song 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.DensityUtil
import io.github.muntashirakon.music.util.PlaylistsUtil import io.github.muntashirakon.music.util.PlaylistsUtil
import io.github.muntashirakon.music.util.RetroColorUtil 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.draggable.RecyclerViewDragDropManager
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils
import kotlinx.android.synthetic.main.activity_playlist_detail.* import kotlinx.android.synthetic.main.activity_playlist_detail.*
import org.koin.android.viewmodel.ext.android.viewModel
class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, PlaylistSongsView { 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 lateinit var playlist: Playlist
private var cab: MaterialCab? = null private var cab: MaterialCab? = null
private lateinit var adapter: SongAdapter private lateinit var adapter: SongAdapter
@ -52,13 +54,20 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
setLightNavigationBar(true) setLightNavigationBar(true)
setBottomBarVisibility(View.GONE) setBottomBarVisibility(View.GONE)
presenter = PlaylistSongsPresenterImpl(RepositoryImpl(this))
presenter.attachView(this)
playlist = extraNotNull<Playlist>(EXTRA_PLAYLIST).value playlist = extraNotNull<Playlist>(EXTRA_PLAYLIST).value
setUpToolBar() setUpToolBar()
setUpRecyclerView() 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 { override fun createContentView(): View {
@ -66,7 +75,6 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
} }
private fun setUpRecyclerView() { private fun setUpRecyclerView() {
recyclerView.layoutManager = LinearLayoutManager(this) recyclerView.layoutManager = LinearLayoutManager(this)
if (playlist is AbsCustomPlaylist) { if (playlist is AbsCustomPlaylist) {
adapter = PlaylistSongAdapter(this, ArrayList(), R.layout.item_list, this) 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() { private fun setUpToolBar() {
applyToolbar(toolbar) applyToolbar(toolbar)
title = playlist.name title = playlist.name
@ -141,7 +144,7 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
cab!!.finish() cab!!.finish()
} }
cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes) cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp) .setCloseDrawableRes(R.drawable.ic_close)
.setBackgroundColor( .setBackgroundColor(
RetroColorUtil.shiftBackgroundColorForLightText( RetroColorUtil.shiftBackgroundColorForLightText(
ATHUtil.resolveColor( 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() { private fun checkForPadding() {
val height = DensityUtil.dip2px(this, 52f) val height = DensityUtil.dip2px(this, 52f)
recyclerView.setPadding(0, 0, 0, (height)) recyclerView.setPadding(0, 0, 0, (height))
@ -223,19 +204,22 @@ class PlaylistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder, Playli
wrappedAdapter = null wrappedAdapter = null
} }
super.onDestroy() super.onDestroy()
presenter.detachView()
} }
override fun showEmptyView() { fun showEmptyView() {
empty.visibility = View.VISIBLE empty.visibility = View.VISIBLE
emptyText.visibility = View.VISIBLE emptyText.visibility = View.VISIBLE
} }
override fun songs(songs: List<Song>) { fun songs(songs: List<Song>) {
adapter.swapDataSet(songs) if (songs.isNotEmpty()) {
adapter.swapDataSet(songs)
} else {
showEmptyView()
}
} }
companion object { companion object {
var EXTRA_PLAYLIST = "extra_playlist" var EXTRA_PLAYLIST = "extra_playlist"
} }
} }

View file

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

View file

@ -1,4 +1,4 @@
package io.github.muntashirakon.music.activities package io.github.muntashirakon.music.activities.search
import android.app.Activity import android.app.Activity
import android.app.Service 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.R
import io.github.muntashirakon.music.activities.base.AbsMusicServiceActivity import io.github.muntashirakon.music.activities.base.AbsMusicServiceActivity
import io.github.muntashirakon.music.adapter.SearchAdapter import io.github.muntashirakon.music.adapter.SearchAdapter
import io.github.muntashirakon.music.mvp.presenter.SearchPresenter import io.github.muntashirakon.music.extensions.extra
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.util.RetroUtil import io.github.muntashirakon.music.util.RetroUtil
import com.google.android.material.textfield.TextInputEditText import com.google.android.material.textfield.TextInputEditText
import kotlinx.android.synthetic.main.activity_search.* import kotlinx.android.synthetic.main.activity_search.*
import org.koin.android.ext.android.inject
import java.util.* import java.util.*
import kotlin.collections.ArrayList 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 searchAdapter: SearchAdapter? = null
private var query: String? = null private var query: String? = null
@ -49,14 +47,11 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
setTaskDescriptionColorAuto() setTaskDescriptionColorAuto()
setLightNavigationBar(true) setLightNavigationBar(true)
presenter = SearchPresenterImpl(RepositoryImpl(this))
presenter.attachView(this)
setupRecyclerView() setupRecyclerView()
setUpToolBar() setUpToolBar()
setupSearchView() setupSearchView()
if (intent.getBooleanExtra(EXTRA_SHOW_MIC, false)) { if (extra<Boolean>(EXTRA_SHOW_MIC).value == true) {
startMicSearch() startMicSearch()
} }
@ -84,6 +79,10 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
if (savedInstanceState != null) { if (savedInstanceState != null) {
query = savedInstanceState.getString(QUERY) query = savedInstanceState.getString(QUERY)
} }
viewModel.getSearchResult().observe(this, androidx.lifecycle.Observer {
showData(it)
})
} }
private fun setupRecyclerView() { private fun setupRecyclerView() {
@ -114,11 +113,6 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
searchView.addTextChangedListener(this) searchView.addTextChangedListener(this)
} }
override fun onDestroy() {
super.onDestroy()
presenter.detachView()
}
override fun onSaveInstanceState(outState: Bundle) { override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState) super.onSaveInstanceState(outState)
outState.putString(QUERY, query) outState.putString(QUERY, query)
@ -133,7 +127,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
TransitionManager.beginDelayedTransition(appBarLayout) TransitionManager.beginDelayedTransition(appBarLayout)
voiceSearch.visibility = if (query.isNotEmpty()) View.GONE else View.VISIBLE voiceSearch.visibility = if (query.isNotEmpty()) View.GONE else View.VISIBLE
clearText.visibility = if (query.isNotEmpty()) View.VISIBLE else View.GONE clearText.visibility = if (query.isNotEmpty()) View.VISIBLE else View.GONE
presenter.search(query) viewModel.search(query)
} }
override fun onMediaStoreChanged() { override fun onMediaStoreChanged() {
@ -158,12 +152,16 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
} }
} }
override fun showEmptyView() { private fun showEmptyView() {
searchAdapter?.swapDataSet(ArrayList()) searchAdapter?.swapDataSet(ArrayList())
} }
override fun showData(data: MutableList<Any>) { private fun showData(data: MutableList<Any>) {
searchAdapter?.swapDataSet(data) if (data.isNotEmpty()) {
searchAdapter?.swapDataSet(data)
} else {
showEmptyView()
}
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
@ -175,7 +173,7 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS) data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS)
query = result?.get(0) query = result?.get(0)
searchView.setText(query, BufferType.EDITABLE) 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_LANGUAGE, Locale.getDefault())
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, getString(R.string.speech_prompt)) intent.putExtra(RecognizerIntent.EXTRA_PROMPT, getString(R.string.speech_prompt))
try { try {
startActivityForResult(intent, REQ_CODE_SPEECH_INPUT) startActivityForResult(
intent,
REQ_CODE_SPEECH_INPUT
)
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
e.printStackTrace() e.printStackTrace()
Toast.makeText(this, getString(R.string.speech_not_supported), Toast.LENGTH_SHORT) Toast.makeText(this, getString(R.string.speech_not_supported), Toast.LENGTH_SHORT)

View file

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

View file

@ -34,8 +34,7 @@ import io.github.muntashirakon.music.misc.UpdateToastMediaScannerCompletionListe
import io.github.muntashirakon.music.util.MusicUtil; import io.github.muntashirakon.music.util.MusicUtil;
import io.github.muntashirakon.music.util.SAFUtil; import io.github.muntashirakon.music.util.SAFUtil;
public class WriteTagsAsyncTask extends public class WriteTagsAsyncTask extends DialogAsyncTask<WriteTagsAsyncTask.LoadingInfo, Integer, String[]> {
DialogAsyncTask<WriteTagsAsyncTask.LoadingInfo, Integer, String[]> {
private WeakReference<Activity> activity; private WeakReference<Activity> activity;

View file

@ -69,8 +69,8 @@ class ContributorAdapter(
text.text = contributor.summary text.text = contributor.summary
Glide.with(image.context) Glide.with(image.context)
.load(contributor.profileImage) .load(contributor.profileImage)
.error(R.drawable.ic_account_white_24dp) .error(R.drawable.ic_account)
.placeholder(R.drawable.ic_account_white_24dp) .placeholder(R.drawable.ic_account)
.dontAnimate() .dontAnimate()
.into(image) .into(image)
} }

View file

@ -11,9 +11,12 @@ import androidx.appcompat.widget.AppCompatTextView
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.HORIZONTAL
import code.name.monkey.appthemehelper.ThemeStore 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.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.artist.ArtistAdapter
import io.github.muntashirakon.music.adapter.song.SongAdapter import io.github.muntashirakon.music.adapter.song.SongAdapter
import io.github.muntashirakon.music.extensions.show 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.model.Playlist
import io.github.muntashirakon.music.util.PreferenceUtil import io.github.muntashirakon.music.util.PreferenceUtil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.google.android.material.card.MaterialCardView
class HomeAdapter( class HomeAdapter(
private val activity: AppCompatActivity, private val activity: AppCompatActivity,
@ -41,8 +45,14 @@ class HomeAdapter(
.inflate(R.layout.section_recycler_view, parent, false) .inflate(R.layout.section_recycler_view, parent, false)
return when (viewType) { return when (viewType) {
RECENT_ARTISTS, TOP_ARTISTS -> ArtistViewHolder(layout) RECENT_ARTISTS, TOP_ARTISTS -> ArtistViewHolder(layout)
PLAYLISTS -> PlaylistViewHolder(layout) TOP_ALBUMS, RECENT_ALBUMS -> {
SUGGESTIONS -> { AlbumViewHolder(
LayoutInflater.from(activity)
.inflate(R.layout.metal_section_recycler_view, parent, false)
)
}
FAVOURITES -> PlaylistViewHolder(layout)
else -> {
SuggestionsViewHolder( SuggestionsViewHolder(
LayoutInflater.from(activity).inflate( LayoutInflater.from(activity).inflate(
R.layout.item_suggestions, 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 val viewHolder = holder as ArtistViewHolder
viewHolder.bindView(list[position].arrayList as List<Artist>, R.string.top_artists) 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 -> { SUGGESTIONS -> {
val viewHolder = holder as SuggestionsViewHolder val viewHolder = holder as SuggestionsViewHolder
viewHolder.bindView( viewHolder.bindView(
list[position].arrayList as List<Song> 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 { 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) @Retention(AnnotationRetention.SOURCE)
annotation class HomeSection annotation class HomeSection
@ -125,8 +126,8 @@ class HomeAdapter(
const val TOP_ALBUMS = 1 const val TOP_ALBUMS = 1
const val RECENT_ARTISTS = 2 const val RECENT_ARTISTS = 2
const val TOP_ARTISTS = 0 const val TOP_ARTISTS = 0
const val SUGGESTIONS = 4 const val SUGGESTIONS = 5
const val PLAYLISTS = 5 const val FAVOURITES = 4
} }
private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view) { private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view) {
@ -134,7 +135,9 @@ class HomeAdapter(
if (list.isNotEmpty()) { if (list.isNotEmpty()) {
recyclerView.apply { recyclerView.apply {
show() 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) title.text = activity.getString(titleRes)
} }
@ -176,17 +179,20 @@ class HomeAdapter(
fun bindView(arrayList: List<Song>) { fun bindView(arrayList: List<Song>) {
val color = ThemeStore.accentColor(activity) val color = ThemeStore.accentColor(activity)
itemView.findViewById<TextView>(R.id.text).setTextColor(color) itemView.findViewById<TextView>(R.id.text).setTextColor(color)
itemView.findViewById<MaterialCardView>(R.id.card6).apply {
images.forEachIndexed { index, i -> setCardBackgroundColor(ColorUtil.withAlpha(color, 0.2f))
itemView.findViewById<View>(i).setOnClickListener {
MusicPlayerRemote.playNext(arrayList[index])
}
SongGlideRequest.Builder.from(Glide.with(activity), arrayList[index])
.asBitmap()
.build()
.into(itemView.findViewById(i))
} }
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))
}
} }
} }

View file

@ -100,7 +100,7 @@ class SongFileAdapter(
if (file.isDirectory) { if (file.isDirectory) {
holder.image?.let { holder.image?.let {
it.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN) it.setColorFilter(iconColor, PorterDuff.Mode.SRC_IN)
it.setImageResource(R.drawable.ic_folder_white_24dp) it.setImageResource(R.drawable.ic_folder)
} }
holder.imageTextContainer?.setCardBackgroundColor( holder.imageTextContainer?.setCardBackgroundColor(
ATHUtil.resolveColor( ATHUtil.resolveColor(
@ -110,7 +110,7 @@ class SongFileAdapter(
) )
} else { } else {
val error = RetroUtil.getTintedVectorDrawable( val error = RetroUtil.getTintedVectorDrawable(
activity, R.drawable.ic_file_music_white_24dp, iconColor activity, R.drawable.ic_file_music, iconColor
) )
Glide.with(activity) Glide.with(activity)
.load(AudioFileCover(file.path)) .load(AudioFileCover(file.path))

View file

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

View file

@ -94,12 +94,12 @@ class PlaylistAdapter(
return if (MusicUtil.isFavoritePlaylist(activity, playlist)) return if (MusicUtil.isFavoritePlaylist(activity, playlist))
TintHelper.createTintedDrawable( TintHelper.createTintedDrawable(
activity, activity,
R.drawable.ic_favorite_white_24dp, R.drawable.ic_favorite,
ThemeStore.accentColor(activity) ThemeStore.accentColor(activity)
) )
else TintHelper.createTintedDrawable( else TintHelper.createTintedDrawable(
activity, activity,
R.drawable.ic_playlist_play_white_24dp, R.drawable.ic_playlist_play,
ATHUtil.resolveColor(activity, R.attr.colorControlNormal) ATHUtil.resolveColor(activity, R.attr.colorControlNormal)
) )
} }

View file

@ -3,7 +3,6 @@ package io.github.muntashirakon.music.adapter.song
import android.app.ActivityOptions import android.app.ActivityOptions
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.content.res.Resources import android.content.res.Resources
import android.graphics.drawable.Drawable
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.MenuItem import android.view.MenuItem
import android.view.View 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.MusicUtil
import io.github.muntashirakon.music.util.NavigationUtil import io.github.muntashirakon.music.util.NavigationUtil
import io.github.muntashirakon.music.util.PreferenceUtil import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import com.afollestad.materialcab.MaterialCab import com.afollestad.materialcab.MaterialCab
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import me.zhanghai.android.fastscroll.PopupTextProvider import me.zhanghai.android.fastscroll.PopupTextProvider
import java.util.*
/** /**
* Created by hemanths on 13/08/17. * Created by hemanths on 13/08/17.
@ -56,7 +53,7 @@ open class SongAdapter(
} }
open fun swapDataSet(dataSet: List<Song>) { open fun swapDataSet(dataSet: List<Song>) {
this.dataSet = dataSet.toMutableList() this.dataSet = ArrayList(dataSet)
notifyDataSetChanged() notifyDataSetChanged()
} }
@ -109,11 +106,6 @@ open class SongAdapter(
.checkIgnoreMediaStore(activity) .checkIgnoreMediaStore(activity)
.generatePalette(activity).build() .generatePalette(activity).build()
.into(object : RetroMusicColoredTarget(holder.image!!) { .into(object : RetroMusicColoredTarget(holder.image!!) {
override fun onLoadCleared(placeholder: Drawable?) {
super.onLoadCleared(placeholder)
}
override fun onColorReady(colors: MediaNotificationProcessor) { override fun onColorReady(colors: MediaNotificationProcessor) {
setColors(colors, holder) setColors(colors, holder)
} }
@ -210,7 +202,6 @@ open class SongAdapter(
} }
companion object { companion object {
val TAG: String = SongAdapter::class.java.simpleName val TAG: String = SongAdapter::class.java.simpleName
} }
} }

View file

@ -17,7 +17,7 @@ package io.github.muntashirakon.music.appshortcuts
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.os.Bundle 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.LastAddedShortcutType
import io.github.muntashirakon.music.appshortcuts.shortcuttype.SearchShortCutType import io.github.muntashirakon.music.appshortcuts.shortcuttype.SearchShortCutType
import io.github.muntashirakon.music.appshortcuts.shortcuttype.ShuffleAllShortcutType import io.github.muntashirakon.music.appshortcuts.shortcuttype.ShuffleAllShortcutType

View file

@ -57,7 +57,7 @@ class AppWidgetBig : BaseAppWidget() {
R.id.button_next, createBitmap( R.id.button_next, createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
context, context,
R.drawable.ic_skip_next_white_24dp, R.drawable.ic_skip_next,
MaterialValueHelper.getPrimaryTextColor(context, false) MaterialValueHelper.getPrimaryTextColor(context, false)
)!!, 1f )!!, 1f
) )
@ -66,7 +66,7 @@ class AppWidgetBig : BaseAppWidget() {
R.id.button_prev, createBitmap( R.id.button_prev, createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
context, context,
R.drawable.ic_skip_previous_white_24dp, R.drawable.ic_skip_previous,
MaterialValueHelper.getPrimaryTextColor(context, false) MaterialValueHelper.getPrimaryTextColor(context, false)
)!!, 1f )!!, 1f
) )
@ -117,7 +117,7 @@ class AppWidgetBig : BaseAppWidget() {
val primaryColor = MaterialValueHelper.getPrimaryTextColor(service, false) val primaryColor = MaterialValueHelper.getPrimaryTextColor(service, false)
// Set correct drawable for pause state // Set correct drawable for pause state
val playPauseRes = 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( appWidgetView.setImageViewBitmap(
R.id.button_toggle_play_pause, createBitmap( R.id.button_toggle_play_pause, createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
@ -133,7 +133,7 @@ class AppWidgetBig : BaseAppWidget() {
R.id.button_next, createBitmap( R.id.button_next, createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
service, service,
R.drawable.ic_skip_next_white_24dp, R.drawable.ic_skip_next,
primaryColor primaryColor
)!!, 1f )!!, 1f
) )
@ -142,7 +142,7 @@ class AppWidgetBig : BaseAppWidget() {
R.id.button_prev, createBitmap( R.id.button_prev, createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
service, service,
R.drawable.ic_skip_previous_white_24dp, R.drawable.ic_skip_previous,
primaryColor primaryColor
)!!, 1f )!!, 1f
) )

View file

@ -55,7 +55,7 @@ class AppWidgetCard : BaseAppWidget() {
R.id.button_next, createBitmap( R.id.button_next, createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
context, context,
R.drawable.ic_skip_next_white_24dp, R.drawable.ic_skip_next,
secondaryColor secondaryColor
)!!, 1f )!!, 1f
) )
@ -64,7 +64,7 @@ class AppWidgetCard : BaseAppWidget() {
R.id.button_prev, createBitmap( R.id.button_prev, createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
context, context,
R.drawable.ic_skip_previous_white_24dp, R.drawable.ic_skip_previous,
secondaryColor secondaryColor
)!!, 1f )!!, 1f
) )
@ -103,7 +103,7 @@ class AppWidgetCard : BaseAppWidget() {
// Set correct drawable for pause state // Set correct drawable for pause state
val playPauseRes = 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( appWidgetView.setImageViewBitmap(
R.id.button_toggle_play_pause, createBitmap( R.id.button_toggle_play_pause, createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
@ -119,7 +119,7 @@ class AppWidgetCard : BaseAppWidget() {
R.id.button_next, createBitmap( R.id.button_next, createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
service, service,
R.drawable.ic_skip_next_white_24dp, R.drawable.ic_skip_next,
MaterialValueHelper.getSecondaryTextColor(service, true) MaterialValueHelper.getSecondaryTextColor(service, true)
)!!, 1f )!!, 1f
) )
@ -128,7 +128,7 @@ class AppWidgetCard : BaseAppWidget() {
R.id.button_prev, createBitmap( R.id.button_prev, createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
service, service,
R.drawable.ic_skip_previous_white_24dp, R.drawable.ic_skip_previous,
MaterialValueHelper.getSecondaryTextColor(service, true) MaterialValueHelper.getSecondaryTextColor(service, true)
)!!, 1f )!!, 1f
) )
@ -189,14 +189,14 @@ class AppWidgetCard : BaseAppWidget() {
appWidgetView.setImageViewBitmap( appWidgetView.setImageViewBitmap(
R.id.button_next, ImageUtil.createBitmap( R.id.button_next, ImageUtil.createBitmap(
ImageUtil.getTintedVectorDrawable( ImageUtil.getTintedVectorDrawable(
service, R.drawable.ic_skip_next_white_24dp, color service, R.drawable.ic_skip_next, color
) )
) )
) )
appWidgetView.setImageViewBitmap( appWidgetView.setImageViewBitmap(
R.id.button_prev, ImageUtil.createBitmap( R.id.button_prev, ImageUtil.createBitmap(
ImageUtil.getTintedVectorDrawable( ImageUtil.getTintedVectorDrawable(
service, R.drawable.ic_skip_previous_white_24dp, color service, R.drawable.ic_skip_previous, color
) )
) )
) )

View file

@ -57,7 +57,7 @@ class AppWidgetClassic : BaseAppWidget() {
createBitmap( createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
context, context,
R.drawable.ic_skip_next_white_24dp, R.drawable.ic_skip_next,
MaterialValueHelper.getSecondaryTextColor(context, true) MaterialValueHelper.getSecondaryTextColor(context, true)
)!!, 1f )!!, 1f
) )
@ -67,7 +67,7 @@ class AppWidgetClassic : BaseAppWidget() {
createBitmap( createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
context, context,
R.drawable.ic_skip_previous_white_24dp, R.drawable.ic_skip_previous,
MaterialValueHelper.getSecondaryTextColor(context, true) MaterialValueHelper.getSecondaryTextColor(context, true)
)!!, 1f )!!, 1f
) )
@ -151,7 +151,7 @@ class AppWidgetClassic : BaseAppWidget() {
private fun update(bitmap: Bitmap?, color: Int) { private fun update(bitmap: Bitmap?, color: Int) {
// Set correct drawable for pause state // Set correct drawable for pause state
val playPauseRes = 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( appWidgetView.setImageViewBitmap(
R.id.button_toggle_play_pause, R.id.button_toggle_play_pause,
ImageUtil.createBitmap( ImageUtil.createBitmap(
@ -169,7 +169,7 @@ class AppWidgetClassic : BaseAppWidget() {
ImageUtil.createBitmap( ImageUtil.createBitmap(
ImageUtil.getTintedVectorDrawable( ImageUtil.getTintedVectorDrawable(
service, service,
R.drawable.ic_skip_next_white_24dp, R.drawable.ic_skip_next,
color color
) )
) )
@ -179,7 +179,7 @@ class AppWidgetClassic : BaseAppWidget() {
ImageUtil.createBitmap( ImageUtil.createBitmap(
ImageUtil.getTintedVectorDrawable( ImageUtil.getTintedVectorDrawable(
service, service,
R.drawable.ic_skip_previous_white_24dp, R.drawable.ic_skip_previous,
color color
) )
) )

View file

@ -54,7 +54,7 @@ class AppWidgetSmall : BaseAppWidget() {
createBitmap( createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
context, context,
R.drawable.ic_skip_next_white_24dp, R.drawable.ic_skip_next,
MaterialValueHelper.getSecondaryTextColor(context, true) MaterialValueHelper.getSecondaryTextColor(context, true)
)!!, 1f )!!, 1f
) )
@ -64,7 +64,7 @@ class AppWidgetSmall : BaseAppWidget() {
createBitmap( createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
context, context,
R.drawable.ic_skip_previous_white_24dp, R.drawable.ic_skip_previous,
MaterialValueHelper.getSecondaryTextColor(context, true) MaterialValueHelper.getSecondaryTextColor(context, true)
)!!, 1f )!!, 1f
) )
@ -150,7 +150,7 @@ class AppWidgetSmall : BaseAppWidget() {
private fun update(bitmap: Bitmap?, color: Int) { private fun update(bitmap: Bitmap?, color: Int) {
// Set correct drawable for pause state // 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 else R.drawable.ic_play_arrow_white_32dp
appWidgetView.setImageViewBitmap( appWidgetView.setImageViewBitmap(
R.id.button_toggle_play_pause, createBitmap( R.id.button_toggle_play_pause, createBitmap(
@ -164,14 +164,14 @@ class AppWidgetSmall : BaseAppWidget() {
appWidgetView.setImageViewBitmap( appWidgetView.setImageViewBitmap(
R.id.button_next, createBitmap( R.id.button_next, createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
service, R.drawable.ic_skip_next_white_24dp, color service, R.drawable.ic_skip_next, color
)!!, 1f )!!, 1f
) )
) )
appWidgetView.setImageViewBitmap( appWidgetView.setImageViewBitmap(
R.id.button_prev, createBitmap( R.id.button_prev, createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
service, R.drawable.ic_skip_previous_white_24dp, color service, R.drawable.ic_skip_previous, color
)!!, 1f )!!, 1f
) )
) )

View file

@ -37,7 +37,7 @@ class AppWidgetText : BaseAppWidget() {
appWidgetView.setImageViewBitmap( appWidgetView.setImageViewBitmap(
R.id.button_next, createBitmap( R.id.button_next, createBitmap(
RetroUtil.getTintedVectorDrawable( 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 context, R.color.md_white_1000
) )
)!!, 1f )!!, 1f
@ -46,7 +46,7 @@ class AppWidgetText : BaseAppWidget() {
appWidgetView.setImageViewBitmap( appWidgetView.setImageViewBitmap(
R.id.button_prev, createBitmap( R.id.button_prev, createBitmap(
RetroUtil.getTintedVectorDrawable( 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 context, R.color.md_white_1000
) )
)!!, 1f )!!, 1f
@ -119,7 +119,7 @@ class AppWidgetText : BaseAppWidget() {
linkButtons(service, appWidgetView) linkButtons(service, appWidgetView)
// Set correct drawable for pause state // 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 else R.drawable.ic_play_arrow_white_32dp
appWidgetView.setImageViewBitmap( appWidgetView.setImageViewBitmap(
R.id.button_toggle_play_pause, createBitmap( R.id.button_toggle_play_pause, createBitmap(
@ -134,7 +134,7 @@ class AppWidgetText : BaseAppWidget() {
R.id.button_next, createBitmap( R.id.button_next, createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
App.getContext(), App.getContext(),
R.drawable.ic_skip_next_white_24dp, R.drawable.ic_skip_next,
ContextCompat.getColor( ContextCompat.getColor(
App.getContext(), R.color.md_white_1000 App.getContext(), R.color.md_white_1000
) )
@ -145,7 +145,7 @@ class AppWidgetText : BaseAppWidget() {
R.id.button_prev, createBitmap( R.id.button_prev, createBitmap(
RetroUtil.getTintedVectorDrawable( RetroUtil.getTintedVectorDrawable(
App.getContext(), App.getContext(),
R.drawable.ic_skip_previous_white_24dp, R.drawable.ic_skip_previous,
ContextCompat.getColor( ContextCompat.getColor(
App.getContext(), R.color.md_white_1000 App.getContext(), R.color.md_white_1000
) )

View file

@ -19,11 +19,12 @@ import android.os.Bundle
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import io.github.muntashirakon.music.EXTRA_SONG import io.github.muntashirakon.music.EXTRA_SONG
import io.github.muntashirakon.music.R 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.extraNotNull
import io.github.muntashirakon.music.extensions.materialDialog
import io.github.muntashirakon.music.loaders.PlaylistLoader import io.github.muntashirakon.music.loaders.PlaylistLoader
import io.github.muntashirakon.music.model.Song import io.github.muntashirakon.music.model.Song
import io.github.muntashirakon.music.util.PlaylistsUtil import io.github.muntashirakon.music.util.PlaylistsUtil
import com.google.android.material.dialog.MaterialAlertDialogBuilder
class AddToPlaylistDialog : DialogFragment() { class AddToPlaylistDialog : DialogFragment() {
@ -31,17 +32,13 @@ class AddToPlaylistDialog : DialogFragment() {
savedInstanceState: Bundle? savedInstanceState: Bundle?
): Dialog { ): Dialog {
val playlists = PlaylistLoader.getAllPlaylists(requireContext()) val playlists = PlaylistLoader.getAllPlaylists(requireContext())
val playlistNames = mutableListOf<CharSequence>() val playlistNames = mutableListOf<String>()
playlistNames.add(requireContext().resources.getString(R.string.action_new_playlist)) playlistNames.add(requireContext().resources.getString(R.string.action_new_playlist))
for (p in playlists) { for (p in playlists) {
playlistNames.add(p.name) playlistNames.add(p.name)
} }
return MaterialAlertDialogBuilder( return materialDialog(R.string.add_playlist_title)
requireContext(),
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
)
.setTitle(R.string.add_playlist_title)
.setItems(playlistNames.toTypedArray()) { _, which -> .setItems(playlistNames.toTypedArray()) { _, which ->
val songs = extraNotNull<ArrayList<Song>>(EXTRA_SONG).value val songs = extraNotNull<ArrayList<Song>>(EXTRA_SONG).value
if (which == 0) { if (which == 0) {
@ -57,7 +54,7 @@ class AddToPlaylistDialog : DialogFragment() {
} }
dismiss() dismiss()
} }
.create() .create().colorButtons()
} }
companion object { companion object {

View file

@ -71,9 +71,9 @@ public class BlacklistFolderChooserDialog extends DialogFragment implements Mate
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& ActivityCompat.checkSelfPermission( && ActivityCompat.checkSelfPermission(
getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE) requireActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) { != PackageManager.PERMISSION_GRANTED) {
return new MaterialDialog.Builder(getActivity()) return new MaterialDialog.Builder(requireActivity())
.title(R.string.md_error_label) .title(R.string.md_error_label)
.content(R.string.md_storage_perm_error) .content(R.string.md_storage_perm_error)
.positiveText(android.R.string.ok) .positiveText(android.R.string.ok)
@ -89,7 +89,7 @@ public class BlacklistFolderChooserDialog extends DialogFragment implements Mate
checkIfCanGoUp(); checkIfCanGoUp();
parentContents = listFiles(); parentContents = listFiles();
MaterialDialog.Builder builder = MaterialDialog.Builder builder =
new MaterialDialog.Builder(getActivity()) new MaterialDialog.Builder(requireActivity())
.title(parentFolder.getAbsolutePath()) .title(parentFolder.getAbsolutePath())
.items((CharSequence[]) getContentsArray()) .items((CharSequence[]) getContentsArray())
.itemsCallback(this) .itemsCallback(this)

View file

@ -23,10 +23,11 @@ import androidx.fragment.app.DialogFragment
import code.name.monkey.appthemehelper.util.MaterialUtil import code.name.monkey.appthemehelper.util.MaterialUtil
import io.github.muntashirakon.music.EXTRA_SONG import io.github.muntashirakon.music.EXTRA_SONG
import io.github.muntashirakon.music.R 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.extraNotNull
import io.github.muntashirakon.music.extensions.materialDialog
import io.github.muntashirakon.music.model.Song import io.github.muntashirakon.music.model.Song
import io.github.muntashirakon.music.util.PlaylistsUtil 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.TextInputEditText
import com.google.android.material.textfield.TextInputLayout import com.google.android.material.textfield.TextInputLayout
import kotlinx.android.synthetic.main.dialog_playlist.view.* import kotlinx.android.synthetic.main.dialog_playlist.view.*
@ -42,11 +43,7 @@ class CreatePlaylistDialog : DialogFragment() {
val playlistContainer: TextInputLayout = view.actionNewPlaylistContainer val playlistContainer: TextInputLayout = view.actionNewPlaylistContainer
MaterialUtil.setTint(playlistContainer, false) MaterialUtil.setTint(playlistContainer, false)
return MaterialAlertDialogBuilder( return materialDialog(R.string.new_playlist_title)
requireActivity(),
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
)
.setTitle(R.string.new_playlist_title)
.setView(view) .setView(view)
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.setPositiveButton( .setPositiveButton(
@ -65,6 +62,7 @@ class CreatePlaylistDialog : DialogFragment() {
} }
} }
.create() .create()
.colorButtons()
} }
companion object { companion object {

View file

@ -20,10 +20,11 @@ import androidx.core.text.HtmlCompat
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import io.github.muntashirakon.music.EXTRA_PLAYLIST import io.github.muntashirakon.music.EXTRA_PLAYLIST
import io.github.muntashirakon.music.R 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.extraNotNull
import io.github.muntashirakon.music.extensions.materialDialog
import io.github.muntashirakon.music.model.Playlist import io.github.muntashirakon.music.model.Playlist
import io.github.muntashirakon.music.util.PlaylistsUtil import io.github.muntashirakon.music.util.PlaylistsUtil
import com.google.android.material.dialog.MaterialAlertDialogBuilder
class DeletePlaylistDialog : DialogFragment() { class DeletePlaylistDialog : DialogFragment() {
@ -46,10 +47,7 @@ class DeletePlaylistDialog : DialogFragment() {
) )
} }
return MaterialAlertDialogBuilder( return materialDialog(title)
requireContext(),
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
)
.setTitle(title) .setTitle(title)
.setMessage(message) .setMessage(message)
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
@ -57,6 +55,7 @@ class DeletePlaylistDialog : DialogFragment() {
PlaylistsUtil.deletePlaylists(requireContext(), playlists) PlaylistsUtil.deletePlaylists(requireContext(), playlists)
} }
.create() .create()
.colorButtons()
} }
companion object { companion object {

View file

@ -23,12 +23,13 @@ import androidx.fragment.app.DialogFragment
import io.github.muntashirakon.music.EXTRA_SONG import io.github.muntashirakon.music.EXTRA_SONG
import io.github.muntashirakon.music.R import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.activities.saf.SAFGuideActivity 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.extraNotNull
import io.github.muntashirakon.music.extensions.materialDialog
import io.github.muntashirakon.music.helper.MusicPlayerRemote import io.github.muntashirakon.music.helper.MusicPlayerRemote
import io.github.muntashirakon.music.model.Song import io.github.muntashirakon.music.model.Song
import io.github.muntashirakon.music.util.MusicUtil import io.github.muntashirakon.music.util.MusicUtil
import io.github.muntashirakon.music.util.SAFUtil import io.github.muntashirakon.music.util.SAFUtil
import com.google.android.material.dialog.MaterialAlertDialogBuilder
class DeleteSongsDialog : DialogFragment() { class DeleteSongsDialog : DialogFragment() {
@JvmField @JvmField
@ -57,11 +58,7 @@ class DeleteSongsDialog : DialogFragment() {
) )
} }
return MaterialAlertDialogBuilder( return materialDialog(title)
requireContext(),
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
)
.setTitle(title)
.setMessage(message) .setMessage(message)
.setCancelable(false) .setCancelable(false)
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
@ -74,6 +71,7 @@ class DeleteSongsDialog : DialogFragment() {
deleteSongsAsyncTask?.execute(DeleteSongsAsyncTask.LoadingInfo(songs, null)) deleteSongsAsyncTask?.execute(DeleteSongsAsyncTask.LoadingInfo(songs, null))
} }
.create() .create()
.colorButtons()
} }
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {

View file

@ -20,9 +20,10 @@ import androidx.core.text.HtmlCompat
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import io.github.muntashirakon.music.EXTRA_SONG import io.github.muntashirakon.music.EXTRA_SONG
import io.github.muntashirakon.music.R 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.model.PlaylistSong
import io.github.muntashirakon.music.util.PlaylistsUtil import io.github.muntashirakon.music.util.PlaylistsUtil
import com.google.android.material.dialog.MaterialAlertDialogBuilder
class RemoveFromPlaylistDialog : DialogFragment() { class RemoveFromPlaylistDialog : DialogFragment() {
@ -50,11 +51,7 @@ class RemoveFromPlaylistDialog : DialogFragment() {
} }
} }
return MaterialAlertDialogBuilder( return materialDialog(title)
requireContext(),
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
)
.setTitle(title)
.setMessage(message) .setMessage(message)
.setPositiveButton(R.string.remove_action) { _, _ -> .setPositiveButton(R.string.remove_action) { _, _ ->
PlaylistsUtil.removeFromPlaylist( PlaylistsUtil.removeFromPlaylist(
@ -64,6 +61,7 @@ class RemoveFromPlaylistDialog : DialogFragment() {
} }
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.create() .create()
.colorButtons()
} }
companion object { companion object {

View file

@ -22,9 +22,10 @@ import android.view.LayoutInflater
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import code.name.monkey.appthemehelper.util.MaterialUtil import code.name.monkey.appthemehelper.util.MaterialUtil
import io.github.muntashirakon.music.R 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.extraNotNull
import io.github.muntashirakon.music.extensions.materialDialog
import io.github.muntashirakon.music.util.PlaylistsUtil 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.TextInputEditText
import com.google.android.material.textfield.TextInputLayout import com.google.android.material.textfield.TextInputLayout
@ -42,11 +43,7 @@ class RenamePlaylistDialog : DialogFragment() {
layout.findViewById(R.id.actionNewPlaylistContainer) layout.findViewById(R.id.actionNewPlaylistContainer)
MaterialUtil.setTint(nameContainer, false) MaterialUtil.setTint(nameContainer, false)
return MaterialAlertDialogBuilder( return materialDialog(R.string.rename_playlist_title)
requireContext(),
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
)
.setTitle(R.string.rename_playlist_title)
.setView(layout) .setView(layout)
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(R.string.action_rename) { _, _ -> .setPositiveButton(R.string.action_rename) { _, _ ->
@ -60,6 +57,7 @@ class RenamePlaylistDialog : DialogFragment() {
} }
} }
.create() .create()
.colorButtons()
} }
companion object { companion object {

View file

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

View file

@ -31,6 +31,8 @@ import android.widget.Toast
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import io.github.muntashirakon.music.R import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.extensions.addAccentColor 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.helper.MusicPlayerRemote
import io.github.muntashirakon.music.service.MusicService import io.github.muntashirakon.music.service.MusicService
import io.github.muntashirakon.music.service.MusicService.ACTION_PENDING_QUIT 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 io.github.muntashirakon.music.util.PreferenceUtil
import com.afollestad.materialdialogs.DialogAction import com.afollestad.materialdialogs.DialogAction
import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.MaterialDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
class SleepTimerDialog : DialogFragment() { class SleepTimerDialog : DialogFragment() {
private var seekArcProgress: Int = 0 private var seekArcProgress: Int = 0
private lateinit var timerUpdater: TimerUpdater private lateinit var timerUpdater: TimerUpdater
private lateinit var materialDialog: MaterialDialog private lateinit var dialog: MaterialDialog
private lateinit var shouldFinishLastSong: CheckBox private lateinit var shouldFinishLastSong: CheckBox
private lateinit var seekBar: SeekBar private lateinit var seekBar: SeekBar
private lateinit var timerDisplay: TextView private lateinit var timerDisplay: TextView
@ -87,11 +88,7 @@ class SleepTimerDialog : DialogFragment() {
PreferenceUtil.lastSleepTimerValue = seekArcProgress PreferenceUtil.lastSleepTimerValue = seekArcProgress
} }
}) })
return MaterialAlertDialogBuilder( return materialDialog(R.string.action_sleep_timer)
requireContext(),
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
)
.setTitle(R.string.action_sleep_timer)
.setView(layout) .setView(layout)
.setPositiveButton(R.string.action_set) { _, _ -> .setPositiveButton(R.string.action_set) { _, _ ->
PreferenceUtil.isSleepTimerFinishMusic = shouldFinishLastSong.isChecked PreferenceUtil.isSleepTimerFinishMusic = shouldFinishLastSong.isChecked
@ -132,6 +129,8 @@ class SleepTimerDialog : DialogFragment() {
} }
} }
.create() .create()
.colorButtons()
} }
private fun updateTimeDisplayTime() { private fun updateTimeDisplayTime() {
@ -152,10 +151,10 @@ class SleepTimerDialog : DialogFragment() {
private fun updateCancelButton() { private fun updateCancelButton() {
val musicService = MusicPlayerRemote.musicService val musicService = MusicPlayerRemote.musicService
if (musicService != null && musicService.pendingQuit) { if (musicService != null && musicService.pendingQuit) {
materialDialog.getActionButton(DialogAction.NEUTRAL).text = dialog.getActionButton(DialogAction.NEUTRAL).text =
materialDialog.context.getString(R.string.cancel_current_timer) dialog.context.getString(R.string.cancel_current_timer)
} else { } else {
materialDialog.getActionButton(DialogAction.NEUTRAL).text = null dialog.getActionButton(DialogAction.NEUTRAL).text = null
} }
} }

View file

@ -29,9 +29,10 @@ import androidx.core.text.HtmlCompat
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import io.github.muntashirakon.music.EXTRA_SONG import io.github.muntashirakon.music.EXTRA_SONG
import io.github.muntashirakon.music.R 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.model.Song
import io.github.muntashirakon.music.util.MusicUtil import io.github.muntashirakon.music.util.MusicUtil
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.jaudiotagger.audio.AudioFileIO import org.jaudiotagger.audio.AudioFileIO
import org.jaudiotagger.audio.exceptions.CannotReadException import org.jaudiotagger.audio.exceptions.CannotReadException
import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException
@ -150,13 +151,11 @@ class SongDetailDialog : DialogFragment() {
) )
} }
} }
return MaterialAlertDialogBuilder( return materialDialog(R.string.action_details)
requireContext(),
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
).setTitle(R.string.action_details)
.setPositiveButton(android.R.string.ok, null) .setPositiveButton(android.R.string.ok, null)
.setView(dialogView) .setView(dialogView)
.create() .create()
.colorButtons()
} }
companion object { companion object {

View file

@ -21,9 +21,10 @@ import androidx.fragment.app.DialogFragment
import io.github.muntashirakon.music.EXTRA_SONG import io.github.muntashirakon.music.EXTRA_SONG
import io.github.muntashirakon.music.R import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.activities.ShareInstagramStory 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.model.Song
import io.github.muntashirakon.music.util.MusicUtil import io.github.muntashirakon.music.util.MusicUtil
import com.google.android.material.dialog.MaterialAlertDialogBuilder
class SongShareDialog : DialogFragment() { class SongShareDialog : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
@ -34,10 +35,7 @@ class SongShareDialog : DialogFragment() {
song?.title, song?.title,
song?.artistName song?.artistName
) )
return MaterialAlertDialogBuilder( return materialDialog(R.string.what_do_you_want_to_share)
requireContext(),
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
).setTitle(R.string.what_do_you_want_to_share)
.setItems( .setItems(
arrayOf( arrayOf(
getString(R.string.the_audio_file), getString(R.string.the_audio_file),
@ -48,6 +46,7 @@ class SongShareDialog : DialogFragment() {
withAction(which, song, listening) withAction(which, song, listening)
} }
.create() .create()
.colorButtons()
} }
private fun withAction( private fun withAction(

View file

@ -18,6 +18,7 @@ import android.app.Dialog
import android.content.Context import android.content.Context
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.graphics.Color import android.graphics.Color
import android.widget.Button
import android.widget.CheckBox import android.widget.CheckBox
import android.widget.SeekBar import android.widget.SeekBar
import androidx.annotation.AttrRes import androidx.annotation.AttrRes
@ -26,6 +27,7 @@ import androidx.fragment.app.Fragment
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
import io.github.muntashirakon.music.App
import io.github.muntashirakon.music.R import io.github.muntashirakon.music.R
fun Int.ripAlpha(): Int { fun Int.ripAlpha(): Int {
@ -77,4 +79,8 @@ fun SeekBar.addAccentColor() {
val colorState = ColorStateList.valueOf(ThemeStore.accentColor(context)) val colorState = ColorStateList.valueOf(ThemeStore.accentColor(context))
progressTintList = colorState progressTintList = colorState
thumbTintList = colorState thumbTintList = colorState
}
fun Button.accentTextColor() {
setTextColor(ThemeStore.accentColor(App.getContext()))
} }

View file

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

View file

@ -1,24 +1,23 @@
package io.github.muntashirakon.music.fragments package io.github.muntashirakon.music.fragments
import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import io.github.muntashirakon.music.adapter.HomeAdapter
import io.github.muntashirakon.music.fragments.ReloadType.* import io.github.muntashirakon.music.fragments.ReloadType.*
import io.github.muntashirakon.music.interfaces.MusicServiceEventListener import io.github.muntashirakon.music.interfaces.MusicServiceEventListener
import io.github.muntashirakon.music.model.* import io.github.muntashirakon.music.model.*
import io.github.muntashirakon.music.providers.RepositoryImpl import io.github.muntashirakon.music.providers.RepositoryImpl
import io.github.muntashirakon.music.providers.interfaces.Repository
import kotlinx.coroutines.Deferred import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
class LibraryViewModel(application: Application) : class LibraryViewModel(
AndroidViewModel(application), MusicServiceEventListener { private val repository: RepositoryImpl
) : ViewModel(), MusicServiceEventListener {
private val _repository: Repository = RepositoryImpl(application.applicationContext)
private val _albums = MutableLiveData<List<Album>>() private val _albums = MutableLiveData<List<Album>>()
private val _songs = MutableLiveData<List<Song>>() private val _songs = MutableLiveData<List<Song>>()
private val _artists = MutableLiveData<List<Artist>>() private val _artists = MutableLiveData<List<Artist>>()
@ -51,16 +50,22 @@ class LibraryViewModel(application: Application) :
private fun loadHomeSections() = viewModelScope.launch { private fun loadHomeSections() = viewModelScope.launch {
val list = mutableListOf<Home>() val list = mutableListOf<Home>()
val result = listOf( val result = listOf(
_repository.topArtists(), repository.topArtists(),
_repository.topAlbums(), repository.topAlbums(),
_repository.recentArtists(), repository.recentArtists(),
_repository.recentAlbums(), repository.recentAlbums(),
_repository.favoritePlaylist(), repository.suggestions(),
_repository.suggestions() repository.favoritePlaylist()
) )
for (r in result) { result.forEach {
if (r != null) { if (it != null && it.arrayList.isNotEmpty()) {
list.add(r) if (it.homeSection == HomeAdapter.SUGGESTIONS) {
if (it.arrayList.size > 9) {
list.add(it)
}
} else {
list.add(it)
}
} }
} }
_homeSections.value = list _homeSections.value = list
@ -68,27 +73,27 @@ class LibraryViewModel(application: Application) :
private val loadSongs: Deferred<List<Song>> private val loadSongs: Deferred<List<Song>>
get() = viewModelScope.async(IO) { get() = viewModelScope.async(IO) {
_repository.allSongs() repository.allSongs()
} }
private val loadAlbums: Deferred<List<Album>> private val loadAlbums: Deferred<List<Album>>
get() = viewModelScope.async(IO) { get() = viewModelScope.async(IO) {
_repository.allAlbums() repository.allAlbums()
} }
private val loadArtists: Deferred<List<Artist>> private val loadArtists: Deferred<List<Artist>>
get() = viewModelScope.async(IO) { get() = viewModelScope.async(IO) {
_repository.allArtists() repository.allArtists()
} }
private val loadPlaylists: Deferred<List<Playlist>> private val loadPlaylists: Deferred<List<Playlist>>
get() = viewModelScope.async(IO) { get() = viewModelScope.async(IO) {
_repository.allPlaylists() repository.allPlaylists()
} }
private val loadGenres: Deferred<List<Genre>> private val loadGenres: Deferred<List<Genre>>
get() = viewModelScope.async(IO) { get() = viewModelScope.async(IO) {
_repository.allGenres() repository.allGenres()
} }
fun forceReload(reloadType: ReloadType) = viewModelScope.launch { fun forceReload(reloadType: ReloadType) = viewModelScope.launch {

View file

@ -15,14 +15,12 @@ import io.github.muntashirakon.music.extensions.show
import io.github.muntashirakon.music.extensions.textColorPrimary import io.github.muntashirakon.music.extensions.textColorPrimary
import io.github.muntashirakon.music.extensions.textColorSecondary import io.github.muntashirakon.music.extensions.textColorSecondary
import io.github.muntashirakon.music.fragments.base.AbsMusicServiceFragment 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.MusicPlayerRemote
import io.github.muntashirakon.music.helper.MusicProgressViewUpdateHelper import io.github.muntashirakon.music.helper.MusicProgressViewUpdateHelper
import io.github.muntashirakon.music.helper.PlayPauseButtonOnClickHandler import io.github.muntashirakon.music.helper.PlayPauseButtonOnClickHandler
import io.github.muntashirakon.music.util.PreferenceUtil import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.RetroUtil import io.github.muntashirakon.music.util.RetroUtil
import io.github.muntashirakon.music.util.ViewUtil import io.github.muntashirakon.music.util.ViewUtil
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.fragment_mini_player.* import kotlinx.android.synthetic.main.fragment_mini_player.*
import kotlin.math.abs import kotlin.math.abs
@ -63,8 +61,7 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
actionPrevious?.show() actionPrevious?.show()
} else { } else {
actionNext.visibility = actionNext.visibility = if (PreferenceUtil.isExtraControls) View.VISIBLE else View.GONE
if (PreferenceUtil.isExtraControls) View.VISIBLE else View.GONE
actionPrevious.visibility = actionPrevious.visibility =
if (PreferenceUtil.isExtraControls) View.VISIBLE else View.GONE if (PreferenceUtil.isExtraControls) View.VISIBLE else View.GONE
} }
@ -97,19 +94,6 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
miniPlayerTitle.isSelected = true miniPlayerTitle.isSelected = true
miniPlayerTitle.text = builder 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() { override fun onServiceConnected() {
@ -145,9 +129,9 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
protected fun updatePlayPauseDrawableState() { protected fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
miniPlayerPlayPauseButton!!.setImageResource(R.drawable.ic_pause_white_24dp) miniPlayerPlayPauseButton.setImageResource(R.drawable.ic_pause)
} else { } else {
miniPlayerPlayPauseButton!!.setImageResource(R.drawable.ic_play_arrow_white_24dp) miniPlayerPlayPauseButton.setImageResource(R.drawable.ic_play_arrow)
} }
} }

View file

@ -62,7 +62,7 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum
volumeSeekBar.max = maxVolume volumeSeekBar.max = maxVolume
volumeSeekBar.progress = currentVolume 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() { override fun onDestroyView() {
@ -74,7 +74,7 @@ class VolumeFragment : Fragment(), SeekBar.OnSeekBarChangeListener, OnAudioVolum
val audioManager = audioManager val audioManager = audioManager
audioManager?.setStreamVolume(AudioManager.STREAM_MUSIC, i, 0) audioManager?.setStreamVolume(AudioManager.STREAM_MUSIC, i, 0)
setPauseWhenZeroVolume(i < 1) 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) { override fun onStartTrackingTouch(seekBar: SeekBar) {

View file

@ -15,7 +15,6 @@ class AlbumsFragment :
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(), AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
MainActivityFragmentCallbacks { MainActivityFragmentCallbacks {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
mainActivity.libraryViewModel.allAlbums() mainActivity.libraryViewModel.allAlbums()

View file

@ -197,9 +197,9 @@ abstract class AbsPlayerFragment : AbsMusicServiceFragment(),
override fun onPostExecute(isFavorite: Boolean) { override fun onPostExecute(isFavorite: Boolean) {
val res = if (isFavorite) val res = if (isFavorite)
R.drawable.ic_favorite_white_24dp R.drawable.ic_favorite
else else
R.drawable.ic_favorite_border_white_24dp R.drawable.ic_favorite_border
val drawable = val drawable =
RetroUtil.getTintedVectorDrawable(requireContext(), res, toolbarIconColor()) RetroUtil.getTintedVectorDrawable(requireContext(), res, toolbarIconColor())

View file

@ -375,7 +375,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
} }
cab = new MaterialCab(getMainActivity(), R.id.cab_stub) cab = new MaterialCab(getMainActivity(), R.id.cab_stub)
.setMenu(menuRes) .setMenu(menuRes)
.setCloseDrawableRes(R.drawable.ic_close_white_24dp) .setCloseDrawableRes(R.drawable.ic_close)
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText( .setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(
ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorSurface))) ATHUtil.INSTANCE.resolveColor(requireContext(), R.attr.colorSurface)))
.start(callback); .start(callback);

View file

@ -157,7 +157,7 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp) playPauseButton.setImageResource(R.drawable.ic_pause)
} else { } else {
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp) playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
} }
@ -214,18 +214,18 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateRepeatState() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }

View file

@ -148,7 +148,7 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp) playPauseButton.setImageResource(R.drawable.ic_pause)
} else { } else {
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp) playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
} }
@ -197,18 +197,18 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateRepeatState() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }

View file

@ -155,7 +155,7 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp) playPauseButton.setImageResource(R.drawable.ic_pause)
} else { } else {
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp) playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
} }
@ -204,18 +204,18 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateRepeatState() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }

View file

@ -79,7 +79,7 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
when { 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) else -> playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
} }
} }
@ -177,18 +177,18 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateRepeatState() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }

View file

@ -206,8 +206,8 @@ class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChanged
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
when { 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_24dp) else -> playPauseButton.setImageResource(R.drawable.ic_play_arrow)
} }
} }

View file

@ -415,9 +415,9 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp) playPauseButton.setImageResource(R.drawable.ic_pause)
} else { } 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() { fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }

View file

@ -129,8 +129,8 @@ class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
when { 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_24dp) else -> playPauseButton.setImageResource(R.drawable.ic_play_arrow)
} }
} }
@ -177,18 +177,18 @@ class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateRepeatState() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }

View file

@ -156,7 +156,7 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp) playPauseButton.setImageResource(R.drawable.ic_pause)
} else { } else {
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp) playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
} }
@ -205,18 +205,18 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateRepeatState() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }

View file

@ -149,7 +149,7 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp) playPauseButton.setImageResource(R.drawable.ic_pause)
} else { } else {
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp) playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
} }
@ -189,18 +189,18 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
override fun updateRepeatState() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }

View file

@ -148,7 +148,7 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp) playPauseButton.setImageResource(R.drawable.ic_pause)
} else { } else {
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp) playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
} }
@ -257,18 +257,18 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
override fun updateRepeatState() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }
@ -309,9 +309,9 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
val activity = activity val activity = activity
if (activity != null) { if (activity != null) {
val res = if (isFavorite!!) val res = if (isFavorite!!)
R.drawable.ic_favorite_white_24dp R.drawable.ic_favorite
else else
R.drawable.ic_favorite_border_white_24dp R.drawable.ic_favorite_border
val drawable = TintHelper.createTintedDrawable(activity, res, Color.WHITE) val drawable = TintHelper.createTintedDrawable(activity, res, Color.WHITE)
songFavourite?.setImageDrawable(drawable) songFavourite?.setImageDrawable(drawable)

View file

@ -355,18 +355,18 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
fun updateRepeatState() { fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }
@ -506,9 +506,9 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
val activity = activity val activity = activity
if (activity != null) { if (activity != null) {
val res = if (isFavorite!!) val res = if (isFavorite!!)
R.drawable.ic_favorite_white_24dp R.drawable.ic_favorite
else else
R.drawable.ic_favorite_border_white_24dp R.drawable.ic_favorite_border
val drawable = TintHelper.createTintedDrawable(activity, res, Color.WHITE) val drawable = TintHelper.createTintedDrawable(activity, res, Color.WHITE)
songFavourite?.setImageDrawable(drawable) songFavourite?.setImageDrawable(drawable)

View file

@ -156,7 +156,7 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp) playPauseButton.setImageResource(R.drawable.ic_pause)
} else { } else {
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp) playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
} }
@ -205,18 +205,18 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
override fun updateRepeatState() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }

View file

@ -190,18 +190,18 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
override fun updateRepeatState() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_sharp_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat_sharp)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }

View file

@ -153,9 +153,9 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp) playPauseButton.setImageResource(R.drawable.ic_pause)
} else { } 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() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }

View file

@ -118,7 +118,7 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment() {
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp) playPauseButton.setImageResource(R.drawable.ic_pause)
} else { } else {
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp) playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
} }
@ -203,18 +203,18 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment() {
override fun updateRepeatState() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }

View file

@ -204,18 +204,18 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateRepeatState() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }
@ -265,7 +265,7 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() {
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp) playPauseButton.setImageResource(R.drawable.ic_pause)
} else { } else {
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp) playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
} }

View file

@ -134,18 +134,18 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateRepeatState() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
repeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) repeatButton.setImageResource(R.drawable.ic_repeat)
repeatButton.setColorFilter( repeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) repeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }
@ -243,7 +243,7 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
private fun updatePlayPauseDrawableState() { private fun updatePlayPauseDrawableState() {
if (MusicPlayerRemote.isPlaying) { if (MusicPlayerRemote.isPlaying) {
playPauseButton.setImageResource(R.drawable.ic_pause_white_24dp) playPauseButton.setImageResource(R.drawable.ic_pause)
} else { } else {
playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp) playPauseButton.setImageResource(R.drawable.ic_play_arrow_white_32dp)
} }

View file

@ -81,18 +81,18 @@ class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
override fun updateRepeatState() { override fun updateRepeatState() {
when (MusicPlayerRemote.repeatMode) { when (MusicPlayerRemote.repeatMode) {
MusicService.REPEAT_MODE_NONE -> { MusicService.REPEAT_MODE_NONE -> {
playerRepeatButton.setImageResource(R.drawable.ic_repeat_white_24dp) playerRepeatButton.setImageResource(R.drawable.ic_repeat)
playerRepeatButton.setColorFilter( playerRepeatButton.setColorFilter(
lastDisabledPlaybackControlsColor, lastDisabledPlaybackControlsColor,
PorterDuff.Mode.SRC_IN PorterDuff.Mode.SRC_IN
) )
} }
MusicService.REPEAT_MODE_ALL -> { 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) playerRepeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
MusicService.REPEAT_MODE_THIS -> { 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) playerRepeatButton.setColorFilter(lastPlaybackControlsColor, PorterDuff.Mode.SRC_IN)
} }
} }

View file

@ -36,9 +36,6 @@ abstract class RetroMusicColoredTarget(view: ImageView) : BitmapPaletteTarget(vi
super.onLoadFailed(e, errorDrawable) super.onLoadFailed(e, errorDrawable)
val colors = MediaNotificationProcessor(App.getContext(), errorDrawable) val colors = MediaNotificationProcessor(App.getContext(), errorDrawable)
onColorReady(colors) onColorReady(colors)
/* MediaNotificationProcessor(App.getContext()).getPaletteAsync({
onColorReady(it)
}, errorDrawable)*/
} }
override fun onResourceReady( override fun onResourceReady(

View file

@ -23,7 +23,7 @@ import static io.github.muntashirakon.music.Constants.USER_PROFILE;
public class UserProfileGlideRequest { public class UserProfileGlideRequest {
private static final DiskCacheStrategy DEFAULT_DISK_CACHE_STRATEGY = DiskCacheStrategy.NONE; 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; private static final int DEFAULT_ANIMATION = android.R.anim.fade_in;
public static File getUserModel() { public static File getUserModel() {
@ -47,7 +47,7 @@ public class UserProfileGlideRequest {
private Builder(RequestManager requestManager, File profile) { private Builder(RequestManager requestManager, File profile) {
this.requestManager = requestManager; this.requestManager = requestManager;
this.profile = profile; 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) { public static Builder from(@NonNull RequestManager requestManager, File profile) {

View file

@ -15,8 +15,8 @@
package io.github.muntashirakon.music.glide.artistimage package io.github.muntashirakon.music.glide.artistimage
import android.content.Context import android.content.Context
import io.github.muntashirakon.music.deezer.Data
import io.github.muntashirakon.music.deezer.DeezerApiService 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.MusicUtil
import io.github.muntashirakon.music.util.PreferenceUtil import io.github.muntashirakon.music.util.PreferenceUtil
import com.bumptech.glide.Priority import com.bumptech.glide.Priority

View file

@ -181,7 +181,7 @@ public class LrcView extends View {
mTimelineColor = ta.getColor(R.styleable.LrcView_lrcTimelineColor, getResources().getColor(R.color.lrc_timeline_color)); 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)); float timelineHeight = ta.getDimension(R.styleable.LrcView_lrcTimelineHeight, getResources().getDimension(R.dimen.lrc_timeline_height));
mPlayDrawable = ta.getDrawable(R.styleable.LrcView_lrcPlayDrawable); 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)); 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)); 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); mTextGravity = ta.getInteger(R.styleable.LrcView_lrcTextGravity, LrcEntry.GRAVITY_CENTER);

View file

@ -59,14 +59,14 @@ public class CategoryInfo implements Parcelable {
} }
public enum Category { public enum Category {
Home(R.id.action_home, R.string.home, R.drawable.ic_home_white_24dp), Home(R.id.action_home, R.string.home, R.drawable.asld_home),
Songs(R.id.action_song, R.string.songs, R.drawable.ic_audiotrack_white_24dp), Songs(R.id.action_song, R.string.songs, R.drawable.asld_music_note),
Albums(R.id.action_album, R.string.albums, R.drawable.ic_album_white_24dp), Albums(R.id.action_album, R.string.albums, R.drawable.asld_album),
Artists(R.id.action_artist, R.string.artists, R.drawable.ic_artist_white_24dp), 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_white_24dp), 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_white_24dp), 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_white_24dp), 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_white_24dp); Folder(R.id.action_folder, R.string.folders, R.drawable.ic_folder);
public final int icon; public final int icon;

View file

@ -36,7 +36,7 @@ public abstract class AbsSmartPlaylist extends AbsCustomPlaylist {
public AbsSmartPlaylist() { public AbsSmartPlaylist() {
super(); super();
this.iconRes = R.drawable.ic_queue_music_white_24dp; this.iconRes = R.drawable.ic_queue_music;
} }
protected AbsSmartPlaylist(Parcel in) { protected AbsSmartPlaylist(Parcel in) {

View file

@ -44,7 +44,7 @@ public class HistoryPlaylist extends AbsSmartPlaylist {
}; };
public HistoryPlaylist(@NonNull Context context) { 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) { protected HistoryPlaylist(Parcel in) {

View file

@ -41,7 +41,7 @@ public class LastAddedPlaylist extends AbsSmartPlaylist {
}; };
public LastAddedPlaylist(@NonNull Context context) { 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) { protected LastAddedPlaylist(Parcel in) {

View file

@ -44,7 +44,7 @@ public class MyTopTracksPlaylist extends AbsSmartPlaylist {
}; };
public MyTopTracksPlaylist(@NonNull Context context) { 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) { protected MyTopTracksPlaylist(Parcel in) {

View file

@ -29,7 +29,7 @@ public class NotRecentlyPlayedPlaylist extends AbsSmartPlaylist {
}; };
public NotRecentlyPlayedPlaylist(@NonNull Context context) { 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) { protected NotRecentlyPlayedPlaylist(Parcel in) {

View file

@ -40,7 +40,7 @@ public class ShuffleAllPlaylist extends AbsSmartPlaylist {
}; };
public ShuffleAllPlaylist(@NonNull Context context) { 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) { protected ShuffleAllPlaylist(Parcel in) {

View file

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

View file

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

View file

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

View file

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

View file

@ -1,26 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package 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>)
}

View file

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

View file

@ -1,61 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package 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)
}
}
}
}

View file

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

View file

@ -1,61 +0,0 @@
/*
* Copyright (c) 2019 Hemanth Savarala.
*
* Licensed under the GNU General Public License v3
*
* This is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*/
package 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) }
}
}
}
}

View file

@ -12,10 +12,10 @@
* See the GNU General Public License for more details. * 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.network.model.LastFmAlbum
import io.github.muntashirakon.music.rest.model.LastFmArtist import io.github.muntashirakon.music.network.model.LastFmArtist
import retrofit2.http.GET import retrofit2.http.GET
import retrofit2.http.Header import retrofit2.http.Header
import retrofit2.http.Query import retrofit2.http.Query

View file

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

View file

@ -12,7 +12,7 @@
* See the GNU General Public License for more details. * 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.Expose;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;

View file

@ -12,7 +12,7 @@
* See the GNU General Public License for more details. * 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.Expose;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;

View file

@ -12,7 +12,7 @@
* See the GNU General Public License for more details. * 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.Expose;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;

View file

@ -31,12 +31,13 @@ import androidx.viewpager.widget.PagerAdapter
import androidx.viewpager.widget.ViewPager import androidx.viewpager.widget.ViewPager
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
import io.github.muntashirakon.music.R 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.colorControlNormal
import io.github.muntashirakon.music.extensions.materialDialog
import io.github.muntashirakon.music.fragments.AlbumCoverStyle.* import io.github.muntashirakon.music.fragments.AlbumCoverStyle.*
import io.github.muntashirakon.music.util.PreferenceUtil import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.ViewUtil import io.github.muntashirakon.music.util.ViewUtil
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.google.android.material.dialog.MaterialAlertDialogBuilder
class AlbumCoverStylePreference @JvmOverloads constructor( class AlbumCoverStylePreference @JvmOverloads constructor(
context: Context, context: Context,
@ -75,15 +76,14 @@ class AlbumCoverStylePreferenceDialog : DialogFragment(),
viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt() viewPager.pageMargin = ViewUtil.convertDpToPixel(32f, resources).toInt()
viewPager.currentItem = PreferenceUtil.albumCoverStyle.ordinal viewPager.currentItem = PreferenceUtil.albumCoverStyle.ordinal
return MaterialAlertDialogBuilder(requireActivity(), return materialDialog(R.string.pref_title_album_cover_style)
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert)
.setTitle(R.string.pref_title_album_cover_style)
.setPositiveButton(R.string.set) { _, _ -> .setPositiveButton(R.string.set) { _, _ ->
val coverStyle = values()[viewPagerPosition] val coverStyle = values()[viewPagerPosition]
PreferenceUtil.albumCoverStyle = coverStyle PreferenceUtil.albumCoverStyle = coverStyle
} }
.setView(view) .setView(view)
.create() .create()
.colorButtons()
} }
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {

View file

@ -26,7 +26,9 @@ import androidx.fragment.app.FragmentActivity
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
import io.github.muntashirakon.music.R import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.dialogs.BlacklistFolderChooserDialog 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.colorControlNormal
import io.github.muntashirakon.music.extensions.materialDialog
import io.github.muntashirakon.music.providers.BlacklistStore import io.github.muntashirakon.music.providers.BlacklistStore
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import java.io.File import java.io.File
@ -65,25 +67,19 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
childFragmentManager.findFragmentByTag("FOLDER_CHOOSER") as BlacklistFolderChooserDialog? childFragmentManager.findFragmentByTag("FOLDER_CHOOSER") as BlacklistFolderChooserDialog?
chooserDialog?.setCallback(this) chooserDialog?.setCallback(this)
refreshBlacklistData() refreshBlacklistData()
return MaterialAlertDialogBuilder( return materialDialog(R.string.blacklist)
mActivity!!,
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
)
.setTitle(R.string.blacklist)
.setPositiveButton(android.R.string.ok) { _, _ -> .setPositiveButton(android.R.string.ok) { _, _ ->
dismiss() dismiss()
} }
.setNeutralButton(R.string.clear_action) { _, _ -> .setNeutralButton(R.string.clear_action) { _, _ ->
MaterialAlertDialogBuilder( materialDialog(R.string.clear_blacklist)
mActivity!!,
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
)
.setTitle(R.string.clear_blacklist)
.setMessage(R.string.do_you_want_to_clear_the_blacklist) .setMessage(R.string.do_you_want_to_clear_the_blacklist)
.setPositiveButton(R.string.clear_action) { _, _ -> .setPositiveButton(R.string.clear_action) { _, _ ->
BlacklistStore.getInstance(mContext!!).clear() BlacklistStore.getInstance(mContext!!).clear()
} }
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.create()
.colorButtons()
.show() .show()
} }
.setNegativeButton(R.string.add_action) { _, _ -> .setNegativeButton(R.string.add_action) { _, _ ->
@ -92,11 +88,7 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
dialog.show(mActivity!!.supportFragmentManager, "FOLDER_CHOOSER") dialog.show(mActivity!!.supportFragmentManager, "FOLDER_CHOOSER")
} }
.setItems(paths.toTypedArray()) { _, which -> .setItems(paths.toTypedArray()) { _, which ->
MaterialAlertDialogBuilder( materialDialog(R.string.remove_from_blacklist)
mActivity!!,
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
)
.setTitle(R.string.remove_from_blacklist)
.setMessage( .setMessage(
HtmlCompat.fromHtml( HtmlCompat.fromHtml(
String.format( String.format(
@ -114,9 +106,9 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
refreshBlacklistData() refreshBlacklistData()
} }
.setNegativeButton(android.R.string.cancel, null) .setNegativeButton(android.R.string.cancel, null)
.show() .show().colorButtons()
} }
.create() .create().colorButtons()
} }
private lateinit var paths: ArrayList<String> private lateinit var paths: ArrayList<String>

View file

@ -29,11 +29,11 @@ import androidx.recyclerview.widget.RecyclerView
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
import io.github.muntashirakon.music.R import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.adapter.CategoryInfoAdapter 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.colorControlNormal
import io.github.muntashirakon.music.extensions.materialDialog
import io.github.muntashirakon.music.model.CategoryInfo import io.github.muntashirakon.music.model.CategoryInfo
import io.github.muntashirakon.music.util.PreferenceUtil import io.github.muntashirakon.music.util.PreferenceUtil
import com.google.android.material.dialog.MaterialAlertDialogBuilder
class LibraryPreference @JvmOverloads constructor( class LibraryPreference @JvmOverloads constructor(
context: Context, context: Context,
@ -64,11 +64,7 @@ class LibraryPreferenceDialog : DialogFragment() {
categoryAdapter.attachToRecyclerView(recyclerView) categoryAdapter.attachToRecyclerView(recyclerView)
return MaterialAlertDialogBuilder( return materialDialog(R.string.library_categories)
requireContext(),
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
)
.setTitle(R.string.library_categories)
.setNeutralButton( .setNeutralButton(
R.string.reset_action R.string.reset_action
) { _, _ -> ) { _, _ ->
@ -80,6 +76,7 @@ class LibraryPreferenceDialog : DialogFragment() {
) { _, _ -> updateCategories(categoryAdapter.categoryInfos) } ) { _, _ -> updateCategories(categoryAdapter.categoryInfos) }
.setView(view) .setView(view)
.create() .create()
.colorButtons()
} }
private fun updateCategories(categories: List<CategoryInfo>) { private fun updateCategories(categories: List<CategoryInfo>) {

Some files were not shown because too many files have changed in this diff Show more