diff --git a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackFragment.kt b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackFragment.kt index 127e14d24..e27920402 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackFragment.kt @@ -39,6 +39,8 @@ import org.oxycblt.auxio.util.logD /** * A [Fragment] that displays more information about the song, along with more media controls. * Instantiation is done by the navigation component, **do not instantiate this fragment manually.** + * TODO: Turn the seekbar + durations combo into a single view that shares touch events. This could + * also make material sliders usable maybe. * @author OxygenCobalt */ class PlaybackFragment : Fragment(), SeekBar.OnSeekBarChangeListener { diff --git a/app/src/main/java/org/oxycblt/auxio/settings/IntListPrefDialog.kt b/app/src/main/java/org/oxycblt/auxio/settings/IntListPrefDialog.kt index ac27289f4..565746499 100644 --- a/app/src/main/java/org/oxycblt/auxio/settings/IntListPrefDialog.kt +++ b/app/src/main/java/org/oxycblt/auxio/settings/IntListPrefDialog.kt @@ -18,31 +18,35 @@ package org.oxycblt.auxio.settings -import android.util.TypedValue +import android.os.Bundle import androidx.appcompat.app.AlertDialog +import androidx.appcompat.view.ContextThemeWrapper import androidx.appcompat.widget.AppCompatTextView -import androidx.core.content.res.ResourcesCompat import androidx.core.view.updatePadding +import androidx.preference.PreferenceFragmentCompat import org.oxycblt.auxio.BuildConfig import org.oxycblt.auxio.R import org.oxycblt.auxio.ui.LifecycleDialog -import org.oxycblt.auxio.util.resolveAttr -class IntListPrefDialog(private val pref: IntListPreference) : LifecycleDialog() { +class IntListPrefDialog : LifecycleDialog() { override fun onConfigDialog(builder: AlertDialog.Builder) { - // Don't set the title. Instead. Set a custom title view so that the padding actually - // works between the title and this dialog's contents. I can't believe I have to do this. - val titleView = AppCompatTextView(requireContext()).apply { - text = pref.title - typeface = ResourcesCompat.getFont(context, R.font.inter_bold) - setTextSize( - TypedValue.COMPLEX_UNIT_PX, - resources.getDimensionPixelSize(R.dimen.text_size_large).toFloat() - ) - setTextColor(android.R.attr.textColorPrimary.resolveAttr(context)) + // Since we have to store the preference key as an argument, we have to find the + // preference we need to use manually. + val pref = requireNotNull( + (parentFragment as PreferenceFragmentCompat).preferenceManager + .findPreference(requireArguments().getString(ARG_KEY, null)) + ) + + // Don't set the title. Instead, Set a custom title view so that the padding is actually a + // uniform 16dp between the title and the list of options. I can't believe I have to do this. + val titleView = AppCompatTextView( + ContextThemeWrapper( + requireContext(), + R.style.Widget_TextView_Dialog_Title + ) + ).apply { + text = pref.title - // We have to make the bottom padding account for the ListView's immutable top padding, - // because Android's dialog code is a massive pile of broken spaghetti. val padding = resources.getDimension(R.dimen.spacing_medium).toInt() val paddingHack = resources.getDimension(R.dimen.spacing_small).toInt() @@ -53,7 +57,6 @@ class IntListPrefDialog(private val pref: IntListPreference) : LifecycleDialog() builder.setSingleChoiceItems(pref.entries, pref.getValueIndex()) { _, index -> pref.setValueIndex(index) - dismiss() } @@ -62,5 +65,14 @@ class IntListPrefDialog(private val pref: IntListPreference) : LifecycleDialog() companion object { const val TAG = BuildConfig.APPLICATION_ID + ".tag.INT_PREF" + const val ARG_KEY = BuildConfig.APPLICATION_ID + ".arg.PREF_KEY" + + fun from(pref: IntListPreference): IntListPrefDialog { + return IntListPrefDialog().apply { + arguments = Bundle().apply { + putString(ARG_KEY, pref.key) + } + } + } } } diff --git a/app/src/main/java/org/oxycblt/auxio/settings/SettingsListFragment.kt b/app/src/main/java/org/oxycblt/auxio/settings/SettingsListFragment.kt index 047ad9319..223a82c8e 100644 --- a/app/src/main/java/org/oxycblt/auxio/settings/SettingsListFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/settings/SettingsListFragment.kt @@ -74,7 +74,7 @@ class SettingsListFragment : PreferenceFragmentCompat() { override fun onDisplayPreferenceDialog(preference: Preference?) { if (preference is IntListPreference) { - IntListPrefDialog(preference).show(childFragmentManager, IntListPrefDialog.TAG) + IntListPrefDialog.from(preference).show(childFragmentManager, IntListPrefDialog.TAG) } else { super.onDisplayPreferenceDialog(preference) } diff --git a/app/src/main/java/org/oxycblt/auxio/ui/ViewHolders.kt b/app/src/main/java/org/oxycblt/auxio/ui/ViewHolders.kt index 863fa6738..dad508ef0 100644 --- a/app/src/main/java/org/oxycblt/auxio/ui/ViewHolders.kt +++ b/app/src/main/java/org/oxycblt/auxio/ui/ViewHolders.kt @@ -256,6 +256,8 @@ class ActionHeaderViewHolder private constructor( override fun onBind(data: ActionHeader) { binding.header = data + binding.executePendingBindings() + binding.headerButton.apply { TooltipCompat.setTooltipText(this, contentDescription) diff --git a/app/src/main/res/values/styles_android.xml b/app/src/main/res/values/styles_android.xml index 59819c7b9..58c1625b8 100644 --- a/app/src/main/res/values/styles_android.xml +++ b/app/src/main/res/values/styles_android.xml @@ -1,20 +1,8 @@ - + - - - - - - - + diff --git a/app/src/main/res/values/styles_ui.xml b/app/src/main/res/values/styles_ui.xml index e4fe17224..61ebaa6c9 100644 --- a/app/src/main/res/values/styles_ui.xml +++ b/app/src/main/res/values/styles_ui.xml @@ -6,7 +6,6 @@