I expect the browser to have the 'current' deck selected and show its cards as specified in the manual and allow me to perform searches in that very deck.
No matter which deck was selected, the browser shows French whenever it is started, and I need to change the deck to perform searches I want to. When I go back, the French deck is 'grayed' i.e. current/selected by AnkiDroid, overriding my preference from before starting the browser.
AnkiDroid Version = 2.8.4
Android Version = 8.1.0
ACRA UUID = 57ffb637-79cd-4fc7-a8ed-83cd0c0fa31a
Enter an [ x ] character to confirm the points below:
[x] I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid
[x] I have checked the manual and the FAQ and could not find a solution to my issue
[x] I have searched for similar existing issues here and on the user forum
Hmm - I can't reproduce this, for me the Card Browser always opens into "All Decks", not any particular deck I have. As far as I know the code makes no attempt to take state from the deck picker (where a deck may be selected) and use that as an initial selection in the browser. So 2 things really - should the browser start on whatever deck you were just using? I'm unsure on this one. It's a matter of opinion I think but I can understand the argument it should. Second thing, why is it going to a specific deck for you every time? Unsure on that one since I can't reproduce it either in 2.8.4 or current alphas
The documentation states:
The browser screen starts by displaying all the cards in the currently selected deck.
I understand the 'selected deck' to be whatever deck I am using right now. So either the documentation is wrong, or the code as you say it doesn't happen, or I just overinterpret the sentence.
Would it help if I shared my collection? I might be a bit big, though, there are quite a few images and a few audio files in it.
Yes, there are some irregularities in how the current deck state is handled. I never got around to look further into that.
To reproduce on 2.8.4:
On a related note, opening the browser from the statistics always shows all cards even when statistics of a specific deck are selected.
Thanks both of you - between the reproduction and the documentation snippet there's definitely something going on. I'll look again when I have a minute - may be a few days though. At least this isn't a review blocker or anything - just an annoyance
@eginhard I could reproduce it the way you mentioned. One thing - for step 3. to show me deck B in the browser, I have to enter the review mode for this deck. Once I leave to deck picker, even though deck B is still marked gray there, going to the browser picks French again.
In other words, for the browser to show me the 'correct'/expected deck I have to enter it directly from the review mode for that deck, without the intermediary step to the deck picker. For my, anything else always results in French being shown.
Thank you both.
Yeah I've been noticing this as well, I believe it used to work as written in the manual
I've just submitted a PR (https://github.com/ankidroid/Anki-Android/pull/5007) that may fix the issue. The change is minor and it seems to work. Now, in any of the three main activities (browser, statistics and picker) whenever a deck is changed, it is reflected in all the others. This was the previous behavior on 2.8.4, except for the browser, which was the reason for the original issue.
While my change is limited to a single line only, and so is my knowledge about the codebase, I actually noticed there is quite some handling of the 'selectedDeck' with the did put into Intents etc. (e.g. NavigationDroverActivity#openCardBrowser, DeckPicker#openDeckBrowser, CardBrowser#closeCardBrowser). I might be wrong, but it seems unnecessary - why not just depend on the activities setting the did of the selected deck on the collection (e.g. CardBrowser#selectDropDownItem) and just have the others use it by working with the collection? This would make the code much simpler, I hope. There may still be some special handling for the 'All decks' option in the browser etc. but maybe not?
I took a quick look at the history, and it seems the current behavior was decided in #4069. It's not working completely as intended there though due to #5010.
This is working as intended
By default the currently selected deck (i.e. the one which is being reviewed) will be used, as per anki desktop
If you search in a deck different from the selected one (let's call it deck x), then go back to the reviewer, and then back to the browser again in the same review session, then deck x will still be selected. Deck x will remembered until you end the review session (go back to the deck picker)
By default, "all decks" will be used (as opposed to the currently selected deck), which is consistent with the behavior in Anki Desktop
If you choose a deck other than "all decks" (again call it "deck x"), then go to another activity, and back to the browser, then deck x should still be selected. I'm not entirely sure how long that choice choice should be persisted.
I think #5010 is definitely a bug (see line 471 in f9883e71ae4e0cc26b5925bf94d3e69c6cba47a5), there may be other bugs here or a change in behavior desired, but let's get that one first.
@wujek-srujek @mikehardy
How does this work for you?
https://github.com/timrae/Anki-Android/commit/ec95ff63e4330d6e5877130eb5366184647948e5
When I change the deck in deck picker, it is reflected in the statistics and browser activities, as expected. However, if I change the deck in statistics or in the browser, it doesn't influence other activities - is this expected?
Yes that's #5010
Sorry for the delay - codewise, looks fine - going from an intent to a shared preference certainly simplifies things. Thinking theoretically about performance since the first use is a write to the value on startup that means memory state is coherent with disk from the beginning so this will never wait for a disk read and since you used apply vs commit, won't wait for a write either. Neat state-passing trick, seemingly without negative consequence.
I personally prefer clarifying parentheses but significantly less than I hate talking about formatting preferences... motivation is just that it doesn't worsen the signal to noise on our current static analysis stuff which is trending dow. And codacy will chirp if it does
Looks good
Thanks, the main point for posting the link was the new business logic, I'll make a PR for this once the other one goes through
Most helpful comment
Yes, there are some irregularities in how the current deck state is handled. I never got around to look further into that.
To reproduce on 2.8.4:
On a related note, opening the browser from the statistics always shows all cards even when statistics of a specific deck are selected.