fix(android): implement automatic edge-to-edge and universal keyboard handling#8366
Open
fabiomartino wants to merge 5 commits intoionic-team:mainfrom
Open
fix(android): implement automatic edge-to-edge and universal keyboard handling#8366fabiomartino wants to merge 5 commits intoionic-team:mainfrom
fabiomartino wants to merge 5 commits intoionic-team:mainfrom
Conversation
|
@fabiomartino Thank you so much Fabio. This is such a crucial fix I'm waiting for. 🙏 |
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
This PR implements universal safe-area and edge-to-edge support for Android, resolving issues where the implementation was gated to Android 15+ only (
VANILLA_ICE_CREAM). The fix works on Android 6+ (API 21+) while maintaining backward compatibility.Key Changes
Removed Android 15+ restriction: Changed
Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAMtoMIN_INSETS_VERSION = Build.VERSION_CODES.LOLLIPOP(API 21)Automatic edge-to-edge: Added
enableEdgeToEdgeIfNeeded()method using reflection to callandroidx.activity.EdgeToEdge.enable()- no MainActivity modification requiredImproved broken WebView handling:
Lifecycle fixes:
handleOnResume()to re-apply insets after returning from external activitiesviewport-fit=coveris not presentUniversal keyboard handling: IME visibility is now monitored on ALL Android versions (not just 15+)
Issues Resolved
Testing
Tested on:
Behavior
WebView >= 140
--safe-area-inset-*are injected with correct valuesWebView < 140 (Broken WebView)
--safe-area-inset-bottomforced to 0 (to avoid double-offset with fixed footers)Keyboard State
--safe-area-inset-bottomreflects keyboard heightConfiguration
Default configuration works automatically. Optional configuration in
capacitor.config.ts:Breaking Changes
None. This is a bug fix that expands functionality to older Android versions while maintaining existing behavior on Android 15+.
Migration
No migration required. Existing configurations continue to work.
Additional Notes
EdgeToEdge.enable()to maintain backward compatibility without requiring additional dependencies