Skip to content

Commit

Permalink
Merge pull request #92 from kaeppler/manifest-update
Browse files Browse the repository at this point in the history
Add support for writing the supports-screens and compatible-screens elements from manifest-update mojo
  • Loading branch information
mosabua committed Mar 12, 2012
2 parents f1e354b + 6314a0e commit f5e8784
Show file tree
Hide file tree
Showing 13 changed files with 566 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.jayway.maven.plugins.android.common;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class XmlHelper {

public static void removeDirectChildren(Node parent) {
NodeList childNodes = parent.getChildNodes();
while (childNodes.getLength() > 0) {
parent.removeChild(childNodes.item(0));
}
}

public static Element getOrCreateElement(Document doc, Element manifestElement,
String elementName) {
NodeList nodeList = manifestElement.getElementsByTagName(elementName);
Element element = null;
if (nodeList.getLength() == 0) {
element = doc.createElement(elementName);
manifestElement.appendChild(element);
} else {
element = (Element) nodeList.item(0);
}
return element;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.jayway.maven.plugins.android.configuration;

import java.util.List;

import com.jayway.maven.plugins.android.standalonemojos.CompatibleScreen;
import com.jayway.maven.plugins.android.standalonemojos.SupportsScreens;

/**
* Configuration for the manifest update. This class is only the definition of the parameters that are shadowed in
* {@link com.jayway.maven.plugins.android.standalonemojos.ManifestUpdateMojo} and used there.
Expand Down Expand Up @@ -37,6 +42,20 @@ public class Manifest {
*/
protected Boolean debuggable;

/**
* Mirror of
* {@link com.jayway.maven.plugins.android.standalonemojos.ManifestUpdateMojo#manifestSupportsScreens}
* .
*/
protected SupportsScreens supportsScreens;

/**
* Mirror of
* {@link com.jayway.maven.plugins.android.standalonemojos.ManifestUpdateMojo#manifestCompatibleScreens}
* .
*/
protected List<CompatibleScreen> compatibleScreens;

public String getVersionName() {
return versionName;
}
Expand All @@ -60,4 +79,12 @@ public String getSharedUserId() {
public Boolean getDebuggable() {
return debuggable;
}

public SupportsScreens getSupportsScreens() {
return supportsScreens;
}

public List<CompatibleScreen> getCompatibleScreens() {
return compatibleScreens;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.jayway.maven.plugins.android.standalonemojos;

public class CompatibleScreen {

private String screenSize, screenDensity;

public String getScreenSize() {
return screenSize;
}

public void setScreenSize(String screenSize) {
this.screenSize = screenSize;
}

public String getScreenDensity() {
return screenDensity;
}

public void setScreenDensity(String screenDensity) {
this.screenDensity = screenDensity;
}

@Override
public boolean equals(Object obj) {
if (obj instanceof CompatibleScreen) {
CompatibleScreen that = (CompatibleScreen) obj;
return this.screenDensity.equals(that.screenDensity)
&& this.screenSize.equals(that.screenSize);
}
return false;
}

@Override
public int hashCode() {
return (screenDensity + screenSize).hashCode();
}

@Override
public String toString() {
return screenSize + ":" + screenDensity;
}
}
Loading

0 comments on commit f5e8784

Please sign in to comment.