diff options
Diffstat (limited to 'ide_common')
8 files changed, 95 insertions, 95 deletions
diff --git a/ide_common/src/com/android/ide/common/resources/SingleResourceFile.java b/ide_common/src/com/android/ide/common/resources/SingleResourceFile.java index cd2b627..9c8977e 100644 --- a/ide_common/src/com/android/ide/common/resources/SingleResourceFile.java +++ b/ide_common/src/com/android/ide/common/resources/SingleResourceFile.java @@ -18,7 +18,7 @@ package com.android.ide.common.resources; import com.android.ide.common.rendering.api.DensityBasedResourceValue; import com.android.ide.common.rendering.api.ResourceValue; -import com.android.ide.common.resources.configuration.PixelDensityQualifier; +import com.android.ide.common.resources.configuration.DensityQualifier; import com.android.io.IAbstractFile; import com.android.resources.FolderTypeRelationship; import com.android.resources.ResourceType; @@ -57,7 +57,7 @@ public class SingleResourceFile extends ResourceFile { mResourceName = getResourceName(mType); // test if there's a density qualifier associated with the resource - PixelDensityQualifier qualifier = folder.getConfiguration().getPixelDensityQualifier(); + DensityQualifier qualifier = folder.getConfiguration().getDensityQualifier(); if (qualifier == null) { mValue = new ResourceValue(mType, getResourceName(mType), diff --git a/ide_common/src/com/android/ide/common/resources/configuration/PixelDensityQualifier.java b/ide_common/src/com/android/ide/common/resources/configuration/DensityQualifier.java index 80842a8..bb23b44 100644 --- a/ide_common/src/com/android/ide/common/resources/configuration/PixelDensityQualifier.java +++ b/ide_common/src/com/android/ide/common/resources/configuration/DensityQualifier.java @@ -25,18 +25,18 @@ import java.util.regex.Pattern; /** * Resource Qualifier for Screen Pixel Density. */ -public final class PixelDensityQualifier extends EnumBasedResourceQualifier { +public final class DensityQualifier extends EnumBasedResourceQualifier { private final static Pattern sDensityLegacyPattern = Pattern.compile("^(\\d+)dpi$");//$NON-NLS-1$ - public static final String NAME = "Pixel Density"; + public static final String NAME = "Density"; private Density mValue = Density.MEDIUM; - public PixelDensityQualifier() { + public DensityQualifier() { // pass } - public PixelDensityQualifier(Density value) { + public DensityQualifier(Density value) { mValue = value; } @@ -79,9 +79,9 @@ public final class PixelDensityQualifier extends EnumBasedResourceQualifier { } if (density != null) { - PixelDensityQualifier qualifier = new PixelDensityQualifier(); + DensityQualifier qualifier = new DensityQualifier(); qualifier.mValue = density; - config.setPixelDensityQualifier(qualifier); + config.setDensityQualifier(qualifier); return true; } @@ -90,7 +90,7 @@ public final class PixelDensityQualifier extends EnumBasedResourceQualifier { @Override public boolean isMatchFor(ResourceQualifier qualifier) { - if (qualifier instanceof PixelDensityQualifier) { + if (qualifier instanceof DensityQualifier) { // as long as there's a density qualifier, it's always a match. // The best match will be found later. return true; @@ -105,8 +105,8 @@ public final class PixelDensityQualifier extends EnumBasedResourceQualifier { return true; } - PixelDensityQualifier compareQ = (PixelDensityQualifier)compareTo; - PixelDensityQualifier referenceQ = (PixelDensityQualifier)reference; + DensityQualifier compareQ = (DensityQualifier)compareTo; + DensityQualifier referenceQ = (DensityQualifier)reference; if (compareQ.mValue == referenceQ.mValue) { // what we have is already the best possible match (exact match) diff --git a/ide_common/src/com/android/ide/common/resources/configuration/FolderConfiguration.java b/ide_common/src/com/android/ide/common/resources/configuration/FolderConfiguration.java index 8b04bac..c0d1293 100644 --- a/ide_common/src/com/android/ide/common/resources/configuration/FolderConfiguration.java +++ b/ide_common/src/com/android/ide/common/resources/configuration/FolderConfiguration.java @@ -50,10 +50,10 @@ public final class FolderConfiguration implements Comparable<FolderConfiguration private final static int INDEX_SMALLEST_SCREEN_WIDTH = 4; private final static int INDEX_SCREEN_WIDTH = 5; private final static int INDEX_SCREEN_HEIGHT = 6; - private final static int INDEX_SCREEN_SIZE = 7; + private final static int INDEX_SCREEN_LAYOUT_SIZE = 7; private final static int INDEX_SCREEN_RATIO = 8; private final static int INDEX_SCREEN_ORIENTATION = 9; - private final static int INDEX_DOCK_MODE = 10; + private final static int INDEX_UI_MODE = 10; private final static int INDEX_NIGHT_MODE = 11; private final static int INDEX_PIXEL_DENSITY = 12; private final static int INDEX_TOUCH_TYPE = 13; @@ -229,8 +229,8 @@ public final class FolderConfiguration implements Comparable<FolderConfiguration } else if (qualifier instanceof ScreenHeightQualifier) { mQualifiers[INDEX_SCREEN_HEIGHT] = qualifier; - } else if (qualifier instanceof ScreenSizeQualifier) { - mQualifiers[INDEX_SCREEN_SIZE] = qualifier; + } else if (qualifier instanceof ScreenLayoutSizeQualifier) { + mQualifiers[INDEX_SCREEN_LAYOUT_SIZE] = qualifier; } else if (qualifier instanceof ScreenRatioQualifier) { mQualifiers[INDEX_SCREEN_RATIO] = qualifier; @@ -238,13 +238,13 @@ public final class FolderConfiguration implements Comparable<FolderConfiguration } else if (qualifier instanceof ScreenOrientationQualifier) { mQualifiers[INDEX_SCREEN_ORIENTATION] = qualifier; - } else if (qualifier instanceof DockModeQualifier) { - mQualifiers[INDEX_DOCK_MODE] = qualifier; + } else if (qualifier instanceof UiModeQualifier) { + mQualifiers[INDEX_UI_MODE] = qualifier; } else if (qualifier instanceof NightModeQualifier) { mQualifiers[INDEX_NIGHT_MODE] = qualifier; - } else if (qualifier instanceof PixelDensityQualifier) { + } else if (qualifier instanceof DensityQualifier) { mQualifiers[INDEX_PIXEL_DENSITY] = qualifier; } else if (qualifier instanceof TouchScreenQualifier) { @@ -350,12 +350,12 @@ public final class FolderConfiguration implements Comparable<FolderConfiguration return (ScreenHeightQualifier) mQualifiers[INDEX_SCREEN_HEIGHT]; } - public void setScreenSizeQualifier(ScreenSizeQualifier qualifier) { - mQualifiers[INDEX_SCREEN_SIZE] = qualifier; + public void setScreenLayoutSizeQualifier(ScreenLayoutSizeQualifier qualifier) { + mQualifiers[INDEX_SCREEN_LAYOUT_SIZE] = qualifier; } - public ScreenSizeQualifier getScreenSizeQualifier() { - return (ScreenSizeQualifier)mQualifiers[INDEX_SCREEN_SIZE]; + public ScreenLayoutSizeQualifier getScreenLayoutSizeQualifier() { + return (ScreenLayoutSizeQualifier)mQualifiers[INDEX_SCREEN_LAYOUT_SIZE]; } public void setScreenRatioQualifier(ScreenRatioQualifier qualifier) { @@ -374,12 +374,12 @@ public final class FolderConfiguration implements Comparable<FolderConfiguration return (ScreenOrientationQualifier)mQualifiers[INDEX_SCREEN_ORIENTATION]; } - public void setDockModeQualifier(DockModeQualifier qualifier) { - mQualifiers[INDEX_DOCK_MODE] = qualifier; + public void setUiModeQualifier(UiModeQualifier qualifier) { + mQualifiers[INDEX_UI_MODE] = qualifier; } - public DockModeQualifier getDockModeQualifier() { - return (DockModeQualifier)mQualifiers[INDEX_DOCK_MODE]; + public UiModeQualifier getUiModeQualifier() { + return (UiModeQualifier)mQualifiers[INDEX_UI_MODE]; } public void setNightModeQualifier(NightModeQualifier qualifier) { @@ -390,12 +390,12 @@ public final class FolderConfiguration implements Comparable<FolderConfiguration return (NightModeQualifier)mQualifiers[INDEX_NIGHT_MODE]; } - public void setPixelDensityQualifier(PixelDensityQualifier qualifier) { + public void setDensityQualifier(DensityQualifier qualifier) { mQualifiers[INDEX_PIXEL_DENSITY] = qualifier; } - public PixelDensityQualifier getPixelDensityQualifier() { - return (PixelDensityQualifier)mQualifiers[INDEX_PIXEL_DENSITY]; + public DensityQualifier getDensityQualifier() { + return (DensityQualifier)mQualifiers[INDEX_PIXEL_DENSITY]; } public void setTouchTypeQualifier(TouchScreenQualifier qualifier) { @@ -457,7 +457,7 @@ public final class FolderConfiguration implements Comparable<FolderConfiguration /** * Updates the {@link SmallestScreenWidthQualifier}, {@link ScreenWidthQualifier}, and * {@link ScreenHeightQualifier} based on the (required) values of - * {@link ScreenDimensionQualifier} {@link PixelDensityQualifier}, and + * {@link ScreenDimensionQualifier} {@link DensityQualifier}, and * {@link ScreenOrientationQualifier}. * * Also the density cannot be {@link Density#NODPI} as it's not valid on a device. @@ -469,7 +469,7 @@ public final class FolderConfiguration implements Comparable<FolderConfiguration ResourceQualifier orientQ = mQualifiers[INDEX_SCREEN_ORIENTATION]; if (sizeQ != null && densityQ != null && orientQ != null) { - Density density = ((PixelDensityQualifier) densityQ).getValue(); + Density density = ((DensityQualifier) densityQ).getValue(); if (density == Density.NODPI) { return; } @@ -846,12 +846,12 @@ public final class FolderConfiguration implements Comparable<FolderConfiguration mQualifiers[INDEX_SMALLEST_SCREEN_WIDTH] = new SmallestScreenWidthQualifier(); mQualifiers[INDEX_SCREEN_WIDTH] = new ScreenWidthQualifier(); mQualifiers[INDEX_SCREEN_HEIGHT] = new ScreenHeightQualifier(); - mQualifiers[INDEX_SCREEN_SIZE] = new ScreenSizeQualifier(); + mQualifiers[INDEX_SCREEN_LAYOUT_SIZE] = new ScreenLayoutSizeQualifier(); mQualifiers[INDEX_SCREEN_RATIO] = new ScreenRatioQualifier(); mQualifiers[INDEX_SCREEN_ORIENTATION] = new ScreenOrientationQualifier(); - mQualifiers[INDEX_DOCK_MODE] = new DockModeQualifier(); + mQualifiers[INDEX_UI_MODE] = new UiModeQualifier(); mQualifiers[INDEX_NIGHT_MODE] = new NightModeQualifier(); - mQualifiers[INDEX_PIXEL_DENSITY] = new PixelDensityQualifier(); + mQualifiers[INDEX_PIXEL_DENSITY] = new DensityQualifier(); mQualifiers[INDEX_TOUCH_TYPE] = new TouchScreenQualifier(); mQualifiers[INDEX_KEYBOARD_STATE] = new KeyboardStateQualifier(); mQualifiers[INDEX_TEXT_INPUT_METHOD] = new TextInputMethodQualifier(); diff --git a/ide_common/src/com/android/ide/common/resources/configuration/ScreenSizeQualifier.java b/ide_common/src/com/android/ide/common/resources/configuration/ScreenLayoutSizeQualifier.java index 7ab6dd8..0f22d36 100644 --- a/ide_common/src/com/android/ide/common/resources/configuration/ScreenSizeQualifier.java +++ b/ide_common/src/com/android/ide/common/resources/configuration/ScreenLayoutSizeQualifier.java @@ -17,26 +17,26 @@ package com.android.ide.common.resources.configuration; import com.android.resources.ResourceEnum; -import com.android.resources.ScreenSize; +import com.android.resources.ScreenLayoutSize; /** * Resource Qualifier for Screen Size. Size can be "small", "normal", "large" and "x-large" */ -public class ScreenSizeQualifier extends EnumBasedResourceQualifier { +public class ScreenLayoutSizeQualifier extends EnumBasedResourceQualifier { public static final String NAME = "Screen Size"; - private ScreenSize mValue = null; + private ScreenLayoutSize mValue = null; - public ScreenSizeQualifier() { + public ScreenLayoutSizeQualifier() { } - public ScreenSizeQualifier(ScreenSize value) { + public ScreenLayoutSizeQualifier(ScreenLayoutSize value) { mValue = value; } - public ScreenSize getValue() { + public ScreenLayoutSize getValue() { return mValue; } @@ -57,10 +57,10 @@ public class ScreenSizeQualifier extends EnumBasedResourceQualifier { @Override public boolean checkAndSet(String value, FolderConfiguration config) { - ScreenSize size = ScreenSize.getEnum(value); + ScreenLayoutSize size = ScreenLayoutSize.getEnum(value); if (size != null) { - ScreenSizeQualifier qualifier = new ScreenSizeQualifier(size); - config.setScreenSizeQualifier(qualifier); + ScreenLayoutSizeQualifier qualifier = new ScreenLayoutSizeQualifier(size); + config.setScreenLayoutSizeQualifier(qualifier); return true; } diff --git a/ide_common/src/com/android/ide/common/resources/configuration/DockModeQualifier.java b/ide_common/src/com/android/ide/common/resources/configuration/UiModeQualifier.java index 2c832eb..f9ad0b7 100644 --- a/ide_common/src/com/android/ide/common/resources/configuration/DockModeQualifier.java +++ b/ide_common/src/com/android/ide/common/resources/configuration/UiModeQualifier.java @@ -16,27 +16,27 @@ package com.android.ide.common.resources.configuration; -import com.android.resources.DockMode; import com.android.resources.ResourceEnum; +import com.android.resources.UiMode; /** - * Resource Qualifier for Navigation Method. + * Resource Qualifier for UI Mode. */ -public final class DockModeQualifier extends EnumBasedResourceQualifier { +public final class UiModeQualifier extends EnumBasedResourceQualifier { - public static final String NAME = "Dock Mode"; + public static final String NAME = "UI Mode"; - private DockMode mValue; + private UiMode mValue; - public DockModeQualifier() { + public UiModeQualifier() { // pass } - public DockModeQualifier(DockMode value) { + public UiModeQualifier(UiMode value) { mValue = value; } - public DockMode getValue() { + public UiMode getValue() { return mValue; } @@ -52,15 +52,15 @@ public final class DockModeQualifier extends EnumBasedResourceQualifier { @Override public String getShortName() { - return "Dock Mode"; + return NAME; } @Override public boolean checkAndSet(String value, FolderConfiguration config) { - DockMode mode = DockMode.getEnum(value); + UiMode mode = UiMode.getEnum(value); if (mode != null) { - DockModeQualifier qualifier = new DockModeQualifier(mode); - config.setDockModeQualifier(qualifier); + UiModeQualifier qualifier = new UiModeQualifier(mode); + config.setUiModeQualifier(qualifier); return true; } @@ -69,13 +69,13 @@ public final class DockModeQualifier extends EnumBasedResourceQualifier { @Override public boolean isMatchFor(ResourceQualifier qualifier) { - // only NONE is a match other DockModes - if (mValue == DockMode.NONE) { + // 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 ((DockModeQualifier)qualifier).mValue == mValue; + return ((UiModeQualifier)qualifier).mValue == mValue; } @Override @@ -84,8 +84,8 @@ public final class DockModeQualifier extends EnumBasedResourceQualifier { return true; } - DockModeQualifier compareQualifier = (DockModeQualifier)compareTo; - DockModeQualifier referenceQualifier = (DockModeQualifier)reference; + UiModeQualifier compareQualifier = (UiModeQualifier)compareTo; + UiModeQualifier referenceQualifier = (UiModeQualifier)reference; if (compareQualifier.getValue() == referenceQualifier.getValue()) { // what we have is already the best possible match (exact match) @@ -93,8 +93,8 @@ public final class DockModeQualifier extends EnumBasedResourceQualifier { } else if (mValue == referenceQualifier.mValue) { // got new exact value, this is the best! return true; - } else if (mValue == DockMode.NONE) { - // else "none" can be a match in case there's no exact match + } else if (mValue == UiMode.NORMAL) { + // else "normal" can be a match in case there's no exact match return true; } diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/DockModeQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/DockModeQualifierTest.java index c2b7452..1653805 100644 --- a/ide_common/tests/src/com/android/ide/common/resources/configuration/DockModeQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/DockModeQualifierTest.java @@ -16,24 +16,24 @@ package com.android.ide.common.resources.configuration; -import com.android.resources.DockMode; +import com.android.resources.UiMode; import junit.framework.TestCase; public class DockModeQualifierTest extends TestCase { - private DockModeQualifier mCarQualifier; - private DockModeQualifier mDeskQualifier; - private DockModeQualifier mTVQualifier; - private DockModeQualifier mNoneQualifier; + private UiModeQualifier mCarQualifier; + private UiModeQualifier mDeskQualifier; + private UiModeQualifier mTVQualifier; + private UiModeQualifier mNoneQualifier; @Override protected void setUp() throws Exception { super.setUp(); - mCarQualifier = new DockModeQualifier(DockMode.CAR); - mDeskQualifier = new DockModeQualifier(DockMode.DESK); - mTVQualifier = new DockModeQualifier(DockMode.TELEVISION); - mNoneQualifier = new DockModeQualifier(DockMode.NONE); + mCarQualifier = new UiModeQualifier(UiMode.CAR); + mDeskQualifier = new UiModeQualifier(UiMode.DESK); + mTVQualifier = new UiModeQualifier(UiMode.TELEVISION); + mNoneQualifier = new UiModeQualifier(UiMode.NORMAL); } @Override diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/PixelDensityQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/PixelDensityQualifierTest.java index b99f2af..4ab493a 100644 --- a/ide_common/tests/src/com/android/ide/common/resources/configuration/PixelDensityQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/PixelDensityQualifierTest.java @@ -22,13 +22,13 @@ import junit.framework.TestCase; public class PixelDensityQualifierTest extends TestCase { - private PixelDensityQualifier pdq; + private DensityQualifier pdq; private FolderConfiguration config; @Override protected void setUp() throws Exception { super.setUp(); - pdq = new PixelDensityQualifier(); + pdq = new DensityQualifier(); config = new FolderConfiguration(); } @@ -41,9 +41,9 @@ public class PixelDensityQualifierTest extends TestCase { public void testCheckAndSet() { assertEquals(true, pdq.checkAndSet("ldpi", config));//$NON-NLS-1$ - assertTrue(config.getPixelDensityQualifier() != null); - assertEquals(Density.LOW, config.getPixelDensityQualifier().getValue()); - assertEquals("ldpi", config.getPixelDensityQualifier().toString()); //$NON-NLS-1$ + assertTrue(config.getDensityQualifier() != null); + assertEquals(Density.LOW, config.getDensityQualifier().getValue()); + assertEquals("ldpi", config.getDensityQualifier().toString()); //$NON-NLS-1$ } public void testFailures() { @@ -55,10 +55,10 @@ public class PixelDensityQualifierTest extends TestCase { } public void testIsBetterMatchThan() { - PixelDensityQualifier ldpi = new PixelDensityQualifier(Density.LOW); - PixelDensityQualifier mdpi = new PixelDensityQualifier(Density.MEDIUM); - PixelDensityQualifier hdpi = new PixelDensityQualifier(Density.HIGH); - PixelDensityQualifier xhdpi = new PixelDensityQualifier(Density.XHIGH); + DensityQualifier ldpi = new DensityQualifier(Density.LOW); + DensityQualifier mdpi = new DensityQualifier(Density.MEDIUM); + DensityQualifier hdpi = new DensityQualifier(Density.HIGH); + DensityQualifier xhdpi = new DensityQualifier(Density.XHIGH); // first test that each Q is a better match than all other Qs when the ref is the same Q. assertTrue(ldpi.isBetterMatchThan(mdpi, ldpi)); diff --git a/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenSizeQualifierTest.java b/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenSizeQualifierTest.java index b19f125..d05399d 100644 --- a/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenSizeQualifierTest.java +++ b/ide_common/tests/src/com/android/ide/common/resources/configuration/ScreenSizeQualifierTest.java @@ -16,19 +16,19 @@ package com.android.ide.common.resources.configuration; -import com.android.resources.ScreenSize; +import com.android.resources.ScreenLayoutSize; import junit.framework.TestCase; public class ScreenSizeQualifierTest extends TestCase { - private ScreenSizeQualifier ssq; + private ScreenLayoutSizeQualifier ssq; private FolderConfiguration config; @Override protected void setUp() throws Exception { super.setUp(); - ssq = new ScreenSizeQualifier(); + ssq = new ScreenLayoutSizeQualifier(); config = new FolderConfiguration(); } @@ -41,29 +41,29 @@ public class ScreenSizeQualifierTest extends TestCase { public void testSmall() { assertEquals(true, ssq.checkAndSet("small", config)); //$NON-NLS-1$ - assertTrue(config.getScreenSizeQualifier() != null); - assertEquals(ScreenSize.SMALL, config.getScreenSizeQualifier().getValue()); - assertEquals("small", config.getScreenSizeQualifier().toString()); //$NON-NLS-1$ + assertTrue(config.getScreenLayoutSizeQualifier() != null); + assertEquals(ScreenLayoutSize.SMALL, config.getScreenLayoutSizeQualifier().getValue()); + assertEquals("small", config.getScreenLayoutSizeQualifier().toString()); //$NON-NLS-1$ } public void testNormal() { assertEquals(true, ssq.checkAndSet("normal", config)); //$NON-NLS-1$ - assertTrue(config.getScreenSizeQualifier() != null); - assertEquals(ScreenSize.NORMAL, config.getScreenSizeQualifier().getValue()); - assertEquals("normal", config.getScreenSizeQualifier().toString()); //$NON-NLS-1$ + assertTrue(config.getScreenLayoutSizeQualifier() != null); + assertEquals(ScreenLayoutSize.NORMAL, config.getScreenLayoutSizeQualifier().getValue()); + assertEquals("normal", config.getScreenLayoutSizeQualifier().toString()); //$NON-NLS-1$ } public void testLarge() { assertEquals(true, ssq.checkAndSet("large", config)); //$NON-NLS-1$ - assertTrue(config.getScreenSizeQualifier() != null); - assertEquals(ScreenSize.LARGE, config.getScreenSizeQualifier().getValue()); - assertEquals("large", config.getScreenSizeQualifier().toString()); //$NON-NLS-1$ + assertTrue(config.getScreenLayoutSizeQualifier() != null); + assertEquals(ScreenLayoutSize.LARGE, config.getScreenLayoutSizeQualifier().getValue()); + assertEquals("large", config.getScreenLayoutSizeQualifier().toString()); //$NON-NLS-1$ } public void testXLarge() { assertEquals(true, ssq.checkAndSet("xlarge", config)); //$NON-NLS-1$ - assertTrue(config.getScreenSizeQualifier() != null); - assertEquals(ScreenSize.XLARGE, config.getScreenSizeQualifier().getValue()); - assertEquals("xlarge", config.getScreenSizeQualifier().toString()); //$NON-NLS-1$ + assertTrue(config.getScreenLayoutSizeQualifier() != null); + assertEquals(ScreenLayoutSize.XLARGE, config.getScreenLayoutSizeQualifier().getValue()); + assertEquals("xlarge", config.getScreenLayoutSizeQualifier().toString()); //$NON-NLS-1$ } } |