all: reformat
This commit is contained in:
@@ -546,11 +546,8 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
|
|||||||
* Since the error drawable must also share a view with an image, any kind of transform or tint
|
* Since the error drawable must also share a view with an image, any kind of transform or tint
|
||||||
* must occur within a custom dialog, which is implemented here.
|
* must occur within a custom dialog, which is implemented here.
|
||||||
*/
|
*/
|
||||||
private class StyledDrawable(
|
private class StyledDrawable(context: Context, inner: Drawable, @Px val iconSize: Int?) :
|
||||||
context: Context,
|
Drawable() {
|
||||||
inner: Drawable,
|
|
||||||
@Px val iconSize: Int?,
|
|
||||||
) : Drawable() {
|
|
||||||
// Never tint a shared drawable instance. These icons are also used elsewhere (e.g. the
|
// Never tint a shared drawable instance. These icons are also used elsewhere (e.g. the
|
||||||
// About screen), and tinting without mutation can leak the modified tint state across
|
// About screen), and tinting without mutation can leak the modified tint state across
|
||||||
// views in inconsistent ways depending on drawable caching/inflation order.
|
// views in inconsistent ways depending on drawable caching/inflation order.
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import android.os.Bundle
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import org.oxycblt.auxio.R
|
|
||||||
import org.oxycblt.auxio.databinding.DialogSortBinding
|
import org.oxycblt.auxio.databinding.DialogSortBinding
|
||||||
import org.oxycblt.auxio.list.ClickableListListener
|
import org.oxycblt.auxio.list.ClickableListListener
|
||||||
import org.oxycblt.auxio.list.adapter.UpdateInstructions
|
import org.oxycblt.auxio.list.adapter.UpdateInstructions
|
||||||
@@ -30,8 +29,7 @@ import org.oxycblt.auxio.ui.ViewBindingBottomSheetDialogFragment
|
|||||||
import org.oxycblt.auxio.util.systemBarInsetsCompat
|
import org.oxycblt.auxio.util.systemBarInsetsCompat
|
||||||
|
|
||||||
abstract class SortDialog :
|
abstract class SortDialog :
|
||||||
ViewBindingBottomSheetDialogFragment<DialogSortBinding>(),
|
ViewBindingBottomSheetDialogFragment<DialogSortBinding>(), ClickableListListener<Sort.Mode> {
|
||||||
ClickableListListener<Sort.Mode> {
|
|
||||||
private val modeAdapter = SortModeAdapter(@Suppress("LeakingThis") this)
|
private val modeAdapter = SortModeAdapter(@Suppress("LeakingThis") this)
|
||||||
|
|
||||||
abstract fun getInitialSort(): Sort?
|
abstract fun getInitialSort(): Sort?
|
||||||
@@ -56,12 +54,8 @@ abstract class SortDialog :
|
|||||||
applyChosenSort(requireNotNull(getCurrentSort()))
|
applyChosenSort(requireNotNull(getCurrentSort()))
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
binding.sortDirectionAsc.setOnClickListener {
|
binding.sortDirectionAsc.setOnClickListener { updateDirection(Sort.Direction.ASCENDING) }
|
||||||
updateDirection(Sort.Direction.ASCENDING)
|
binding.sortDirectionDsc.setOnClickListener { updateDirection(Sort.Direction.DESCENDING) }
|
||||||
}
|
|
||||||
binding.sortDirectionDsc.setOnClickListener {
|
|
||||||
updateDirection(Sort.Direction.DESCENDING)
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- STATE SETUP ---
|
// --- STATE SETUP ---
|
||||||
modeAdapter.update(getModeChoices(), UpdateInstructions.Diff)
|
modeAdapter.update(getModeChoices(), UpdateInstructions.Diff)
|
||||||
@@ -95,7 +89,9 @@ abstract class SortDialog :
|
|||||||
val binding = requireBinding()
|
val binding = requireBinding()
|
||||||
val initial = getInitialSort()
|
val initial = getInitialSort()
|
||||||
val mode = modeAdapter.currentMode ?: return null
|
val mode = modeAdapter.currentMode ?: return null
|
||||||
val direction = if (binding.sortDirectionAsc.isChecked) Sort.Direction.ASCENDING else Sort.Direction.DESCENDING
|
val direction =
|
||||||
|
if (binding.sortDirectionAsc.isChecked) Sort.Direction.ASCENDING
|
||||||
|
else Sort.Direction.DESCENDING
|
||||||
return Sort(mode, direction)
|
return Sort(mode, direction)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,18 +89,8 @@ class ExportPlaylistDialog : ViewBindingMaterialDialogFragment<DialogPlaylistExp
|
|||||||
findNavController().navigateUp()
|
findNavController().navigateUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.exportRelativePaths.setOnClickListener {
|
binding.exportRelativePaths.setOnClickListener { updatePathStyle(absolute = false) }
|
||||||
// Enforce "selection required" behavior even if the config value doesn't change.
|
binding.exportAbsolutePaths.setOnClickListener { updatePathStyle(absolute = true) }
|
||||||
val current = pickerModel.currentExportConfig.value
|
|
||||||
updateExportConfig(current.copy(absolute = false))
|
|
||||||
pickerModel.setExportConfig(current.copy(absolute = false))
|
|
||||||
}
|
|
||||||
binding.exportAbsolutePaths.setOnClickListener {
|
|
||||||
// Enforce "selection required" behavior even if the config value doesn't change.
|
|
||||||
val current = pickerModel.currentExportConfig.value
|
|
||||||
updateExportConfig(current.copy(absolute = true))
|
|
||||||
pickerModel.setExportConfig(current.copy(absolute = true))
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.exportWindowsPaths.setOnClickListener { _ ->
|
binding.exportWindowsPaths.setOnClickListener { _ ->
|
||||||
val current = pickerModel.currentExportConfig.value
|
val current = pickerModel.currentExportConfig.value
|
||||||
@@ -141,6 +131,16 @@ class ExportPlaylistDialog : ViewBindingMaterialDialogFragment<DialogPlaylistExp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun updatePathStyle(absolute: Boolean) {
|
||||||
|
// Keep the UI in a valid state even if the config doesn't change (no emission).
|
||||||
|
val current = pickerModel.currentExportConfig.value
|
||||||
|
val updated = current.copy(absolute = absolute)
|
||||||
|
updateExportConfig(updated)
|
||||||
|
if (updated != current) {
|
||||||
|
pickerModel.setExportConfig(updated)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateExportConfig(config: ExportConfig) {
|
private fun updateExportConfig(config: ExportConfig) {
|
||||||
val binding = requireBinding()
|
val binding = requireBinding()
|
||||||
binding.exportRelativePaths.isChecked = !config.absolute
|
binding.exportRelativePaths.isChecked = !config.absolute
|
||||||
|
|||||||
Reference in New Issue
Block a user