Move SSD PDF choice labels to typed Kotlin
ober
3e54f16033f36129e7c77f1f0c344e8704c6efec
--- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -1143,11 +1143,19 @@ (kotlin-imports (android net Uri)) (typed-library (com sfb ssdreview) (export make-SsdPdfChoice SsdPdfChoice? - SsdPdfChoice-label SsdPdfChoice-uri) + SsdPdfChoice-label SsdPdfChoice-uri + ssdPdfChoiceLabels) + (type Int32) (type Uri) (record SsdPdfChoice ((label : String) - (uri : Uri))))) + (uri : Uri))) + (def (ssdPdfChoiceLabels (choices : (List SsdPdfChoice))) : (MutableList String) + (for/fold ((labels (mutable-list-empty String))) + ((i (in-range (int32 0) (list-size choices)))) + (begin + (mutable-list-add! labels (SsdPdfChoice-label (list-ref choices i))) + labels))))) (typed-kotlin-file "com/sfb/ssdreview/TruthStoreRecords.kt" (kotlin-imports (java io File) (java net URL)) @@ -4651,7 +4659,7 @@ " private fun showPdfChoiceDialog(choices: List<SsdPdfChoice>, title: String) {" " AlertDialog.Builder(this)" " .setTitle(title)" - " .setItems(choices.map { it.label }.toTypedArray()) { _, which ->" + " .setItems(ssdPdfChoiceLabels(choices).toTypedArray()) { _, which ->" " loadPdf(choices[which].uri, Intent.FLAG_GRANT_READ_URI_PERMISSION)" " }" " .setNegativeButton(\"Cancel\", null)"