Disable insets unless android >= 15

This commit is contained in:
Pieter Vander Vennet 2025-07-21 22:14:07 +02:00
parent 4bb7346a3b
commit bdbf551132

View file

@ -67,18 +67,20 @@ public class MainActivity extends BridgeActivity {
}); });
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
WindowCompat.setDecorFitsSystemWindows(getWindow(), false); var useInsets = Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE;
Databridge.addResponder("insets", (responder) -> { WindowCompat.setDecorFitsSystemWindows(getWindow(), useInsets);
var view = getWindow().getDecorView(); if(useInsets) {
var insets = view.getRootWindowInsets(); Databridge.addResponder("insets", (responder) -> {
var topInsetPxSize= insets.getInsetsIgnoringVisibility(WindowInsets.Type.statusBars()).top; var view = getWindow().getDecorView();
var bottomInsetPxSize= insets.getInsetsIgnoringVisibility(WindowInsets.Type.navigationBars()).bottom; var insets = view.getRootWindowInsets();
var topInsetPxSize = insets.getInsetsIgnoringVisibility(WindowInsets.Type.statusBars()).top;
var json = "{ \"top\": "+topInsetPxSize+", \"bottom\":"+bottomInsetPxSize+"}"; var bottomInsetPxSize = insets.getInsetsIgnoringVisibility(WindowInsets.Type.navigationBars()).bottom;
Log.i("insets","Inset sizes are:"+topInsetPxSize+" bottom:"+ bottomInsetPxSize);
Databridge.sendAnswerTo(responder, json);
});
var json = "{ \"top\": " + topInsetPxSize + ", \"bottom\":" + bottomInsetPxSize + "}";
Log.i("insets", "Inset sizes are:" + topInsetPxSize + " bottom:" + bottomInsetPxSize);
Databridge.sendAnswerTo(responder, json);
});
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
getOnBackInvokedDispatcher().registerOnBackInvokedCallback(OnBackInvokedDispatcher.PRIORITY_OVERLAY, getOnBackInvokedDispatcher().registerOnBackInvokedCallback(OnBackInvokedDispatcher.PRIORITY_OVERLAY,