Minor changes
Change some minor things across the app.
This commit is contained in:
@@ -11,9 +11,8 @@ import org.oxycblt.auxio.ui.accent
|
||||
|
||||
// FIXME: Fix bug where fast navigation will break the animations and
|
||||
// lead to nothing being displayed [Possibly Un-fixable]
|
||||
// FIXME: Compat issues with Versions 5/6 that cause recyclerview
|
||||
// dividers not to show and for progress bars to look wonky
|
||||
// FIXME: Navigation memory leak that is really confusing
|
||||
// TODO: Landscape UI layouts
|
||||
// FIXME: Compat issue with Versions 5 that leads to progress bar looking off
|
||||
class MainActivity : AppCompatActivity(R.layout.activity_main) {
|
||||
|
||||
override fun onCreateView(name: String, context: Context, attrs: AttributeSet): View? {
|
||||
|
||||
@@ -59,9 +59,9 @@ class MainFragment : Fragment() {
|
||||
)
|
||||
|
||||
val navController = (
|
||||
childFragmentManager.findFragmentById(R.id.explore_nav_host)
|
||||
as NavHostFragment?
|
||||
)?.findNavController()
|
||||
childFragmentManager.findFragmentById(R.id.explore_nav_host)
|
||||
as NavHostFragment?
|
||||
)?.findNavController()
|
||||
|
||||
// --- UI SETUP ---
|
||||
|
||||
@@ -97,11 +97,11 @@ class MainFragment : Fragment() {
|
||||
if (it) {
|
||||
if (binding.navBar.selectedItemId != R.id.library_fragment ||
|
||||
(
|
||||
navController!!.currentDestination?.id == R.id.album_detail_fragment &&
|
||||
detailModel.currentAlbum.value == null ||
|
||||
detailModel.currentAlbum.value?.id
|
||||
!= playbackModel.song.value!!.album.id
|
||||
) ||
|
||||
navController!!.currentDestination?.id == R.id.album_detail_fragment &&
|
||||
detailModel.currentAlbum.value == null ||
|
||||
detailModel.currentAlbum.value?.id
|
||||
!= playbackModel.song.value!!.album.id
|
||||
) ||
|
||||
navController.currentDestination?.id == R.id.artist_detail_fragment ||
|
||||
navController.currentDestination?.id == R.id.genre_detail_fragment
|
||||
) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import android.util.Log
|
||||
*/
|
||||
class PlaybackStateDatabase(context: Context) :
|
||||
SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
|
||||
|
||||
override fun onCreate(db: SQLiteDatabase) {
|
||||
createTable(db, TABLE_NAME_STATE)
|
||||
createTable(db, TABLE_NAME_QUEUE)
|
||||
@@ -111,7 +112,7 @@ class PlaybackStateDatabase(context: Context) :
|
||||
|
||||
/**
|
||||
* Read the stored [PlaybackState] from the database, if there is one.
|
||||
* @return The stored [PlaybackState], null if there isnt one,.
|
||||
* @return The stored [PlaybackState], null if there isn't one,.
|
||||
* @author OxygenCobalt
|
||||
*/
|
||||
fun readState(): PlaybackState? {
|
||||
@@ -121,7 +122,11 @@ class PlaybackStateDatabase(context: Context) :
|
||||
var stateCursor: Cursor? = null
|
||||
|
||||
try {
|
||||
stateCursor = database.query(TABLE_NAME_STATE, null, null, null, null, null, null)
|
||||
stateCursor = database.query(
|
||||
TABLE_NAME_STATE,
|
||||
null, null, null,
|
||||
null, null, null
|
||||
)
|
||||
|
||||
stateCursor?.use { cursor ->
|
||||
// Don't bother if the cursor [and therefore database] has nothing in it.
|
||||
@@ -227,7 +232,10 @@ class PlaybackStateDatabase(context: Context) :
|
||||
var queueCursor: Cursor? = null
|
||||
|
||||
try {
|
||||
queueCursor = database.query(TABLE_NAME_QUEUE, null, null, null, null, null, null)
|
||||
queueCursor = database.query(
|
||||
TABLE_NAME_QUEUE, null, null,
|
||||
null, null, null, null
|
||||
)
|
||||
|
||||
queueCursor?.use { cursor ->
|
||||
if (cursor.count == 0) return@use
|
||||
|
||||
@@ -131,7 +131,7 @@ class AlbumDetailFragment : DetailFragment() {
|
||||
binding.albumSongRecycler.post {
|
||||
// Only scroll after UI creation
|
||||
val y = binding.albumSongRecycler.y +
|
||||
binding.albumSongRecycler.getChildAt(pos).y
|
||||
binding.albumSongRecycler.getChildAt(pos).y
|
||||
|
||||
binding.nestedScroll.smoothScrollBy(0, y.toInt())
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ import androidx.navigation.fragment.findNavController
|
||||
* A Base [Fragment] implementing a [OnBackPressedCallback] so that Auxio will navigate upwards
|
||||
* instead of out of the app if a Detail Fragment is currently open. Also carries the
|
||||
* multi-navigation fix.
|
||||
* // TODO: Merge headers with recyclerview [if possible]
|
||||
* TODO: Implement a system where the Toolbar will update with some info when
|
||||
* the main detail header is obscured.
|
||||
* @author OxygenCobalt
|
||||
*/
|
||||
abstract class DetailFragment : Fragment() {
|
||||
@@ -32,6 +33,7 @@ abstract class DetailFragment : Fragment() {
|
||||
super.onPause()
|
||||
callback.isEnabled = false
|
||||
}
|
||||
|
||||
private val callback = object : OnBackPressedCallback(false) {
|
||||
|
||||
override fun handleOnBackPressed() {
|
||||
|
||||
@@ -9,9 +9,6 @@ import org.oxycblt.auxio.music.Genre
|
||||
import org.oxycblt.auxio.recycler.SortMode
|
||||
|
||||
// ViewModel for the Detail Fragments.
|
||||
// TODO:
|
||||
// - Implement a system where the Toolbar will update with some info when
|
||||
// the main detail header is obscured.
|
||||
class DetailViewModel : ViewModel() {
|
||||
private var mIsNavigating = false
|
||||
val isNavigating: Boolean get() = mIsNavigating
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import org.oxycblt.auxio.databinding.ItemArtistAlbumBinding
|
||||
import org.oxycblt.auxio.music.Album
|
||||
import org.oxycblt.auxio.recycler.DiffCallback
|
||||
@@ -11,17 +12,19 @@ import org.oxycblt.auxio.recycler.viewholders.BaseViewHolder
|
||||
|
||||
class DetailAlbumAdapter(
|
||||
private val doOnClick: (data: Album) -> Unit,
|
||||
private val doOnLongClick: (data: Album, view: View) -> Unit
|
||||
) : ListAdapter<Album, DetailAlbumAdapter.AlbumViewHolder>(DiffCallback()) {
|
||||
private val doOnLongClick: (data: Album, view: View) -> Unit,
|
||||
) : ListAdapter<Album, RecyclerView.ViewHolder>(DiffCallback()) {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AlbumViewHolder {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
return AlbumViewHolder(
|
||||
ItemArtistAlbumBinding.inflate(LayoutInflater.from(parent.context))
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: AlbumViewHolder, position: Int) {
|
||||
holder.bind(getItem(position))
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
when (val item = getItem(position)) {
|
||||
is Album -> (holder as AlbumViewHolder).bind(item)
|
||||
}
|
||||
}
|
||||
|
||||
// Generic ViewHolder for a detail album
|
||||
|
||||
@@ -44,7 +44,7 @@ class LibraryFragment : Fragment(), SearchView.OnQueryTextListener {
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
): View {
|
||||
val binding = FragmentLibraryBinding.inflate(inflater)
|
||||
|
||||
val musicStore = MusicStore.getInstance()
|
||||
|
||||
@@ -107,5 +107,5 @@ class MosaicFetcher(private val context: Context) : Fetcher<List<Uri>> {
|
||||
)
|
||||
}
|
||||
|
||||
override fun key(data: List<Uri>): String? = data.toString()
|
||||
override fun key(data: List<Uri>): String = data.toString()
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.ImageButton
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
@@ -27,8 +27,6 @@ import org.oxycblt.auxio.ui.createToast
|
||||
class CompactPlaybackFragment : Fragment() {
|
||||
private val playbackModel: PlaybackViewModel by activityViewModels()
|
||||
|
||||
private var playbackControls: ImageView? = null
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
@@ -77,9 +75,6 @@ class CompactPlaybackFragment : Fragment() {
|
||||
binding.playbackProgress.progress = it
|
||||
}
|
||||
|
||||
// Use the playback control ImageView for later.
|
||||
playbackControls = binding.playbackControls
|
||||
|
||||
Log.d(this::class.simpleName, "Fragment Created")
|
||||
|
||||
return binding.root
|
||||
@@ -90,6 +85,10 @@ class CompactPlaybackFragment : Fragment() {
|
||||
|
||||
playbackModel.disableAnimation()
|
||||
|
||||
// Use the caveman method of getting a view as storing the binding will cause a memory
|
||||
// leak.
|
||||
val playbackControls = requireView().findViewById<ImageButton>(R.id.playback_controls)
|
||||
|
||||
// Observe the changes to isPlaying for
|
||||
val iconPauseToPlay = ContextCompat.getDrawable(
|
||||
requireContext(), R.drawable.ic_pause_to_play
|
||||
@@ -122,10 +121,4 @@ class CompactPlaybackFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
|
||||
playbackControls = null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class PlaybackFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
): View {
|
||||
val binding = FragmentPlaybackBinding.inflate(inflater)
|
||||
|
||||
// TODO: Add a swipe-to-next-track function using a ViewPager
|
||||
@@ -84,7 +84,6 @@ class PlaybackFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
|
||||
}
|
||||
|
||||
// Make marquee scroll work
|
||||
// TODO: Add nav here as well
|
||||
binding.playbackSong.isSelected = true
|
||||
binding.playbackSeekBar.setOnSeekBarChangeListener(this)
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.oxycblt.auxio.playback.queue
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MotionEvent
|
||||
@@ -54,7 +55,7 @@ class QueueAdapter(
|
||||
ItemQueueSongBinding.inflate(LayoutInflater.from(parent.context))
|
||||
)
|
||||
USER_QUEUE_HEADER_ITEM_tYPE -> UserQueueHeaderViewHolder(
|
||||
ItemActionHeaderBinding.inflate(LayoutInflater.from(parent.context))
|
||||
parent.context, ItemActionHeaderBinding.inflate(LayoutInflater.from(parent.context))
|
||||
)
|
||||
else -> error("Someone messed with the ViewHolder item types.")
|
||||
}
|
||||
@@ -97,6 +98,7 @@ class QueueAdapter(
|
||||
// Check for two things:
|
||||
// If the data from the next queue is now entirely empty [Signified by a header at the end]
|
||||
// Or if the data from the last queue is now entirely empty [Signified by there being 2 headers with no items in between]
|
||||
// If so, remove that item and the removed item in a range. Otherwise just remove the item.
|
||||
if (data[data.lastIndex] is Header) {
|
||||
val lastIndex = data.lastIndex
|
||||
|
||||
@@ -146,8 +148,16 @@ class QueueAdapter(
|
||||
}
|
||||
|
||||
inner class UserQueueHeaderViewHolder(
|
||||
context: Context,
|
||||
private val binding: ItemActionHeaderBinding
|
||||
) : BaseViewHolder<Header>(binding, null, null) {
|
||||
|
||||
init {
|
||||
binding.headerButton.contentDescription = context.getString(
|
||||
R.string.description_clear_user_queue
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBind(data: Header) {
|
||||
binding.header = data
|
||||
binding.headerButton.apply {
|
||||
|
||||
@@ -28,7 +28,7 @@ class QueueFragment : Fragment() {
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
): View {
|
||||
val binding = FragmentQueueBinding.inflate(inflater)
|
||||
|
||||
val callback = QueueDragCallback(playbackModel)
|
||||
|
||||
@@ -560,12 +560,12 @@ class PlaybackStateManager private constructor() {
|
||||
// Traverse albums and then album songs instead of just the songs, as its faster.
|
||||
musicStore.albums.find { it.id == item.albumId }
|
||||
?.songs?.find { it.id == item.songId }?.let {
|
||||
if (item.isUserQueue) {
|
||||
mUserQueue.add(it)
|
||||
} else {
|
||||
mQueue.add(it)
|
||||
if (item.isUserQueue) {
|
||||
mUserQueue.add(it)
|
||||
} else {
|
||||
mQueue.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get a more accurate index [At least if were not in the user queue]
|
||||
|
||||
@@ -3,8 +3,6 @@ package org.oxycblt.auxio.recycler.viewholders
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.annotation.DrawableRes
|
||||
import org.oxycblt.auxio.databinding.ItemActionHeaderBinding
|
||||
import org.oxycblt.auxio.databinding.ItemAlbumBinding
|
||||
import org.oxycblt.auxio.databinding.ItemArtistBinding
|
||||
import org.oxycblt.auxio.databinding.ItemGenreBinding
|
||||
@@ -149,20 +147,3 @@ class HeaderViewHolder(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class ActionHeaderViewHolder(
|
||||
protected val binding: ItemActionHeaderBinding,
|
||||
@DrawableRes private val iconRes: Int
|
||||
) : BaseViewHolder<Header>(binding, null, null) {
|
||||
override fun onBind(data: Header) {
|
||||
binding.header = data
|
||||
binding.headerButton.apply {
|
||||
setImageResource(iconRes)
|
||||
setOnClickListener {
|
||||
onActionClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun onActionClick()
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class SongsFragment : Fragment() {
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
): View {
|
||||
val binding = FragmentSongsBinding.inflate(inflater)
|
||||
|
||||
val musicStore = MusicStore.getInstance()
|
||||
|
||||
Reference in New Issue
Block a user