com.android.resources.UiMode Java Examples
The following examples show how to use
com.android.resources.UiMode.
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: UiModeQualifier.java From javaide with GNU General Public License v3.0 | 6 votes |
@Override public boolean isBetterMatchThan(ResourceQualifier compareTo, ResourceQualifier reference) { if (compareTo == null) { return true; } UiModeQualifier compareQualifier = (UiModeQualifier)compareTo; UiModeQualifier referenceQualifier = (UiModeQualifier)reference; if (compareQualifier.getValue() == referenceQualifier.getValue()) { // what we have is already the best possible match (exact match) return false; } else if (mValue == referenceQualifier.mValue) { // got new exact value, this is the best! return true; } else if (mValue == UiMode.NORMAL) { // else "normal" can be a match in case there's no exact match return true; } return false; }
Example #2
Source File: UiModeQualifier.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
@Override public boolean isBetterMatchThan(ResourceQualifier compareTo, ResourceQualifier reference) { if (compareTo == null) { return true; } UiModeQualifier compareQualifier = (UiModeQualifier)compareTo; UiModeQualifier referenceQualifier = (UiModeQualifier)reference; if (compareQualifier.getValue() == referenceQualifier.getValue()) { // what we have is already the best possible match (exact match) return false; } else if (mValue == referenceQualifier.mValue) { // got new exact value, this is the best! return true; } else if (mValue == UiMode.NORMAL) { // else "normal" can be a match in case there's no exact match return true; } return false; }
Example #3
Source File: ConfigGenerator.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
public FolderConfiguration getFolderConfig() { FolderConfiguration config = new FolderConfiguration(); // config.createDefault(); config.setDensityQualifier(new DensityQualifier(mDensity)); config.setNavigationMethodQualifier(new NavigationMethodQualifier(mNavigation)); if (mScreenWidth > mScreenHeight) { config.setScreenDimensionQualifier(new ScreenDimensionQualifier(mScreenWidth, mScreenHeight)); } else { config.setScreenDimensionQualifier(new ScreenDimensionQualifier(mScreenHeight, mScreenWidth)); } config.setScreenRatioQualifier(new ScreenRatioQualifier(mRatio)); config.setScreenSizeQualifier(new ScreenSizeQualifier(mSize)); config.setTextInputMethodQualifier(new TextInputMethodQualifier(mKeyboard)); config.setTouchTypeQualifier(new TouchScreenQualifier(mTouchScreen)); config.setKeyboardStateQualifier(new KeyboardStateQualifier(mKeyboardState)); config.setScreenOrientationQualifier(new ScreenOrientationQualifier(mOrientation)); config.updateScreenWidthAndHeight(); // some default qualifiers. config.setUiModeQualifier(new UiModeQualifier(UiMode.NORMAL)); config.setNightModeQualifier(new NightModeQualifier(NightMode.NOTNIGHT)); config.setCountryCodeQualifier(new CountryCodeQualifier()); config.setLayoutDirectionQualifier(new LayoutDirectionQualifier()); config.setNetworkCodeQualifier(new NetworkCodeQualifier()); config.setLocaleQualifier(new LocaleQualifier()); config.setVersionQualifier(new VersionQualifier(28)); return config; }
Example #4
Source File: UiModeQualifier.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public boolean isMatchFor(ResourceQualifier qualifier) { // only normal is a match for all UI mode, because it's not an actual mode. if (mValue == UiMode.NORMAL) { return true; } // others must be an exact match return ((UiModeQualifier)qualifier).mValue == mValue; }
Example #5
Source File: UiModeQualifier.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
@Override public boolean checkAndSet(String value, FolderConfiguration config) { UiMode mode = UiMode.getEnum(value); if (mode != null) { UiModeQualifier qualifier = new UiModeQualifier(mode); config.setUiModeQualifier(qualifier); return true; } return false; }
Example #6
Source File: UiModeQualifier.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
@Override public boolean isMatchFor(ResourceQualifier qualifier) { // only normal is a match for all UI mode, because it's not an actual mode. if (mValue == UiMode.NORMAL) { return true; } // others must be an exact match return ((UiModeQualifier)qualifier).mValue == mValue; }
Example #7
Source File: UiModeQualifier.java From javaide with GNU General Public License v3.0 | 5 votes |
@Override public boolean checkAndSet(String value, FolderConfiguration config) { UiMode mode = UiMode.getEnum(value); if (mode != null) { UiModeQualifier qualifier = new UiModeQualifier(mode); config.setUiModeQualifier(qualifier); return true; } return false; }
Example #8
Source File: Hardware.java From javaide with GNU General Public License v3.0 | 4 votes |
@NonNull public Set<UiMode> getSupportedUiModes() { return mUiModes; }
Example #9
Source File: DeviceConfigHelper.java From javaide with GNU General Public License v3.0 | 4 votes |
/** * Returns a {@link FolderConfiguration} based on the given state * * @param state * The {@link State} of the {@link Device} to base the * {@link FolderConfiguration} on. Can be null. * @return A {@link FolderConfiguration} based on the given {@link State}. * If the given {@link State} is null, the result is also null; */ @Nullable public static FolderConfiguration getFolderConfig(@Nullable State state) { if (state == null) { return null; } Hardware hw = state.getHardware(); FolderConfiguration config = new FolderConfiguration(); config.createDefault(); Screen screen = hw.getScreen(); config.setDensityQualifier(new DensityQualifier(screen.getPixelDensity())); config.setNavigationMethodQualifier(new NavigationMethodQualifier(hw.getNav())); ScreenDimensionQualifier sdq; if (screen.getXDimension() > screen.getYDimension()) { sdq = new ScreenDimensionQualifier(screen.getXDimension(), screen.getYDimension()); } else { sdq = new ScreenDimensionQualifier(screen.getYDimension(), screen.getXDimension()); } config.setScreenDimensionQualifier(sdq); config.setScreenRatioQualifier(new ScreenRatioQualifier(screen.getRatio())); config.setScreenSizeQualifier(new ScreenSizeQualifier(screen.getSize())); config.setTextInputMethodQualifier(new TextInputMethodQualifier(hw.getKeyboard())); config.setTouchTypeQualifier(new TouchScreenQualifier(screen.getMechanism())); ScreenRound screenRound = screen.getScreenRound(); if (screenRound == null) { // The default is not round. screenRound = ScreenRound.NOTROUND; } config.setScreenRoundQualifier(new ScreenRoundQualifier(screenRound)); config.setKeyboardStateQualifier(new KeyboardStateQualifier(state.getKeyState())); config.setNavigationStateQualifier(new NavigationStateQualifier(state.getNavState())); config.setScreenOrientationQualifier( new ScreenOrientationQualifier(state.getOrientation())); config.updateScreenWidthAndHeight(); // Setup some default qualifiers config.setUiModeQualifier(new UiModeQualifier(UiMode.NORMAL)); config.setNightModeQualifier(new NightModeQualifier(NightMode.NOTNIGHT)); config.setCountryCodeQualifier(new CountryCodeQualifier()); config.setLocaleQualifier(new LocaleQualifier()); config.setLayoutDirectionQualifier(new LayoutDirectionQualifier()); config.setNetworkCodeQualifier(new NetworkCodeQualifier()); config.setVersionQualifier(new VersionQualifier()); return config; }
Example #10
Source File: UiModeQualifier.java From javaide with GNU General Public License v3.0 | 4 votes |
public UiMode getValue() { return mValue; }
Example #11
Source File: UiModeQualifier.java From javaide with GNU General Public License v3.0 | 4 votes |
public UiModeQualifier(UiMode value) { mValue = value; }
Example #12
Source File: Hardware.java From javaide with GNU General Public License v3.0 | 4 votes |
public void addAllSupportedUiModes(@NonNull Collection<UiMode> uiModes) { mUiModes.addAll(uiModes); }
Example #13
Source File: Hardware.java From javaide with GNU General Public License v3.0 | 4 votes |
public void addSupportedUiMode(@NonNull UiMode uiMode) { mUiModes.add(uiMode); }
Example #14
Source File: Hardware.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
@NonNull public Set<UiMode> getSupportedUiModes() { return mUiModes; }
Example #15
Source File: DeviceWriter.java From javaide with GNU General Public License v3.0 | 4 votes |
private static Element generateHardwareNode(Hardware hw, Document doc) { Screen s = hw.getScreen(); Element hardware = doc.createElement(PREFIX + DeviceSchema.NODE_HARDWARE); Element screen = doc.createElement(PREFIX + DeviceSchema.NODE_SCREEN); hardware.appendChild(screen); addElement(doc, screen, DeviceSchema.NODE_SCREEN_SIZE, s.getSize().getResourceValue()); addElement(doc, screen, DeviceSchema.NODE_DIAGONAL_LENGTH, String.format(Locale.US, "%.2f",s.getDiagonalLength())); addElement(doc, screen, DeviceSchema.NODE_PIXEL_DENSITY, s.getPixelDensity().getResourceValue()); addElement(doc, screen, DeviceSchema.NODE_SCREEN_RATIO, s.getRatio().getResourceValue()); Element dimensions = doc.createElement(PREFIX + DeviceSchema.NODE_DIMENSIONS); screen.appendChild(dimensions); addElement(doc, dimensions, DeviceSchema.NODE_X_DIMENSION, Integer.toString(s.getXDimension())); addElement(doc, dimensions, DeviceSchema.NODE_Y_DIMENSION, Integer.toString(s.getYDimension())); addElement(doc, screen, DeviceSchema.NODE_XDPI, String.format(Locale.US, "%.2f", s.getXdpi())); addElement(doc, screen, DeviceSchema.NODE_YDPI, String.format(Locale.US, "%.2f", s.getYdpi())); Element touch = doc.createElement(PREFIX + DeviceSchema.NODE_TOUCH); screen.appendChild(touch); addElement(doc, touch, DeviceSchema.NODE_MULTITOUCH, s.getMultitouch().toString()); addElement(doc, touch, DeviceSchema.NODE_MECHANISM, s.getMechanism().getResourceValue()); addElement(doc, touch, DeviceSchema.NODE_SCREEN_TYPE, s.getScreenType().toString()); addElement(doc, hardware, DeviceSchema.NODE_NETWORKING, hw.getNetworking()); addElement(doc, hardware, DeviceSchema.NODE_SENSORS, hw.getSensors()); addElement(doc, hardware, DeviceSchema.NODE_MIC, Boolean.toString(hw.hasMic())); for (Camera c : hw.getCameras()) { Element camera = doc.createElement(PREFIX + DeviceSchema.NODE_CAMERA); hardware.appendChild(camera); addElement(doc, camera, DeviceSchema.NODE_LOCATION, c.getLocation().toString()); addElement(doc, camera, DeviceSchema.NODE_AUTOFOCUS, Boolean.toString(c.hasAutofocus())); addElement(doc, camera, DeviceSchema.NODE_FLASH, Boolean.toString(c.hasFlash())); } addElement(doc, hardware, DeviceSchema.NODE_KEYBOARD, hw.getKeyboard().getResourceValue()); addElement(doc, hardware, DeviceSchema.NODE_NAV, hw.getNav().getResourceValue()); Storage.Unit unit = hw.getRam().getAppropriateUnits(); Element ram = addElement(doc, hardware, DeviceSchema.NODE_RAM, Long.toString(hw.getRam().getSizeAsUnit(unit))); ram.setAttribute(DeviceSchema.ATTR_UNIT, unit.toString()); addElement(doc, hardware, DeviceSchema.NODE_BUTTONS, hw.getButtonType().toString()); addStorageElement(doc, hardware, DeviceSchema.NODE_INTERNAL_STORAGE, hw.getInternalStorage()); addStorageElement(doc, hardware, DeviceSchema.NODE_REMOVABLE_STORAGE, hw.getRemovableStorage()); addElement(doc, hardware, DeviceSchema.NODE_CPU, hw.getCpu()); addElement(doc, hardware, DeviceSchema.NODE_GPU, hw.getGpu()); addElement(doc, hardware, DeviceSchema.NODE_ABI, hw.getSupportedAbis()); StringBuilder sb = new StringBuilder(); for (UiMode u : hw.getSupportedUiModes()) { sb.append('\n').append(u.getResourceValue()); } addElement(doc, hardware, DeviceSchema.NODE_DOCK, sb.toString()); addElement(doc, hardware, DeviceSchema.NODE_POWER_TYPE, hw.getChargeType().toString()); File skinPath = hw.getSkinFile(); if (skinPath != null) { String canonicalPath = skinPath.getPath().replace(File.separatorChar, '/'); addElement(doc, hardware, DeviceSchema.NODE_SKIN, canonicalPath); } return hardware; }
Example #16
Source File: DeviceConfigHelper.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
/** * Returns a {@link FolderConfiguration} based on the given state * * @param state * The {@link State} of the {@link Device} to base the * {@link FolderConfiguration} on. Can be null. * @return A {@link FolderConfiguration} based on the given {@link State}. * If the given {@link State} is null, the result is also null; */ @Nullable public static FolderConfiguration getFolderConfig(@Nullable State state) { if (state == null) { return null; } Hardware hw = state.getHardware(); FolderConfiguration config = new FolderConfiguration(); config.createDefault(); Screen screen = hw.getScreen(); config.setDensityQualifier(new DensityQualifier(screen.getPixelDensity())); config.setNavigationMethodQualifier(new NavigationMethodQualifier(hw.getNav())); ScreenDimensionQualifier sdq; if (screen.getXDimension() > screen.getYDimension()) { sdq = new ScreenDimensionQualifier(screen.getXDimension(), screen.getYDimension()); } else { sdq = new ScreenDimensionQualifier(screen.getYDimension(), screen.getXDimension()); } config.setScreenDimensionQualifier(sdq); config.setScreenRatioQualifier(new ScreenRatioQualifier(screen.getRatio())); config.setScreenSizeQualifier(new ScreenSizeQualifier(screen.getSize())); config.setTextInputMethodQualifier(new TextInputMethodQualifier(hw.getKeyboard())); config.setTouchTypeQualifier(new TouchScreenQualifier(screen.getMechanism())); config.setKeyboardStateQualifier(new KeyboardStateQualifier(state.getKeyState())); config.setNavigationStateQualifier(new NavigationStateQualifier(state.getNavState())); config.setScreenOrientationQualifier( new ScreenOrientationQualifier(state.getOrientation())); config.updateScreenWidthAndHeight(); // Setup some default qualifiers config.setUiModeQualifier(new UiModeQualifier(UiMode.NORMAL)); config.setNightModeQualifier(new NightModeQualifier(NightMode.NOTNIGHT)); config.setCountryCodeQualifier(new CountryCodeQualifier()); config.setLanguageQualifier(new LanguageQualifier()); config.setLayoutDirectionQualifier(new LayoutDirectionQualifier()); config.setNetworkCodeQualifier(new NetworkCodeQualifier()); config.setRegionQualifier(new RegionQualifier()); config.setVersionQualifier(new VersionQualifier()); return config; }
Example #17
Source File: UiModeQualifier.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public UiMode getValue() { return mValue; }
Example #18
Source File: UiModeQualifier.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public UiModeQualifier(UiMode value) { mValue = value; }
Example #19
Source File: Hardware.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void addAllSupportedUiModes(@NonNull Collection<UiMode> uiModes) { mUiModes.addAll(uiModes); }
Example #20
Source File: Hardware.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
public void addSupportedUiMode(@NonNull UiMode uiMode) { mUiModes.add(uiMode); }