mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-11-05 17:46:24 +00:00
Address review comments
This commit is contained in:
parent
cfda073aa5
commit
5e2ef7ff0d
@ -89,11 +89,11 @@ public final class DeviceUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDesktopMode(final Context context) {
|
public static boolean isDesktopMode(final Context context) {
|
||||||
final boolean isDesktopMode = ContextCompat.getSystemService(context, UiModeManager.class)
|
if (ContextCompat.getSystemService(context, UiModeManager.class)
|
||||||
.getCurrentModeType() == Configuration.UI_MODE_TYPE_DESK;
|
.getCurrentModeType() == Configuration.UI_MODE_TYPE_DESK) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
// DeX check for standalone and multi-window mode
|
// DeX check for standalone and multi-window mode
|
||||||
boolean isDeXMode = false;
|
|
||||||
try {
|
try {
|
||||||
final Configuration config = context.getResources().getConfiguration();
|
final Configuration config = context.getResources().getConfiguration();
|
||||||
final Class<?> configClass = config.getClass();
|
final Class<?> configClass = config.getClass();
|
||||||
@ -102,7 +102,7 @@ public final class DeviceUtils {
|
|||||||
final int currentMode =
|
final int currentMode =
|
||||||
configClass.getField("semDesktopModeEnabled").getInt(config);
|
configClass.getField("semDesktopModeEnabled").getInt(config);
|
||||||
if (semDesktopModeEnabledConst == currentMode) {
|
if (semDesktopModeEnabledConst == currentMode) {
|
||||||
isDeXMode = true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (final NoSuchFieldException | IllegalAccessException e) {
|
} catch (final NoSuchFieldException | IllegalAccessException e) {
|
||||||
// empty
|
// empty
|
||||||
@ -122,14 +122,14 @@ public final class DeviceUtils {
|
|||||||
final int enabled = (int) getEnabledMethod.invoke(desktopModeState);
|
final int enabled = (int) getEnabledMethod.invoke(desktopModeState);
|
||||||
if (enabled == desktopModeStateClass
|
if (enabled == desktopModeStateClass
|
||||||
.getDeclaredField("ENABLED").getInt(desktopModeStateClass)) {
|
.getDeclaredField("ENABLED").getInt(desktopModeStateClass)) {
|
||||||
isDeXMode = true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (NoSuchFieldException | NoSuchMethodException
|
} catch (NoSuchFieldException | NoSuchMethodException
|
||||||
| IllegalAccessException | InvocationTargetException e) {
|
| IllegalAccessException | InvocationTargetException e) {
|
||||||
// Device does not support DeX 3.0
|
// Device does not support DeX 3.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return isDesktopMode || isDeXMode;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isTablet(@NonNull final Context context) {
|
public static boolean isTablet(@NonNull final Context context) {
|
||||||
|
Loading…
Reference in New Issue
Block a user