Abstract browser access with BrowserDestinations
[!IMPORTANT] We use this as a reference for discussion, please don't ask to be assigned until something is decided on the approach.
Original comment: https://github.com/ankidroid/Anki-Android/pull/20532#discussion_r2968007120
I was hoping we could slowly move to a Destination-based model
We're likely going to go multi-module to improve build times, and our Destination classes both make the API of the intents clear, and reduce bugs from typos.
I'm ok with this.
The usages that could be refactored and I found with a quick search:
https://github.com/ankidroid/Anki-Android/blob/8d288e88952e10a4bda83a3978f6c463603adf35/AnkiDroid/src/main/java/com/ichi2/anki/NavigationDrawerActivity.kt#L390-L395
https://github.com/ankidroid/Anki-Android/blob/8d288e88952e10a4bda83a3978f6c463603adf35/AnkiDroid/src/main/java/com/ichi2/anki/BackendImporting.kt#L73-L81
https://github.com/ankidroid/Anki-Android/blob/8d288e88952e10a4bda83a3978f6c463603adf35/AnkiDroid/src/main/java/com/ichi2/anki/filtered/FilteredDeckOptionsFragment.kt#L128-L132
https://github.com/ankidroid/Anki-Android/blob/8d288e88952e10a4bda83a3978f6c463603adf35/AnkiDroid/src/main/java/com/ichi2/anki/dialogs/EmptyCardsDialogFragment.kt#L255-L259
Hello! 👋 Thanks for logging this issue. Please remember we are all volunteers here, so some patience may be required before we can get to the issue. Also remember that the fastest way to get resolution on an issue is to propose a change directly, https://github.com/ankidroid/Anki-Android/wiki/Contributing
Any issue if we alias these as CardBrowserDestination, and add a .toIntent() method:
https://github.com/ankidroid/Anki-Android/blob/b825f75f4119f2dddcd7f4f3b776ecd891fd172f/AnkiDroid/src/main/java/com/ichi2/anki/browser/CardBrowserLaunchOptions.kt#L24-L71
https://github.com/ankidroid/Anki-Android/blob/b825f75f4119f2dddcd7f4f3b776ecd891fd172f/AnkiDroid/src/main/java/com/ichi2/anki/browser/BrowserDestination.kt#L27-L59
Hello, I’ve been reading through the existing BrowserDestination / CardBrowserLaunchOptions code to understand the intended direction here. If I understood correctly, the likely approach would be to introduce destination variants covering the current launch cases and then replace the direct Intent(..., CardBrowser::class.java) usages with toIntent() calls.
@lukstbit
commonis belowlibankiin the dependency tree- Destinations will want to be above
libAnkiso they can referenceDeckIdetc...- Alternately: the common types could be moved out of libanki into
:common
- Alternately: the common types could be moved out of libanki into
Brief thoughts:
- Add a
:destinationsmodule, referencing:libanki, with the intention that it will contain destinations for all types- Planned to be pure JVM once libanki becomes a
java-library
- Planned to be pure JVM once libanki becomes a
feature-[card]browserwould exposeDestination.toIntent()for the specific destinations which it handles- For now, this will be in
com.ichi2.anki.browser, until the browser is split into a module
- For now, this will be in
:AnkiDroidwould implement anavigate(Destination)method:- a large
whenclause mapping from the domainDestinationinto an Intent, then launching the intent
- a large
navigate(Destination)is defined, but not implemented in:destinations
Hello 👋, this issue has been opened for more than 3 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like still searching for solutions and if you found one, please open a pull request! You have 7 days until this gets closed automatically