Merge pull request #4 from asdoi/text_score

add score as text
pull/646/head
asdoi 5 years ago committed by GitHub
commit 766a3e45f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -20,6 +20,7 @@
package org.isoron.uhabits.activities.habits.list.views
import android.content.*
import android.graphics.Typeface
import android.os.*
import android.os.Build.VERSION.*
import android.os.Build.VERSION_CODES.*
@ -74,6 +75,7 @@ class HabitCardView(
set(value) {
scoreRing.percentage = value.toFloat()
scoreRing.precision = 1.0f / 16
scoreText.text = "${(value * 100).toInt()}%"
}
var unit
@ -100,6 +102,7 @@ class HabitCardView(
private var innerFrame: LinearLayout
private var label: TextView
private var scoreRing: RingView
private var scoreText: TextView
init {
scoreRing = RingView(context).apply {
@ -113,6 +116,17 @@ class HabitCardView(
setThickness(thickness)
}
scoreText = TextView(context).apply {
val margin = dp(8f).toInt()
setSingleLine()
gravity = Gravity.CENTER
typeface = Typeface.DEFAULT_BOLD
layoutParams = LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT).apply {
setMargins(margin, 0, margin, 0)
gravity = Gravity.CENTER
}
}
label = TextView(context).apply {
maxLines = 2
ellipsize = TextUtils.TruncateAt.END
@ -142,6 +156,7 @@ class HabitCardView(
if (SDK_INT >= LOLLIPOP) elevation = dp(1f)
addView(scoreRing)
addView(scoreText)
addView(label)
addView(checkmarkPanel)
addView(numberPanel)
@ -207,6 +222,9 @@ class HabitCardView(
scoreRing.apply {
color = c
}
scoreText.apply {
setTextColor(c)
}
checkmarkPanel.apply {
color = c
visibility = when (h.isNumerical) {

Loading…
Cancel
Save