Skip to content

Reorderable exercises in routines and workouts#25

Open
dpusceddu wants to merge 10 commits intoLibreFitOrg:mainfrom
dpusceddu:reorder-edit-exercises
Open

Reorderable exercises in routines and workouts#25
dpusceddu wants to merge 10 commits intoLibreFitOrg:mainfrom
dpusceddu:reorder-edit-exercises

Conversation

@dpusceddu
Copy link
Copy Markdown

Adds a drag handle to reorder exercises around by dragging them up or down.
Used https://github.com/Calvin-LL/Reorderable as #4 pointed at.
Had to change the database schema to include the position of the exercise in the routine / workout, as previous behavior relied just on the original insert order upon creation of the routine / workout

Copy link
Copy Markdown
Member

@IamDg IamDg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dpusceddu,

I'm really impressed by your implementation—you've done as well as possible. I just tried the debug APK and it works like a charm. Majestic job!

Now, I'll list the refinements that should take little time and will make this PR perfect:

  1. Add AnimatedVisibility to ExerciseCard.kt so the card shortens when the user begins to drag. This will provide better visual feedback for reordering.
  2. Include haptic feedback during drag movement of the exercises in the list.
  3. In AppDatabase.kt, Gradle warns The corresponding parameter in the supertype ‘Migration’ is named ‘db’. This may cause problems when calling this function with named arguments. so renaming the parameter to db should fix it.
  4. It looks like CI failed due to a false positive from Room. Fix it by updating the lint-baseline.xml with ./gradlew updateLintBaseline and committing the updated file.

Comment thread app/src/main/java/org/librefit/ui/components/ExerciseCard.kt
Comment thread app/src/main/java/org/librefit/ui/screens/workout/WorkoutScreen.kt
Comment thread app/src/main/java/org/librefit/db/AppDatabase.kt Outdated
@dpusceddu
Copy link
Copy Markdown
Author

Thanks for the feedback 🌟
For comment number 1: I made all cards collapse during dragging of any one of them, do you like it? The 2nd last commit is for collapsing just one card on the other hand

@IamDg
Copy link
Copy Markdown
Member

IamDg commented Apr 18, 2026

Oh, yeah. I meant all cards, so the current version is correct (it makes reordering easier). I took a look at the debug APK and it looks awesome! Keep up the good work!

Edit: After further testing, I noticed reordering is a little bit messy when dragging a card from the middle or the bottom of the list. What could be the cause?

@dpusceddu
Copy link
Copy Markdown
Author

dpusceddu commented Apr 18, 2026

I have the impression that it's caused by the drag handle changing position by a lot due to the resizing of the cards around, and so the finger and what you're actually dragging become very distanced. So with the one on top nothing bad happens because the drag handle remains in the same spot. Right now I dunno how to fix this with the currently used APIs, but in my mind I think a good solution would be to make the currently dragged card "float" instead of remaining fixed in the list, that way the position of what you're dragging coincides with the position of your finger

@IamDg
Copy link
Copy Markdown
Member

IamDg commented Apr 19, 2026

I had an idea: since there will be more options in the exercise card (e.g., replace, superset), the solution (and workaround) would be to use the new expressive DropdownMenuGroup instead. Once the user clicks "reorder," all cards collapse and the handle appears. This approach could be a workable solution. Let me know what you think!

@IamDg IamDg mentioned this pull request Apr 20, 2026
3 tasks
@IamDg IamDg added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers and removed help wanted Extra attention is needed labels Apr 20, 2026
@IamDg
Copy link
Copy Markdown
Member

IamDg commented Apr 21, 2026

Hi @dpusceddu,

I've implemented as suggested in previous comment and it looks and works well so I'm confident to merge this. Let me know what you think about it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants