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

feat(browse): more than 2 columns #17781

Merged
merged 8 commits into from
Jan 21, 2025

Conversation

david-allison
Copy link
Member

@david-allison david-allison commented Jan 9, 2025

Purpose / Description

Anki Desktop allows more than 2 columns in the Browse screen. Let's do the same for AnkiDroid

Fixes

⚠️ This changes the default columns, I believe to match AnkiMobile

Approach

  • Remove 'column1' and 'column2' and instead use 'availableColumns'
  • Replace column spinners with TextViews, to allow more horizontal space
  • Either modify columns from the settings, or long press a header to open the options item
  • Add a settings screen
  • Move from a 'processing' popup to a LinearProgressBar

The settings screen allows a user to reorder and 'select' usable columns

A full-screen dialog fragment with two headings: 'displayed' & 'available'
Headings are implemented as RecyclerView items, so dragging feels natural. Headings may not be dragged.

It has two primary functions:

  • Drag to reorder
  • +/- to quickly add/remove from 'displayed'

A 'preview' is obtained from the first row of the Browse window. If there are no rows, there is no preview

How Has This Been Tested?

Unit tested, and tested on an API 32 emulator

Screenshot 2025-01-09 at 20 28 34 Screenshot 2025-01-09 at 20 28 21 Screenshot 2025-01-08 at 23 32 41 Screenshot 2025-01-09 at 21 13 36 Screenshot 2025-01-09 at 21 13 46

Checklist

  • 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

@david-allison david-allison added Anki Ecosystem Compatibility Blocked by dependency Currently blocked by some other dependent / related change labels Jan 9, 2025
Copy link
Contributor

github-actions bot commented Jan 9, 2025

Important

Maintainers: This PR contains Strings changes

  1. Sync Translations before merging this PR and wait for the action to complete
  2. Review and merge the auto-generated PR in order to sync all user-submitted translations
  3. Sync Translations again and merge the PR so the huge automated string changes caused by merging this PR are by themselves and easy to review

@david-allison

This comment was marked as resolved.

@david-allison david-allison force-pushed the card-browser-column branch 3 times, most recently from cc173fb to a072fbc Compare January 10, 2025 00:16
@david-allison david-allison force-pushed the card-browser-column branch 2 times, most recently from 7e1bf25 to 54a640a Compare January 11, 2025 22:14
@david-allison

This comment was marked as outdated.

@david-allison david-allison added Needs Review and removed Blocked by dependency Currently blocked by some other dependent / related change Has Conflicts labels Jan 11, 2025
BrayanDSO

This comment was marked as resolved.

@BrayanDSO BrayanDSO added Needs Author Reply Waiting for a reply from the original author and removed Needs Review labels Jan 12, 2025
@david-allison david-allison force-pushed the card-browser-column branch 3 times, most recently from 4a968f2 to 5676b32 Compare January 13, 2025 03:24
@david-allison
Copy link
Member Author

david-allison commented Jan 13, 2025

Thanks for getting to this! I've moved to layouts and removed the 'disabled' status for the checkmark

There's more to do with in-IDE layout previews (low priority. On me)

Fixed: animations

Also, leaving the columns selection fragment seems "abrupt", as there is no animation after leaving it (after all, it is just a Fragment being cleared of the backstack with no transition)

Help Wanted Requesting Pull Requests from volunteers . the following line blocks the fade animation:

// fullscreen material dialog
setStyle(STYLE_NORMAL, com.google.android.material.R.style.MaterialAlertDialog_Material3)

@david-allison david-allison added Help Wanted Requesting Pull Requests from volunteers and removed Needs Author Reply Waiting for a reply from the original author labels Jan 13, 2025
@david-allison david-allison force-pushed the card-browser-column branch 3 times, most recently from 651e63e to b01dba5 Compare January 13, 2025 23:21
This should use the main view if available
Prep for a variable column count

* replace `setColumn1(` with `setColumn(0, `

