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:
parent
622133ace2
commit
2ce9140c6c
@ -83,34 +83,9 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
|
|||||||
int types = WindowInsets.Type.displayCutout() | WindowInsets.Type.systemBars();
|
int types = WindowInsets.Type.displayCutout() | WindowInsets.Type.systemBars();
|
||||||
safeInsets = insets.getInsets(types);
|
safeInsets = insets.getInsets(types);
|
||||||
} else {
|
} else {
|
||||||
int left = 0;
|
safeInsets = getSafeInsetsPreAndroidR(view, insets);
|
||||||
int top = 0;
|
|
||||||
int right = 0;
|
|
||||||
int bottom = 0;
|
|
||||||
|
|
||||||
int visibility = view.getSystemUiVisibility();
|
|
||||||
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
|
|
||||||
left = insets.getSystemWindowInsetLeft();
|
|
||||||
top = insets.getSystemWindowInsetTop();
|
|
||||||
right = insets.getSystemWindowInsetRight();
|
|
||||||
bottom = insets.getSystemWindowInsetBottom();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Android 9 and 10 emulators don't seem to be able
|
|
||||||
// to handle this, but let's have the logic here anyway
|
|
||||||
DisplayCutout cutout = insets.getDisplayCutout();
|
|
||||||
if (cutout != null) {
|
|
||||||
left = Math.max(left, cutout.getSafeInsetLeft());
|
|
||||||
top = Math.max(top, cutout.getSafeInsetTop());
|
|
||||||
right = Math.max(right, cutout.getSafeInsetRight());
|
|
||||||
bottom = Math.max(bottom, cutout.getSafeInsetBottom());
|
|
||||||
}
|
|
||||||
|
|
||||||
safeInsets = Insets.of(left, top, right, bottom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QtNative.runAction(() -> safeAreaMarginsChanged(safeInsets, getId()));
|
QtNative.runAction(() -> safeAreaMarginsChanged(safeInsets, getId()));
|
||||||
|
|
||||||
return insets;
|
return insets;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -118,6 +93,35 @@ class QtWindow extends QtLayout implements QtSurfaceInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
Insets getSafeInsetsPreAndroidR(View view, WindowInsets insets)
|
||||||
|
{
|
||||||
|
int left = 0;
|
||||||
|
int top = 0;
|
||||||
|
int right = 0;
|
||||||
|
int bottom = 0;
|
||||||
|
|
||||||
|
int visibility = view.getSystemUiVisibility();
|
||||||
|
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
|
||||||
|
left = insets.getSystemWindowInsetLeft();
|
||||||
|
top = insets.getSystemWindowInsetTop();
|
||||||
|
right = insets.getSystemWindowInsetRight();
|
||||||
|
bottom = insets.getSystemWindowInsetBottom();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Android 9 and 10 emulators don't seem to be able
|
||||||
|
// to handle this, but let's have the logic here anyway
|
||||||
|
DisplayCutout cutout = insets.getDisplayCutout();
|
||||||
|
if (cutout != null) {
|
||||||
|
left = Math.max(left, cutout.getSafeInsetLeft());
|
||||||
|
top = Math.max(top, cutout.getSafeInsetTop());
|
||||||
|
right = Math.max(right, cutout.getSafeInsetRight());
|
||||||
|
bottom = Math.max(bottom, cutout.getSafeInsetBottom());
|
||||||
|
}
|
||||||
|
|
||||||
|
return Insets.of(left, top, right, bottom);
|
||||||
|
}
|
||||||
|
|
||||||
@UsedFromNativeCode
|
@UsedFromNativeCode
|
||||||
void setVisible(boolean visible) {
|
void setVisible(boolean visible) {
|
||||||
QtNative.runAction(() -> {
|
QtNative.runAction(() -> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user