com.android.resources.ScreenSize Java Examples
The following examples show how to use
com.android.resources.ScreenSize.
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: AvdHwProfile.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
public static ScreenSize getScreenSize(@Nullable Double diagonalSize) { if (diagonalSize == null) { return ScreenSize.NORMAL; } /** * Density-independent pixel (dp) : The density-independent pixel is * equivalent to one physical pixel on a 160 dpi screen, which is the * baseline density assumed by the system for a "medium" density screen. * * Taken from * http://developer.android.com/guide/practices/screens_support.html */ double diagonalDp = 160.0 * diagonalSize; // Set the Screen Size if (diagonalDp >= 1200) { return ScreenSize.XLARGE; } else if (diagonalDp >= 800) { return ScreenSize.LARGE; } else if (diagonalDp >= 568) { return ScreenSize.NORMAL; } else { return ScreenSize.SMALL; } }
Example #2
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 #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: ScreenSizeQualifier.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public boolean isBetterMatchThan(ResourceQualifier compareTo, ResourceQualifier reference) { if (compareTo == null) { return true; } ScreenSizeQualifier compareQ = (ScreenSizeQualifier) compareTo; int thisIndex = ScreenSize.getIndex(mValue); int compareIndex = ScreenSize.getIndex(compareQ.mValue); // Return true if this size is larger than reference size. Since isMatchFor() is called // before, it is guaranteed that the size will not be larger than the reference. return thisIndex > compareIndex; }
Example #6
Source File: ScreenSizeQualifier.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public boolean isMatchFor(ResourceQualifier qualifier) { // This is a match only if the screen size is smaller than the qualifier's screen size. if (qualifier instanceof ScreenSizeQualifier) { int qualifierIndex = ScreenSize.getIndex(((ScreenSizeQualifier) qualifier).mValue); int index = ScreenSize.getIndex(mValue); if (index <= qualifierIndex) { return true; } } return false; }
Example #7
Source File: ScreenSizeQualifier.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
@Override public boolean checkAndSet(String value, FolderConfiguration config) { ScreenSize size = ScreenSize.getEnum(value); if (size != null) { ScreenSizeQualifier qualifier = new ScreenSizeQualifier(size); config.setScreenSizeQualifier(qualifier); return true; } return false; }
Example #8
Source File: ScreenSizeQualifier.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
@Override public boolean isMatchFor(ResourceQualifier qualifier) { // This is a match only if the screen size is smaller than the qualifier's screen size. if (qualifier instanceof ScreenSizeQualifier) { int qualifierIndex = ScreenSize.getIndex(((ScreenSizeQualifier) qualifier).mValue); int index = ScreenSize.getIndex(mValue); if (index <= qualifierIndex) { return true; } } return false; }
Example #9
Source File: ScreenSizeQualifier.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
@Override public boolean isBetterMatchThan(ResourceQualifier compareTo, ResourceQualifier reference) { if (compareTo == null) { return true; } ScreenSizeQualifier compareQ = (ScreenSizeQualifier) compareTo; int thisIndex = ScreenSize.getIndex(mValue); int compareIndex = ScreenSize.getIndex(compareQ.mValue); // Return true if this size is larger than reference size. Since isMatchFor() is called // before, it is guaranteed that the size will not be larger than the reference. return thisIndex > compareIndex; }
Example #10
Source File: ScreenSizeQualifier.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkAndSet(String value, FolderConfiguration config) { ScreenSize size = ScreenSize.getEnum(value); if (size != null) { ScreenSizeQualifier qualifier = new ScreenSizeQualifier(size); config.setScreenSizeQualifier(qualifier); return true; } return false; }
Example #11
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 #12
Source File: ConfigGenerator.java From NBANDROID-V2 with Apache License 2.0 | 4 votes |
public ConfigGenerator setSize(ScreenSize size) { mSize = size; return this; }
Example #13
Source File: ScreenSizeQualifier.java From javaide with GNU General Public License v3.0 | 4 votes |
public ScreenSize getValue() { return mValue; }
Example #14
Source File: ScreenSizeQualifier.java From javaide with GNU General Public License v3.0 | 4 votes |
public ScreenSizeQualifier(ScreenSize value) { mValue = value; }
Example #15
Source File: HardwareConfig.java From javaide with GNU General Public License v3.0 | 4 votes |
public ScreenSize getScreenSize() { return mScreenSize; }
Example #16
Source File: RenderParams.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * @deprecated Use {@link #getHardwareConfig()} */ @Deprecated public ScreenSize getConfigScreenSize() { return mHardwareConfig.getScreenSize(); }
Example #17
Source File: Screen.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public ScreenSize getSize() { return mScreenSize; }
Example #18
Source File: Screen.java From javaide with GNU General Public License v3.0 | 4 votes |
public void setSize(ScreenSize s) { mScreenSize = s; }
Example #19
Source File: Screen.java From javaide with GNU General Public License v3.0 | 4 votes |
public ScreenSize getSize() { return mScreenSize; }
Example #20
Source File: ScreenSizeQualifier.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public ScreenSize getValue() { return mValue; }
Example #21
Source File: ScreenSizeQualifier.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public ScreenSizeQualifier(ScreenSize value) { mValue = value; }
Example #22
Source File: HardwareConfig.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public ScreenSize getScreenSize() { return mScreenSize; }
Example #23
Source File: RenderParams.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * @deprecated Use {@link #getHardwareConfig()} */ @Deprecated public ScreenSize getConfigScreenSize() { return mHardwareConfig.getScreenSize(); }
Example #24
Source File: Screen.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void setSize(ScreenSize s) { mScreenSize = s; }