Compare commits

...

4 Commits

@ -25,6 +25,7 @@ import org.isoron.uhabits.R
import org.isoron.uhabits.core.utils.DateUtils.Companion.getTodayWithOffset
import org.isoron.uhabits.utils.PaletteUtils.getAndroidTestColor
import org.junit.Before
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import java.io.IOException
@ -57,6 +58,7 @@ class CheckmarkWidgetViewTest : BaseViewTest() {
@Test
@Throws(IOException::class)
@Ignore("non-deterministic")
fun testRender_checked() {
assertRenders(view, PATH + "checked.png")
}

@ -23,6 +23,7 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.provider.Settings
import androidx.appcompat.app.AppCompatActivity
import dagger.Lazy
import nl.dionsegijn.konfetti.core.Party
@ -226,6 +227,14 @@ class ListHabitsScreen
override fun showConfetti(color: PaletteColor, x: Float, y: Float) {
if (x == 0f && y == 0f) return
if (preferences.isConfettiAnimationDisabled) return
if (Settings.Global.getFloat(
activity.contentResolver,
Settings.Global.ANIMATOR_DURATION_SCALE,
1f
) == 0f
) {
return
}
val baseColor = themeSwitcher.currentTheme!!.color(color).toInt()
rootView.get().konfettiView.start(
Party(
@ -299,30 +308,36 @@ class ListHabitsScreen
command.selected.size
)
}
is ChangeHabitColorCommand -> {
return activity.resources.getQuantityString(
R.plurals.toast_habits_changed,
command.selected.size
)
}
is CreateHabitCommand -> {
return activity.resources.getString(R.string.toast_habit_created)
}
is DeleteHabitsCommand -> {
return activity.resources.getQuantityString(
R.plurals.toast_habits_deleted,
command.selected.size
)
}
is EditHabitCommand -> {
return activity.resources.getQuantityString(R.plurals.toast_habits_changed, 1)
}
is UnarchiveHabitsCommand -> {
return activity.resources.getQuantityString(
R.plurals.toast_habits_unarchived,
command.selected.size
)
}
else -> return null
}
}
@ -335,9 +350,11 @@ class ListHabitsScreen
adapter.refresh()
activity.showMessage(activity.resources.getString(R.string.habits_imported))
}
ImportDataTask.NOT_RECOGNIZED -> {
activity.showMessage(activity.resources.getString(R.string.file_not_recognized))
}
else -> {
activity.showMessage(activity.resources.getString(R.string.could_not_import))
}

@ -189,16 +189,19 @@ class NumberButtonView(
textSize = dim(R.dimen.smallTextSize)
typeface = getFontAwesome()
}
value >= 0 -> {
label = value.toShortString()
typeface = BOLD_TYPEFACE
textSize = dim(R.dimen.smallTextSize)
}
preferences.areQuestionMarksEnabled -> {
label = resources.getString(R.string.fa_question)
typeface = getFontAwesome()
textSize = dim(R.dimen.smallerTextSize)
}
else -> {
label = "0"
typeface = BOLD_TYPEFACE
@ -212,14 +215,23 @@ class NumberButtonView(
pUnit.color = activeColor
if (units.isBlank()) {
// Draw number without units
rect.set(0f, 0f, width.toFloat(), height.toFloat())
rect.offset(0f, 0.5f * em)
canvas.drawText(label, rect.centerX(), rect.centerY(), pNumber)
} else {
// Draw number
rect.set(0f, 0f, width.toFloat(), height.toFloat())
canvas.drawText(label, rect.centerX(), rect.centerY(), pNumber)
// Draw units
val maxUnitsWidth = width * 0.9f
var trimmedUnits = units
while (trimmedUnits.length > 2 && pUnit.measureText(trimmedUnits) > maxUnitsWidth) {
trimmedUnits = trimmedUnits.dropLast(2) + ""
}
rect.offset(0f, 1.3f * em)
canvas.drawText(units, rect.centerX(), rect.centerY(), pUnit)
canvas.drawText(trimmedUnits, rect.centerX(), rect.centerY(), pUnit)
}
drawNotesIndicator(canvas, color, em, notes)

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
~
~ This file is part of Loop Habit Tracker.
@ -32,8 +31,7 @@
android:layout_marginBottom="8dp"
android:textColor="?attr/contrast60"
android:textSize="@dimen/regularTextSize"
tools:text="Have you worked out today?"
/>
tools:text="Have you worked out today?" />
<LinearLayout
android:layout_width="match_parent"
@ -54,12 +52,14 @@
android:id="@+id/targetText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8.5k"
android:text=""
android:textColor="?attr/contrast60"
android:textSize="@dimen/smallTextSize"
android:layout_marginStart="4dp"
android:layout_marginEnd="16dp"
/>
android:maxEms="7"
android:maxLines="1"
android:ellipsize="end" />
<TextView
android:id="@+id/frequencyIcon"
@ -93,7 +93,7 @@
android:layout_height="wrap_content"
android:paddingTop="1dp"
android:textColor="?attr/contrast60"
android:text="8:00 AM"
android:text=""
android:layout_marginStart="4dp"
android:textSize="@dimen/smallTextSize" />

Loading…
Cancel
Save