package funkin.external.android; #if android import lime.math.Rectangle; import lime.system.JNI; /** * A Utility class to get Android screen related informations. */ @:unreflective class ScreenUtil { /** * Retrieves the dimensions of display cutouts (such as notches) on Android devices. * * @return An array of `Rectangle` objects, each representing a display cutout's position and size. */ public static function getCutoutDimensions():Array { final getCutoutDimensionsJNI:Null = JNIUtil.createStaticMethod('funkin/util/ScreenUtil', 'getCutoutDimensions', '()[Landroid/graphics/Rect;'); if (getCutoutDimensionsJNI != null) { final rectangles:Array = []; for (rectangle in cast(getCutoutDimensionsJNI(), Array)) { if (rectangle == null) continue; final topJNI:Null = JNIUtil.createMemberField('android/graphics/Rect', 'top', 'I'); final leftJNI:Null = JNIUtil.createMemberField('android/graphics/Rect', 'left', 'I'); final rightJNI:Null = JNIUtil.createMemberField('android/graphics/Rect', 'right', 'I'); final bottomJNI:Null = JNIUtil.createMemberField('android/graphics/Rect', 'bottom', 'I'); if (topJNI != null && leftJNI != null && rightJNI != null && bottomJNI != null) { final top:Int = topJNI.get(rectangle); final left:Int = leftJNI.get(rectangle); final right:Int = rightJNI.get(rectangle); final bottom:Int = bottomJNI.get(rectangle); rectangles.push(new Rectangle(left, top, right - left, bottom - top)); } } return rectangles; } return []; } } #end