recycler: refactor displaymode usage
Remove the SHOW_ALL variant from DisplayMode, replacing it with null in SearchFragment where it was initially used. This allows all the home pager fragments to be combined into a single HomeListFragment that simply chooses a DisplayMode.
This commit is contained in:
parent
27764046f7
commit
776776690d
14 changed files with 168 additions and 384 deletions
|
@ -32,24 +32,25 @@ import com.google.android.material.tabs.TabLayoutMediator
|
||||||
import org.oxycblt.auxio.MainFragmentDirections
|
import org.oxycblt.auxio.MainFragmentDirections
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.databinding.FragmentHomeBinding
|
import org.oxycblt.auxio.databinding.FragmentHomeBinding
|
||||||
import org.oxycblt.auxio.home.pager.AlbumListFragment
|
|
||||||
import org.oxycblt.auxio.home.pager.ArtistListFragment
|
|
||||||
import org.oxycblt.auxio.home.pager.GenreListFragment
|
|
||||||
import org.oxycblt.auxio.home.pager.SongListFragment
|
|
||||||
import org.oxycblt.auxio.logD
|
import org.oxycblt.auxio.logD
|
||||||
import org.oxycblt.auxio.logE
|
import org.oxycblt.auxio.logE
|
||||||
import org.oxycblt.auxio.playback.PlaybackViewModel
|
import org.oxycblt.auxio.playback.PlaybackViewModel
|
||||||
|
import org.oxycblt.auxio.recycler.DisplayMode
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main "Launching Point" fragment of Auxio, allowing navigation to the detail
|
* The main "Launching Point" fragment of Auxio, allowing navigation to the detail
|
||||||
* views for each respective fragment.
|
* views for each respective fragment.
|
||||||
* TODO: Re-add sorting (but new and improved)
|
* TODO: Re-add sorting (but new and improved)
|
||||||
* TODO: Fix issue where elevation will act wrong when switching tabs
|
* TODO: Add lift-on-scroll eventually
|
||||||
* @author OxygenCobalt
|
* @author OxygenCobalt
|
||||||
*/
|
*/
|
||||||
class HomeFragment : Fragment() {
|
class HomeFragment : Fragment() {
|
||||||
private val playbackModel: PlaybackViewModel by activityViewModels()
|
private val playbackModel: PlaybackViewModel by activityViewModels()
|
||||||
|
private val tabs = arrayOf(
|
||||||
|
DisplayMode.SHOW_SONGS, DisplayMode.SHOW_ALBUMS,
|
||||||
|
DisplayMode.SHOW_ARTISTS, DisplayMode.SHOW_GENRES
|
||||||
|
)
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
|
@ -106,12 +107,11 @@ class HomeFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
TabLayoutMediator(binding.homeTabs, binding.homePager) { tab, pos ->
|
TabLayoutMediator(binding.homeTabs, binding.homePager) { tab, pos ->
|
||||||
val labelRes = when (pos) {
|
val labelRes = when (tabs[pos]) {
|
||||||
0 -> R.string.lbl_songs
|
DisplayMode.SHOW_SONGS -> R.string.lbl_songs
|
||||||
1 -> R.string.lbl_albums
|
DisplayMode.SHOW_ALBUMS -> R.string.lbl_albums
|
||||||
2 -> R.string.lbl_artists
|
DisplayMode.SHOW_ARTISTS -> R.string.lbl_artists
|
||||||
3 -> R.string.lbl_genres
|
DisplayMode.SHOW_GENRES -> R.string.lbl_genres
|
||||||
else -> error("Unreachable")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tab.setText(labelRes)
|
tab.setText(labelRes)
|
||||||
|
@ -128,16 +128,8 @@ class HomeFragment : Fragment() {
|
||||||
|
|
||||||
private inner class HomePagerAdapter :
|
private inner class HomePagerAdapter :
|
||||||
FragmentStateAdapter(childFragmentManager, viewLifecycleOwner.lifecycle) {
|
FragmentStateAdapter(childFragmentManager, viewLifecycleOwner.lifecycle) {
|
||||||
override fun createFragment(position: Int): Fragment {
|
|
||||||
return when (position) {
|
|
||||||
0 -> SongListFragment()
|
|
||||||
1 -> AlbumListFragment()
|
|
||||||
2 -> ArtistListFragment()
|
|
||||||
3 -> GenreListFragment()
|
|
||||||
else -> error("Unreachable")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemCount(): Int = 4
|
override fun getItemCount(): Int = tabs.size
|
||||||
|
override fun createFragment(position: Int): Fragment = HomeListFragment.new(tabs[position])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2021 Auxio Project
|
* Copyright (c) 2021 Auxio Project
|
||||||
* GenreListFragment.kt is part of Auxio.
|
* HomeListFragment.kt is part of Auxio.
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.oxycblt.auxio.home.pager
|
package org.oxycblt.auxio.home
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
@ -24,17 +24,25 @@ import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import org.oxycblt.auxio.databinding.FragmentHomeListBinding
|
import org.oxycblt.auxio.databinding.FragmentHomeListBinding
|
||||||
import org.oxycblt.auxio.home.HomeAdapter
|
import org.oxycblt.auxio.music.Album
|
||||||
import org.oxycblt.auxio.music.MusicStore
|
import org.oxycblt.auxio.music.Artist
|
||||||
|
import org.oxycblt.auxio.music.Genre
|
||||||
import org.oxycblt.auxio.music.Song
|
import org.oxycblt.auxio.music.Song
|
||||||
import org.oxycblt.auxio.playback.PlaybackViewModel
|
import org.oxycblt.auxio.playback.PlaybackViewModel
|
||||||
|
import org.oxycblt.auxio.recycler.DisplayMode
|
||||||
import org.oxycblt.auxio.spans
|
import org.oxycblt.auxio.spans
|
||||||
import org.oxycblt.auxio.ui.newMenu
|
import org.oxycblt.auxio.ui.newMenu
|
||||||
|
|
||||||
class SongListFragment : Fragment() {
|
/*
|
||||||
|
* Fragment that contains a list of items specified by a [DisplayMode].
|
||||||
|
*/
|
||||||
|
class HomeListFragment : Fragment() {
|
||||||
|
private val homeModel: HomeViewModel by viewModels()
|
||||||
private val playbackModel: PlaybackViewModel by viewModels()
|
private val playbackModel: PlaybackViewModel by viewModels()
|
||||||
|
private lateinit var displayMode: DisplayMode
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
|
@ -45,13 +53,28 @@ class SongListFragment : Fragment() {
|
||||||
|
|
||||||
val homeAdapter = HomeAdapter(
|
val homeAdapter = HomeAdapter(
|
||||||
doOnClick = { item ->
|
doOnClick = { item ->
|
||||||
playbackModel.playSong(item as Song)
|
when (item) {
|
||||||
|
is Song -> playbackModel.playSong(item)
|
||||||
|
|
||||||
|
is Album -> findNavController().navigate(
|
||||||
|
HomeFragmentDirections.actionShowAlbum(item.id)
|
||||||
|
)
|
||||||
|
|
||||||
|
is Artist -> findNavController().navigate(
|
||||||
|
HomeFragmentDirections.actionShowArtist(item.id)
|
||||||
|
)
|
||||||
|
|
||||||
|
is Genre -> findNavController().navigate(
|
||||||
|
HomeFragmentDirections.actionShowGenre(item.id)
|
||||||
|
)
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
::newMenu
|
::newMenu
|
||||||
)
|
)
|
||||||
|
|
||||||
homeAdapter.updateData(MusicStore.getInstance().songs)
|
|
||||||
|
|
||||||
// --- UI SETUP ---
|
// --- UI SETUP ---
|
||||||
|
|
||||||
binding.homeRecycler.apply {
|
binding.homeRecycler.apply {
|
||||||
|
@ -63,6 +86,30 @@ class SongListFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- VIEWMODEL SETUP ---
|
||||||
|
|
||||||
|
val data = when (displayMode) {
|
||||||
|
DisplayMode.SHOW_SONGS -> homeModel.songs
|
||||||
|
DisplayMode.SHOW_ALBUMS -> homeModel.albums
|
||||||
|
DisplayMode.SHOW_ARTISTS -> homeModel.artists
|
||||||
|
DisplayMode.SHOW_GENRES -> homeModel.genres
|
||||||
|
}
|
||||||
|
|
||||||
|
data.observe(viewLifecycleOwner) { data ->
|
||||||
|
homeAdapter.updateData(data)
|
||||||
|
}
|
||||||
|
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
/*
|
||||||
|
* Instantiates this fragment for use in a ViewPager.
|
||||||
|
*/
|
||||||
|
fun new(mode: DisplayMode): HomeListFragment {
|
||||||
|
val fragment = HomeListFragment()
|
||||||
|
fragment.displayMode = mode
|
||||||
|
return fragment
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
51
app/src/main/java/org/oxycblt/auxio/home/HomeViewModel.kt
Normal file
51
app/src/main/java/org/oxycblt/auxio/home/HomeViewModel.kt
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 Auxio Project
|
||||||
|
* HomeViewModel.kt is part of Auxio.
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.oxycblt.auxio.home
|
||||||
|
|
||||||
|
import androidx.lifecycle.LiveData
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
|
import androidx.lifecycle.ViewModel
|
||||||
|
import org.oxycblt.auxio.music.Album
|
||||||
|
import org.oxycblt.auxio.music.Artist
|
||||||
|
import org.oxycblt.auxio.music.Genre
|
||||||
|
import org.oxycblt.auxio.music.MusicStore
|
||||||
|
import org.oxycblt.auxio.music.Song
|
||||||
|
|
||||||
|
class HomeViewModel : ViewModel() {
|
||||||
|
private val mGenres = MutableLiveData(listOf<Genre>())
|
||||||
|
val genres: LiveData<List<Genre>> get() = mGenres
|
||||||
|
|
||||||
|
private val mArtists = MutableLiveData(listOf<Artist>())
|
||||||
|
val artists: LiveData<List<Artist>> get() = mArtists
|
||||||
|
|
||||||
|
private val mAlbums = MutableLiveData(listOf<Album>())
|
||||||
|
val albums: LiveData<List<Album>> get() = mAlbums
|
||||||
|
|
||||||
|
private val mSongs = MutableLiveData(listOf<Song>())
|
||||||
|
val songs: LiveData<List<Song>> get() = mSongs
|
||||||
|
|
||||||
|
private val musicStore = MusicStore.getInstance()
|
||||||
|
|
||||||
|
init {
|
||||||
|
mGenres.value = musicStore.genres
|
||||||
|
mArtists.value = musicStore.artists
|
||||||
|
mAlbums.value = musicStore.albums
|
||||||
|
mSongs.value = musicStore.songs
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,65 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2021 Auxio Project
|
|
||||||
* GenreListFragment.kt is part of Auxio.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.oxycblt.auxio.home.pager
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.navigation.fragment.findNavController
|
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
|
||||||
import org.oxycblt.auxio.databinding.FragmentHomeListBinding
|
|
||||||
import org.oxycblt.auxio.home.HomeAdapter
|
|
||||||
import org.oxycblt.auxio.home.HomeFragmentDirections
|
|
||||||
import org.oxycblt.auxio.music.MusicStore
|
|
||||||
import org.oxycblt.auxio.spans
|
|
||||||
import org.oxycblt.auxio.ui.newMenu
|
|
||||||
|
|
||||||
class AlbumListFragment : Fragment() {
|
|
||||||
override fun onCreateView(
|
|
||||||
inflater: LayoutInflater,
|
|
||||||
container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?
|
|
||||||
): View {
|
|
||||||
val binding = FragmentHomeListBinding.inflate(inflater)
|
|
||||||
|
|
||||||
val homeAdapter = HomeAdapter(
|
|
||||||
doOnClick = { item ->
|
|
||||||
findNavController().navigate(HomeFragmentDirections.actionShowAlbum(item.id))
|
|
||||||
},
|
|
||||||
::newMenu
|
|
||||||
)
|
|
||||||
|
|
||||||
homeAdapter.updateData(MusicStore.getInstance().albums)
|
|
||||||
|
|
||||||
// --- UI SETUP ---
|
|
||||||
|
|
||||||
binding.homeRecycler.apply {
|
|
||||||
adapter = homeAdapter
|
|
||||||
setHasFixedSize(true)
|
|
||||||
|
|
||||||
if (spans != 1) {
|
|
||||||
layoutManager = GridLayoutManager(requireContext(), spans)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return binding.root
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2021 Auxio Project
|
|
||||||
* GenreListFragment.kt is part of Auxio.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.oxycblt.auxio.home.pager
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.navigation.fragment.findNavController
|
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
|
||||||
import org.oxycblt.auxio.databinding.FragmentHomeListBinding
|
|
||||||
import org.oxycblt.auxio.home.HomeAdapter
|
|
||||||
import org.oxycblt.auxio.home.HomeFragmentDirections
|
|
||||||
import org.oxycblt.auxio.music.MusicStore
|
|
||||||
import org.oxycblt.auxio.spans
|
|
||||||
import org.oxycblt.auxio.ui.newMenu
|
|
||||||
|
|
||||||
class ArtistListFragment : Fragment() {
|
|
||||||
override fun onCreateView(
|
|
||||||
inflater: LayoutInflater,
|
|
||||||
container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?
|
|
||||||
): View {
|
|
||||||
val binding = FragmentHomeListBinding.inflate(inflater)
|
|
||||||
|
|
||||||
val homeAdapter = HomeAdapter(
|
|
||||||
doOnClick = { item ->
|
|
||||||
findNavController().navigate(HomeFragmentDirections.actionShowArtist(item.id))
|
|
||||||
},
|
|
||||||
::newMenu
|
|
||||||
)
|
|
||||||
|
|
||||||
homeAdapter.updateData(MusicStore.getInstance().artists)
|
|
||||||
|
|
||||||
// --- UI SETUP ---
|
|
||||||
|
|
||||||
binding.homeRecycler.apply {
|
|
||||||
adapter = homeAdapter
|
|
||||||
setHasFixedSize(true)
|
|
||||||
|
|
||||||
if (spans != 1) {
|
|
||||||
layoutManager = GridLayoutManager(requireContext(), spans)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return binding.root
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2021 Auxio Project
|
|
||||||
* GenreListFragment.kt is part of Auxio.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.oxycblt.auxio.home.pager
|
|
||||||
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.navigation.fragment.findNavController
|
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
|
||||||
import org.oxycblt.auxio.databinding.FragmentHomeListBinding
|
|
||||||
import org.oxycblt.auxio.home.HomeAdapter
|
|
||||||
import org.oxycblt.auxio.home.HomeFragmentDirections
|
|
||||||
import org.oxycblt.auxio.music.MusicStore
|
|
||||||
import org.oxycblt.auxio.spans
|
|
||||||
import org.oxycblt.auxio.ui.newMenu
|
|
||||||
|
|
||||||
class GenreListFragment : Fragment() {
|
|
||||||
override fun onCreateView(
|
|
||||||
inflater: LayoutInflater,
|
|
||||||
container: ViewGroup?,
|
|
||||||
savedInstanceState: Bundle?
|
|
||||||
): View {
|
|
||||||
val binding = FragmentHomeListBinding.inflate(inflater)
|
|
||||||
|
|
||||||
val homeAdapter = HomeAdapter(
|
|
||||||
doOnClick = { item ->
|
|
||||||
findNavController().navigate(HomeFragmentDirections.actionShowGenre(item.id))
|
|
||||||
},
|
|
||||||
::newMenu
|
|
||||||
)
|
|
||||||
|
|
||||||
homeAdapter.updateData(MusicStore.getInstance().genres)
|
|
||||||
|
|
||||||
// --- UI SETUP ---
|
|
||||||
|
|
||||||
binding.homeRecycler.apply {
|
|
||||||
adapter = homeAdapter
|
|
||||||
setHasFixedSize(true)
|
|
||||||
|
|
||||||
if (spans != 1) {
|
|
||||||
layoutManager = GridLayoutManager(requireContext(), spans)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return binding.root
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,7 +19,6 @@
|
||||||
package org.oxycblt.auxio.recycler
|
package org.oxycblt.auxio.recycler
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.annotation.IdRes
|
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,35 +26,11 @@ import org.oxycblt.auxio.R
|
||||||
* @author OxygenCobalt
|
* @author OxygenCobalt
|
||||||
*/
|
*/
|
||||||
enum class DisplayMode(@DrawableRes val iconRes: Int) {
|
enum class DisplayMode(@DrawableRes val iconRes: Int) {
|
||||||
SHOW_ALL(R.drawable.ic_sort_none),
|
|
||||||
SHOW_GENRES(R.drawable.ic_genre),
|
SHOW_GENRES(R.drawable.ic_genre),
|
||||||
SHOW_ARTISTS(R.drawable.ic_artist),
|
SHOW_ARTISTS(R.drawable.ic_artist),
|
||||||
SHOW_ALBUMS(R.drawable.ic_album),
|
SHOW_ALBUMS(R.drawable.ic_album),
|
||||||
SHOW_SONGS(R.drawable.ic_song);
|
SHOW_SONGS(R.drawable.ic_song);
|
||||||
|
|
||||||
fun isAllOr(value: DisplayMode) = this == SHOW_ALL || this == value
|
|
||||||
|
|
||||||
@IdRes
|
|
||||||
fun toId(): Int {
|
|
||||||
return when (this) {
|
|
||||||
SHOW_ALL -> R.id.option_filter_all
|
|
||||||
SHOW_GENRES -> R.id.option_filter_genres
|
|
||||||
SHOW_ARTISTS -> R.id.option_filter_artists
|
|
||||||
SHOW_ALBUMS -> R.id.option_filter_albums
|
|
||||||
SHOW_SONGS -> R.id.option_filter_songs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun toInt(): Int {
|
|
||||||
return when (this) {
|
|
||||||
SHOW_ALL -> CONST_SHOW_ALL
|
|
||||||
SHOW_GENRES -> CONST_SHOW_GENRES
|
|
||||||
SHOW_ARTISTS -> CONST_SHOW_ARTISTS
|
|
||||||
SHOW_ALBUMS -> CONST_SHOW_ALBUMS
|
|
||||||
SHOW_SONGS -> CONST_SHOW_SONGS
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val CONST_SHOW_ALL = 0xA107
|
const val CONST_SHOW_ALL = 0xA107
|
||||||
const val CONST_SHOW_GENRES = 0xA108
|
const val CONST_SHOW_GENRES = 0xA108
|
||||||
|
@ -63,30 +38,22 @@ enum class DisplayMode(@DrawableRes val iconRes: Int) {
|
||||||
const val CONST_SHOW_ALBUMS = 0xA10A
|
const val CONST_SHOW_ALBUMS = 0xA10A
|
||||||
const val CONST_SHOW_SONGS = 0xA10B
|
const val CONST_SHOW_SONGS = 0xA10B
|
||||||
|
|
||||||
fun fromId(@IdRes id: Int): DisplayMode {
|
fun toSearchInt(value: DisplayMode?): Int {
|
||||||
return when (id) {
|
|
||||||
R.id.option_filter_all -> SHOW_ALL
|
|
||||||
R.id.option_filter_songs -> SHOW_SONGS
|
|
||||||
R.id.option_filter_albums -> SHOW_ALBUMS
|
|
||||||
R.id.option_filter_artists -> SHOW_ARTISTS
|
|
||||||
R.id.option_filter_genres -> SHOW_GENRES
|
|
||||||
|
|
||||||
else -> SHOW_ALL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get an enum for an int constant
|
|
||||||
* @return The [DisplayMode] if the constant is valid, null otherwise.
|
|
||||||
*/
|
|
||||||
fun fromInt(value: Int): DisplayMode? {
|
|
||||||
return when (value) {
|
return when (value) {
|
||||||
CONST_SHOW_ALL -> SHOW_ALL
|
SHOW_SONGS -> CONST_SHOW_SONGS
|
||||||
CONST_SHOW_GENRES -> SHOW_GENRES
|
SHOW_ALBUMS -> CONST_SHOW_ALBUMS
|
||||||
CONST_SHOW_ARTISTS -> SHOW_ARTISTS
|
SHOW_ARTISTS -> CONST_SHOW_ARTISTS
|
||||||
CONST_SHOW_ALBUMS -> SHOW_ALBUMS
|
SHOW_GENRES -> CONST_SHOW_GENRES
|
||||||
CONST_SHOW_SONGS -> SHOW_SONGS
|
null -> CONST_SHOW_ALL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun fromSearchInt(value: Int): DisplayMode? {
|
||||||
|
return when (value) {
|
||||||
|
CONST_SHOW_SONGS -> SHOW_SONGS
|
||||||
|
CONST_SHOW_ALBUMS -> SHOW_ALBUMS
|
||||||
|
CONST_SHOW_ARTISTS -> SHOW_ARTISTS
|
||||||
|
CONST_SHOW_GENRES -> SHOW_GENRES
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.oxycblt.auxio.music.Genre
|
||||||
import org.oxycblt.auxio.music.Header
|
import org.oxycblt.auxio.music.Header
|
||||||
import org.oxycblt.auxio.music.Song
|
import org.oxycblt.auxio.music.Song
|
||||||
import org.oxycblt.auxio.playback.PlaybackViewModel
|
import org.oxycblt.auxio.playback.PlaybackViewModel
|
||||||
|
import org.oxycblt.auxio.recycler.DisplayMode
|
||||||
import org.oxycblt.auxio.spans
|
import org.oxycblt.auxio.spans
|
||||||
import org.oxycblt.auxio.ui.newMenu
|
import org.oxycblt.auxio.ui.newMenu
|
||||||
|
|
||||||
|
@ -75,7 +76,15 @@ class SearchFragment : Fragment() {
|
||||||
binding.lifecycleOwner = viewLifecycleOwner
|
binding.lifecycleOwner = viewLifecycleOwner
|
||||||
|
|
||||||
binding.searchToolbar.apply {
|
binding.searchToolbar.apply {
|
||||||
menu.findItem(searchModel.filterMode.toId()).isChecked = true
|
val itemId = when (searchModel.filterMode) {
|
||||||
|
DisplayMode.SHOW_SONGS -> R.id.option_filter_songs
|
||||||
|
DisplayMode.SHOW_ALBUMS -> R.id.option_filter_albums
|
||||||
|
DisplayMode.SHOW_ARTISTS -> R.id.option_filter_artists
|
||||||
|
DisplayMode.SHOW_GENRES -> R.id.option_filter_genres
|
||||||
|
null -> R.id.option_filter_all
|
||||||
|
}
|
||||||
|
|
||||||
|
menu.findItem(itemId).isChecked = true
|
||||||
|
|
||||||
setNavigationOnClickListener {
|
setNavigationOnClickListener {
|
||||||
requireView().rootView.clearFocus()
|
requireView().rootView.clearFocus()
|
||||||
|
|
|
@ -39,13 +39,13 @@ import org.oxycblt.auxio.settings.SettingsManager
|
||||||
class SearchViewModel : ViewModel() {
|
class SearchViewModel : ViewModel() {
|
||||||
private val mSearchResults = MutableLiveData(listOf<BaseModel>())
|
private val mSearchResults = MutableLiveData(listOf<BaseModel>())
|
||||||
private var mIsNavigating = false
|
private var mIsNavigating = false
|
||||||
private var mFilterMode = DisplayMode.SHOW_ALL
|
private var mFilterMode: DisplayMode? = null
|
||||||
private var mLastQuery = ""
|
private var mLastQuery = ""
|
||||||
|
|
||||||
/** Current search results from the last [doSearch] call. */
|
/** Current search results from the last [doSearch] call. */
|
||||||
val searchResults: LiveData<List<BaseModel>> get() = mSearchResults
|
val searchResults: LiveData<List<BaseModel>> get() = mSearchResults
|
||||||
val isNavigating: Boolean get() = mIsNavigating
|
val isNavigating: Boolean get() = mIsNavigating
|
||||||
val filterMode: DisplayMode get() = mFilterMode
|
val filterMode: DisplayMode? get() = mFilterMode
|
||||||
|
|
||||||
private val musicStore = MusicStore.getInstance()
|
private val musicStore = MusicStore.getInstance()
|
||||||
private val settingsManager = SettingsManager.getInstance()
|
private val settingsManager = SettingsManager.getInstance()
|
||||||
|
@ -70,31 +70,33 @@ class SearchViewModel : ViewModel() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val results = mutableListOf<BaseModel>()
|
val results = mutableListOf<BaseModel>()
|
||||||
|
|
||||||
if (mFilterMode.isAllOr(DisplayMode.SHOW_ARTISTS)) {
|
// A filter mode of null means to not filter at all.
|
||||||
musicStore.artists.filterByOrNull(query)?.let { artists ->
|
|
||||||
results.add(Header(id = -2, name = context.getString(R.string.lbl_artists)))
|
if (mFilterMode == null || mFilterMode == DisplayMode.SHOW_SONGS) {
|
||||||
results.addAll(artists)
|
musicStore.songs.filterByOrNull(query)?.let { songs ->
|
||||||
|
results.add(Header(id = -2, name = context.getString(R.string.lbl_songs)))
|
||||||
|
results.addAll(songs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mFilterMode.isAllOr(DisplayMode.SHOW_ALBUMS)) {
|
if (mFilterMode == null || mFilterMode == DisplayMode.SHOW_ALBUMS) {
|
||||||
musicStore.albums.filterByOrNull(query)?.let { albums ->
|
musicStore.albums.filterByOrNull(query)?.let { albums ->
|
||||||
results.add(Header(id = -3, name = context.getString(R.string.lbl_albums)))
|
results.add(Header(id = -3, name = context.getString(R.string.lbl_albums)))
|
||||||
results.addAll(albums)
|
results.addAll(albums)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mFilterMode.isAllOr(DisplayMode.SHOW_GENRES)) {
|
if (mFilterMode == null || mFilterMode == DisplayMode.SHOW_ARTISTS) {
|
||||||
musicStore.genres.filterByOrNull(query)?.let { genres ->
|
musicStore.artists.filterByOrNull(query)?.let { artists ->
|
||||||
results.add(Header(id = -4, name = context.getString(R.string.lbl_genres)))
|
results.add(Header(id = -4, name = context.getString(R.string.lbl_artists)))
|
||||||
results.addAll(genres)
|
results.addAll(artists)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mFilterMode.isAllOr(DisplayMode.SHOW_SONGS)) {
|
if (mFilterMode == null || mFilterMode == DisplayMode.SHOW_GENRES) {
|
||||||
musicStore.songs.filterByOrNull(query)?.let { songs ->
|
musicStore.genres.filterByOrNull(query)?.let { genres ->
|
||||||
results.add(Header(id = -5, name = context.getString(R.string.lbl_songs)))
|
results.add(Header(id = -5, name = context.getString(R.string.lbl_genres)))
|
||||||
results.addAll(songs)
|
results.addAll(genres)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +109,14 @@ class SearchViewModel : ViewModel() {
|
||||||
* New value will be pushed to [filterMode].
|
* New value will be pushed to [filterMode].
|
||||||
*/
|
*/
|
||||||
fun updateFilterModeWithId(@IdRes id: Int, context: Context) {
|
fun updateFilterModeWithId(@IdRes id: Int, context: Context) {
|
||||||
mFilterMode = DisplayMode.fromId(id)
|
mFilterMode = when (id) {
|
||||||
|
R.id.option_filter_songs -> DisplayMode.SHOW_SONGS
|
||||||
|
R.id.option_filter_albums -> DisplayMode.SHOW_ALBUMS
|
||||||
|
R.id.option_filter_artists -> DisplayMode.SHOW_ARTISTS
|
||||||
|
R.id.option_filter_genres -> DisplayMode.SHOW_GENRES
|
||||||
|
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
|
||||||
settingsManager.searchFilterMode = mFilterMode
|
settingsManager.searchFilterMode = mFilterMode
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ import androidx.core.content.edit
|
||||||
import org.oxycblt.auxio.accent.ACCENTS
|
import org.oxycblt.auxio.accent.ACCENTS
|
||||||
import org.oxycblt.auxio.accent.Accent
|
import org.oxycblt.auxio.accent.Accent
|
||||||
import org.oxycblt.auxio.playback.state.PlaybackMode
|
import org.oxycblt.auxio.playback.state.PlaybackMode
|
||||||
import org.oxycblt.auxio.recycler.DisplayMode
|
|
||||||
|
|
||||||
// A couple of utils for migrating from old settings values to the new
|
// A couple of utils for migrating from old settings values to the new
|
||||||
// formats used in 1.3.2 & 1.4.0
|
// formats used in 1.3.2 & 1.4.0
|
||||||
|
@ -84,23 +83,6 @@ fun handleAccentCompat(prefs: SharedPreferences): Accent {
|
||||||
return ACCENTS[prefs.getInt(SettingsManager.KEY_ACCENT, 5)]
|
return ACCENTS[prefs.getInt(SettingsManager.KEY_ACCENT, 5)]
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleLibDisplayCompat(prefs: SharedPreferences): DisplayMode {
|
|
||||||
if (prefs.contains(OldKeys.KEY_LIB_MODE)) {
|
|
||||||
val mode = prefs.handleOldDisplayMode(OldKeys.KEY_LIB_MODE) ?: DisplayMode.SHOW_ARTISTS
|
|
||||||
|
|
||||||
prefs.edit {
|
|
||||||
putInt(SettingsManager.KEY_LIB_DISPLAY_MODE, mode.toInt())
|
|
||||||
remove(OldKeys.KEY_LIB_MODE)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
return mode
|
|
||||||
}
|
|
||||||
|
|
||||||
return prefs.getData(SettingsManager.KEY_LIB_DISPLAY_MODE, DisplayMode::fromInt)
|
|
||||||
?: DisplayMode.SHOW_ARTISTS
|
|
||||||
}
|
|
||||||
|
|
||||||
fun handleSongPlayModeCompat(prefs: SharedPreferences): PlaybackMode {
|
fun handleSongPlayModeCompat(prefs: SharedPreferences): PlaybackMode {
|
||||||
if (prefs.contains(OldKeys.KEY_SONG_PLAYBACK_MODE)) {
|
if (prefs.contains(OldKeys.KEY_SONG_PLAYBACK_MODE)) {
|
||||||
val mode = when (prefs.getStringOrNull(OldKeys.KEY_SONG_PLAYBACK_MODE)) {
|
val mode = when (prefs.getStringOrNull(OldKeys.KEY_SONG_PLAYBACK_MODE)) {
|
||||||
|
@ -125,44 +107,13 @@ fun handleSongPlayModeCompat(prefs: SharedPreferences): PlaybackMode {
|
||||||
?: PlaybackMode.ALL_SONGS
|
?: PlaybackMode.ALL_SONGS
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleSearchModeCompat(prefs: SharedPreferences): DisplayMode {
|
|
||||||
if (prefs.contains(OldKeys.KEY_SEARCH_FILTER)) {
|
|
||||||
val mode = prefs.handleOldDisplayMode(OldKeys.KEY_SEARCH_FILTER) ?: DisplayMode.SHOW_ALL
|
|
||||||
|
|
||||||
prefs.edit {
|
|
||||||
putInt(SettingsManager.KEY_SEARCH_FILTER_MODE, mode.toInt())
|
|
||||||
remove(OldKeys.KEY_SEARCH_FILTER)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
return mode
|
|
||||||
}
|
|
||||||
|
|
||||||
return prefs.getData(SettingsManager.KEY_SEARCH_FILTER_MODE, DisplayMode::fromInt)
|
|
||||||
?: DisplayMode.SHOW_ALL
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun SharedPreferences.handleOldDisplayMode(key: String): DisplayMode? {
|
|
||||||
return when (getStringOrNull(key)) {
|
|
||||||
EntryValues.SHOW_GENRES -> DisplayMode.SHOW_GENRES
|
|
||||||
EntryValues.SHOW_ARTISTS -> DisplayMode.SHOW_ARTISTS
|
|
||||||
EntryValues.SHOW_ALBUMS -> DisplayMode.SHOW_ALBUMS
|
|
||||||
EntryValues.SHOW_SONGS -> DisplayMode.SHOW_SONGS
|
|
||||||
EntryValues.SHOW_ALL -> DisplayMode.SHOW_ALL
|
|
||||||
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache of the old keys used in Auxio.
|
* Cache of the old keys used in Auxio.
|
||||||
*/
|
*/
|
||||||
private object OldKeys {
|
private object OldKeys {
|
||||||
const val KEY_ACCENT = "KEY_ACCENT"
|
const val KEY_ACCENT = "KEY_ACCENT"
|
||||||
const val KEY_THEME = "KEY_THEME"
|
const val KEY_THEME = "KEY_THEME"
|
||||||
const val KEY_LIB_MODE = "KEY_LIBRARY_DISPLAY_MODE"
|
|
||||||
const val KEY_SONG_PLAYBACK_MODE = "KEY_SONG_PLAY_MODE"
|
const val KEY_SONG_PLAYBACK_MODE = "KEY_SONG_PLAY_MODE"
|
||||||
const val KEY_SEARCH_FILTER = "KEY_SEARCH"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,12 +124,6 @@ private object EntryValues {
|
||||||
const val THEME_LIGHT = "LIGHT"
|
const val THEME_LIGHT = "LIGHT"
|
||||||
const val THEME_DARK = "DARK"
|
const val THEME_DARK = "DARK"
|
||||||
|
|
||||||
const val SHOW_GENRES = "SHOW_GENRES"
|
|
||||||
const val SHOW_ARTISTS = "SHOW_ARTISTS"
|
|
||||||
const val SHOW_ALBUMS = "SHOW_ALBUMS"
|
|
||||||
const val SHOW_SONGS = "SHOW_SONGS"
|
|
||||||
const val SHOW_ALL = "SHOW_ALL"
|
|
||||||
|
|
||||||
const val IN_GENRE = "IN_GENRE"
|
const val IN_GENRE = "IN_GENRE"
|
||||||
const val IN_ARTIST = "IN_ARTIST"
|
const val IN_ARTIST = "IN_ARTIST"
|
||||||
const val IN_ALBUM = "IN_ALBUM"
|
const val IN_ALBUM = "IN_ALBUM"
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.oxycblt.auxio.excluded.ExcludedDialog
|
||||||
import org.oxycblt.auxio.isNight
|
import org.oxycblt.auxio.isNight
|
||||||
import org.oxycblt.auxio.logD
|
import org.oxycblt.auxio.logD
|
||||||
import org.oxycblt.auxio.playback.PlaybackViewModel
|
import org.oxycblt.auxio.playback.PlaybackViewModel
|
||||||
import org.oxycblt.auxio.recycler.DisplayMode
|
|
||||||
import org.oxycblt.auxio.settings.ui.IntListPrefDialog
|
import org.oxycblt.auxio.settings.ui.IntListPrefDialog
|
||||||
import org.oxycblt.auxio.settings.ui.IntListPreference
|
import org.oxycblt.auxio.settings.ui.IntListPreference
|
||||||
import org.oxycblt.auxio.showToast
|
import org.oxycblt.auxio.showToast
|
||||||
|
@ -120,15 +119,6 @@ class SettingsListFragment : PreferenceFragmentCompat() {
|
||||||
summary = Accent.get().getDetailedSummary(context)
|
summary = Accent.get().getDetailedSummary(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsManager.KEY_LIB_DISPLAY_MODE -> {
|
|
||||||
setIcon(settingsManager.libraryDisplayMode.iconRes)
|
|
||||||
|
|
||||||
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
|
|
||||||
setIcon(DisplayMode.fromInt(value as Int)!!.iconRes)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingsManager.KEY_SHOW_COVERS -> {
|
SettingsManager.KEY_SHOW_COVERS -> {
|
||||||
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, _ ->
|
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, _ ->
|
||||||
Coil.imageLoader(requireContext()).apply {
|
Coil.imageLoader(requireContext()).apply {
|
||||||
|
|
|
@ -80,10 +80,6 @@ class SettingsManager private constructor(context: Context) :
|
||||||
val useAltNotifAction: Boolean
|
val useAltNotifAction: Boolean
|
||||||
get() = sharedPrefs.getBoolean(KEY_USE_ALT_NOTIFICATION_ACTION, false)
|
get() = sharedPrefs.getBoolean(KEY_USE_ALT_NOTIFICATION_ACTION, false)
|
||||||
|
|
||||||
/** What to display on the library. */
|
|
||||||
val libraryDisplayMode: DisplayMode
|
|
||||||
get() = handleLibDisplayCompat(sharedPrefs)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to even loading embedded covers
|
* Whether to even loading embedded covers
|
||||||
*/
|
*/
|
||||||
|
@ -118,17 +114,6 @@ class SettingsManager private constructor(context: Context) :
|
||||||
val pauseOnLoop: Boolean
|
val pauseOnLoop: Boolean
|
||||||
get() = sharedPrefs.getBoolean(KEY_LOOP_PAUSE, false)
|
get() = sharedPrefs.getBoolean(KEY_LOOP_PAUSE, false)
|
||||||
|
|
||||||
/** The current [SortMode] of the library. */
|
|
||||||
var librarySortMode: SortMode
|
|
||||||
get() = sharedPrefs.getData(KEY_LIB_SORT_MODE, SortMode::fromInt) ?: SortMode.ALPHA_DOWN
|
|
||||||
|
|
||||||
set(value) {
|
|
||||||
sharedPrefs.edit {
|
|
||||||
putInt(KEY_LIB_SORT_MODE, value.toInt())
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var albumSortMode: SortMode
|
var albumSortMode: SortMode
|
||||||
get() = sharedPrefs.getData(KEY_ALBUM_SORT_MODE, SortMode::fromInt) ?: SortMode.NUMERIC_DOWN
|
get() = sharedPrefs.getData(KEY_ALBUM_SORT_MODE, SortMode::fromInt) ?: SortMode.NUMERIC_DOWN
|
||||||
set(value) {
|
set(value) {
|
||||||
|
@ -157,12 +142,12 @@ class SettingsManager private constructor(context: Context) :
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The current filter mode of the search tab */
|
/** The current filter mode of the search tab */
|
||||||
var searchFilterMode: DisplayMode
|
var searchFilterMode: DisplayMode?
|
||||||
get() = handleSearchModeCompat(sharedPrefs)
|
get() = sharedPrefs.getData(KEY_SEARCH_FILTER_MODE, DisplayMode::fromSearchInt)
|
||||||
|
|
||||||
set(value) {
|
set(value) {
|
||||||
sharedPrefs.edit {
|
sharedPrefs.edit {
|
||||||
putInt(KEY_SEARCH_FILTER_MODE, value.toInt())
|
putInt(KEY_SEARCH_FILTER_MODE, DisplayMode.toSearchInt(value))
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,10 +176,6 @@ class SettingsManager private constructor(context: Context) :
|
||||||
it.onNotifActionUpdate(useAltNotifAction)
|
it.onNotifActionUpdate(useAltNotifAction)
|
||||||
}
|
}
|
||||||
|
|
||||||
KEY_LIB_DISPLAY_MODE -> callbacks.forEach {
|
|
||||||
it.onLibDisplayModeUpdate(libraryDisplayMode)
|
|
||||||
}
|
|
||||||
|
|
||||||
KEY_SHOW_COVERS -> callbacks.forEach {
|
KEY_SHOW_COVERS -> callbacks.forEach {
|
||||||
it.onShowCoverUpdate(showCovers)
|
it.onShowCoverUpdate(showCovers)
|
||||||
}
|
}
|
||||||
|
@ -213,7 +194,6 @@ class SettingsManager private constructor(context: Context) :
|
||||||
interface Callback {
|
interface Callback {
|
||||||
fun onColorizeNotifUpdate(doColorize: Boolean) {}
|
fun onColorizeNotifUpdate(doColorize: Boolean) {}
|
||||||
fun onNotifActionUpdate(useAltAction: Boolean) {}
|
fun onNotifActionUpdate(useAltAction: Boolean) {}
|
||||||
fun onLibDisplayModeUpdate(displayMode: DisplayMode) {}
|
|
||||||
fun onShowCoverUpdate(showCovers: Boolean) {}
|
fun onShowCoverUpdate(showCovers: Boolean) {}
|
||||||
fun onQualityCoverUpdate(doQualityCovers: Boolean) {}
|
fun onQualityCoverUpdate(doQualityCovers: Boolean) {}
|
||||||
}
|
}
|
||||||
|
@ -223,7 +203,6 @@ class SettingsManager private constructor(context: Context) :
|
||||||
const val KEY_BLACK_THEME = "KEY_BLACK_THEME"
|
const val KEY_BLACK_THEME = "KEY_BLACK_THEME"
|
||||||
const val KEY_ACCENT = "KEY_ACCENT2"
|
const val KEY_ACCENT = "KEY_ACCENT2"
|
||||||
|
|
||||||
const val KEY_LIB_DISPLAY_MODE = "KEY_LIB_MODE"
|
|
||||||
const val KEY_SHOW_COVERS = "KEY_SHOW_COVERS"
|
const val KEY_SHOW_COVERS = "KEY_SHOW_COVERS"
|
||||||
const val KEY_QUALITY_COVERS = "KEY_QUALITY_COVERS"
|
const val KEY_QUALITY_COVERS = "KEY_QUALITY_COVERS"
|
||||||
const val KEY_COLORIZE_NOTIFICATION = "KEY_COLOR_NOTIF"
|
const val KEY_COLORIZE_NOTIFICATION = "KEY_COLOR_NOTIF"
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
<!-- Appearance -->
|
<!-- Appearance -->
|
||||||
<item name="android:windowBackground">?attr/colorSurface</item>
|
<item name="android:windowBackground">?attr/colorSurface</item>
|
||||||
<item name="android:colorBackground">?attr/colorSurface</item>
|
<item name="android:colorBackground">?attr/colorSurface</item>
|
||||||
<item name="android:textColorSecondary">@color/secondary_text</item>
|
|
||||||
<item name="android:fontFamily">@font/inter</item>
|
<item name="android:fontFamily">@font/inter</item>
|
||||||
<item name="android:textCursorDrawable">@drawable/ui_cursor</item>
|
<item name="android:textCursorDrawable">@drawable/ui_cursor</item>
|
||||||
|
|
||||||
|
|
|
@ -34,15 +34,6 @@
|
||||||
app:layout="@layout/item_header"
|
app:layout="@layout/item_header"
|
||||||
app:title="@string/set_display">
|
app:title="@string/set_display">
|
||||||
|
|
||||||
<org.oxycblt.auxio.settings.ui.IntListPreference
|
|
||||||
app:defaultValue="@integer/display_artist"
|
|
||||||
app:entries="@array/entries_lib_display"
|
|
||||||
app:entryValues="@array/values_lib_display"
|
|
||||||
app:icon="@drawable/ic_artist"
|
|
||||||
app:key="KEY_LIB_MODE"
|
|
||||||
app:title="@string/set_lib_display"
|
|
||||||
app:useSimpleSummaryProvider="true" />
|
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
app:defaultValue="true"
|
app:defaultValue="true"
|
||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
|
|
Loading…
Reference in a new issue