public void test12Key() {
assertEquals(true, timq.checkAndSet("12key", config)); //$NON-NLS-1$
assertTrue(config.getTextInputMethodQualifier() != null);
- assertEquals(Keyboard.TWELVEKEYS, config.getTextInputMethodQualifier().getValue());
+ assertEquals(Keyboard.TWELVEKEY, config.getTextInputMethodQualifier().getValue());
assertEquals("12key", config.getTextInputMethodQualifier().toString()); //$NON-NLS-1$
}
* <p/>This is used in the manifest in the uses-configuration node and in the resource folder names.
*/
public enum Keyboard {
- NOKEY("nokeys", "No Keys"), //$NON-NLS-1$
- QWERTY("qwerty", "Qwerty"), //$NON-NLS-1$
- TWELVEKEYS("12key", "12 Key"); //$NON-NLS-1$
+ NOKEY("nokeys", null, "No Keys"), //$NON-NLS-1$
+ QWERTY("qwerty", null, "Qwerty"), //$NON-NLS-1$
+ TWELVEKEY("12key", "twelvekey", "12 Key"); //$NON-NLS-1$
- private String mValue;
+ private String mValue, mValue2;
private String mDisplayValue;
- private Keyboard(String value, String displayValue) {
+ private Keyboard(String value, String value2, String displayValue) {
mValue = value;
+ mValue2 = value2;
mDisplayValue = displayValue;
}
* @return the enum for the qualifier value or null if no matching was found.
*/
public static Keyboard getEnum(String value) {
- for (Keyboard orient : values()) {
- if (orient.mValue.equals(value)) {
- return orient;
+ for (Keyboard kbrd : values()) {
+ if (kbrd.mValue.equals(value) ||
+ (kbrd.mValue2 != null && kbrd.mValue2.equals(value))) {
+ return kbrd;
}
}
public final static String NODE_USES_SDK = "uses-sdk";
public final static String NODE_INSTRUMENTATION = "instrumentation";
public final static String NODE_USES_LIBRARY = "uses-library";
- public static final String NODE_SUPPORTS_SCREENS = "supports-screens";
+ public final static String NODE_SUPPORTS_SCREENS = "supports-screens";
+ public final static String NODE_USES_CONFIGURATION = "uses-configuration";
public final static String ATTRIBUTE_PACKAGE = "package";
public final static String ATTRIBUTE_VERSIONCODE = "versionCode";
public final static String ATTRIBUTE_MIN_SDK_VERSION = "minSdkVersion";
public final static String ATTRIBUTE_TARGET_PACKAGE = "targetPackage";
public final static String ATTRIBUTE_EXPORTED = "exported";
- public final static String ATTRIBUTE_RESIZABLE = "resizeable";
+ public final static String ATTRIBUTE_RESIZEABLE = "resizeable";
public final static String ATTRIBUTE_ANYDENSITY = "anyDensity";
public final static String ATTRIBUTE_SMALLSCREENS = "smallScreens";
public final static String ATTRIBUTE_NORMALSCREENS = "normalScreens";
public final static String ATTRIBUTE_LARGESCREENS = "largeScreens";
+ public final static String ATTRIBUTE_REQ_5WAYNAV = "reqFiveWayNav";
+ public final static String ATTRIBUTE_REQ_NAVIGATION = "reqNavigation";
+ public final static String ATTRIBUTE_REQ_HARDKEYBOARD = "reqHardKeyboard";
+ public final static String ATTRIBUTE_REQ_KEYBOARDTYPE = "reqKeyboardType";
+ public final static String ATTRIBUTE_REQ_TOUCHSCREEN = "reqTouchScreen";
/**
* Returns the package for a given project.
import com.android.sdklib.io.IAbstractFile;
import com.android.sdklib.io.IAbstractFolder;
import com.android.sdklib.io.StreamException;
+import com.android.sdklib.resources.Keyboard;
+import com.android.sdklib.resources.Navigation;
+import com.android.sdklib.resources.TouchScreen;
import com.android.sdklib.xml.ManifestData.Activity;
import com.android.sdklib.xml.ManifestData.Instrumentation;
import com.android.sdklib.xml.ManifestData.SupportsScreens;
+import com.android.sdklib.xml.ManifestData.UsesConfiguration;
import org.xml.sax.Attributes;
import org.xml.sax.ErrorHandler;
/**
* XML error & data handler used when parsing the AndroidManifest.xml file.
* <p/>
- * This serves both as an {@link XmlErrorHandler} to report errors and as a data repository
- * to collect data from the manifest.
+ * During parsing this will fill up the {@link ManifestData} object given to the constructor
+ * and call out errors to the given {@link ManifestErrorHandler}.
*/
private static class ManifestHandler extends DefaultHandler {
private Locator mLocator;
/**
- * Creates a new {@link ManifestHandler}, which is also an {@link XmlErrorHandler}.
+ * Creates a new {@link ManifestHandler}.
*
* @param manifestFile The manifest file being parsed. Can be null.
* @param errorListener An optional error listener.
true /* hasNamespace */);
} else if (AndroidManifest.NODE_INSTRUMENTATION.equals(localName)) {
processInstrumentationNode(attributes);
+
} else if (AndroidManifest.NODE_SUPPORTS_SCREENS.equals(localName)) {
processSupportsScreensNode(attributes);
+
+ } else if (AndroidManifest.NODE_USES_CONFIGURATION.equals(localName)) {
+ processUsesConfiguration(attributes);
+
}
break;
case LEVEL_ACTIVITY:
mManifestData.mSupportsScreens.mResizeable = Boolean.valueOf(
getAttributeValue(attributes,
- AndroidManifest.ATTRIBUTE_RESIZABLE, true /*hasNamespace*/));
+ AndroidManifest.ATTRIBUTE_RESIZEABLE, true /*hasNamespace*/));
mManifestData.mSupportsScreens.mAnyDensity = Boolean.valueOf(
getAttributeValue(attributes,
AndroidManifest.ATTRIBUTE_ANYDENSITY, true /*hasNamespace*/));
}
/**
+ * Processes the supports-screens node.
+ * @param attributes the attributes for the supports-screens node.
+ */
+ private void processUsesConfiguration(Attributes attributes) {
+ mManifestData.mUsesConfiguration = new UsesConfiguration();
+
+ mManifestData.mUsesConfiguration.mReqFiveWayNav = Boolean.valueOf(
+ getAttributeValue(attributes,
+ AndroidManifest.ATTRIBUTE_REQ_5WAYNAV, true /*hasNamespace*/));
+ mManifestData.mUsesConfiguration.mReqNavigation = Navigation.getEnum(
+ getAttributeValue(attributes,
+ AndroidManifest.ATTRIBUTE_REQ_NAVIGATION, true /*hasNamespace*/));
+ mManifestData.mUsesConfiguration.mReqHardKeyboard = Boolean.valueOf(
+ getAttributeValue(attributes,
+ AndroidManifest.ATTRIBUTE_REQ_HARDKEYBOARD, true /*hasNamespace*/));
+ mManifestData.mUsesConfiguration.mReqKeyboardType = Keyboard.getEnum(
+ getAttributeValue(attributes,
+ AndroidManifest.ATTRIBUTE_REQ_KEYBOARDTYPE, true /*hasNamespace*/));
+ mManifestData.mUsesConfiguration.mReqTouchScreen = TouchScreen.getEnum(
+ getAttributeValue(attributes,
+ AndroidManifest.ATTRIBUTE_REQ_TOUCHSCREEN, true /*hasNamespace*/));
+ }
+
+ /**
* Searches through the attributes list for a particular one and returns its value.
* @param attributes the attribute list to search through
* @param attributeName the name of the attribute to look for.
package com.android.sdklib.xml;
+import com.android.sdklib.resources.Keyboard;
+import com.android.sdklib.resources.Navigation;
+import com.android.sdklib.resources.TouchScreen;
+
import java.util.ArrayList;
import java.util.Set;
import java.util.TreeSet;
final ArrayList<String> mLibraries = new ArrayList<String>();
SupportsScreens mSupportsScreens;
+ UsesConfiguration mUsesConfiguration;
/**
* Instrumentation info obtained from manifest
}
}
+ /**
+ * Class representing the <code>supports-screens</code> node in the manifest.
+ */
public final static class SupportsScreens {
Boolean mResizeable;
Boolean mAnyDensity;
Boolean mLargeScreens;
Boolean mNormalScreens;
+ /**
+ * returns the value of the <code>resizeable</code> attribute or null if not present.
+ */
public Boolean getResizeable() {
return mResizeable;
}
+ /**
+ * returns the value of the <code>anyDensity</code> attribute or null if not present.
+ */
public Boolean getAnyDensity() {
return mAnyDensity;
}
+ /**
+ * returns the value of the <code>smallScreens</code> attribute or null if not present.
+ */
public Boolean getSmallScreens() {
return mSmallScreens;
}
+ /**
+ * returns the value of the <code>normalScreens</code> attribute or null if not present.
+ */
public Boolean getNormalScreens() {
return mNormalScreens;
}
+ /**
+ * returns the value of the <code>largeScreens</code> attribute or null if not present.
+ */
public Boolean getLargeScreens() {
return mLargeScreens;
}
}
+ /**
+ * Class representing the <code>uses-configuration</code> node in the manifest.
+ */
public final static class UsesConfiguration {
Boolean mReqFiveWayNav;
Boolean mReqHardKeyboard;
+ Keyboard mReqKeyboardType;
+ TouchScreen mReqTouchScreen;
+ Navigation mReqNavigation;
+
+ /**
+ * returns the value of the <code>reqFiveWayNav</code> attribute or null if not present.
+ */
+ public Boolean getReqFiveWayNav() {
+ return mReqFiveWayNav;
+ }
+
+ /**
+ * returns the value of the <code>reqNavigation</code> attribute or null if not present.
+ */
+ public Navigation getReqNavigation() {
+ return mReqNavigation;
+ }
+
+ /**
+ * returns the value of the <code>reqHardKeyboard</code> attribute or null if not present.
+ */
+ public Boolean getReqHardKeyboard() {
+ return mReqHardKeyboard;
+ }
+
+ /**
+ * returns the value of the <code>reqKeyboardType</code> attribute or null if not present.
+ */
+ public Keyboard getReqKeyboardType() {
+ return mReqKeyboardType;
+ }
+
+ /**
+ * returns the value of the <code>reqTouchScreen</code> attribute or null if not present.
+ */
+ public TouchScreen getReqTouchScreen() {
+ return mReqTouchScreen;
+ }
}
/**
return mLibraries.toArray(new String[mLibraries.size()]);
}
+ /**
+ * Returns the {@link SupportsScreens} object representing the <code>supports-screens</code>
+ * node, or null if the node doesn't exist at all.
+ */
public SupportsScreens getSupportsScreens() {
return mSupportsScreens;
}
+ /**
+ * Returns the {@link UsesConfiguration} object representing the <code>uses-configuration</code>
+ * node, or null if the node doesn't exist at all.
+ */
+ public UsesConfiguration getUsesConfiguration() {
+ return mUsesConfiguration;
+ }
+
void addProcessName(String processName) {
if (mProcesses == null) {
mProcesses = new TreeSet<String>();
package com.android.sdklib.xml;
+import com.android.sdklib.resources.Keyboard;
+import com.android.sdklib.resources.Navigation;
+import com.android.sdklib.resources.TouchScreen;
+
import java.io.InputStream;
import junit.framework.TestCase;
public void testSupportsScreen() {
ManifestData.SupportsScreens supportsScreens = mManifestTestApp.getSupportsScreens();
+ assertNotNull(supportsScreens);
assertEquals(Boolean.TRUE, supportsScreens.getAnyDensity());
assertEquals(Boolean.TRUE, supportsScreens.getResizeable());
assertEquals(Boolean.TRUE, supportsScreens.getSmallScreens());
assertEquals(Boolean.TRUE, supportsScreens.getLargeScreens());
}
+ public void testUsesConfiguration() {
+ ManifestData.UsesConfiguration usesConfig = mManifestTestApp.getUsesConfiguration();
+
+ assertNotNull(usesConfig);
+ assertEquals(Boolean.TRUE, usesConfig.getReqFiveWayNav());
+ assertEquals(Navigation.NONAV, usesConfig.getReqNavigation());
+ assertEquals(Boolean.TRUE, usesConfig.getReqHardKeyboard());
+ assertEquals(Keyboard.TWELVEKEY, usesConfig.getReqKeyboardType());
+ assertEquals(TouchScreen.FINGER, usesConfig.getReqTouchScreen());
+ }
+
private void assertEquals(ManifestData.Activity lhs, ManifestData.Activity rhs) {
assertTrue(lhs == rhs || (lhs != null && rhs != null));
if (lhs != null && rhs != null) {