GitToTheHub commented on code in PR #1924:
URL: https://github.com/apache/cordova-android/pull/1924#discussion_r3252778520
##########
framework/src/org/apache/cordova/CordovaActivity.java:
##########
@@ -222,16 +222,24 @@ protected void createViews() {
Insets bars = insets.getInsets(
WindowInsetsCompat.Type.systemBars() |
WindowInsetsCompat.Type.displayCutout()
);
+ Insets ime = insets.getInsets(WindowInsetsCompat.Type.ime());
boolean isStatusBarVisible = statusBarView.getVisibility() !=
View.GONE;
int top = isStatusBarVisible && !canEdgeToEdge && !isFullScreen ?
bars.top : 0;
- int bottom = !canEdgeToEdge && !isFullScreen ? bars.bottom : 0;
int left = !canEdgeToEdge && !isFullScreen ? bars.left : 0;
int right = !canEdgeToEdge && !isFullScreen ? bars.right : 0;
+ int bottom = 0;
+ if (!isFullScreen) {
+ bottom = !canEdgeToEdge ? Math.max(bars.bottom, ime.bottom) :
ime.bottom;
Review Comment:
Ok I never had know, that this should be avoided. For me it depends always
on the code itself if it makes sense to use a nested ternary operator or not.
It should always improve readability. For e.g. this nested ternary operator,
shown as an example on
https://docs.openrewrite.org/recipes/staticanalysis/ternaryoperatorsshouldnotbenested,
makes the code really not easy to read:
```java
"a".equals(a) ? "a" : "b".equals(a) ? "b" : "nope";
```
but in this context, it makes it easier to read:
```java
Insets imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime());
// When in fullscreen mode, we ignore bottom system insets (like the
navigation bar)
// to allow the WebView to span the entire screen and avoid being pushed up.
int bottom = isFullScreen ? 0 : canEdgeToEdge ? imeInsets.bottom :
Math.max(bars.bottom, imeInsets.bottom);
```
instead of
```java
int bottom = 0;
Insets imeInsets = insets.getInsets(WindowInsetsCompat.Type.ime());
// When in fullscreen mode, we ignore bottom system insets (like the
navigation bar)
// to allow the WebView to span the entire screen and avoid being pushed up.
if (!isFullScreen) {
bottom = canEdgeToEdge ? imeInsets.bottom : Math.max(bars.bottom,
imeInsets.bottom);
}
```
Also the bottom variable is a one-liner and could be grouped together with
the other assignments.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]