aboutsummaryrefslogtreecommitdiff
path: root/mobile/mobile.go
diff options
context:
space:
mode:
Diffstat (limited to 'mobile/mobile.go')
-rw-r--r--mobile/mobile.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/mobile/mobile.go b/mobile/mobile.go
index e79e748..d863463 100644
--- a/mobile/mobile.go
+++ b/mobile/mobile.go
@@ -184,6 +184,37 @@ func Days(start string, count int, form, lang string) string {
return string(b)
}
+// partLabel is one section's machine ID and its human label.
+type partLabel struct {
+ Part string `json:"part"`
+ Label string `json:"label"`
+}
+
+// PartLabels returns the form's section IDs and their labels in lang, in display
+// order, as a JSON array. The app builds its reading filters from this instead
+// of hardcoding part IDs -- which is how it came to ship seven 1962 checkboxes
+// the engine never emits.
+//
+// An array, not an object: JSON object key order is not guaranteed and the app
+// renders these in order.
+func PartLabels(form, lang string) string {
+ ids := readings.PartIDs(lectByForm(form))
+ ui := i18n.Get(lang)
+ out := make([]partLabel, 0, len(ids))
+ for _, id := range ids {
+ label := ui.PartLabel[id]
+ if label == "" {
+ label = id
+ }
+ out = append(out, partLabel{Part: id, Label: label})
+ }
+ b, err := json.Marshal(out)
+ if err != nil {
+ return "[]"
+ }
+ return string(b)
+}
+
// Ping is a trivial JNI smoke test: it returns "pong" so the app can confirm the
// native engine loaded before issuing a real query.
func Ping() string { return "pong" }