import android.os.Build;
import android.view.DisplayCutout;
public String get_cutout_safe_area()
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
{
DisplayCutout displayCutout = RunnerActivity.CurrentActivity.getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
if (displayCutout == null)
{
return "{\"detected\":0,\"top\":0,\"bottom\":0,\"left\":0,\"right\":0}";
}
else
{
int topPadding = displayCutout.getSafeInsetTop();
int bottomPadding = displayCutout.getSafeInsetBottom();
int leftPadding = displayCutout.getSafeInsetLeft();
int rightPadding = displayCutout.getSafeInsetRight();
return String.format("{\"detected\":1,\"top\":%d,\"bottom\":%d,\"left\":%d,\"right\":%d}", topPadding, bottomPadding, leftPadding, rightPadding);
}
}
else
{
return "{\"detected\":0,\"top\":0,\"bottom\":0,\"left\":0,\"right\":0}";
}
}
// to notify the game about rotation changes
int _screenRotation = -1;
public void onWindowFocusChanged(boolean hasFocus)
{
if (!hasFocus) return;
int newRotation = RunnerActivity.CurrentActivity.getWindowManager().getDefaultDisplay().getRotation();
if (newRotation != _screenRotation)
{
_screenRotation = newRotation;
int dsMapIndex = RunnerJNILib.jCreateDsMap(null, null, null);
RunnerJNILib.DsMapAddString( dsMapIndex, "type", "orientation_changed" );
RunnerJNILib.CreateAsynEventWithDSMap(dsMapIndex, EVENT_OTHER_SOCIAL);
}
}