Fix general issues
Fix issues where colorPrimary was the main ripple color [ew], and some QueueAdapter errors stemming from a useless function.
This commit is contained in:
parent
12c14eeda6
commit
91b8d226c8
10 changed files with 27 additions and 56 deletions
|
@ -10,7 +10,6 @@ import android.view.WindowInsets
|
|||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import dev.chrisbanes.insetter.applySystemWindowInsetsToMargin
|
||||
import org.oxycblt.auxio.databinding.ActivityMainBinding
|
||||
import org.oxycblt.auxio.playback.PlaybackService
|
||||
import org.oxycblt.auxio.settings.SettingsManager
|
||||
|
@ -72,7 +71,7 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
// I barely know how insets work so here's another third party library
|
||||
// that I think does things
|
||||
binding.root.applySystemWindowInsetsToMargin(top = false, bottom = false)
|
||||
// binding.root.applySystemWindowInsetsToMargin(top = false, bottom = false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,9 +82,7 @@ class AlbumDetailFragment : DetailFragment() {
|
|||
)
|
||||
|
||||
R.id.action_queue_add -> {
|
||||
playbackModel.addToUserQueue(
|
||||
detailModel.currentAlbum.value!!.songs
|
||||
)
|
||||
playbackModel.addToUserQueue(detailModel.currentAlbum.value!!)
|
||||
context.getString(R.string.label_queue_added).createToast(requireContext())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.oxycblt.auxio.playback.queue.QueueAdapter
|
|||
import org.oxycblt.auxio.playback.state.LoopMode
|
||||
import org.oxycblt.auxio.playback.state.PlaybackMode
|
||||
import org.oxycblt.auxio.playback.state.PlaybackStateManager
|
||||
import org.oxycblt.auxio.recycler.SortMode
|
||||
|
||||
/**
|
||||
* The ViewModel that provides a UI frontend for [PlaybackStateManager].
|
||||
|
@ -235,7 +236,9 @@ class PlaybackViewModel : ViewModel(), PlaybackStateManager.Callback {
|
|||
playbackManager.addToUserQueue(song)
|
||||
}
|
||||
|
||||
fun addToUserQueue(songs: List<Song>) {
|
||||
fun addToUserQueue(album: Album) {
|
||||
val songs = SortMode.NUMERIC_DOWN.getSortedSongList(album.songs)
|
||||
|
||||
playbackManager.addToUserQueue(songs)
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ class QueueAdapter(
|
|||
|
||||
return if (item is Header)
|
||||
if (item.isAction)
|
||||
USER_QUEUE_HEADER_ITEM_tYPE
|
||||
USER_QUEUE_HEADER_ITEM_TYPE
|
||||
else
|
||||
HeaderViewHolder.ITEM_TYPE
|
||||
else
|
||||
|
@ -54,7 +54,7 @@ class QueueAdapter(
|
|||
QUEUE_ITEM_TYPE -> QueueSongViewHolder(
|
||||
ItemQueueSongBinding.inflate(LayoutInflater.from(parent.context))
|
||||
)
|
||||
USER_QUEUE_HEADER_ITEM_tYPE -> UserQueueHeaderViewHolder(
|
||||
USER_QUEUE_HEADER_ITEM_TYPE -> UserQueueHeaderViewHolder(
|
||||
parent.context, ItemActionHeaderBinding.inflate(LayoutInflater.from(parent.context))
|
||||
)
|
||||
else -> error("Someone messed with the ViewHolder item types.")
|
||||
|
@ -117,15 +117,6 @@ class QueueAdapter(
|
|||
}
|
||||
}
|
||||
|
||||
private fun clearUserQueue() {
|
||||
val nextQueueHeaderIndex = data.indexOfLast { it is Header && !it.isAction }
|
||||
Log.d(this::class.simpleName, nextQueueHeaderIndex.toString())
|
||||
val slice = data.slice(0..nextQueueHeaderIndex.dec())
|
||||
|
||||
data.removeAll(slice)
|
||||
notifyItemRangeRemoved(0, slice.size)
|
||||
}
|
||||
|
||||
// Generic ViewHolder for a queue item
|
||||
inner class QueueSongViewHolder(
|
||||
private val binding: ItemQueueSongBinding,
|
||||
|
@ -168,7 +159,6 @@ class QueueAdapter(
|
|||
setImageResource(R.drawable.ic_clear)
|
||||
|
||||
setOnClickListener {
|
||||
clearUserQueue()
|
||||
onHeaderAction()
|
||||
}
|
||||
}
|
||||
|
@ -177,6 +167,6 @@ class QueueAdapter(
|
|||
|
||||
companion object {
|
||||
const val QUEUE_ITEM_TYPE = 0xA015
|
||||
const val USER_QUEUE_HEADER_ITEM_tYPE = 0xA016
|
||||
const val USER_QUEUE_HEADER_ITEM_TYPE = 0xA016
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,11 @@ class QueueFragment : Fragment() {
|
|||
|
||||
if (playbackModel.userQueue.value!!.isNotEmpty()) {
|
||||
queue.add(
|
||||
Header(name = getString(R.string.label_next_user_queue), isAction = true)
|
||||
Header(
|
||||
id = 0,
|
||||
name = getString(R.string.label_next_user_queue),
|
||||
isAction = true
|
||||
)
|
||||
)
|
||||
queue.addAll(playbackModel.userQueue.value!!)
|
||||
}
|
||||
|
@ -88,6 +92,7 @@ class QueueFragment : Fragment() {
|
|||
if (playbackModel.nextItemsInQueue.value!!.isNotEmpty()) {
|
||||
queue.add(
|
||||
Header(
|
||||
id = 1,
|
||||
name = getString(
|
||||
R.string.format_next_from,
|
||||
if (playbackModel.mode.value == PlaybackMode.ALL_SONGS)
|
||||
|
|
|
@ -84,25 +84,25 @@ class NoLeakThumbView @JvmOverloads constructor(
|
|||
fastScrollerView.onTouchEvent(event)
|
||||
fastScrollerView.performClick()
|
||||
|
||||
isVisible = true
|
||||
|
||||
if (event.actionMasked in intArrayOf(
|
||||
MotionEvent.ACTION_UP,
|
||||
MotionEvent.ACTION_CANCEL
|
||||
)
|
||||
) {
|
||||
isActivated = false
|
||||
isVisible = true
|
||||
return@setOnTouchListener true
|
||||
}
|
||||
|
||||
isActivated = isPointerOnItem(fastScrollerView, event.y.toInt())
|
||||
isVisible = true
|
||||
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hack so that I can detect when the pointer is off the FastScrollerView's items
|
||||
* Hack so that I can detect when the pointer is on the FastScrollerView's items
|
||||
* without using onItemIndicatorTouched (Which is internal)
|
||||
* @author OxygenCobalt
|
||||
*/
|
||||
|
@ -113,7 +113,7 @@ class NoLeakThumbView @JvmOverloads constructor(
|
|||
|
||||
fastScrollerView.apply {
|
||||
children.forEach { view ->
|
||||
if (view.containsY(touchY) && (view is ImageView || view is TextView)) {
|
||||
if (view.containsY(touchY)) {
|
||||
consumed = true
|
||||
return@forEach
|
||||
}
|
||||
|
@ -125,6 +125,7 @@ class NoLeakThumbView @JvmOverloads constructor(
|
|||
|
||||
private fun applyStyle() {
|
||||
thumbView.backgroundTintList = thumbColor
|
||||
|
||||
if (Build.VERSION.SDK_INT == 21) {
|
||||
// Workaround for 21 background tint bug
|
||||
(thumbView.background as GradientDrawable).apply {
|
||||
|
|
|
@ -1,17 +1,12 @@
|
|||
package org.oxycblt.auxio.settings
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceGroupAdapter
|
||||
import androidx.preference.PreferenceScreen
|
||||
import androidx.preference.PreferenceViewHolder
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
|
@ -97,30 +92,6 @@ class SettingsListFragment : PreferenceFragmentCompat() {
|
|||
setPreferencesFromResource(R.xml.prefs_main, rootKey)
|
||||
}
|
||||
|
||||
// Forcefully override the adapter creation process so I can get rid of the ugly
|
||||
// colorPrimary ripples.
|
||||
@SuppressLint("RestrictedApi")
|
||||
override fun onCreateAdapter(preferenceScreen: PreferenceScreen?): RecyclerView.Adapter<*> {
|
||||
return object : PreferenceGroupAdapter(preferenceScreen) {
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
): PreferenceViewHolder {
|
||||
val holder = super.onCreateViewHolder(parent, viewType)
|
||||
|
||||
if (holder.itemView.id != android.R.id.title) {
|
||||
holder.itemView.setBackgroundResource(R.drawable.ui_ripple)
|
||||
}
|
||||
|
||||
return holder
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun offLoad(something: String) {
|
||||
Log.d(this::class.simpleName, something)
|
||||
}
|
||||
|
||||
private fun showAccentDialog() {
|
||||
MaterialDialog(requireActivity()).show {
|
||||
title(R.string.setting_accent)
|
||||
|
@ -149,6 +120,7 @@ class SettingsListFragment : PreferenceFragmentCompat() {
|
|||
)
|
||||
}
|
||||
|
||||
// TODO: Implement dialog edge-to-edge
|
||||
layoutManager = LinearLayoutManager(
|
||||
requireContext()
|
||||
).also { it.orientation = LinearLayoutManager.HORIZONTAL }
|
||||
|
|
|
@ -177,7 +177,7 @@ fun PopupMenu.setupAlbumActions(
|
|||
setOnMenuItemClickListener {
|
||||
when (it.itemId) {
|
||||
R.id.action_queue_add -> {
|
||||
playbackModel.addToUserQueue(album.songs)
|
||||
playbackModel.addToUserQueue(album)
|
||||
context.getString(R.string.label_queue_added).createToast(context)
|
||||
|
||||
true
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:theme="@style/ThemeOverlay.Accented"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
|
|
|
@ -14,15 +14,17 @@
|
|||
<item name="colorControlNormal">@color/control_color</item>
|
||||
<item name="alertDialogTheme">@style/Theme.CustomDialog</item>
|
||||
<item name="indicatorFastScrollerStyle">@style/FastScrollTheme</item>
|
||||
<item name="colorControlHighlight">@color/selection_color</item>
|
||||
<item name="colorControlActivated">?attr/colorPrimary</item>
|
||||
<item name="colorControlHighlight">?attr/colorPrimary</item>
|
||||
|
||||
<item name="md_background_color">@color/background</item>
|
||||
<item name="md_corner_radius">0dp</item>
|
||||
<item name="md_color_button_text">@color/control_color</item>
|
||||
<item name="md_font_title">@font/inter_black</item>
|
||||
</style>
|
||||
|
||||
<item name="android:activatedBackgroundIndicator">@drawable/ui_ripple</item>
|
||||
<style name="ThemeOverlay.Accented" parent="ThemeOverlay.AppCompat.DayNight">
|
||||
<item name="android:windowBackground">@color/background</item>
|
||||
</style>
|
||||
|
||||
<!-- Hack to fix the weird icon/underline with LibraryFragment's SearchView -->
|
||||
|
|
Loading…
Reference in a new issue