Refactor styles heavily
Move a bunch of UI elements into reusable styles, along with removing literal dimen resources.
This commit is contained in:
@@ -26,7 +26,6 @@ import org.oxycblt.auxio.ui.toColor
|
||||
class MainActivity : AppCompatActivity() {
|
||||
private val settingsModel: SettingsViewModel by viewModels()
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
@@ -56,8 +55,6 @@ class MainActivity : AppCompatActivity() {
|
||||
settingsModel.theme.observe(this) {
|
||||
if (it != null) {
|
||||
doThemeRecreate(it)
|
||||
|
||||
settingsModel.doneWithThemeUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +83,7 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun doEdgeToEdgeSetup(binding: ActivityMainBinding) {
|
||||
window?.apply {
|
||||
statusBarColor = Color.TRANSPARENT
|
||||
@@ -120,10 +118,7 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
fun doThemeRecreate(newTheme: Int) {
|
||||
private fun doThemeRecreate(newTheme: Int) {
|
||||
AppCompatDelegate.setDefaultNightMode(newTheme)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package org.oxycblt.auxio.playback
|
||||
|
||||
import android.content.Context
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package org.oxycblt.auxio.playback.queue
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowInsets
|
||||
import androidx.core.view.updatePadding
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import com.afollestad.materialdialogs.utils.MDUtil.updatePadding
|
||||
import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.databinding.FragmentQueueBinding
|
||||
import org.oxycblt.auxio.music.BaseModel
|
||||
@@ -49,9 +50,15 @@ class QueueFragment : Fragment() {
|
||||
findNavController().navigateUp()
|
||||
}
|
||||
|
||||
setOnApplyWindowInsetsListener { v, insets ->
|
||||
setOnApplyWindowInsetsListener { _, insets ->
|
||||
val top = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
insets.getInsets(WindowInsets.Type.systemBars()).top
|
||||
} else {
|
||||
insets.systemWindowInsetTop
|
||||
}
|
||||
|
||||
(parent as View).updatePadding(
|
||||
top = insets.systemWindowInsetTop
|
||||
top = top
|
||||
)
|
||||
|
||||
insets
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("MemberVisibilityCanBePrivate")
|
||||
|
||||
package org.oxycblt.auxio.recycler
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
@@ -40,9 +42,9 @@ class NoLeakThumbView @JvmOverloads constructor(
|
||||
FastScrollerView.ItemIndicatorSelectedCallback {
|
||||
|
||||
private var thumbColor = ColorStateList.valueOf(accent.first.toColor(context))
|
||||
var iconColor = R.color.background.toColor(context)
|
||||
private var iconColor = R.color.background.toColor(context)
|
||||
var textAppearanceRes = R.style.TextAppearance_ThumbIndicator
|
||||
var textColor = R.color.background.toColor(context)
|
||||
private var textColor = R.color.background.toColor(context)
|
||||
|
||||
private val thumbView: ViewGroup
|
||||
private val textView: TextView
|
||||
@@ -80,16 +82,14 @@ class NoLeakThumbView @JvmOverloads constructor(
|
||||
|
||||
// FastScrollerView's "onItemIndicatorTouched" [Which I would've used here] is internal,
|
||||
// so instead I just use a setOnTouchListener to get the same-ish effect.
|
||||
fastScrollerView.setOnTouchListener { v, event ->
|
||||
fastScrollerView.setOnTouchListener { _, event ->
|
||||
fastScrollerView.onTouchEvent(event)
|
||||
fastScrollerView.performClick()
|
||||
|
||||
isVisible = true
|
||||
|
||||
if (event.actionMasked in intArrayOf(
|
||||
MotionEvent.ACTION_UP,
|
||||
MotionEvent.ACTION_CANCEL
|
||||
)
|
||||
if (event.actionMasked == MotionEvent.ACTION_UP ||
|
||||
event.actionMasked == MotionEvent.ACTION_CANCEL
|
||||
) {
|
||||
isActivated = false
|
||||
return@setOnTouchListener true
|
||||
|
||||
@@ -27,7 +27,7 @@ abstract class BaseViewHolder<T : BaseModel>(
|
||||
/**
|
||||
* Bind the viewholder with whatever [BaseModel] instance that has been specified.
|
||||
* Will call [onBind] on the inheriting ViewHolder.
|
||||
* @param data Data that the viewholder should be binded with
|
||||
* @param data Data that the viewholder should be bound with
|
||||
*/
|
||||
fun bind(data: T) {
|
||||
doOnClick?.let { onClick ->
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package org.oxycblt.auxio.settings
|
||||
|
||||
import android.os.Bundle
|
||||
@@ -59,6 +61,8 @@ class SettingsListFragment : PreferenceFragmentCompat() {
|
||||
else -> R.drawable.ic_auto
|
||||
}
|
||||
)
|
||||
|
||||
settingsModel.doneWithThemeUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -84,6 +84,8 @@ class SongsFragment : Fragment(), SearchView.OnQueryTextListener {
|
||||
var hasAddedNumber = false
|
||||
var iters = 0
|
||||
|
||||
// TODO: Do selection instead of using iters
|
||||
|
||||
setupWithRecyclerView(
|
||||
binding.songRecycler,
|
||||
{ pos ->
|
||||
|
||||
Reference in New Issue
Block a user