Repository navigation
fix(compat): remove API 23/24 calls flagged by lint - #817
Merged
Merged
Conversation
HashMap.putIfAbsent (settings search map) and String.codePoints/IntStream (custom text styles parser) need API 24, and View.getRootWindowInsets in InputView needs API 23 on the pre-API-30 path. Use plain equivalents and a version guard so Android 6 and the offline flavor do not hit NoSuchMethodError.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Fixes the 4
NewApilint errors thatlintStandardDebugreports on main, plus one more that only the offline flavor (minSdk 21) reports.Motivation & Context
./gradlew :app:lintStandardDebugfailed with 4 errors. Core library desugaring is not enabled (isCoreLibraryDesugaringEnabledis unset), so these calls throwNoSuchMethodErroron older devices. CI runscompileOfflineRunTestsKotlinonly, so it never caught them.Changes Made
SettingsContainer.kt:HashMap.putIfAbsent(API 24, added with the settings-search jump in beta2) replaced withcontainsKey+put.UnicodeStyleEngine.kt:String.codePoints()andIntStream(API 24, from the custom text styles parser) replaced with acodePointAtloop. Without this, typing in the Custom text styles dialog would crash on Android 6.InputView.kt:View.rootWindowInsets(API 23) is now behind a version check on the pre-API-30 path; API 21-22 get their insets fromonApplyWindowInsets.Verification & Testing
CustomTextStylesTestpasseslintStandardDebug: 0 errors (was 4), warnings unchanged at 1258lintOfflineDebug: the InputView error is gone; the remaining ~295 offline errors (vector paths, long log tags,setForeground,Paint.hasGlyph) are unrelated and not touched hereGuidelines Checklist