Move SSD dialog window guard to typed Kotlin

ober

0a10c3186a1444513fc2dd8756822d2d89d65b2b

diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index 89d025e..4ab121e 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -4340,6 +4340,7 @@
                       (android database Cursor)
                       (android net Uri)
                       (android os ParcelFileDescriptor)
+                      (android view Window)
                       (androidx documentfile provider DocumentFile)
                       (org json JSONObject))
       (typed-library (com sfb ssdreview)
@@ -4402,6 +4403,7 @@
                 viewportScalePreferenceMissing
                 lastPdfUriMismatch lastViewportPageMismatch
                 cursorPresent parcelFileDescriptorPresent
+                setSoftInputModeIfWindowPresent
                 displayNameColumnPresent displayNameCursorHasFirstRow
                 currentLoadMatches currentLoadStale
                 packageUriText mediaStorePdfSelection
@@ -4439,6 +4441,7 @@
         (type Intent)
         (type Uri)
         (type ParcelFileDescriptor)
+        (type Window)
         (type DocumentFile)
         (type JSONObject)
         (type SsdSession)
@@ -4453,6 +4456,8 @@
           (kotlin-member-get isFile))
         (extern (documentFileDelete (file : DocumentFile)) : Bool
           (kotlin-member-call delete))
+        (extern (windowSetSoftInputMode (window : Window) (mode : Int32)) : Unit
+          (kotlin-member-call setSoftInputMode))
         (extern (stringLines (text : String)) : (List String)
           (kotlin-member-call lines))
         (extern (stringSplitTwoChars (text : String)
@@ -4572,6 +4577,11 @@
         (def (parcelFileDescriptorPresent
                (descriptor : (Nullable ParcelFileDescriptor))) : Bool
           (not (nullable-null? descriptor)))
+        (def (setSoftInputModeIfWindowPresent (window : (Nullable Window))
+                                              (mode : Int32)) : Unit
+          (if (nullable-null? window)
+            (begin)
+            (windowSetSoftInputMode (nullable-get window) mode)))
         (def (documentFilePresent (file : (Nullable DocumentFile))) : Bool
           (not (nullable-null? file)))
         (def (deleteDocumentFileIfPresent (file : (Nullable DocumentFile))) : Unit
@@ -6501,7 +6511,7 @@
        ""
        "    private fun focusBoxTypeDropdown(dialog: AlertDialog, boxType: AutoCompleteTextView) {"
        "        boxType.dropDownHeight = dropdownHeight(resources.displayMetrics.heightPixels)"
-       "        dialog.window?.setSoftInputMode("
+       "        setSoftInputModeIfWindowPresent(dialog.window,"
        "            android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE or"
        "                android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE"
        "        )"