Fix chips icon tint
This commit is contained in:
@@ -14,7 +14,6 @@ import com.google.android.material.chip.ChipDrawable
|
|||||||
import com.google.android.material.chip.ChipGroup
|
import com.google.android.material.chip.ChipGroup
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.utils.ext.castOrNull
|
import org.koitharu.kotatsu.utils.ext.castOrNull
|
||||||
import org.koitharu.kotatsu.utils.ext.getThemeColorStateList
|
|
||||||
import com.google.android.material.R as materialR
|
import com.google.android.material.R as materialR
|
||||||
|
|
||||||
class ChipsView @JvmOverloads constructor(
|
class ChipsView @JvmOverloads constructor(
|
||||||
@@ -33,6 +32,7 @@ class ChipsView @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
private val defaultChipStrokeColor: ColorStateList
|
private val defaultChipStrokeColor: ColorStateList
|
||||||
private val defaultChipTextColor: ColorStateList
|
private val defaultChipTextColor: ColorStateList
|
||||||
|
private val defaultChipIconTint: ColorStateList
|
||||||
var onChipClickListener: OnChipClickListener? = null
|
var onChipClickListener: OnChipClickListener? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
@@ -51,6 +51,7 @@ class ChipsView @JvmOverloads constructor(
|
|||||||
val a = context.obtainStyledAttributes(null, materialR.styleable.Chip, 0, R.style.Widget_Kotatsu_Chip)
|
val a = context.obtainStyledAttributes(null, materialR.styleable.Chip, 0, R.style.Widget_Kotatsu_Chip)
|
||||||
defaultChipStrokeColor = a.getColorStateListOrThrow(materialR.styleable.Chip_chipStrokeColor)
|
defaultChipStrokeColor = a.getColorStateListOrThrow(materialR.styleable.Chip_chipStrokeColor)
|
||||||
defaultChipTextColor = a.getColorStateListOrThrow(materialR.styleable.Chip_android_textColor)
|
defaultChipTextColor = a.getColorStateListOrThrow(materialR.styleable.Chip_android_textColor)
|
||||||
|
defaultChipIconTint = a.getColorStateListOrThrow(materialR.styleable.Chip_chipIconTint)
|
||||||
a.recycle()
|
a.recycle()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,8 +95,8 @@ class ChipsView @JvmOverloads constructor(
|
|||||||
} else {
|
} else {
|
||||||
ContextCompat.getColorStateList(context, model.tint)
|
ContextCompat.getColorStateList(context, model.tint)
|
||||||
}
|
}
|
||||||
chip.chipIconTint = tint
|
chip.chipIconTint = tint ?: defaultChipIconTint
|
||||||
chip.checkedIconTint = tint
|
chip.checkedIconTint = tint ?: defaultChipIconTint
|
||||||
chip.chipStrokeColor = tint ?: defaultChipStrokeColor
|
chip.chipStrokeColor = tint ?: defaultChipStrokeColor
|
||||||
chip.setTextColor(tint ?: defaultChipTextColor)
|
chip.setTextColor(tint ?: defaultChipTextColor)
|
||||||
chip.isClickable = onChipClickListener != null || model.isCheckable
|
chip.isClickable = onChipClickListener != null || model.isCheckable
|
||||||
@@ -111,7 +112,7 @@ class ChipsView @JvmOverloads constructor(
|
|||||||
chip.isCheckedIconVisible = true
|
chip.isCheckedIconVisible = true
|
||||||
chip.isChipIconVisible = false
|
chip.isChipIconVisible = false
|
||||||
chip.setCheckedIconResource(R.drawable.ic_check)
|
chip.setCheckedIconResource(R.drawable.ic_check)
|
||||||
chip.checkedIconTint = context.getThemeColorStateList(materialR.attr.colorControlNormal)
|
chip.checkedIconTint = defaultChipIconTint
|
||||||
chip.isCloseIconVisible = onChipCloseClickListener != null
|
chip.isCloseIconVisible = onChipCloseClickListener != null
|
||||||
chip.setOnCloseIconClickListener(chipOnCloseListener)
|
chip.setOnCloseIconClickListener(chipOnCloseListener)
|
||||||
chip.setEnsureMinTouchTargetSize(false)
|
chip.setEnsureMinTouchTargetSize(false)
|
||||||
|
|||||||
@@ -95,6 +95,7 @@
|
|||||||
<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="chipStrokeColor">?attr/colorOutline</item>
|
<item name="chipStrokeColor">?attr/colorOutline</item>
|
||||||
|
<item name="chipIconTint">?attr/colorControlNormal</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