-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for removing elements from the resource file
- Loading branch information
Showing
6 changed files
with
184 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
resourcespoet/src/main/java/com/commit451/resourcespoet/Type.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.commit451.resourcespoet; | ||
|
||
/** | ||
* The various resource types | ||
* | ||
* @see <a href="https://developer.android.com/guide/topics/resources/available-resources.html">https://developer.android.com/guide/topics/resources/available-resources.html</a> | ||
*/ | ||
public enum Type { | ||
|
||
ATTR { | ||
@Override | ||
public String toString() { | ||
return "attr"; | ||
} | ||
}, | ||
BOOL { | ||
@Override | ||
public String toString() { | ||
return "bool"; | ||
} | ||
}, | ||
COLOR { | ||
@Override | ||
public String toString() { | ||
return "color"; | ||
} | ||
}, | ||
DRAWABLE { | ||
@Override | ||
public String toString() { | ||
return "drawable"; | ||
} | ||
}, | ||
DIMENSION { | ||
@Override | ||
public String toString() { | ||
return "dimen"; | ||
} | ||
}, | ||
ID { | ||
@Override | ||
public String toString() { | ||
return "item"; | ||
} | ||
}, | ||
INTEGER { | ||
@Override | ||
public String toString() { | ||
return "integer"; | ||
} | ||
}, | ||
INTEGER_ARRAY { | ||
@Override | ||
public String toString() { | ||
return "integer-array"; | ||
} | ||
}, | ||
PLURALS { | ||
@Override | ||
public String toString() { | ||
return "plurals"; | ||
} | ||
}, | ||
STRING { | ||
@Override | ||
public String toString() { | ||
return "string"; | ||
} | ||
}, | ||
STRING_ARRAY { | ||
@Override | ||
public String toString() { | ||
return "string-array"; | ||
} | ||
}, | ||
STYLE { | ||
@Override | ||
public String toString() { | ||
return "style"; | ||
} | ||
}, | ||
TYPED_ARRAY { | ||
@Override | ||
public String toString() { | ||
return "array"; | ||
} | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
resourcespoet/src/test/java/com/commit451/resourcespoet/RemoveTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.commit451.resourcespoet; | ||
|
||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
|
||
/** | ||
* Tests the resources creation | ||
*/ | ||
public class RemoveTest { | ||
|
||
@Test | ||
public void removeTest() throws Exception { | ||
ClassLoader classLoader = getClass().getClassLoader(); | ||
File file = new File(classLoader.getResource("remove_before.xml").getFile()); | ||
ResourcesPoet poet = ResourcesPoet.create(file) | ||
.remove(Type.STRING, "red"); | ||
|
||
TestUtil.assertEquals("remove_after.xml", poet); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="no"?> | ||
<resources> | ||
<color name="red">#FF0000</color> | ||
|
||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="no"?> | ||
<resources> | ||
<color name="red">#FF0000</color> | ||
<string name="red">red</string> | ||
</resources> |