/** * Returns the current display saturation level set via {@link * android.hardware.display.DisplayManager#setSaturationLevel(float)}. */ public float getSaturationLevel() { return getShadowDisplayManagerGlobal().getSaturationLevel(); }
/** * Removes a simulated display. * * @param displayId the display id to remove */ public static void removeDisplay(int displayId) { getShadowDisplayManagerGlobal().removeDisplay(displayId); }
/** * Adds a simulated display. * * @param qualifiersStr the {@link Qualifiers} string representing characteristics of the new * display. * @return the new display's ID */ public static int addDisplay(String qualifiersStr) { return getShadowDisplayManagerGlobal().addDisplay(createDisplayInfo(qualifiersStr, null)); }
/** internal only */ public static void configureDefaultDisplay(Configuration configuration, DisplayMetrics displayMetrics) { ShadowDisplayManagerGlobal shadowDisplayManagerGlobal = getShadowDisplayManagerGlobal(); if (DisplayManagerGlobal.getInstance().getDisplayIds().length != 0) { throw new IllegalStateException("this method should only be called by Robolectric"); } shadowDisplayManagerGlobal.addDisplay(createDisplayInfo(configuration, displayMetrics)); }
/** * Changes properties of a simulated display. If `qualifiersStr` starts with a plus (`+`) sign, * the display's previous configuration is modified with the given qualifiers; otherwise defaults * are applied as described [here](http://robolectric.org/device-configuration/). * * * @param displayId the display id to change * @param qualifiersStr the {@link Qualifiers} string representing characteristics of the new * display */ public static void changeDisplay(int displayId, String qualifiersStr) { DisplayInfo baseDisplayInfo = DisplayManagerGlobal.getInstance().getDisplayInfo(displayId); DisplayInfo displayInfo = createDisplayInfo(qualifiersStr, baseDisplayInfo); getShadowDisplayManagerGlobal().changeDisplay(displayId, displayInfo); }
/** * Changes properties of a simulated display. The original properties will be passed to the * `consumer`, which may modify them in place. The display will be updated with the new * properties. * * @param displayId the display id to change * @param consumer a function which modifies the display properties */ static void changeDisplay(int displayId, Consumer<DisplayConfig> consumer) { DisplayInfo displayInfo = DisplayManagerGlobal.getInstance().getDisplayInfo(displayId); if (displayInfo != null) { DisplayConfig displayConfig = new DisplayConfig(displayInfo); consumer.accept(displayConfig); displayConfig.copyTo(displayInfo); fixNominalDimens(displayInfo); } getShadowDisplayManagerGlobal().changeDisplay(displayId, displayInfo); }
/** * Returns the current display saturation level set via {@link * android.hardware.display.DisplayManager#setSaturationLevel(float)}. */ public static float getSaturationLevel() { return getShadowDisplayManagerGlobal().getSaturationLevel(); }
/** * Removes a simulated display. * * @param displayId the display id to remove */ public static void removeDisplay(int displayId) { getShadowDisplayManagerGlobal().removeDisplay(displayId); }
/** * Adds a simulated display. * * @param qualifiersStr the {@link Qualifiers} string representing characteristics of the new * display. * @return the new display's ID */ public static int addDisplay(String qualifiersStr) { return getShadowDisplayManagerGlobal().addDisplay(createDisplayInfo(qualifiersStr, null)); }
/** internal only */ public static void configureDefaultDisplay(Configuration configuration, DisplayMetrics displayMetrics) { ShadowDisplayManagerGlobal shadowDisplayManagerGlobal = getShadowDisplayManagerGlobal(); if (DisplayManagerGlobal.getInstance().getDisplayIds().length != 0) { throw new IllegalStateException("this method should only be called by Robolectric"); } shadowDisplayManagerGlobal.addDisplay(createDisplayInfo(configuration, displayMetrics)); }
/** * Changes properties of a simulated display. If `qualifiersStr` starts with a plus (`+`) sign, * the display's previous configuration is modified with the given qualifiers; otherwise defaults * are applied as described [here](http://robolectric.org/device-configuration/). * * * @param displayId the display id to change * @param qualifiersStr the {@link Qualifiers} string representing characteristics of the new * display */ public static void changeDisplay(int displayId, String qualifiersStr) { DisplayInfo baseDisplayInfo = DisplayManagerGlobal.getInstance().getDisplayInfo(displayId); DisplayInfo displayInfo = createDisplayInfo(qualifiersStr, baseDisplayInfo); getShadowDisplayManagerGlobal().changeDisplay(displayId, displayInfo); }
/** * Changes properties of a simulated display. The original properties will be passed to the * `consumer`, which may modify them in place. The display will be updated with the new * properties. * * @param displayId the display id to change * @param consumer a function which modifies the display properties */ static void changeDisplay(int displayId, Consumer<DisplayConfig> consumer) { DisplayInfo displayInfo = DisplayManagerGlobal.getInstance().getDisplayInfo(displayId); if (displayInfo != null) { DisplayConfig displayConfig = new DisplayConfig(displayInfo); consumer.accept(displayConfig); displayConfig.copyTo(displayInfo); fixNominalDimens(displayInfo); } getShadowDisplayManagerGlobal().changeDisplay(displayId, displayInfo); }