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);
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
Databridge.addResponder("insets", (responder) -> {
var view = getWindow().getDecorView();
var insets = view.getRootWindowInsets();
var topInsetPxSize= insets.getInsetsIgnoringVisibility(WindowInsets.Type.statusBars()).top;
var bottomInsetPxSize= insets.getInsetsIgnoringVisibility(WindowInsets.Type.navigationBars()).bottom;
var json = "{ \"top\": "+topInsetPxSize+", \"bottom\":"+bottomInsetPxSize+"}";
Log.i("insets","Inset sizes are:"+topInsetPxSize+" bottom:"+ bottomInsetPxSize);
Databridge.sendAnswerTo(responder, json);
});
var useInsets = Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE;
WindowCompat.setDecorFitsSystemWindows(getWindow(), useInsets);
if(useInsets) {
Databridge.addResponder("insets", (responder) -> {
var view = getWindow().getDecorView();
var insets = view.getRootWindowInsets();
var topInsetPxSize = insets.getInsetsIgnoringVisibility(WindowInsets.Type.statusBars()).top;
var bottomInsetPxSize = insets.getInsetsIgnoringVisibility(WindowInsets.Type.navigationBars()).bottom;
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) {
getOnBackInvokedDispatcher().registerOnBackInvokedCallback(OnBackInvokedDispatcher.PRIORITY_OVERLAY,