Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature: Allow users to create groups of habits #2020

Draft
wants to merge 51 commits into
base: dev
Choose a base branch
from

Conversation

dharux
Copy link

@dharux dharux commented Jul 14, 2024

Features

  1. Creation of habit groups: There is a third option in the habit type picker, which creates groups
  2. Attributes of habit groups: name, color, question, reminder, notes. These attributes are set in the edit habit screen.
  3. Create new sub-habits into a group: There is a plus button on the right side of the habit group, which adds habits to the group. On tapping it, it opens the habit type picker but without the option of habit groups.
  4. Transfer of existing habits into groups: select the required habits (can also be sub-habits), top on the options button, select "Add to group" and select the desired group
  5. Removal of sub-habits from groups: select the desired sub-habits and select "Remove from group" from the options menu.
  6. Displaying habit groups and sub-habits: All main habits are displayed together at the top, followed by habit groups. The habit group card contains a score ring, name, add button, collapse button. Below the habit group card, are displayed the cards of the habits contained in it. In these cards, the score ring and name are indented a bit to the right to show that they are sub habits.
  7. Collapsing habit groups: On the rightmost of the habit group card is a caret button. Tapping this will collapse the habit group and remove all the sub-habits from display. The caret is rotated 90 deg to indicate this. Tapping again will expand the group.
  8. Displaying a habit group: On tapping on the empty space on a habit group card opens the habit group. If the group is empty, a message is displayed indicating so. If the group does contain any sub-habits, the overview, score and frequency cards are displayed. The score is obtained by simply taking an average of the scores of the individual sub-habits. Frequency of each sub-habit is normalized by their target and then taken an average of. If the group contains only subhabits of only one type, then a history bar card is also displayed. This sums up the entries of all sub-habits. If the sub-habits of the group are all boolean, then a streak card is also displayed. The streaks are calculated as intersections of streaks of all sub-habits. If all sub-habits are instead numerical, then a target card is also displayed. This is calculated by a simple sum of all sub-habits.
  9. Sorting of groups and sub-habits: All standalone habits are displayed at the top and their sorting is unaffected. Sub-habits within groups are sorted with each other and are displayed under their group. The groups themselves can be sorted by all properties, and they reorder accordingly.
  10. Sorting manually: Sub-habits can be dragged and dropped within the group manually. Habit groups can also be dragged and dropped on other habit groups to reorder it.
  11. Habit group score ring: The score ring is updated when a new sub-habit is added, removed, modified or an entry is added to it.
  12. Widgets: The score and frequency widgets are available for habit groups too
  13. Notifications: Reminder notifications are displayed for habit groups as well. Tapping on the notification opens up the habit group. Tapping on the "enter" button opens the main list screen and clears the notification.

Implementation

Will follow soon

To do

  • Moving habit groups manually is a bit buggy and can cause crashes in some instances
  • Testing: unit tests and instrumented test all have to be written for all these features
  • Existing test: The behaviour of the JdbcDatabase is different from that of the AndroidDatabase which results in erroring in the SQLiteHabitListTest giving: "[SQLITE_CONSTRAINT_FOREIGNKEY] A foreign key constraint failed (FOREIGN KEY constraint failed)". This error is not present in when performing the same tasks in the app. I do not understand this difference in databases to be able to fix this problem. (there is a problem in the database handling which cannot handle updating of foreign key values to null. Workaround implemented to solve this.)

Dharanish added 30 commits May 12, 2024 18:31
@hiqua
Copy link
Collaborator

hiqua commented Jul 24, 2024

@iSoron given that this is quite big already, I'm sure this could use a quick review from you to say whether you'd be fine with the general principle or if you already dislike some of this and the overall direction.

@hiqua
Copy link
Collaborator

hiqua commented Jul 24, 2024

@dharux thanks a lot for your contribution! I see you're implementing quite a lot of features already; I'd suggest to keep it as simple as possible, to the extent that it makes sense. Just as an example, handling habit groups in widget could definitely come later, as another PR. This would make the review more manageable, and this PR more likely to be accepted IMHO.

@EDLLT
Copy link

EDLLT commented Oct 20, 2024

@iSoron given that this is quite big already, I'm sure this could use a quick review from you to say whether you'd be fine with the general principle or if you already dislike some of this and the overall direction.

This is such a great PR! It solves a problem I had been facing lately with mixing habits that must have their streaks absolutely never broken with other habits that are more lenient

Is it be possible for me to use this before it's merged?

edit: managed to compile and install it
I have backups in case things go south

@EDLLT
Copy link

EDLLT commented Oct 20, 2024

Hey @dharux
Really appreciate the work that's been done

I found a bug whereby the Habits app crashes when pressing on the "EDIT" button within a habit that's inside a group

Current workaround is to remove the habit from the group, edit it, then place it back in the group

@Timotheusel
Copy link

This looks like a great addition to the app!
I use more then 70 habits, I need grouping :D

@abpolym
Copy link

abpolym commented Dec 23, 2024

Very cool PR! This is exactly what I need 😄 !

What do you think about my comment here?
In your third picture for the study habit group, my suggestion would display a sum of the hours spent on the sub-habits Math and Economics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants