Search in sources :

Example 1 with NightMode

use of com.android.resources.NightMode in project android by JetBrains.

the class ConfigurationFileState method loadState.

public void loadState(@NotNull Configuration configuration) {
    configuration.startBulkEditing();
    ConfigurationManager manager = configuration.getConfigurationManager();
    configuration.setDeviceStateName(myDeviceState);
    if (myDockMode != null) {
        UiMode dockMode = UiMode.getEnum(myDockMode);
        if (dockMode != null) {
            configuration.setUiMode(dockMode);
        }
    }
    if (myNightMode != null) {
        NightMode nightMode = NightMode.getEnum(myNightMode);
        if (nightMode != null) {
            configuration.setNightMode(nightMode);
        }
    }
    if (myTheme != null) {
        configuration.setTheme(myTheme);
    }
    configuration.finishBulkEditing();
}
Also used : NightMode(com.android.resources.NightMode) UiMode(com.android.resources.UiMode)

Example 2 with NightMode

use of com.android.resources.NightMode in project android by JetBrains.

the class OrientationMenuAction method createPopupActionGroup.

@Override
@NotNull
protected DefaultActionGroup createPopupActionGroup() {
    DefaultActionGroup group = new DefaultActionGroup(null, true);
    Configuration configuration = myRenderContext.getConfiguration();
    if (configuration != null) {
        Device device = configuration.getDevice();
        if (device != null) {
            List<State> states = device.getAllStates();
            State current = configuration.getDeviceState();
            if (states.size() > 1 && current != null) {
                State flip = configuration.getNextDeviceState(current);
                State nextSate = flip == null ? current : flip;
                String title = getPresentationDescription(nextSate);
                group.add(new SetDeviceStateAction(myRenderContext, title, nextSate, false, true));
                group.addSeparator();
            }
            for (State config : states) {
                String stateName = config.getName();
                String title = stateName;
                VirtualFile better = ConfigurationMatcher.getBetterMatch(configuration, null, stateName, null, null);
                if (better != null) {
                    title = ConfigurationAction.getBetterMatchLabel(stateName, better, configuration.getFile());
                }
                group.add(new SetDeviceStateAction(myRenderContext, title, config, config == current, false));
            }
            group.addSeparator();
        }
        group.addSeparator();
        DefaultActionGroup uiModeGroup = new DefaultActionGroup("_UI Mode", true);
        UiMode currentUiMode = configuration.getUiMode();
        for (UiMode uiMode : UiMode.values()) {
            String title = uiMode.getShortDisplayValue();
            boolean checked = uiMode == currentUiMode;
            uiModeGroup.add(new SetUiModeAction(myRenderContext, title, uiMode, checked));
        }
        group.add(uiModeGroup);
        group.addSeparator();
        DefaultActionGroup nightModeGroup = new DefaultActionGroup("_Night Mode", true);
        NightMode currentNightMode = configuration.getNightMode();
        for (NightMode nightMode : NightMode.values()) {
            String title = nightMode.getShortDisplayValue();
            boolean checked = nightMode == currentNightMode;
            nightModeGroup.add(new SetNightModeAction(myRenderContext, title, nightMode, checked));
        }
        group.add(nightModeGroup);
    }
    return group;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FolderConfiguration(com.android.ide.common.resources.configuration.FolderConfiguration) Device(com.android.sdklib.devices.Device) DefaultActionGroup(com.intellij.openapi.actionSystem.DefaultActionGroup) NightMode(com.android.resources.NightMode) UiMode(com.android.resources.UiMode) State(com.android.sdklib.devices.State) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with NightMode

use of com.android.resources.NightMode in project android by JetBrains.

the class ConfigurationFileState method saveState.

public void saveState(@NotNull Configuration configuration) {
    Device device = configuration.getDevice();
    myDeviceState = null;
    if (device != null) {
        State deviceState = configuration.getDeviceState();
        if (deviceState != null && deviceState != device.getDefaultState()) {
            myDeviceState = deviceState.getName();
        }
    }
    // Null out if same as the default
    UiMode dockMode = configuration.getUiMode();
    if (dockMode != UiMode.NORMAL) {
        myDockMode = dockMode.getResourceValue();
    } else {
        myDockMode = null;
    }
    myDockMode = StringUtil.nullize(dockMode.getResourceValue());
    NightMode nightMode = configuration.getNightMode();
    if (nightMode != NightMode.NOTNIGHT) {
        myNightMode = nightMode.getResourceValue();
    } else {
        myNightMode = null;
    }
    myTheme = StringUtil.nullize(configuration.getTheme());
}
Also used : Device(com.android.sdklib.devices.Device) State(com.android.sdklib.devices.State) NightMode(com.android.resources.NightMode) UiMode(com.android.resources.UiMode)

Aggregations

NightMode (com.android.resources.NightMode)3 UiMode (com.android.resources.UiMode)3 Device (com.android.sdklib.devices.Device)2 State (com.android.sdklib.devices.State)2 FolderConfiguration (com.android.ide.common.resources.configuration.FolderConfiguration)1 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 NotNull (org.jetbrains.annotations.NotNull)1