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

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

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

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

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

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

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

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

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

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

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

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

@ -40,7 +40,7 @@ import java.text.*;
import java.util.*; import java.util.*;
import static org.isoron.uhabits.utils.InterfaceUtils.*; 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 public class HistoryChart extends ScrollableChart
{ {
@ -158,12 +158,12 @@ public class HistoryChart extends ScrollableChart
if (offset < checkmarks.length) if (offset < checkmarks.length)
{ {
if(skipsEnabled) if(skipsEnabled)
newValue = Checkmark.Companion.nextToggleValueWithSkip(checkmarks[offset]); newValue = Entry.Companion.nextToggleValueWithSkip(checkmarks[offset]);
else else
newValue = Checkmark.Companion.nextToggleValueWithoutSkip(checkmarks[offset]); newValue = Entry.Companion.nextToggleValueWithoutSkip(checkmarks[offset]);
} }
onToggleCheckmarkListener.onToggleCheckmark(timestamp, newValue); onToggleCheckmarkListener.onToggleEntry(timestamp, newValue);
postInvalidate(); postInvalidate();
return true; return true;
@ -187,7 +187,7 @@ public class HistoryChart extends ScrollableChart
} }
} }
public void setCheckmarks(int[] checkmarks) public void setEntries(int[] checkmarks)
{ {
this.checkmarks = checkmarks; this.checkmarks = checkmarks;
postInvalidate(); postInvalidate();
@ -454,7 +454,7 @@ public class HistoryChart extends ScrollableChart
onToggleCheckmarkListener = new OnToggleCheckmarkListener() onToggleCheckmarkListener = new OnToggleCheckmarkListener()
{ {
@Override @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 com.google.auto.factory.*
import org.isoron.uhabits.* import org.isoron.uhabits.*
import org.isoron.uhabits.core.models.* import org.isoron.uhabits.core.models.*
import org.isoron.uhabits.core.models.Checkmark.Companion.NO import org.isoron.uhabits.core.models.Entry.Companion.NO
import org.isoron.uhabits.core.models.Checkmark.Companion.SKIP import org.isoron.uhabits.core.models.Entry.Companion.SKIP
import org.isoron.uhabits.core.models.Checkmark.Companion.UNKNOWN import org.isoron.uhabits.core.models.Entry.Companion.UNKNOWN
import org.isoron.uhabits.core.models.Checkmark.Companion.YES_MANUAL import org.isoron.uhabits.core.models.Entry.Companion.YES_MANUAL
import org.isoron.uhabits.core.preferences.* import org.isoron.uhabits.core.preferences.*
import org.isoron.uhabits.inject.* import org.isoron.uhabits.inject.*
import org.isoron.uhabits.utils.* import org.isoron.uhabits.utils.*
@ -66,9 +66,9 @@ class CheckmarkButtonView(
fun performToggle() { fun performToggle() {
value = if(preferences.isSkipEnabled) { value = if(preferences.isSkipEnabled) {
Checkmark.nextToggleValueWithSkip(value) Entry.nextToggleValueWithSkip(value)
} else { } else {
Checkmark.nextToggleValueWithoutSkip(value) Entry.nextToggleValueWithoutSkip(value)
} }
onToggle(value) onToggle(value)
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS) performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)

@ -22,7 +22,7 @@ package org.isoron.uhabits.activities.habits.list.views
import android.content.* import android.content.*
import com.google.auto.factory.* import com.google.auto.factory.*
import org.isoron.uhabits.core.models.* 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.preferences.*
import org.isoron.uhabits.core.utils.* import org.isoron.uhabits.core.utils.*
import org.isoron.uhabits.inject.* import org.isoron.uhabits.inject.*

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

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

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

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

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

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

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

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

@ -71,7 +71,7 @@ class NumericalCheckmarkWidgetActivity : Activity(), ListHabitsBehavior.NumberPi
val app = this.applicationContext as HabitsApplication val app = this.applicationContext as HabitsApplication
AndroidThemeSwitcher(this, app.component.preferences).apply() AndroidThemeSwitcher(this, app.component.preferences).apply()
val numberPickerFactory = NumberPickerFactory(context) 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, data.habit.unit,
this).show() this).show()
} }

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

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

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

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

@ -30,7 +30,7 @@ import java.util.*;
import javax.inject.*; 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. * Class that imports database files exported by Rewire.
@ -167,7 +167,7 @@ public class RewireDBImporter extends AbstractImporter
GregorianCalendar cal = DateUtils.getStartOfTodayCalendar(); GregorianCalendar cal = DateUtils.getStartOfTodayCalendar();
cal.set(year, month - 1, day); 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()); } while (c.moveToNext());
} }
finally finally

