Implement option to remove sub habits from groups

This commit is contained in:
Dharanish
2024-07-13 15:44:27 +02:00
parent fc16c7078a
commit d9213ed239
12 changed files with 73 additions and 11 deletions

View File

@@ -300,7 +300,7 @@ class EditHabitActivity : AppCompatActivity() {
habit.unit = binding.unitInput.text.trim().toString()
}
habit.type = habitType
habit.parent = parentGroup
habit.group = parentGroup
habit.groupId = parentGroup?.id
habit.groupUUID = parentGroup?.uuid

View File

@@ -75,12 +75,14 @@ class ListHabitsSelectionMenu @Inject constructor(
val itemColor = menu.findItem(R.id.action_color)
val itemArchive = menu.findItem(R.id.action_archive_habit)
val itemUnarchive = menu.findItem(R.id.action_unarchive_habit)
val itemRemoveFromGroup = menu.findItem(R.id.action_remove_from_group)
val itemNotify = menu.findItem(R.id.action_notify)
itemColor.isVisible = true
itemEdit.isVisible = behavior.canEdit()
itemArchive.isVisible = behavior.canArchive()
itemUnarchive.isVisible = behavior.canUnarchive()
itemRemoveFromGroup.isVisible = behavior.areSubHabits()
itemNotify.isVisible = prefs.isDeveloper
activeActionMode?.title = (listAdapter.selectedHabits.size + listAdapter.selectedHabitGroups.size).toString()
return true
@@ -106,6 +108,11 @@ class ListHabitsSelectionMenu @Inject constructor(
return true
}
R.id.action_remove_from_group -> {
behavior.onRemoveFromGroup()
return true
}
R.id.action_delete -> {
behavior.onDeleteHabits()
return true

View File

@@ -97,7 +97,6 @@ class HabitCardView(
set(value) {
scoreRing.setPercentage(value.toFloat())
scoreRing.setPrecision(1.0f / 16)
// behavior.onChangeScore(habit!!)
}
var unit

View File

@@ -41,6 +41,11 @@
android:title="@string/unarchive"
app:showAsAction="never"/>
<item
android:id="@+id/action_remove_from_group"
android:title="@string/remove_from_group"
app:showAsAction="never"/>
<item
android:id="@+id/action_delete"
android:title="@string/delete"

View File

@@ -29,6 +29,7 @@
<string name="delete">Delete</string>
<string name="archive">Archive</string>
<string name="unarchive">Unarchive</string>
<string name="remove_from_group">Remove from group</string>
<string name="add_habit">Add habit</string>
<string name="color_picker_default_title">Change color</string>
<string name="toast_habit_created">Habit created</string>