mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-15 13:38:52 -06:00
Add Habits to groups without displaying
This commit is contained in:
@@ -132,6 +132,7 @@ data class Habit(
|
||||
this.type = other.type
|
||||
this.unit = other.unit
|
||||
this.uuid = other.uuid
|
||||
this.parent = other.parent
|
||||
this.parentID = other.parentID
|
||||
this.parentUUID = other.parentUUID
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ data class HabitGroup(
|
||||
) {
|
||||
init {
|
||||
if (uuid == null) this.uuid = UUID.randomUUID().toString().replace("-", "")
|
||||
habitList.groupUUID = this.uuid
|
||||
}
|
||||
|
||||
var observable = ModelObservable()
|
||||
@@ -77,6 +78,7 @@ data class HabitGroup(
|
||||
this.question = other.question
|
||||
this.reminder = other.reminder
|
||||
this.uuid = other.uuid
|
||||
this.habitList.groupUUID = this.uuid
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
|
||||
@@ -34,6 +34,8 @@ abstract class HabitList : Iterable<Habit> {
|
||||
@JvmField
|
||||
protected val filter: HabitMatcher
|
||||
|
||||
var groupUUID: String? = null
|
||||
|
||||
/**
|
||||
* Creates a new HabitList.
|
||||
*
|
||||
|
||||
@@ -22,8 +22,6 @@ import org.isoron.uhabits.core.models.Habit
|
||||
import org.isoron.uhabits.core.models.HabitList
|
||||
import org.isoron.uhabits.core.models.HabitMatcher
|
||||
import org.isoron.uhabits.core.utils.DateUtils.Companion.getTodayWithOffset
|
||||
import java.util.ArrayList
|
||||
import java.util.Comparator
|
||||
import java.util.LinkedList
|
||||
import java.util.Objects
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ class SQLiteHabitList @Inject constructor(private val modelFactory: ModelFactory
|
||||
private fun loadRecords() {
|
||||
if (loaded) return
|
||||
loaded = true
|
||||
list.groupUUID = this.groupUUID
|
||||
list.removeAll()
|
||||
val records = repository.findAll("order by position")
|
||||
var shouldRebuildOrder = false
|
||||
@@ -45,7 +46,7 @@ class SQLiteHabitList @Inject constructor(private val modelFactory: ModelFactory
|
||||
val h = modelFactory.buildHabit()
|
||||
rec.copyTo(h)
|
||||
(h.originalEntries as SQLiteEntryList).habitId = h.id
|
||||
list.add(h)
|
||||
if (h.parentUUID == list.groupUUID) list.add(h)
|
||||
}
|
||||
if (shouldRebuildOrder) rebuildOrder()
|
||||
}
|
||||
|
||||
@@ -476,7 +476,7 @@ class HabitCardListCache @Inject constructor(
|
||||
logger.error("performMove: $fromPosition for habit group is out of bounds")
|
||||
return
|
||||
}
|
||||
data.habitGroups.removeAt(fromPosition)
|
||||
data.habitGroups.removeAt(fromPosition - data.habits.size)
|
||||
|
||||
// Workaround for https://github.com/iSoron/uhabits/issues/968
|
||||
val checkedToPosition = if (toPosition < data.habits.size) {
|
||||
|
||||
@@ -33,8 +33,8 @@ class ListHabitsMenuBehavior @Inject constructor(
|
||||
private var showCompleted: Boolean
|
||||
private var showArchived: Boolean
|
||||
|
||||
fun onCreateHabit() {
|
||||
screen.showSelectHabitTypeDialog()
|
||||
fun onCreateHabit(parentUUID: String? = null) {
|
||||
screen.showSelectHabitTypeDialog(parentUUID)
|
||||
}
|
||||
|
||||
fun onViewFAQ() {
|
||||
@@ -132,7 +132,7 @@ class ListHabitsMenuBehavior @Inject constructor(
|
||||
fun showAboutScreen()
|
||||
fun showFAQScreen()
|
||||
fun showSettingsScreen()
|
||||
fun showSelectHabitTypeDialog()
|
||||
fun showSelectHabitTypeDialog(parentUUID: String? = null)
|
||||
}
|
||||
|
||||
init {
|
||||
|
||||
Reference in New Issue
Block a user