@ -30,7 +30,7 @@ import java.util.*;
import javax.inject.*; 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. * Class that imports data from database files exported by Tickmate.
@ -102,7 +102,7 @@ public class TickmateDBImporter extends AbstractImporter
GregorianCalendar cal = DateUtils.getStartOfTodayCalendar(); GregorianCalendar cal = DateUtils.getStartOfTodayCalendar();
cal.set(year, month, day); cal.set(year, month, day);
habit.getOriginalCheckmarks().setValue(new Timestamp(cal), YES_MANUAL); habit.getOriginalEntries().setValue(new Timestamp(cal), YES_MANUAL);
} while (c.moveToNext()); } while (c.moveToNext());
} }
finally finally

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

@ -18,45 +18,35 @@
*/ */
package org.isoron.uhabits.core.models package org.isoron.uhabits.core.models
/** data class Entry(
* 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(
val timestamp: Timestamp, val timestamp: Timestamp,
val value: Int, val value: Int,
) { ) {
companion object { 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 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 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. * expected to, because of the frequency of the habit.
*/ */
const val YES_AUTO = 1 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. * expected to perform it.
*/ */
const val NO = 0 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 const val UNKNOWN = -1

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

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

@ -27,7 +27,7 @@ import java.io.*;
import java.text.*; import java.text.*;
import java.util.*; 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> public abstract class ScoreList implements Iterable<Score>
{ {
@ -201,9 +201,9 @@ public abstract class ScoreList implements Iterable<Score>
if (newestComputed == null) if (newestComputed == null)
{ {
Checkmark oldestOriginal = habit.getOriginalCheckmarks().getOldest(); Entry oldest = habit.getOriginalEntries().getOldest();
if (oldestOriginal != null) from = if (oldest != null) from =
Timestamp.oldest(from, oldestOriginal.getTimestamp()); Timestamp.oldest(from, oldest.getTimestamp());
forceRecompute(from, to, 0); forceRecompute(from, to, 0);
} }
else else
@ -221,11 +221,11 @@ public abstract class ScoreList implements Iterable<Score>
*/ */
protected void computeAll() protected void computeAll()
{ {
Checkmark oldestRep = habit.getOriginalCheckmarks().getOldest(); Entry oldest = habit.getOriginalEntries().getOldest();
if (oldestRep == null) return; if (oldest == null) return;
Timestamp today = DateUtils.getTodayWithOffset(); 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 numerator = habit.getFrequency().getNumerator();
int denominator = habit.getFrequency().getDenominator(); int denominator = habit.getFrequency().getDenominator();
final double freq = habit.getFrequency().toDouble(); 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 // 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 // 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<>(); 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()) if (habit.isNumerical())
{ {
rollingSum += checkmarkValues[offset]; rollingSum += values[offset];
if (offset + denominator < checkmarkValues.length) { if (offset + denominator < values.length) {
rollingSum -= checkmarkValues[offset + denominator]; rollingSum -= values[offset + denominator];
} }
double percentageCompleted = Math.min(1, rollingSum / 1000 / habit.getTargetValue()); double percentageCompleted = Math.min(1, rollingSum / 1000 / habit.getTargetValue());
previousValue = Score.compute(freq, previousValue, percentageCompleted); previousValue = Score.compute(freq, previousValue, percentageCompleted);
} }
else else
{ {
if (checkmarkValues[offset] == YES_MANUAL) if (values[offset] == YES_MANUAL)
rollingSum += 1.0; rollingSum += 1.0;
if (offset + denominator < checkmarkValues.length) if (offset + denominator < values.length)
if (checkmarkValues[offset + denominator] == YES_MANUAL) if (values[offset + denominator] == YES_MANUAL)
rollingSum -= 1.0; rollingSum -= 1.0;
if (checkmarkValues[offset] != SKIP) if (values[offset] != SKIP)
{ {
double percentageCompleted = Math.min(1, rollingSum / numerator); double percentageCompleted = Math.min(1, rollingSum / numerator);
previousValue = Score.compute(freq, previousValue, percentageCompleted); previousValue = Score.compute(freq, previousValue, percentageCompleted);

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

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

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

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

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

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

@ -25,7 +25,7 @@ import org.isoron.uhabits.core.database.*;
import org.isoron.uhabits.core.models.*; 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") @Table(name = "Repetitions")
public class RepetitionRecord public class RepetitionRecord
@ -44,14 +44,14 @@ public class RepetitionRecord
@Column @Column
public Long id; public Long id;
public void copyFrom(Checkmark checkmark) public void copyFrom(Entry entry)
{ {
timestamp = checkmark.getTimestamp().getUnixTime(); timestamp = entry.getTimestamp().getUnixTime();
value = checkmark.getValue(); 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.models.sqlite.*;
import org.isoron.uhabits.core.utils.*; 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 public class HabitFixtures
{ {
@ -65,7 +65,7 @@ public class HabitFixtures
81, 83, 89, 90, 91, 95, 102, 103, 108, 109, 120}; 81, 83, 89, 90, 91, 95, 102, 103, 108, 109, 120};
for (int mark : marks) for (int mark : marks)
habit.getOriginalCheckmarks().setValue(today.minus(mark), YES_MANUAL); habit.getOriginalEntries().setValue(today.minus(mark), YES_MANUAL);
return habit; return habit;
} }
@ -89,7 +89,7 @@ public class HabitFixtures
for (int i = 0; i < times.length; i++) for (int i = 0; i < times.length; i++)
{ {
Timestamp timestamp = today.minus(times[i]); Timestamp timestamp = today.minus(times[i]);
habit.getOriginalCheckmarks().setValue(timestamp, values[i]); habit.getOriginalEntries().setValue(timestamp, values[i]);
} }
return habit; return habit;
@ -125,7 +125,7 @@ public class HabitFixtures
for (int i = 0; i < times.length; i++) for (int i = 0; i < times.length; i++)
{ {
Timestamp timestamp = reference.minus(times[i]); Timestamp timestamp = reference.minus(times[i]);
habit.getOriginalCheckmarks().setValue(timestamp, values[i]); habit.getOriginalEntries().setValue(timestamp, values[i]);
} }
return habit; return habit;
@ -144,7 +144,7 @@ public class HabitFixtures
{ {
int value = NO; int value = NO;
if (c) value = YES_MANUAL; if (c) value = YES_MANUAL;
habit.getOriginalCheckmarks().setValue(timestamp, value); habit.getOriginalEntries().setValue(timestamp, value);
timestamp = timestamp.minus(1); timestamp = timestamp.minus(1);
} }
@ -153,7 +153,7 @@ public class HabitFixtures
private void saveIfSQLite(Habit habit) private void saveIfSQLite(Habit habit)
{ {
if (!(habit.getOriginalCheckmarks() instanceof SQLiteRepetitionList)) return; if (!(habit.getOriginalEntries() instanceof SQLiteRepetitionList)) return;
habitList.add(habit); habitList.add(habit);
} }
} }

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

@ -22,5 +22,5 @@ package org.isoron.uhabits.core.ui.callbacks
import org.isoron.uhabits.core.models.* import org.isoron.uhabits.core.models.*
interface OnToggleCheckmarkListener { 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.scores.put(id, habit.getScores().getTodayValue());
newData.checkmarks.put( newData.checkmarks.put(
id, id,
habit.getComputedCheckmarks().getValues(dateFrom, dateTo)); habit.getComputedEntries().getValues(dateFrom, dateTo));
runner.publishProgress(this, position); runner.publishProgress(this, position);
} }

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

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

@ -58,14 +58,14 @@ class ShowHabitMenuBehavior(
fun onRandomize() { fun onRandomize() {
val random = Random() val random = Random()
habit.originalCheckmarks.removeAll() habit.originalEntries.removeAll()
var strength = 50.0 var strength = 50.0
for (i in 0 until 365 * 5) { 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 (i % 7 == 0) strength = Math.max(0.0, Math.min(100.0, strength + 10 * random.nextGaussian()))
if (random.nextInt(100) > strength) continue 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 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) habit.invalidateNewerThan(Timestamp.ZERO)
screen.refresh() screen.refresh()

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

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

@ -30,7 +30,7 @@ import java.util.*;
import static junit.framework.TestCase.assertFalse; import static junit.framework.TestCase.assertFalse;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.*; 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.isoron.uhabits.core.models.Frequency.*;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@ -123,7 +123,7 @@ public class ImportTest extends BaseUnitTest
GregorianCalendar date = DateUtils.getStartOfTodayCalendar(); GregorianCalendar date = DateUtils.getStartOfTodayCalendar();
date.set(year, month - 1, day); date.set(year, month - 1, day);
Timestamp timestamp = new Timestamp(date); 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 private void importFromFile(String assetFilename) throws IOException

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

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

@ -30,7 +30,7 @@ import java.util.*;
import static java.util.Calendar.*; import static java.util.Calendar.*;
import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.core.IsEqual.*; 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.*; import static org.mockito.Mockito.*;
public class RepetitionListTest extends BaseUnitTest public class RepetitionListTest extends BaseUnitTest
@ -54,7 +54,7 @@ public class RepetitionListTest extends BaseUnitTest
{ {
super.setUp(); super.setUp();
habit = fixtures.createEmptyHabit(); habit = fixtures.createEmptyHabit();
reps = habit.getOriginalCheckmarks(); reps = habit.getOriginalEntries();
today = DateUtils.getToday(); today = DateUtils.getToday();
@ -79,7 +79,7 @@ public class RepetitionListTest extends BaseUnitTest
@Test @Test
public void test_getOldest() public void test_getOldest()
{ {
Checkmark check = reps.getOldest(); Entry check = reps.getOldest();
assertThat(check.getTimestamp(), equalTo(today.minus(7))); assertThat(check.getTimestamp(), equalTo(today.minus(7)));
} }
@ -87,7 +87,7 @@ public class RepetitionListTest extends BaseUnitTest
public void test_getWeekDayFrequency() public void test_getWeekDayFrequency()
{ {
habit = fixtures.createEmptyHabit(); habit = fixtures.createEmptyHabit();
reps = habit.getOriginalCheckmarks(); reps = habit.getOriginalEntries();
Random random = new Random(123L); Random random = new Random(123L);
Integer weekdayCount[][] = new Integer[12][7]; 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.core.IsEqual.*;
import static org.hamcrest.number.IsCloseTo.*; import static org.hamcrest.number.IsCloseTo.*;
import static org.hamcrest.number.OrderingComparison.*; 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 public class ScoreListTest extends BaseUnitTest
{ {
@ -326,34 +326,34 @@ public class ScoreListTest extends BaseUnitTest
private void check(final int offset) private void check(final int offset)
{ {
RepetitionList reps = habit.getOriginalCheckmarks(); RepetitionList entries = habit.getOriginalEntries();
Timestamp today = DateUtils.getToday(); 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) private void check(final int from, final int to)
{ {
RepetitionList reps = habit.getOriginalCheckmarks(); RepetitionList entries = habit.getOriginalEntries();
Timestamp today = DateUtils.getToday(); Timestamp today = DateUtils.getToday();
for (int i = from; i < to; i++) 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) private void check(ArrayList<Integer> values)
{ {
RepetitionList reps = habit.getOriginalCheckmarks(); RepetitionList entries = habit.getOriginalEntries();
Timestamp today = DateUtils.getToday(); Timestamp today = DateUtils.getToday();
for (int i = 0; i < values.size(); i++) for (int i = 0; i < values.size(); i++)
if (values.get(i) == YES_MANUAL) 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) private void addSkip(final int day)
{ {
RepetitionList reps = habit.getOriginalCheckmarks(); RepetitionList entries = habit.getOriginalEntries();
Timestamp today = DateUtils.getToday(); Timestamp today = DateUtils.getToday();
reps.setValue(today.minus(day), Checkmark.SKIP); entries.setValue(today.minus(day), Entry.SKIP);
} }
private void checkScoreValues(double[] expectedValues) private void checkScoreValues(double[] expectedValues)

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

@ -33,7 +33,7 @@ public class RepetitionRecordTest extends BaseUnitTest
@Test @Test
public void testRecord() throws Exception 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(); RepetitionRecord record = new RepetitionRecord();
record.copyFrom(check); record.copyFrom(check);
assertThat(check, equalTo(record.toCheckmark())); assertThat(check, equalTo(record.toCheckmark()));

@ -84,7 +84,7 @@ public class HabitCardListCacheTest extends BaseUnitTest
{ {
Habit h2 = habitList.getByPosition(2); Habit h2 = habitList.getByPosition(2);
Timestamp today = DateUtils.getToday(); 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).onItemChanged(2);
verify(listener).onRefreshFinished(); verify(listener).onRefreshFinished();
verifyNoMoreInteractions(listener); verifyNoMoreInteractions(listener);
@ -105,7 +105,7 @@ public class HabitCardListCacheTest extends BaseUnitTest
Timestamp today = DateUtils.getToday(); Timestamp today = DateUtils.getToday();
int[] actualCheckmarks = cache.getCheckmarks(h.getId()); int[] actualCheckmarks = cache.getCheckmarks(h.getId());
int[] expectedCheckmarks = int[] expectedCheckmarks =
h.getComputedCheckmarks().getValues(today.minus(9), today); h.getComputedEntries().getValues(today.minus(9), today);
assertThat(actualCheckmarks, equalTo(expectedCheckmarks)); assertThat(actualCheckmarks, equalTo(expectedCheckmarks));
} }

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

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

Loading…
Cancel
Save