Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

Auto-sync on login from settings

Open ShaanNarendran opened this issue 1 month ago • 6 comments

Purpose / Description

Auto syncs data when a user logs in via the settings page.

Fixes

  • Fixes #15460

Approach

We use a variable to track whether a user has logged in through the settings page var pendingSyncOnResume = false Then onWindowFocusChanged() is overridden to tell us when the deck picker page is loaded, after this we can sync

How Has This Been Tested?

Screen_recording_20251210_012201.webm

Checklist

Please, go through these checks before submitting the PR.

  • [x] You have a descriptive commit message with a short title (first line, max 50 chars).
  • [x] You have commented your code, particularly in hard-to-understand areas
  • [x] You have performed a self-review of your own code
  • [x] 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

ShaanNarendran avatar Dec 09 '25 20:12 ShaanNarendran

I am not actually sure why one of the commits that was merged today keeps showing up in mine, if anyone can help me on that please do. Git still confuses me TT.

ShaanNarendran avatar Dec 09 '25 21:12 ShaanNarendran

  • You want to: 'sync' your Fork's 'main' with 'upstream/main' (on ankidroid/Anki-Android)
  • Then rebase this branch onto main

david-allison avatar Dec 09 '25 21:12 david-allison

  • You want to: 'sync' your Fork's 'main' with 'upstream/main' (on ankidroid/Anki-Android)
  • Then rebase this branch onto main

ok let me do that

ShaanNarendran avatar Dec 09 '25 21:12 ShaanNarendran

@criticalAY whenever you're free, I'd like to know if you have any ideas on how I can signal deck picker to sync once the login is done. I had looked into activity contracts but I don't think they would work here since I have to notify through another fragment i.e Login->settings->deckpicker. I won't be able to work till friday so I will implement the changes then and force push.

ShaanNarendran avatar Dec 09 '25 21:12 ShaanNarendran

@david-allison @criticalAY I have got it in a nice working order using the getIntent function, the thing is I've been able to do it such that you login through the settings and upon a successful login it takes you to the deck picker screen and auto syncs basically skipping the login success page and having to go back. Do we want the success page to be displayed, if so I'll get working on that. I've attached how it is below:

Screen_recording_20251210_211449.webm

ShaanNarendran avatar Dec 10 '25 15:12 ShaanNarendran

Looks great!

I don't think there's a benefit in showing the login success in this case. Going to the Deck Picker is expected

david-allison avatar Dec 10 '25 23:12 david-allison

Really sorry for the successive force pushes, I had forgotten to add some changes before committing. @david-allison I think I've implemented everything you mentioned and it works the same way as before, whenever you get time do have a look! Edit 1: Nevermind, 2 minutes it still didn't change properly TT still working on git really sorry ill have to do one last push

Edit 2: I have finally pushed all the changes, really sorry again for all the force pushes

ShaanNarendran avatar Dec 11 '25 14:12 ShaanNarendran

Not really sure how/where to apply the NeedsTest annotation, Android Studio isn't giving me any hints on it

ShaanNarendran avatar Dec 11 '25 16:12 ShaanNarendran

I believe this is what was the flow requested by David, hopefully I didn't misinterpret Screen_recording_20251213_100153.webm

ShaanNarendran avatar Dec 13 '25 04:12 ShaanNarendran

I believe this is what was the flow requested by David, hopefully I didn't misinterpret Screen_recording_20251213_100153.webm

@david-allison I posted the new ui overview here!!

ShaanNarendran avatar Dec 13 '25 05:12 ShaanNarendran

I think I broke something while applying patches and trying to push, will fix Edit: very stupidly deleted initObservers() altogether, going to force push for hopefully the last time, really sorry

ShaanNarendran avatar Dec 13 '25 06:12 ShaanNarendran

I definitely messed up somewhere while figuring out the git part but everything works and all patches are applied. @david-allison @criticalAY thank you so much for being so patient with me over the course of the pr, I'm really excited to be able to close a normal issue but I know I made a lot of mistakes while fixing the issue. I did learn a lot however about how to document and how to keep the code clean, I apologise if it took a long time to review the code, I wanted to try and do as much of it myself as possible. I know there may still be changes to do here, but next time I open a pr it'll definitely be much cleaner! Thank you again, this was super rewarding and helpful for me, hopefully we can merge it soon

ShaanNarendran avatar Dec 13 '25 06:12 ShaanNarendran

Looks great, thanks SO MUCH for the fast turnaround!

Just pushed the remaining changes requested, this pr was such a great learning experience for me. I'll be back for more on Monday after my exam!

ShaanNarendran avatar Dec 13 '25 15:12 ShaanNarendran