Rename Checkmark to Entry

pull/699/head
Alinson S. Xavier 5 years ago
parent a3cf2877b8
commit 71597ca89b

@ -22,15 +22,15 @@ package org.isoron.uhabits;
import org.isoron.uhabits.core.models.*;
import org.isoron.uhabits.core.utils.DateUtils;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
public class HabitFixtures
{
public boolean LONG_HABIT_CHECKS[] = {
public boolean LONG_HABIT_ENTRIES[] = {
true, false, false, true, true, true, false, false, true, true
};
public int LONG_NUMERICAL_HABIT_CHECKS[] = {
public int LONG_NUMERICAL_HABIT_ENTRIES[] = {
200000, 0, 150000, 137000, 0, 0, 500000, 30000, 100000, 0, 300000,
100000, 0, 100000
};
@ -75,7 +75,7 @@ public class HabitFixtures
81, 83, 89, 90, 91, 95, 102, 103, 108, 109, 120};
for (int mark : marks)
habit.getOriginalCheckmarks().setValue(today.minus(mark), YES_MANUAL);
habit.getOriginalEntries().setValue(today.minus(mark), YES_MANUAL);
return habit;
}
@ -109,7 +109,7 @@ public class HabitFixtures
582, 583, 584, 586, 589};
for (int mark : marks)
habit.getOriginalCheckmarks().setValue(today.minus(mark), YES_MANUAL);
habit.getOriginalEntries().setValue(today.minus(mark), YES_MANUAL);
return habit;
}
@ -126,9 +126,9 @@ public class HabitFixtures
habitList.add(habit);
Timestamp timestamp = DateUtils.getToday();
for (int value : LONG_NUMERICAL_HABIT_CHECKS)
for (int value : LONG_NUMERICAL_HABIT_ENTRIES)
{
habit.getOriginalCheckmarks().setValue(timestamp, value);
habit.getOriginalEntries().setValue(timestamp, value);
timestamp = timestamp.minus(1);
}
@ -144,9 +144,9 @@ public class HabitFixtures
habitList.add(habit);
Timestamp timestamp = DateUtils.getToday();
for (boolean c : LONG_HABIT_CHECKS)
for (boolean c : LONG_HABIT_ENTRIES)
{
if (c) habit.getOriginalCheckmarks().setValue(timestamp, YES_MANUAL);
if (c) habit.getOriginalEntries().setValue(timestamp, YES_MANUAL);
timestamp = timestamp.minus(1);
}

@ -42,7 +42,7 @@ class TestModule {
interface HabitsActivityTestComponent {
fun getCheckmarkPanelViewFactory(): CheckmarkPanelViewFactory
fun getHabitCardViewFactory(): HabitCardViewFactory
fun getCheckmarkButtonViewFactory(): CheckmarkButtonViewFactory
fun getEntryButtonViewFactory(): CheckmarkButtonViewFactory
fun getNumberButtonViewFactory(): NumberButtonViewFactory
fun getNumberPanelViewFactory(): NumberPanelViewFactory
}

@ -46,8 +46,8 @@ public class BarChartTest extends BaseViewTest
Habit habit = fixtures.createLongNumericalHabit();
view = new BarChart(targetContext);
Timestamp today = DateUtils.getToday();
CheckmarkList checkmarks = habit.getComputedCheckmarks();
view.setCheckmarks(checkmarks.getByInterval(today.minus(20), today));
CheckmarkList entries = habit.getComputedEntries();
view.setEntries(entries.getByInterval(today.minus(20), today));
view.setColor(PaletteUtilsKt.toThemedAndroidColor(habit.getColor(), targetContext));
view.setTarget(200.0);
measureView(view, dpToPixels(300), dpToPixels(200));

@ -46,7 +46,7 @@ public class FrequencyChartTest extends BaseViewTest
Habit habit = fixtures.createLongHabit();
view = new FrequencyChart(targetContext);
view.setFrequency(habit.getOriginalCheckmarks().getWeekdayFrequency());
view.setFrequency(habit.getOriginalEntries().getWeekdayFrequency());
view.setColor(PaletteUtilsKt.toFixedAndroidColor(habit.getColor()));
measureView(view, dpToPixels(300), dpToPixels(100));
}

@ -44,7 +44,7 @@ public class HistoryChartTest extends BaseViewTest
Timestamp today;
private OnToggleCheckmarkListener onToggleCheckmarkListener;
private OnToggleCheckmarkListener onToggleEntryListener;
@Override
@Before
@ -58,12 +58,12 @@ public class HistoryChartTest extends BaseViewTest
chart = new HistoryChart(targetContext);
chart.setSkipEnabled(true);
chart.setCheckmarks(habit.getComputedCheckmarks().getAllValues());
chart.setEntries(habit.getComputedEntries().getAllValues());
chart.setColor(PaletteUtilsKt.toFixedAndroidColor(habit.getColor()));
measureView(chart, dpToPixels(400), dpToPixels(200));
onToggleCheckmarkListener = mock(OnToggleCheckmarkListener.class);
chart.setOnToggleCheckmarkListener(onToggleCheckmarkListener);
onToggleEntryListener = mock(OnToggleCheckmarkListener.class);
chart.setOnToggleCheckmarkListener(onToggleEntryListener);
}
@Test
@ -73,7 +73,7 @@ public class HistoryChartTest extends BaseViewTest
chart.tap(dpToPixels(118), dpToPixels(13)); // header
chart.tap(dpToPixels(336), dpToPixels(60)); // tomorrow's square
chart.tap(dpToPixels(370), dpToPixels(60)); // right axis
verifyNoMoreInteractions(onToggleCheckmarkListener);
verifyNoMoreInteractions(onToggleEntryListener);
}
@Test
@ -81,18 +81,18 @@ public class HistoryChartTest extends BaseViewTest
{
chart.setIsEditable(true);
chart.tap(dpToPixels(340), dpToPixels(40));
verify(onToggleCheckmarkListener).onToggleCheckmark(today, Checkmark.SKIP);
verifyNoMoreInteractions(onToggleCheckmarkListener);
verify(onToggleEntryListener).onToggleEntry(today, Entry.SKIP);
verifyNoMoreInteractions(onToggleEntryListener);
}
@Test
public void tapDate_withEmptyHabit()
{
chart.setIsEditable(true);
chart.setCheckmarks(new int[]{});
chart.setEntries(new int[]{});
chart.tap(dpToPixels(340), dpToPixels(40));
verify(onToggleCheckmarkListener).onToggleCheckmark(today, Checkmark.YES_MANUAL);
verifyNoMoreInteractions(onToggleCheckmarkListener);
verify(onToggleEntryListener).onToggleEntry(today, Entry.YES_MANUAL);
verifyNoMoreInteractions(onToggleEntryListener);
}
@Test
@ -100,7 +100,7 @@ public class HistoryChartTest extends BaseViewTest
{
chart.setIsEditable(false);
chart.tap(dpToPixels(340), dpToPixels(40));
verifyNoMoreInteractions(onToggleCheckmarkListener);
verifyNoMoreInteractions(onToggleEntryListener);
}
@Test

