Move SSD box type object access to typed Kotlin
ober
0a95f287145d8cd5be868bbdd7d11a8d997dbdb8
--- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -125,10 +125,25 @@ (typed-kotlin-file "com/sfb/ssdreview/BoxTypeAndroid.kt" (kotlin-imports (android content Context)) (typed-library (com sfb ssdreview) - (export boxTypeRawIsWeapon resolvedBoxTypeNameOr resolvedBoxTypeIdOr) + (export boxTypeRawIsWeapon resolvedBoxTypeNameOr resolvedBoxTypeIdOr + boxTypesLoadAndroid boxTypesResolveAndroid boxTypesDisplayAndroid) (type Context) (extern (boxTypesResolve (context : Context) (raw : String)) : (Nullable BoxType) (kotlin-call BoxTypes resolve)) + (extern (boxTypesLoadRaw (context : Context)) : (List BoxType) + (kotlin-call BoxTypes load)) + (extern (boxTypesDisplayRaw (context : Context) (id : String)) : String + (kotlin-call BoxTypes display)) + (def (boxTypesLoadAndroid (context : Context)) : (List BoxType) + (boxTypesLoadRaw context)) + (def (boxTypesResolveAndroid + (context : Context) + (raw : String)) : (Nullable BoxType) + (boxTypesResolve context raw)) + (def (boxTypesDisplayAndroid + (context : Context) + (id : String)) : String + (boxTypesDisplayRaw context id)) (def (resolvedBoxTypeNameOr (boxType : (Nullable BoxType)) (fallback : String)) : String (if (nullable-null? boxType) fallback @@ -7299,7 +7314,7 @@ " internal var ssdAreaMode: Boolean = false" " internal var reopenSsdBrowserOnResume: Boolean = false" " @Volatile internal var loadGeneration: Int = 0" - " private val boxTypeDisplays: List<String> by lazy { boxTypeDisplays(BoxTypes.load(this)) }" + " private val boxTypeDisplays: List<String> by lazy { boxTypeDisplays(boxTypesLoadAndroid(this)) }" " private val firingArcDisplays = listOf(" " \"FA\"," " \"FH\"," @@ -7511,7 +7526,7 @@ " }" "" " private fun finalizeGroupLabel(group: SsdGroup) {" - " val typeDisplay = BoxTypes.display(this, group.boxTypeId)" + " val typeDisplay = boxTypesDisplayAndroid(this, group.boxTypeId)" " val resolved = resolvedLabelForBoxTypeAndroid(this, group.label, typeDisplay, group.boxTypeId)" " ssdGroupApplyResolvedLabel(group, resolved)" " }" @@ -8065,7 +8080,7 @@ " ) {" " if (sessionMissing(currentSession)) return" " val session = ssdSessionOrEmpty(currentSession)" - " val resolvedType = BoxTypes.resolve(this, boxType)" + " val resolvedType = boxTypesResolveAndroid(this, boxType)" " val cleanLabel = manualGroupLabel(resolvedLabelForBoxTypeAndroid(this, label, boxType, \"\"), resolvedBoxTypeNameOr(resolvedType, \"\"), \"\")" " val group = mainActivityAddApprovedAreaGroup(this, reviewView, session, rect, detectedIds, cleanLabel, resolvedBoxTypeIdOr(resolvedType, boxType), firingArc, count)" " truthStoreAppendGroupApproved(truthStore, session)" @@ -8103,13 +8118,13 @@ " val label = EditText(this).apply {" " hint = \"Label\"" " inputType = InputType.TYPE_CLASS_TEXT" - " val typeDisplay = BoxTypes.display(this@MainActivity, group.boxTypeId)" + " val typeDisplay = boxTypesDisplayAndroid(this@MainActivity, group.boxTypeId)" " setText(resolvedLabelForBoxTypeAndroid(this@MainActivity, group.label, typeDisplay, group.boxTypeId))" " selectAll()" " }" " val boxType = boxTypeInput().apply {" " hint = \"Box type id/name\"" - " setText(BoxTypes.display(this@MainActivity, group.boxTypeId), false)" + " setText(boxTypesDisplayAndroid(this@MainActivity, group.boxTypeId), false)" " }" " val firingArc = firingArcInput().apply {" " setText(group.firingArc, false)" @@ -8138,7 +8153,7 @@ " boxType.dismissDropDown()" " firingArc.dismissDropDown()" " dialog.dismiss()" - " val resolved = BoxTypes.resolve(this, boxTypeText)" + " val resolved = boxTypesResolveAndroid(this, boxTypeText)" " ssdSessionApplyEditedGroup(" " session," " group,"