mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Compare commits
4 Commits
96e20f751f
...
e608c6ea62
| Author | SHA1 | Date | |
|---|---|---|---|
| e608c6ea62 | |||
| 5403b6bd51 | |||
| a6cf43dbca | |||
| 074627f6e1 |
@@ -25,6 +25,7 @@ import org.isoron.uhabits.R
|
|||||||
import org.isoron.uhabits.core.utils.DateUtils.Companion.getTodayWithOffset
|
import org.isoron.uhabits.core.utils.DateUtils.Companion.getTodayWithOffset
|
||||||
import org.isoron.uhabits.utils.PaletteUtils.getAndroidTestColor
|
import org.isoron.uhabits.utils.PaletteUtils.getAndroidTestColor
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
import org.junit.Ignore
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
@@ -57,6 +58,7 @@ class CheckmarkWidgetViewTest : BaseViewTest() {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
|
@Ignore("non-deterministic")
|
||||||
fun testRender_checked() {
|
fun testRender_checked() {
|
||||||
assertRenders(view, PATH + "checked.png")
|
assertRenders(view, PATH + "checked.png")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import android.app.Activity
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.provider.Settings
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import dagger.Lazy
|
import dagger.Lazy
|
||||||
import nl.dionsegijn.konfetti.core.Party
|
import nl.dionsegijn.konfetti.core.Party
|
||||||
@@ -226,6 +227,14 @@ class ListHabitsScreen
|
|||||||
override fun showConfetti(color: PaletteColor, x: Float, y: Float) {
|
override fun showConfetti(color: PaletteColor, x: Float, y: Float) {
|
||||||
if (x == 0f && y == 0f) return
|
if (x == 0f && y == 0f) return
|
||||||
if (preferences.isConfettiAnimationDisabled) 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()
|
val baseColor = themeSwitcher.currentTheme!!.color(color).toInt()
|
||||||
rootView.get().konfettiView.start(
|
rootView.get().konfettiView.start(
|
||||||
Party(
|
Party(
|
||||||
@@ -299,30 +308,36 @@ class ListHabitsScreen
|
|||||||
command.selected.size
|
command.selected.size
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
is ChangeHabitColorCommand -> {
|
is ChangeHabitColorCommand -> {
|
||||||
return activity.resources.getQuantityString(
|
return activity.resources.getQuantityString(
|
||||||
R.plurals.toast_habits_changed,
|
R.plurals.toast_habits_changed,
|
||||||
command.selected.size
|
command.selected.size
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
is CreateHabitCommand -> {
|
is CreateHabitCommand -> {
|
||||||
return activity.resources.getString(R.string.toast_habit_created)
|
return activity.resources.getString(R.string.toast_habit_created)
|
||||||
}
|
}
|
||||||
|
|
||||||
is DeleteHabitsCommand -> {
|
is DeleteHabitsCommand -> {
|
||||||
return activity.resources.getQuantityString(
|
return activity.resources.getQuantityString(
|
||||||
R.plurals.toast_habits_deleted,
|
R.plurals.toast_habits_deleted,
|
||||||
command.selected.size
|
command.selected.size
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
is EditHabitCommand -> {
|
is EditHabitCommand -> {
|
||||||
return activity.resources.getQuantityString(R.plurals.toast_habits_changed, 1)
|
return activity.resources.getQuantityString(R.plurals.toast_habits_changed, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
is UnarchiveHabitsCommand -> {
|
is UnarchiveHabitsCommand -> {
|
||||||
return activity.resources.getQuantityString(
|
return activity.resources.getQuantityString(
|
||||||
R.plurals.toast_habits_unarchived,
|
R.plurals.toast_habits_unarchived,
|
||||||
command.selected.size
|
command.selected.size
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> return null
|
else -> return null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -335,9 +350,11 @@ class ListHabitsScreen
|
|||||||
adapter.refresh()
|
adapter.refresh()
|
||||||
activity.showMessage(activity.resources.getString(R.string.habits_imported))
|
activity.showMessage(activity.resources.getString(R.string.habits_imported))
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportDataTask.NOT_RECOGNIZED -> {
|
ImportDataTask.NOT_RECOGNIZED -> {
|
||||||
activity.showMessage(activity.resources.getString(R.string.file_not_recognized))
|
activity.showMessage(activity.resources.getString(R.string.file_not_recognized))
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
activity.showMessage(activity.resources.getString(R.string.could_not_import))
|
activity.showMessage(activity.resources.getString(R.string.could_not_import))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,16 +189,19 @@ class NumberButtonView(
|
|||||||
textSize = dim(R.dimen.smallTextSize)
|
textSize = dim(R.dimen.smallTextSize)
|
||||||
typeface = getFontAwesome()
|
typeface = getFontAwesome()
|
||||||
}
|
}
|
||||||
|
|
||||||
value >= 0 -> {
|
value >= 0 -> {
|
||||||
label = value.toShortString()
|
label = value.toShortString()
|
||||||
typeface = BOLD_TYPEFACE
|
typeface = BOLD_TYPEFACE
|
||||||
textSize = dim(R.dimen.smallTextSize)
|
textSize = dim(R.dimen.smallTextSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
preferences.areQuestionMarksEnabled -> {
|
preferences.areQuestionMarksEnabled -> {
|
||||||
label = resources.getString(R.string.fa_question)
|
label = resources.getString(R.string.fa_question)
|
||||||
typeface = getFontAwesome()
|
typeface = getFontAwesome()
|
||||||
textSize = dim(R.dimen.smallerTextSize)
|
textSize = dim(R.dimen.smallerTextSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
label = "0"
|
label = "0"
|
||||||
typeface = BOLD_TYPEFACE
|
typeface = BOLD_TYPEFACE
|
||||||
@@ -212,14 +215,23 @@ class NumberButtonView(
|
|||||||
pUnit.color = activeColor
|
pUnit.color = activeColor
|
||||||
|
|
||||||
if (units.isBlank()) {
|
if (units.isBlank()) {
|
||||||
|
// Draw number without units
|
||||||
rect.set(0f, 0f, width.toFloat(), height.toFloat())
|
rect.set(0f, 0f, width.toFloat(), height.toFloat())
|
||||||
rect.offset(0f, 0.5f * em)
|
rect.offset(0f, 0.5f * em)
|
||||||
canvas.drawText(label, rect.centerX(), rect.centerY(), pNumber)
|
canvas.drawText(label, rect.centerX(), rect.centerY(), pNumber)
|
||||||
} else {
|
} else {
|
||||||
|
// Draw number
|
||||||
rect.set(0f, 0f, width.toFloat(), height.toFloat())
|
rect.set(0f, 0f, width.toFloat(), height.toFloat())
|
||||||
canvas.drawText(label, rect.centerX(), rect.centerY(), pNumber)
|
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)
|
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)
|
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>
|
~ Copyright (C) 2016-2021 Álinson Santos Xavier <git@axavier.org>
|
||||||
~
|
~
|
||||||
~ This file is part of Loop Habit Tracker.
|
~ This file is part of Loop Habit Tracker.
|
||||||
@@ -32,8 +31,7 @@
|
|||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:textColor="?attr/contrast60"
|
android:textColor="?attr/contrast60"
|
||||||
android:textSize="@dimen/regularTextSize"
|
android:textSize="@dimen/regularTextSize"
|
||||||
tools:text="Have you worked out today?"
|
tools:text="Have you worked out today?" />
|
||||||
/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -54,12 +52,14 @@
|
|||||||
android:id="@+id/targetText"
|
android:id="@+id/targetText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="8.5k"
|
android:text=""
|
||||||
android:textColor="?attr/contrast60"
|
android:textColor="?attr/contrast60"
|
||||||
android:textSize="@dimen/smallTextSize"
|
android:textSize="@dimen/smallTextSize"
|
||||||
android:layout_marginStart="4dp"
|
android:layout_marginStart="4dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
/>
|
android:maxEms="7"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/frequencyIcon"
|
android:id="@+id/frequencyIcon"
|
||||||
@@ -93,7 +93,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="1dp"
|
android:paddingTop="1dp"
|
||||||
android:textColor="?attr/contrast60"
|
android:textColor="?attr/contrast60"
|
||||||
android:text="8:00 AM"
|
android:text=""
|
||||||
android:layout_marginStart="4dp"
|
android:layout_marginStart="4dp"
|
||||||
android:textSize="@dimen/smallTextSize" />
|
android:textSize="@dimen/smallTextSize" />
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user