From 5e2ef7ff0d3c95df191e857ab329c67b8a77f9db Mon Sep 17 00:00:00 2001 From: Hanif Shersy Date: Tue, 3 May 2022 09:49:11 +1000 Subject: [PATCH] Address review comments --- .../java/org/schabi/newpipe/util/DeviceUtils.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java b/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java index 102541d64..c4d3a7bbf 100644 --- a/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java +++ b/app/src/main/java/org/schabi/newpipe/util/DeviceUtils.java @@ -89,11 +89,11 @@ public final class DeviceUtils { } public static boolean isDesktopMode(final Context context) { - final boolean isDesktopMode = ContextCompat.getSystemService(context, UiModeManager.class) - .getCurrentModeType() == Configuration.UI_MODE_TYPE_DESK; - + if (ContextCompat.getSystemService(context, UiModeManager.class) + .getCurrentModeType() == Configuration.UI_MODE_TYPE_DESK) { + return true; + } // DeX check for standalone and multi-window mode - boolean isDeXMode = false; try { final Configuration config = context.getResources().getConfiguration(); final Class configClass = config.getClass(); @@ -102,7 +102,7 @@ public final class DeviceUtils { final int currentMode = configClass.getField("semDesktopModeEnabled").getInt(config); if (semDesktopModeEnabledConst == currentMode) { - isDeXMode = true; + return true; } } catch (final NoSuchFieldException | IllegalAccessException e) { // empty @@ -122,14 +122,14 @@ public final class DeviceUtils { final int enabled = (int) getEnabledMethod.invoke(desktopModeState); if (enabled == desktopModeStateClass .getDeclaredField("ENABLED").getInt(desktopModeStateClass)) { - isDeXMode = true; + return true; } } catch (NoSuchFieldException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { // Device does not support DeX 3.0 } } - return isDesktopMode || isDeXMode; + return false; } public static boolean isTablet(@NonNull final Context context) {