Fix tags highlighter
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
package org.koitharu.kotatsu.base.ui.widgets
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.res.ColorStateList
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View.OnClickListener
|
import android.view.View.OnClickListener
|
||||||
import androidx.annotation.ColorRes
|
import androidx.annotation.ColorRes
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.content.res.getColorStateListOrThrow
|
||||||
import androidx.core.view.children
|
import androidx.core.view.children
|
||||||
import com.google.android.material.chip.Chip
|
import com.google.android.material.chip.Chip
|
||||||
import com.google.android.material.chip.ChipDrawable
|
import com.google.android.material.chip.ChipDrawable
|
||||||
@@ -28,6 +31,8 @@ class ChipsView @JvmOverloads constructor(
|
|||||||
private val chipOnCloseListener = OnClickListener {
|
private val chipOnCloseListener = OnClickListener {
|
||||||
onChipCloseClickListener?.onChipCloseClick(it as Chip, it.tag)
|
onChipCloseClickListener?.onChipCloseClick(it as Chip, it.tag)
|
||||||
}
|
}
|
||||||
|
private val defaultChipStrokeColor: ColorStateList
|
||||||
|
private val defaultChipTextColor: ColorStateList
|
||||||
var onChipClickListener: OnChipClickListener? = null
|
var onChipClickListener: OnChipClickListener? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
@@ -41,6 +46,14 @@ class ChipsView @JvmOverloads constructor(
|
|||||||
children.forEach { (it as? Chip)?.isCloseIconVisible = isCloseIconVisible }
|
children.forEach { (it as? Chip)?.isCloseIconVisible = isCloseIconVisible }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
@SuppressLint("CustomViewStyleable")
|
||||||
|
val a = context.obtainStyledAttributes(null, materialR.styleable.Chip, 0, R.style.Widget_Kotatsu_Chip)
|
||||||
|
defaultChipStrokeColor = a.getColorStateListOrThrow(materialR.styleable.Chip_chipStrokeColor)
|
||||||
|
defaultChipTextColor = a.getColorStateListOrThrow(materialR.styleable.Chip_android_textColor)
|
||||||
|
a.recycle()
|
||||||
|
}
|
||||||
|
|
||||||
override fun requestLayout() {
|
override fun requestLayout() {
|
||||||
if (isLayoutSuppressedCompat) {
|
if (isLayoutSuppressedCompat) {
|
||||||
isLayoutCalledOnSuppressed = true
|
isLayoutCalledOnSuppressed = true
|
||||||
@@ -81,7 +94,10 @@ class ChipsView @JvmOverloads constructor(
|
|||||||
} else {
|
} else {
|
||||||
ContextCompat.getColorStateList(context, model.tint)
|
ContextCompat.getColorStateList(context, model.tint)
|
||||||
}
|
}
|
||||||
chip.buttonTintList = tint
|
chip.chipIconTint = tint
|
||||||
|
chip.checkedIconTint = tint
|
||||||
|
chip.chipStrokeColor = tint ?: defaultChipStrokeColor
|
||||||
|
chip.setTextColor(tint ?: defaultChipTextColor)
|
||||||
chip.isClickable = onChipClickListener != null || model.isCheckable
|
chip.isClickable = onChipClickListener != null || model.isCheckable
|
||||||
chip.isCheckable = model.isCheckable
|
chip.isCheckable = model.isCheckable
|
||||||
chip.isChecked = model.isChecked
|
chip.isChecked = model.isChecked
|
||||||
|
|||||||
@@ -9,5 +9,5 @@
|
|||||||
<color name="selector_foreground">#29FFFFFF</color>
|
<color name="selector_foreground">#29FFFFFF</color>
|
||||||
<color name="divider_default">#1FFFFFFF</color>
|
<color name="divider_default">#1FFFFFFF</color>
|
||||||
<color name="status_bar_incognito">#260052</color>
|
<color name="status_bar_incognito">#260052</color>
|
||||||
<color name="warning">#EF6C00</color>
|
<color name="warning">#FB8C00</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -22,5 +22,5 @@
|
|||||||
<color name="selector_foreground">#29000000</color>
|
<color name="selector_foreground">#29000000</color>
|
||||||
<color name="divider_default">#1F000000</color>
|
<color name="divider_default">#1F000000</color>
|
||||||
<color name="status_bar_incognito">#334800E0</color>
|
<color name="status_bar_incognito">#334800E0</color>
|
||||||
<color name="warning">#FFA726</color>
|
<color name="warning">#E65100</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -94,7 +94,7 @@
|
|||||||
<style name="Widget.Kotatsu.Chip" parent="Widget.Material3.Chip.Suggestion">
|
<style name="Widget.Kotatsu.Chip" parent="Widget.Material3.Chip.Suggestion">
|
||||||
<item name="chipSurfaceColor">?attr/colorSurface</item>
|
<item name="chipSurfaceColor">?attr/colorSurface</item>
|
||||||
<item name="android:textColor">?attr/colorOnSurfaceVariant</item>
|
<item name="android:textColor">?attr/colorOnSurfaceVariant</item>
|
||||||
<item name="strokeColor">?attr/colorOutline</item>
|
<item name="chipStrokeColor">?attr/colorOutline</item>
|
||||||
<item name="rippleColor">?attr/colorControlHighlight</item>
|
<item name="rippleColor">?attr/colorControlHighlight</item>
|
||||||
|
|
||||||
<!-- Custom chip states -->
|
<!-- Custom chip states -->
|
||||||
|
|||||||
Reference in New Issue
Block a user