settings: redocument
This commit is contained in:
parent
0f265cc2a4
commit
2c2b560195
7 changed files with 37 additions and 6 deletions
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
#### What's New
|
#### What's New
|
||||||
- Added ability to play/shuffle selections
|
- Added ability to play/shuffle selections
|
||||||
- Settings UI has been visually refreshed
|
- Visually refreshed header components
|
||||||
|
- Resigned settings view
|
||||||
|
|
||||||
#### What's Improved
|
#### What's Improved
|
||||||
- Added ability to edit previously played or currently playing items in the queue
|
- Added ability to edit previously played or currently playing items in the queue
|
||||||
|
|
|
@ -25,6 +25,11 @@ import com.google.android.material.divider.BackportMaterialDividerItemDecoration
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.list.Header
|
import org.oxycblt.auxio.list.Header
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [BackportMaterialDividerItemDecoration] that sets up the divider configuration to correctly
|
||||||
|
* separate content with headers.
|
||||||
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
|
*/
|
||||||
class HeaderItemDecoration
|
class HeaderItemDecoration
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -35,6 +40,9 @@ constructor(
|
||||||
) : BackportMaterialDividerItemDecoration(context, attributeSet, defStyleAttr, orientation) {
|
) : BackportMaterialDividerItemDecoration(context, attributeSet, defStyleAttr, orientation) {
|
||||||
override fun shouldDrawDivider(position: Int, adapter: RecyclerView.Adapter<*>?) =
|
override fun shouldDrawDivider(position: Int, adapter: RecyclerView.Adapter<*>?) =
|
||||||
try {
|
try {
|
||||||
|
// Add a divider if the next item is a header. This organizes the divider to separate
|
||||||
|
// the ends of content rather than the beginning of content, alongside an added benefit
|
||||||
|
// of preventing top headers from having a divider applied.
|
||||||
(adapter as DiffAdapter<*, *, *>).getItem(position + 1) is Header
|
(adapter as DiffAdapter<*, *, *>).getItem(position + 1) is Header
|
||||||
} catch (e: ClassCastException) {
|
} catch (e: ClassCastException) {
|
||||||
false
|
false
|
||||||
|
|
|
@ -21,6 +21,10 @@ import androidx.navigation.fragment.findNavController
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.settings.SettingsFragmentDirections
|
import org.oxycblt.auxio.settings.SettingsFragmentDirections
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Audio settings interface.
|
||||||
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
|
*/
|
||||||
class AudioPreferenceFragment : BasePreferenceFragment(R.xml.preferences_audio) {
|
class AudioPreferenceFragment : BasePreferenceFragment(R.xml.preferences_audio) {
|
||||||
|
|
||||||
override fun onOpenDialogPreference(preference: WrappedDialogPreference) {
|
override fun onOpenDialogPreference(preference: WrappedDialogPreference) {
|
||||||
|
|
|
@ -35,6 +35,10 @@ import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.util.logD
|
import org.oxycblt.auxio.util.logD
|
||||||
import org.oxycblt.auxio.util.systemBarInsetsCompat
|
import org.oxycblt.auxio.util.systemBarInsetsCompat
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shared [PreferenceFragmentCompat] used across all preference screens.
|
||||||
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
|
*/
|
||||||
abstract class BasePreferenceFragment(@XmlRes private val screen: Int) :
|
abstract class BasePreferenceFragment(@XmlRes private val screen: Int) :
|
||||||
PreferenceFragmentCompat() {
|
PreferenceFragmentCompat() {
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +69,7 @@ abstract class BasePreferenceFragment(@XmlRes private val screen: Int) :
|
||||||
view.findViewById<Toolbar>(R.id.preferences_toolbar).apply {
|
view.findViewById<Toolbar>(R.id.preferences_toolbar).apply {
|
||||||
title = preferenceScreen.title
|
title = preferenceScreen.title
|
||||||
setNavigationOnClickListener {
|
setNavigationOnClickListener {
|
||||||
val fragmentManager = fragmentManager
|
val fragmentManager = @Suppress("Deprecation") fragmentManager
|
||||||
if (fragmentManager == null || fragmentManager.backStackEntryCount == 0) {
|
if (fragmentManager == null || fragmentManager.backStackEntryCount == 0) {
|
||||||
findNavController().navigateUp()
|
findNavController().navigateUp()
|
||||||
} else {
|
} else {
|
||||||
|
@ -98,14 +102,13 @@ abstract class BasePreferenceFragment(@XmlRes private val screen: Int) :
|
||||||
setPreferencesFromResource(screen, rootKey)
|
setPreferencesFromResource(screen, rootKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("Deprecation")
|
|
||||||
override fun onDisplayPreferenceDialog(preference: Preference) {
|
override fun onDisplayPreferenceDialog(preference: Preference) {
|
||||||
when (preference) {
|
when (preference) {
|
||||||
is IntListPreference -> {
|
is IntListPreference -> {
|
||||||
// Copy the built-in preference dialog launching code into our project so
|
// Copy the built-in preference dialog launching code into our project so
|
||||||
// we can automatically use the provided preference class.
|
// we can automatically use the provided preference class.
|
||||||
val dialog = IntListPreferenceDialog.from(preference)
|
val dialog = IntListPreferenceDialog.from(preference)
|
||||||
dialog.setTargetFragment(this, 0)
|
@Suppress("Deprecation") dialog.setTargetFragment(this, 0)
|
||||||
dialog.show(parentFragmentManager, IntListPreferenceDialog.TAG)
|
dialog.show(parentFragmentManager, IntListPreferenceDialog.TAG)
|
||||||
}
|
}
|
||||||
is WrappedDialogPreference -> {
|
is WrappedDialogPreference -> {
|
||||||
|
|
|
@ -23,6 +23,10 @@ import coil.Coil
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.settings.SettingsFragmentDirections
|
import org.oxycblt.auxio.settings.SettingsFragmentDirections
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "Content" settings.
|
||||||
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
|
*/
|
||||||
class MusicPreferenceFragment : BasePreferenceFragment(R.xml.preferences_music) {
|
class MusicPreferenceFragment : BasePreferenceFragment(R.xml.preferences_music) {
|
||||||
override fun onOpenDialogPreference(preference: WrappedDialogPreference) {
|
override fun onOpenDialogPreference(preference: WrappedDialogPreference) {
|
||||||
if (preference.key == getString(R.string.set_key_separators)) {
|
if (preference.key == getString(R.string.set_key_separators)) {
|
||||||
|
|
|
@ -21,6 +21,10 @@ import androidx.navigation.fragment.findNavController
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.settings.SettingsFragmentDirections
|
import org.oxycblt.auxio.settings.SettingsFragmentDirections
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Personalization settings interface.
|
||||||
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
|
*/
|
||||||
class PersonalizePreferenceFragment : BasePreferenceFragment(R.xml.preferences_personalize) {
|
class PersonalizePreferenceFragment : BasePreferenceFragment(R.xml.preferences_personalize) {
|
||||||
override fun onOpenDialogPreference(preference: WrappedDialogPreference) {
|
override fun onOpenDialogPreference(preference: WrappedDialogPreference) {
|
||||||
if (preference.key == getString(R.string.set_key_home_tabs)) {
|
if (preference.key == getString(R.string.set_key_home_tabs)) {
|
||||||
|
|
|
@ -25,8 +25,12 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.divider.BackportMaterialDividerItemDecoration
|
import com.google.android.material.divider.BackportMaterialDividerItemDecoration
|
||||||
import org.oxycblt.auxio.R
|
import org.oxycblt.auxio.R
|
||||||
import org.oxycblt.auxio.util.logD
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [BackportMaterialDividerItemDecoration] that sets up the divider configuration to correctly
|
||||||
|
* separate preference categories.
|
||||||
|
* @author Alexander Capehart (OxygenCobalt)
|
||||||
|
*/
|
||||||
class PreferenceHeaderItemDecoration
|
class PreferenceHeaderItemDecoration
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -37,7 +41,10 @@ constructor(
|
||||||
) : BackportMaterialDividerItemDecoration(context, attributeSet, defStyleAttr, orientation) {
|
) : BackportMaterialDividerItemDecoration(context, attributeSet, defStyleAttr, orientation) {
|
||||||
override fun shouldDrawDivider(position: Int, adapter: RecyclerView.Adapter<*>?) =
|
override fun shouldDrawDivider(position: Int, adapter: RecyclerView.Adapter<*>?) =
|
||||||
try {
|
try {
|
||||||
logD(position)
|
// Add a divider if the next item is a header (in this case a preference category
|
||||||
|
// that corresponds to a header viewholder). This organizes the divider to separate
|
||||||
|
// the ends of content rather than the beginning of content, alongside an added benefit
|
||||||
|
// of preventing top headers from having a divider applied.
|
||||||
(adapter as PreferenceGroupAdapter).getItem(position + 1) is PreferenceCategory
|
(adapter as PreferenceGroupAdapter).getItem(position + 1) is PreferenceCategory
|
||||||
} catch (e: ClassCastException) {
|
} catch (e: ClassCastException) {
|
||||||
false
|
false
|
||||||
|
|
Loading…
Reference in a new issue