Android: suppress deprecation warning for safe area APIs before Android R

We already handle both cases of pre and post Android R APIs, so  we can
safely suppress the code using older API after extracting it to its own
method.

Change-Id: I3f5d6dab480c5fb32d35f615db719a4a0eb3f45d
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
This commit is contained in:
Assam Boudjelthia 2025-01-07 18:33:29 +02:00
parent 622133ace2
commit 2ce9140c6c

View File

@ -83,6 +83,19 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
int types = WindowInsets.Type.displayCutout() | WindowInsets.Type.systemBars();
safeInsets = insets.getInsets(types);
} else {
safeInsets = getSafeInsetsPreAndroidR(view, insets);
}
QtNative.runAction(() -> safeAreaMarginsChanged(safeInsets, getId()));
return insets;
});
QtNative.runAction(() -> requestApplyInsets());
}
}
@SuppressWarnings("deprecation")
Insets getSafeInsetsPreAndroidR(View view, WindowInsets insets)
{
int left = 0;
int top = 0;
int right = 0;
@ -106,16 +119,7 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
bottom = Math.max(bottom, cutout.getSafeInsetBottom());
}
safeInsets = Insets.of(left, top, right, bottom);
}
QtNative.runAction(() -> safeAreaMarginsChanged(safeInsets, getId()));
return insets;
});
QtNative.runAction(() -> requestApplyInsets());
}
return Insets.of(left, top, right, bottom);
}
@UsedFromNativeCode