Android app: a read-only viewer, paired by QR from the API tokens page

3ec21a7 · gmorell · 2026-12-02 19:15

116 files +5851 -19
Message
{commit_body(@commit)}

Files changed

modified .dockerignore
+4 −0
@@ -38,3 +38,7 @@ cover/
38 38 # The vgl CLI (cli/Dockerfile builds it from source).
39 39 cli/target/
40 40 cli-dist/
41 +
42 +# The Android app (android/Dockerfile builds it, with android/ as its
43 +# context): the server image needs none of it.
44 +android/
added .forgejo/workflows/android.yml
+202 −0
@@ -0,0 +1,202 @@
1 +# The Android client (android/): its unit tests on every push that touches
2 +# it, and on master a signed release APK published to the forge's own
3 +# F-Droid repository, the way the other neiam apps publish theirs.
4 +#
5 +# Everything runs in android/Dockerfile, so the runner needs docker and
6 +# nothing else, and `docker buildx build --target android-test …` on a
7 +# laptop reproduces the test job exactly (the commands are in the
8 +# Dockerfile's header).
9 +#
10 +# Publishing needs two secrets, and skips cleanly without them rather
11 +# than failing a build for a package that isn't set up yet:
12 +#
13 +# ANDROID_KEYSTORE base64 of the release keystore (.jks)
14 +# ANDROID_KEYSTORE_PASS its password
15 +#
16 +# Generate one once, and keep it: the signing certificate is what
17 +# Android checks on every update, so losing it means every install has
18 +# to be uninstalled and redone by hand. See android/README.md.
19 +#
20 +# This is the APK signing key. It is NOT the F-Droid index key — that
21 +# one is per-owner, lives in the forge's OpenBao, and never comes near
22 +# CI.
23 +#
24 +# The `paths:` filters are GitHub's semantics; this forge doesn't apply
25 +# them yet and runs the workflow on every push, which costs a test run
26 +# and a re-publish but breaks nothing.
27 +name: android
28 +on:
29 + push:
30 + paths:
31 + - "android/**"
32 + - ".forgejo/workflows/android.yml"
33 + pull_request:
34 + paths:
35 + - "android/**"
36 + - ".forgejo/workflows/android.yml"
37 +
38 +# A newer push supersedes this run: on a branch or PR the run in
39 +# progress is cancelled; on master it finishes, and only a run still
40 +# waiting is replaced.
41 +concurrency:
42 + group: ${{ github.workflow }}-${{ github.ref }}
43 + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
44 +
45 +jobs:
46 + test:
47 + runs-on: self-hosted
48 + steps:
49 + - uses: actions/checkout@v4
50 +
51 + - uses: docker/setup-buildx-action@v3
52 +
53 + - name: Unit tests
54 + run: |
55 + docker buildx build \
56 + --target android-test \
57 + --progress=plain \
58 + --file android/Dockerfile android
59 +
60 + publish:
61 + needs: test
62 + # Only `github.ref`: this forge's runner context carries `event`, not
63 + # `event_name`, so `github.event_name == 'push'` reads as empty and
64 + # skipped this job on every push. A pull request's ref is never
65 + # master's, so the ref alone keeps publishing to pushes to master.
66 + if: github.ref == 'refs/heads/master'
67 + runs-on: self-hosted
68 + steps:
69 + - uses: actions/checkout@v4
70 +
71 + - uses: docker/setup-buildx-action@v3
72 +
73 + # `vars.CI_FORGE_URL` is a forge built-in, but an older forge
74 + # build won't inject it. Fall back to what the runner already
75 + # knows, and say so plainly if neither resolves rather than
76 + # handing curl an empty URL.
77 + - name: Resolve the forge URL
78 + env:
79 + CI_FORGE_URL: ${{ vars.CI_FORGE_URL }}
80 + run: |
81 + set -euo pipefail
82 + forge_url=${CI_FORGE_URL:-${GITHUB_SERVER_URL:-}}
83 +
84 + if [ -z "$forge_url" ]; then
85 + echo "No forge URL available." >&2
86 + echo "Set a CI_FORGE_URL variable on this repository or its org," >&2
87 + echo "or upgrade the forge to a build that injects it." >&2
88 + exit 1
89 + fi
90 +
91 + echo "using forge URL: $forge_url"
92 + echo "FORGE_URL=$forge_url" >> "$GITHUB_ENV"
93 +
94 + # A secret can't be read in a job-level `if`, so the gate is a
95 + # step output that everything after checks.
96 + - name: Unpack the signing keystore
97 + id: keystore
98 + env:
99 + KEYSTORE: ${{ secrets.ANDROID_KEYSTORE }}
100 + KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASS }}
101 + run: |
102 + set -euo pipefail
103 +
104 + if [ -z "${KEYSTORE:-}" ] || [ -z "${KEYSTORE_PASS:-}" ]; then
105 + echo "No ANDROID_KEYSTORE / ANDROID_KEYSTORE_PASS set — skipping."
106 + echo "An unsigned or debug-signed APK is worse than none: the"
107 + echo "debug key is shared by every developer, so publishing one"
108 + echo "would let anyone ship an 'update' to it."
109 + echo "skip=true" >> "$GITHUB_OUTPUT"
110 + exit 0
111 + fi
112 +
113 + umask 077
114 + printf '%s' "$KEYSTORE" | base64 -d > release.jks
115 + printf '%s' "$KEYSTORE_PASS" > keystore.pass
116 + echo "skip=false" >> "$GITHUB_OUTPUT"
117 +
118 + - name: Build and sign the APK
119 + if: steps.keystore.outputs.skip != 'true'
120 + env:
121 + RUN_NUMBER: ${{ github.run_number }}
122 + run: |
123 + set -euo pipefail
124 +
125 + # One stamp for the whole run, computed here rather than
126 + # inside Gradle, so every artifact a run produces agrees on
127 + # its version even if the build is retried a step at a time.
128 + stamp=$(date -u +%s)
129 + echo "version: 0.1.0-dev-$stamp (versionCode $RUN_NUMBER)"
130 +
131 + docker buildx build \
132 + --target android-export \
133 + --build-arg GITHUB_RUN_NUMBER="$RUN_NUMBER" \
134 + --build-arg SOURCE_DATE_EPOCH="$stamp" \
135 + --secret id=keystore,src=./release.jks \
136 + --secret id=keystore_password,src=./keystore.pass \
137 + --output type=local,dest=./apk \
138 + --progress=plain \
139 + --file android/Dockerfile android
140 +
141 + # The keystore is gone before anything else runs, so a later step
142 + # or a failure mid-job can't leave it on a persistent runner.
143 + - name: Shred the keystore
144 + if: always()
145 + run: shred -u release.jks keystore.pass 2>/dev/null || rm -f release.jks keystore.pass
146 +
147 + # `${{ github.token }}` is minted for this job and authorized to
148 + # publish to THIS repository's packages and nowhere else, so there
149 + # is no secret to create first.
150 + - name: Publish to the F-Droid repository
151 + if: steps.keystore.outputs.skip != 'true'
152 + env:
153 + REPOSITORY: ${{ github.repository }}
154 + TOKEN: ${{ github.token }}
155 + run: |
156 + set -euo pipefail
157 +
158 + # What F-Droid shows under the name and on the app's page.
159 + # android/DESCRIPTION.md: the summary on its first line, then
160 + # a blank line, then the description. The description header
161 + # is percent-encoded because a header can't carry newlines —
162 + # done in bash so the runner needs nothing it doesn't have.
163 + urlencode() {
164 + local LC_ALL=C s="$1" out="" c i
165 + for ((i = 0; i < ${#s}; i++)); do
166 + c=${s:i:1}
167 + case $c in
168 + [a-zA-Z0-9.~_-]) out+=$c ;;
169 + *) printf -v c '%%%02X' "'$c"; out+=$c ;;
170 + esac
171 + done
172 + printf '%s' "$out"
173 + }
174 + summary=$(head -n 1 android/DESCRIPTION.md)
175 + description=$(tail -n +3 android/DESCRIPTION.md)
176 +
177 + curl --fail-with-body -sS \
178 + -u "ci:$TOKEN" \
179 + -H "Content-Type: application/vnd.android.package-archive" \
180 + -H "X-Package-Summary: $summary" \
181 + -H "X-Package-Description: $(urlencode "$description")" \
182 + --data-binary "@apk/app-release.apk" \
183 + "$FORGE_URL/pkg/fdroid/$REPOSITORY/upload"
184 + echo
185 +
186 + - name: How to install it
187 + if: steps.keystore.outputs.skip != 'true'
188 + env:
189 + OWNER: ${{ github.repository_owner }}
190 + run: |
191 + set -euo pipefail
192 + fingerprint=$(curl -fsSL "$FORGE_URL/pkg/_keys/fdroid/$OWNER")
193 +
194 + cat <<EOF
195 + Add this repository in F-Droid (Settings -> Repositories -> +):
196 +
197 + $FORGE_URL/pkg/fdroid/$OWNER/_all?fingerprint=$fingerprint
198 +
199 + One entry covers every Android app $OWNER publishes. The
200 + fingerprint pins the index signing certificate; F-Droid
201 + refuses an index signed by anything else.
202 + EOF
modified README.md
+15 −1

Click to load diff…

modified ROADMAP.md
+7 −0

Click to load diff…

added android/.dockerignore
+10 −0

Click to load diff…

added android/.gitignore
+12 −0

Click to load diff…

added android/DESCRIPTION.md
+5 −0

Click to load diff…

added android/Dockerfile
+159 −0

Click to load diff…

added android/README.md
+218 −0

Click to load diff…

added android/app/build.gradle.kts
+100 −0

Click to load diff…

added android/app/proguard-rules.pro
+10 −0

Click to load diff…

added android/app/src/main/AndroidManifest.xml
+41 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/MainActivity.kt
+207 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/auth/PairScreen.kt
+227 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/data/Links.kt
+56 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/data/Models.kt
+243 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/data/PrefsStore.kt
+32 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/data/TokenStore.kt
+71 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/data/VigilClient.kt
+132 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/ui/Common.kt
+203 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/ui/HomeScreen.kt
+145 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/ui/IssueScreen.kt
+446 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/ui/IssuesTab.kt
+341 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/ui/Loading.kt
+114 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/ui/MonitorsTab.kt
+185 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/ui/OrgPickerScreen.kt
+104 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/ui/ThemePicker.kt
+71 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/ui/theme/AppTheme.kt
+219 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/ui/theme/Shapes.kt
+26 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/ui/theme/Theme.kt
+18 −0

Click to load diff…

added android/app/src/main/java/org/neiam/vigil/app/ui/theme/Typography.kt
+38 −0

Click to load diff…

added android/app/src/main/res/drawable/ic_launcher_foreground.xml
+20 −0

Click to load diff…

added android/app/src/main/res/drawable/ic_launcher_monochrome.xml
+20 −0

Click to load diff…

modified ?
+0 −0

Click to load diff…

modified ?
+0 −0

Click to load diff…

added android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
+6 −0

Click to load diff…

added android/app/src/main/res/values/colors.xml
+5 −0

Click to load diff…

added android/app/src/main/res/values/strings.xml
+4 −0

Click to load diff…

added android/app/src/main/res/values/themes.xml
+9 −0

Click to load diff…

added android/app/src/main/res/xml/data_extraction_rules.xml
+13 −0

Click to load diff…

added android/app/src/test/java/org/neiam/vigil/app/data/ContractTest.kt
+89 −0

Click to load diff…

added android/app/src/test/java/org/neiam/vigil/app/data/LinksTest.kt
+51 −0

Click to load diff…

added android/app/src/test/java/org/neiam/vigil/app/ui/CommonTest.kt
+27 −0

Click to load diff…

added android/app/src/test/resources/api/event.json
+209 −0

Click to load diff…

added android/app/src/test/resources/api/issue.json
+140 −0

Click to load diff…

added android/app/src/test/resources/api/issues.json
+37 −0

Click to load diff…

added android/app/src/test/resources/api/issues_link.txt
+1 −0

Click to load diff…

added android/app/src/test/resources/api/monitors.json
+28 −0

Click to load diff…

added android/app/src/test/resources/api/organizations.json
+12 −0

Click to load diff…

added android/app/src/test/resources/api/projects.json
+22 −0

Click to load diff…

added android/app/src/test/resources/api/root.json
+23 −0

Click to load diff…

added android/app/src/test/resources/api/uptime.json
+21 −0

Click to load diff…

added android/build.gradle.kts
+7 −0

Click to load diff…

added android/gradle.properties
+4 −0

Click to load diff…

added android/gradle/libs.versions.toml
+50 −0

Click to load diff…

modified ?
+0 −0

Click to load diff…

added android/gradle/wrapper/gradle-wrapper.properties
+7 −0

Click to load diff…

added android/gradlew
+251 −0

Click to load diff…

added android/gradlew.bat
+94 −0

Click to load diff…

added android/settings.gradle.kts
+24 −0

Click to load diff…

modified lib/vigil/api_tokens.ex
+12 −0

Click to load diff…

modified lib/vigil/issues.ex
+32 −3

Click to load diff…

added lib/vigil_web/api/v0/event_json.ex
+254 −0

Click to load diff…

modified lib/vigil_web/api/v0/issue_controller.ex
+94 −4

Click to load diff…

modified lib/vigil_web/api/v0/project_json.ex
+38 −3

Click to load diff…

modified lib/vigil_web/live/api_token_live.ex
+104 −6

Click to load diff…

modified lib/vigil_web/router.ex
+5 −0

Click to load diff…

modified mix.exs
+4 −1

Click to load diff…

modified mix.lock
+1 −0

Click to load diff…

modified test/test_helper.exs
+3 −1

Click to load diff…

added test/vigil_web/api/android_fixtures_test.exs
+156 −0

Click to load diff…

added test/vigil_web/api/mobile_api_test.exs
+247 −0

Click to load diff…

modified test/vigil_web/live/api_token_live_test.exs
+66 −0

Click to load diff…

Parents: fb64a1a