use of android.view.DisplayCutout in project robolectric by robolectric.
the class ShadowWindowManagerImpl method getWindowInsetsFromServer.
/**
* Re implement to avoid server call
*/
@Implementation(minSdk = R)
protected WindowInsets getWindowInsetsFromServer(WindowManager.LayoutParams attrs, Rect bounds) {
Context context = reflector(ReflectorWindowManagerImpl.class, realObject).getContext();
final Rect systemWindowInsets = new Rect();
final Rect stableInsets = new Rect();
final DisplayCutout.ParcelableWrapper displayCutout = new DisplayCutout.ParcelableWrapper();
final InsetsState insetsState = new InsetsState();
final boolean alwaysConsumeSystemBars = true;
final boolean isScreenRound = context.getResources().getConfiguration().isScreenRound();
if (getApiLevel() <= R && reflector(ViewRootImplReflector.class).getNewInsetsMode() == NEW_INSETS_MODE_FULL) {
return ReflectionHelpers.callInstanceMethod(insetsState, "calculateInsets", ClassParameter.from(Rect.class, bounds), null, ClassParameter.from(Boolean.TYPE, isScreenRound), ClassParameter.from(Boolean.TYPE, alwaysConsumeSystemBars), ClassParameter.from(DisplayCutout.ParcelableWrapper.class, displayCutout.get()), ClassParameter.from(int.class, SOFT_INPUT_ADJUST_NOTHING), ClassParameter.from(int.class, SYSTEM_UI_FLAG_VISIBLE), null);
} else {
return new WindowInsets.Builder().setAlwaysConsumeSystemBars(alwaysConsumeSystemBars).setRound(isScreenRound).setSystemWindowInsets(Insets.of(systemWindowInsets)).setStableInsets(Insets.of(stableInsets)).setDisplayCutout(displayCutout.get()).build();
}
}
use of android.view.DisplayCutout in project UIWidget by AriesHoo.
the class NotchUtil method attachHasOfficialNotch.
/**
* @param view
* @return false indicates the failure to get the result
*/
@TargetApi(28)
private static boolean attachHasOfficialNotch(View view) {
WindowInsets windowInsets = view.getRootWindowInsets();
if (windowInsets != null) {
DisplayCutout displayCutout = windowInsets.getDisplayCutout();
sHasNotch = displayCutout != null;
return true;
} else {
// view not attached, do nothing
return false;
}
}
use of android.view.DisplayCutout in project var3dframe by Var3D.
the class VAndroidLauncher method getSafeAreaInsets.
public Rectangle getSafeAreaInsets() {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
final View decorView = getWindow().getDecorView();
WindowInsets rootWindowInsets = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
rootWindowInsets = decorView.getRootWindowInsets();
}
if (rootWindowInsets == null) {
return rectangle;
}
DisplayCutout displayCutout = null;
if (android.os.Build.VERSION.SDK_INT >= 28) {
displayCutout = rootWindowInsets.getDisplayCutout();
if (displayCutout != null) {
rectangle.set(displayCutout.getSafeInsetLeft(), displayCutout.getSafeInsetBottom(), displayCutout.getSafeInsetRight(), displayCutout.getSafeInsetTop());
}
}
}
return rectangle;
}
use of android.view.DisplayCutout in project Android-skin-support by ximsfei.
the class SkinNotchUtils method attachHasOfficialNotch.
/**
* @param view
* @return false indicates the failure to get the result
*/
@TargetApi(28)
private static boolean attachHasOfficialNotch(View view) {
WindowInsets windowInsets = view.getRootWindowInsets();
if (windowInsets != null) {
DisplayCutout displayCutout = windowInsets.getDisplayCutout();
sHasNotch = displayCutout != null;
return true;
} else {
// view not attached, do nothing
return false;
}
}
use of android.view.DisplayCutout in project QMUI_Android by Tencent.
the class QMUINotchHelper method attachHasOfficialNotch.
/**
* @param view
* @return false indicates the failure to get the result
*/
@TargetApi(28)
private static boolean attachHasOfficialNotch(View view) {
WindowInsets windowInsets = view.getRootWindowInsets();
if (windowInsets != null) {
DisplayCutout displayCutout = windowInsets.getDisplayCutout();
sHasNotch = displayCutout != null;
return true;
} else {
// view not attached, do nothing
return false;
}
}
Aggregations