Move SSD truth apply pruning to typed Kotlin

ober

edc9000362c70bde1f23ef55c30d4d2132351132

diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index 17371b6..7e83a5f 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -4669,6 +4669,7 @@
                 mainActivityAdvanceLoadGeneration
                 mainActivitySetTruthStore mainActivitySetStatusView
                 mainActivitySetReviewView
+                truthStoreApplyTruthAndPrune
                 ssdBrowserResumeReady focusChangeShouldShowDropdown
                 dialogReadyToShowDropdown focusedDialogReadyToShowDropdown
                 permissionResultGranted downloadAccessBeforeRuntimePermissions
@@ -4765,6 +4766,9 @@
         (extern (truthStoreApplyLearnedGuesses (store : TruthStore)
                                                (session : SsdSession)) : Int32
           (kotlin-member-call applyLearnedGuesses))
+        (extern (truthStoreApplyTruth (store : TruthStore)
+                                      (session : SsdSession)) : Unit
+          (kotlin-member-call applyTruth))
         (extern (reviewViewCaptureViewport (view : SsdReviewView)) : (Nullable ViewportState)
           (kotlin-member-call captureViewport))
         (extern (reviewViewSelectedGroupIdSet (view : SsdReviewView)
@@ -5573,6 +5577,13 @@
         (def (mainActivitySetReviewView (activity : MainActivity)
                                         (view : SsdReviewView)) : Unit
           (mainActivityReviewViewSet activity view))
+        (def (truthStoreApplyTruthAndPrune
+               (store : TruthStore)
+               (session : SsdSession)) : Unit
+          (begin
+            (truthStoreApplyTruth store session)
+            (ssdSessionPruneGroupsOutsideSsdArea session)
+            (begin)))
         (def (shouldCaptureViewport (includeViewport : Bool)) : Bool
           includeViewport)
         (def (viewportForSave (view : SsdReviewView)
@@ -7567,8 +7578,7 @@
        "                val localTruth = localTruthForDetection(truthStore, session, forceDetect)"
 	       "                val localGroupCount = nullableTruthGroupCount(localTruth)"
 	       "                if (truthGroupCountAtLeast(localGroupCount, FAST_TRUTH_GROUP_THRESHOLD)) {"
-	       "                    truthStore.applyTruth(session)"
-	      "                    ssdSessionPruneGroupsOutsideSsdArea(session)"
+	       "                    truthStoreApplyTruthAndPrune(truthStore, session)"
 	       "                    runOnUiThread {"
        "                        if (isStaleLoad(expectedGeneration, uri, expectedPageIndex)) return@runOnUiThread"
 	       "                        mainActivityShowSession(this, reviewView, session)"
@@ -7589,8 +7599,7 @@
        "                if (shouldUseExistingTruthObject(existingTruth, existingTruthGroupCount, forceDetect)) {"
        "                    detectorSource = \"local-truth\""
        "                    copyExistingTruthSsdArea(session, existingTruth)"
-       "                    truthStore.applyTruth(session)"
-       "                    ssdSessionPruneGroupsOutsideSsdArea(session)"
+       "                    truthStoreApplyTruthAndPrune(truthStore, session)"
        "                } else {"
        "                    copyExistingTruthSsdArea(session, existingTruth)"
        "                    val nativeDetection = SsdVisionBridge.detect(bitmap)"
@@ -7607,8 +7616,7 @@
        "                    ssdSessionAddDetectedCellsInsideArea(session, detectedCells)"
        "                    ssdSessionAddInitialGroups(session, 120)"
        "                    if (shouldApplyExistingTruthObject(existingTruth, existingTruthGroupCount)) {"
-       "                        truthStore.applyTruth(session)"
-       "                        ssdSessionPruneGroupsOutsideSsdArea(session)"
+       "                        truthStoreApplyTruthAndPrune(truthStore, session)"
        "                    }"
        "                    applyInitialGuesses(this, session)"
        "                    ssdSessionAddOcrWords(session, SsdOcr.recognizeWords(bitmap))"
@@ -7654,8 +7662,7 @@
        "            val loadedTruth = truthJsonObjectOrEmpty(truth)"
        "            val merged = makeRemoteTruthMergeSession(session)"
        "            copyLoadedTruthSsdArea(merged, loadedTruth)"
-       "            truthStore.applyTruth(merged)"
-       "            ssdSessionPruneGroupsOutsideSsdArea(merged)"
+       "            truthStoreApplyTruthAndPrune(truthStore, merged)"
        "            runOnUiThread {"
        "                if (isStaleLoad(generation, uri, page)) return@runOnUiThread"
        "                mainActivityShowSession(this, reviewView, merged)"