Five flows cover almost everything the app does. Each one below names the functions it passes through, in order, so you can follow it in the code.
Sign-in
- The sign-in button →
AppViewModel.beginSignIn()→AuthFlow.start()keeps the verifier and state and opens the browser. - Android opens
AuthCallbackActivity, which hands the address toMainActivity. AppViewModel.completeSignIn()checks the state and callsOpensolrApi.exchangeCode()with the phone's device id.- The session, with this phone's own key, and the plan limits go into
AppPrefs. An older session is moved to its own key byupgradeToDeviceKey().
Sync
SyncSchedulerstartsSyncWorker, which runsSyncEngine.run().OpensolrApi.syncInfo(), thenIndexManager.ensure(), makes sure the index is there and on the right configuration.MediaScanner.scan()lists the photos; the list is compared withPhotoCacheon the phone. What differs goes into theactionsqueue.- Photos to read:
PhotoReader.readForIngest(), the faces fromFaceEngine, thenOpensolrApi.photosIngest(), five per call. - Words only:
EditRepository.sendWords()→OpensolrApi.photosWords(), fifty per call. - Either way
EditRepository.storeDoc()keeps the phone's copy in step with what Opensolr wrote; theSyncReportis saved.
Browse and search
- Nothing typed, no filter:
AppViewModelbuilds the date headings fromPhotoCache.takenTimes()and fills them fromPhotoCache.docsBetween(). No request. - Text or filters:
AppViewModel.search()→SearchRepository.search(). A search by meaning goes throughOpensolrApi.photosSelect(), words only throughSolrClient; both throughSearchCache. - The results go into
UiStateandSearchScreendraws them.
Editing words
EditSheetorBulkTagSheet→AppViewModel→EditRepository.saveLocal().saveLocal()writes the edit and the phone's copy, and queues anACTION_WORDSrow. The edit is finished here.- A sync starts at once and carries the queue up.
Reset and refill
AppViewModel.resetIndex()empties the index and marks it to be filled again.- The sync that starts runs
SyncEngine.restoreFromClone(): the copy, fifty documents perOpensolrApi.photosRestore(), picking up where it stopped. - The same refill runs when a new configuration was applied, or when a sync finds the index empty while the copy is not.