pull/2222/merge
Vlad Petrushkevich 2 weeks ago committed by GitHub
commit 63333ac6e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -36,12 +36,14 @@ abstract class ButtonPanelView<T : View>(
var buttonCount = 0 var buttonCount = 0
set(value) { set(value) {
if (field == value) return
field = value field = value
inflateButtons() inflateButtons()
} }
var dataOffset = 0 var dataOffset = 0
set(value) { set(value) {
if (field == value) return
field = value field = value
setupButtons() setupButtons()
} }

@ -135,6 +135,7 @@ class CheckmarkButtonView(
private val bgColor = sres.getColor(R.attr.cardBgColor) private val bgColor = sres.getColor(R.attr.cardBgColor)
private val lowContrastColor = sres.getColor(R.attr.contrast40) private val lowContrastColor = sres.getColor(R.attr.contrast40)
private val mediumContrastColor = sres.getColor(R.attr.contrast60) private val mediumContrastColor = sres.getColor(R.attr.contrast60)
private val pNotesIndicator = Paint()
private val paint = TextPaint().apply { private val paint = TextPaint().apply {
typeface = getFontAwesome() typeface = getFontAwesome()
@ -192,7 +193,13 @@ class CheckmarkButtonView(
canvas.drawText(label, rect.centerX(), rect.centerY(), paint) canvas.drawText(label, rect.centerX(), rect.centerY(), paint)
} }
drawNotesIndicator(canvas, color, em, notes) drawNotesIndicator(
pNotesIndicator = pNotesIndicator,
canvas = canvas,
color = color,
size = em,
notes = notes,
)
} }
} }
} }

@ -70,6 +70,8 @@ class HabitCardListAdapter @Inject constructor(
* Sets all items as not selected. * Sets all items as not selected.
*/ */
override fun clearSelection() { override fun clearSelection() {
if (selected.isEmpty()) return
selected.clear() selected.clear()
notifyDataSetChanged() notifyDataSetChanged()
observable.notifyListeners() observable.notifyListeners()

@ -145,6 +145,8 @@ class NumberButtonView(
private val lowContrast: Int private val lowContrast: Int
private val mediumContrast: Int private val mediumContrast: Int
private val pNotesIndicator = Paint()
private val paint = TextPaint().apply { private val paint = TextPaint().apply {
typeface = getFontAwesome() typeface = getFontAwesome()
isAntiAlias = true isAntiAlias = true
@ -234,7 +236,13 @@ class NumberButtonView(
canvas.drawText(trimmedUnits, rect.centerX(), rect.centerY(), pUnit) canvas.drawText(trimmedUnits, rect.centerX(), rect.centerY(), pUnit)
} }
drawNotesIndicator(canvas, color, em, notes) drawNotesIndicator(
pNotesIndicator = pNotesIndicator,
canvas = canvas,
color = color,
size = em,
notes = notes,
)
} }
} }
} }

@ -210,14 +210,19 @@ fun View.sp(value: Float) = InterfaceUtils.spToPixels(context, value)
fun View.dp(value: Float) = InterfaceUtils.dpToPixels(context, value) fun View.dp(value: Float) = InterfaceUtils.dpToPixels(context, value)
fun View.str(id: Int) = resources.getString(id) fun View.str(id: Int) = resources.getString(id)
fun View.drawNotesIndicator(canvas: Canvas, color: Int, size: Float, notes: String) { fun View.drawNotesIndicator(
val pNotesIndicator = Paint() pNotesIndicator: Paint,
canvas: Canvas,
color: Int,
size: Float,
notes: String,
) {
if (notes.isBlank()) return
pNotesIndicator.color = color pNotesIndicator.color = color
if (notes.isNotBlank()) {
val cy = 0.8f * size val cy = 0.8f * size
canvas.drawCircle(width.toFloat() - cy, cy, 8f, pNotesIndicator) canvas.drawCircle(width.toFloat() - cy, cy, 8f, pNotesIndicator)
} }
}
val View.sres: StyledResources val View.sres: StyledResources
get() = StyledResources(context) get() = StyledResources(context)

Loading…
Cancel
Save