Fixed Audio Fade, Crossfade & Android Auto search

This commit is contained in:
Prathamesh More 2021-09-18 14:10:22 +05:30
parent 7f683eb0ee
commit ee7545f64e
15 changed files with 269 additions and 79 deletions

View file

@ -1,10 +1,13 @@
package code.name.monkey.appthemehelper.common.prefs.supportv7
import android.content.Context
import android.text.Editable
import android.util.AttributeSet
import android.widget.SeekBar
import android.widget.TextView
import androidx.core.graphics.BlendModeColorFilterCompat
import androidx.core.graphics.BlendModeCompat
import androidx.core.widget.doAfterTextChanged
import androidx.preference.PreferenceViewHolder
import androidx.preference.SeekBarPreference
import code.name.monkey.appthemehelper.R
@ -19,7 +22,16 @@ class ATESeekBarPreference @JvmOverloads constructor(
defStyleRes: Int = -1
) : SeekBarPreference(context, attrs, defStyleAttr, defStyleRes) {
var unit: String = ""
init {
val attributes =
context.obtainStyledAttributes(attrs, R.styleable.ATESeekBarPreference, 0, 0)
attributes.getString(R.styleable.ATESeekBarPreference_ateKey_pref_unit)?.let {
unit = it
}
attributes.recycle()
icon?.colorFilter = BlendModeColorFilterCompat.createBlendModeColorFilterCompat(
ATHUtil.resolveColor(
context,
@ -32,5 +44,17 @@ class ATESeekBarPreference @JvmOverloads constructor(
super.onBindViewHolder(view)
val seekBar = view.findViewById(R.id.seekbar) as SeekBar
TintHelper.setTintAuto(seekBar, ThemeStore.accentColor(context), false)
(view.findViewById(R.id.seekbar_value) as TextView).apply {
appendUnit(editableText)
doAfterTextChanged {
appendUnit(it)
}
}
}
private fun TextView.appendUnit(editable: Editable?) {
if (!editable.toString().endsWith(unit)) {
append(unit)
}
}
}

4
appthemehelper/src/main/res/values/attrs.xml Executable file → Normal file
View file

@ -16,6 +16,10 @@
<attr name="ateKey_pref_color" format="string" />
</declare-styleable>
<declare-styleable name="ATESeekBarPreference">
<attr name="ateKey_pref_unit" format="string" />
</declare-styleable>
<declare-styleable name="ATEDialogPreference">
<attr name="ateKey_pref_dialog" format="string" />
</declare-styleable>