Skip to content

feat(gallery): Drag to select photos - #3

Merged
fabiocatalao merged 3 commits into
mainfrom
claude/zealous-lamport-4jia5e
Oct 2, 2026
Merged

fabiocatalao merged 3 commits into
mainfrom
claude/zealous-lamport-4jia5e

Conversation

@fabiocatalao

@fabiocatalao fabiocatalao commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Why

In the file list you can long-press and drag to select a range of files. The gallery didn't support this, so selecting many photos meant tapping each one.

What changes

  • Drag to select in the gallery. Long-press a photo and drag. Every photo between the first one and your finger is selected, and dragging back unselects them. Dragging near the top or bottom edge scrolls the gallery.
  • Month headers are skipped. They're rows in the same list as the photos, so a range can cross months without selecting a header.
  • A long press now selects the photo instead of toggling it. The drag listener and the photo both react to the same long press, so a toggle would unselect the photo right after the listener selected it. Tapping still toggles.
  • Thumbnails don't reload while dragging. Selection changes redraw only the checkmark.

Implementation

  • GalleryFragment.setupDragSelection() attaches the existing DragSelectTouchListener (from ui/fileList), set up the same way as FileListFragment.setupDragSelection().
  • GalleryAdapter: isFileSelectableAt() and setFilesSelectedInRange(), which work on adapter positions and skip header rows. Selection goes through the selection model, so a photo is never added to the selected items twice. A payload bind updates only the checkmark.

Sort by date taken: dropped

This PR first added a gallery sort toggle (Date taken / Date modified / Date added). It's reverted in the last commit: /3/drive/{id}/files/search accepts only order_by=last_modified_at or relevance and rejects created_at and added_at with a 422. As a result, the two new options showed only the cached photos and never loaded more. Sorting the whole gallery on the device doesn't scale to large libraries, so the gallery keeps the server's date-modified order.

Verification

  • compileStandardDebugKotlin and testStandardDebugUnitTest pass
  • On a device: drag across rows and month headers, drag back to unselect, auto-scroll at the edges, and check the selection count

🤖 Generated with Claude Code

https://claude.ai/code/session_012mej6ZVyiQ7aAfoRJYT1d4

…r dates

The gallery used to always sort by last modified date, which changes whenever
a photo is copied, restored or edited. It now sorts by the file's creation
date by default, which uploads from Android fill in from the photo's date
taken.

A new toolbar button, left of the period filter, opens a sheet to pick between
date taken, date modified and date added. The choice is persisted, triggers a
reload from the API with the matching order, and section headers use the same
date. The offline cache is re-sorted locally by the chosen date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017EHLLDTsEsyzxGQ8uPBdn2
@fabiocatalao
fabiocatalao marked this pull request as ready for review October 2, 2026 16:17
fabiocatalao and others added 2 commits October 2, 2026 18:44
…t button

Drag to select only existed in the file list. The gallery now uses the same
DragSelectTouchListener, skipping month headers, which share the list with
the photos.

A long press now selects the photo instead of toggling it. The drag
listener reacts to the same long press, so a toggle would unselect the
photo right after the listener selected it. Selection changes redraw only
the checkmark, so thumbnails don't reload while dragging.

The sort button showed a calendar; it now shows a sort icon.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This reverts the sort part of 5f4eafa. The gallery loads through
/3/drive/{id}/files/search, which only accepts order_by=last_modified_at
or relevance. The server rejects added_at and created_at with a 422, so
Date added and Date taken showed only the cached photos and never loaded
more. Sorting the whole gallery on the device doesn't scale to a large
library, so the gallery goes back to the server's date-modified order.

Drag to select from the previous commit is kept. The sort icon goes away
with the button.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012mej6ZVyiQ7aAfoRJYT1d4
@fabiocatalao fabiocatalao changed the title feat(gallery): Sort the gallery by date taken, with a toggle for other dates feat(gallery): Drag to select photos Oct 2, 2026
@fabiocatalao
fabiocatalao merged commit 4a690d5 into main Oct 2, 2026
3 checks passed
@fabiocatalao
fabiocatalao deleted the claude/zealous-lamport-4jia5e branch October 2, 2026 20:52
fabiocatalao added a commit that referenced this pull request Nov 27, 2026
Add drag-to-select support to the gallery by reusing DragSelectTouchListener
from the file list in GalleryFragment and GalleryAdapter:

- Skip month header rows when selecting or deselecting ranges across adapter
  positions.
- Select rather than toggle on long press so the card listener and drag
  listener do not cancel each other out (tapping still toggles).
- Redraw only the checkmark via a selection payload so thumbnails do not
  reload while dragging.

Squashes PR #3 (add sort / drag-to-select + sort icon / revert sort) into
its net drag-to-select diff.
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.

2 participants