Skip to content

feat(deck-picker): draw tree hierarchy branch lines#21373

Open
ShaanNarendran wants to merge 1 commit into
ankidroid:mainfrom
ShaanNarendran:feat/deck-picker-hierarchy-lines
Open

feat(deck-picker): draw tree hierarchy branch lines#21373
ShaanNarendran wants to merge 1 commit into
ankidroid:mainfrom
ShaanNarendran:feat/deck-picker-hierarchy-lines

Conversation

@ShaanNarendran

@ShaanNarendran ShaanNarendran commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Note

Used Gemini 3.1 Pro to help write the code for the bit mask approach (horrible at math, so this was an experiment). All comments are my own, tested completely with the emulator and with a very large deck.

Purpose / Description

Draws hierarchy lines for the new deck picker redesign.

Fixes

  • For GSoC 2026: Redesign Deck Picker

Approach

We use a bit mask approach since looping through every row to draw all the lines is very inefficient, I've tried to comment it as much as possible with examples so that should explain the approach.

How Has This Been Tested?

Screen_recording_20260714_231431.webm

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

@ShaanNarendran
ShaanNarendran force-pushed the feat/deck-picker-hierarchy-lines branch 2 times, most recently from bc3f433 to 9694199 Compare July 15, 2026 16:26
@ShaanNarendran ShaanNarendran added the GSoC Pull requests authored by a Google Summer of Code participant [Candidate/Selected], for GSoC mentors label Jul 15, 2026

@BrayanDSO BrayanDSO left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Screenshot tests would help

Comment thread AnkiDroid/src/main/java/com/ichi2/anki/widgets/DeckAdapter.kt Outdated