@ -29,7 +29,7 @@ import org.junit.runner.*
@RunWith(AndroidJUnit4::class)
@MediumTest
class CheckmarkButtonViewTest : BaseViewTest() {
class EntryButtonViewTest : BaseViewTest() {
private val PATH = "habits/list/CheckmarkButtonView"
lateinit var view: CheckmarkButtonView
@ -39,8 +39,8 @@ class CheckmarkButtonViewTest : BaseViewTest() {
@Before
override fun setUp() {
super.setUp()
view = component.getCheckmarkButtonViewFactory().create().apply {
value = Checkmark.NO
view = component.getEntryButtonViewFactory().create().apply {
value = Entry.NO
color = PaletteUtils.getAndroidTestColor(5)
onToggle = { toggled = true }
}
@ -49,19 +49,19 @@ class CheckmarkButtonViewTest : BaseViewTest() {
@Test
fun testRender_explicitCheck() {
view.value = Checkmark.YES_MANUAL
view.value = Entry.YES_MANUAL
assertRendersCheckedExplicitly()
}
@Test
fun testRender_implicitCheck() {
view.value = Checkmark.YES_AUTO
view.value = Entry.YES_AUTO
assertRendersCheckedImplicitly()
}
@Test
fun testRender_unchecked() {
view.value = Checkmark.NO
view.value = Entry.NO
assertRendersUnchecked()
}

@ -25,16 +25,16 @@ import org.hamcrest.CoreMatchers.*
import org.hamcrest.MatcherAssert.*
import org.isoron.uhabits.*
import org.isoron.uhabits.core.models.*
import org.isoron.uhabits.core.models.Checkmark.Companion.NO
import org.isoron.uhabits.core.models.Checkmark.Companion.YES_AUTO
import org.isoron.uhabits.core.models.Checkmark.Companion.YES_MANUAL
import org.isoron.uhabits.core.models.Entry.Companion.NO
import org.isoron.uhabits.core.models.Entry.Companion.YES_AUTO
import org.isoron.uhabits.core.models.Entry.Companion.YES_MANUAL
import org.isoron.uhabits.utils.*
import org.junit.*
import org.junit.runner.*
@RunWith(AndroidJUnit4::class)
@MediumTest
class CheckmarkPanelViewTest : BaseViewTest() {
class EntryPanelViewTest : BaseViewTest() {
private val PATH = "habits/list/CheckmarkPanelView"
private lateinit var view: CheckmarkPanelView

@ -43,7 +43,7 @@ class HabitCardViewTest : BaseViewTest() {
habit2 = fixtures.createLongNumericalHabit()
view = component.getHabitCardViewFactory().create().apply {
habit = habit1
values = habit1.computedCheckmarks.allValues
values = habit1.computedEntries.allValues
score = habit1.scores.todayValue
isSelected = false
buttonCount = 5
@ -70,7 +70,7 @@ class HabitCardViewTest : BaseViewTest() {
fun testRender_numerical() {
view.apply {
habit = habit2
values = habit2.computedCheckmarks.allValues
values = habit2.computedEntries.allValues
}
assertRenders(view, "$PATH/render_numerical.png")
}

@ -52,7 +52,7 @@ public class PerformanceTest extends BaseAndroidTest
for (int i = 0; i < 100000; i++)
{
habit.getScores().getTodayValue();
habit.getComputedCheckmarks().getTodayValue();
habit.getComputedEntries().getTodayValue();
}
}

@ -31,7 +31,7 @@ import org.junit.runner.*;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
@RunWith(AndroidJUnit4.class)
@MediumTest
@ -41,7 +41,7 @@ public class CheckmarkWidgetTest extends BaseViewTest
private Habit habit;
private CheckmarkList checkmarks;
private CheckmarkList entries;
private FrameLayout view;
@ -54,11 +54,11 @@ public class CheckmarkWidgetTest extends BaseViewTest
prefs.setSkipEnabled(true);
habit = fixtures.createVeryLongHabit();
checkmarks = habit.getComputedCheckmarks();
entries = habit.getComputedEntries();
CheckmarkWidget widget = new CheckmarkWidget(targetContext, 0, habit);
view = convertToView(widget, 150, 200);
assertThat(checkmarks.getTodayValue(), equalTo(YES_MANUAL));
assertThat(entries.getTodayValue(), equalTo(YES_MANUAL));
}
@Test
@ -71,11 +71,11 @@ public class CheckmarkWidgetTest extends BaseViewTest
// possible to capture intents sent to BroadcastReceivers.
button.performClick();
sleep(1000);
assertThat(checkmarks.getTodayValue(), equalTo(SKIP));
assertThat(entries.getTodayValue(), equalTo(SKIP));
button.performClick();
sleep(1000);
assertThat(checkmarks.getTodayValue(), equalTo(NO));
assertThat(entries.getTodayValue(), equalTo(NO));
}
@Test

@ -51,8 +51,8 @@ public class CheckmarkWidgetViewTest extends BaseViewTest
float percentage = (float) score;
view.setActiveColor(PaletteUtils.getAndroidTestColor(0));
view.setCheckmarkState(habit.getComputedCheckmarks().getTodayValue());
view.setCheckmarkValue(habit.getComputedCheckmarks().getTodayValue());
view.setEntryState(habit.getComputedEntries().getTodayValue());
view.setEntryValue(habit.getComputedEntries().getTodayValue());
view.setPercentage(percentage);
view.setName(habit.getName());
view.refresh();

@ -63,7 +63,7 @@ public class HistoryEditorDialog extends AppCompatDialogFragment
this.onToggleCheckmarkListener = new OnToggleCheckmarkListener()
{
@Override
public void onToggleCheckmark(@NotNull Timestamp timestamp, int value)
public void onToggleEntry(@NotNull Timestamp timestamp, int value)
{
}
};
@ -124,7 +124,7 @@ public class HistoryEditorDialog extends AppCompatDialogFragment
@Override
public void onPause()
{
habit.getComputedCheckmarks().observable.removeListener(this);
habit.getComputedEntries().observable.removeListener(this);
super.onPause();
}
@ -142,7 +142,7 @@ public class HistoryEditorDialog extends AppCompatDialogFragment
getDialog().getWindow().setLayout(width, height);
refreshData();
habit.getComputedCheckmarks().observable.addListener(this);
habit.getComputedEntries().observable.addListener(this);
}
@Override
@ -175,7 +175,7 @@ public class HistoryEditorDialog extends AppCompatDialogFragment
@Override
public void doInBackground()
{
checkmarks = habit.getComputedCheckmarks().getAllValues();
checkmarks = habit.getComputedEntries().getAllValues();
}
@Override
@ -186,7 +186,7 @@ public class HistoryEditorDialog extends AppCompatDialogFragment
int color = PaletteUtilsKt.toThemedAndroidColor(habit.getColor(), getContext());
historyChart.setColor(color);
historyChart.setCheckmarks(checkmarks);
historyChart.setEntries(checkmarks);
historyChart.setNumerical(habit.isNumerical());
historyChart.setTarget(habit.getTargetValue() / habit.getFrequency().getDenominator());
}

@ -74,7 +74,7 @@ public class BarChart extends ScrollableChart
private int gridColor;
@Nullable
private List<Checkmark> checkmarks;
private List<Entry> entries;
private int bucketSize = 7;
@ -115,17 +115,17 @@ public class BarChart extends ScrollableChart
public void populateWithRandomData()
{
Random random = new Random();
List<Checkmark> checkmarks = new LinkedList<>();
List<Entry> entries = new LinkedList<>();
Timestamp today = DateUtils.getToday();
for (int i = 1; i < 100; i++)
{
int value = random.nextInt(1000);
checkmarks.add(new Checkmark(today.minus(i), value));
entries.add(new Entry(today.minus(i), value));
}
setCheckmarks(checkmarks);
setEntries(entries);
setTarget(0.5);
}
@ -135,13 +135,13 @@ public class BarChart extends ScrollableChart
postInvalidate();
}
public void setCheckmarks(@NonNull List<Checkmark> checkmarks)
public void setEntries(@NonNull List<Entry> entries)
{
this.checkmarks = checkmarks;
this.entries = entries;
maxValue = 1.0;
for (Checkmark c : checkmarks)
maxValue = Math.max(maxValue, c.getValue());
for (Entry e : entries)
maxValue = Math.max(maxValue, e.getValue());
maxValue = Math.ceil(maxValue / 1000 * 1.05) * 1000;
postInvalidate();
@ -186,7 +186,7 @@ public class BarChart extends ScrollableChart
activeCanvas = canvas;
}
if (checkmarks == null) return;
if (entries == null) return;
rect.set(0, 0, nColumns * columnWidth, columnHeight);
rect.offset(0, paddingTop);
@ -204,10 +204,10 @@ public class BarChart extends ScrollableChart
for (int k = 0; k < nColumns; k++)
{
int offset = nColumns - k - 1 + getDataOffset();
if (offset >= checkmarks.size()) continue;
if (offset >= entries.size()) continue;
double value = checkmarks.get(offset).getValue();
Timestamp timestamp = checkmarks.get(offset).getTimestamp();
double value = entries.get(offset).getValue();
Timestamp timestamp = entries.get(offset).getTimestamp();
int height = (int) (columnHeight * value / maxValue);
rect.set(0, 0, baseSize, height);

@ -40,7 +40,7 @@ import java.text.*;
import java.util.*;
import static org.isoron.uhabits.utils.InterfaceUtils.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
public class HistoryChart extends ScrollableChart
{
@ -158,12 +158,12 @@ public class HistoryChart extends ScrollableChart
if (offset < checkmarks.length)
{
if(skipsEnabled)
newValue = Checkmark.Companion.nextToggleValueWithSkip(checkmarks[offset]);
newValue = Entry.Companion.nextToggleValueWithSkip(checkmarks[offset]);
else
newValue = Checkmark.Companion.nextToggleValueWithoutSkip(checkmarks[offset]);
newValue = Entry.Companion.nextToggleValueWithoutSkip(checkmarks[offset]);
}
onToggleCheckmarkListener.onToggleCheckmark(timestamp, newValue);
onToggleCheckmarkListener.onToggleEntry(timestamp, newValue);
postInvalidate();
return true;
@ -187,7 +187,7 @@ public class HistoryChart extends ScrollableChart
}
}
public void setCheckmarks(int[] checkmarks)
public void setEntries(int[] checkmarks)
{
this.checkmarks = checkmarks;
postInvalidate();
@ -454,7 +454,7 @@ public class HistoryChart extends ScrollableChart
onToggleCheckmarkListener = new OnToggleCheckmarkListener()
{
@Override
public void onToggleCheckmark(@NotNull Timestamp timestamp, int value)
public void onToggleEntry(@NotNull Timestamp timestamp, int value)
{
}
};

@ -27,10 +27,10 @@ import android.view.View.MeasureSpec.*
import com.google.auto.factory.*
import org.isoron.uhabits.*
import org.isoron.uhabits.core.models.*
import org.isoron.uhabits.core.models.Checkmark.Companion.NO
import org.isoron.uhabits.core.models.Checkmark.Companion.SKIP
import org.isoron.uhabits.core.models.Checkmark.Companion.UNKNOWN
import org.isoron.uhabits.core.models.Checkmark.Companion.YES_MANUAL
import org.isoron.uhabits.core.models.Entry.Companion.NO
import org.isoron.uhabits.core.models.Entry.Companion.SKIP
import org.isoron.uhabits.core.models.Entry.Companion.UNKNOWN
import org.isoron.uhabits.core.models.Entry.Companion.YES_MANUAL
import org.isoron.uhabits.core.preferences.*
import org.isoron.uhabits.inject.*
import org.isoron.uhabits.utils.*
@ -66,9 +66,9 @@ class CheckmarkButtonView(
fun performToggle() {
value = if(preferences.isSkipEnabled) {
Checkmark.nextToggleValueWithSkip(value)
Entry.nextToggleValueWithSkip(value)
} else {
Checkmark.nextToggleValueWithoutSkip(value)
Entry.nextToggleValueWithoutSkip(value)
}
onToggle(value)
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)

@ -22,7 +22,7 @@ package org.isoron.uhabits.activities.habits.list.views
import android.content.*
import com.google.auto.factory.*
import org.isoron.uhabits.core.models.*
import org.isoron.uhabits.core.models.Checkmark.Companion.UNKNOWN
import org.isoron.uhabits.core.models.Entry.Companion.UNKNOWN
import org.isoron.uhabits.core.preferences.*
import org.isoron.uhabits.core.utils.*
import org.isoron.uhabits.inject.*

@ -28,7 +28,7 @@ import org.isoron.uhabits.databinding.*
import org.isoron.uhabits.utils.*
data class BarCardViewModel(
val checkmarks: List<Checkmark>,
val entries: List<Entry>,
val bucketSize: Int,
val color: PaletteColor,
val isNumerical: Boolean,
@ -44,7 +44,7 @@ class BarCard(context: Context, attrs: AttributeSet) : LinearLayout(context, att
var onBoolSpinnerPosition: (position: Int) -> Unit = {}
fun update(data: BarCardViewModel) {
binding.barChart.setCheckmarks(data.checkmarks)
binding.barChart.setEntries(data.entries)
binding.barChart.setBucketSize(data.bucketSize)
val androidColor = data.color.toThemedAndroidColor(context)
binding.title.setTextColor(androidColor)
@ -95,13 +95,13 @@ class BarCardPresenter(
} else {
boolBucketSizes[boolSpinnerPosition]
}
val checkmarks = if (bucketSize == 1) {
habit.computedCheckmarks.all
val entries = if (bucketSize == 1) {
habit.computedEntries.all
} else {
habit.computedCheckmarks.groupBy(getTruncateField(bucketSize), firstWeekday)
habit.computedEntries.groupBy(getTruncateField(bucketSize), firstWeekday)
}
return BarCardViewModel(
checkmarks = checkmarks,
entries = entries,
bucketSize = bucketSize,
color = habit.color,
isNumerical = habit.isNumerical,

@ -52,7 +52,7 @@ class FrequencyCardPresenter(
) {
fun present() = FrequencyCardViewModel(
color = habit.color,
frequency = habit.originalCheckmarks.weekdayFrequency,
frequency = habit.originalEntries.weekdayFrequency,
firstWeekday = firstWeekday,
)
}

@ -27,7 +27,7 @@ import org.isoron.uhabits.databinding.*
import org.isoron.uhabits.utils.*
data class HistoryCardViewModel(
val checkmarks: IntArray,
val entries: IntArray,
val color: PaletteColor,
val firstWeekday: Int,
val isNumerical: Boolean,
@ -48,7 +48,7 @@ class HistoryCard(context: Context, attrs: AttributeSet) : LinearLayout(context,
fun update(data: HistoryCardViewModel) {
binding.historyChart.setFirstWeekday(data.firstWeekday)
binding.historyChart.setSkipEnabled(data.isSkipEnabled)
binding.historyChart.setCheckmarks(data.checkmarks)
binding.historyChart.setEntries(data.entries)
val androidColor = data.color.toThemedAndroidColor(context)
binding.title.setTextColor(androidColor)
binding.historyChart.setColor(androidColor)
@ -66,7 +66,7 @@ class HistoryCardPresenter(
val isSkipEnabled: Boolean,
) {
fun present() = HistoryCardViewModel(
checkmarks = habit.computedCheckmarks.allValues,
entries = habit.computedEntries.allValues,
color = habit.color,
firstWeekday = firstWeekday,
isNumerical = habit.isNumerical,

@ -79,7 +79,7 @@ class OverviewCardPresenter(val habit: Habit) {
scoreToday = scoreToday,
scoreMonthDiff = scoreToday - scoreLastMonth,
scoreYearDiff = scoreToday - scoreLastYear,
totalCount = habit.originalCheckmarks.totalCount,
totalCount = habit.originalEntries.totalCount,
)
}
}

@ -57,12 +57,12 @@ class TargetCardPresenter(
val resources: Resources,
) {
suspend fun present(): TargetCardViewModel = Dispatchers.IO {
val checkmarks = habit.computedCheckmarks
val valueToday = checkmarks.todayValue / 1e3
val valueThisWeek = checkmarks.getThisWeekValue(firstWeekday) / 1e3
val valueThisMonth = checkmarks.thisMonthValue / 1e3
val valueThisQuarter = checkmarks.thisQuarterValue / 1e3
val valueThisYear = checkmarks.thisYearValue / 1e3
val entries = habit.computedEntries
val valueToday = entries.todayValue / 1e3
val valueThisWeek = entries.getThisWeekValue(firstWeekday) / 1e3
val valueThisMonth = entries.thisMonthValue / 1e3
val valueThisQuarter = entries.thisQuarterValue / 1e3
val valueThisYear = entries.thisYearValue / 1e3
val cal = DateUtils.getStartOfTodayCalendarWithOffset()
val daysInMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH)

@ -46,12 +46,12 @@ open class CheckmarkWidget(
setActiveColor(habit.color.toThemedAndroidColor(context))
setName(habit.name)
setCheckmarkValue(habit.computedCheckmarks.todayValue)
setEntryValue(habit.computedEntries.todayValue)
if (habit.isNumerical) {
setNumerical(true)
setCheckmarkState(getNumericalCheckmarkState())
setEntryState(getNumericalEntryState())
} else {
setCheckmarkState(habit.computedCheckmarks.todayValue)
setEntryState(habit.computedEntries.todayValue)
}
setPercentage(habit.scores.todayValue.toFloat())
refresh()
@ -65,11 +65,11 @@ open class CheckmarkWidget(
override fun getDefaultHeight() = 125
override fun getDefaultWidth() = 125
private fun getNumericalCheckmarkState(): Int {
private fun getNumericalEntryState(): Int {
return if (habit.isCompletedToday) {
Checkmark.YES_MANUAL
Entry.YES_MANUAL
} else {
Checkmark.NO
Entry.NO
}
}

@ -44,7 +44,7 @@ class FrequencyWidget(
(widgetView.dataView as FrequencyChart).apply {
setFirstWeekday(firstWeekday)
setColor(habit.color.toThemedAndroidColor(context))
setFrequency(habit.originalCheckmarks.weekdayFrequency)
setFrequency(habit.originalEntries.weekdayFrequency)
}
}

@ -46,7 +46,7 @@ class HistoryWidget(
setFirstWeekday(firstWeekday)
setSkipEnabled(prefs.isSkipEnabled)
setColor(habit.color.toThemedAndroidColor(context))
setCheckmarks(habit.computedCheckmarks.allValues)
setEntries(habit.computedEntries.allValues)
setNumerical(habit.isNumerical)
setTarget(habit.targetValue / habit.frequency.denominator)
}

@ -71,7 +71,7 @@ class NumericalCheckmarkWidgetActivity : Activity(), ListHabitsBehavior.NumberPi
val app = this.applicationContext as HabitsApplication
AndroidThemeSwitcher(this, app.component.preferences).apply()
val numberPickerFactory = NumberPickerFactory(context)
numberPickerFactory.create(data.habit.computedCheckmarks.today!!.value.toDouble() / 1000,
numberPickerFactory.create(data.habit.computedEntries.today!!.value.toDouble() / 1000,
data.habit.unit,
this).show()
}

@ -48,9 +48,9 @@ public class CheckmarkWidgetView extends HabitWidgetView {
protected TextView label;
protected int checkmarkValue;
protected int entryValue;
protected int checkmarkState;
protected int entryState;
protected boolean isNumerical;
@ -77,9 +77,9 @@ public class CheckmarkWidgetView extends HabitWidgetView {
int bgColor;
int fgColor;
switch (checkmarkState) {
case Checkmark.YES_MANUAL:
case Checkmark.SKIP:
switch (entryState) {
case Entry.YES_MANUAL:
case Entry.SKIP:
bgColor = activeColor;
fgColor = res.getColor(R.attr.highContrastReverseTextColor);
setShadowAlpha(0x4f);
@ -87,9 +87,9 @@ public class CheckmarkWidgetView extends HabitWidgetView {
frame.setBackgroundDrawable(background);
break;
case Checkmark.YES_AUTO:
case Checkmark.NO:
case Checkmark.UNKNOWN:
case Entry.YES_AUTO:
case Entry.NO:
case Entry.UNKNOWN:
default:
bgColor = res.getColor(R.attr.cardBgColor);
fgColor = res.getColor(R.attr.mediumContrastTextColor);
@ -109,28 +109,28 @@ public class CheckmarkWidgetView extends HabitWidgetView {
postInvalidate();
}
public void setCheckmarkState(int checkmarkState)
public void setEntryState(int entryState)
{
this.checkmarkState = checkmarkState;
this.entryState = entryState;
}
protected String getText()
{
if (isNumerical) return NumberButtonViewKt.toShortString(checkmarkValue / 1000.0);
switch (checkmarkState) {
case Checkmark.YES_MANUAL:
case Checkmark.YES_AUTO:
if (isNumerical) return NumberButtonViewKt.toShortString(entryValue / 1000.0);
switch (entryState) {
case Entry.YES_MANUAL:
case Entry.YES_AUTO:
return getResources().getString(R.string.fa_check);
case Checkmark.SKIP:
case Entry.SKIP:
return getResources().getString(R.string.fa_skipped);
case Checkmark.UNKNOWN:
case Entry.UNKNOWN:
{
if (preferences.areQuestionMarksEnabled())
return getResources().getString(R.string.fa_question);
else
getResources().getString(R.string.fa_times);
}
case Checkmark.NO:
case Entry.NO:
default:
return getResources().getString(R.string.fa_times);
}
@ -141,9 +141,9 @@ public class CheckmarkWidgetView extends HabitWidgetView {
this.activeColor = activeColor;
}
public void setCheckmarkValue(int checkmarkValue)
public void setEntryValue(int entryValue)
{
this.checkmarkValue = checkmarkValue;
this.entryValue = entryValue;
}
public void setName(@NonNull String name)
@ -218,7 +218,7 @@ public class CheckmarkWidgetView extends HabitWidgetView {
percentage = 0.75f;
name = "Wake up early";
activeColor = PaletteUtils.getAndroidTestColor(6);
checkmarkValue = Checkmark.YES_MANUAL;
entryValue = Entry.YES_MANUAL;
refresh();
}
}

@ -52,7 +52,7 @@ public class CreateRepetitionCommand implements Command
@Override
public void execute()
{
RepetitionList checks = habit.getOriginalCheckmarks();
RepetitionList checks = habit.getOriginalEntries();
checks.setValue(timestamp, value);
habitList.resort();
}

@ -31,7 +31,7 @@ import java.util.*;
import javax.inject.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
/**
@ -95,7 +95,7 @@ public class HabitBullCSVImporter extends AbstractImporter
map.put(name, h);
}
h.getOriginalCheckmarks().setValue(timestamp, YES_MANUAL);
h.getOriginalEntries().setValue(timestamp, YES_MANUAL);
}
}
}

@ -126,7 +126,7 @@ public class HabitsCSVExporter
generateDirs.add(habitDirName);
writeScores(habitDirName, h.getScores());
writeCheckmarks(habitDirName, h.getComputedCheckmarks());
writeCheckmarks(habitDirName, h.getComputedEntries());
}
writeMultipleHabits();
@ -181,7 +181,7 @@ public class HabitsCSVExporter
List<double[]> scores = new ArrayList<>();
for (Habit h : selectedHabits)
{
checkmarks.add(h.getComputedCheckmarks().getValues(oldest, newest));
checkmarks.add(h.getComputedEntries().getValues(oldest, newest));
scores.add(h.getScores().getValues(oldest, newest));
}
@ -244,10 +244,10 @@ public class HabitsCSVExporter
Timestamp newest = Timestamp.ZERO;
for (Habit h : selectedHabits)
{
if(h.getOriginalCheckmarks().getOldest() == null || h.getOriginalCheckmarks().getNewest() == null)
if(h.getOriginalEntries().getOldest() == null || h.getOriginalEntries().getNewest() == null)
continue;
Timestamp currOld = h.getOriginalCheckmarks().getOldest().getTimestamp();
Timestamp currNew = h.getOriginalCheckmarks().getNewest().getTimestamp();
Timestamp currOld = h.getOriginalEntries().getOldest().getTimestamp();
Timestamp currNew = h.getOriginalEntries().getNewest().getTimestamp();
oldest = currOld.isOlderThan(oldest) ? currOld : oldest;
newest = currNew.isNewerThan(newest) ? currNew : newest;
}

@ -131,8 +131,8 @@ public class LoopDBImporter extends AbstractImporter
for (RepetitionRecord r : reps)
{
Timestamp t = new Timestamp(r.timestamp);
Checkmark check = habit.getOriginalCheckmarks().getByTimestamp(t);
if (check == null || check.getValue() != r.value)
Entry entry = habit.getOriginalEntries().getByTimestamp(t);
if (entry == null || entry.getValue() != r.value)
new CreateRepetitionCommand(habitList, habit, t, r.value).execute();
}
}

@ -30,7 +30,7 @@ import java.util.*;
import javax.inject.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
/**
* Class that imports database files exported by Rewire.
@ -167,7 +167,7 @@ public class RewireDBImporter extends AbstractImporter
GregorianCalendar cal = DateUtils.getStartOfTodayCalendar();
cal.set(year, month - 1, day);
habit.getOriginalCheckmarks().setValue(new Timestamp(cal), YES_MANUAL);
habit.getOriginalEntries().setValue(new Timestamp(cal), YES_MANUAL);
} while (c.moveToNext());
}
finally

@ -30,7 +30,7 @@ import java.util.*;
import javax.inject.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
/**
* Class that imports data from database files exported by Tickmate.
@ -102,7 +102,7 @@ public class TickmateDBImporter extends AbstractImporter
GregorianCalendar cal = DateUtils.getStartOfTodayCalendar();
cal.set(year, month, day);
habit.getOriginalCheckmarks().setValue(new Timestamp(cal), YES_MANUAL);
habit.getOriginalEntries().setValue(new Timestamp(cal), YES_MANUAL);
} while (c.moveToNext());
}
finally

@ -30,11 +30,11 @@ import java.util.*;
import javax.annotation.concurrent.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
import static org.isoron.uhabits.core.utils.StringUtils.defaultToStringStyle;
/**
* The collection of {@link Checkmark}s belonging to a habit.
* The collection of {@link Entry}s belonging to a habit.
*/
@ThreadSafe
public abstract class CheckmarkList
@ -50,7 +50,7 @@ public abstract class CheckmarkList
}
@NonNull
static List<Checkmark> buildCheckmarksFromIntervals(Checkmark[] original,
static List<Entry> buildEntriesFromInterval(Entry[] original,
ArrayList<Interval> intervals)
{
if (original.length == 0) throw new IllegalArgumentException();
@ -60,9 +60,9 @@ public abstract class CheckmarkList
if (intervals.size() > 0) begin = Timestamp.oldest(begin, intervals.get(0).begin);
int nDays = begin.daysUntil(today) + 1;
List<Checkmark> checkmarks = new ArrayList<>(nDays);
List<Entry> entries = new ArrayList<>(nDays);
for (int i = 0; i < nDays; i++)
checkmarks.add(new Checkmark(today.minus(i), UNKNOWN));
entries.add(new Entry(today.minus(i), UNKNOWN));
for (Interval interval : intervals)
{
@ -71,51 +71,50 @@ public abstract class CheckmarkList
Timestamp date = interval.begin.plus(i);
int offset = date.daysUntil(today);
if (offset < 0) continue;
checkmarks.set(offset, new Checkmark(date, YES_AUTO));
entries.set(offset, new Entry(date, YES_AUTO));
}
}
for (Checkmark c : original)
for (Entry e : original)
{
Timestamp date = c.getTimestamp();
Timestamp date = e.getTimestamp();
int offset = date.daysUntil(today);
int value = c.getValue();
int prevValue = checkmarks.get(offset).getValue();
int value = e.getValue();
int prevValue = entries.get(offset).getValue();
if (prevValue < value)
checkmarks.set(offset, new Checkmark(date, value));
entries.set(offset, new Entry(date, value));
}
return checkmarks;
return entries;
}
/**
* For non-daily habits, some groups of repetitions generate many
* checkmarks. For example, for weekly habits, each repetition generates
* For non-daily habits, some manual entries generate many
* automatic entries. For example, for weekly habits, each repetition generates
* seven checkmarks. For twice-a-week habits, two repetitions that are close
* enough together also generate seven checkmarks.
* <p>
* This group of generated checkmarks, for a given set of repetition, is
* represented by an interval. This function computes the list of intervals
* for a given list of repetitions. It tries to build the intervals as far
* away in the future as possible.
* This group of generated entries is represented by an interval. This function
* computes the list of intervals for a given list of original entries. It tries
* to build the intervals as far away in the future as possible.
*/
@NonNull
static ArrayList<Interval> buildIntervals(@NonNull Frequency freq,
@NonNull Checkmark[] checks)
@NonNull Entry[] entries)
{
ArrayList<Checkmark> filteredReps = new ArrayList<>();
for (Checkmark c : checks)
if (c.getValue() == YES_MANUAL)
filteredReps.add(c);
ArrayList<Entry> filteredEntries = new ArrayList<>();
for (Entry e : entries)
if (e.getValue() == YES_MANUAL)
filteredEntries.add(e);
int num = freq.getNumerator();
int den = freq.getDenominator();
ArrayList<Interval> intervals = new ArrayList<>();
for (int i = 0; i < filteredReps.size() - num + 1; i++)
for (int i = 0; i < filteredEntries.size() - num + 1; i++)
{
Checkmark first = filteredReps.get(i);
Checkmark last = filteredReps.get(i + num - 1);
Entry first = filteredEntries.get(i);
Entry last = filteredEntries.get(i + num - 1);
long distance = first.getTimestamp().daysUntil(last.getTimestamp());
if (distance >= den) continue;
@ -155,15 +154,7 @@ public abstract class CheckmarkList
}
}
/**
* Adds all the given checkmarks to the list.
* <p>
* This should never be called by the application, since the checkmarks are
* computed automatically from the list of repetitions.
*
* @param checkmarks the checkmarks to be added.
*/
public abstract void add(List<Checkmark> checkmarks);
public abstract void add(List<Entry> entries);
/**
* Returns the values for all the checkmarks, since the oldest repetition of
@ -180,7 +171,7 @@ public abstract class CheckmarkList
@NonNull
public synchronized final int[] getAllValues()
{
Checkmark oldestOriginal = habit.getOriginalCheckmarks().getOldest();
Entry oldestOriginal = habit.getOriginalEntries().getOldest();
if (oldestOriginal == null) return new int[0];
Timestamp fromTimestamp = oldestOriginal.getTimestamp();
@ -202,7 +193,7 @@ public abstract class CheckmarkList
* @return the list of checkmarks within the interval.
*/
@NonNull
public abstract List<Checkmark> getByInterval(Timestamp fromTimestamp,
public abstract List<Entry> getByInterval(Timestamp fromTimestamp,
Timestamp toTimestamp);
/**
@ -211,7 +202,7 @@ public abstract class CheckmarkList
* @return checkmark for today
*/
@Nullable
public synchronized final Checkmark getToday()
public synchronized final Entry getToday()
{
compute();
Timestamp today = DateUtils.getTodayWithOffset();
@ -225,7 +216,7 @@ public abstract class CheckmarkList
*/
public synchronized int getTodayValue()
{
Checkmark today = getToday();
Entry today = getToday();
if (today != null) return today.getValue();
else return UNKNOWN;
}
@ -254,7 +245,7 @@ public abstract class CheckmarkList
private int getThisIntervalValue(DateUtils.TruncateField truncateField, int firstWeekday)
{
List<Checkmark> groups = habit.getComputedCheckmarks().groupBy(truncateField, firstWeekday, 1);
List<Entry> groups = habit.getComputedEntries().groupBy(truncateField, firstWeekday, 1);
if (groups.isEmpty()) return 0;
return groups.get(0).getValue();
}
@ -276,11 +267,11 @@ public abstract class CheckmarkList
{
if (from.isNewerThan(to)) return new int[0];
List<Checkmark> checkmarks = getByInterval(from, to);
int values[] = new int[checkmarks.size()];
List<Entry> entries = getByInterval(from, to);
int values[] = new int[entries.size()];
int i = 0;
for (Checkmark c : checkmarks)
for (Entry c : entries)
values[i++] = c.getValue();
return values;
@ -330,20 +321,20 @@ public abstract class CheckmarkList
{
final Timestamp today = DateUtils.getTodayWithOffset();
Checkmark newest = getNewestComputed();
Entry newest = getNewestComputed();
if (newest != null && newest.getTimestamp().equals(today)) return;
invalidateNewerThan(Timestamp.ZERO);
Checkmark oldestRep = habit.getOriginalCheckmarks().getOldest();
Entry oldestRep = habit.getOriginalEntries().getOldest();
if (oldestRep == null) return;
final Timestamp from = oldestRep.getTimestamp();
if (from.isNewerThan(today)) return;
Checkmark reps[] = habit
.getOriginalCheckmarks()
Entry reps[] = habit
.getOriginalEntries()
.getByInterval(from, today)
.toArray(new Checkmark[0]);
.toArray(new Entry[0]);
if (habit.isNumerical()) computeNumerical(reps);
else computeYesNo(reps);
@ -355,7 +346,7 @@ public abstract class CheckmarkList
* @return newest checkmark already computed
*/
@Nullable
protected abstract Checkmark getNewestComputed();
protected abstract Entry getNewestComputed();
/**
* Returns oldest checkmark that has already been computed.
@ -363,9 +354,9 @@ public abstract class CheckmarkList
* @return oldest checkmark already computed
*/
@Nullable
protected abstract Checkmark getOldestComputed();
protected abstract Entry getOldestComputed();
private void computeNumerical(Checkmark[] original)
private void computeNumerical(Entry[] original)
{
if (original.length == 0) return;
@ -373,29 +364,29 @@ public abstract class CheckmarkList
Timestamp begin = original[0].getTimestamp();
int nDays = begin.daysUntil(today) + 1;
List<Checkmark> computed = new ArrayList<>(nDays);
List<Entry> computed = new ArrayList<>(nDays);
for (int i = 0; i < nDays; i++)
computed.add(new Checkmark(today.minus(i), 0));
computed.add(new Entry(today.minus(i), 0));
for (Checkmark c : original)
for (Entry e : original)
{
int offset = c.getTimestamp().daysUntil(today);
computed.set(offset, new Checkmark(c.getTimestamp(), c.getValue()));
int offset = e.getTimestamp().daysUntil(today);
computed.set(offset, new Entry(e.getTimestamp(), e.getValue()));
}
add(computed);
}
private void computeYesNo(Checkmark[] original)
private void computeYesNo(Entry[] original)
{
ArrayList<Interval> intervals;
intervals = buildIntervals(habit.getFrequency(), original);
snapIntervalsTogether(intervals);
add(buildCheckmarksFromIntervals(original, intervals));
add(buildEntriesFromInterval(original, intervals));
}
public List<Checkmark> getAll() {
Checkmark oldest = habit.getOriginalCheckmarks().getOldest();
public List<Entry> getAll() {
Entry oldest = habit.getOriginalEntries().getOldest();
if(oldest == null) return new ArrayList<>();
return getByInterval(oldest.getTimestamp(), DateUtils.getTodayWithOffset());
}
@ -457,24 +448,24 @@ public abstract class CheckmarkList
}
@NonNull
public List<Checkmark> groupBy(DateUtils.TruncateField field, int firstWeekday)
public List<Entry> groupBy(DateUtils.TruncateField field, int firstWeekday)
{
return groupBy(field, firstWeekday, 0);
}
@NonNull
public List<Checkmark> groupBy(DateUtils.TruncateField field,
public List<Entry> groupBy(DateUtils.TruncateField field,
int firstWeekday,
int maxGroups)
{
List<Checkmark> checks = getAll();
List<Entry> checks = getAll();
int count = 0;
Timestamp[] truncatedTimestamps = new Timestamp[checks.size()];
int[] values = new int[checks.size()];
for (Checkmark rep : checks)
for (Entry rep : checks)
{
Timestamp tt = rep.getTimestamp().truncate(field, firstWeekday);
if (count == 0 || !truncatedTimestamps[count - 1].equals(tt))
@ -485,18 +476,18 @@ public abstract class CheckmarkList
if(habit.isNumerical())
values[count - 1] += rep.getValue();
else if(rep.getValue() == Checkmark.YES_MANUAL)
else if(rep.getValue() == Entry.YES_MANUAL)
values[count - 1] += 1000;
}
ArrayList<Checkmark> groupedCheckmarks = new ArrayList<>();
ArrayList<Entry> groupedEntries = new ArrayList<>();
for (int i = 0; i < count; i++)
{
Checkmark rep = new Checkmark(truncatedTimestamps[i], values[i]);
groupedCheckmarks.add(rep);
Entry rep = new Entry(truncatedTimestamps[i], values[i]);
groupedEntries.add(rep);
}
return groupedCheckmarks;
return groupedEntries;
}
}

@ -18,45 +18,35 @@
*/
package org.isoron.uhabits.core.models
/**
* A Checkmark represents the completion status of the habit for a given day.
*
* While repetitions simply record that the habit was performed at a given date, a checkmark
* provides more information, such as whether a repetition was expected at that day or not.
*
* Checkmarks are computed automatically from the list of repetitions.
*
* Note that the status comparator in relies on SKIP > YES_MANUAL > YES_AUTO > NO.
*/
data class Checkmark(
data class Entry(
val timestamp: Timestamp,
val value: Int,
) {
companion object {
/**
* Checkmark value indicating that the habit is not applicable for this timestamp.
* Value indicating that the habit is not applicable for this timestamp.
*/
const val SKIP = 3
/**
* Checkmark value indicating that the user has performed the habit at this timestamp.
* Value indicating that the user has performed the habit at this timestamp.
*/
const val YES_MANUAL = 2
/**
* Checkmark value indicating that the user did not perform the habit, but they were not
* Value indicating that the user did not perform the habit, but they were not
* expected to, because of the frequency of the habit.
*/
const val YES_AUTO = 1
/**
* Checkmark value indicating that the user did not perform the habit, even though they were
* Value indicating that the user did not perform the habit, even though they were
* expected to perform it.
*/
const val NO = 0
/**
* Checkmark value indicating that no data is available for the given timestamp.
* Value indicating that no data is available for the given timestamp.
*/
const val UNKNOWN = -1

@ -28,7 +28,7 @@ import java.util.*;
import javax.annotation.concurrent.*;
import javax.inject.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
import static org.isoron.uhabits.core.utils.StringUtils.defaultToStringStyle;
/**
@ -115,7 +115,7 @@ public class Habit
}
@NonNull
public synchronized CheckmarkList getComputedCheckmarks()
public synchronized CheckmarkList getComputedEntries()
{
return checkmarks;
}
@ -203,7 +203,7 @@ public class Habit
data.reminder = reminder;
}
public RepetitionList getOriginalCheckmarks()
public RepetitionList getOriginalEntries()
{
return repetitions;
}
@ -296,7 +296,7 @@ public class Habit
public void invalidateNewerThan(Timestamp timestamp)
{
getScores().invalidateNewerThan(timestamp);
getComputedCheckmarks().invalidateNewerThan(timestamp);
getComputedEntries().invalidateNewerThan(timestamp);
getStreaks().invalidateNewerThan(timestamp);
}
@ -312,7 +312,7 @@ public class Habit
public synchronized boolean isCompletedToday()
{
int todayCheckmark = getComputedCheckmarks().getTodayValue();
int todayCheckmark = getComputedEntries().getTodayValue();
if (isNumerical())
{
if(getTargetType() == AT_LEAST)

@ -178,7 +178,7 @@ public abstract class HabitList implements Iterable<Habit>
{
for (Habit h : this)
{
h.getComputedCheckmarks().invalidateNewerThan(Timestamp.ZERO);
h.getComputedEntries().invalidateNewerThan(Timestamp.ZERO);
h.getStreaks().invalidateNewerThan(Timestamp.ZERO);
h.getScores().invalidateNewerThan(Timestamp.ZERO);
}

@ -45,9 +45,9 @@ public abstract class RepetitionList
* Any implementation of this method must call observable.notifyListeners()
* after the checkmark has been added.
*
* @param checkmark the checkmark to be added.
* @param entry the checkmark to be added.
*/
public abstract void add(Checkmark checkmark);
public abstract void add(Entry entry);
/**
* Returns the list of checkmarks that happened within the given time
@ -61,7 +61,7 @@ public abstract class RepetitionList
* @param toTimestamp timestamp of the end of the interval
* @return list of checkmarks within given time interval
*/
public abstract List<Checkmark> getByInterval(Timestamp fromTimestamp,
public abstract List<Entry> getByInterval(Timestamp fromTimestamp,
Timestamp toTimestamp);
/**
@ -72,7 +72,7 @@ public abstract class RepetitionList
* @return the checkmark that has the given timestamp.
*/
@Nullable
public abstract Checkmark getByTimestamp(Timestamp timestamp);
public abstract Entry getByTimestamp(Timestamp timestamp);
/**
* If a checkmark with the given timestamp exists, return its value. Otherwise, returns
@ -81,8 +81,8 @@ public abstract class RepetitionList
@NonNull
public int getValue(Timestamp timestamp)
{
Checkmark check = getByTimestamp(timestamp);
if (check == null) return Checkmark.UNKNOWN;
Entry check = getByTimestamp(timestamp);
if (check == null) return Entry.UNKNOWN;
return check.getValue();
}
@ -101,7 +101,7 @@ public abstract class RepetitionList
* @return oldest checkmark in the list, or null if list is empty.
*/
@Nullable
public abstract Checkmark getOldest();
public abstract Entry getOldest();
@Nullable
/**
@ -112,7 +112,7 @@ public abstract class RepetitionList
*
* @return newest checkmark in the list, or null if list is empty.
*/
public abstract Checkmark getNewest();
public abstract Entry getNewest();
/**
* Returns the total number of successful checkmarks for each month, from the first
@ -130,17 +130,17 @@ public abstract class RepetitionList
@NonNull
public HashMap<Timestamp, Integer[]> getWeekdayFrequency()
{
List<Checkmark> checks =
List<Entry> entries =
getByInterval(Timestamp.ZERO, DateUtils.getTodayWithOffset());
HashMap<Timestamp, Integer[]> map = new HashMap<>();
for (Checkmark c : checks)
for (Entry e : entries)
{
if (!habit.isNumerical() && c.getValue() != Checkmark.YES_MANUAL)
if (!habit.isNumerical() && e.getValue() != Entry.YES_MANUAL)
continue;
Calendar date = c.getTimestamp().toCalendar();
int weekday = c.getTimestamp().getWeekday();
Calendar date = e.getTimestamp().toCalendar();
int weekday = e.getTimestamp().getWeekday();
date.set(Calendar.DAY_OF_MONTH, 1);
Timestamp timestamp = new Timestamp(date.getTimeInMillis());
@ -167,17 +167,17 @@ public abstract class RepetitionList
* Any implementation of this method must call observable.notifyListeners()
* after the checkmark has been added.
*
* @param checkmark the checkmark to be removed
* @param entry the checkmark to be removed
*/
public abstract void remove(@NonNull Checkmark checkmark);
public abstract void remove(@NonNull Entry entry);
public abstract long getTotalCount();
public void setValue(Timestamp timestamp, int value)
{
Checkmark check = getByTimestamp(timestamp);
Entry check = getByTimestamp(timestamp);
if (check != null) remove(check);
add(new Checkmark(timestamp, value));
add(new Entry(timestamp, value));
habit.invalidateNewerThan(timestamp);
}

@ -27,7 +27,7 @@ import java.io.*;
import java.text.*;
import java.util.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
public abstract class ScoreList implements Iterable<Score>
{
@ -201,9 +201,9 @@ public abstract class ScoreList implements Iterable<Score>
if (newestComputed == null)
{
Checkmark oldestOriginal = habit.getOriginalCheckmarks().getOldest();
if (oldestOriginal != null) from =
Timestamp.oldest(from, oldestOriginal.getTimestamp());
Entry oldest = habit.getOriginalEntries().getOldest();
if (oldest != null) from =
Timestamp.oldest(from, oldest.getTimestamp());
forceRecompute(from, to, 0);
}
else
@ -221,11 +221,11 @@ public abstract class ScoreList implements Iterable<Score>
*/
protected void computeAll()
{
Checkmark oldestRep = habit.getOriginalCheckmarks().getOldest();
if (oldestRep == null) return;
Entry oldest = habit.getOriginalEntries().getOldest();
if (oldest == null) return;
Timestamp today = DateUtils.getTodayWithOffset();
compute(oldestRep.getTimestamp(), today);
compute(oldest.getTimestamp(), today);
}
/**
@ -273,7 +273,7 @@ public abstract class ScoreList implements Iterable<Score>
int numerator = habit.getFrequency().getNumerator();
int denominator = habit.getFrequency().getDenominator();
final double freq = habit.getFrequency().toDouble();
final int[] checkmarkValues = habit.getComputedCheckmarks().getValues(from, to);
final int[] values = habit.getComputedEntries().getValues(from, to);
// For non-daily boolean habits, we double the numerator and the denominator to smooth
// out irregular repetition schedules (for example, weekly habits performed on different
@ -286,26 +286,26 @@ public abstract class ScoreList implements Iterable<Score>
List<Score> scores = new LinkedList<>();
for (int i = 0; i < checkmarkValues.length; i++)
for (int i = 0; i < values.length; i++)
{
int offset = checkmarkValues.length - i - 1;
int offset = values.length - i - 1;
if (habit.isNumerical())
{
rollingSum += checkmarkValues[offset];
if (offset + denominator < checkmarkValues.length) {
rollingSum -= checkmarkValues[offset + denominator];
rollingSum += values[offset];
if (offset + denominator < values.length) {
rollingSum -= values[offset + denominator];
}
double percentageCompleted = Math.min(1, rollingSum / 1000 / habit.getTargetValue());
previousValue = Score.compute(freq, previousValue, percentageCompleted);
}
else
{
if (checkmarkValues[offset] == YES_MANUAL)
if (values[offset] == YES_MANUAL)
rollingSum += 1.0;
if (offset + denominator < checkmarkValues.length)
if (checkmarkValues[offset + denominator] == YES_MANUAL)
if (offset + denominator < values.length)
if (values[offset + denominator] == YES_MANUAL)
rollingSum -= 1.0;
if (checkmarkValues[offset] != SKIP)
if (values[offset] != SKIP)
{
double percentageCompleted = Math.min(1, rollingSum / numerator);
previousValue = Score.compute(freq, previousValue, percentageCompleted);

@ -71,7 +71,7 @@ public abstract class StreakList
Timestamp beginning = findBeginning();
if (beginning == null || beginning.isNewerThan(today)) return;
int checks[] = habit.getComputedCheckmarks().getValues(beginning, today);
int checks[] = habit.getComputedEntries().getValues(beginning, today);
List<Streak> streaks = checkmarksToStreaks(beginning, checks);
removeNewestComputed();
@ -113,7 +113,7 @@ public abstract class StreakList
Streak newestStreak = getNewestComputed();
if (newestStreak != null) return newestStreak.getStart();
Checkmark oldestOriginal = habit.getOriginalCheckmarks().getOldest();
Entry oldestOriginal = habit.getOriginalEntries().getOldest();
if (oldestOriginal != null) return oldestOriginal.getTimestamp();
return null;
}

@ -30,7 +30,7 @@ import java.util.*;
*/
public class MemoryCheckmarkList extends CheckmarkList
{
ArrayList<Checkmark> list;
ArrayList<Entry> list;
public MemoryCheckmarkList(Habit habit)
{
@ -39,16 +39,16 @@ public class MemoryCheckmarkList extends CheckmarkList
}
@Override
public void add(List<Checkmark> checkmarks)
public void add(List<Entry> entries)
{
list.addAll(checkmarks);
list.addAll(entries);
Collections.sort(list,
(c1, c2) -> c2.getTimestamp().compare(c1.getTimestamp()));
}
@NonNull
@Override
public synchronized List<Checkmark> getByInterval(Timestamp from,
public synchronized List<Entry> getByInterval(Timestamp from,
Timestamp to)
{
compute();
@ -56,19 +56,19 @@ public class MemoryCheckmarkList extends CheckmarkList
Timestamp newestComputed = new Timestamp(0);
Timestamp oldestComputed = new Timestamp(0).plus(1000000);
Checkmark newest = getNewestComputed();
Checkmark oldest = getOldestComputed();
Entry newest = getNewestComputed();
Entry oldest = getOldestComputed();
if(newest != null) newestComputed = newest.getTimestamp();
if(oldest != null) oldestComputed = oldest.getTimestamp();
List<Checkmark> filtered = new ArrayList<>(
List<Entry> filtered = new ArrayList<>(
Math.max(0, oldestComputed.daysUntil(newestComputed) + 1));
for(int i = 0; i <= from.daysUntil(to); i++)
{
Timestamp t = to.minus(i);
if(t.isNewerThan(newestComputed) || t.isOlderThan(oldestComputed))
filtered.add(new Checkmark(t, Checkmark.UNKNOWN));
filtered.add(new Entry(t, Entry.UNKNOWN));
else
filtered.add(list.get(t.daysUntil(newestComputed)));
}
@ -85,7 +85,7 @@ public class MemoryCheckmarkList extends CheckmarkList
@Override
@Nullable
protected Checkmark getOldestComputed()
protected Entry getOldestComputed()
{
if(list.isEmpty()) return null;
return list.get(list.size()-1);
@ -93,7 +93,7 @@ public class MemoryCheckmarkList extends CheckmarkList
@Override
@Nullable
protected Checkmark getNewestComputed()
protected Entry getNewestComputed()
{
if(list.isEmpty()) return null;
return list.get(0);

@ -186,8 +186,8 @@ public class MemoryHabitList extends HabitList
return h1.isNumerical() ? -1 : 1;
}
Integer v1 = Objects.requireNonNull(h1.getComputedCheckmarks().getToday()).getValue();
Integer v2 = Objects.requireNonNull(h2.getComputedCheckmarks().getToday()).getValue();
Integer v1 = Objects.requireNonNull(h1.getComputedEntries().getToday()).getValue();
Integer v2 = Objects.requireNonNull(h2.getComputedEntries().getToday()).getValue();
return v2.compareTo(v1);
};

@ -30,7 +30,7 @@ import java.util.*;
*/
public class MemoryRepetitionList extends RepetitionList
{
ArrayList<Checkmark> list;
ArrayList<Entry> list;
public MemoryRepetitionList(Habit habit)
{
@ -39,18 +39,18 @@ public class MemoryRepetitionList extends RepetitionList
}
@Override
public void add(Checkmark repetition)
public void add(Entry repetition)
{
list.add(repetition);
observable.notifyListeners();
}
@Override
public List<Checkmark> getByInterval(Timestamp fromTimestamp, Timestamp toTimestamp)
public List<Entry> getByInterval(Timestamp fromTimestamp, Timestamp toTimestamp)
{
ArrayList<Checkmark> filtered = new ArrayList<>();
ArrayList<Entry> filtered = new ArrayList<>();
for (Checkmark r : list)
for (Entry r : list)
{
Timestamp t = r.getTimestamp();
if (t.isOlderThan(fromTimestamp) || t.isNewerThan(toTimestamp)) continue;
@ -65,9 +65,9 @@ public class MemoryRepetitionList extends RepetitionList
@Nullable
@Override
public Checkmark getByTimestamp(Timestamp timestamp)
public Entry getByTimestamp(Timestamp timestamp)
{
for (Checkmark r : list)
for (Entry r : list)
if (r.getTimestamp().equals(timestamp)) return r;
return null;
@ -75,12 +75,12 @@ public class MemoryRepetitionList extends RepetitionList
@Nullable
@Override
public Checkmark getOldest()
public Entry getOldest()
{
Timestamp oldestTimestamp = Timestamp.ZERO.plus(1000000);
Checkmark oldestRep = null;
Entry oldestRep = null;
for (Checkmark rep : list)
for (Entry rep : list)
{
if (rep.getTimestamp().isOlderThan(oldestTimestamp))
{
@ -94,12 +94,12 @@ public class MemoryRepetitionList extends RepetitionList
@Nullable
@Override
public Checkmark getNewest()
public Entry getNewest()
{
Timestamp newestTimestamp = Timestamp.ZERO;
Checkmark newestRep = null;
Entry newestRep = null;
for (Checkmark rep : list)
for (Entry rep : list)
{
if (rep.getTimestamp().isNewerThan(newestTimestamp))
{
@ -112,7 +112,7 @@ public class MemoryRepetitionList extends RepetitionList
}
@Override
public void remove(@NonNull Checkmark repetition)
public void remove(@NonNull Entry repetition)
{
list.remove(repetition);
observable.notifyListeners();
@ -122,8 +122,8 @@ public class MemoryRepetitionList extends RepetitionList
public long getTotalCount()
{
int count = 0;
for (Checkmark rep : list)
if (rep.getValue() == Checkmark.YES_MANUAL)
for (Entry rep : list)
if (rep.getValue() == Entry.YES_MANUAL)
count++;
return count;
}

@ -201,7 +201,7 @@ public class SQLiteHabitList extends HabitList
if (record == null) throw new RuntimeException("habit not in database");
repository.executeAsTransaction(() ->
{
habit.getOriginalCheckmarks().removeAll();
habit.getOriginalEntries().removeAll();
repository.remove(record);
});

@ -66,20 +66,20 @@ public class SQLiteRepetitionList extends RepetitionList
}
@Override
public void add(Checkmark check)
public void add(Entry entry)
{
loadRecords();
list.add(check);
list.add(entry);
check(habit.getId());
RepetitionRecord record = new RepetitionRecord();
record.habit_id = habit.getId();
record.copyFrom(check);
record.copyFrom(entry);
repository.save(record);
observable.notifyListeners();
}
@Override
public List<Checkmark> getByInterval(Timestamp timeFrom, Timestamp timeTo)
public List<Entry> getByInterval(Timestamp timeFrom, Timestamp timeTo)
{
loadRecords();
return list.getByInterval(timeFrom, timeTo);
@ -87,35 +87,35 @@ public class SQLiteRepetitionList extends RepetitionList
@Override
@Nullable
public Checkmark getByTimestamp(Timestamp timestamp)
public Entry getByTimestamp(Timestamp timestamp)
{
loadRecords();
return list.getByTimestamp(timestamp);
}
@Override
public Checkmark getOldest()
public Entry getOldest()
{
loadRecords();
return list.getOldest();
}
@Override
public Checkmark getNewest()
public Entry getNewest()
{
loadRecords();
return list.getNewest();
}
@Override
public void remove(@NonNull Checkmark checkmark)
public void remove(@NonNull Entry entry)
{
loadRecords();
list.remove(checkmark);
list.remove(entry);
check(habit.getId());
repository.execSQL(
"delete from repetitions where habit = ? and timestamp = ?",
habit.getId(), checkmark.getTimestamp().getUnixTime());
habit.getId(), entry.getTimestamp().getUnixTime());
observable.notifyListeners();
}

@ -25,7 +25,7 @@ import org.isoron.uhabits.core.database.*;
import org.isoron.uhabits.core.models.*;
/**
* The SQLite database record corresponding to a {@link Checkmark}.
* The SQLite database record corresponding to a {@link Entry}.
*/
@Table(name = "Repetitions")
public class RepetitionRecord
@ -44,14 +44,14 @@ public class RepetitionRecord
@Column
public Long id;
public void copyFrom(Checkmark checkmark)
public void copyFrom(Entry entry)
{
timestamp = checkmark.getTimestamp().getUnixTime();
value = checkmark.getValue();
timestamp = entry.getTimestamp().getUnixTime();
value = entry.getValue();
}
public Checkmark toCheckmark()
public Entry toCheckmark()
{
return new Checkmark(new Timestamp(timestamp), value);
return new Entry(new Timestamp(timestamp), value);
}
}

@ -23,7 +23,7 @@ import org.isoron.uhabits.core.models.*;
import org.isoron.uhabits.core.models.sqlite.*;
import org.isoron.uhabits.core.utils.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
public class HabitFixtures
{
@ -65,7 +65,7 @@ public class HabitFixtures
81, 83, 89, 90, 91, 95, 102, 103, 108, 109, 120};
for (int mark : marks)
habit.getOriginalCheckmarks().setValue(today.minus(mark), YES_MANUAL);
habit.getOriginalEntries().setValue(today.minus(mark), YES_MANUAL);
return habit;
}
@ -89,7 +89,7 @@ public class HabitFixtures
for (int i = 0; i < times.length; i++)
{
Timestamp timestamp = today.minus(times[i]);
habit.getOriginalCheckmarks().setValue(timestamp, values[i]);
habit.getOriginalEntries().setValue(timestamp, values[i]);
}
return habit;
@ -125,7 +125,7 @@ public class HabitFixtures
for (int i = 0; i < times.length; i++)
{
Timestamp timestamp = reference.minus(times[i]);
habit.getOriginalCheckmarks().setValue(timestamp, values[i]);
habit.getOriginalEntries().setValue(timestamp, values[i]);
}
return habit;
@ -144,7 +144,7 @@ public class HabitFixtures
{
int value = NO;
if (c) value = YES_MANUAL;
habit.getOriginalCheckmarks().setValue(timestamp, value);
habit.getOriginalEntries().setValue(timestamp, value);
timestamp = timestamp.minus(1);
}
@ -153,7 +153,7 @@ public class HabitFixtures
private void saveIfSQLite(Habit habit)
{
if (!(habit.getOriginalCheckmarks() instanceof SQLiteRepetitionList)) return;
if (!(habit.getOriginalEntries() instanceof SQLiteRepetitionList)) return;
habitList.add(habit);
}
}

@ -178,7 +178,7 @@ public class NotificationTray
@Override
public void doInBackground()
{
todayValue = habit.getComputedCheckmarks().getTodayValue();
todayValue = habit.getComputedEntries().getTodayValue();
}
@Override
@ -186,7 +186,7 @@ public class NotificationTray
{
systemTray.log("Showing notification for habit=" + habit.id);
if (todayValue != Checkmark.UNKNOWN) {
if (todayValue != Entry.UNKNOWN) {
systemTray.log(String.format(
Locale.US,
"Habit %d already checked. Skipping.",

@ -22,5 +22,5 @@ package org.isoron.uhabits.core.ui.callbacks
import org.isoron.uhabits.core.models.*
interface OnToggleCheckmarkListener {
fun onToggleCheckmark(timestamp: Timestamp, value: Int) {}
fun onToggleEntry(timestamp: Timestamp, value: Int) {}
}

@ -361,7 +361,7 @@ public class HabitCardListCache implements CommandRunner.Listener
newData.scores.put(id, habit.getScores().getTodayValue());
newData.checkmarks.put(
id,
habit.getComputedCheckmarks().getValues(dateFrom, dateTo));
habit.getComputedEntries().getValues(dateFrom, dateTo));
runner.publishProgress(this, position);
}

@ -82,8 +82,8 @@ public class ListHabitsBehavior
public void onEdit(@NonNull Habit habit, Timestamp timestamp)
{
CheckmarkList checkmarks = habit.getComputedCheckmarks();
double oldValue = checkmarks.getValues(timestamp, timestamp)[0];
CheckmarkList entries = habit.getComputedEntries();
double oldValue = entries.getValues(timestamp, timestamp)[0];
screen.showNumberPicker(oldValue / 1000, habit.getUnit(), newValue ->
{

@ -54,10 +54,10 @@ class ShowHabitBehavior(
screen.showHistoryEditorDialog(this)
}
override fun onToggleCheckmark(timestamp: Timestamp, value: Int) {
override fun onToggleEntry(timestamp: Timestamp, value: Int) {
if (habit.isNumerical) {
val checkmarks = habit.computedCheckmarks
val oldValue = checkmarks.getValues(timestamp, timestamp)[0].toDouble()
val entries = habit.computedEntries
val oldValue = entries.getValues(timestamp, timestamp)[0].toDouble()
screen.showNumberPicker(oldValue / 1000, habit.unit) { newValue: Double ->
val thousands = Math.round(newValue * 1000).toInt()
commandRunner.execute(

@ -58,14 +58,14 @@ class ShowHabitMenuBehavior(
fun onRandomize() {
val random = Random()
habit.originalCheckmarks.removeAll()
habit.originalEntries.removeAll()
var strength = 50.0
for (i in 0 until 365 * 5) {
if (i % 7 == 0) strength = Math.max(0.0, Math.min(100.0, strength + 10 * random.nextGaussian()))
if (random.nextInt(100) > strength) continue
var value = Checkmark.YES_MANUAL
var value = Entry.YES_MANUAL
if (habit.isNumerical) value = (1000 + 250 * random.nextGaussian() * strength / 100).toInt() * 1000
habit.originalCheckmarks.setValue(DateUtils.getToday().minus(i), value)
habit.originalEntries.setValue(DateUtils.getToday().minus(i), value)
}
habit.invalidateNewerThan(Timestamp.ZERO)
screen.refresh()

@ -29,7 +29,7 @@ import org.jetbrains.annotations.*;
import javax.inject.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
public class WidgetBehavior
{
@ -70,24 +70,24 @@ public class WidgetBehavior
public void onToggleRepetition(@NonNull Habit habit, Timestamp timestamp)
{
int currentValue = habit.getOriginalCheckmarks().getValue(timestamp);
int currentValue = habit.getOriginalEntries().getValue(timestamp);
int newValue;
if(preferences.isSkipEnabled())
newValue = Checkmark.Companion.nextToggleValueWithSkip(currentValue);
newValue = Entry.Companion.nextToggleValueWithSkip(currentValue);
else
newValue = Checkmark.Companion.nextToggleValueWithoutSkip(currentValue);
newValue = Entry.Companion.nextToggleValueWithoutSkip(currentValue);
setValue(habit, timestamp, newValue);
notificationTray.cancel(habit);
}
public void onIncrement(@NotNull Habit habit, @NotNull Timestamp timestamp, int amount) {
int currentValue = habit.getComputedCheckmarks().getValues(timestamp, timestamp)[0];
int currentValue = habit.getComputedEntries().getValues(timestamp, timestamp)[0];
setValue(habit, timestamp, currentValue + amount);
notificationTray.cancel(habit);
}
public void onDecrement(@NotNull Habit habit, @NotNull Timestamp timestamp, int amount) {
int currentValue = habit.getComputedCheckmarks().getValues(timestamp, timestamp)[0];
int currentValue = habit.getComputedEntries().getValues(timestamp, timestamp)[0];
setValue(habit, timestamp, currentValue - amount);
notificationTray.cancel(habit);
}

@ -24,7 +24,7 @@ import org.isoron.uhabits.core.models.*;
import org.isoron.uhabits.core.utils.*;
import org.junit.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
import static org.junit.Assert.*;
public class CreateRepetitionCommandTest extends BaseUnitTest
@ -51,13 +51,13 @@ public class CreateRepetitionCommandTest extends BaseUnitTest
@Test
public void testExecute()
{
RepetitionList reps = habit.getOriginalCheckmarks();
Checkmark check = reps.getByTimestamp(today);
assertNotNull(check);
assertEquals(YES_MANUAL, check.getValue());
RepetitionList originalEntries = habit.getOriginalEntries();
Entry entry = originalEntries.getByTimestamp(today);
assertNotNull(entry);
assertEquals(YES_MANUAL, entry.getValue());
command.execute();
check = reps.getByTimestamp(today);
assertNotNull(check);
assertEquals(100, check.getValue());
entry = originalEntries.getByTimestamp(today);
assertNotNull(entry);
assertEquals(100, entry.getValue());
}
}

@ -30,7 +30,7 @@ import java.util.*;
import static junit.framework.TestCase.assertFalse;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
import static org.isoron.uhabits.core.models.Frequency.*;
import static org.junit.Assert.assertTrue;
@ -123,7 +123,7 @@ public class ImportTest extends BaseUnitTest
GregorianCalendar date = DateUtils.getStartOfTodayCalendar();
date.set(year, month - 1, day);
Timestamp timestamp = new Timestamp(date);
return h.getOriginalCheckmarks().getValue(timestamp) == YES_MANUAL;
return h.getOriginalEntries().getValue(timestamp) == YES_MANUAL;
}
private void importFromFile(String assetFilename) throws IOException

@ -31,12 +31,12 @@ import nl.jqno.equalsverifier.*;
import static java.util.Calendar.*;
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.core.IsEqual.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
import static org.isoron.uhabits.core.utils.DateUtils.TruncateField.MONTH;
import static org.isoron.uhabits.core.utils.DateUtils.TruncateField.QUARTER;
import static org.isoron.uhabits.core.utils.DateUtils.TruncateField.YEAR;
public class CheckmarkListTest extends BaseUnitTest
public class EntryListTest extends BaseUnitTest
{
private long dayLength;
@ -67,11 +67,11 @@ public class CheckmarkListTest extends BaseUnitTest
@Test
public void test_buildCheckmarksFromIntervals_1() throws Exception
{
Checkmark checks[] = new Checkmark[]{
new Checkmark(day(10), YES_MANUAL),
new Checkmark(day(5), YES_MANUAL),
new Checkmark(day(2), YES_MANUAL),
new Checkmark(day(1), YES_MANUAL),
Entry entries[] = new Entry[]{
new Entry(day(10), YES_MANUAL),
new Entry(day(5), YES_MANUAL),
new Entry(day(2), YES_MANUAL),
new Entry(day(1), YES_MANUAL),
};
ArrayList<CheckmarkList.Interval> intervals = new ArrayList<>();
@ -79,49 +79,49 @@ public class CheckmarkListTest extends BaseUnitTest
intervals.add(new CheckmarkList.Interval(day(6), day(5), day(4)));
intervals.add(new CheckmarkList.Interval(day(2), day(2), day(1)));
List<Checkmark> expected = new ArrayList<>();
expected.add(new Checkmark(day(0), UNKNOWN));
expected.add(new Checkmark(day(1), YES_MANUAL));
expected.add(new Checkmark(day(2), YES_MANUAL));
expected.add(new Checkmark(day(3), UNKNOWN));
expected.add(new Checkmark(day(4), YES_AUTO));
expected.add(new Checkmark(day(5), YES_MANUAL));
expected.add(new Checkmark(day(6), YES_AUTO));
expected.add(new Checkmark(day(7), UNKNOWN));
expected.add(new Checkmark(day(8), YES_AUTO));
expected.add(new Checkmark(day(9), YES_AUTO));
expected.add(new Checkmark(day(10), YES_MANUAL));
List<Checkmark> actual =
CheckmarkList.buildCheckmarksFromIntervals(checks, intervals);
List<Entry> expected = new ArrayList<>();
expected.add(new Entry(day(0), UNKNOWN));
expected.add(new Entry(day(1), YES_MANUAL));
expected.add(new Entry(day(2), YES_MANUAL));
expected.add(new Entry(day(3), UNKNOWN));
expected.add(new Entry(day(4), YES_AUTO));
expected.add(new Entry(day(5), YES_MANUAL));
expected.add(new Entry(day(6), YES_AUTO));
expected.add(new Entry(day(7), UNKNOWN));
expected.add(new Entry(day(8), YES_AUTO));
expected.add(new Entry(day(9), YES_AUTO));
expected.add(new Entry(day(10), YES_MANUAL));
List<Entry> actual =
CheckmarkList.buildEntriesFromInterval(entries, intervals);
assertThat(actual, equalTo(expected));
}
@Test
public void test_buildCheckmarksFromIntervals_2() throws Exception
{
Checkmark checks[] = new Checkmark[]{
new Checkmark(day(0), YES_MANUAL),
Entry entries[] = new Entry[]{
new Entry(day(0), YES_MANUAL),
};
ArrayList<CheckmarkList.Interval> intervals = new ArrayList<>();
intervals.add(new CheckmarkList.Interval(day(0), day(0), day(-10)));
List<Checkmark> expected = new ArrayList<>();
expected.add(new Checkmark(day(0), YES_MANUAL));
List<Entry> expected = new ArrayList<>();
expected.add(new Entry(day(0), YES_MANUAL));
List<Checkmark> actual =
CheckmarkList.buildCheckmarksFromIntervals(checks, intervals);
List<Entry> actual =
CheckmarkList.buildEntriesFromInterval(entries, intervals);
assertThat(actual, equalTo(expected));
}
@Test
public void test_buildIntervals_1() throws Exception
{
Checkmark checks[] = new Checkmark[]{
new Checkmark(day(23), YES_MANUAL),
new Checkmark(day(18), YES_MANUAL),
new Checkmark(day(8), YES_MANUAL),
Entry entries[] = new Entry[]{
new Entry(day(23), YES_MANUAL),
new Entry(day(18), YES_MANUAL),
new Entry(day(8), YES_MANUAL),
};
ArrayList<CheckmarkList.Interval> expected = new ArrayList<>();
@ -130,17 +130,17 @@ public class CheckmarkListTest extends BaseUnitTest
expected.add(new CheckmarkList.Interval(day(8), day(8), day(2)));
ArrayList<CheckmarkList.Interval> actual;
actual = CheckmarkList.buildIntervals(Frequency.WEEKLY, checks);
actual = CheckmarkList.buildIntervals(Frequency.WEEKLY, entries);
assertThat(actual, equalTo(expected));
}
@Test
public void test_buildIntervals_2() throws Exception
{
Checkmark checks[] = new Checkmark[]{
new Checkmark(day(23), YES_MANUAL),
new Checkmark(day(18), YES_MANUAL),
new Checkmark(day(8), YES_MANUAL),
Entry entries[] = new Entry[]{
new Entry(day(23), YES_MANUAL),
new Entry(day(18), YES_MANUAL),
new Entry(day(8), YES_MANUAL),
};
ArrayList<CheckmarkList.Interval> expected = new ArrayList<>();
@ -149,19 +149,19 @@ public class CheckmarkListTest extends BaseUnitTest
expected.add(new CheckmarkList.Interval(day(8), day(8), day(8)));
ArrayList<CheckmarkList.Interval> actual;
actual = CheckmarkList.buildIntervals(Frequency.DAILY, checks);
actual = CheckmarkList.buildIntervals(Frequency.DAILY, entries);
assertThat(actual, equalTo(expected));
}
@Test
public void test_buildIntervals_3() throws Exception
{
Checkmark checks[] = new Checkmark[]{
new Checkmark(day(23), YES_MANUAL),
new Checkmark(day(22), YES_MANUAL),
new Checkmark(day(18), YES_MANUAL),
new Checkmark(day(15), YES_MANUAL),
new Checkmark(day(8), YES_MANUAL),
Entry entries[] = new Entry[]{
new Entry(day(23), YES_MANUAL),
new Entry(day(22), YES_MANUAL),
new Entry(day(18), YES_MANUAL),
new Entry(day(15), YES_MANUAL),
new Entry(day(8), YES_MANUAL),
};
ArrayList<CheckmarkList.Interval> expected = new ArrayList<>();
@ -171,7 +171,7 @@ public class CheckmarkListTest extends BaseUnitTest
ArrayList<CheckmarkList.Interval> actual;
actual =
CheckmarkList.buildIntervals(Frequency.TWO_TIMES_PER_WEEK, checks);
CheckmarkList.buildIntervals(Frequency.TWO_TIMES_PER_WEEK, entries);
assertThat(actual, equalTo(expected));
}
@ -179,10 +179,10 @@ public class CheckmarkListTest extends BaseUnitTest
@Test
public void test_buildIntervals_4() throws Exception
{
Checkmark[] checks = new Checkmark[]{
new Checkmark(day(30), YES_MANUAL),
new Checkmark(day(20), SKIP),
new Checkmark(day(10), YES_MANUAL),
Entry[] entries = new Entry[]{
new Entry(day(30), YES_MANUAL),
new Entry(day(20), SKIP),
new Entry(day(10), YES_MANUAL),
};
ArrayList<CheckmarkList.Interval> expected = new ArrayList<>();
@ -190,7 +190,7 @@ public class CheckmarkListTest extends BaseUnitTest
expected.add(new CheckmarkList.Interval(day(10), day(10), day(8)));
ArrayList<CheckmarkList.Interval> actual;
actual = CheckmarkList.buildIntervals(new Frequency(1, 3), checks);
actual = CheckmarkList.buildIntervals(new Frequency(1, 3), entries);
assertThat(actual, equalTo(expected));
}
@ -209,7 +209,7 @@ public class CheckmarkListTest extends BaseUnitTest
YES_MANUAL
};
int[] actualValues = nonDailyHabit.getComputedCheckmarks().getAllValues();
int[] actualValues = nonDailyHabit.getComputedEntries().getAllValues();
assertThat(actualValues, equalTo(expectedValues));
}
@ -235,7 +235,7 @@ public class CheckmarkListTest extends BaseUnitTest
YES_MANUAL
};
int[] actualValues = nonDailyHabit.getComputedCheckmarks().getAllValues();
int[] actualValues = nonDailyHabit.getComputedEntries().getAllValues();
assertThat(actualValues, equalTo(expectedValues));
}
@ -244,7 +244,7 @@ public class CheckmarkListTest extends BaseUnitTest
public void test_getAllValues_withEmptyHabit()
{
int[] expectedValues = new int[0];
int[] actualValues = emptyHabit.getComputedCheckmarks().getAllValues();
int[] actualValues = emptyHabit.getComputedEntries().getAllValues();
assertThat(actualValues, equalTo(expectedValues));
}
@ -265,7 +265,7 @@ public class CheckmarkListTest extends BaseUnitTest
YES_MANUAL
};
int[] actualValues = nonDailyHabit.getComputedCheckmarks().getAllValues();
int[] actualValues = nonDailyHabit.getComputedEntries().getAllValues();
assertThat(actualValues, equalTo(expectedValues));
}
@ -273,37 +273,37 @@ public class CheckmarkListTest extends BaseUnitTest
@Test
public void test_getByInterval_withNumericalHabits() throws Exception
{
CheckmarkList checkmarks = numericalHabit.getComputedCheckmarks();
CheckmarkList entries = numericalHabit.getComputedEntries();
List<Checkmark> expected =
Arrays.asList(new Checkmark(day(1), 200), new Checkmark(day(2), 0),
new Checkmark(day(3), 300), new Checkmark(day(4), 0),
new Checkmark(day(5), 400));
List<Entry> expected =
Arrays.asList(new Entry(day(1), 200), new Entry(day(2), 0),
new Entry(day(3), 300), new Entry(day(4), 0),
new Entry(day(5), 400));
List<Checkmark> actual = checkmarks.getByInterval(day(5), day(1));
List<Entry> actual = entries.getByInterval(day(5), day(1));
assertThat(actual, equalTo(expected));
}
@Test
public void test_getTodayValue()
{
CheckmarkList checkmarks = nonDailyHabit.getComputedCheckmarks();
CheckmarkList entries = nonDailyHabit.getComputedEntries();
travelInTime(-1);
assertThat(checkmarks.getTodayValue(), equalTo(NO));
assertThat(entries.getTodayValue(), equalTo(NO));
travelInTime(0);
assertThat(checkmarks.getTodayValue(), equalTo(YES_MANUAL));
assertThat(entries.getTodayValue(), equalTo(YES_MANUAL));
travelInTime(1);
assertThat(checkmarks.getTodayValue(), equalTo(UNKNOWN));
assertThat(entries.getTodayValue(), equalTo(UNKNOWN));
}
@Test
public void test_getValues_withInvalidInterval()
{
int values[] = nonDailyHabit
.getComputedCheckmarks()
.getComputedEntries()
.getValues(new Timestamp(0L).plus(100), new Timestamp(0L));
assertThat(values, equalTo(new int[0]));
}
@ -328,7 +328,7 @@ public class CheckmarkListTest extends BaseUnitTest
UNKNOWN
};
int[] actualValues = nonDailyHabit.getComputedCheckmarks().getValues(from, to);
int[] actualValues = nonDailyHabit.getComputedEntries().getValues(from, to);
assertThat(actualValues, equalTo(expectedValues));
}
@ -376,7 +376,7 @@ public class CheckmarkListTest extends BaseUnitTest
StringWriter writer = new StringWriter();
nonDailyHabit.getComputedCheckmarks().writeCSV(writer);
nonDailyHabit.getComputedEntries().writeCSV(writer);
assertThat(writer.toString(), equalTo(expectedCSV));
}
@ -395,7 +395,7 @@ public class CheckmarkListTest extends BaseUnitTest
@Test
public void testEquals() throws Exception
{
EqualsVerifier.forClass(Checkmark.class).verify();
EqualsVerifier.forClass(Entry.class).verify();
EqualsVerifier.forClass(Timestamp.class).verify();
EqualsVerifier.forClass(CheckmarkList.Interval.class).verify();
}
@ -404,33 +404,33 @@ public class CheckmarkListTest extends BaseUnitTest
public void testGroupBy() throws Exception
{
Habit habit = fixtures.createLongNumericalHabit(timestamp(2014, JUNE, 1));
CheckmarkList checkmarks = habit.getComputedCheckmarks();
CheckmarkList entries = habit.getComputedEntries();
List<Checkmark> byMonth = checkmarks.groupBy(MONTH, Calendar.SATURDAY);
List<Entry> byMonth = entries.groupBy(MONTH, Calendar.SATURDAY);
assertThat(byMonth.size(), equalTo(25)); // from 2013-01-01 to 2015-01-01
assertThat(byMonth.get(0), equalTo(new Checkmark(timestamp(2015, JANUARY, 1), 0)));
assertThat(byMonth.get(6), equalTo(new Checkmark(timestamp(2014, JULY, 1), 0)));
assertThat(byMonth.get(12), equalTo(new Checkmark(timestamp(2014, JANUARY, 1), 1706)));
assertThat(byMonth.get(18), equalTo(new Checkmark(timestamp(2013, JULY, 1), 1379)));
assertThat(byMonth.get(0), equalTo(new Entry(timestamp(2015, JANUARY, 1), 0)));
assertThat(byMonth.get(6), equalTo(new Entry(timestamp(2014, JULY, 1), 0)));
assertThat(byMonth.get(12), equalTo(new Entry(timestamp(2014, JANUARY, 1), 1706)));
assertThat(byMonth.get(18), equalTo(new Entry(timestamp(2013, JULY, 1), 1379)));
List<Checkmark> byQuarter = checkmarks.groupBy(QUARTER, Calendar.SATURDAY);
List<Entry> byQuarter = entries.groupBy(QUARTER, Calendar.SATURDAY);
assertThat(byQuarter.size(), equalTo(9)); // from 2013-Q1 to 2015-Q1
assertThat(byQuarter.get(0), equalTo(new Checkmark(timestamp(2015, JANUARY, 1), 0)));
assertThat(byQuarter.get(4), equalTo(new Checkmark(timestamp(2014, JANUARY, 1), 4964)));
assertThat(byQuarter.get(8), equalTo(new Checkmark(timestamp(2013, JANUARY, 1), 4975)));
assertThat(byQuarter.get(0), equalTo(new Entry(timestamp(2015, JANUARY, 1), 0)));
assertThat(byQuarter.get(4), equalTo(new Entry(timestamp(2014, JANUARY, 1), 4964)));
assertThat(byQuarter.get(8), equalTo(new Entry(timestamp(2013, JANUARY, 1), 4975)));
List<Checkmark> byYear = checkmarks.groupBy(YEAR, Calendar.SATURDAY);
List<Entry> byYear = entries.groupBy(YEAR, Calendar.SATURDAY);
assertThat(byYear.size(), equalTo(3)); // from 2013 to 2015
assertThat(byYear.get(0), equalTo(new Checkmark(timestamp(2015, JANUARY, 1), 0)));
assertThat(byYear.get(1), equalTo(new Checkmark(timestamp(2014, JANUARY, 1), 8227)));
assertThat(byYear.get(2), equalTo(new Checkmark(timestamp(2013, JANUARY, 1), 16172)));
assertThat(byYear.get(0), equalTo(new Entry(timestamp(2015, JANUARY, 1), 0)));
assertThat(byYear.get(1), equalTo(new Entry(timestamp(2014, JANUARY, 1), 8227)));
assertThat(byYear.get(2), equalTo(new Entry(timestamp(2013, JANUARY, 1), 16172)));
}
@Test
public void testGetTodayValue() throws Exception
{
Habit habit = fixtures.createLongNumericalHabit(timestamp(2014, JUNE, 1));
CheckmarkList checkmarks = habit.getComputedCheckmarks();
CheckmarkList checkmarks = habit.getComputedEntries();
DateUtils.setFixedLocalTime(unixTime(2050, MAY, 1));
assertThat(checkmarks.getTodayValue(), equalTo(0));

@ -49,8 +49,8 @@ public class HabitTest extends BaseUnitTest
assertThat(habit.hasReminder(), is(false));
assertNotNull(habit.getStreaks());
assertNotNull(habit.getScores());
assertNotNull(habit.getOriginalCheckmarks());
assertNotNull(habit.getComputedCheckmarks());
assertNotNull(habit.getOriginalEntries());
assertNotNull(habit.getComputedEntries());
}
@Test
@ -89,7 +89,7 @@ public class HabitTest extends BaseUnitTest
{
Habit h = modelFactory.buildHabit();
assertFalse(h.isCompletedToday());
h.getOriginalCheckmarks().setValue(getToday(), Checkmark.YES_MANUAL);
h.getOriginalEntries().setValue(getToday(), Entry.YES_MANUAL);
assertTrue(h.isCompletedToday());
}
@ -102,19 +102,19 @@ public class HabitTest extends BaseUnitTest
h.setTargetValue(100.0);
assertFalse(h.isCompletedToday());
h.getOriginalCheckmarks().setValue(getToday(), 200_000);
h.getOriginalEntries().setValue(getToday(), 200_000);
assertTrue(h.isCompletedToday());
h.getOriginalCheckmarks().setValue(getToday(), 100_000);
h.getOriginalEntries().setValue(getToday(), 100_000);
assertTrue(h.isCompletedToday());
h.getOriginalCheckmarks().setValue(getToday(), 50_000);
h.getOriginalEntries().setValue(getToday(), 50_000);
assertFalse(h.isCompletedToday());
h.setTargetType(Habit.AT_MOST);
h.getOriginalCheckmarks().setValue(getToday(), 200_000);
h.getOriginalEntries().setValue(getToday(), 200_000);
assertFalse(h.isCompletedToday());
h.getOriginalCheckmarks().setValue(getToday(), 100_000);
h.getOriginalEntries().setValue(getToday(), 100_000);
assertTrue(h.isCompletedToday());
h.getOriginalCheckmarks().setValue(getToday(), 50_000);
h.getOriginalEntries().setValue(getToday(), 50_000);
assertTrue(h.isCompletedToday());
}

@ -30,7 +30,7 @@ import java.util.*;
import static java.util.Calendar.*;
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.core.IsEqual.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
import static org.mockito.Mockito.*;
public class RepetitionListTest extends BaseUnitTest
@ -54,7 +54,7 @@ public class RepetitionListTest extends BaseUnitTest
{
super.setUp();
habit = fixtures.createEmptyHabit();
reps = habit.getOriginalCheckmarks();
reps = habit.getOriginalEntries();
today = DateUtils.getToday();
@ -79,7 +79,7 @@ public class RepetitionListTest extends BaseUnitTest
@Test
public void test_getOldest()
{
Checkmark check = reps.getOldest();
Entry check = reps.getOldest();
assertThat(check.getTimestamp(), equalTo(today.minus(7)));
}
@ -87,7 +87,7 @@ public class RepetitionListTest extends BaseUnitTest
public void test_getWeekDayFrequency()
{
habit = fixtures.createEmptyHabit();
reps = habit.getOriginalCheckmarks();
reps = habit.getOriginalEntries();
Random random = new Random(123L);
Integer weekdayCount[][] = new Integer[12][7];

@ -30,7 +30,7 @@ import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.core.IsEqual.*;
import static org.hamcrest.number.IsCloseTo.*;
import static org.hamcrest.number.OrderingComparison.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
public class ScoreListTest extends BaseUnitTest
{
@ -326,34 +326,34 @@ public class ScoreListTest extends BaseUnitTest
private void check(final int offset)
{
RepetitionList reps = habit.getOriginalCheckmarks();
RepetitionList entries = habit.getOriginalEntries();
Timestamp today = DateUtils.getToday();
reps.setValue(today.minus(offset), YES_MANUAL);
entries.setValue(today.minus(offset), YES_MANUAL);
}
private void check(final int from, final int to)
{
RepetitionList reps = habit.getOriginalCheckmarks();
RepetitionList entries = habit.getOriginalEntries();
Timestamp today = DateUtils.getToday();
for (int i = from; i < to; i++)
reps.setValue(today.minus(i), YES_MANUAL);
entries.setValue(today.minus(i), YES_MANUAL);
}
private void check(ArrayList<Integer> values)
{
RepetitionList reps = habit.getOriginalCheckmarks();
RepetitionList entries = habit.getOriginalEntries();
Timestamp today = DateUtils.getToday();
for (int i = 0; i < values.size(); i++)
if (values.get(i) == YES_MANUAL)
reps.setValue(today.minus(i), YES_MANUAL);
entries.setValue(today.minus(i), YES_MANUAL);
}
private void addSkip(final int day)
{
RepetitionList reps = habit.getOriginalCheckmarks();
RepetitionList entries = habit.getOriginalEntries();
Timestamp today = DateUtils.getToday();
reps.setValue(today.minus(day), Checkmark.SKIP);
entries.setValue(today.minus(day), Entry.SKIP);
}
private void checkScoreValues(double[] expectedValues)

@ -34,7 +34,7 @@ import java.util.*;
import static junit.framework.TestCase.*;
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.core.IsEqual.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
public class SQLiteRepetitionListTest extends BaseUnitTest
{
@ -60,7 +60,7 @@ public class SQLiteRepetitionListTest extends BaseUnitTest
repository = new Repository<>(RepetitionRecord.class, db);
habit = fixtures.createLongHabit();
originalCheckmarks = habit.getOriginalCheckmarks();
originalCheckmarks = habit.getOriginalEntries();
today = DateUtils.getToday();
}
@ -70,8 +70,8 @@ public class SQLiteRepetitionListTest extends BaseUnitTest
RepetitionRecord record = getByTimestamp(today.plus(1));
assertNull(record);
Checkmark rep = new Checkmark(today.plus(1), YES_MANUAL);
habit.getOriginalCheckmarks().add(rep);
Entry rep = new Entry(today.plus(1), YES_MANUAL);
habit.getOriginalEntries().add(rep);
record = getByTimestamp(today.plus(1));
assertNotNull(record);
@ -81,7 +81,7 @@ public class SQLiteRepetitionListTest extends BaseUnitTest
@Test
public void testGetByInterval()
{
List<Checkmark> checks =
List<Entry> checks =
originalCheckmarks.getByInterval(today.minus(10), today);
assertThat(checks.size(), equalTo(8));
@ -93,7 +93,7 @@ public class SQLiteRepetitionListTest extends BaseUnitTest
@Test
public void testGetByTimestamp()
{
Checkmark rep = originalCheckmarks.getByTimestamp(today);
Entry rep = originalCheckmarks.getByTimestamp(today);
assertNotNull(rep);
assertThat(rep.getTimestamp(), equalTo(today));
@ -104,7 +104,7 @@ public class SQLiteRepetitionListTest extends BaseUnitTest
@Test
public void testGetOldest()
{
Checkmark rep = originalCheckmarks.getOldest();
Entry rep = originalCheckmarks.getOldest();
assertNotNull(rep);
assertThat(rep.getTimestamp(), equalTo(today.minus(120)));
}
@ -113,7 +113,7 @@ public class SQLiteRepetitionListTest extends BaseUnitTest
public void testGetOldest_withEmptyHabit()
{
Habit empty = fixtures.createEmptyHabit();
Checkmark rep = empty.getOriginalCheckmarks().getOldest();
Entry rep = empty.getOriginalEntries().getOldest();
assertNull(rep);
}
@ -123,7 +123,7 @@ public class SQLiteRepetitionListTest extends BaseUnitTest
RepetitionRecord record = getByTimestamp(today);
assertNotNull(record);
Checkmark rep = record.toCheckmark();
Entry rep = record.toCheckmark();
originalCheckmarks.remove(rep);
record = getByTimestamp(today);

@ -33,7 +33,7 @@ public class RepetitionRecordTest extends BaseUnitTest
@Test
public void testRecord() throws Exception
{
Checkmark check = new Checkmark(Timestamp.ZERO.plus(100), 50);
Entry check = new Entry(Timestamp.ZERO.plus(100), 50);
RepetitionRecord record = new RepetitionRecord();
record.copyFrom(check);
assertThat(check, equalTo(record.toCheckmark()));

@ -84,7 +84,7 @@ public class HabitCardListCacheTest extends BaseUnitTest
{
Habit h2 = habitList.getByPosition(2);
Timestamp today = DateUtils.getToday();
commandRunner.execute(new CreateRepetitionCommand(habitList, h2, today, Checkmark.NO), h2.getId());
commandRunner.execute(new CreateRepetitionCommand(habitList, h2, today, Entry.NO), h2.getId());
verify(listener).onItemChanged(2);
verify(listener).onRefreshFinished();
verifyNoMoreInteractions(listener);
@ -105,7 +105,7 @@ public class HabitCardListCacheTest extends BaseUnitTest
Timestamp today = DateUtils.getToday();
int[] actualCheckmarks = cache.getCheckmarks(h.getId());
int[] expectedCheckmarks =
h.getComputedCheckmarks().getValues(today.minus(9), today);
h.getComputedEntries().getValues(today.minus(9), today);
assertThat(actualCheckmarks, equalTo(expectedCheckmarks));
}

@ -86,7 +86,7 @@ public class ListHabitsBehaviorTest extends BaseUnitTest
behavior.onEdit(habit2, DateUtils.getToday());
verify(screen).showNumberPicker(eq(0.1), eq("miles"), picker.capture());
picker.getValue().onNumberPicked(100);
assertThat(habit2.getComputedCheckmarks().getTodayValue(), equalTo(100000));
assertThat(habit2.getComputedEntries().getTodayValue(), equalTo(100000));
}
@Test
@ -173,7 +173,7 @@ public class ListHabitsBehaviorTest extends BaseUnitTest
public void testOnToggle()
{
assertTrue(habit1.isCompletedToday());
behavior.onToggle(habit1, DateUtils.getToday(), Checkmark.NO);
behavior.onToggle(habit1, DateUtils.getToday(), Entry.NO);
assertFalse(habit1.isCompletedToday());
}

@ -28,7 +28,7 @@ import org.junit.*;
import java.util.*;
import static org.isoron.uhabits.core.models.Checkmark.*;
import static org.isoron.uhabits.core.models.Entry.*;
import static org.mockito.Mockito.*;
public class WidgetBehaviorTest extends BaseUnitTest
@ -88,10 +88,10 @@ public class WidgetBehaviorTest extends BaseUnitTest
when(preferences.isSkipEnabled()).thenReturn(skipEnabled);
int nextValue;
if(skipEnabled) nextValue = Checkmark.Companion.nextToggleValueWithSkip(currentValue);
else nextValue = Checkmark.Companion.nextToggleValueWithoutSkip(currentValue);
if(skipEnabled) nextValue = Entry.Companion.nextToggleValueWithSkip(currentValue);
else nextValue = Entry.Companion.nextToggleValueWithoutSkip(currentValue);
habit.getOriginalCheckmarks().setValue(timestamp, currentValue);
habit.getOriginalEntries().setValue(timestamp, currentValue);
behavior.onToggleRepetition(habit, timestamp);
verify(preferences).isSkipEnabled();
verify(commandRunner).execute(
@ -106,7 +106,7 @@ public class WidgetBehaviorTest extends BaseUnitTest
public void testOnIncrement()
{
habit = fixtures.createNumericalHabit();
habit.getOriginalCheckmarks().setValue(timestamp, 500);
habit.getOriginalEntries().setValue(timestamp, 500);
behavior.onIncrement(habit, timestamp, 100);
verify(commandRunner).execute(
@ -120,7 +120,7 @@ public class WidgetBehaviorTest extends BaseUnitTest
public void testOnDecrement()
{
habit = fixtures.createNumericalHabit();
habit.getOriginalCheckmarks().setValue(timestamp, 500);
habit.getOriginalEntries().setValue(timestamp, 500);
behavior.onDecrement(habit, timestamp, 100);
verify(commandRunner).execute(

Loading…
Cancel
Save