Skip to content

Commit efd6dd9

Browse files
committed
Enable edge-to-edge only on android 15+
1 parent 7838145 commit efd6dd9

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

app/src/main/java/org/bspb/smartbirds/pro/ui/BaseActivity.java

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,31 @@ public void onServiceDisconnected(ComponentName name) {
3737
@Override
3838
protected void onCreate(Bundle savedInstanceState) {
3939
super.onCreate(savedInstanceState);
40-
EdgeToEdge.enable(
41-
this,
42-
androidx.activity.SystemBarStyle.light(
43-
android.graphics.Color.TRANSPARENT,
44-
android.graphics.Color.TRANSPARENT
45-
)
46-
);
40+
if (shouldEnableEdgeToEdge()) {
41+
EdgeToEdge.enable(
42+
this,
43+
androidx.activity.SystemBarStyle.light(
44+
android.graphics.Color.TRANSPARENT,
45+
android.graphics.Color.TRANSPARENT
46+
)
47+
);
48+
}
49+
}
50+
51+
/**
52+
* Determine if edge-to-edge should be enabled for this activity.
53+
* Override in subclasses to customize behavior.
54+
*
55+
* Note: Edge-to-edge is only enabled on Android 15+ (API 35+) where it's natively
56+
* supported. The backported implementation on older Android versions has compatibility
57+
* issues with Espresso instrumented tests (view visibility calculations fail).
58+
*
59+
* @return true to enable edge-to-edge, false otherwise
60+
*/
61+
protected boolean shouldEnableEdgeToEdge() {
62+
// Only enable on Android 15+ where edge-to-edge is native and Espresso-compatible
63+
// On older versions, the AndroidX backport causes Espresso PerformException
64+
return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.VANILLA_ICE_CREAM;
4765
}
4866

4967
@Override

0 commit comments

Comments
 (0)