Skip to content

Add dictionary auto-sort and batch import#29

Open
leoxs22 wants to merge 3 commits intoyomihon:mainfrom
leoxs22:feature/dictionary-auto-sort-and-batch-import
Open

Add dictionary auto-sort and batch import#29
leoxs22 wants to merge 3 commits intoyomihon:mainfrom
leoxs22:feature/dictionary-auto-sort-and-batch-import

Conversation

@leoxs22
Copy link
Copy Markdown
Contributor

@leoxs22 leoxs22 commented Apr 13, 2026

Summary

  • Auto-sort: Reorders installed dictionaries by a recommended priority based on well-known Yomitan dictionary names (frequency, pitch, monolingual, bilingual, grammar, kanji — for JA, YUE, and ZH). Unrecognised dictionaries keep their relative order at the end. Accessible via an "Auto-sort" button next to the "Installed Dictionaries" header.
  • Batch import: Three new import modes behind a dropdown menu on the existing import button:
    • Import Files — multi-file picker (OpenMultipleDocuments) to select several ZIPs at once
    • Import from Folder — folder picker (OpenDocumentTree) that enumerates and imports all ZIPs in a directory
    • Nested ZIP auto-detection — if a ZIP has no index.json but contains inner .zip entries, each is extracted and imported automatically
  • All batch imports are processed sequentially within a single WorkManager Worker, with per-dict error isolation (duplicates are skipped, failures are logged, remaining dicts continue)
  • Batch progress shown in the UI as "Importing Dictionaries (2 of 5)"

Test plan

  • Select multiple dictionary ZIPs via "Import Files" — all import, duplicates skipped
  • Select a folder with dictionary ZIPs via "Import from Folder" — all enumerate and import
  • Import a ZIP containing multiple dictionary ZIPs (nested) — auto-detects and imports each
  • Import a single ZIP — still works as before
  • Include a duplicate in a batch — skipped without stopping the rest
  • Tap "Auto-sort" with installed dictionaries — reorders by recommended priority
  • Run ./gradlew :domain:test — all tests pass (including 9 new DictionaryAutoSorterTest cases)

🤖 Generated with Claude Code

leoxs22 and others added 3 commits April 12, 2026 12:16
Auto-sort reorders dictionaries by a recommended priority based on
well-known Yomitan dictionary names (frequency, pitch, monolingual,
bilingual, grammar, kanji — for JA, YUE, and ZH). Unrecognised
dictionaries keep their relative order at the end.

Batch import adds three modes behind the existing import button:
- Import Files: multi-file picker (OpenMultipleDocuments)
- Import from Folder: folder picker that enumerates ZIPs via SAF
- Nested ZIP auto-detection: if a ZIP has no index.json, inner .zip
  entries are extracted and each is imported sequentially

Progress is tracked per-batch ("Importing 2 of 5") and failed or
duplicate dictionaries do not block the rest of the batch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
WorkManager chains created by enqueueUniqueWork with APPEND_OR_REPLACE
break when any Worker returns Result.failure() — all remaining Workers
in the chain are cancelled. This caused nested ZIP imports to stop
after the first duplicate/error.

Fix by processing all items inline within a single Worker:
- Nested ZIPs: extract all inner .zip files, import each in a loop
- Multi-file/folder: pass all URIs via KEY_URIS to a single Worker
- Per-dict errors are caught and logged without stopping the batch
- Summary logged at completion (N imported, N skipped, N failed)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant