Skip to content

feat(deckpicker): improve collection file too large dialog - #22164

Open
Ranjan-3105 wants to merge 3 commits into
ankidroid:mainfrom
Ranjan-3105:fix/large-collection-sync-dialog
Open

Ranjan-3105 wants to merge 3 commits into
ankidroid:mainfrom
Ranjan-3105:fix/large-collection-sync-dialog

Conversation

@Ranjan-3105

Copy link
Copy Markdown

Purpose / Description

When a collection is too large to be uploaded to AnkiWeb, the current sync error doesn't give the user an obvious next step.
This change improves that error dialog by adding a Check Database action. OK remains the primary action, while Check Database is available as a secondary option to help users reduce the collection size.

Fixes

Approach

The backend already returns a specific error message when the collection is too large to upload, so there was no need to add any new size checking on the Android side.
I added handling for this specific sync error and route it to a dedicated dialog. The error message is kept as-is, while the dialog provides OK as the primary action and Check Database as the secondary action.
I followed the existing handling for the clock-off sync error as the pattern for identifying and displaying the specific sync error.

How Has This Been Tested?

I added a unit test covering the large collection sync error and checking that:

  • the original error message is displayed
  • OK is the primary action
  • Check Database is the secondary action
    I also added a Roborazzi screenshot test for the new dialog and generated the corresponding screenshot baseline.
    The relevant tests were run using the PlayDebug test configuration with Robolectric.

Learning (optional, can help others)

While working on this, I traced the sync error from the backend through BackendSyncException to the Android sync error dialog.
I used the existing clock-off sync error handling as a reference for handling a specific backend sync error without changing the generic sync error flow.

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
collection_too_large_dialog

# Conflicts:
#	AnkiDroid/src/main/java/com/ichi2/anki/dialogs/SyncErrorDialog.kt
@welcome

welcome Bot commented Sep 28, 2026

Copy link
Copy Markdown

First PR! 🚀 We sincerely appreciate that you have taken the time to propose a change to AnkiDroid! Please have patience with us as we are all volunteers - we will get to this as soon as possible.

@github-actions

github-actions Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

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

  • CollectionTooLargeScreenshotTest: 1 change
All 1 changed screenshots

CollectionTooLargeScreenshotTest

  • collection_too_large_dialog_compare.png

@david-allison

david-allison commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Why does the screenshot show '(uncompressed) twice?

collection_too_large_dialog_compare

@Ranjan-3105

Copy link
Copy Markdown
Author

Ahhh! The test was passing "150 MB (uncompressed)" to syncUploadTooLarge(), while the string itself already appends (uncompressed). I'll change the test input to "150 MB" and regenerate the screenshot.

@Ranjan-3105

Copy link
Copy Markdown
Author

I've fixed the test inputs to "150 MB" and verified the screenshot.
image

)
assertEquals(
getString(R.string.dialog_ok),
dialog.getButton(DialogInterface.BUTTON_POSITIVE).text,

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.

We should have extensions, such asdialog.positiveButton

dialog.getButton(DialogInterface.BUTTON_POSITIVE).text,
)
assertEquals(
CollectionManager.TR.sentenceCase.checkDatabase,

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.

Import CollectionManager, so this appears as TR.

You can do this within Android Studio

Image

@Test
fun `collection too large dialog`() =
withDeckPicker(deckCount = 0) { deckPicker ->
val message = CollectionManager.TR.syncUploadTooLarge("150 MB (uncompressed)")

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.

ditto with the 'TR'

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Sep 29, 2026

@david-allison david-allison 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.

The comparison fails for: [Catalan, Esperanto, French, Japanese, Odia, Uyghur, Yiddish]
{details} is on the first line.

Could you add a regression test for one of these languages and fix the logic.

@Ranjan-3105

Copy link
Copy Markdown
Author

Hey David, I traced the issue to isCollectionTooLargeException() in Sync.kt. The current logic compares the text before the first newline, but for the languages you mentioned, {details} is on the first line, so the comparison fails.

I’m looking at the cleanest way to fix this and add a regression test for one of those locales. Is there any existing translation/helper pattern in AnkiDroid that you’d prefer me to use for matching translations with arguments, or should I handle the placeholder explicitly here?

@david-allison

Copy link
Copy Markdown
Member

I think this one will be unique. You already made isCollectionTooLargeException, so it's time to test and improve it

@david-allison david-allison removed the Needs Author Reply Waiting for a reply from the original author label Sep 29, 2026

@david-allison david-allison 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.

Romanian still fails

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

improve 'Your collection file is too large'

2 participants