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();
}
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;
}
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());
}
Aggregations