Migrate to material theming

Finally move the app from AppCompat the Material Bridge theme. This does a couple things:
- Removes need for runtime styling of material widgets used before
- Allows for a better dialog style [But only after a ton of tinkering and weird hacks]
- Makes theming slightly easier [After all the dumb migration bugs and technicalities are fixed]

I never want to do something like this again. UI styling on android is a nightmare.
This commit is contained in:
OxygenCobalt
2021-04-04 09:20:56 -06:00
parent f2445e56f2
commit 03aa2d4579
21 changed files with 95 additions and 102 deletions
@@ -16,7 +16,6 @@ import org.oxycblt.auxio.recycler.DiffCallback
import org.oxycblt.auxio.recycler.viewholders.BaseViewHolder
import org.oxycblt.auxio.recycler.viewholders.Highlightable
import org.oxycblt.auxio.ui.Accent
import org.oxycblt.auxio.ui.applyAccents
import org.oxycblt.auxio.ui.disable
import org.oxycblt.auxio.ui.inflater
import org.oxycblt.auxio.ui.setTextColorResource
@@ -116,9 +115,6 @@ class AlbumDetailAdapter(
binding.playbackModel = playbackModel
binding.lifecycleOwner = lifecycleOwner
binding.albumShuffleButton.applyAccents(true)
binding.albumPlayButton.applyAccents(false)
if (data.songs.size < 2) {
binding.albumSortButton.disable()
}
@@ -16,7 +16,6 @@ import org.oxycblt.auxio.recycler.DiffCallback
import org.oxycblt.auxio.recycler.viewholders.BaseViewHolder
import org.oxycblt.auxio.recycler.viewholders.Highlightable
import org.oxycblt.auxio.ui.Accent
import org.oxycblt.auxio.ui.applyAccents
import org.oxycblt.auxio.ui.disable
import org.oxycblt.auxio.ui.inflater
import org.oxycblt.auxio.ui.setTextColorResource
@@ -115,9 +114,6 @@ class ArtistDetailAdapter(
binding.playbackModel = playbackModel
binding.lifecycleOwner = lifecycleOwner
binding.artistShuffleButton.applyAccents(true)
binding.artistPlayButton.applyAccents(false)
if (data.albums.size < 2) {
binding.artistSortButton.disable()
}
@@ -16,7 +16,6 @@ import org.oxycblt.auxio.recycler.DiffCallback
import org.oxycblt.auxio.recycler.viewholders.BaseViewHolder
import org.oxycblt.auxio.recycler.viewholders.Highlightable
import org.oxycblt.auxio.ui.Accent
import org.oxycblt.auxio.ui.applyAccents
import org.oxycblt.auxio.ui.disable
import org.oxycblt.auxio.ui.inflater
import org.oxycblt.auxio.ui.setTextColorResource
@@ -116,9 +115,6 @@ class GenreDetailAdapter(
binding.playbackModel = playbackModel
binding.lifecycleOwner = lifecycleOwner
binding.genreShuffleButton.applyAccents(true)
binding.genrePlayButton.applyAccents(false)
if (data.songs.size < 2) {
binding.genreSortButton.disable()
}
@@ -1,6 +1,5 @@
package org.oxycblt.auxio.search
import android.content.res.ColorStateList
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
@@ -23,12 +22,9 @@ import org.oxycblt.auxio.music.Genre
import org.oxycblt.auxio.music.Header
import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.playback.PlaybackViewModel
import org.oxycblt.auxio.ui.Accent
import org.oxycblt.auxio.ui.fixAnimInfoLeak
import org.oxycblt.auxio.ui.getSpans
import org.oxycblt.auxio.ui.newMenu
import org.oxycblt.auxio.ui.toColor
import org.oxycblt.auxio.ui.toStateList
/**
* A [Fragment] that allows for the searching of the entire music library.
@@ -51,9 +47,6 @@ class SearchFragment : Fragment() {
newMenu(view, data)
}
// Apply the accents manually. Not going through the mess of converting my app's
// styling to Material given all the second-and-third-order effects it has.
val accent = Accent.get().color.toColor(requireContext())
val toolbarParams = binding.searchToolbar.layoutParams as AppBarLayout.LayoutParams
val defaultParams = toolbarParams.scrollFlags
@@ -73,12 +66,6 @@ class SearchFragment : Fragment() {
}
}
binding.searchTextLayout.apply {
boxStrokeColor = accent
hintTextColor = ColorStateList.valueOf(accent)
setEndIconTintList(R.color.control_color.toStateList(context))
}
binding.searchEditText.addTextChangedListener { text ->
// Run the search with the updated text as the query
searchModel.doSearch(text?.toString() ?: "", requireContext())
@@ -1,6 +1,7 @@
package org.oxycblt.auxio.settings.ui
import androidx.appcompat.app.AlertDialog
import org.oxycblt.auxio.R
class IntListPrefDialog(private val pref: IntListPreference) : LifecycleDialog() {
override fun onConfigDialog(builder: AlertDialog.Builder) {
@@ -4,16 +4,17 @@ import android.app.Dialog
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatDialogFragment
import androidx.fragment.app.DialogFragment
import org.oxycblt.auxio.R
import com.google.android.material.dialog.MaterialAlertDialogBuilder
/**
* A wrapper around [DialogFragment] that allows the usage of the standard Auxio lifecycle
* override [onCreateView] and [onDestroyView], but with a proper dialog being created.
*/
abstract class LifecycleDialog : DialogFragment() {
abstract class LifecycleDialog : AppCompatDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(requireActivity(), R.style.Theme_CustomDialog)
val builder = MaterialAlertDialogBuilder(requireActivity(), theme)
onConfigDialog(builder)
@@ -23,7 +23,6 @@ import androidx.annotation.PluralsRes
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.button.MaterialButton
import org.oxycblt.auxio.R
import org.oxycblt.auxio.logE
import kotlin.reflect.KClass
@@ -47,21 +46,6 @@ fun TextView.setTextColorResource(@ColorRes color: Int) {
setTextColor(color.toColor(context))
}
/**
* Apply accents to a [MaterialButton] manually.
* Yes, I could change my theming to Material but that would have so many second-and-third order
* effects that I *really* dont want to deal with it. This hack works.
* @param highlighted Whether the MaterialButton has an "Unimportant" style or not.
* Required because you cant determine a style of a view before API 29
*/
fun MaterialButton.applyAccents(highlighted: Boolean) {
if (highlighted) {
backgroundTintList = Accent.get().getStateList(context)
} else {
setTextColorResource(Accent.get().color)
}
}
// --- CONVENIENCE ---
/**