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
FieldsModifier and TypeFieldDescriptionstatic intInset type to calculate the app usable screen size.static final intMaximum height for the gesture navigation in DP. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PointgetAppUsableScreenSize(Context context) Get the app usable screen size.static WindowMetricsgetCurrentWindowMetrics(Context context) Returns the current window metrics for the supplied context.static DisplaygetDisplay(Context context) Returns the correct display according to the different API levels.static floatgetDisplayDensity(Context context) Returns the display used by the supplied context.static DisplayMetricsgetDisplayMetrics(Context context) Returns the display metrics for the supplied context.static PointgetNavigationBarSize(Context context) Get the on-screen navigation bar size.static intgetOverlayFlag(boolean alert) Get the overlay flag according to the Android version.static intgetOverlayFlag(boolean alert, boolean accessibility) Get the overlay flag according to the Android version.static PointgetRealScreenSize(Context context) Get the real screen size.static intgetScreenOrientation(Context context) Get the current device orientation.static intgetStatusBarSize(Context context) Get the status bar size.static booleanisGestureNavigation(Context context) Detects support for gesture navigation.static booleanisNavigationBarPresent(Context context) Detects if on-screen navigation bar is present or not.static booleanisNavigationBarThemeSupported(Context context) Detects support for navigation bar theme.static voidsetEdgeToEdge(Window window, boolean edgeToEdge) Set the hide navigation flag for edge-to-edge content on API 23 and above.static voidsetShowWallpaper(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-trueto 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-trueto 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-trueto return alert flag on API 25 and below.accessibility-trueto return the accessibility overlay.- Returns:
- The
WindowManageroverlay 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-trueto return alert flag on API 25 and below.- Returns:
- The
WindowManageroverlay flag according to the Android version. - See Also:
-