# Herbarium

> A pocket field guide to 500 herbs and wild flowers, with a notebook for what you find.

Case study by Paolo Gianfelici (Full-stack developer & UI/UX designer). https://paologianfelici.com/work/herbarium

- **Role:** Design and development, on my own
- **Type:** Personal project, published on Google Play
- **Period:** 2016–2020 (version 4.2)
- **Platform:** Android, native Java
- **Stack:** Java, Android SDK, SQLite, ContentProvider, Google Maps, GPS, Glide

Herbarium is a field guide that fits in a pocket and works without a connection: 500 species, each with photo, description, distribution and habitat in English and Italian, all shipped inside the app.

It is built around the question you actually have in a meadow (what is this purple thing, flowering in September, at four hundred metres?) and answers it by filtering on flower colour, on what is in bloom this month and on the altitude the phone reports. Then it keeps a notebook: every sighting is saved with its position, altitude, photo and notes.

*Published on Google Play from 2016 and updated until version 4.2 in 2020; it is no longer listed there. For this page I rebuilt the app from its original source with a current toolchain and recorded it on an emulator: what you see is the real app, not a reconstruction.*

- 500: species in the offline catalogue
- 2: languages: English and Italian
- 1M: geoid grid points bundled to turn GPS height into altitude
- 10k: lines of Java

## From “what is this flower?” to a dated entry in your notebook

### A catalogue you browse with your eyes

The catalogue is a wall of photos that scrolls sideways, sized to the screen so four rows always fit. Typing part of a scientific name narrows it down as you type; a tap opens the plant.

### Filters that match how you meet a plant

You rarely know the name; you know what it looks like and where you are. So the filters are the flower’s colour, whether the species is in bloom this month, and whether it grows at your current altitude, read from the GPS. They combine freely.

### A sheet for every species

Common and scientific name, a credited photo you can zoom into, description, distribution and habitat. A bloom calendar highlights the current month and a small mountain shows the altitude range with a line at your own height. Wikipedia and Wikimedia Commons open inside the app for more.

### A notebook for the field

A sighting pins the spot on a satellite map and records coordinates, date and altitude. Raw GPS height is off by tens of metres, so the app averages a few readings and corrects them with a geoid model it carries along. Add a photo and a note, and the plant joins “My herbs”, where every sighting of a species is kept.

## How it was built

### Offline first

A 33 MB SQLite database is bundled with the app and unpacked on first launch, then read through a ContentProvider with typed contracts. Data updates ship as migration scripts, so users of an older version get the hundred species added later without losing their own sightings.

### Altitude done properly

GPS reports height above a mathematical ellipsoid, not above sea level. The database includes the EGM96 geoid grid at quarter-degree resolution (about a million rows), and the app looks up the cell the user is standing in to convert one into the other, after averaging several fixes.

### Custom UI, no framework

Hand-written views draw the altitude chart and shape the photos; grid and item sizes are computed from the display so the layout holds on phones, tablets and in landscape. Google Maps for the sightings, Glide for the image pipeline, background queries to keep scrolling smooth.

## Rebuilding a 2016 Android app today: The code had not changed. Everything around it had.

The project no longer built: its build tools were obsolete, the repository it downloaded libraries from had shut down, and one library version had vanished. The sources themselves were fine.

- **A new build around the old code.** A small wrapper project compiles the original sources where they are, untouched, with a current Android toolchain and repositories that still exist.
- **Signed like the original.** Google Maps only answers to an app signed with the certificate it was registered for. The rebuilt app is signed the way the original was, so the satellite maps load.
- **Two patches, applied at build time.** The emulator’s camera only sees a synthetic living room, so a stand-in camera frames a real plant photo instead. And Wikipedia retired its mobile addresses, which made the in-app page jump to the browser. Both are one-line substitutions made while building; the original files stay as they are.
- **Recorded on an emulator, by a script.** A storyboard finds widgets through Android’s accessibility tree, sends real touch events to the emulator’s touchscreen, feeds it GPS positions and records the screen. Every clip and screenshot here can be regenerated with one command.

Catalogue photos are credited to their authors inside the app. The sighting shown was made up for the recording.

## Recordings

- **Browsing the catalogue** (88 s): From launch to a plant: the photo grid, filters by flower colour, by what is in bloom now and by altitude, and search by scientific name. https://paologianfelici.com/media/herbarium/clips/catalogue.mp4?v=3513dfed86
- **A plant sheet** (70 s): Everything about one species: photo, description, bloom calendar, altitude range against your own altitude, Wikipedia inside the app and a zoomable photo. https://paologianfelici.com/media/herbarium/clips/plant.mp4?v=16a0f83224
- **Recording a sighting** (123 s): Found one in the field: the app pins the GPS position and altitude on a satellite map, takes photos, stores a note and files everything under “My herbs”. https://paologianfelici.com/media/herbarium/clips/sighting.mp4?v=6ca0b72ea3
