use of com.android.resources.ScreenOrientation in project android_frameworks_base by DirtyUnicorns.
the class RenderAction method getConfiguration.
// VisibleForTesting
public static Configuration getConfiguration(RenderParams params) {
Configuration config = new Configuration();
HardwareConfig hardwareConfig = params.getHardwareConfig();
ScreenSize screenSize = hardwareConfig.getScreenSize();
if (screenSize != null) {
switch(screenSize) {
case SMALL:
config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_SMALL;
break;
case NORMAL:
config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_NORMAL;
break;
case LARGE:
config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_LARGE;
break;
case XLARGE:
config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_XLARGE;
break;
}
}
Density density = hardwareConfig.getDensity();
if (density == null) {
density = Density.MEDIUM;
}
config.screenWidthDp = hardwareConfig.getScreenWidth() / density.getDpiValue();
config.screenHeightDp = hardwareConfig.getScreenHeight() / density.getDpiValue();
if (config.screenHeightDp < config.screenWidthDp) {
//noinspection SuspiciousNameCombination
config.smallestScreenWidthDp = config.screenHeightDp;
} else {
config.smallestScreenWidthDp = config.screenWidthDp;
}
config.densityDpi = density.getDpiValue();
// never run in compat mode:
config.compatScreenWidthDp = config.screenWidthDp;
config.compatScreenHeightDp = config.screenHeightDp;
ScreenOrientation orientation = hardwareConfig.getOrientation();
if (orientation != null) {
switch(orientation) {
case PORTRAIT:
config.orientation = Configuration.ORIENTATION_PORTRAIT;
break;
case LANDSCAPE:
config.orientation = Configuration.ORIENTATION_LANDSCAPE;
break;
case SQUARE:
//noinspection deprecation
config.orientation = Configuration.ORIENTATION_SQUARE;
break;
}
} else {
config.orientation = Configuration.ORIENTATION_UNDEFINED;
}
ScreenRound roundness = hardwareConfig.getScreenRoundness();
if (roundness != null) {
switch(roundness) {
case ROUND:
config.screenLayout |= Configuration.SCREENLAYOUT_ROUND_YES;
break;
case NOTROUND:
config.screenLayout |= Configuration.SCREENLAYOUT_ROUND_NO;
}
} else {
config.screenLayout |= Configuration.SCREENLAYOUT_ROUND_UNDEFINED;
}
String locale = params.getLocale();
if (locale != null && !locale.isEmpty())
config.locale = new Locale(locale);
return config;
}
use of com.android.resources.ScreenOrientation in project android_frameworks_base by ResurrectionRemix.
the class RenderAction method getConfiguration.
// VisibleForTesting
public static Configuration getConfiguration(RenderParams params) {
Configuration config = new Configuration();
HardwareConfig hardwareConfig = params.getHardwareConfig();
ScreenSize screenSize = hardwareConfig.getScreenSize();
if (screenSize != null) {
switch(screenSize) {
case SMALL:
config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_SMALL;
break;
case NORMAL:
config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_NORMAL;
break;
case LARGE:
config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_LARGE;
break;
case XLARGE:
config.screenLayout |= Configuration.SCREENLAYOUT_SIZE_XLARGE;
break;
}
}
Density density = hardwareConfig.getDensity();
if (density == null) {
density = Density.MEDIUM;
}
config.screenWidthDp = hardwareConfig.getScreenWidth() / density.getDpiValue();
config.screenHeightDp = hardwareConfig.getScreenHeight() / density.getDpiValue();
if (config.screenHeightDp < config.screenWidthDp) {
//noinspection SuspiciousNameCombination
config.smallestScreenWidthDp = config.screenHeightDp;
} else {
config.smallestScreenWidthDp = config.screenWidthDp;
}
config.densityDpi = density.getDpiValue();
// never run in compat mode:
config.compatScreenWidthDp = config.screenWidthDp;
config.compatScreenHeightDp = config.screenHeightDp;
ScreenOrientation orientation = hardwareConfig.getOrientation();
if (orientation != null) {
switch(orientation) {
case PORTRAIT:
config.orientation = Configuration.ORIENTATION_PORTRAIT;
break;
case LANDSCAPE:
config.orientation = Configuration.ORIENTATION_LANDSCAPE;
break;
case SQUARE:
//noinspection deprecation
config.orientation = Configuration.ORIENTATION_SQUARE;
break;
}
} else {
config.orientation = Configuration.ORIENTATION_UNDEFINED;
}
ScreenRound roundness = hardwareConfig.getScreenRoundness();
if (roundness != null) {
switch(roundness) {
case ROUND:
config.screenLayout |= Configuration.SCREENLAYOUT_ROUND_YES;
break;
case NOTROUND:
config.screenLayout |= Configuration.SCREENLAYOUT_ROUND_NO;
}
} else {
config.screenLayout |= Configuration.SCREENLAYOUT_ROUND_UNDEFINED;
}
String locale = params.getLocale();
if (locale != null && !locale.isEmpty())
config.locale = new Locale(locale);
return config;
}
use of com.android.resources.ScreenOrientation in project android by JetBrains.
the class ScreenshotViewer method getDescriptorsToFrame.
// returns the list of descriptors capable of framing the given image
private static List<DeviceArtDescriptor> getDescriptorsToFrame(final BufferedImage image) {
double imgAspectRatio = image.getWidth() / (double) image.getHeight();
final ScreenOrientation orientation = imgAspectRatio >= (1 - ImageUtils.EPSILON) ? ScreenOrientation.LANDSCAPE : ScreenOrientation.PORTRAIT;
List<DeviceArtDescriptor> allDescriptors = DeviceArtDescriptor.getDescriptors(null);
return ContainerUtil.filter(allDescriptors, descriptor -> {
return descriptor.canFrameImage(image, orientation);
});
}
use of com.android.resources.ScreenOrientation in project android by JetBrains.
the class ConfigureAvdOptionsStep method createUIComponents.
private void createUIComponents() {
Function<ScreenOrientation, Image> orientationIconFunction = new Function<ScreenOrientation, Image>() {
@Override
public Image apply(ScreenOrientation input) {
return IconUtil.toImage(ORIENTATIONS.get(input).myIcon);
}
};
Function<ScreenOrientation, String> orientationNameFunction = new Function<ScreenOrientation, String>() {
@Override
public String apply(ScreenOrientation input) {
return ORIENTATIONS.get(input).myName;
}
};
myOrientationToggle = new ASGallery<ScreenOrientation>(JBList.createDefaultListModel(ScreenOrientation.PORTRAIT, ScreenOrientation.LANDSCAPE), orientationIconFunction, orientationNameFunction, JBUI.size(50, 50), null);
myOrientationToggle.setCellMargin(JBUI.insets(5, 20, 4, 20));
myOrientationToggle.setBackground(JBColor.background());
myOrientationToggle.setForeground(JBColor.foreground());
myHardwareSkinHelpLabel = new HyperlinkLabel("How do I create a custom hardware skin?");
myHardwareSkinHelpLabel.setHyperlinkTarget(AvdWizardUtils.CREATE_SKIN_HELP_LINK);
mySkinComboBox = new SkinChooser(myProject, true);
}
use of com.android.resources.ScreenOrientation in project android by JetBrains.
the class DeviceArtDescriptorTest method test1.
public void test1() throws IOException {
List<DeviceArtDescriptor> specs = DeviceArtDescriptor.getDescriptors(null);
assertEquals(22, specs.size());
DeviceArtDescriptor nexus4 = getDescriptorFor("nexus_4", specs);
assertNotNull(nexus4);
Point offsets = nexus4.getScreenPos(ScreenOrientation.PORTRAIT);
assertEquals(94, offsets.x);
assertEquals(187, offsets.y);
offsets = nexus4.getScreenPos(ScreenOrientation.LANDSCAPE);
assertEquals(257, offsets.x);
assertEquals(45, offsets.y);
verifyFileExists(nexus4.getFrame(ScreenOrientation.LANDSCAPE));
verifyFileExists(nexus4.getFrame(ScreenOrientation.PORTRAIT));
verifyFileExists(nexus4.getDropShadow(ScreenOrientation.LANDSCAPE));
verifyFileExists(nexus4.getDropShadow(ScreenOrientation.PORTRAIT));
verifyFileExists(nexus4.getReflectionOverlay(ScreenOrientation.LANDSCAPE));
verifyFileExists(nexus4.getReflectionOverlay(ScreenOrientation.PORTRAIT));
for (DeviceArtDescriptor descriptor : specs) {
String id = descriptor.getId();
assertNotNull(id);
assertNotNull(descriptor.getName());
for (ScreenOrientation orientation : new ScreenOrientation[] { ScreenOrientation.LANDSCAPE, ScreenOrientation.PORTRAIT }) {
if (orientation == ScreenOrientation.PORTRAIT && id.startsWith("tv_")) {
continue;
}
assertNotNull(id, descriptor.getFrameSize(orientation));
assertNotNull(id, descriptor.getScreenPos(orientation));
assertNotNull(id, descriptor.getScreenSize(orientation));
// We've pre-subtracted the crop everywhere now
assertNull(descriptor.getCrop(orientation));
assertTrue(id, descriptor.getFrame(orientation).exists());
assertTrue(id, descriptor.getDropShadow(orientation).exists());
File reflectionOverlay = descriptor.getReflectionOverlay(orientation);
if (reflectionOverlay != null) {
assertTrue(id, reflectionOverlay.exists());
}
verifyCompatibleImage(descriptor.getFrame(orientation));
verifyCompatibleImage(descriptor.getDropShadow(orientation));
verifyCompatibleImage(descriptor.getReflectionOverlay(orientation));
verifyCompatibleImage(descriptor.getMask(orientation));
}
}
DeviceArtDescriptor generic_phone = getDescriptorFor("phone", specs);
assertNull(generic_phone.getReflectionOverlay(ScreenOrientation.LANDSCAPE));
}
Aggregations