Skip to content

Commit 3168db3

Browse files
authored
fix: [3909] Fixed regression in android async editing (#3910)
* fix: [3909] Fixed regression in android async editing Fixes #3909 Caused by #3905, which fixed #3904 * pegged to jupiter version that supports jdk8 * another attempt to fix junit dependency * attempt to fix junit dependencies * another attempt to fix junit dependencies
1 parent a87ef18 commit 3168db3

File tree

6 files changed

+63
-17
lines changed

6 files changed

+63
-17
lines changed

Ports/Android/src/com/codename1/impl/android/InPlaceEditView.java

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,16 +1376,14 @@ public void run() {
13761376
}
13771377
}
13781378

1379-
1380-
13811379
private static void setEditMode(final boolean resize) {
13821380
resizeMode = resize;
13831381

13841382
final Activity activity = sInstance.impl.getActivity();
13851383
final Window window = activity.getWindow();
13861384

13871385
if (resize) {
1388-
if (Build.VERSION.SDK_INT >= 34) {
1386+
if (Build.VERSION.SDK_INT >= 34 && isImmersive(window)) {
13891387
// On Android 14+, adjustResize doesn't work with immersive layouts
13901388
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
13911389
View rootView = window.getDecorView().findViewById(android.R.id.content);
@@ -1399,6 +1397,53 @@ private static void setEditMode(final boolean resize) {
13991397
}
14001398
}
14011399

1400+
private static boolean isImmersive(Window window) {
1401+
View decor = window.getDecorView();
1402+
1403+
// ---------- Modern branch : API 30+ ----------
1404+
if (Build.VERSION.SDK_INT >= 30) {
1405+
try {
1406+
// WindowInsets insets = decor.getRootWindowInsets();
1407+
Object insets = View.class
1408+
.getMethod("getRootWindowInsets")
1409+
.invoke(decor);
1410+
if (insets == null) return false;
1411+
1412+
// int mask = WindowInsets.Type.systemBars();
1413+
Class<?> typeCls =
1414+
Class.forName("android.view.WindowInsets$Type");
1415+
int systemBars = (Integer) typeCls
1416+
.getMethod("systemBars")
1417+
.invoke(null);
1418+
1419+
// boolean barsVisible = insets.isVisible(mask);
1420+
boolean barsVisible = (Boolean) insets.getClass()
1421+
.getMethod("isVisible", int.class)
1422+
.invoke(insets, systemBars);
1423+
1424+
/* --------------------------------------------------
1425+
* Edge-to-edge is guaranteed on API 35+ anyway, and
1426+
* `getDecorFitsSystemWindows()` no longer exists on
1427+
* API 36. We treat everything >=30 as edge-to-edge
1428+
* (decorFits = false) and only look at bar visibility
1429+
* to decide if we’re *immersive*.
1430+
* -------------------------------------------------- */
1431+
return !barsVisible; // immersive ⇢ bars are hidden
1432+
} catch (Throwable ignore) {
1433+
System.out.println("Error: " + ignore);
1434+
}
1435+
}
1436+
1437+
// ---------- Legacy branch : API 19-29 ----------
1438+
int f = decor.getSystemUiVisibility();
1439+
boolean immersiveBits =
1440+
(f & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0 ||
1441+
(f & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0;
1442+
boolean barsHidden =
1443+
(f & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0 &&
1444+
(f & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0;
1445+
return immersiveBits && barsHidden;
1446+
}
14021447

14031448
private static void applyImeInsetPaddingReflection(View rootView) {
14041449
try {

maven/codenameone-maven-plugin/pom.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,11 @@
127127
<dependency>
128128
<groupId>org.junit.jupiter</groupId>
129129
<artifactId>junit-jupiter-api</artifactId>
130-
<version>5.4.2</version>
131130
<scope>test</scope>
132131
</dependency>
133132
<dependency>
134133
<groupId>org.junit.jupiter</groupId>
135134
<artifactId>junit-jupiter-engine</artifactId>
136-
<version>5.4.2</version>
137135
<scope>test</scope>
138136
</dependency>
139137
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-vfs2 -->

maven/core-unittests/pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,16 @@
6565
<dependency>
6666
<groupId>junit</groupId>
6767
<artifactId>junit</artifactId>
68-
<version>RELEASE</version>
6968
<scope>test</scope>
7069
</dependency>
7170
<dependency>
7271
<groupId>org.junit.jupiter</groupId>
7372
<artifactId>junit-jupiter</artifactId>
74-
<version>RELEASE</version>
7573
<scope>test</scope>
7674
</dependency>
7775
<dependency>
7876
<groupId>org.junit.jupiter</groupId>
7977
<artifactId>junit-jupiter-params</artifactId>
80-
<version>RELEASE</version>
8178
<scope>test</scope>
8279
</dependency>
8380
<dependency>

maven/designer/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
<dependency>
116116
<groupId>org.junit.jupiter</groupId>
117117
<artifactId>junit-jupiter-engine</artifactId>
118-
<version>5.3.1</version>
119118
<scope>test</scope>
120119
</dependency>
121120

maven/pom.xml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
<cn1.binaries>${maven.multiModuleProjectDirectory}/target/cn1-binaries</cn1.binaries>
5353
<jaxb.version>2.3.1</jaxb.version>
5454
<cn1.build.client.path>${user.home}/.codenameone/CodeNameOneBuildClient.jar</cn1.build.client.path>
55+
<junit.jupiter.version>5.9.3</junit.jupiter.version>
56+
<junit.version>4.13.2</junit.version>
5557
</properties>
5658
<modules>
5759
<!--<module>codenameone-maven-goals</module>-->
@@ -69,6 +71,13 @@
6971
</modules>
7072
<dependencyManagement>
7173
<dependencies>
74+
<dependency>
75+
<groupId>org.junit</groupId>
76+
<artifactId>junit-bom</artifactId>
77+
<version>${junit.jupiter.version}</version>
78+
<type>pom</type>
79+
<scope>import</scope>
80+
</dependency>
7281
<dependency>
7382
<groupId>org.apache.maven</groupId>
7483
<artifactId>maven-model</artifactId>
@@ -193,12 +202,6 @@
193202
<artifactId>codenameone-factory</artifactId>
194203
<version>${project.version}</version>
195204
</dependency>
196-
<dependency>
197-
<groupId>junit</groupId>
198-
<artifactId>junit</artifactId>
199-
<version>4.13.1</version>
200-
<scope>test</scope>
201-
</dependency>
202205
<dependency>
203206
<groupId>org.apache.maven</groupId>
204207
<artifactId>maven-plugin-api</artifactId>
@@ -289,6 +292,12 @@
289292
<artifactId>jaxb-core</artifactId>
290293
<version>2.3.0.1</version>
291294
</dependency>
295+
<dependency>
296+
<groupId>junit</groupId>
297+
<artifactId>junit</artifactId>
298+
<scope>test</scope>
299+
<version>${junit.version}</version>
300+
</dependency>
292301
</dependencies>
293302
</dependencyManagement>
294303
<build>

maven/tests/mojo-tests/pom.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@
1717
<dependency>
1818
<groupId>org.junit.jupiter</groupId>
1919
<artifactId>junit-jupiter-api</artifactId>
20-
<version>5.4.2</version>
2120
<scope>test</scope>
2221
</dependency>
2322
<dependency>
2423
<groupId>org.junit.jupiter</groupId>
2524
<artifactId>junit-jupiter-engine</artifactId>
26-
<version>5.4.2</version>
2725
<scope>test</scope>
2826
</dependency>
2927
<dependency>

0 commit comments

Comments
 (0)