/**
* Whether to highlight the selected deck. Usually true for fragmented (tablet) layouts
* where the deck contents are shown side-by-side, but false for phones.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the selected deck is highlighted in phones as well. What do you mean here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Whenever I highlighted a deck during testing, it stayed highlighted even after I finished tapping it. I could probably word the comment better, and put that in a separate commit. I'm not sure if that was an issue only on my local but thought I'd put a fix in here.

Comment thread AnkiDroid/src/main/java/com/ichi2/anki/widgets/DeckAdapter.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/anki/widgets/DeckHierarchyLinesDecoration.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/anki/widgets/DeckHierarchyLinesDecoration.kt Outdated
@BrayanDSO BrayanDSO added Needs Author Reply Waiting for a reply from the original author and removed Needs Review labels Jul 15, 2026
@ShaanNarendran

Copy link
Copy Markdown
Contributor Author

Screenshot test would help

Do I just have to add screenshots of the page into the PR?

@ZornHadNoChoice

Copy link
Copy Markdown
Collaborator

A few suggestions:

  • The lines shouldn't break when collapsing/expanding decks.
  • I think it'd look better if the "tips" were longer.
  • Maybe "connect" the lines to the arrows or put circles around the arrows.

@BrayanDSO

Copy link
Copy Markdown
Member

Do I just have to add screenshots of the page into the PR?

We use the Roborazzi library for automated screenshot unit tests. Check the inheritors of ScreenshotTest in AnkiDroid's repository for examples

@ShaanNarendran

ShaanNarendran commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

A few suggestions:

  • The lines shouldn't break when collapsing/expanding decks.

I'm not sure if this is possible without making it too inefficient for large decks, will try this out.

  • I think it'd look better if the "tips" were longer.

I had a similar thought but I could never get it to look visually "uncluttered", can send some mocks once the rest of the code is perfected but I like what we have now.

  • Maybe "connect" the lines to the arrows or put circles around the arrows.

@david-allison would love your thoughts here, do we go with lines connected to the chevron or not?

@ShaanNarendran
ShaanNarendran force-pushed the feat/deck-picker-hierarchy-lines branch 5 times, most recently from f5c5df0 to 9a68a5f Compare July 16, 2026 17:35
@ZornHadNoChoice

This comment was marked as resolved.

@ShaanNarendran
ShaanNarendran force-pushed the feat/deck-picker-hierarchy-lines branch from 9a68a5f to 6261296 Compare July 16, 2026 17:39
@ShaanNarendran

Copy link
Copy Markdown
Contributor Author

Nitpick: the horizontal tips overlap the vertical lines creating a darker color.

I've tried a lot to avoid this but it's always come out wrong, may have to be a small quirk of the lines. It doesn't seem too noticeable to me, but ill still try and fix this while I finish the pr up tomorrow!

@david-allison

Copy link
Copy Markdown
Member

Outside the transition states, looks great!

Pausing on the video provides unusual output

Screenshot_20260716-191337.png

I'd go slowly through this and validate the animations are doing as you'd expect, both expansion and contraction of the decks, and drawing of the lines themselves

@david-allison

david-allison commented Jul 16, 2026

Copy link
Copy Markdown
Member

I'm happy with the lines not connected to the chevron, but I feel the "dead zone" should be a few pixels smaller, in my screenshot it's hard to see the the horizontal line towards "blog"

@ShaanNarendran
ShaanNarendran force-pushed the feat/deck-picker-hierarchy-lines branch 3 times, most recently from b5e70a0 to 005f886 Compare July 17, 2026 02:13
@sanjaysargam

Copy link
Copy Markdown
Member

Nitpick: the horizontal tips overlap the vertical lines creating a darker color.

I've tried a lot to avoid this but it's always come out wrong, may have to be a small quirk of the lines. It doesn't seem too noticeable to me, but ill still try and fix this while I finish the pr up tomorrow!

@ShaanNarendran try this : draw vertical lines as two segments with a gap at the horizontal tip position, or use a single Path that outlines the entire corner shape without overlap

Comment thread AnkiDroid/src/main/java/com/ichi2/anki/widgets/DeckAdapter.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/anki/widgets/DeckHierarchyLinesDecoration.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/anki/widgets/DeckHierarchyLinesDecoration.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/anki/widgets/DeckHierarchyLinesDecoration.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/anki/widgets/DeckHierarchyLinesDecoration.kt Outdated
Comment thread AnkiDroid/src/main/java/com/ichi2/anki/widgets/DeckHierarchyLinesDecoration.kt Outdated
val childCount = parent.childCount
if (childCount == 0) return

val currentList = (parent.adapter as? DeckAdapter)?.currentList ?: return

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

MAJOR BLOCKER:
When DeckAdapter.submitList() is called while onDrawOver is executing, we may observe list in partially updated state which could lead to IndexOutOfBoundsException or can crash during scroll or adapter updates on large nested decks
It can be fix using RecyclerView.AdapterDataObserver or a callback from the adapter when the list changes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added null safety when we are looping so if there is an issue of a race condition it should just skip instead of crashing, would this work or should I go for the approach you mentioned?

@ShaanNarendran
ShaanNarendran force-pushed the feat/deck-picker-hierarchy-lines branch from 005f886 to 77deec3 Compare July 17, 2026 12:37
@ShaanNarendran
ShaanNarendran force-pushed the feat/deck-picker-hierarchy-lines branch from 77deec3 to e6e9411 Compare July 17, 2026 12:49
@ShaanNarendran

Copy link
Copy Markdown
Contributor Author
Screen_recording_20260717_192949.webm

Just an update on how it's going with incorporating all the feedback, I think it looks and feels much better now and I would love to get some more opinions

@ShaanNarendran
ShaanNarendran force-pushed the feat/deck-picker-hierarchy-lines branch from 6064cd5 to de3823e Compare July 17, 2026 14:41
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Snapshot diff report vs main. Open screenshot-diff for diffs.

  • DeckPickerScreenshotTest: 4 changes
All 4 changed screenshots

DeckPickerScreenshotTest

  • hierarchy_lines_collapsed_compare.png
  • hierarchy_lines_compare.png
  • hierarchy_lines_deep_nesting_compare.png
  • hierarchy_lines_many_siblings_compare.png

@ShaanNarendran
ShaanNarendran force-pushed the feat/deck-picker-hierarchy-lines branch from de3823e to cb32a6d Compare July 17, 2026 14:52
sanjaysargam
sanjaysargam approved these changes Jul 18, 2026
@ShaanNarendran
ShaanNarendran force-pushed the feat/deck-picker-hierarchy-lines branch from cb32a6d to a7c9a77 Compare July 18, 2026 16:44
@sanjaysargam sanjaysargam added Needs Second Approval Has one approval, one more approval to merge and removed Needs Author Reply Waiting for a reply from the original author labels Jul 18, 2026
@ZornHadNoChoice

Copy link
Copy Markdown
Collaborator

There are still a few issues and nitpicks which I hope that you can fix:

Expanding a deck

The lines appear first then the decks move then the subdecks fade in. This causes a grid-like mess for a moment. I suggest that the lines fade in with the subdecks after the decks have moved.

ResizedImage_2026-07-19_10-59-53_8096

Collapsing a deck

The lines disappear instantly instead of fading out with the subdecks.

ResizedImage_2026-07-19_10-56-56_3410

Lines disappear when decks are too far

This feels unintentional and it's definitely confusing. Below, you can see the left two lines disappear after expanding a subdeck.

ResizedImage_2026-07-19_11-02-35_1255

Arrows and lines

It's great that you managed to remove the dark bits and made the arrows longer. However:

  • The lines are almost connected to the arrows horizontally. It should either have a noticable gap (but shorter than in the original recording) as David said, or be connected completely as I said.
  • The vertical gap is much larger than the horizontal one.

Here's a comparison between current, what I suggest, and my interpretation of what David suggested:

ResizedImage_2026-07-19_11-40-25_4602

@ShaanNarendran
ShaanNarendran force-pushed the feat/deck-picker-hierarchy-lines branch from a7c9a77 to 14ce977 Compare July 19, 2026 09:34
@ShaanNarendran

Copy link
Copy Markdown
Contributor Author

@ZornHadNoChoice Thank you so much for the in-depth review! I had most of this sitting as changes and I was just waiting for any other feedback to push it out, I think everything should be much cleaner now. The design is probably always going to be subjective, but I'm happy with this and hopefully it looks good.
Screen_recording_20260719_150610.webm

@ZornHadNoChoice

Copy link
Copy Markdown
Collaborator

No, thank you for your patience with my nitpicks!

Speaking of which (haha): when expanding decks, the fade in effect doesn't apply to the little vertical bar under the arrow.

Screenshot_2026-07-19-12-57-02-726_deckers thibault aves libre-edit

@ShaanNarendran
ShaanNarendran force-pushed the feat/deck-picker-hierarchy-lines branch 14 times, most recently from 2a4fe9b to 472ea21 Compare July 22, 2026 13:02
@ShaanNarendran
ShaanNarendran force-pushed the feat/deck-picker-hierarchy-lines branch from 472ea21 to 4b8b16a Compare July 22, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GSoC Pull requests authored by a Google Summer of Code participant [Candidate/Selected], for GSoC mentors Needs Second Approval Has one approval, one more approval to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants