Skip to content

Commit adafcc8

Browse files
authored
fix(android): make onConfigurationChanged param non-nullable (#1472)
## Description Android's `View.onConfigurationChanged(@nonnull Configuration newConfig)` is now strictly enforced as non-null by Kotlin under the compileSdk shipped with React Native 0.86. The overrides in `EdgeToEdgeReactViewGroup` and `KeyboardBackgroundViewGroup` declared the parameter as `Configuration?`, which no longer matches the parent signature and breaks the build: ``` e: EdgeToEdgeReactViewGroup.kt:97 'onConfigurationChanged' overrides nothing. Potential signatures for overriding: fun onConfigurationChanged(newConfig: Configuration): Unit e: KeyboardBackgroundViewGroup.kt:20 'onConfigurationChanged' overrides nothing. e: KeyboardBackgroundViewGroup.kt:21 Argument type mismatch: actual type is 'Configuration?', but 'Configuration' was expected. ``` Dropping the `?` matches the parent signature. The change is backwards-compatible with older React Native / compileSdk versions because the parent method is exposed there as a Kotlin platform type (`Configuration!`), which accepts a non-nullable override. ## 💡 Motivation and Context - react-native 0.86 support ## 📢 Changelog ### Android - Make `onConfigurationChanged` param non-nullable ## 🤔 How Has This Been Tested? - Android build (`./gradlew :react-native-keyboard-controller:compileReleaseKotlin`) succeeds against React Native 0.86 - Android build still succeeds against the previously supported React Native versions - Theme change still triggers `setBackgroundColor` / `reApplyWindowInsets` at runtime ## 📸 Screenshots (if appropriate): <!-- Add screenshots/video if needed --> <!-- That would be highly appreciated if you can add how it looked before and after your changes --> ## 📝 Checklist - [ ] CI successfully passed - [ ] I added new mocks and corresponding unit-tests if library API was changed
1 parent ac72bda commit adafcc8

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

android/src/main/java/com/reactnativekeyboardcontroller/views/EdgeToEdgeReactViewGroup.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class EdgeToEdgeReactViewGroup(
9494
this.deactivate()
9595
}
9696

97-
override fun onConfigurationChanged(newConfig: Configuration?) {
97+
override fun onConfigurationChanged(newConfig: Configuration) {
9898
this.reApplyWindowInsets()
9999
}
100100
// endregion

android/src/main/java/com/reactnativekeyboardcontroller/views/background/KeyboardBackgroundViewGroup.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class KeyboardBackgroundViewGroup(
1717
}
1818

1919
// theme changed
20-
override fun onConfigurationChanged(newConfig: Configuration?) {
20+
override fun onConfigurationChanged(newConfig: Configuration) {
2121
super.onConfigurationChanged(newConfig)
2222
super.setBackgroundColor(reactContext.getInputMethodColor())
2323
}

0 commit comments

Comments
 (0)