Move SSD saved viewport match checks to typed Kotlin
ober
6f95aa4a42fcfdd10e9ca5441717db888d54740a
--- a/templates/ssd-review.ss +++ b/templates/ssd-review.ss @@ -4561,6 +4561,7 @@ shouldPersistLoadedPdfState viewportScalePreferencePresent viewportScalePreferenceMissing lastPdfUriMismatch lastViewportPageMismatch + savedViewportAvailable cursorPresent parcelFileDescriptorPresent setSoftInputModeIfWindowPresent displayNameColumnPresent displayNameCursorHasFirstRow @@ -5173,6 +5174,14 @@ (not (equal? (nullable-get saved) uriText)))) (def (lastViewportPageMismatch (savedPage : Int32) (page : Int32)) : Bool (not (= savedPage page))) + (def (savedViewportAvailable (savedUri : (Nullable String)) + (uriText : String) + (savedPage : Int32) + (page : Int32) + (scalePresent : Bool)) : Bool + (and (not (lastPdfUriMismatch savedUri uriText)) + (and (not (lastViewportPageMismatch savedPage page)) + (viewportScalePreferencePresent scalePresent)))) (def (displayNameColumnPresent (columnIndex : Int32)) : Bool (>= columnIndex (int32 0))) (def (displayNameCursorHasFirstRow (hasFirstRow : Bool)) : Bool @@ -7902,9 +7911,7 @@ "" " private fun restoredViewportFor(uri: Uri, page: Int): ViewportState? {" " val prefs = getPreferences(MODE_PRIVATE)" - " if (lastPdfUriMismatch(prefs.getString(PREF_LAST_PDF_URI, null), uri.toString())) return null" - " if (lastViewportPageMismatch(prefs.getInt(PREF_LAST_VIEWPORT_PAGE_INDEX, -1), page)) return null" - " if (viewportScalePreferenceMissing(prefs.contains(PREF_LAST_VIEWPORT_SCALE))) return null" + " if (!savedViewportAvailable(prefs.getString(PREF_LAST_PDF_URI, null), uri.toString(), prefs.getInt(PREF_LAST_VIEWPORT_PAGE_INDEX, -1), page, prefs.contains(PREF_LAST_VIEWPORT_SCALE))) return null" " return ViewportState(" " prefs.getFloat(PREF_LAST_VIEWPORT_SCALE, 1f)," " prefs.getFloat(PREF_LAST_VIEWPORT_OFFSET_X, 0f),"