Class DynamicWindowUtils
java.lang.Object
com.pranavpandey.android.dynamic.util.DynamicWindowUtils
Helper class to perform window operations and to detect system configurations at runtime.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
Inset type to calculate the app usable screen size.static final int
Maximum height for the gesture navigation in DP. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Point
getAppUsableScreenSize
(Context context) Get the app usable screen size.static WindowMetrics
getCurrentWindowMetrics
(Context context) Returns the current window metrics for the supplied context.static Display
getDisplay
(Context context) Returns the correct display according to the different API levels.static float
getDisplayDensity
(Context context) Returns the display used by the supplied context.static DisplayMetrics
getDisplayMetrics
(Context context) Returns the display metrics for the supplied context.static Point
getNavigationBarSize
(Context context) Get the on-screen navigation bar size.static int
getOverlayFlag
(boolean alert) Get the overlay flag according to the Android version.static int
getOverlayFlag
(boolean alert, boolean accessibility) Get the overlay flag according to the Android version.static Point
getRealScreenSize
(Context context) Get the real screen size.static int
getScreenOrientation
(Context context) Get the current device orientation.static int
getStatusBarSize
(Context context) Get the status bar size.static boolean
isGestureNavigation
(Context context) Detects support for gesture navigation.static boolean
isNavigationBarPresent
(Context context) Detects if on-screen navigation bar is present or not.static boolean
isNavigationBarThemeSupported
(Context context) Detects support for navigation bar theme.static void
setEdgeToEdge
(Window window, boolean edgeToEdge) Set the hide navigation flag for edge-to-edge content on API 23 and above.static void
setShowWallpaper
(Window window, boolean showWallpaper) Set the show wallpaper flag for the supplied window.
-
Field Details
-
GESTURE_NAVIGATION_BAR_HEIGHT
public static final int GESTURE_NAVIGATION_BAR_HEIGHTMaximum height for the gesture navigation in DP.- See Also:
-
APP_USABLE_SCREEN_SIZE_INSETS
Inset type to calculate the app usable screen size.
-
-
Constructor Details
-
DynamicWindowUtils
public DynamicWindowUtils()
-
-
Method Details
-
getDisplay
Returns the correct display according to the different API levels.- Parameters:
context
- The context to be used.- Returns:
- The display according to the API level.
- See Also:
-
getDisplayMetrics
Returns the display metrics for the supplied context.- Parameters:
context
- The context to be used.- Returns:
- The display metrics for the supplied context.
- See Also:
-
getCurrentWindowMetrics
Returns the current window metrics for the supplied context.- Parameters:
context
- The context to be used.- Returns:
- The current window metrics for the supplied context.
- See Also:
-
getDisplayDensity
Returns the display used by the supplied context.- Parameters:
context
- The context to be used.- Returns:
- The display density used by the supplied context.
- See Also:
-
getAppUsableScreenSize
Get the app usable screen size.- Parameters:
context
- The context to be used.- Returns:
- The app usable screen size in point.
- See Also:
-
getRealScreenSize
Get the real screen size.- Parameters:
context
- The context to be used.- Returns:
- The real screen size in point.
- See Also:
-
getStatusBarSize
Get the status bar size.- Parameters:
context
- The context to get the resources.- Returns:
- The status bar size in pixels.
-
setShowWallpaper
Set the show wallpaper flag for the supplied window.This method must be called before window is created.
- Parameters:
window
- The window to be used.showWallpaper
-true
to show the wallpaper.- See Also:
-
setEdgeToEdge
Set the hide navigation flag for edge-to-edge content on API 23 and above.- Parameters:
window
- The window to be used.edgeToEdge
-true
to hide the layout navigation.
-
getScreenOrientation
Get the current device orientation.- Parameters:
context
- The context to be used.- Returns:
- The current activity orientation info.
- See Also:
-
getOverlayFlag
public static int getOverlayFlag(boolean alert, boolean accessibility) Get the overlay flag according to the Android version.- Parameters:
alert
-true
to return alert flag on API 25 and below.accessibility
-true
to return the accessibility overlay.- Returns:
- The
WindowManager
overlay flag according to the Android version. - See Also:
-
getOverlayFlag
public static int getOverlayFlag(boolean alert) Get the overlay flag according to the Android version.- Parameters:
alert
-true
to return alert flag on API 25 and below.- Returns:
- The
WindowManager
overlay flag according to the Android version. - See Also:
-