|
|
@ -59,6 +59,9 @@ public class Habit extends Model
|
|
|
|
@Column(name = "highlight")
|
|
|
|
@Column(name = "highlight")
|
|
|
|
public Integer highlight;
|
|
|
|
public Integer highlight;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Column(name = "archived")
|
|
|
|
|
|
|
|
public Integer archived;
|
|
|
|
|
|
|
|
|
|
|
|
public Habit(Habit model)
|
|
|
|
public Habit(Habit model)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
copyAttributes(model);
|
|
|
|
copyAttributes(model);
|
|
|
@ -69,6 +72,7 @@ public class Habit extends Model
|
|
|
|
this.color = ColorHelper.palette[7];
|
|
|
|
this.color = ColorHelper.palette[7];
|
|
|
|
this.position = Habit.getCount();
|
|
|
|
this.position = Habit.getCount();
|
|
|
|
this.highlight = 0;
|
|
|
|
this.highlight = 0;
|
|
|
|
|
|
|
|
this.archived = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static Habit get(Long id)
|
|
|
|
public static Habit get(Long id)
|
|
|
@ -84,7 +88,7 @@ public class Habit extends Model
|
|
|
|
|
|
|
|
|
|
|
|
protected static From select()
|
|
|
|
protected static From select()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return new Select().from(Habit.class).orderBy("position");
|
|
|
|
return new Select().from(Habit.class).where("archived = 0").orderBy("position");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static int getCount()
|
|
|
|
public static int getCount()
|
|
|
@ -178,7 +182,6 @@ public class Habit extends Model
|
|
|
|
this.highlight = model.highlight;
|
|
|
|
this.highlight = model.highlight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void save(Long id)
|
|
|
|
public void save(Long id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
save();
|
|
|
|
save();
|
|
|
@ -282,6 +285,18 @@ public class Habit extends Model
|
|
|
|
deleteScoresNewerThan(timestamp);
|
|
|
|
deleteScoresNewerThan(timestamp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void archive()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
archived = 1;
|
|
|
|
|
|
|
|
save();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void unarchive()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
archived = 0;
|
|
|
|
|
|
|
|
save();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void toggleRepetitionToday()
|
|
|
|
public void toggleRepetitionToday()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
toggleRepetition(DateHelper.getStartOfToday());
|
|
|
|
toggleRepetition(DateHelper.getStartOfToday());
|
|
|
@ -552,4 +567,31 @@ public class Habit extends Model
|
|
|
|
execute();
|
|
|
|
execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class ArchiveCommand extends Command
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void execute()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
archive();
|
|
|
|
|
|
|
|
Habit.rebuildOrder();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void undo()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
unarchive();
|
|
|
|
|
|
|
|
Habit.rebuildOrder();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Integer getExecuteStringId()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return R.string.toast_habit_archived;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Integer getUndoStringId()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return R.string.toast_habit_unarchived;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|