Code flows

Five flows, each named function by function, so you can follow them in the code.

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

  1. The sign-in button → AppViewModel.beginSignIn() → AuthFlow.start() keeps the verifier and state and opens the browser.
  2. Android opens AuthCallbackActivity, which hands the address to MainActivity.
  3. AppViewModel.completeSignIn() checks the state and calls OpensolrApi.exchangeCode() with the phone's device id.
  4. The session, with this phone's own key, and the plan limits go into AppPrefs. An older session is moved to its own key by upgradeToDeviceKey().

Sync

  1. SyncScheduler starts SyncWorker, which runs SyncEngine.run().
  2. OpensolrApi.syncInfo(), then IndexManager.ensure(), makes sure the index is there and on the right configuration.
  3. MediaScanner.scan() lists the photos; the list is compared with PhotoCache on the phone. What differs goes into the actions queue.
  4. Photos to read: PhotoReader.readForIngest(), the faces from FaceEngine, then OpensolrApi.photosIngest(), five per call.
  5. Words only: EditRepository.sendWords() → OpensolrApi.photosWords(), fifty per call.
  6. Either way EditRepository.storeDoc() keeps the phone's copy in step with what Opensolr wrote; the SyncReport is saved.

Browse and search

  1. Nothing typed, no filter: AppViewModel builds the date headings from PhotoCache.takenTimes() and fills them from PhotoCache.docsBetween(). No request.
  2. Text or filters: AppViewModel.search() → SearchRepository.search(). A search by meaning goes through OpensolrApi.photosSelect(), words only through SolrClient; both through SearchCache.
  3. The results go into UiState and SearchScreen draws them.

Editing words

  1. EditSheet or BulkTagSheet → AppViewModel → EditRepository.saveLocal().
  2. saveLocal() writes the edit and the phone's copy, and queues an ACTION_WORDS row. The edit is finished here.
  3. A sync starts at once and carries the queue up.

Reset and refill

  1. AppViewModel.resetIndex() empties the index and marks it to be filled again.
  2. The sync that starts runs SyncEngine.restoreFromClone(): the copy, fifty documents per OpensolrApi.photosRestore(), picking up where it stopped.
  3. The same refill runs when a new configuration was applied, or when a sync finds the index empty while the copy is not.

For developers

Opensolr Photos is open source and MIT licensed. Questions about your Opensolr account, index or plan go to opensolr.com/contact; questions about the app itself belong on GitHub.

Opensolr Photos Documentation