Use typed object for SSD text watcher
ober
b84eb0b6b56624707267a1f9b5f5fee12891ebe5
--- a/.build.yml +++ b/.build.yml @@ -5,7 +5,7 @@ packages: - make=4.4.1-r4 sources: # Build dependency: full immutable commit, mirrored in dependencies.lock.json. - - "https://git.sr.ht/~lisp/jerboa#6d63174685d3b838c20b1b559e442e6d745ee03b" + - "https://git.sr.ht/~lisp/jerboa#3192be39569ab234ee7ffd3e2a7cf766ac1ae7ab" # The second source is the build subject selected by the SourceHut submitter. - https://git.sr.ht/~lisp/jerboa-android tasks: @@ -14,6 +14,6 @@ tasks: test "$(apk info -v chez-scheme)" = chez-scheme-10.3.0-r2 test "$(apk info -v git)" = git-2.54.0-r0 test "$(apk info -v make)" = make-4.4.1-r4 - test "$(git -C ../jerboa rev-parse HEAD)" = 6d63174685d3b838c20b1b559e442e6d745ee03b - test "$(git -C ../jerboa rev-parse 'HEAD^{tree}')" = 14b8c71a9b94bfa65dd0ef2aeb16f9db3b31aaec + test "$(git -C ../jerboa rev-parse HEAD)" = 3192be39569ab234ee7ffd3e2a7cf766ac1ae7ab + test "$(git -C ../jerboa rev-parse 'HEAD^{tree}')" = df37b61fef97a1800e17cf23edf34310f9f1107c JERBOA="chez --libdirs .:../jerboa/lib --script" make test --- a/dependencies.lock.json +++ b/dependencies.lock.json @@ -11,8 +11,8 @@ "generator_runtime": { "name": "jerboa", "repository": "https://git.sr.ht/~lisp/jerboa", - "commit": "6d63174685d3b838c20b1b559e442e6d745ee03b", - "tree": "14b8c71a9b94bfa65dd0ef2aeb16f9db3b31aaec" + "commit": "3192be39569ab234ee7ffd3e2a7cf766ac1ae7ab", + "tree": "df37b61fef97a1800e17cf23edf34310f9f1107c" }, "assurance_tools": { "osv_scanner": { --- a/scripts/verify-supply-chain.sh +++ b/scripts/verify-supply-chain.sh @@ -3,8 +3,8 @@ set -eu repo=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd -P) lock="$repo/dependencies.lock.json" -jerboa_commit=6d63174685d3b838c20b1b559e442e6d745ee03b # gitsafe:ignore -jerboa_tree=14b8c71a9b94bfa65dd0ef2aeb16f9db3b31aaec # gitsafe:ignore +jerboa_commit=3192be39569ab234ee7ffd3e2a7cf766ac1ae7ab # gitsafe:ignore +jerboa_tree=df37b61fef97a1800e17cf23edf34310f9f1107c # gitsafe:ignore gradle_sha=20f1b1176237254a6fc204d8434196fa11a4cfb387567519c61556e8710aed78 jdk_macos_sha=8fa1eff40bb637a33613b2ccb8b12c70dc3661cc22cf8e784943715769a05336 jdk_linux_sha=d8afc263758141a66e0e3aafc321e783f7016696f4eaea067d340a269037d331 --- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -4616,6 +4616,8 @@ (android database Cursor) (android net Uri) (android os ParcelFileDescriptor) + (android text Editable) + (android text TextWatcher) (android view View) (android view Window) (android widget AutoCompleteTextView) @@ -4741,6 +4743,8 @@ dialogReadyToShowDropdown focusedDialogReadyToShowDropdown autoCompleteInstallDropdownOpeners autoCompleteFocusAndShowDropdown + autoCompleteUpdateFiringArcVisibility + autoCompleteInstallFiringArcVisibilityWatcher buttonSetOnClickAction permissionResultGranted downloadAccessBeforeRuntimePermissions downloadAccessFromPermission activityResultRejected @@ -4792,6 +4796,8 @@ (type AlertDialog) (type AutoCompleteTextView) (type Button) + (type CharSequence) + (type Editable) (type File) (type InputStream) (type OutputStream) @@ -4808,6 +4814,7 @@ (type MainActivity) (type TruthStore) (type TextView) + (type TextWatcher) (type ViewportState) (extern (fileIsFile (file : File)) : Bool (kotlin-member-get isFile)) @@ -4839,6 +4846,15 @@ (extern (autoCompleteHasFocusRaw (view : AutoCompleteTextView)) : Bool (kotlin-member-call hasFocus)) + (extern (autoCompleteTextRaw + (view : AutoCompleteTextView)) : Editable + (kotlin-member-get text)) + (extern (editableToString (value : Editable)) : String + (kotlin-member-call toString)) + (extern (autoCompleteVisibilitySet + (view : AutoCompleteTextView) + (visibility : Int32)) : Unit + (kotlin-member-set visibility)) (extern (autoCompletePostRaw (view : AutoCompleteTextView) (callback : (-> Unit))) : Unit @@ -4856,10 +4872,18 @@ (view : AutoCompleteTextView) (listener : (-> View Bool Unit))) : Unit (kotlin-member-call setOnFocusChangeListener)) + (extern (autoCompleteAddTextChangedListenerRaw + (view : AutoCompleteTextView) + (watcher : TextWatcher)) : Unit + (kotlin-member-call addTextChangedListener)) (extern (buttonSetOnClickListenerRaw (button : Button) (listener : (-> View Unit))) : Unit (kotlin-member-call setOnClickListener)) + (extern (boxTypeRawIsWeaponFromActivity + (activity : MainActivity) + (raw : String)) : Bool + (kotlin-call boxTypeRawIsWeapon)) (extern (stringLines (text : String)) : (List String) (kotlin-member-call lines)) (extern (stringSplitTwoChars (text : String) @@ -6154,6 +6178,54 @@ (autoCompleteShowDropDownRaw view) (begin))) (int32 250)))) + (def (autoCompleteText (view : AutoCompleteTextView)) : String + (editableToString (autoCompleteTextRaw view))) + (def (autoCompleteVisibilityForVisible (visible : Bool)) : Int32 + (if visible (int32 0) (int32 8))) + (def (autoCompleteSetVisible + (view : AutoCompleteTextView) + (visible : Bool)) : Unit + (autoCompleteVisibilitySet + view + (autoCompleteVisibilityForVisible visible))) + (def (autoCompleteFiringArcVisible + (activity : MainActivity) + (boxType : AutoCompleteTextView) + (firingArc : AutoCompleteTextView)) : Bool + (shouldShowFiringArc + (autoCompleteText firingArc) + (boxTypeRawIsWeaponFromActivity + activity + (autoCompleteText boxType)))) + (def (autoCompleteUpdateFiringArcVisibility + (activity : MainActivity) + (boxType : AutoCompleteTextView) + (firingArc : AutoCompleteTextView)) : Unit + (autoCompleteSetVisible + firingArc + (autoCompleteFiringArcVisible activity boxType firingArc))) + (def (autoCompleteInstallFiringArcVisibilityWatcher + (activity : MainActivity) + (boxType : AutoCompleteTextView) + (firingArc : AutoCompleteTextView)) : Unit + (autoCompleteAddTextChangedListenerRaw + boxType + (object TextWatcher + (override (beforeTextChanged + (s : (Nullable CharSequence)) + (start : Int32) + (count : Int32) + (after : Int32)) : Unit + (begin)) + (override (onTextChanged + (s : (Nullable CharSequence)) + (start : Int32) + (before : Int32) + (count : Int32)) : Unit + (autoCompleteUpdateFiringArcVisibility activity boxType firingArc)) + (override (afterTextChanged + (s : (Nullable Editable))) : Unit + (begin))))) (def (buttonSetOnClickAction (button : Button) (action : (-> Unit))) : Unit @@ -7515,7 +7587,6 @@ "import android.provider.Settings" "import android.text.Editable" "import android.text.InputType" - "import android.text.TextWatcher" "import android.view.Gravity" "import android.view.HapticFeedbackConstants" "import android.view.View" @@ -7725,25 +7796,17 @@ " initialBoxType: String = \"\"" " ) {" " var previousBoxType = initialBoxType" - " fun update() {" - " val visible = shouldShowFiringArc(firingArc.text.toString(), boxTypeRawIsWeapon(this, boxType.text.toString()))" - " firingArc.visibility = if (visible) View.VISIBLE else View.GONE" - " }" - " boxType.addTextChangedListener(object : TextWatcher {" - " override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) = Unit" - " override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) = update()" - " override fun afterTextChanged(s: Editable?) = Unit" - " })" + " autoCompleteInstallFiringArcVisibilityWatcher(this, boxType, firingArc)" " boxType.setOnItemClickListener { _, _, _, _ ->" " replaceAutoLabelForBoxType(label, boxType.text.toString(), previousBoxType)" " previousBoxType = boxType.text.toString()" - " update()" + " autoCompleteUpdateFiringArcVisibility(this, boxType, firingArc)" " if (shouldFocusFiringArc(firingArc.text.toString(), boxTypeRawIsWeapon(this, boxType.text.toString()))) {" " firingArc.requestFocus()" " firingArc.showDropDown()" " }" " }" - " update()" + " autoCompleteUpdateFiringArcVisibility(this, boxType, firingArc)" " }" "" " private fun replaceAutoLabelForBoxType(label: EditText, boxType: String, previousBoxType: String) {"