Issue 17780
@david-allison david-allison force-pushed the card-browser-column branch 2 times, most recently from 21946d8 to 9141054 Compare January 20, 2025 17:51
@david-allison
Copy link
Member Author

david-allison commented Jan 20, 2025

I've also improved the onBackPressedDispatcher work, due to learnings from #17826

Using ComponentDialog.onBackPressedDispatcher

We introduce BrowserColumnSelectionFragment: a full screen
dialog which allows a user to select and reorder the available
columns in the Browse window

There are two headings: 'active' & 'available'
Headings are implemented as RecyclerView items, so dragging
feels natural. Headings may not be dragged.

It has two primary functions:
* Drag to reorder
* +/- to quickly add/remove from 'active'

A 'preview' is obtained from the first row of the Browse window
If there are no rows, there is no preview

Issue 17780
A user can long press the column headings
or edit them from the options to add/remove multiple columns

Issue 17780
If a user is editing options and changes 'cards/notes'
then they should be editing columns for their provided selection

If a user saves columns, then reverts the switch, columns
should not be updated

Issue 17780
Added bonus:
This means we can remove 'initCompleted' and don't need
to handle flow re-subscription if the user moves from dark
to light mode

Fixes a bug in the Columns where the preview didn't remain
if switching dark/light mode

* make searchForCards non-blocking
* stop refreshing searches unconditionally on state restore
* cards.reset() is no longer needed
* onCleared is no longer needed:
  * It's called when the theme changes, and we didn't actually
want this, as we wanted to persist the rows in the ViewModel
* After a collection change, `setActiveBrowserColumns` is reset
* After a language change, column headers need to be updated

Due to the language change, the activity goes through `onCreate`,
so pick up this change on `onRestoreInstanceState`

This was a good opportunity to decouple the column data and the column
headings in the View

Fixes 17803
Fixes 17367
Copy link
Member

@lukstbit lukstbit left a comment

Choose a reason for hiding this comment

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

Still LGTM, even better with the extension on the Dialog.

@lukstbit
Copy link
Member

Did a strings sync in

I'm out for now but will merge if not already done when I come back.

@david-allison
Copy link
Member Author

david-allison commented Jan 21, 2025

Over the moon that we got this in before 2.21. Thank you both!!

@david-allison david-allison added this pull request to the merge queue Jan 21, 2025
Merged via the queue into ankidroid:main with commit 3ea835e Jan 21, 2025
9 checks passed
@github-actions github-actions bot added this to the 2.21 release milestone Jan 21, 2025
Copy link
Contributor

Maintainers: Please Sync Translations to produce a commit with only the automated changes from this PR.

Read more about updating strings on the wiki,

@github-actions github-actions bot removed Pending Merge Things with approval that are waiting future merge (e.g. targets a future release, CI wait, etc) Review High Priority Request for high priority review labels Jan 21, 2025
@mikehardy
Copy link
Member

Ooooo smells like new alpha time :-)

@david-allison david-allison deleted the card-browser-column branch January 27, 2025 20:50
@snowtimeglass
Copy link
Contributor

snowtimeglass commented Jan 28, 2025

Thanks for these great works!

Has the following change been withdrawn?

This has been updated to no longer show vertical dividers between the columns:

image
Originally posted by @david-allison in #17781 (comment)

(I skimmed through this PR page some times, but unfortunately could not find out what happened about it.)

@david-allison
Copy link
Member Author

It was. I marked the comment as outdated, but should have communicated more. Apologies!

I felt that this PR would already be a huge change to get in, and didn't want to change functionality, especially if it would act as a rationale to drag out the review.

I figured it would be faster to do it in two PRs, and it's a trivial change now the PR is in.

Needs a little discussion, I'm pretty ambivalent but happy to implement it

@snowtimeglass
Copy link
Contributor

snowtimeglass commented Jan 28, 2025

Thank you for the clarification! I understand.

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