This commit is contained in:
Muntashir Al-Islam 2020-08-02 14:14:02 +06:00
commit 283280529b
140 changed files with 2267 additions and 931 deletions

View file

@ -18,8 +18,6 @@ import androidx.multidex.MultiDexApplication
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.VersionUtils
import io.github.muntashirakon.music.appshortcuts.DynamicShortcutManager
import io.github.muntashirakon.music.network.networkModule
import io.github.muntashirakon.music.providers.provideModules
import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin
@ -31,7 +29,7 @@ class App : MultiDexApplication() {
startKoin {
androidContext(this@App)
modules(listOf(mainModule, provideModules, networkModule))
modules(appModules)
}
// default theme
if (!ThemeStore.isConfigured(this, 3)) {

View file

@ -8,11 +8,20 @@ import io.github.muntashirakon.music.activities.search.SearchViewModel
import io.github.muntashirakon.music.fragments.LibraryViewModel
import io.github.muntashirakon.music.model.Genre
import io.github.muntashirakon.music.model.Playlist
import org.koin.android.viewmodel.dsl.viewModel
import io.github.muntashirakon.music.network.networkModule
import io.github.muntashirakon.music.providers.RepositoryImpl
import org.eclipse.egit.github.core.Repository
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.dsl.bind
import org.koin.dsl.module
private val dataModule = module {
single {
RepositoryImpl(get(), get())
} bind Repository::class
}
val mainModule = module {
private val viewModules = module {
viewModel {
LibraryViewModel(get())
@ -37,4 +46,6 @@ val mainModule = module {
viewModel {
SearchViewModel(get())
}
}
}
val appModules = listOf(dataModule, viewModules, networkModule)

View file

@ -20,10 +20,10 @@ import io.github.muntashirakon.music.dialogs.CreatePlaylistDialog.Companion.crea
import io.github.muntashirakon.music.fragments.LibraryViewModel
import io.github.muntashirakon.music.fragments.albums.AlbumsFragment
import io.github.muntashirakon.music.fragments.artists.ArtistsFragment
import io.github.muntashirakon.music.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
import io.github.muntashirakon.music.fragments.base.AbsRecyclerViewCustomGridSizeFragment
import io.github.muntashirakon.music.fragments.folder.FoldersFragment
import io.github.muntashirakon.music.fragments.genres.GenresFragment
import io.github.muntashirakon.music.fragments.home.BannerHomeFragment
import io.github.muntashirakon.music.fragments.mainactivity.FoldersFragment
import io.github.muntashirakon.music.fragments.playlists.PlaylistsFragment
import io.github.muntashirakon.music.fragments.queue.PlayingQueueFragment
import io.github.muntashirakon.music.fragments.songs.SongsFragment
@ -60,7 +60,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
const val EXPAND_PANEL = "expand_panel"
}
val libraryViewModel: LibraryViewModel by inject()
private val libraryViewModel: LibraryViewModel by inject()
private var cab: MaterialCab? = null
private val intentFilter = IntentFilter(Intent.ACTION_SCREEN_OFF)
private lateinit var currentFragment: MainActivityFragmentCallbacks
@ -157,7 +157,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_IF_ROOM)
}
val fragment: Fragment? = getCurrentFragment()
if (fragment != null && fragment is AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>) {
if (fragment != null && fragment is AbsRecyclerViewCustomGridSizeFragment<*, *>) {
val gridSizeItem: MenuItem = menu.findItem(R.id.action_grid_size)
if (RetroUtil.isLandscape()) {
gridSizeItem.setTitle(R.string.action_grid_size_land)
@ -187,7 +187,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
override fun onOptionsItemSelected(item: MenuItem): Boolean {
val fragment = getCurrentFragment()
if (fragment is AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>) {
if (fragment is AbsRecyclerViewCustomGridSizeFragment<*, *>) {
if (handleGridSizeMenuItem(fragment, item)) {
return true
}
@ -221,7 +221,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
}
private fun handleSortOrderMenuItem(
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
fragment: AbsRecyclerViewCustomGridSizeFragment<*, *>,
item: MenuItem
): Boolean {
var sortOrder: String? = null
@ -265,7 +265,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
}
private fun handleLayoutResType(
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
fragment: AbsRecyclerViewCustomGridSizeFragment<*, *>,
item: MenuItem
): Boolean {
var layoutRes = -1
@ -286,7 +286,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
}
private fun handleGridSizeMenuItem(
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
fragment: AbsRecyclerViewCustomGridSizeFragment<*, *>,
item: MenuItem
): Boolean {
var gridSize = 0
@ -309,7 +309,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
}
private fun setUpGridSizeMenu(
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
fragment: AbsRecyclerViewCustomGridSizeFragment<*, *>,
gridSizeMenu: SubMenu
) {
when (fragment.getGridSize()) {
@ -344,7 +344,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
}
private fun setupLayoutMenu(
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
fragment: AbsRecyclerViewCustomGridSizeFragment<*, *>,
subMenu: SubMenu
) {
when (fragment.itemLayoutRes()) {
@ -366,7 +366,7 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
}
private fun setUpSortOrderMenu(
fragment: AbsLibraryPagerRecyclerViewCustomGridSizeFragment<*, *>,
fragment: AbsRecyclerViewCustomGridSizeFragment<*, *>,
sortOrderMenu: SubMenu
) {
val currentSortOrder = fragment.getSortOrder()
@ -532,8 +532,13 @@ class MainActivity : AbsSlidingMusicPanelActivity(),
fragment: Fragment,
tag: String
) {
supportFragmentManager.commit {
setCustomAnimations(
R.anim.retro_fragment_open_enter,
R.anim.retro_fragment_open_exit,
R.anim.retro_fragment_fade_enter,
R.anim.retro_fragment_fade_exit
)
replace(R.id.fragment_container, fragment, tag)
}
currentFragment = fragment as MainActivityFragmentCallbacks

View file

@ -4,19 +4,23 @@ import android.os.Bundle
import android.view.MenuItem
import androidx.annotation.StringRes
import androidx.fragment.app.Fragment
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.AppBarConfiguration
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.VersionUtils
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.activities.base.AbsBaseActivity
import io.github.muntashirakon.music.appshortcuts.DynamicShortcutManager
import io.github.muntashirakon.music.extensions.applyToolbar
import io.github.muntashirakon.music.fragments.settings.MainSettingsFragment
import com.afollestad.materialdialogs.color.ColorChooserDialog
import kotlinx.android.synthetic.main.activity_settings.*
class SettingsActivity : AbsBaseActivity(), ColorChooserDialog.ColorCallback {
private val fragmentManager = supportFragmentManager
private lateinit var appBarConfiguration: AppBarConfiguration
private lateinit var navController: NavController
override fun onCreate(savedInstanceState: Bundle?) {
setDrawUnderStatusBar()
@ -26,16 +30,25 @@ class SettingsActivity : AbsBaseActivity(), ColorChooserDialog.ColorCallback {
setNavigationbarColorAuto()
setLightNavigationBar(true)
setupToolbar()
if (savedInstanceState == null) {
fragmentManager.beginTransaction().replace(R.id.contentFrame, MainSettingsFragment())
.commit()
}
}
private fun setupToolbar() {
setTitle(R.string.action_settings)
applyToolbar(toolbar)
val navHostFragment =
supportFragmentManager.findFragmentById(R.id.contentFrame) as NavHostFragment
val navController: NavController = navHostFragment.navController
navController.addOnDestinationChangedListener { _, _, _ ->
toolbar.title = navController.currentDestination?.label
}
//It removes the back button
//appBarConfiguration = AppBarConfiguration(navController.graph)
//setupActionBarWithNavController(navController, appBarConfiguration)
}
override fun onSupportNavigateUp(): Boolean {
return navController.navigateUp() || super.onSupportNavigateUp()
}
fun setupFragment(fragment: Fragment, @StringRes titleName: Int) {

View file

@ -8,7 +8,6 @@ import android.view.Menu
import android.view.MenuItem
import android.view.SubMenu
import android.view.View
import android.widget.ImageView
import androidx.core.app.ActivityCompat
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.GridLayoutManager
@ -25,7 +24,6 @@ import io.github.muntashirakon.music.adapter.song.SimpleSongAdapter
import io.github.muntashirakon.music.dialogs.AddToPlaylistDialog
import io.github.muntashirakon.music.dialogs.DeleteSongsDialog
import io.github.muntashirakon.music.extensions.extraNotNull
import io.github.muntashirakon.music.extensions.ripAlpha
import io.github.muntashirakon.music.extensions.show
import io.github.muntashirakon.music.extensions.surfaceColor
import io.github.muntashirakon.music.glide.AlbumGlideRequest
@ -43,7 +41,7 @@ import com.afollestad.materialcab.MaterialCab
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.activity_album.*
import kotlinx.android.synthetic.main.activity_album_content.*
import org.koin.android.viewmodel.ext.android.viewModel
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.parameter.parametersOf
import java.util.*
import android.util.Pair as UtilPair
@ -68,12 +66,11 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder {
return cab as MaterialCab
}
private val detailsViewModel: AlbumDetailsViewModel by viewModel {
private val detailsViewModel by viewModel<AlbumDetailsViewModel> {
parametersOf(extraNotNull<Int>(EXTRA_ALBUM_ID).value)
}
private lateinit var simpleSongAdapter: SimpleSongAdapter
private lateinit var album: Album
private lateinit var artistImage: ImageView
private var cab: MaterialCab? = null
private val savedSortOrder: String
get() = PreferenceUtil.albumDetailSongSortOrder
@ -101,24 +98,25 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder {
setBottomBarVisibility(View.GONE)
window.sharedElementsUseOverlay = true
windowEnterTransition()
toolbar.setBackgroundColor(surfaceColor())
addMusicServiceEventListener(detailsViewModel)
ActivityCompat.postponeEnterTransition(this)
//val viewModelFactory = AlbumDetailsViewModelFactory(application, albumId)
//viewModel = ViewModelProvider(this, viewModelFactory).get(AlbumDetailsViewModel::class.java)
detailsViewModel.getAlbum().observe(this, androidx.lifecycle.Observer {
ActivityCompat.startPostponedEnterTransition(this@AlbumDetailsActivity)
album(it)
showAlbum(it)
})
detailsViewModel.getArtist().observe(this, androidx.lifecycle.Observer {
loadArtistImage(it)
})
detailsViewModel.getMoreAlbums().observe(this, androidx.lifecycle.Observer {
moreAlbums(it)
})
detailsViewModel.getAlbumInfo().observe(this, androidx.lifecycle.Observer {
aboutAlbum(it)
})
setupRecyclerView()
artistImage = findViewById(R.id.artistImage)
artistImage.setOnClickListener {
val artistPairs = ActivityOptions.makeSceneTransitionAnimation(
this,
@ -155,12 +153,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder {
}
}
fun complete() {
ActivityCompat.startPostponedEnterTransition(this)
}
fun album(album: Album) {
complete()
private fun showAlbum(album: Album) {
if (album.songs!!.isEmpty()) {
finish()
return
@ -196,7 +189,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder {
detailsViewModel.loadAlbumInfo(album)
}
fun moreAlbums(albums: List<Album>) {
private fun moreAlbums(albums: List<Album>) {
moreTitle.show()
moreRecyclerView.show()
moreTitle.text = String.format(getString(R.string.label_more_from), album.artistName)
@ -211,7 +204,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder {
moreRecyclerView.adapter = albumAdapter
}
fun aboutAlbum(lastFmAlbum: LastFmAlbum) {
private fun aboutAlbum(lastFmAlbum: LastFmAlbum) {
if (lastFmAlbum.album != null) {
if (lastFmAlbum.album.wiki != null) {
aboutAlbumText.show()
@ -232,7 +225,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder {
}
}
fun loadArtistImage(artist: Artist) {
private fun loadArtistImage(artist: Artist) {
ArtistGlideRequest.Builder.from(Glide.with(this), artist)
.generatePalette(this)
.build()
@ -260,15 +253,17 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder {
}
private fun setColors(color: MediaNotificationProcessor) {
val buttonColor = if (PreferenceUtil.isAdaptiveColor)
color.backgroundColor.ripAlpha()
else
ATHUtil.resolveColor(this, R.attr.colorSurface)
MaterialUtil.tintColor(
button = shuffleAction,
textColor = color.primaryTextColor,
backgroundColor = color.backgroundColor
)
MaterialUtil.tintColor(
button = playAction,
textColor = color.primaryTextColor,
backgroundColor = color.backgroundColor
)
MaterialUtil.setTint(button = shuffleAction, color = buttonColor)
MaterialUtil.setTint(button = playAction, color = buttonColor)
toolbar.setBackgroundColor(surfaceColor())
setSupportActionBar(toolbar)
supportActionBar?.title = null
}

View file

@ -0,0 +1,250 @@
package code.name.monkey.retromusic.activities.albums
import android.app.ActivityOptions
import android.os.Bundle
import android.transition.TransitionInflater
import android.util.Pair
import android.view.MenuItem
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.fragment.findNavController
import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import code.name.monkey.appthemehelper.util.MaterialUtil
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
import code.name.monkey.retromusic.extensions.extraNotNull
import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
import code.name.monkey.retromusic.glide.AlbumGlideRequest
import code.name.monkey.retromusic.glide.ArtistGlideRequest
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.model.Album
import code.name.monkey.retromusic.model.Artist
import code.name.monkey.retromusic.network.model.LastFmAlbum
import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.NavigationUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.activity_album.*
import kotlinx.android.synthetic.main.activity_album_content.*
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.parameter.parametersOf
import java.util.*
class AlbumDetailsFragment : AbsMusicServiceFragment(R.layout.fragment_album_details) {
private lateinit var simpleSongAdapter: SimpleSongAdapter
private lateinit var album: Album
private val savedSortOrder: String
get() = PreferenceUtil.albumDetailSongSortOrder
private val detailsViewModel by viewModel<AlbumDetailsViewModel> {
parametersOf(extraNotNull<Int>(AlbumDetailsActivity.EXTRA_ALBUM_ID).value)
}
private fun setSharedElementTransitionOnEnter() {
sharedElementEnterTransition = TransitionInflater.from(context)
.inflateTransition(R.transition.change_bounds)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
setSharedElementTransitionOnEnter()
postponeEnterTransition()
playerActivity?.addMusicServiceEventListener(detailsViewModel)
detailsViewModel.getAlbum().observe(viewLifecycleOwner, androidx.lifecycle.Observer {
startPostponedEnterTransition()
showAlbum(it)
})
detailsViewModel.getArtist().observe(viewLifecycleOwner, androidx.lifecycle.Observer {
loadArtistImage(it)
})
detailsViewModel.getMoreAlbums().observe(viewLifecycleOwner, androidx.lifecycle.Observer {
moreAlbums(it)
})
detailsViewModel.getAlbumInfo().observe(viewLifecycleOwner, androidx.lifecycle.Observer {
aboutAlbum(it)
})
setupRecyclerView()
artistImage.setOnClickListener {
val artistPairs = ActivityOptions.makeSceneTransitionAnimation(
requireActivity(),
Pair.create(
artistImage,
getString(R.string.transition_artist_image)
)
)
NavigationUtil.goToArtistOptions(requireActivity(), album.artistId, artistPairs)
}
playAction.setOnClickListener { MusicPlayerRemote.openQueue(album.songs!!, 0, true) }
shuffleAction.setOnClickListener {
MusicPlayerRemote.openAndShuffleQueue(
album.songs!!,
true
)
}
aboutAlbumText.setOnClickListener {
if (aboutAlbumText.maxLines == 4) {
aboutAlbumText.maxLines = Integer.MAX_VALUE
} else {
aboutAlbumText.maxLines = 4
}
}
image.apply {
transitionName = getString(R.string.transition_album_art)
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val activity = activity as AppCompatActivity
activity.supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
override fun onDestroy() {
super.onDestroy()
playerActivity?.removeMusicServiceEventListener(detailsViewModel)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
android.R.id.home -> findNavController().navigateUp()
}
return super.onOptionsItemSelected(item)
}
private fun setupRecyclerView() {
simpleSongAdapter = SimpleSongAdapter(
requireActivity() as AppCompatActivity,
ArrayList(),
R.layout.item_song,
null
)
recyclerView.apply {
layoutManager = LinearLayoutManager(requireContext())
itemAnimator = DefaultItemAnimator()
isNestedScrollingEnabled = false
adapter = simpleSongAdapter
}
}
private fun showAlbum(album: Album) {
if (album.songs!!.isEmpty()) {
return
}
this.album = album
albumTitle.text = album.title
val songText =
resources.getQuantityString(
R.plurals.albumSongs,
album.songCount,
album.songCount
)
songTitle.text = songText
if (MusicUtil.getYearString(album.year) == "-") {
albumText.text = String.format(
"%s • %s",
album.artistName,
MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(album.songs))
)
} else {
albumText.text = String.format(
"%s • %s • %s",
album.artistName,
MusicUtil.getYearString(album.year),
MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(album.songs))
)
}
loadAlbumCover()
simpleSongAdapter.swapDataSet(album.songs)
detailsViewModel.loadArtist(album.artistId)
detailsViewModel.loadAlbumInfo(album)
}
private fun moreAlbums(albums: List<Album>) {
moreTitle.show()
moreRecyclerView.show()
moreTitle.text = String.format(getString(R.string.label_more_from), album.artistName)
val albumAdapter =
HorizontalAlbumAdapter(requireActivity() as AppCompatActivity, albums, null)
moreRecyclerView.layoutManager = GridLayoutManager(
requireContext(),
1,
GridLayoutManager.HORIZONTAL,
false
)
moreRecyclerView.adapter = albumAdapter
}
private fun aboutAlbum(lastFmAlbum: LastFmAlbum) {
if (lastFmAlbum.album != null) {
if (lastFmAlbum.album.wiki != null) {
aboutAlbumText.show()
aboutAlbumTitle.show()
aboutAlbumTitle.text =
String.format(getString(R.string.about_album_label), lastFmAlbum.album.name)
aboutAlbumText.text = lastFmAlbum.album.wiki.content
}
if (lastFmAlbum.album.listeners.isNotEmpty()) {
listeners.show()
listenersLabel.show()
scrobbles.show()
scrobblesLabel.show()
listeners.text = RetroUtil.formatValue(lastFmAlbum.album.listeners.toFloat())
scrobbles.text = RetroUtil.formatValue(lastFmAlbum.album.playcount.toFloat())
}
}
}
private fun loadArtistImage(artist: Artist) {
ArtistGlideRequest.Builder.from(Glide.with(requireContext()), artist)
.generatePalette(requireContext())
.build()
.dontAnimate()
.dontTransform()
.into(object : RetroMusicColoredTarget(artistImage) {
override fun onColorReady(colors: MediaNotificationProcessor) {
}
})
}
private fun loadAlbumCover() {
AlbumGlideRequest.Builder.from(Glide.with(requireContext()), album.safeGetFirstSong())
.checkIgnoreMediaStore(requireContext())
.ignoreMediaStore(PreferenceUtil.isIgnoreMediaStoreArtwork)
.generatePalette(requireContext())
.build()
.dontAnimate()
.dontTransform()
.into(object : RetroMusicColoredTarget(image) {
override fun onColorReady(colors: MediaNotificationProcessor) {
setColors(colors)
}
})
}
private fun setColors(color: MediaNotificationProcessor) {
MaterialUtil.tintColor(
button = shuffleAction,
textColor = color.primaryTextColor,
backgroundColor = color.backgroundColor
)
MaterialUtil.tintColor(
button = playAction,
textColor = color.primaryTextColor,
backgroundColor = color.backgroundColor
)
}
}

View file

@ -7,8 +7,8 @@ import androidx.lifecycle.viewModelScope
import io.github.muntashirakon.music.interfaces.MusicServiceEventListener
import io.github.muntashirakon.music.model.Album
import io.github.muntashirakon.music.model.Artist
import io.github.muntashirakon.music.providers.RepositoryImpl
import io.github.muntashirakon.music.network.model.LastFmAlbum
import io.github.muntashirakon.music.providers.RepositoryImpl
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
@ -23,10 +23,12 @@ class AlbumDetailsViewModel(
private val _album = MutableLiveData<Album>()
private val _artist = MutableLiveData<Artist>()
private val _lastFmAlbum = MutableLiveData<LastFmAlbum>()
private val _moreAlbums = MutableLiveData<List<Album>>()
fun getAlbum(): LiveData<Album> = _album
fun getArtist(): LiveData<Artist> = _artist
fun getAlbumInfo(): LiveData<LastFmAlbum> = _lastFmAlbum
fun getMoreAlbums(): LiveData<List<Album>> = _moreAlbums
init {
loadAlbumDetails()
@ -49,6 +51,10 @@ class AlbumDetailsViewModel(
fun loadArtist(artistId: Int) = viewModelScope.launch(Dispatchers.IO) {
val artist = repository.artistById(artistId)
_artist.postValue(artist)
artist.albums?.filter { item -> item.id != albumId }?.let { albums ->
if (albums.isNotEmpty()) _moreAlbums.postValue(albums)
}
}
private val loadAlbumAsync: Deferred<Album?>

View file

@ -22,7 +22,6 @@ import io.github.muntashirakon.music.adapter.album.HorizontalAlbumAdapter
import io.github.muntashirakon.music.adapter.song.SimpleSongAdapter
import io.github.muntashirakon.music.dialogs.AddToPlaylistDialog
import io.github.muntashirakon.music.extensions.extraNotNull
import io.github.muntashirakon.music.extensions.ripAlpha
import io.github.muntashirakon.music.extensions.show
import io.github.muntashirakon.music.extensions.surfaceColor
import io.github.muntashirakon.music.glide.ArtistGlideRequest
@ -31,13 +30,16 @@ import io.github.muntashirakon.music.helper.MusicPlayerRemote
import io.github.muntashirakon.music.interfaces.CabHolder
import io.github.muntashirakon.music.model.Artist
import io.github.muntashirakon.music.network.model.LastFmArtist
import io.github.muntashirakon.music.util.*
import io.github.muntashirakon.music.util.CustomArtistImageUtil
import io.github.muntashirakon.music.util.MusicUtil
import io.github.muntashirakon.music.util.RetroColorUtil
import io.github.muntashirakon.music.util.RetroUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import com.afollestad.materialcab.MaterialCab
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.activity_artist_content.*
import kotlinx.android.synthetic.main.activity_artist_details.*
import org.koin.android.viewmodel.ext.android.viewModel
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.parameter.parametersOf
import java.util.*
import kotlin.collections.ArrayList
@ -95,8 +97,11 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder {
setBottomBarVisibility(View.GONE)
window.sharedElementsUseOverlay = true
windowEnterTransition()
ActivityCompat.postponeEnterTransition(this)
toolbar.setBackgroundColor(surfaceColor())
addMusicServiceEventListener(detailsViewModel)
ActivityCompat.postponeEnterTransition(this)
detailsViewModel.getArtist().observe(this, androidx.lifecycle.Observer {
ActivityCompat.startPostponedEnterTransition(this@ArtistDetailActivity)
artist(it)
@ -150,18 +155,12 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder {
}
}
fun complete() {
ActivityCompat.startPostponedEnterTransition(this)
}
fun artist(artist: Artist) {
complete()
if (artist.songCount <= 0) {
if (artist.songs.isEmpty()) {
finish()
}
this.artist = artist
loadArtistImage()
loadArtistImage(artist)
if (RetroUtil.isAllowedToDownloadMetadata(this)) {
loadBiography(artist.name)
}
@ -186,7 +185,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder {
songTitle.text = songText
albumTitle.text = albumText
songAdapter.swapDataSet(artist.songs)
albumAdapter.swapDataSet(artist.albums!!)
artist.albums?.let { albumAdapter.swapDataSet(it) }
}
private fun loadBiography(
@ -198,7 +197,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder {
detailsViewModel.loadBiography(name, lang, null)
}
fun artistInfo(lastFmArtist: LastFmArtist?) {
private fun artistInfo(lastFmArtist: LastFmArtist?) {
if (lastFmArtist != null && lastFmArtist.artist != null) {
val bioContent = lastFmArtist.artist.bio.content
if (bioContent != null && bioContent.trim { it <= ' ' }.isNotEmpty()) {
@ -211,7 +210,6 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder {
listenersLabel.show()
scrobbles.show()
scrobblesLabel.show()
listeners.text =
RetroUtil.formatValue(lastFmArtist.artist.stats.listeners.toFloat())
scrobbles.text =
@ -228,8 +226,9 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder {
private var lang: String? = null
private fun loadArtistImage() {
ArtistGlideRequest.Builder.from(Glide.with(this), artist).generatePalette(this).build()
private fun loadArtistImage(artist: Artist) {
ArtistGlideRequest.Builder.from(Glide.with(this), artist)
.generatePalette(this).build()
.dontAnimate().into(object : RetroMusicColoredTarget(image) {
override fun onColorReady(colors: MediaNotificationProcessor) {
setColors(colors)
@ -238,16 +237,16 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), CabHolder {
}
private fun setColors(color: MediaNotificationProcessor) {
val buttonColor = if (PreferenceUtil.isAdaptiveColor)
color.backgroundColor.ripAlpha()
else
ATHUtil.resolveColor(this, R.attr.colorSurface)
MaterialUtil.setTint(button = shuffleAction, color = buttonColor)
MaterialUtil.setTint(button = playAction, color = buttonColor)
toolbar.setBackgroundColor(surfaceColor())
MaterialUtil.tintColor(
button = shuffleAction,
textColor = color.primaryTextColor,
backgroundColor = color.backgroundColor
)
MaterialUtil.tintColor(
button = playAction,
textColor = color.primaryTextColor,
backgroundColor = color.backgroundColor
)
setSupportActionBar(toolbar)
supportActionBar?.title = null
}

View file

@ -1,6 +1,5 @@
package io.github.muntashirakon.music.activities.base
import android.animation.ValueAnimator
import android.graphics.Color
import android.os.Bundle
import android.view.View
@ -8,61 +7,41 @@ import android.view.ViewGroup
import android.view.ViewTreeObserver
import android.widget.FrameLayout
import androidx.annotation.LayoutRes
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.RetroBottomSheetBehavior
import io.github.muntashirakon.music.extensions.hide
import io.github.muntashirakon.music.extensions.show
import io.github.muntashirakon.music.fragments.LibraryViewModel
import io.github.muntashirakon.music.fragments.MiniPlayerFragment
import io.github.muntashirakon.music.fragments.NowPlayingScreen
import io.github.muntashirakon.music.fragments.NowPlayingScreen.*
import io.github.muntashirakon.music.fragments.base.AbsPlayerFragment
import io.github.muntashirakon.music.fragments.player.adaptive.AdaptiveFragment
import io.github.muntashirakon.music.fragments.player.blur.BlurPlayerFragment
import io.github.muntashirakon.music.fragments.player.card.CardFragment
import io.github.muntashirakon.music.fragments.player.cardblur.CardBlurFragment
import io.github.muntashirakon.music.fragments.player.circle.CirclePlayerFragment
import io.github.muntashirakon.music.fragments.player.classic.ClassicPlayerFragment
import io.github.muntashirakon.music.fragments.player.color.ColorFragment
import io.github.muntashirakon.music.fragments.player.fit.FitFragment
import io.github.muntashirakon.music.fragments.player.flat.FlatPlayerFragment
import io.github.muntashirakon.music.fragments.player.full.FullPlayerFragment
import io.github.muntashirakon.music.fragments.player.gradient.GradientPlayerFragment
import io.github.muntashirakon.music.fragments.player.material.MaterialFragment
import io.github.muntashirakon.music.fragments.player.normal.PlayerFragment
import io.github.muntashirakon.music.fragments.player.peak.PeakPlayerFragment
import io.github.muntashirakon.music.fragments.player.plain.PlainPlayerFragment
import io.github.muntashirakon.music.fragments.player.simple.SimplePlayerFragment
import io.github.muntashirakon.music.fragments.player.tiny.TinyPlayerFragment
import io.github.muntashirakon.music.helper.MusicPlayerRemote
import io.github.muntashirakon.music.model.CategoryInfo
import io.github.muntashirakon.music.util.DensityUtil
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.views.BottomNavigationBarTinted
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.shape.MaterialShapeDrawable
import com.google.android.material.shape.ShapeAppearanceModel
import kotlinx.android.synthetic.main.sliding_music_panel_layout.*
import org.koin.androidx.viewmodel.ext.android.viewModel
abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
AbsPlayerFragment.Callbacks {
abstract class AbsSlidingMusicPanelActivity() : AbsMusicServiceActivity() {
companion object {
val TAG: String = AbsSlidingMusicPanelActivity::class.java.simpleName
}
private val libraryViewModel by viewModel<LibraryViewModel>()
private lateinit var behavior: RetroBottomSheetBehavior<FrameLayout>
private var miniPlayerFragment: MiniPlayerFragment? = null
private var playerFragment: AbsPlayerFragment? = null
private var cps: NowPlayingScreen? = null
private var navigationBarColor: Int = 0
private var taskColor: Int = 0
private var lightStatusBar: Boolean = false
private var lightNavigationBar: Boolean = false
private var navigationBarColorAnimator: ValueAnimator? = null
private var paletteColor: Int = Color.WHITE
protected abstract fun createContentView(): View
private lateinit var shapeDrawable: MaterialShapeDrawable
private val panelState: Int
get() = behavior.state
@ -72,7 +51,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
setMiniPlayerAlphaProgress(slideOffset)
dimBackground.show()
dimBackground.alpha = slideOffset
shapeDrawable.interpolation = 1 - slideOffset
}
override fun onStateChanged(bottomSheet: View, newState: Int) {
@ -91,35 +69,29 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
}
}
fun getBottomSheetBehavior() = behavior
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(createContentView())
chooseFragmentForTheme()
setupSlidingUpPanel()
addMusicServiceEventListener(libraryViewModel)
behavior = BottomSheetBehavior.from(slidingPanel) as RetroBottomSheetBehavior
setupBottomSheet()
val themeColor = ATHUtil.resolveColor(this, android.R.attr.windowBackground, Color.GRAY)
dimBackground.setBackgroundColor(ColorUtil.withAlpha(themeColor, 0.5f))
shapeDrawable = MaterialShapeDrawable(
ShapeAppearanceModel.builder(
this,
R.style.ClassicThemeOverLay,
0
).build()
)
slidingPanel.background = shapeDrawable
libraryViewModel.paletteColorLiveData.observe(this, Observer {
this.paletteColor = it
onPaletteColorChanged()
})
}
override fun onResume() {
super.onResume()
if (cps != PreferenceUtil.nowPlayingScreen) {
postRecreate()
}
fun getBottomSheetBehavior() = behavior
private fun setupBottomSheet() {
behavior = BottomSheetBehavior.from(slidingPanel) as RetroBottomSheetBehavior
behavior.addBottomSheetCallback(bottomSheetCallbackList)
if (behavior.state == BottomSheetBehavior.STATE_EXPANDED) {
@ -127,17 +99,23 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
}
}
override fun onResume() {
super.onResume()
if (cps != PreferenceUtil.nowPlayingScreen) {
postRecreate()
}
}
override fun onDestroy() {
super.onDestroy()
behavior.removeBottomSheetCallback(bottomSheetCallbackList)
if (navigationBarColorAnimator != null) navigationBarColorAnimator?.cancel() // just in case
}
protected fun wrapSlidingMusicPanel(@LayoutRes resId: Int): View {
val slidingMusicPanelLayout =
layoutInflater.inflate(R.layout.sliding_music_panel_layout, null)
val contentContainer =
slidingMusicPanelLayout.findViewById<ViewGroup>(R.id.mainContentFrame)
val contentContainer: ViewGroup =
slidingMusicPanelLayout.findViewById(R.id.mainContentFrame)
layoutInflater.inflate(resId, contentContainer)
return slidingMusicPanelLayout
}
@ -159,7 +137,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
miniPlayerFragment?.view?.visibility = if (alpha == 0f) View.GONE else View.VISIBLE
bottomNavigationView.translationY = progress * 500
//bottomNavigationView.alpha = alpha
bottomNavigationView.alpha = alpha
}
open fun onPanelCollapsed() {
@ -168,20 +146,9 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
super.setTaskDescriptionColor(taskColor)
super.setNavigationbarColor(navigationBarColor)
super.setLightNavigationBar(lightNavigationBar)
playerFragment?.setMenuVisibility(false)
playerFragment?.userVisibleHint = false
playerFragment?.onHide()
}
open fun onPanelExpanded() {
val playerFragmentColor = playerFragment!!.paletteColor
super.setTaskDescriptionColor(playerFragmentColor)
playerFragment?.setMenuVisibility(true)
playerFragment?.userVisibleHint = true
playerFragment?.onShow()
onPaletteColorChanged()
}
@ -190,15 +157,12 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() {
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
if (cps != Peak) {
val params = slidingPanel.layoutParams as ViewGroup.LayoutParams
params.height = ViewGroup.LayoutParams.MATCH_PARENT
slidingPanel.layoutParams = params
}
when (panelState) {
BottomSheetBehavior.STATE_EXPANDED -> onPanelExpanded()
BottomSheetBehavior.STATE_COLLAPSED -> onPanelCollapsed()
else -> playerFragment!!.onHide()
else -> {
//playerFragment!!.onHide()
}
}
}
})
@ -240,33 +204,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
private fun chooseFragmentForTheme() {
cps = PreferenceUtil.nowPlayingScreen
val fragment: Fragment = when (cps) {
Blur -> BlurPlayerFragment()
Adaptive -> AdaptiveFragment()
Normal -> PlayerFragment()
Card -> CardFragment()
BlurCard -> CardBlurFragment()
Fit -> FitFragment()
Flat -> FlatPlayerFragment()
Full -> FullPlayerFragment()
Plain -> PlainPlayerFragment()
Simple -> SimplePlayerFragment()
Material -> MaterialFragment()
Color -> ColorFragment()
Tiny -> TinyPlayerFragment()
Peak -> PeakPlayerFragment()
Circle -> CirclePlayerFragment()
Classic -> ClassicPlayerFragment()
Gradient -> GradientPlayerFragment()
else -> PlayerFragment()
} // must implement AbsPlayerFragment
supportFragmentManager.beginTransaction()
.replace(R.id.playerFragmentContainer, fragment)
.commit()
supportFragmentManager.executePendingTransactions()
playerFragment =
supportFragmentManager.findFragmentById(R.id.playerFragmentContainer) as AbsPlayerFragment
miniPlayerFragment =
supportFragmentManager.findFragmentById(R.id.miniPlayerFragment) as MiniPlayerFragment
miniPlayerFragment?.view?.setOnClickListener { expandPanel() }
@ -295,7 +232,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
}
open fun handleBackPress(): Boolean {
if (behavior.peekHeight != 0 && playerFragment!!.onBackPressed()) return true
if (panelState == BottomSheetBehavior.STATE_EXPANDED) {
collapsePanel()
return true
@ -303,13 +240,10 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
return false
}
override fun onPaletteColorChanged() {
private fun onPaletteColorChanged() {
if (panelState == BottomSheetBehavior.STATE_EXPANDED) {
val paletteColor = playerFragment!!.paletteColor
super.setTaskDescriptionColor(paletteColor)
val isColorLight = ColorUtil.isColorLight(paletteColor)
if (PreferenceUtil.isAdaptiveColor && (cps == Normal || cps == Flat)) {
super.setLightNavigationBar(true)
super.setLightStatusbar(isColorLight)
@ -360,7 +294,6 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity(),
override fun setNavigationbarColor(color: Int) {
navigationBarColor = color
if (panelState == BottomSheetBehavior.STATE_COLLAPSED) {
if (navigationBarColorAnimator != null) navigationBarColorAnimator!!.cancel()
super.setNavigationbarColor(color)
}
}

View file

@ -21,7 +21,7 @@ import io.github.muntashirakon.music.util.DensityUtil
import io.github.muntashirakon.music.util.RetroColorUtil
import com.afollestad.materialcab.MaterialCab
import kotlinx.android.synthetic.main.activity_playlist_detail.*
import org.koin.android.viewmodel.ext.android.viewModel
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.parameter.parametersOf
import java.util.*

View file

@ -29,7 +29,7 @@ import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemA
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils
import kotlinx.android.synthetic.main.activity_playlist_detail.*
import org.koin.android.viewmodel.ext.android.viewModel
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.parameter.parametersOf

View file

@ -51,6 +51,7 @@ class HomeAdapter(
.inflate(R.layout.metal_section_recycler_view, parent, false)
)
}
GENRES -> GenreViewHolder(layout)
FAVOURITES -> PlaylistViewHolder(layout)
else -> {
SuggestionsViewHolder(
@ -104,6 +105,10 @@ class HomeAdapter(
R.string.favorites
)
}
GENRES -> {
val viewHolder = holder as GenreViewHolder
viewHolder.bind(list[position].arrayList as List<Genre>, R.string.genres)
}
}
}
@ -118,7 +123,15 @@ class HomeAdapter(
companion object {
@IntDef(RECENT_ALBUMS, TOP_ALBUMS, RECENT_ARTISTS, TOP_ARTISTS, SUGGESTIONS, FAVOURITES)
@IntDef(
RECENT_ALBUMS,
TOP_ALBUMS,
RECENT_ARTISTS,
TOP_ARTISTS,
SUGGESTIONS,
FAVOURITES,
GENRES
)
@Retention(AnnotationRetention.SOURCE)
annotation class HomeSection
@ -128,6 +141,7 @@ class HomeAdapter(
const val TOP_ARTISTS = 0
const val SUGGESTIONS = 5
const val FAVOURITES = 4
const val GENRES = 6
}
private inner class AlbumViewHolder(view: View) : AbsHomeViewItem(view) {
@ -215,6 +229,18 @@ class HomeAdapter(
}
}
private inner class GenreViewHolder(itemView: View) : AbsHomeViewItem(itemView) {
fun bind(genres: List<Genre>, titleRes: Int) {
title.text = activity.getString(titleRes)
recyclerView.apply {
show()
layoutManager = GridLayoutManager(activity, 2, GridLayoutManager.HORIZONTAL, false)
val genreAdapter = GenreAdapter(activity, genres, R.layout.item_grid_genre)
adapter = genreAdapter
}
}
}
open inner class AbsHomeViewItem(itemView: View) : RecyclerView.ViewHolder(itemView) {
val recyclerView: RecyclerView = itemView.findViewById(R.id.recyclerView)
val title: AppCompatTextView = itemView.findViewById(R.id.title)

View file

@ -3,7 +3,6 @@ package io.github.muntashirakon.music.adapter.album
import android.app.ActivityOptions
import android.content.res.ColorStateList
import android.content.res.Resources
import android.graphics.drawable.Drawable
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
@ -106,10 +105,6 @@ open class AlbumAdapter(
.generatePalette(activity)
.build()
.into(object : RetroMusicColoredTarget(holder.image!!) {
override fun onLoadCleared(placeholder: Drawable?) {
super.onLoadCleared(placeholder)
//setColors(defaultFooterColor, holder)
}
override fun onColorReady(colors: MediaNotificationProcessor) {
setColors(colors, holder)

View file

@ -7,6 +7,7 @@ import android.view.ViewGroup
import android.widget.ImageView
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.lifecycleScope
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.fragments.AlbumCoverStyle
import io.github.muntashirakon.music.fragments.NowPlayingScreen.*
@ -21,7 +22,6 @@ import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import com.bumptech.glide.Glide
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@ -68,7 +68,7 @@ class AlbumCoverPagerAdapter(
class AlbumCoverFragment : Fragment() {
lateinit var albumCover: ImageView
private lateinit var albumCover: ImageView
private var isColorReady: Boolean = false
private lateinit var color: MediaNotificationProcessor
private lateinit var song: Song
@ -96,7 +96,7 @@ class AlbumCoverPagerAdapter(
}
private fun showLyricsDialog() {
GlobalScope.launch(Dispatchers.IO) {
lifecycleScope.launch(Dispatchers.IO) {
val data = MusicUtil.getLyrics(song)
withContext(Dispatchers.Main) {
MaterialAlertDialogBuilder(
@ -116,7 +116,7 @@ class AlbumCoverPagerAdapter(
private fun getLayoutWithPlayerTheme(): Int {
return when (PreferenceUtil.nowPlayingScreen) {
Card, Fit, Tiny, Classic, Peak, Gradient, Full -> R.layout.fragment_album_full_cover
Card, Fit, Tiny, Classic, Gradient, Full -> R.layout.fragment_album_full_cover
else -> {
if (PreferenceUtil.isCarouselEffect) {
R.layout.fragment_album_carousel_cover

View file

@ -36,9 +36,10 @@ class SearchShortCutType(context: Context) : BaseShortcutType(context) {
id
).setShortLabel(context.getString(R.string.action_search))
.setLongLabel(context.getString(R.string.search_hint)).setIcon(
AppShortcutIconGenerator.generateThemedIcon(
context,
R.drawable.ic_app_shortcut_search
)
).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_SEARCH)).build()
AppShortcutIconGenerator.generateThemedIcon(
context,
R.drawable.ic_app_shortcut_search
)
).setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.SHORTCUT_TYPE_SEARCH))
.build()
}

View file

@ -88,19 +88,18 @@ public class BlacklistFolderChooserDialog extends DialogFragment implements Mate
parentFolder = new File(savedInstanceState.getString("current_path", File.pathSeparator));
checkIfCanGoUp();
parentContents = listFiles();
MaterialDialog.Builder builder =
new MaterialDialog.Builder(requireActivity())
.title(parentFolder.getAbsolutePath())
.items((CharSequence[]) getContentsArray())
.itemsCallback(this)
.autoDismiss(false)
.onPositive((dialog, which) -> {
dismiss();
callback.onFolderSelection(BlacklistFolderChooserDialog.this, parentFolder);
})
.onNegative((materialDialog, dialogAction) -> dismiss())
.positiveText(R.string.add_action)
.negativeText(android.R.string.cancel);
MaterialDialog.Builder builder = new MaterialDialog.Builder(requireContext())
.title(parentFolder.getAbsolutePath())
.items((CharSequence[]) getContentsArray())
.itemsCallback(this)
.autoDismiss(false)
.onPositive((dialog, which) -> {
callback.onFolderSelection(BlacklistFolderChooserDialog.this, parentFolder);
dismiss();
})
.onNegative((materialDialog, dialogAction) -> dismiss())
.positiveText(R.string.add_action)
.negativeText(android.R.string.cancel);
return builder.build();
}

View file

@ -4,7 +4,10 @@ import android.content.Context
import android.content.res.Configuration
import android.os.PowerManager
import androidx.annotation.IntegerRes
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.navigation.fragment.NavHostFragment
import io.github.muntashirakon.music.util.PreferenceUtil
fun Fragment.getIntRes(@IntegerRes int: Int): Int {
@ -36,4 +39,17 @@ inline fun <reified T : Any> Fragment.extra(key: String, default: T? = null) = l
inline fun <reified T : Any> Fragment.extraNotNull(key: String, default: T? = null) = lazy {
val value = arguments?.get(key)
requireNotNull(if (value is T) value else default) { key }
}
}
val NavHostFragment.currentFragment: Fragment?
get() = targetFragment
val FragmentManager.currentNavigationFragment: Fragment?
get() = primaryNavigationFragment?.childFragmentManager?.fragments?.first()
fun AppCompatActivity.currentFragment(navHostId: Int): Fragment? {
val navHostFragment: NavHostFragment =
supportFragmentManager.findFragmentById(navHostId) as NavHostFragment
navHostFragment.targetFragment
return navHostFragment?.childFragmentManager?.fragments?.first()
}

View file

@ -0,0 +1,20 @@
package code.name.monkey.retromusic.extensions
import androidx.annotation.IdRes
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.fragment.findNavController
fun Fragment.navigate(@IdRes id: Int) = findNavController().navigate(id)
fun Fragment.navController(@IdRes id: Int): NavController {
val fragment = childFragmentManager.findFragmentById(id) as NavHostFragment
return fragment.navController
}
fun AppCompatActivity.navController(@IdRes id: Int): NavController {
val fragment = supportFragmentManager.findFragmentById(id) as NavHostFragment
return fragment.navController
}

View file

@ -18,19 +18,21 @@ class LibraryViewModel(
private val repository: RepositoryImpl
) : ViewModel(), MusicServiceEventListener {
private val _albums = MutableLiveData<List<Album>>()
private val _songs = MutableLiveData<List<Song>>()
private val _artists = MutableLiveData<List<Artist>>()
private val _playlist = MutableLiveData<List<Playlist>>()
private val _genre = MutableLiveData<List<Genre>>()
private val _homeSections = MutableLiveData<List<Home>>()
private val albums = MutableLiveData<List<Album>>()
private val songs = MutableLiveData<List<Song>>()
private val artists = MutableLiveData<List<Artist>>()
private val playlists = MutableLiveData<List<Playlist>>()
private val genres = MutableLiveData<List<Genre>>()
private val home = MutableLiveData<List<Home>>()
private val paletteColor = MutableLiveData<Int>()
fun homeSections(): LiveData<List<Home>> = _homeSections
fun allAlbums(): LiveData<List<Album>> = _albums
fun allSongs(): LiveData<List<Song>> = _songs
fun allArtists(): LiveData<List<Artist>> = _artists
fun allPlaylisits(): LiveData<List<Playlist>> = _playlist
fun allGenres(): LiveData<List<Genre>> = _genre
val paletteColorLiveData: LiveData<Int> = paletteColor
val homeLiveData: LiveData<List<Home>> = home
val albumsLiveData: LiveData<List<Album>> = albums
val songsLiveData: LiveData<List<Song>> = songs
val artistsLiveData: LiveData<List<Artist>> = artists
val playlisitsLiveData: LiveData<List<Playlist>> = playlists
val genresLiveData: LiveData<List<Genre>> = genres
init {
viewModelScope.launch {
@ -39,11 +41,11 @@ class LibraryViewModel(
}
private fun loadLibraryContent() = viewModelScope.launch {
_songs.value = loadSongs.await()
_albums.value = loadAlbums.await()
_artists.value = loadArtists.await()
_playlist.value = loadPlaylists.await()
_genre.value = loadGenres.await()
songs.value = loadSongs.await()
albums.value = loadAlbums.await()
artists.value = loadArtists.await()
playlists.value = loadPlaylists.await()
genres.value = loadGenres.await()
loadHomeSections()
}
@ -55,7 +57,8 @@ class LibraryViewModel(
repository.recentArtists(),
repository.recentAlbums(),
repository.suggestions(),
repository.favoritePlaylist()
repository.favoritePlaylist(),
repository.homeGenres()
)
result.forEach {
if (it != null && it.arrayList.isNotEmpty()) {
@ -68,7 +71,7 @@ class LibraryViewModel(
}
}
}
_homeSections.value = list
home.value = list
}
private val loadSongs: Deferred<List<Song>>
@ -98,13 +101,17 @@ class LibraryViewModel(
fun forceReload(reloadType: ReloadType) = viewModelScope.launch {
when (reloadType) {
Songs -> _songs.value = loadSongs.await()
Albums -> _albums.value = loadAlbums.await()
Artists -> _artists.value = loadArtists.await()
HomeSections -> _songs.value = loadSongs.await()
Songs -> songs.value = loadSongs.await()
Albums -> albums.value = loadAlbums.await()
Artists -> artists.value = loadArtists.await()
HomeSections -> songs.value = loadSongs.await()
}
}
fun updateColor(newColor: Int) {
paletteColor.postValue(newColor)
}
override fun onMediaStoreChanged() {
loadLibraryContent()
}
@ -116,6 +123,7 @@ class LibraryViewModel(
override fun onPlayStateChanged() {}
override fun onRepeatModeChanged() {}
override fun onShuffleModeChanged() {}
}
enum class ReloadType {

View file

@ -7,7 +7,9 @@ import android.os.Bundle
import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan
import android.view.*
import android.view.GestureDetector
import android.view.MotionEvent
import android.view.View
import android.view.animation.DecelerateInterpolator
import code.name.monkey.appthemehelper.ThemeStore
import io.github.muntashirakon.music.R
@ -24,8 +26,8 @@ import io.github.muntashirakon.music.util.ViewUtil
import kotlinx.android.synthetic.main.fragment_mini_player.*
import kotlin.math.abs
open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpdateHelper.Callback,
View.OnClickListener {
open class MiniPlayerFragment : AbsMusicServiceFragment(R.layout.fragment_mini_player),
MusicProgressViewUpdateHelper.Callback, View.OnClickListener {
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
@ -34,14 +36,6 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_mini_player, container, false)
}
override fun onClick(view: View) {
when (view.id) {
R.id.actionNext -> MusicPlayerRemote.playNextSong()

View file

@ -24,7 +24,8 @@ enum class NowPlayingScreen constructor(
Gradient(R.string.gradient, R.drawable.np_gradient, 17),
Material(R.string.material, R.drawable.np_material, 11),
Normal(R.string.normal, R.drawable.np_normal, 0),
Peak(R.string.peak, R.drawable.np_peak, 14),
//Peak(R.string.peak, R.drawable.np_peak, 14),
Plain(R.string.plain, R.drawable.np_plain, 3),
Simple(R.string.simple, R.drawable.np_simple, 8),
Tiny(R.string.tiny, R.drawable.np_tiny, 7),

View file

@ -7,17 +7,21 @@ import androidx.recyclerview.widget.GridLayoutManager
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.adapter.album.AlbumAdapter
import io.github.muntashirakon.music.fragments.ReloadType
import io.github.muntashirakon.music.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
import io.github.muntashirakon.music.fragments.base.AbsRecyclerViewCustomGridSizeFragment
import io.github.muntashirakon.music.interfaces.MainActivityFragmentCallbacks
import io.github.muntashirakon.music.util.PreferenceUtil
class AlbumsFragment :
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
MainActivityFragmentCallbacks {
override fun handleBackPress(): Boolean {
return false
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
mainActivity.libraryViewModel.allAlbums()
libraryViewModel.albumsLiveData
.observe(viewLifecycleOwner, Observer { albums ->
if (albums.isNotEmpty())
adapter?.swapDataSet(albums)
@ -73,7 +77,7 @@ class AlbumsFragment :
}
override fun setSortOrder(sortOrder: String) {
mainActivity.libraryViewModel.forceReload(ReloadType.Albums)
libraryViewModel.forceReload(ReloadType.Albums)
}
override fun loadLayoutRes(): Int {
@ -84,9 +88,6 @@ class AlbumsFragment :
PreferenceUtil.albumGridStyle = layoutRes
}
override fun handleBackPress(): Boolean {
return false
}
companion object {
@JvmField

View file

@ -7,17 +7,23 @@ import androidx.recyclerview.widget.GridLayoutManager
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.adapter.artist.ArtistAdapter
import io.github.muntashirakon.music.fragments.ReloadType
import io.github.muntashirakon.music.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
import io.github.muntashirakon.music.fragments.base.AbsRecyclerViewCustomGridSizeFragment
import io.github.muntashirakon.music.interfaces.MainActivityFragmentCallbacks
import io.github.muntashirakon.music.util.PreferenceUtil
class ArtistsFragment :
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(),
AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(),
MainActivityFragmentCallbacks {
override fun handleBackPress(): Boolean {
return false
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
mainActivity.libraryViewModel.allArtists().observe(
viewLifecycleOwner, Observer { artists ->
libraryViewModel.artistsLiveData
.observe(viewLifecycleOwner, Observer { artists ->
if (artists.isNotEmpty()) {
adapter?.swapDataSet(artists)
} else {
@ -26,15 +32,11 @@ class ArtistsFragment :
})
}
override fun handleBackPress(): Boolean {
return false
}
override val emptyMessage: Int
get() = R.string.no_artists
override fun setSortOrder(sortOrder: String) {
mainActivity.libraryViewModel.forceReload(ReloadType.Artists)
libraryViewModel.forceReload(ReloadType.Artists)
}
override fun createLayoutManager(): GridLayoutManager {

View file

@ -1,15 +0,0 @@
package io.github.muntashirakon.music.fragments.base
import android.os.Bundle
import io.github.muntashirakon.music.activities.MainActivity
open class AbsLibraryPagerFragment : AbsMusicServiceFragment() {
val mainActivity: MainActivity
get() = requireActivity() as MainActivity
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
setHasOptionsMenu(true)
}
}

View file

@ -2,13 +2,14 @@ package io.github.muntashirakon.music.fragments.base
import android.os.Bundle
import android.view.View
import androidx.annotation.LayoutRes
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.VersionUtils
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.activities.MainActivity
abstract class AbsMainActivityFragment : AbsMusicServiceFragment() {
abstract class AbsMainActivityFragment(@LayoutRes layout: Int) : AbsMusicServiceFragment(layout) {
val mainActivity: MainActivity
get() = activity as MainActivity

View file

@ -5,6 +5,7 @@ import android.net.Uri
import android.os.Bundle
import android.view.View
import android.webkit.MimeTypeMap
import androidx.annotation.LayoutRes
import androidx.fragment.app.Fragment
import io.github.muntashirakon.music.activities.base.AbsMusicServiceActivity
import io.github.muntashirakon.music.interfaces.MusicServiceEventListener
@ -19,7 +20,8 @@ import java.util.*
* Created by hemanths on 18/08/17.
*/
open class AbsMusicServiceFragment : Fragment(), MusicServiceEventListener {
open class AbsMusicServiceFragment(@LayoutRes layout: Int) : Fragment(layout),
MusicServiceEventListener {
var playerActivity: AbsMusicServiceActivity? = null
private set

View file

@ -4,6 +4,7 @@ import android.os.Bundle
import android.view.View
import android.view.animation.AccelerateInterpolator
import android.view.animation.DecelerateInterpolator
import androidx.annotation.LayoutRes
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.fragments.VolumeFragment
import io.github.muntashirakon.music.helper.MusicProgressViewUpdateHelper
@ -15,7 +16,7 @@ import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
* Created by hemanths on 24/09/17.
*/
abstract class AbsPlayerControlsFragment : AbsMusicServiceFragment(),
abstract class AbsPlayerControlsFragment(@LayoutRes layout: Int) : AbsMusicServiceFragment(layout),
MusicProgressViewUpdateHelper.Callback {
protected abstract fun show()

View file

@ -2,7 +2,6 @@ package io.github.muntashirakon.music.fragments.base
import android.annotation.SuppressLint
import android.content.ContentUris
import android.content.Context
import android.content.Intent
import android.media.MediaMetadataRetriever
import android.os.AsyncTask
@ -13,12 +12,14 @@ import android.text.TextUtils
import android.view.MenuItem
import android.view.View
import android.widget.Toast
import androidx.annotation.LayoutRes
import androidx.appcompat.widget.Toolbar
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.activities.tageditor.AbsTagEditorActivity
import io.github.muntashirakon.music.activities.tageditor.SongTagEditorActivity
import io.github.muntashirakon.music.dialogs.*
import io.github.muntashirakon.music.extensions.hide
import io.github.muntashirakon.music.fragments.LibraryViewModel
import io.github.muntashirakon.music.fragments.player.PlayerAlbumCoverFragment
import io.github.muntashirakon.music.helper.MusicPlayerRemote
import io.github.muntashirakon.music.interfaces.PaletteColorHolder
@ -26,34 +27,19 @@ import io.github.muntashirakon.music.model.Song
import io.github.muntashirakon.music.model.lyrics.Lyrics
import io.github.muntashirakon.music.util.*
import kotlinx.android.synthetic.main.shadow_statusbar_toolbar.*
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
import java.io.FileNotFoundException
abstract class AbsPlayerFragment : AbsMusicServiceFragment(),
abstract class AbsPlayerFragment(@LayoutRes layout: Int) : AbsMusicServiceFragment(layout),
Toolbar.OnMenuItemClickListener,
PaletteColorHolder,
PlayerAlbumCoverFragment.Callbacks {
var callbacks: Callbacks? = null
private set
private var updateIsFavoriteTask: AsyncTask<*, *, *>? = null
private var updateLyricsAsyncTask: AsyncTask<*, *, *>? = null
private var playerAlbumCoverFragment: PlayerAlbumCoverFragment? = null
override fun onAttach(
context: Context
) {
super.onAttach(context)
try {
callbacks = context as Callbacks?
} catch (e: ClassCastException) {
throw RuntimeException(context.javaClass.simpleName + " must implement " + Callbacks::class.java.simpleName)
}
}
override fun onDetach() {
super.onDetach()
callbacks = null
}
protected val libraryViewModel by sharedViewModel<LibraryViewModel>()
override fun onMenuItemClick(
item: MenuItem

View file

@ -7,8 +7,8 @@ import androidx.recyclerview.widget.RecyclerView
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.util.RetroUtil
abstract class AbsLibraryPagerRecyclerViewCustomGridSizeFragment<A : RecyclerView.Adapter<*>, LM : RecyclerView.LayoutManager> :
AbsLibraryPagerRecyclerViewFragment<A, LM>() {
abstract class AbsRecyclerViewCustomGridSizeFragment<A : RecyclerView.Adapter<*>, LM : RecyclerView.LayoutManager> :
AbsRecyclerViewFragment<A, LM>() {
private var gridSize: Int = 0
private var sortOrder: String? = null

View file

@ -1,13 +1,14 @@
package io.github.muntashirakon.music.fragments.base
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.NonNull
import androidx.annotation.StringRes
import androidx.recyclerview.widget.RecyclerView
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.activities.MainActivity
import io.github.muntashirakon.music.fragments.LibraryViewModel
import io.github.muntashirakon.music.helper.MusicPlayerRemote
import io.github.muntashirakon.music.util.DensityUtil
import io.github.muntashirakon.music.util.ThemedFastScroller.create
@ -16,19 +17,24 @@ import com.google.android.material.appbar.AppBarLayout
import kotlinx.android.synthetic.main.fragment_main_activity_recycler_view.*
import me.zhanghai.android.fastscroll.FastScroller
import me.zhanghai.android.fastscroll.FastScrollerBuilder
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : RecyclerView.LayoutManager> :
AbsLibraryPagerFragment(), AppBarLayout.OnOffsetChangedListener {
abstract class AbsRecyclerViewFragment<A : RecyclerView.Adapter<*>, LM : RecyclerView.LayoutManager> :
AbsMusicServiceFragment(R.layout.fragment_main_activity_recycler_view),
AppBarLayout.OnOffsetChangedListener {
val libraryViewModel: LibraryViewModel by sharedViewModel()
val mainActivity: MainActivity
get() = requireActivity() as MainActivity
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
setHasOptionsMenu(true)
}
protected var adapter: A? = null
protected var layoutManager: LM? = null
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_main_activity_recycler_view, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@ -92,7 +98,6 @@ abstract class AbsLibraryPagerRecyclerViewFragment<A : RecyclerView.Adapter<*>,
}
private fun initLayoutManager() {
layoutManager = createLayoutManager()
}

View file

@ -12,7 +12,7 @@
* See the GNU General Public License for more details.
*/
package io.github.muntashirakon.music.fragments.mainactivity;
package io.github.muntashirakon.music.fragments.folder;
import android.app.Dialog;
import android.content.Context;
@ -84,7 +84,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
FileUtil.fileIsMimeType(file, "audio/*", MimeTypeMap.getSingleton()) ||
FileUtil.fileIsMimeType(file, "application/opus", MimeTypeMap.getSingleton()) ||
FileUtil.fileIsMimeType(file, "application/ogg", MimeTypeMap.getSingleton()));
private static final String PATH = "path";
public static final String PATH = "path";
private static final String CRUMBS = "crumbs";
private static final int LOADER_ID = 5;
private SongFileAdapter adapter;
@ -106,6 +106,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
private RecyclerView recyclerView;
public FoldersFragment() {
super(R.layout.fragment_folder);
}
public static File getDefaultStartDirectory() {
@ -170,8 +171,7 @@ public class FoldersFragment extends AbsMainActivityFragment implements
if (savedInstanceState == null) {
//noinspection ConstantConditions
setCrumb(new BreadCrumbLayout.Crumb(
FileUtil.safeGetCanonicalFile((File) getArguments().getSerializable(PATH))), true);
setCrumb(new BreadCrumbLayout.Crumb(FileUtil.safeGetCanonicalFile((File) requireArguments().getSerializable(PATH))), true);
} else {
breadCrumbs.restoreFromStateWrapper(savedInstanceState.getParcelable(CRUMBS));
getLoaderManager().initLoader(LOADER_ID, null, this);

View file

@ -20,16 +20,20 @@ import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.adapter.GenreAdapter
import io.github.muntashirakon.music.fragments.base.AbsLibraryPagerRecyclerViewFragment
import io.github.muntashirakon.music.fragments.base.AbsRecyclerViewFragment
import io.github.muntashirakon.music.interfaces.MainActivityFragmentCallbacks
class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearLayoutManager>(),
class GenresFragment : AbsRecyclerViewFragment<GenreAdapter, LinearLayoutManager>(),
MainActivityFragmentCallbacks {
override fun handleBackPress(): Boolean {
return false
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
mainActivity.libraryViewModel.allGenres().observe(
viewLifecycleOwner, Observer { genres ->
libraryViewModel.genresLiveData
.observe(viewLifecycleOwner, Observer { genres ->
if (genres.isNotEmpty()) {
adapter?.swapDataSet(genres)
} else {
@ -38,9 +42,6 @@ class GenresFragment : AbsLibraryPagerRecyclerViewFragment<GenreAdapter, LinearL
})
}
override fun handleBackPress(): Boolean {
return false
}
override fun createLayoutManager(): LinearLayoutManager {
return LinearLayoutManager(activity)

View file

@ -17,13 +17,12 @@ package io.github.muntashirakon.music.fragments.home
import android.app.ActivityOptions
import android.os.Bundle
import android.util.DisplayMetrics
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.adapter.HomeAdapter
import io.github.muntashirakon.music.fragments.LibraryViewModel
import io.github.muntashirakon.music.fragments.base.AbsMainActivityFragment
import io.github.muntashirakon.music.glide.ProfileBannerGlideRequest
import io.github.muntashirakon.music.glide.UserProfileGlideRequest
@ -39,22 +38,18 @@ import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.abs_playlists.*
import kotlinx.android.synthetic.main.fragment_banner_home.*
import kotlinx.android.synthetic.main.home_content.*
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallbacks {
private lateinit var homeAdapter: HomeAdapter
class BannerHomeFragment :
AbsMainActivityFragment(if (PreferenceUtil.isHomeBanner) R.layout.fragment_banner_home else R.layout.fragment_home),
MainActivityFragmentCallbacks {
override fun onCreateView(
inflater: LayoutInflater,
viewGroup: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(
if (PreferenceUtil.isHomeBanner) R.layout.fragment_banner_home else R.layout.fragment_home,
viewGroup,
false
)
override fun handleBackPress(): Boolean {
return false
}
private val libraryViewModel: LibraryViewModel by sharedViewModel()
private val displayMetrics: DisplayMetrics
get() {
val display = mainActivity.windowManager.defaultDisplay
@ -106,13 +101,13 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
}
titleWelcome?.text = String.format("%s", PreferenceUtil.userName)
homeAdapter = HomeAdapter(mainActivity, displayMetrics)
val homeAdapter = HomeAdapter(mainActivity, displayMetrics)
recyclerView.apply {
layoutManager = LinearLayoutManager(mainActivity)
adapter = homeAdapter
}
mainActivity.libraryViewModel.homeSections()
libraryViewModel.homeLiveData
.observe(viewLifecycleOwner, Observer { sections ->
homeAdapter.swapData(sections)
})
@ -120,10 +115,6 @@ class BannerHomeFragment : AbsMainActivityFragment(), MainActivityFragmentCallba
loadProfile()
}
override fun handleBackPress(): Boolean {
return false
}
private fun loadProfile() {
bannerImage?.let {
ProfileBannerGlideRequest.Builder.from(

View file

@ -0,0 +1,42 @@
package code.name.monkey.retromusic.fragments.player
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.navigation.NavController
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.navController
import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
import code.name.monkey.retromusic.util.PreferenceUtil
class NowPlayingPlayerFragment : Fragment(R.layout.fragment_now_playing_player) {
companion object {
const val TAG = "NowPlaying"
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
val navController = navController(R.id.playerFragmentContainer)
updateNowPlaying(navController)
}
private fun updateNowPlaying(navController: NavController) {
when (PreferenceUtil.nowPlayingScreen) {
Adaptive -> navController.navigate(R.id.adaptiveFragment)
Blur -> navController.navigate(R.id.blurPlayerFragment)
BlurCard -> navController.navigate(R.id.cardBlurFragment)
Card -> navController.navigate(R.id.cardFragment)
Circle -> navController.navigate(R.id.circlePlayerFragment)
Classic -> navController.navigate(R.id.classicPlayerFragment)
Color -> navController.navigate(R.id.colorFragment)
Fit -> navController.navigate(R.id.fitFragment)
Flat -> navController.navigate(R.id.flatPlayerFragment)
Full -> navController.navigate(R.id.fullPlayerFragment)
Gradient -> navController.navigate(R.id.gradientPlayerFragment)
Material -> navController.navigate(R.id.materialFragment)
Plain -> navController.navigate(R.id.plainPlayerFragment)
Simple -> navController.navigate(R.id.simplePlayerFragment)
Tiny -> navController.navigate(R.id.tinyPlayerFragment)
else -> navController.navigate(R.id.playerFragment)
}
}
}

View file

@ -1,9 +1,7 @@
package io.github.muntashirakon.music.fragments.player
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.viewpager.widget.ViewPager
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.adapter.album.AlbumCoverPagerAdapter
@ -13,13 +11,13 @@ import io.github.muntashirakon.music.fragments.base.AbsMusicServiceFragment
import io.github.muntashirakon.music.helper.MusicPlayerRemote
import io.github.muntashirakon.music.transform.CarousalPagerTransformer
import io.github.muntashirakon.music.transform.ParallaxPagerTransformer
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_player_album_cover.*
class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChangeListener {
class PlayerAlbumCoverFragment : AbsMusicServiceFragment(R.layout.fragment_player_album_cover),
ViewPager.OnPageChangeListener {
private var callbacks: Callbacks? = null
private var currentPosition: Int = 0
private val colorReceiver = object : AlbumCoverFragment.ColorReceiver {
@ -35,13 +33,6 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(), ViewPager.OnPageChan
transformer.setSpeed(0.3f)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_player_album_cover, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
viewPager.addOnPageChangeListener(this)

View file

@ -1,9 +1,7 @@
package io.github.muntashirakon.music.fragments.player.adaptive
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
@ -18,7 +16,7 @@ import io.github.muntashirakon.music.model.Song
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_adaptive_player.*
class AdaptiveFragment : AbsPlayerFragment() {
class AdaptiveFragment : AbsPlayerFragment(R.layout.fragment_adaptive_player) {
override fun playerToolbar(): Toolbar {
return playerToolbar
@ -27,14 +25,6 @@ class AdaptiveFragment : AbsPlayerFragment() {
private var lastColor: Int = 0
private lateinit var playbackControlsFragment: AdaptivePlaybackControlsFragment
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_adaptive_player, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpSubFragments()
@ -96,7 +86,7 @@ class AdaptiveFragment : AbsPlayerFragment() {
override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setColor(color)
lastColor = color.primaryTextColor
callbacks?.onPaletteColorChanged()
libraryViewModel.updateColor(color.primaryTextColor)
ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),

View file

@ -30,7 +30,8 @@ import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.*
class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
class AdaptivePlaybackControlsFragment :
AbsPlayerControlsFragment(R.layout.fragment_adaptive_player_playback_controls) {
private var lastPlaybackControlsColor: Int = 0
private var lastDisabledPlaybackControlsColor: Int = 0

View file

@ -4,9 +4,7 @@ import android.animation.ObjectAnimator
import android.graphics.Color
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.AccelerateInterpolator
import android.view.animation.DecelerateInterpolator
import android.view.animation.LinearInterpolator
@ -29,7 +27,8 @@ import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_blur_player_playback_controls.*
class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
class BlurPlaybackControlsFragment :
AbsPlayerControlsFragment(R.layout.fragment_blur_player_playback_controls) {
private var lastPlaybackControlsColor: Int = 0
private var lastDisabledPlaybackControlsColor: Int = 0
@ -40,14 +39,6 @@ class BlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_blur_player_playback_controls, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpMusicControllers()

View file

@ -3,9 +3,7 @@ package io.github.muntashirakon.music.fragments.player.blur
import android.content.SharedPreferences
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.preference.PreferenceManager
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
@ -22,7 +20,8 @@ import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.fragment_blur.*
class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
class BlurPlayerFragment : AbsPlayerFragment(R.layout.fragment_blur),
SharedPreferences.OnSharedPreferenceChangeListener {
override fun playerToolbar(): Toolbar {
return playerToolbar
@ -32,12 +31,6 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
private var lastColor: Int = 0
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_blur, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@ -68,7 +61,7 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setColor(color)
lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged()
libraryViewModel.updateColor(color.backgroundColor)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
}

View file

@ -2,9 +2,7 @@ package io.github.muntashirakon.music.fragments.player.card
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import io.github.muntashirakon.music.R
@ -16,7 +14,7 @@ import io.github.muntashirakon.music.model.Song
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_card_player.*
class CardFragment : AbsPlayerFragment() {
class CardFragment : AbsPlayerFragment(R.layout.fragment_card_player) {
override fun playerToolbar(): Toolbar {
return playerToolbar
}
@ -47,7 +45,7 @@ class CardFragment : AbsPlayerFragment() {
override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setColor(color)
lastColor = color.primaryTextColor
callbacks?.onPaletteColorChanged()
libraryViewModel.updateColor(color.primaryTextColor)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
}
@ -62,14 +60,6 @@ class CardFragment : AbsPlayerFragment() {
toggleFavorite(MusicPlayerRemote.currentSong)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_card_player, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpSubFragments()

View file

@ -3,9 +3,7 @@ package io.github.muntashirakon.music.fragments.player.card
import android.animation.ObjectAnimator
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.LinearInterpolator
import android.widget.SeekBar
import code.name.monkey.appthemehelper.ThemeStore
@ -24,13 +22,13 @@ import io.github.muntashirakon.music.helper.PlayPauseButtonOnClickHandler
import io.github.muntashirakon.music.misc.SimpleOnSeekbarChangeListener
import io.github.muntashirakon.music.service.MusicService
import io.github.muntashirakon.music.util.MusicUtil
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_card_player_playback_controls.*
import kotlinx.android.synthetic.main.media_button.*
class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
class CardPlaybackControlsFragment :
AbsPlayerControlsFragment(R.layout.fragment_card_player_playback_controls) {
private var lastPlaybackControlsColor: Int = 0
private var lastDisabledPlaybackControlsColor: Int = 0
@ -41,12 +39,6 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_card_player_playback_controls, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

View file

@ -3,9 +3,7 @@ package io.github.muntashirakon.music.fragments.player.cardblur
import android.content.SharedPreferences
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.preference.PreferenceManager
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
@ -19,12 +17,12 @@ import io.github.muntashirakon.music.glide.RetroMusicColoredTarget
import io.github.muntashirakon.music.glide.SongGlideRequest
import io.github.muntashirakon.music.helper.MusicPlayerRemote
import io.github.muntashirakon.music.model.Song
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.fragment_card_blur_player.*
class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferenceChangeListener {
class CardBlurFragment : AbsPlayerFragment(R.layout.fragment_card_blur_player),
SharedPreferences.OnSharedPreferenceChangeListener {
override fun playerToolbar(): Toolbar {
return playerToolbar
}
@ -54,7 +52,7 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setColor(color)
lastColor = color.backgroundColor
callbacks!!.onPaletteColorChanged()
libraryViewModel.updateColor(color.backgroundColor)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
playerToolbar.setTitleTextColor(Color.WHITE)
@ -72,13 +70,6 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
toggleFavorite(MusicPlayerRemote.currentSong)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_card_blur_player, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

View file

@ -4,9 +4,7 @@ import android.animation.ObjectAnimator
import android.graphics.Color
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.DecelerateInterpolator
import android.view.animation.LinearInterpolator
import android.widget.SeekBar
@ -24,12 +22,12 @@ import io.github.muntashirakon.music.misc.SimpleOnSeekbarChangeListener
import io.github.muntashirakon.music.service.MusicService
import io.github.muntashirakon.music.util.MusicUtil
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_card_blur_player_playback_controls.*
import kotlinx.android.synthetic.main.media_button.*
class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
class CardBlurPlaybackControlsFragment :
AbsPlayerControlsFragment(R.layout.fragment_card_blur_player_playback_controls) {
private var lastPlaybackControlsColor: Int = 0
private var lastDisabledPlaybackControlsColor: Int = 0
@ -40,18 +38,6 @@ class CardBlurPlaybackControlsFragment : AbsPlayerControlsFragment() {
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(
R.layout.fragment_card_blur_player_playback_controls,
container,
false
)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpMusicControllers()

View file

@ -58,7 +58,8 @@ import kotlinx.android.synthetic.main.fragment_circle_player.*
* Created by hemanths on 2020-01-06.
*/
class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChangedListener,
class CirclePlayerFragment : AbsPlayerFragment(R.layout.fragment_circle_player), Callback,
OnAudioVolumeChangedListener,
OnSeekArcChangeListener {
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper

View file

@ -6,9 +6,7 @@ import android.content.res.ColorStateList
import android.graphics.Color
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.LinearInterpolator
import android.widget.SeekBar
import androidx.appcompat.app.AppCompatActivity
@ -37,7 +35,6 @@ import io.github.muntashirakon.music.misc.SimpleOnSeekbarChangeListener
import io.github.muntashirakon.music.model.Song
import io.github.muntashirakon.music.service.MusicService
import io.github.muntashirakon.music.util.MusicUtil
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.ViewUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
@ -53,7 +50,8 @@ import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils
import kotlinx.android.synthetic.main.fragment_classic_controls.*
import kotlinx.android.synthetic.main.fragment_classic_player.*
class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
class ClassicPlayerFragment : AbsPlayerFragment(R.layout.fragment_classic_player),
View.OnLayoutChangeListener,
MusicProgressViewUpdateHelper.Callback {
private var lastColor: Int = 0
@ -107,14 +105,6 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_classic_player, container, false)
}
@SuppressLint("ClickableViewAccessibility")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@ -271,7 +261,7 @@ class ClassicPlayerFragment : AbsPlayerFragment(), View.OnLayoutChangeListener,
override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged()
libraryViewModel.updateColor(color.backgroundColor)
lastPlaybackControlsColor = color.primaryTextColor
lastDisabledPlaybackControlsColor = ColorUtil.withAlpha(color.primaryTextColor, 0.3f)

View file

@ -3,9 +3,7 @@ package io.github.muntashirakon.music.fragments.player.color
import android.animation.ValueAnimator
import android.os.Bundle
import android.os.Handler
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
@ -18,7 +16,7 @@ import io.github.muntashirakon.music.model.Song
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_color_player.*
class ColorFragment : AbsPlayerFragment() {
class ColorFragment : AbsPlayerFragment(R.layout.fragment_color_player) {
private var lastColor: Int = 0
private var navigationColor: Int = 0
@ -33,10 +31,11 @@ class ColorFragment : AbsPlayerFragment() {
get() = navigationColor
override fun onColorChanged(color: MediaNotificationProcessor) {
libraryViewModel.updateColor(color.backgroundColor)
lastColor = color.secondaryTextColor
playbackControlsFragment.setColor(color)
navigationColor = color.backgroundColor
callbacks?.onPaletteColorChanged()
colorGradientBackground?.setBackgroundColor(color.backgroundColor)
playerActivity?.setLightNavigationBar(ColorUtil.isColorLight(color.backgroundColor))
Handler().post {
@ -84,14 +83,6 @@ class ColorFragment : AbsPlayerFragment() {
}
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_color_player, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpSubFragments()

View file

@ -28,7 +28,8 @@ import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_color_player_playback_controls.*
class ColorPlaybackControlsFragment : AbsPlayerControlsFragment() {
class ColorPlaybackControlsFragment :
AbsPlayerControlsFragment(R.layout.fragment_adaptive_player_playback_controls) {
private var lastPlaybackControlsColor: Int = 0
private var lastDisabledPlaybackControlsColor: Int = 0

View file

@ -1,9 +1,7 @@
package io.github.muntashirakon.music.fragments.player.fit
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
@ -15,7 +13,7 @@ import io.github.muntashirakon.music.model.Song
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_fit.*
class FitFragment : AbsPlayerFragment() {
class FitFragment : AbsPlayerFragment(R.layout.fragment_fit) {
override fun playerToolbar(): Toolbar {
return playerToolbar
}
@ -46,7 +44,7 @@ class FitFragment : AbsPlayerFragment() {
override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setColor(color)
lastColor = color.primaryTextColor
callbacks?.onPaletteColorChanged()
libraryViewModel.updateColor(color.primaryTextColor)
ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),
@ -65,14 +63,6 @@ class FitFragment : AbsPlayerFragment() {
toggleFavorite(MusicPlayerRemote.currentSong)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_fit, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpSubFragments()

View file

@ -31,7 +31,8 @@ import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_fit_playback_controls.*
class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
class FitPlaybackControlsFragment :
AbsPlayerControlsFragment(R.layout.fragment_fit_playback_controls) {
private var lastPlaybackControlsColor: Int = 0
@ -43,13 +44,6 @@ class FitPlaybackControlsFragment : AbsPlayerControlsFragment() {
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_fit_playback_controls, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

View file

@ -3,9 +3,7 @@ package io.github.muntashirakon.music.fragments.player.flat
import android.animation.ObjectAnimator
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.DecelerateInterpolator
import android.view.animation.LinearInterpolator
import android.widget.SeekBar
@ -27,12 +25,12 @@ import io.github.muntashirakon.music.helper.PlayPauseButtonOnClickHandler
import io.github.muntashirakon.music.misc.SimpleOnSeekbarChangeListener
import io.github.muntashirakon.music.service.MusicService
import io.github.muntashirakon.music.util.MusicUtil
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_flat_player_playback_controls.*
class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
class FlatPlaybackControlsFragment :
AbsPlayerControlsFragment(R.layout.fragment_flat_player_playback_controls), Callback {
private var lastPlaybackControlsColor: Int = 0
private var lastDisabledPlaybackControlsColor: Int = 0
@ -43,13 +41,6 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_flat_player_playback_controls, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpMusicControllers()
@ -86,14 +77,14 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
override fun setColor(color: MediaNotificationProcessor) {
if (ATHUtil.isWindowBackgroundDark(requireContext())) {
lastPlaybackControlsColor =
MaterialValueHelper.getSecondaryTextColor(requireContext(), true)
MaterialValueHelper.getSecondaryTextColor(requireContext(), false)
lastDisabledPlaybackControlsColor =
MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), true)
MaterialValueHelper.getSecondaryDisabledTextColor(requireContext(), false)
} else {
lastPlaybackControlsColor =
MaterialValueHelper.getPrimaryTextColor(requireContext(), false)
MaterialValueHelper.getPrimaryTextColor(requireContext(), true)
lastDisabledPlaybackControlsColor =
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), false)
MaterialValueHelper.getPrimaryDisabledTextColor(requireContext(), true)
}
val colorFinal = if (PreferenceUtil.isAdaptiveColor) {
@ -116,8 +107,8 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
val colorSecondary =
MaterialValueHelper.getSecondaryTextColor(context, ColorUtil.isColorLight(darkColor))
TintHelper.setTintAuto(playPauseButton!!, colorPrimary, false)
TintHelper.setTintAuto(playPauseButton!!, color, true)
TintHelper.setTintAuto(playPauseButton, colorPrimary, false)
TintHelper.setTintAuto(playPauseButton, color, true)
title.setBackgroundColor(color)
title.setTextColor(colorPrimary)

View file

@ -4,9 +4,7 @@ import android.animation.ArgbEvaluator
import android.animation.ValueAnimator
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
@ -17,14 +15,13 @@ import io.github.muntashirakon.music.fragments.base.AbsPlayerFragment
import io.github.muntashirakon.music.fragments.player.PlayerAlbumCoverFragment
import io.github.muntashirakon.music.helper.MusicPlayerRemote
import io.github.muntashirakon.music.model.Song
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.ViewUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import io.github.muntashirakon.music.views.DrawableGradient
import kotlinx.android.synthetic.main.fragment_flat_player.*
class FlatPlayerFragment : AbsPlayerFragment() {
class FlatPlayerFragment : AbsPlayerFragment(R.layout.fragment_flat_player) {
override fun playerToolbar(): Toolbar {
return playerToolbar
}
@ -71,13 +68,6 @@ class FlatPlayerFragment : AbsPlayerFragment() {
valueAnimator?.setDuration(ViewUtil.RETRO_MUSIC_ANIM_TIME.toLong())?.start()
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_flat_player, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpPlayerToolbar()
@ -108,7 +98,7 @@ class FlatPlayerFragment : AbsPlayerFragment() {
override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color.backgroundColor
controlsFragment.setColor(color)
callbacks?.onPaletteColorChanged()
libraryViewModel.updateColor(color.backgroundColor)
val isLight = ColorUtil.isColorLight(color.backgroundColor)
val iconColor = if (PreferenceUtil.isAdaptiveColor)
MaterialValueHelper.getPrimaryTextColor(requireContext(), isLight)

View file

@ -7,10 +7,8 @@ import android.graphics.Color
import android.graphics.PorterDuff
import android.os.AsyncTask
import android.os.Bundle
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.view.animation.DecelerateInterpolator
import android.view.animation.LinearInterpolator
import android.widget.PopupMenu
@ -30,7 +28,6 @@ import io.github.muntashirakon.music.model.Song
import io.github.muntashirakon.music.service.MusicService
import io.github.muntashirakon.music.util.MusicUtil
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_full_player_controls.*
@ -38,7 +35,8 @@ import kotlinx.android.synthetic.main.fragment_full_player_controls.*
* Created by hemanths on 20/09/17.
*/
class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
class FullPlaybackControlsFragment :
AbsPlayerControlsFragment(R.layout.fragment_full_player_controls),
PopupMenu.OnMenuItemClickListener {
private var lastPlaybackControlsColor: Int = 0
@ -50,14 +48,6 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_full_player_controls, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpMusicControllers()

View file

@ -4,9 +4,7 @@ import android.app.ActivityOptions
import android.content.res.ColorStateList
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.TextView
import androidx.appcompat.widget.Toolbar
@ -33,7 +31,8 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
class FullPlayerFragment : AbsPlayerFragment(R.layout.fragment_full),
MusicProgressViewUpdateHelper.Callback {
private lateinit var lyricsLayout: FrameLayout
private lateinit var lyricsLine1: TextView
private lateinit var lyricsLine2: TextView
@ -134,13 +133,6 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
}
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_full, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
lyricsLayout = view.findViewById(R.id.playerLyrics)
@ -202,7 +194,7 @@ class FullPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
lastColor = color.backgroundColor
mask.backgroundTintList = ColorStateList.valueOf(color.backgroundColor)
controlsFragment.setColor(color)
callbacks?.onPaletteColorChanged()
libraryViewModel.updateColor(color.backgroundColor)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)
}

View file

@ -7,9 +7,7 @@ import android.graphics.Color
import android.graphics.PorterDuff
import android.os.AsyncTask
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.LinearInterpolator
import android.widget.PopupMenu
import android.widget.SeekBar
@ -51,7 +49,8 @@ import kotlinx.android.synthetic.main.fragment_gradient_controls.*
import kotlinx.android.synthetic.main.fragment_gradient_player.*
import kotlinx.android.synthetic.main.status_bar.*
class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback,
class GradientPlayerFragment : AbsPlayerFragment(R.layout.fragment_gradient_player),
MusicProgressViewUpdateHelper.Callback,
View.OnLayoutChangeListener, PopupMenu.OnMenuItemClickListener {
private var lastColor: Int = 0
private var lastPlaybackControlsColor: Int = 0
@ -124,13 +123,6 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_gradient_player, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@ -201,7 +193,7 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged()
libraryViewModel.updateColor(color.backgroundColor)
mask.backgroundTintList = ColorStateList.valueOf(color.backgroundColor)
colorBackground.setBackgroundColor(color.backgroundColor)
playerQueueSheet.setBackgroundColor(ColorUtil.darkenColor(color.backgroundColor))
@ -283,6 +275,7 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
super.onQueueChanged()
updateLabel()
}
private fun updateSong() {
val song = MusicPlayerRemote.currentSong
title.text = song.title
@ -485,35 +478,36 @@ class GradientPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelpe
songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
}
@SuppressLint("StaticFieldLeak")
private fun updateFavorite() {
if (updateIsFavoriteTask != null) {
updateIsFavoriteTask?.cancel(false)
}
updateIsFavoriteTask =
object : AsyncTask<Song, Void, Boolean>() {
override fun doInBackground(vararg params: Song): Boolean? {
val activity = activity
return if (activity != null) {
MusicUtil.isFavorite(requireActivity(), params[0])
} else {
cancel(false)
null
object : AsyncTask<Song, Void, Boolean>() {
override fun doInBackground(vararg params: Song): Boolean? {
val activity = activity
return if (activity != null) {
MusicUtil.isFavorite(requireActivity(), params[0])
} else {
cancel(false)
null
}
}
}
override fun onPostExecute(isFavorite: Boolean?) {
val activity = activity
if (activity != null) {
val res = if (isFavorite!!)
R.drawable.ic_favorite
else
R.drawable.ic_favorite_border
override fun onPostExecute(isFavorite: Boolean?) {
val activity = activity
if (activity != null) {
val res = if (isFavorite!!)
R.drawable.ic_favorite
else
R.drawable.ic_favorite_border
val drawable = TintHelper.createTintedDrawable(activity, res, Color.WHITE)
songFavourite?.setImageDrawable(drawable)
val drawable = TintHelper.createTintedDrawable(activity, res, Color.WHITE)
songFavourite?.setImageDrawable(drawable)
}
}
}
}.execute(MusicPlayerRemote.currentSong)
}.execute(MusicPlayerRemote.currentSong)
}
}

View file

@ -2,9 +2,7 @@ package io.github.muntashirakon.music.fragments.player.home
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
@ -18,7 +16,8 @@ import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_home_player.*
class HomePlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
class HomePlayerFragment : AbsPlayerFragment(R.layout.fragment_home_player),
MusicProgressViewUpdateHelper.Callback {
private var lastColor: Int = 0
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
@ -27,14 +26,6 @@ class HomePlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_home_player, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpPlayerToolbar()
@ -93,7 +84,7 @@ class HomePlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged()
libraryViewModel.updateColor(color.backgroundColor)
ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,
Color.WHITE,

View file

@ -17,9 +17,7 @@ package io.github.muntashirakon.music.fragments.player.lockscreen
import android.animation.ObjectAnimator
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.DecelerateInterpolator
import android.view.animation.LinearInterpolator
import android.widget.SeekBar
@ -38,7 +36,6 @@ import io.github.muntashirakon.music.helper.PlayPauseButtonOnClickHandler
import io.github.muntashirakon.music.misc.SimpleOnSeekbarChangeListener
import io.github.muntashirakon.music.service.MusicService
import io.github.muntashirakon.music.util.MusicUtil
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.*
@ -46,7 +43,8 @@ import kotlinx.android.synthetic.main.fragment_lock_screen_playback_controls.*
/**
* @author Hemanth S (h4h13).
*/
class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
class LockScreenPlayerControlsFragment :
AbsPlayerControlsFragment(R.layout.fragment_lock_screen_playback_controls) {
private var progressViewUpdateHelper: MusicProgressViewUpdateHelper? = null
private var lastPlaybackControlsColor: Int = 0
@ -57,14 +55,6 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_lock_screen_playback_controls, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpMusicControllers()

View file

@ -3,9 +3,7 @@ package io.github.muntashirakon.music.fragments.player.material
import android.animation.ObjectAnimator
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.LinearInterpolator
import android.widget.SeekBar
import code.name.monkey.appthemehelper.util.ATHUtil
@ -19,7 +17,6 @@ import io.github.muntashirakon.music.helper.PlayPauseButtonOnClickHandler
import io.github.muntashirakon.music.misc.SimpleOnSeekbarChangeListener
import io.github.muntashirakon.music.service.MusicService
import io.github.muntashirakon.music.util.MusicUtil
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_material_playback_controls.*
@ -27,7 +24,8 @@ import kotlinx.android.synthetic.main.fragment_material_playback_controls.*
/**
* @author Hemanth S (h4h13).
*/
class MaterialControlsFragment : AbsPlayerControlsFragment() {
class MaterialControlsFragment :
AbsPlayerControlsFragment(R.layout.fragment_material_playback_controls) {
private var lastPlaybackControlsColor: Int = 0
private var lastDisabledPlaybackControlsColor: Int = 0
@ -38,13 +36,6 @@ class MaterialControlsFragment : AbsPlayerControlsFragment() {
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_material_playback_controls, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpMusicControllers()

View file

@ -1,9 +1,7 @@
package io.github.muntashirakon.music.fragments.player.material
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
@ -19,7 +17,7 @@ import kotlinx.android.synthetic.main.fragment_material.*
/**
* @author Hemanth S (h4h13).
*/
class MaterialFragment : AbsPlayerFragment() {
class MaterialFragment : AbsPlayerFragment(R.layout.fragment_material) {
override fun playerToolbar(): Toolbar {
return playerToolbar
@ -52,7 +50,7 @@ class MaterialFragment : AbsPlayerFragment() {
override fun onColorChanged(color: MediaNotificationProcessor) {
playbackControlsFragment.setColor(color)
lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged()
libraryViewModel.updateColor(color.backgroundColor)
ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,
@ -72,13 +70,6 @@ class MaterialFragment : AbsPlayerFragment() {
toggleFavorite(MusicPlayerRemote.currentSong)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_material, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpSubFragments()

View file

@ -4,9 +4,7 @@ import android.animation.ArgbEvaluator
import android.animation.ValueAnimator
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
@ -15,7 +13,6 @@ import io.github.muntashirakon.music.fragments.base.AbsPlayerFragment
import io.github.muntashirakon.music.fragments.player.PlayerAlbumCoverFragment
import io.github.muntashirakon.music.helper.MusicPlayerRemote
import io.github.muntashirakon.music.model.Song
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.ViewUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
@ -23,7 +20,7 @@ import io.github.muntashirakon.music.views.DrawableGradient
import kotlinx.android.synthetic.main.fragment_player.*
class PlayerFragment : AbsPlayerFragment() {
class PlayerFragment : AbsPlayerFragment(R.layout.fragment_player) {
private var lastColor: Int = 0
override val paletteColor: Int
@ -78,7 +75,7 @@ class PlayerFragment : AbsPlayerFragment() {
override fun onColorChanged(color: MediaNotificationProcessor) {
controlsFragment.setColor(color)
lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged()
libraryViewModel.updateColor(color.backgroundColor)
ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,
@ -103,14 +100,6 @@ class PlayerFragment : AbsPlayerFragment() {
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_player, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpSubFragments()

View file

@ -3,9 +3,7 @@ package io.github.muntashirakon.music.fragments.player.normal
import android.animation.ObjectAnimator
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.DecelerateInterpolator
import android.view.animation.LinearInterpolator
import android.widget.SeekBar
@ -26,12 +24,12 @@ import io.github.muntashirakon.music.helper.PlayPauseButtonOnClickHandler
import io.github.muntashirakon.music.misc.SimpleOnSeekbarChangeListener
import io.github.muntashirakon.music.service.MusicService
import io.github.muntashirakon.music.util.MusicUtil
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_player_playback_controls.*
class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
class PlayerPlaybackControlsFragment :
AbsPlayerControlsFragment(R.layout.fragment_player_playback_controls) {
private var lastPlaybackControlsColor: Int = 0
private var lastDisabledPlaybackControlsColor: Int = 0
@ -42,13 +40,6 @@ class PlayerPlaybackControlsFragment : AbsPlayerControlsFragment() {
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_player_playback_controls, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpMusicControllers()

View file

@ -18,9 +18,7 @@ import android.animation.ObjectAnimator
import android.graphics.Color
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.LinearInterpolator
import android.widget.SeekBar
import code.name.monkey.appthemehelper.ThemeStore
@ -36,7 +34,6 @@ import io.github.muntashirakon.music.helper.PlayPauseButtonOnClickHandler
import io.github.muntashirakon.music.misc.SimpleOnSeekbarChangeListener
import io.github.muntashirakon.music.service.MusicService
import io.github.muntashirakon.music.util.MusicUtil
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_peak_control_player.*
@ -45,7 +42,7 @@ import kotlinx.android.synthetic.main.fragment_peak_control_player.*
* Created by hemanths on 2019-10-04.
*/
class PeakPlayerControlFragment : AbsPlayerControlsFragment() {
class PeakPlayerControlFragment : AbsPlayerControlsFragment(R.layout.fragment_peak_control_player) {
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
private var lastPlaybackControlsColor: Int = 0
@ -66,14 +63,6 @@ class PeakPlayerControlFragment : AbsPlayerControlsFragment() {
progressViewUpdateHelper.stop()
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_peak_control_player, container, false)
}
override fun onViewCreated(
view: View,
savedInstanceState: Bundle?

View file

@ -15,9 +15,7 @@
package io.github.muntashirakon.music.fragments.player.peak
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
@ -28,7 +26,6 @@ import io.github.muntashirakon.music.fragments.base.AbsPlayerFragment
import io.github.muntashirakon.music.fragments.player.PlayerAlbumCoverFragment
import io.github.muntashirakon.music.helper.MusicPlayerRemote
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_peak_player.*
@ -36,19 +33,11 @@ import kotlinx.android.synthetic.main.fragment_peak_player.*
* Created by hemanths on 2019-10-03.
*/
class PeakPlayerFragment : AbsPlayerFragment() {
class PeakPlayerFragment : AbsPlayerFragment(R.layout.fragment_peak_player) {
private lateinit var controlsFragment: PeakPlayerControlFragment
private var lastColor: Int = 0
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_peak_player, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setUpPlayerToolbar()
@ -102,7 +91,7 @@ class PeakPlayerFragment : AbsPlayerFragment() {
override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color.primaryTextColor
callbacks?.onPaletteColorChanged()
libraryViewModel.updateColor(color.primaryTextColor)
controlsFragment.setColor(color)
}

View file

@ -3,9 +3,7 @@ package io.github.muntashirakon.music.fragments.player.plain
import android.animation.ObjectAnimator
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.AccelerateInterpolator
import android.view.animation.DecelerateInterpolator
import android.view.animation.LinearInterpolator
@ -26,7 +24,6 @@ import io.github.muntashirakon.music.helper.PlayPauseButtonOnClickHandler
import io.github.muntashirakon.music.misc.SimpleOnSeekbarChangeListener
import io.github.muntashirakon.music.service.MusicService
import io.github.muntashirakon.music.util.MusicUtil
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.*
@ -43,7 +40,8 @@ import kotlinx.android.synthetic.main.fragment_plain_controls_fragment.songTotal
* @author Hemanth S (h4h13).
*/
class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() {
class PlainPlaybackControlsFragment :
AbsPlayerControlsFragment(R.layout.fragment_plain_controls_fragment) {
private var lastPlaybackControlsColor: Int = 0
private var lastDisabledPlaybackControlsColor: Int = 0
@ -87,14 +85,6 @@ class PlainPlaybackControlsFragment : AbsPlayerControlsFragment() {
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_plain_controls_fragment, container, false)
}
override fun onResume() {
super.onResume()

View file

@ -1,9 +1,7 @@
package io.github.muntashirakon.music.fragments.player.plain
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
@ -15,7 +13,7 @@ import io.github.muntashirakon.music.model.Song
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_plain_player.*
class PlainPlayerFragment : AbsPlayerFragment() {
class PlainPlayerFragment : AbsPlayerFragment(R.layout.fragment_plain_player) {
override fun playerToolbar(): Toolbar {
return playerToolbar
}
@ -41,13 +39,6 @@ class PlainPlayerFragment : AbsPlayerFragment() {
updateSong()
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_plain_player, container, false)
}
private fun setUpPlayerToolbar() {
playerToolbar.apply {
inflateMenu(R.menu.menu_player)
@ -97,7 +88,7 @@ class PlainPlayerFragment : AbsPlayerFragment() {
override fun onColorChanged(color: MediaNotificationProcessor) {
plainPlaybackControlsFragment.setColor(color)
lastColor = color.primaryTextColor
callbacks!!.onPaletteColorChanged()
libraryViewModel.updateColor(color.primaryTextColor)
ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,
ATHUtil.resolveColor(requireContext(), R.attr.colorControlNormal),

View file

@ -2,9 +2,7 @@ package io.github.muntashirakon.music.fragments.player.simple
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.DecelerateInterpolator
import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil
@ -20,7 +18,6 @@ import io.github.muntashirakon.music.helper.MusicProgressViewUpdateHelper
import io.github.muntashirakon.music.helper.PlayPauseButtonOnClickHandler
import io.github.muntashirakon.music.service.MusicService
import io.github.muntashirakon.music.util.MusicUtil
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.*
@ -29,7 +26,8 @@ import kotlinx.android.synthetic.main.fragment_simple_controls_fragment.*
* @author Hemanth S (h4h13).
*/
class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
class SimplePlaybackControlsFragment :
AbsPlayerControlsFragment(R.layout.fragment_simple_controls_fragment) {
private var lastPlaybackControlsColor: Int = 0
private var lastDisabledPlaybackControlsColor: Int = 0
@ -59,14 +57,6 @@ class SimplePlaybackControlsFragment : AbsPlayerControlsFragment() {
progressViewUpdateHelper = MusicProgressViewUpdateHelper(this)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_simple_controls_fragment, container, false)
}
override fun onResume() {
super.onResume()
progressViewUpdateHelper.start()

View file

@ -1,9 +1,7 @@
package io.github.muntashirakon.music.fragments.player.simple
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
@ -19,7 +17,7 @@ import kotlinx.android.synthetic.main.fragment_simple_player.*
* @author Hemanth S (h4h13).
*/
class SimplePlayerFragment : AbsPlayerFragment() {
class SimplePlayerFragment : AbsPlayerFragment(R.layout.fragment_simple_player) {
override fun playerToolbar(): Toolbar {
return playerToolbar
@ -31,13 +29,6 @@ class SimplePlayerFragment : AbsPlayerFragment() {
private lateinit var controlsFragment: SimplePlaybackControlsFragment
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_simple_player, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
@ -71,7 +62,7 @@ class SimplePlayerFragment : AbsPlayerFragment() {
override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color.backgroundColor
callbacks?.onPaletteColorChanged()
libraryViewModel.updateColor(color.backgroundColor)
controlsFragment.setColor(color)
ToolbarContentTintHelper.colorizeToolbar(
playerToolbar,

View file

@ -2,9 +2,7 @@ package io.github.muntashirakon.music.fragments.player.tiny
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import code.name.monkey.appthemehelper.util.ColorUtil
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.fragments.base.AbsPlayerControlsFragment
@ -13,7 +11,8 @@ import io.github.muntashirakon.music.service.MusicService
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_tiny_controls_fragment.*
class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
class TinyPlaybackControlsFragment :
AbsPlayerControlsFragment(R.layout.fragment_tiny_controls_fragment) {
override fun show() {
}
@ -38,13 +37,6 @@ class TinyPlaybackControlsFragment : AbsPlayerControlsFragment() {
private var lastPlaybackControlsColor: Int = 0
private var lastDisabledPlaybackControlsColor: Int = 0
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_tiny_controls_fragment, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

View file

@ -4,9 +4,7 @@ import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.os.Bundle
import android.os.Handler
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.animation.LinearInterpolator
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
@ -22,12 +20,12 @@ import io.github.muntashirakon.music.helper.PlayPauseButtonOnClickHandler
import io.github.muntashirakon.music.model.Song
import io.github.muntashirakon.music.util.MusicUtil
import io.github.muntashirakon.music.util.PreferenceUtil
import io.github.muntashirakon.music.util.ViewUtil
import io.github.muntashirakon.music.util.color.MediaNotificationProcessor
import kotlinx.android.synthetic.main.fragment_tiny_player.*
class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Callback {
class TinyPlayerFragment : AbsPlayerFragment(R.layout.fragment_tiny_player),
MusicProgressViewUpdateHelper.Callback {
private var lastColor: Int = 0
private var toolbarColor: Int = 0
@ -57,9 +55,9 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
override fun onColorChanged(color: MediaNotificationProcessor) {
lastColor = color.backgroundColor
libraryViewModel.updateColor(color.backgroundColor)
toolbarColor = color.secondaryTextColor
controlsFragment.setColor(color)
callbacks?.onPaletteColorChanged()
title.setTextColor(color.primaryTextColor)
playerSongTotalTime.setTextColor(color.primaryTextColor)
@ -111,13 +109,6 @@ class TinyPlayerFragment : AbsPlayerFragment(), MusicProgressViewUpdateHelper.Ca
}
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_tiny_player, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

View file

@ -8,30 +8,28 @@ import androidx.lifecycle.Observer
import androidx.recyclerview.widget.GridLayoutManager
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.adapter.playlist.PlaylistAdapter
import io.github.muntashirakon.music.fragments.base.AbsLibraryPagerRecyclerViewFragment
import io.github.muntashirakon.music.fragments.base.AbsRecyclerViewFragment
import io.github.muntashirakon.music.interfaces.MainActivityFragmentCallbacks
class PlaylistsFragment :
AbsLibraryPagerRecyclerViewFragment<PlaylistAdapter, GridLayoutManager>(),
AbsRecyclerViewFragment<PlaylistAdapter, GridLayoutManager>() ,
MainActivityFragmentCallbacks {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
mainActivity.libraryViewModel.allPlaylisits()
.observe(viewLifecycleOwner, Observer { playlists ->
if (playlists.isNotEmpty()) {
adapter?.swapDataSet(playlists)
} else {
adapter?.swapDataSet(listOf())
}
})
}
override fun handleBackPress(): Boolean {
return false
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
libraryViewModel.playlisitsLiveData.observe(viewLifecycleOwner, Observer { playlists ->
if (playlists.isNotEmpty()) {
adapter?.swapDataSet(playlists)
} else {
adapter?.swapDataSet(listOf())
}
})
}
override val emptyMessage: Int
get() = R.string.no_playlists

View file

@ -20,7 +20,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.adapter.song.PlayingQueueAdapter
import io.github.muntashirakon.music.fragments.base.AbsLibraryPagerRecyclerViewFragment
import io.github.muntashirakon.music.fragments.base.AbsRecyclerViewFragment
import io.github.muntashirakon.music.helper.MusicPlayerRemote
import io.github.muntashirakon.music.interfaces.MainActivityFragmentCallbacks
import com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator
@ -34,7 +34,7 @@ import kotlinx.android.synthetic.main.activity_playing_queue.*
* Created by hemanths on 2019-12-08.
*/
class PlayingQueueFragment :
AbsLibraryPagerRecyclerViewFragment<PlayingQueueAdapter, LinearLayoutManager>(),
AbsRecyclerViewFragment<PlayingQueueAdapter, LinearLayoutManager>(),
MainActivityFragmentCallbacks {
override fun handleBackPress(): Boolean {

View file

@ -22,8 +22,6 @@ import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.PreferenceManager
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEPreferenceFragmentCompat
import code.name.monkey.appthemehelper.util.ATHUtil
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.preferences.*
/**
@ -57,7 +55,7 @@ abstract class AbsSettingsFragment : ATEPreferenceFragmentCompat() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setDivider(ColorDrawable(Color.TRANSPARENT))
listView.setBackgroundColor(ATHUtil.resolveColor(requireContext(), R.attr.colorSurface))
//listView.setBackgroundColor(ATHUtil.resolveColor(requireContext(), R.attr.colorSurface))
listView.overScrollMode = View.OVER_SCROLL_NEVER
listView.setPadding(0, 0, 0, 0)
listView.setPaddingRelative(0, 0, 0, 0)

View file

@ -14,12 +14,14 @@
package io.github.muntashirakon.music.fragments.settings
import android.content.res.ColorStateList
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.StringRes
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.activities.SettingsActivity
import io.github.muntashirakon.music.util.NavigationUtil
@ -28,29 +30,14 @@ import kotlinx.android.synthetic.main.fragment_main_settings.*
class MainSettingsFragment : Fragment(), View.OnClickListener {
override fun onClick(view: View) {
when (view.id) {
R.id.generalSettings -> inflateFragment(
ThemeSettingsFragment(),
R.string.general_settings_title
)
R.id.audioSettings -> inflateFragment(AudioSettings(), R.string.pref_header_audio)
R.id.nowPlayingSettings -> inflateFragment(
NowPlayingSettingsFragment(),
R.string.now_playing
)
R.id.personalizeSettings -> inflateFragment(
PersonalizeSettingsFragment(),
R.string.personalize
)
R.id.imageSettings -> inflateFragment(
ImageSettingFragment(),
R.string.pref_header_images
)
R.id.notificationSettings -> inflateFragment(
NotificationSettingsFragment(),
R.string.notification
)
R.id.otherSettings -> inflateFragment(OtherSettingsFragment(), R.string.others)
R.id.aboutSettings -> NavigationUtil.goToAbout(requireActivity())
R.id.generalSettings -> findNavController().navigate(R.id.action_mainSettingsFragment_to_themeSettingsFragment)
R.id.audioSettings -> findNavController().navigate(R.id.action_mainSettingsFragment_to_audioSettings)
R.id.personalizeSettings -> findNavController().navigate(R.id.action_mainSettingsFragment_to_personalizeSettingsFragment)
R.id.imageSettings -> findNavController().navigate(R.id.action_mainSettingsFragment_to_imageSettingFragment)
R.id.notificationSettings -> findNavController().navigate(R.id.action_mainSettingsFragment_to_notificationSettingsFragment)
R.id.otherSettings -> findNavController().navigate(R.id.action_mainSettingsFragment_to_otherSettingsFragment)
R.id.aboutSettings -> findNavController().navigate(R.id.action_mainSettingsFragment_to_aboutActivity)
R.id.nowPlayingSettings -> findNavController().navigate(R.id.action_mainSettingsFragment_to_nowPlayingSettingsFragment)
}
}

View file

@ -1,30 +1,35 @@
package io.github.muntashirakon.music.fragments.songs
import android.os.Bundle
import android.view.View
import android.view.*
import androidx.annotation.LayoutRes
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.GridLayoutManager
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.adapter.song.ShuffleButtonSongAdapter
import io.github.muntashirakon.music.adapter.song.SongAdapter
import io.github.muntashirakon.music.fragments.ReloadType
import io.github.muntashirakon.music.fragments.base.AbsLibraryPagerRecyclerViewCustomGridSizeFragment
import io.github.muntashirakon.music.fragments.base.AbsRecyclerViewCustomGridSizeFragment
import io.github.muntashirakon.music.interfaces.MainActivityFragmentCallbacks
import io.github.muntashirakon.music.util.PreferenceUtil
class SongsFragment :
AbsLibraryPagerRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>(),
AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>(),
MainActivityFragmentCallbacks {
override fun handleBackPress(): Boolean {
return false
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
mainActivity.libraryViewModel.allSongs()
.observe(viewLifecycleOwner, androidx.lifecycle.Observer {
if (it.isNotEmpty()) {
adapter?.swapDataSet(it)
} else {
adapter?.swapDataSet(listOf())
}
})
libraryViewModel.songsLiveData.observe(viewLifecycleOwner, Observer {
if (it.isNotEmpty()) {
adapter?.swapDataSet(it)
} else {
adapter?.swapDataSet(listOf())
}
})
}
override val emptyMessage: Int
@ -73,7 +78,7 @@ class SongsFragment :
override fun setGridSize(gridSize: Int) {
adapter?.notifyDataSetChanged()
}
override fun loadSortOrder(): String {
return PreferenceUtil.songSortOrder
}
@ -92,7 +97,7 @@ class SongsFragment :
}
override fun setSortOrder(sortOrder: String) {
mainActivity.libraryViewModel.forceReload(ReloadType.Songs)
libraryViewModel.forceReload(ReloadType.Songs)
}
companion object {
@ -105,8 +110,71 @@ class SongsFragment :
}
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
setUpGridSizeMenu(menu.findItem(R.id.action_grid_size).subMenu)
}
override fun handleBackPress(): Boolean {
private fun setUpGridSizeMenu(
gridSizeMenu: SubMenu
) {
println(getGridSize())
when (getGridSize()) {
1 -> gridSizeMenu.findItem(R.id.action_grid_size_1).isChecked = true
2 -> gridSizeMenu.findItem(R.id.action_grid_size_2).isChecked = true
3 -> gridSizeMenu.findItem(R.id.action_grid_size_3).isChecked = true
4 -> gridSizeMenu.findItem(R.id.action_grid_size_4).isChecked = true
5 -> gridSizeMenu.findItem(R.id.action_grid_size_5).isChecked = true
6 -> gridSizeMenu.findItem(R.id.action_grid_size_6).isChecked = true
7 -> gridSizeMenu.findItem(R.id.action_grid_size_7).isChecked = true
8 -> gridSizeMenu.findItem(R.id.action_grid_size_8).isChecked = true
}
val maxGridSize = maxGridSize
if (maxGridSize < 8) {
gridSizeMenu.findItem(R.id.action_grid_size_8).isVisible = false
}
if (maxGridSize < 7) {
gridSizeMenu.findItem(R.id.action_grid_size_7).isVisible = false
}
if (maxGridSize < 6) {
gridSizeMenu.findItem(R.id.action_grid_size_6).isVisible = false
}
if (maxGridSize < 5) {
gridSizeMenu.findItem(R.id.action_grid_size_5).isVisible = false
}
if (maxGridSize < 4) {
gridSizeMenu.findItem(R.id.action_grid_size_4).isVisible = false
}
if (maxGridSize < 3) {
gridSizeMenu.findItem(R.id.action_grid_size_3).isVisible = false
}
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (handleGridSizeMenuItem(item)) return true
return super.onOptionsItemSelected(item)
}
fun handleGridSizeMenuItem(
item: MenuItem
): Boolean {
var gridSize = 0
when (item.itemId) {
R.id.action_grid_size_1 -> gridSize = 1
R.id.action_grid_size_2 -> gridSize = 2
R.id.action_grid_size_3 -> gridSize = 3
R.id.action_grid_size_4 -> gridSize = 4
R.id.action_grid_size_5 -> gridSize = 5
R.id.action_grid_size_6 -> gridSize = 6
R.id.action_grid_size_7 -> gridSize = 7
R.id.action_grid_size_8 -> gridSize = 8
}
if (gridSize > 0) {
item.isChecked = true
setAndSaveGridSize(gridSize)
return true
}
return false
}
}

View file

@ -11,14 +11,11 @@
* 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.interfaces
/**
* Created by hemanths on 14/08/17.
*/
interface MainActivityFragmentCallbacks {
internal interface MainActivityFragmentCallbacks {
fun handleBackPress(): Boolean
}
}

View file

@ -24,6 +24,7 @@ import androidx.core.text.HtmlCompat
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentActivity
import code.name.monkey.appthemehelper.common.prefs.supportv7.ATEDialogPreference
import io.github.muntashirakon.music.App
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.dialogs.BlacklistFolderChooserDialog
import io.github.muntashirakon.music.extensions.colorButtons
@ -101,12 +102,14 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
)
)
.setPositiveButton(R.string.remove_action) { _, _ ->
BlacklistStore.getInstance(mContext!!)
BlacklistStore.getInstance(App.getContext())
.removePath(File(paths[which]))
refreshBlacklistData()
}
.setNegativeButton(android.R.string.cancel, null)
.show().colorButtons()
.create()
.colorButtons()
.show()
}
.create().colorButtons()
}
@ -114,13 +117,13 @@ class BlacklistPreferenceDialog : DialogFragment(), BlacklistFolderChooserDialog
private lateinit var paths: ArrayList<String>
private fun refreshBlacklistData() {
this.paths = BlacklistStore.getInstance(mContext!!).paths
this.paths = BlacklistStore.getInstance(App.getContext()).paths
val dialog = dialog as MaterialAlertDialogBuilder?
dialog?.setItems(paths.toTypedArray(), null)
}
override fun onFolderSelection(dialog: BlacklistFolderChooserDialog, folder: File) {
BlacklistStore.getInstance(mContext!!).addPath(folder)
BlacklistStore.getInstance(App.getContext()).addPath(folder)
refreshBlacklistData()
}
}

View file

@ -1,11 +0,0 @@
package io.github.muntashirakon.music.providers
import org.eclipse.egit.github.core.Repository
import org.koin.dsl.bind
import org.koin.dsl.module
val provideModules = module {
single {
RepositoryImpl(get(), get())
} bind Repository::class
}

View file

@ -32,19 +32,19 @@ class RepositoryImpl(
override suspend fun allAlbums(): List<Album> = AlbumLoader.getAllAlbums(context)
override suspend fun albumById(albumId: Int): Album = AlbumLoader.getAlbum(context, albumId)
override suspend fun allArtists(): List<Artist> = ArtistLoader.getAllArtists(context)
override suspend fun artistById(artistId: Int): Artist =
ArtistLoader.getArtist(context, artistId)
override suspend fun allPlaylists(): List<Playlist> = PlaylistLoader.getAllPlaylists(context)
override suspend fun allGenres(): List<Genre> = GenreLoader.getAllGenres(context)
override suspend fun allSongs(): List<Song> = SongLoader.getAllSongs(context)
override suspend fun albumById(albumId: Int): Album = AlbumLoader.getAlbum(context, albumId)
override suspend fun artistById(artistId: Int): Artist =
ArtistLoader.getArtist(context, artistId)
override suspend fun suggestions(): Home? {
val songs = NotRecentlyPlayedPlaylist(context).getSongs(context).shuffled().apply {
if (size > 9) subList(0, 9)
@ -59,6 +59,22 @@ class RepositoryImpl(
return null
}
override suspend fun homeGenres(): Home? {
val genres =
GenreLoader.getAllGenres(context)
.shuffled()
.filter { it.name.length in 5..10 }
if (genres.isNotEmpty()) {
return Home(
genres,
HomeAdapter.GENRES,
R.drawable.ic_guitar
)
}
return null
}
override suspend fun search(query: String?): MutableList<Any> =
SearchLoader.searchAll(context, query)

View file

@ -58,4 +58,6 @@ interface Repository {
suspend fun favoritePlaylist(): Home?
suspend fun suggestions(): Home?
suspend fun homeGenres(): Home?
}

View file

@ -170,6 +170,7 @@ public class MusicService extends Service implements
private AppWidgetSmall appWidgetSmall = AppWidgetSmall.Companion.getInstance();
private AppWidgetText appWidgetText = AppWidgetText.Companion.getInstance();
private final BroadcastReceiver widgetIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, final Intent intent) {

View file

@ -8,12 +8,12 @@ import androidx.core.content.ContextCompat
import androidx.core.content.edit
import androidx.preference.PreferenceManager
import androidx.viewpager.widget.ViewPager
import io.github.muntashirakon.music.R
import io.github.muntashirakon.music.*
import io.github.muntashirakon.music.extensions.getIntRes
import io.github.muntashirakon.music.extensions.getStringOrDefault
import io.github.muntashirakon.music.fragments.AlbumCoverStyle
import io.github.muntashirakon.music.fragments.NowPlayingScreen
import io.github.muntashirakon.music.fragments.mainactivity.FoldersFragment
import io.github.muntashirakon.music.fragments.folder.FoldersFragment
import io.github.muntashirakon.music.helper.SortOrder.*
import io.github.muntashirakon.music.model.CategoryInfo
import io.github.muntashirakon.music.transform.*
@ -22,7 +22,6 @@ import com.google.android.material.bottomnavigation.LabelVisibilityMode
import com.google.gson.Gson
import com.google.gson.JsonSyntaxException
import com.google.gson.reflect.TypeToken
import io.github.muntashirakon.music.*
import java.io.File
@ -64,16 +63,14 @@ object PreferenceUtil {
}
fun registerOnSharedPreferenceChangedListener(
changeListener: OnSharedPreferenceChangeListener
) {
sharedPreferences.registerOnSharedPreferenceChangeListener(changeListener)
}
listener: OnSharedPreferenceChangeListener
) = sharedPreferences.registerOnSharedPreferenceChangeListener(listener)
fun unregisterOnSharedPreferenceChangedListener(
changeListener: OnSharedPreferenceChangeListener
) {
sharedPreferences.unregisterOnSharedPreferenceChangeListener(changeListener)
}
) = sharedPreferences.unregisterOnSharedPreferenceChangeListener(changeListener)
val baseTheme get() = sharedPreferences.getStringOrDefault(GENERAL_THEME, "auto")

View file

@ -46,7 +46,7 @@ class ListItemView : FrameLayout {
}
private fun init(context: Context, attrs: AttributeSet?) {
View.inflate(context, R.layout.list_item_view, this)
View.inflate(context, R.layout.list_item_view_no_card, this)
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.ListItemView)
if (typedArray.hasValue(R.styleable.ListItemView_listItemIcon)) {