[GSoC] Add `Use new backend` (persistent) preference
Purpose / Description
- The V16 pref is useful to testing in case the dev forgot to set
legacy_schema=falseonlocal.propertieswhile not having to re-enable every time the app is reopened.
Fixes
A tiny bit of #6772
Approach
On the commits
How Has This Been Tested?
Emulator SDK 25
(not so sure why Android Studio recording is getting dark, maybe I should buy a faster computer)
Checklist
Please, go through these checks before submitting the PR.
- [X] You have not changed whitespace unnecessarily (it makes diffs hard to read)
- [X] You have a descriptive commit message with a short title (first line, max 50 chars).
- [X] Your code follows the style of the project (e.g. never omit braces in
ifstatements) - [X] You have commented your code, particularly in hard-to-understand areas
- [X] 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
Would it be worth moving these into the Advanced section so alpha testers can try too? https://github.com/ankidroid/Anki-Android/pull/11808#issuecomment-1202816430
Also, I don't really see the benefit of the separate csv pref. The csv importer will require v16 to be enabled, so it's going to be hidden by default even without a separate preference.
Would it be worth moving these into the Advanced section so alpha testers can try too? #11808 (comment)
I'm particularly quite in favor of releasing it as an Advanced preference. If I get a green light of the maintainers, I'll do it.
Also, I don't really see the benefit of the separate csv pref. The csv importer will require v16 to be enabled, so it's going to be hidden by default even without a separate preference.
I actually prefer enabling the CSV importer if the new backend is active instead of a preference as well. Good to hear that another person find this reasonable too. Better than taking the "safe" approach (the CSV importer screen is self contained, so shouldn't break the rest of the app). edit: done this
Noticed that I should refactor some of the file selection code, so I'll keep this PR only for the V16 option
edit: moved to the Advanced category anyway, that's what I interpreted https://github.com/ankidroid/Anki-Android/pull/11808#issuecomment-1202816430 wants, and sooner or later it will have do be done

you have a merge conflict
I reviewed the changes and I'm questioning if we really need the temporary backend change. The permanent backend change preference has several advantages:
- offers the user full control about the backend choice
- it has a status indicator which shows what backend implementation we use
The temporary backend change:
- it doesn't have a a status indicator to show what backend implementation we use. See below why this might be a problem
- it doesn't work as its description mentions as Android doesn't really have the concept of "app close"(apps just come and go as the user does he's thing). Example: I'm clicking the temporary backend preference -> I'm being taken to the DeckPicker -> I press BACK -> reopen the app x minutes later.
At this point did I close the app? I would say yes, and others might as well Is the backend reverted ? No, it isn't.
At this point, although I left the app, the backend wasn't changed back. Can I see/realize this by looking at the preferences? No, as the temporary backend change doesn't offer any visual feedback.
So the text would need to be changed to mention that the user has to kill the app from the task manager(which indeed reverts the backend). At this point, if we require the user to go to the task manager and kill the app, we might as well just use the permanent backend preference.
Also, I really think that changing any of these preferences should bring up a confirmation dialog. When I was first checking the preferences, as I scrolled, I accidentally touched the permanent backend change preference and I enabled it. A simple misplaced touch shouldn't automatically enable such preferences.
Fair points about visibility and confirmation. I think the reason David originally added the temporary toggle is out of concern that the user might turn it on, find it crashes the app on startup due to some code path/condition we didn't anticipate, and then will be unable to revert to the old setting. That's a legitimate concern while this code is so fresh, and I actually encountered such a situation today - if the collection has the current deck id stored incorrectly as a string (which happened with old AnkiDroid versions IIRC), the new schema path currently crashes AnkiDroid on startup.
Added confirmation and visual indication if temporary pref is enabled or not
https://user-images.githubusercontent.com/69634269/183411279-358e6efd-14ef-4423-a6be-58205b7b88ad.mp4
Sorry to drop in here semi-uninformed and kind of tardy, but I just got a network time slice and my thoughts were/are:
- change should be permanent. Yes, there is some risk, string description should contain serious risk warning, then go for it
- should be in advanced section, entire goal here (for me) is to say to V3 scheduler requesters (a motivated pool of testers!) "there is some risk here, but try the new alpha and do this..."
Also, it allows developers here to more easily test their GSoC stuff (because it's persistent) and for people doing QA on GSoC to test it more easily (because it's persistent...)
Hoping to review this (if someone doesn't beat me to it) shortly but just in case I get pulled away again for a week or whatever (like I did last week) I at least stated my vision for it. Done traveling on Aug 18 so I'm about to be able to really help push things forward again. Cheers
Okey dokey. No temporary preference it is. Make your backups and have fun testing, people! Cheers.
FWIW, my opinion is:
- The temporary preference should be removed or kept only at "Developer options"
- It is useful only for developers. Non-devs shouldn't/wouldn't use it. And it's only useful for the specific case that something makes the app crash before the developer can go disable the setting. Even if that happens, the developer should just fix the problem or clear the app data.
- We should have a persistent option (at least on "Developer options")
- It's more useful than the temporary preference, as it isn't necessary to do the burden of re-enabling the preference on every app startup
- It's still useful for motivated alpha users that aren't on DEBUG builds and want to test it can do it be enabling Dev options on the About screen secret
- Advanced X Developer options
- I lean more to putting it on "Advanced"
- I don't want it, or any experimental preference, to go to the play store release versions once we are able to, but I still want more people to be able to test it. Many of the bugs that appear on
mainare only discovered by chance. The same will happen with the V16 changes, so we need more testers before releasing it to the general public. - So, I'm personally in favor of putting it, along with any other experimental preference, as a alpha-only Advanced option.
- I don't know how AnkiDroid's beta program works, as the app releases were already blocked when I started to contribute, so I can't give an opinion if beta users should be able or not to use it.
I'm strong on the first two points. I've stated my opinion about the third point, but I'm happy with any path taken.
I still want this. There's a chicken-and-egg problem of getting enough testing to feel that it's stable enough to offer to "users", and "users" is not just two classes ("people with debug builds from source" and "people using alphas / betas / etc"). There is at the moment one specific group of people - our alpha users - that are installing manually a thing labeled "alpha" and if they want to test, they would specifically tap a thing that warns them about the danger. At that point it could eat the family pet and we have clean conscience I think.
In the meantime a subset of these people (v3 scheduler requesters) is motivated to try it, and we'll start getting some real usage of the backend. Realistically, I think this will net us probably 4-5 testers max, 2 alpha / non-developer v3 people, and 2-3 of "us" (people that regular test / PR things)
Sync works, review works, undo works, those are the basic use cases. And for problems, we've got Damien and myself ready for fixes.
My vision for duration of v3 stabilization is just a couple weeks and I'm happy to re-hide this if there are problems and/or if we're about to go to beta, if for some reason it takes a lot longer or it becomes a problem.
Where to put it? Definitely "advanced" but it can't be in "developer options" since that is for debug-builds only
Note that I have still not reviewed the text - when I do so I'll make sure it says something about "There is a chance this could corrupt your installation completely, requiring app uninstall and deletion of /sdcard/AnkiDroid, and has a chance of propagating corruption via sync to ankiweb. We welcome the testing, but please make sure you have a valid non-AnkiWeb backup." (or similar)
I'm happy with any text. When you do review it, if text changes are required, please suggest the one you'd like 🙏 for 1. the summary and 2. the dialog message
edit: current dialog message and summary:

With a warning like that, I believe any "reasonable person" (yes, that's vague, but it's a US legal standard at least, I'm being sincere) can agree that if something goes wrong, you were warned......
maintainer note: doing i18n sync prior to merging this, so the string change from this does not mix with unrelated translations (a real string review velocity killer...)