com.android.resources.ScreenOrientation Java Examples
The following examples show how to use
com.android.resources.ScreenOrientation.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HardwareConfig.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public HardwareConfig( int screenWidth, int screenHeight, Density density, float xdpi, float ydpi, ScreenSize screenSize, ScreenOrientation orientation, boolean softwareButtons) { mScreenWidth = screenWidth; mScreenHeight = screenHeight; mDensity = density; mXdpi = xdpi; mYdpi = ydpi; mScreenSize = screenSize; mOrientation = orientation; mSoftwareButtons = softwareButtons; }
Example #2
Source File: AvdHwProfile.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
private List<State> generateStates(Hardware hardware) { List<State> states = Lists.newArrayListWithExpectedSize(4); if (portrait.isSelected()) { states.add(createState(ScreenOrientation.PORTRAIT, hardware, false)); } if (landscape.isSelected()) { states.add(createState(ScreenOrientation.LANDSCAPE, hardware, false)); } if (hwKeyb.isSelected()) { if (portrait.isSelected()) { states.add(createState(ScreenOrientation.PORTRAIT, hardware, true)); } if (landscape.isSelected()) { states.add(createState(ScreenOrientation.LANDSCAPE, hardware, true)); } } // We've added states in the order of most common to least common, so let's mark the first one as default states.get(0).setDefaultState(true); return states; }
Example #3
Source File: LayoutPreviewPanelImpl.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
private ConfigGenerator getCurrentConfig() { ConfigGenerator current = new ConfigGenerator() .setScreenHeight(imageHeight) .setScreenWidth(imageWidth) .setXdpi(dpi) .setYdpi(dpi) .setOrientation(ScreenOrientation.PORTRAIT) .setDensity(((Density) density.getSelectedItem()).getDensity()) .setRatio(ScreenRatio.NOTLONG) .setSize(ScreenSize.NORMAL) .setKeyboard(Keyboard.NOKEY) .setTouchScreen(TouchScreen.FINGER) .setKeyboardState(KeyboardState.SOFT) .setSoftButtons(true) .setNavigation(Navigation.NONAV); return current; }
Example #4
Source File: HardwareConfig.java From javaide with GNU General Public License v3.0 | 6 votes |
public HardwareConfig( int screenWidth, int screenHeight, Density density, float xdpi, float ydpi, ScreenSize screenSize, ScreenOrientation orientation, ScreenRound screenRoundness, boolean softwareButtons) { mScreenWidth = screenWidth; mScreenHeight = screenHeight; mDensity = density; mXdpi = xdpi; mYdpi = ydpi; mScreenSize = screenSize; mOrientation = orientation; mScreenRound = screenRoundness; mSoftwareButtons = softwareButtons; }
Example #5
Source File: Device.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
@SuppressWarnings("SuspiciousNameCombination") // Deliberately swapping orientations @Nullable public Dimension getScreenSize(@NonNull ScreenOrientation orientation) { Screen screen = getDefaultHardware().getScreen(); if (screen == null) { return null; } // compute width and height to take orientation into account. int x = screen.getXDimension(); int y = screen.getYDimension(); int screenWidth, screenHeight; if (x > y) { if (orientation == ScreenOrientation.LANDSCAPE) { screenWidth = x; screenHeight = y; } else { screenWidth = y; screenHeight = x; } } else { if (orientation == ScreenOrientation.LANDSCAPE) { screenWidth = y; screenHeight = x; } else { screenWidth = x; screenHeight = y; } } return new Dimension(screenWidth, screenHeight); }
Example #6
Source File: ScreenOrientationQualifier.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkAndSet(String value, FolderConfiguration config) { ScreenOrientation orientation = ScreenOrientation.getEnum(value); if (orientation != null) { ScreenOrientationQualifier qualifier = new ScreenOrientationQualifier(orientation); config.setScreenOrientationQualifier(qualifier); return true; } return false; }
Example #7
Source File: ScreenOrientationQualifier.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
@Override public boolean checkAndSet(String value, FolderConfiguration config) { ScreenOrientation orientation = ScreenOrientation.getEnum(value); if (orientation != null) { ScreenOrientationQualifier qualifier = new ScreenOrientationQualifier(orientation); config.setScreenOrientationQualifier(qualifier); return true; } return false; }
Example #8
Source File: Device.java From javaide with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("SuspiciousNameCombination") // Deliberately swapping orientations @Nullable public Point getScreenSize(@NonNull ScreenOrientation orientation) { Screen screen = getDefaultHardware().getScreen(); if (screen == null) { return null; } // compute width and height to take orientation into account. int x = screen.getXDimension(); int y = screen.getYDimension(); int screenWidth, screenHeight; if (x > y) { if (orientation == ScreenOrientation.LANDSCAPE) { screenWidth = x; screenHeight = y; } else { screenWidth = y; screenHeight = x; } } else { if (orientation == ScreenOrientation.LANDSCAPE) { screenWidth = y; screenHeight = x; } else { screenWidth = x; screenHeight = y; } } return new Point(screenWidth, screenHeight); }
Example #9
Source File: RenderService.java From javaide with GNU General Public License v3.0 | 5 votes |
private void figureSomeValuesOut() { int size1 = mConfig.getScreenDimensionQualifier().getValue1(); int size2 = mConfig.getScreenDimensionQualifier().getValue2(); ScreenOrientation orientation = mConfig.getScreenOrientationQualifier().getValue(); switch (orientation) { case LANDSCAPE: mWidth = size1 < size2 ? size2 : size1; mHeight = size1 < size2 ? size1 : size2; break; case PORTRAIT: mWidth = size1 < size2 ? size1 : size2; mHeight = size1 < size2 ? size2 : size1; break; case SQUARE: mWidth = mHeight = size1; break; } if (mMinSdkVersion == -1) { mMinSdkVersion = mConfig.getVersionQualifier().getVersion(); } if (mTargetSdkVersion == -1) { mTargetSdkVersion = mConfig.getVersionQualifier().getVersion(); } if (mXdpi == -1) { mXdpi = mConfig.getDensityQualifier().getValue().getDpiValue(); } if (mYdpi == -1) { mYdpi = mConfig.getDensityQualifier().getValue().getDpiValue(); } }
Example #10
Source File: ConfigGenerator.java From NBANDROID-V2 with Apache License 2.0 | 4 votes |
public ConfigGenerator setOrientation(ScreenOrientation orientation) { mOrientation = orientation; return this; }
Example #11
Source File: AvdHwProfile.java From NBANDROID-V2 with Apache License 2.0 | 4 votes |
/** * Creates new form AvdHwProfile */ public AvdHwProfile(Device device, DeviceManager deviceManager,boolean edit) { this.deviceManager = deviceManager; this.edit=edit; initComponents(); deviceType.setModel(new DefaultComboBoxModel<>(DeviceType.values())); if (device != null) { String tagId = device.getTagId(); initBootProperties(device); if (tagId == null) { deviceType.setSelectedItem(DeviceType.MOBILE); } else if (DeviceType.TV.id.equals(tagId)) { deviceType.setSelectedItem(DeviceType.TV); } else if (DeviceType.WEAR.id.equals(tagId)) { deviceType.setSelectedItem(DeviceType.WEAR); } if (edit) { deviceName.setText(device.getDisplayName()); deviceName.setEditable(false); }else{ deviceName.setText(String.format("%s (Edited)", device.getDisplayName())); } if (CreateAvdVisualPanel1.isTv(device)) { deviceType.setSelectedItem(DeviceType.TV); } else if (HardwareConfigHelper.isWear(device)) { deviceType.setSelectedItem(DeviceType.WEAR); } else { deviceType.setSelectedItem(DeviceType.MOBILE); } screenSize.setValue(device.getDefaultHardware().getScreen().getDiagonalLength()); Dimension dimension = device.getScreenSize(device.getDefaultState().getOrientation()); resolutionX.setValue(dimension.width); resolutionY.setValue(dimension.height); round.setSelected(device.isScreenRound()); ram.setValue(device.getDefaultHardware().getRam().getSizeAsUnit(Storage.Unit.MiB)); hwButt.setSelected(device.getDefaultHardware().getButtonType() == ButtonType.HARD); hwKeyb.setSelected(device.getDefaultHardware().getKeyboard() != Keyboard.NOKEY); List<State> states = device.getAllStates(); portrait.setSelected(false); landscape.setSelected(false); for (State state : states) { if (state.getOrientation().equals(ScreenOrientation.PORTRAIT)) { portrait.setSelected(true); } if (state.getOrientation().equals(ScreenOrientation.LANDSCAPE)) { landscape.setSelected(true); } } Navigation nav = device.getDefaultHardware().getNav(); switch (nav) { case NONAV: navigationStyle.setSelectedIndex(0); break; case DPAD: navigationStyle.setSelectedIndex(1); break; case TRACKBALL: navigationStyle.setSelectedIndex(2); break; case WHEEL: navigationStyle.setSelectedIndex(3); break; } cameraFront.setSelected(device.getDefaultHardware().getCamera(CameraLocation.FRONT) != null); cameraBack.setSelected(device.getDefaultHardware().getCamera(CameraLocation.BACK) != null); accelerometer.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.ACCELEROMETER)); gyroscope.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.GYROSCOPE)); gps.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.GPS)); proximity.setSelected(device.getDefaultHardware().getSensors().contains(Sensor.PROXIMITY_SENSOR)); File skinFile = device.getDefaultHardware().getSkinFile(); AndroidSdk defaultSdk = AndroidSdkProvider.getDefaultSdk(); if (defaultSdk != null) { String skinPath = defaultSdk.getSdkPath() + File.separator + "skins"; skin.setModel(new SkinsComboboxModel(new File(skinPath))); } skin.setSelectedItem(skinFile); playstore.setSelected(device.hasPlayStore()); } else { deviceType.setSelectedItem(DeviceType.MOBILE); navigationStyle.setSelectedIndex(0); deviceName.setText(getUniqueId(null)); } skin.setRenderer(new BasicComboBoxRenderer() { @Override public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates. if ((component instanceof JLabel) && (value instanceof File)) { ((JLabel) component).setText(((File) value).getName()); } return component; } }); }
Example #12
Source File: ScreenOrientationQualifier.java From javaide with GNU General Public License v3.0 | 4 votes |
public ScreenOrientation getValue() { return mValue; }
Example #13
Source File: ScreenOrientationQualifier.java From javaide with GNU General Public License v3.0 | 4 votes |
public ScreenOrientationQualifier(ScreenOrientation value) { mValue = value; }
Example #14
Source File: FolderConfiguration.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Updates the {@link SmallestScreenWidthQualifier}, {@link ScreenWidthQualifier}, and * {@link ScreenHeightQualifier} based on the (required) values of * {@link ScreenDimensionQualifier} {@link DensityQualifier}, and * {@link ScreenOrientationQualifier}. * * Also the density cannot be {@link Density#NODPI} as it's not valid on a device. */ public void updateScreenWidthAndHeight() { ResourceQualifier sizeQ = mQualifiers[INDEX_SCREEN_DIMENSION]; ResourceQualifier densityQ = mQualifiers[INDEX_PIXEL_DENSITY]; ResourceQualifier orientQ = mQualifiers[INDEX_SCREEN_ORIENTATION]; if (sizeQ != null && densityQ != null && orientQ != null) { Density density = ((DensityQualifier) densityQ).getValue(); if (density == Density.NODPI || density == Density.ANYDPI) { return; } ScreenOrientation orientation = ((ScreenOrientationQualifier) orientQ).getValue(); int size1 = ((ScreenDimensionQualifier) sizeQ).getValue1(); int size2 = ((ScreenDimensionQualifier) sizeQ).getValue2(); // make sure size1 is the biggest (should be the case, but make sure) if (size1 < size2) { int a = size1; size1 = size2; size2 = a; } // compute the dp. round them up since we want -w480dp to match a 480.5dp screen int dp1 = (int) Math.ceil(size1 * Density.DEFAULT_DENSITY / density.getDpiValue()); int dp2 = (int) Math.ceil(size2 * Density.DEFAULT_DENSITY / density.getDpiValue()); setSmallestScreenWidthQualifier(new SmallestScreenWidthQualifier(dp2)); switch (orientation) { case PORTRAIT: setScreenWidthQualifier(new ScreenWidthQualifier(dp2)); setScreenHeightQualifier(new ScreenHeightQualifier(dp1)); break; case LANDSCAPE: setScreenWidthQualifier(new ScreenWidthQualifier(dp1)); setScreenHeightQualifier(new ScreenHeightQualifier(dp2)); break; case SQUARE: setScreenWidthQualifier(new ScreenWidthQualifier(dp2)); setScreenHeightQualifier(new ScreenHeightQualifier(dp2)); break; } } }
Example #15
Source File: HardwareConfigHelper.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Creates and returns the HardwareConfig object. * @return the config */ @SuppressWarnings("SuspiciousNameCombination") // Deliberately swapping orientations @NonNull public HardwareConfig getConfig() { Screen screen = mDevice.getDefaultHardware().getScreen(); // compute width and height to take orientation into account. int x = screen.getXDimension(); int y = screen.getYDimension(); int width, height; if (x > y) { if (mScreenOrientation == ScreenOrientation.LANDSCAPE) { width = x; height = y; } else { width = y; height = x; } } else { if (mScreenOrientation == ScreenOrientation.LANDSCAPE) { width = y; height = x; } else { width = x; height = y; } } if (mOverrideRenderHeight != -1) { width = mOverrideRenderWidth; } if (mOverrideRenderHeight != -1) { height = mOverrideRenderHeight; } if (mMaxRenderWidth != -1) { width = mMaxRenderWidth; } if (mMaxRenderHeight != -1) { height = mMaxRenderHeight; } return new HardwareConfig( width, height, screen.getPixelDensity(), (float) screen.getXdpi(), (float) screen.getYdpi(), screen.getSize(), mScreenOrientation, mDevice.getDefaultHardware().getScreen().getScreenRound(), mDevice.getDefaultHardware().getButtonType() == ButtonType.SOFT); }
Example #16
Source File: HardwareConfigHelper.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Sets the orientation of the config. * @param screenOrientation the orientation. * @return this (such that chains of setters can be stringed together) */ @NonNull public HardwareConfigHelper setOrientation(@NonNull ScreenOrientation screenOrientation) { mScreenOrientation = screenOrientation; return this; }
Example #17
Source File: HardwareConfig.java From javaide with GNU General Public License v3.0 | 4 votes |
public ScreenOrientation getOrientation() { return mOrientation; }
Example #18
Source File: RenderServiceFactory.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Creates a config. This must be a valid config like a device would return. This is to * prevent issues where some resources don't exist in all cases and not in the default * (for instance only available in hdpi and mdpi but not in default). * * @param size1 * @param size2 * @param screenSize * @param screenRatio * @param orientation * @param density * @param touchScreen * @param keyboardState * @param keyboard * @param navigationState * @param navigation * @param apiLevel * @return */ public static FolderConfiguration createConfig( int size1, int size2, ScreenSize screenSize, ScreenRatio screenRatio, ScreenOrientation orientation, Density density, TouchScreen touchScreen, KeyboardState keyboardState, Keyboard keyboard, NavigationState navigationState, Navigation navigation, int apiLevel) { FolderConfiguration config = new FolderConfiguration(); int width = size1, height = size2; switch (orientation) { case LANDSCAPE: width = size1 < size2 ? size2 : size1; height = size1 < size2 ? size1 : size2; break; case PORTRAIT: width = size1 < size2 ? size1 : size2; height = size1 < size2 ? size2 : size1; break; case SQUARE: width = height = size1; break; } int wdp = (width * Density.DEFAULT_DENSITY) / density.getDpiValue(); int hdp = (height * Density.DEFAULT_DENSITY) / density.getDpiValue(); config.addQualifier(new SmallestScreenWidthQualifier(wdp < hdp ? wdp : hdp)); config.addQualifier(new ScreenWidthQualifier(wdp)); config.addQualifier(new ScreenHeightQualifier(hdp)); config.addQualifier(new ScreenSizeQualifier(screenSize)); config.addQualifier(new ScreenRatioQualifier(screenRatio)); config.addQualifier(new ScreenOrientationQualifier(orientation)); config.addQualifier(new DensityQualifier(density)); config.addQualifier(new TouchScreenQualifier(touchScreen)); config.addQualifier(new KeyboardStateQualifier(keyboardState)); config.addQualifier(new TextInputMethodQualifier(keyboard)); config.addQualifier(new NavigationStateQualifier(navigationState)); config.addQualifier(new NavigationMethodQualifier(navigation)); config.addQualifier(width > height ? new ScreenDimensionQualifier(width, height) : new ScreenDimensionQualifier(height, width)); config.addQualifier(new VersionQualifier(apiLevel)); config.updateScreenWidthAndHeight(); return config; }
Example #19
Source File: State.java From javaide with GNU General Public License v3.0 | 4 votes |
public void setOrientation(ScreenOrientation orientation) { mOrientation = orientation; }
Example #20
Source File: State.java From javaide with GNU General Public License v3.0 | 4 votes |
public ScreenOrientation getOrientation() { return mOrientation; }
Example #21
Source File: ScreenOrientationQualifier.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public ScreenOrientation getValue() { return mValue; }
Example #22
Source File: ScreenOrientationQualifier.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public ScreenOrientationQualifier(ScreenOrientation value) { mValue = value; }
Example #23
Source File: FolderConfiguration.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * Updates the {@link SmallestScreenWidthQualifier}, {@link ScreenWidthQualifier}, and * {@link ScreenHeightQualifier} based on the (required) values of * {@link ScreenDimensionQualifier} {@link DensityQualifier}, and * {@link ScreenOrientationQualifier}. * * Also the density cannot be {@link Density#NODPI} as it's not valid on a device. */ public void updateScreenWidthAndHeight() { ResourceQualifier sizeQ = mQualifiers[INDEX_SCREEN_DIMENSION]; ResourceQualifier densityQ = mQualifiers[INDEX_PIXEL_DENSITY]; ResourceQualifier orientQ = mQualifiers[INDEX_SCREEN_ORIENTATION]; if (sizeQ != null && densityQ != null && orientQ != null) { Density density = ((DensityQualifier) densityQ).getValue(); if (density == Density.NODPI) { return; } ScreenOrientation orientation = ((ScreenOrientationQualifier) orientQ).getValue(); int size1 = ((ScreenDimensionQualifier) sizeQ).getValue1(); int size2 = ((ScreenDimensionQualifier) sizeQ).getValue2(); // make sure size1 is the biggest (should be the case, but make sure) if (size1 < size2) { int a = size1; size1 = size2; size2 = a; } // compute the dp. round them up since we want -w480dp to match a 480.5dp screen int dp1 = (int) Math.ceil(size1 * Density.DEFAULT_DENSITY / density.getDpiValue()); int dp2 = (int) Math.ceil(size2 * Density.DEFAULT_DENSITY / density.getDpiValue()); setSmallestScreenWidthQualifier(new SmallestScreenWidthQualifier(dp2)); switch (orientation) { case PORTRAIT: setScreenWidthQualifier(new ScreenWidthQualifier(dp2)); setScreenHeightQualifier(new ScreenHeightQualifier(dp1)); break; case LANDSCAPE: setScreenWidthQualifier(new ScreenWidthQualifier(dp1)); setScreenHeightQualifier(new ScreenHeightQualifier(dp2)); break; case SQUARE: setScreenWidthQualifier(new ScreenWidthQualifier(dp2)); setScreenHeightQualifier(new ScreenHeightQualifier(dp2)); break; } } }
Example #24
Source File: HardwareConfig.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public ScreenOrientation getOrientation() { return mOrientation; }
Example #25
Source File: State.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void setOrientation(ScreenOrientation orientation) { mOrientation = orientation; }
Example #26
Source File: State.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public ScreenOrientation getOrientation() { return mOrientation; }