Skip to content
observ-ingPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Observ.ing mobile

Potential iOS and Android apps for observ.ing. The two apps share one Rust core built with Crux; each has its own native UI (SwiftUI, Jetpack Compose with Material 3).

This may be superceded by Exact-based work in https://github.com/observ-ing/core, but I figured I'd share what I've got.

Layout

  • shared/: the core. All state and decisions live here: drafts and their upload queue, explore filters, the saved explore list, sessions. It does no I/O itself; it asks the shell for it through effects (HTTP, key-value storage, device location, photo uploads).
  • ios/: SwiftUI shell. Observing/Core.swift carries out the effects. ShareExtension/ puts the app in other apps' share sheets.
  • android/: Compose shell. app/.../Core.kt carries out the effects.
  • fake-appview/: a stand-in for the observ.ing server, for end-to-end tests.
  • e2e/: end-to-end Maestro flows that drive the apps.

The Swift and Kotlin versions of the core's types, and the compiled Rust libraries, are generated into ios/generated and android/generated and are not checked in.

Building

make test             # core and fake appview unit tests
make ios              # generate code and ios/Observing.xcodeproj, then build in Xcode
make ios-install      # build and install on connected devices (or IOS_DEVICE)
make android          # generate code and build android/app/build/outputs/apk/debug
make android-install  # build and install on connected devices (or ANDROID_SERIAL)
make e2e-android      # end-to-end flows on the "Observing_E2E" emulator
make e2e-ios          # end-to-end flows on the "Observing E2E" simulator

Testing

Most behavior lives in the core, and shared/src/tests.rs tests it by playing the shell: sending events and answering effects. What the core can't cover, such as a screen showing a stale copy of what the core holds, is covered by end-to-end flows in e2e/flows/, which drive the real apps against fake-appview.

  • The fake appview serves the endpoints the apps use on 127.0.0.1:8787, with any Bearer token counting as one signed-in user. Its responses are checked against the real server's OpenAPI spec, vendored as fake-appview/openapi.json (make openapi refreshes it), and it answers writes whose bodies the spec rejects with a 400 (query parameters aren't checked). Saves are indexed at once unless a flow holds them, which is how the real server's indexing delay is reproduced. Explore's feed comes in pages, as the real one does, and a flow can hold the later pages to act while one loads. Each flow seeds it through POST /fake/reset; src/lib.rs lists the control endpoints.
  • Signed in without an account. Debug builds take the server and session token as launch arguments, observingUrl and observingToken (intent extras on Android, -observingUrl ... arguments on iOS). Neither is saved. Release builds ignore them.
  • Maestro runs the flows. Install it with its installer, which puts it in ~/.maestro/bin; the Makefile looks there and on PATH, and turns its analytics off. Flows start with clearState, which wipes the app's data on the device, so make e2e-ios and make e2e-android each use a simulator or emulator of their own, created and booted if need be. The Android one runs without a window and stays running for the next run; creating it takes an installed phone system image and the SDK Command-line Tools. ANDROID_SERIAL runs the Android flows on another device instead. E2E_RETRIES=2 runs flows that fail again, up to twice more, as CI does. Results and failure screenshots are in ~/.maestro/tests/.

To look around the apps signed in by hand, run make fake-appview, install a debug build, and launch it with the arguments:

xcrun simctl launch --terminate-running-process booted ing.observ.app \
  -observingUrl http://127.0.0.1:8787 -observingToken fake-token

adb reverse tcp:8787 tcp:8787
adb shell am start -S -n ing.observ.app/.MainActivity \
  --es observingUrl http://127.0.0.1:8787 --es observingToken fake-token

How things work

  • Offline recording. A new observation is a draft held by the core and saved to the device on every change. Photos are copied into app storage as JPEGs. Submitting a draft queues it; the queue uploads one draft at a time whenever the device is online and signed in. Deleting an observation queues the deletion the same way and hides the observation at once.
  • Before the server indexes an upload. The server indexes what it saves a moment later, so until a reload brings back its copy, the app shows the observation as sent, with its photos from the device, and checks again a few times over the next 45 seconds.
  • Sharing. Photos shared from another app start a new observation. On Android the share opens the app itself. On iOS a share extension copies the photos into the group.ing.observ.app app group and opens the app, which makes the observation when it next comes to the front; signing for a device needs a team that can provide app groups.
  • Sign-in. observ.ing accepts its session token as a Bearer header but only issues it as a cookie, so the app shows the sign-in in a web view and reads the session cookie afterwards.
  • Explore. The feed takes taxon and date filters on the server. The bounding-box endpoint takes none, so map-area results are filtered in the core. The last results are saved and shown when offline.
  • Maps. MapLibre Native with the website's basemaps. Tiles that have been viewed stay in MapLibre's cache (raised to 256 MB) and draw offline.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages