mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Changed Checkmark Widget Color on implicit check
As proposed in #615, the background is now solid color on implicit check but has a stroked checkmark instead of a full one.
This commit is contained in:
@@ -58,6 +58,7 @@ class RingView : View {
|
|||||||
private var em = 0f
|
private var em = 0f
|
||||||
private var text: String?
|
private var text: String?
|
||||||
private var textSize: Float
|
private var textSize: Float
|
||||||
|
private var isStrokedTextEnabled: Boolean = false
|
||||||
private var enableFontAwesome = false
|
private var enableFontAwesome = false
|
||||||
private var internalDrawingCache: Bitmap? = null
|
private var internalDrawingCache: Bitmap? = null
|
||||||
private var cacheCanvas: Canvas? = null
|
private var cacheCanvas: Canvas? = null
|
||||||
@@ -131,6 +132,10 @@ class RingView : View {
|
|||||||
invalidate()
|
invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setIsStrokedTextEnabled(isStroked: Boolean) {
|
||||||
|
this.isStrokedTextEnabled = isStroked
|
||||||
|
}
|
||||||
|
|
||||||
override fun onDraw(canvas: Canvas) {
|
override fun onDraw(canvas: Canvas) {
|
||||||
super.onDraw(canvas)
|
super.onDraw(canvas)
|
||||||
val activeCanvas: Canvas?
|
val activeCanvas: Canvas?
|
||||||
@@ -159,6 +164,12 @@ class RingView : View {
|
|||||||
pRing!!.xfermode = null
|
pRing!!.xfermode = null
|
||||||
pRing!!.color = color
|
pRing!!.color = color
|
||||||
pRing!!.textSize = textSize
|
pRing!!.textSize = textSize
|
||||||
|
|
||||||
|
if (isStrokedTextEnabled){
|
||||||
|
pRing!!.style = Paint.Style.STROKE
|
||||||
|
pRing!!.strokeWidth = textSize / 15f
|
||||||
|
}
|
||||||
|
|
||||||
if (enableFontAwesome) pRing!!.typeface = getFontAwesome(context)
|
if (enableFontAwesome) pRing!!.typeface = getFontAwesome(context)
|
||||||
activeCanvas.drawText(
|
activeCanvas.drawText(
|
||||||
text!!,
|
text!!,
|
||||||
|
|||||||
@@ -68,13 +68,13 @@ class CheckmarkWidgetView : HabitWidgetView {
|
|||||||
val fgColor: Int
|
val fgColor: Int
|
||||||
setShadowAlpha(0x4f)
|
setShadowAlpha(0x4f)
|
||||||
when (entryState) {
|
when (entryState) {
|
||||||
YES_MANUAL, SKIP -> {
|
YES_MANUAL, SKIP, YES_AUTO -> {
|
||||||
bgColor = activeColor
|
bgColor = activeColor
|
||||||
fgColor = res.getColor(R.attr.contrast0)
|
fgColor = res.getColor(R.attr.contrast0)
|
||||||
backgroundPaint!!.color = bgColor
|
backgroundPaint!!.color = bgColor
|
||||||
frame!!.setBackgroundDrawable(background)
|
frame!!.setBackgroundDrawable(background)
|
||||||
}
|
}
|
||||||
YES_AUTO, NO, UNKNOWN -> {
|
NO, UNKNOWN -> {
|
||||||
bgColor = res.getColor(R.attr.cardBgColor)
|
bgColor = res.getColor(R.attr.cardBgColor)
|
||||||
fgColor = res.getColor(R.attr.contrast60)
|
fgColor = res.getColor(R.attr.contrast60)
|
||||||
}
|
}
|
||||||
@@ -87,12 +87,23 @@ class CheckmarkWidgetView : HabitWidgetView {
|
|||||||
ring.setColor(fgColor)
|
ring.setColor(fgColor)
|
||||||
ring.setBackgroundColor(bgColor)
|
ring.setBackgroundColor(bgColor)
|
||||||
ring.setText(text)
|
ring.setText(text)
|
||||||
|
ring.setIsStrokedTextEnabled(strokedTextEnabled)
|
||||||
label.text = name
|
label.text = name
|
||||||
label.setTextColor(fgColor)
|
label.setTextColor(fgColor)
|
||||||
requestLayout()
|
requestLayout()
|
||||||
postInvalidate()
|
postInvalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val strokedTextEnabled: Boolean
|
||||||
|
get() = if (isNumerical) {
|
||||||
|
false
|
||||||
|
} else {
|
||||||
|
when (entryState) {
|
||||||
|
YES_AUTO -> true
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val text: String
|
private val text: String
|
||||||
get() = if (isNumerical) {
|
get() = if (isNumerical) {
|
||||||
(max(0, entryValue) / 1000.0).toShortString()
|
(max(0, entryValue) / 1000.0).toShortString()
|
||||||
|
|||||||
Reference in New Issue
Block a user