Skip to content

Commit

Permalink
Merge pull request #1394 from dimagi/copy_of_rc/field-shading
Browse files Browse the repository at this point in the history
Copy of rc/field shading
  • Loading branch information
shubham1g5 authored Jan 5, 2024
2 parents 544393c + 8d8d056 commit eaf846c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/main/java/org/commcare/suite/model/DetailField.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class DetailField implements Externalizable {
private EndpointAction endpointAction;

private boolean showBorder;
private boolean showShading;

/**
* Optional hint which provides a hint for whether rich media should be
Expand Down Expand Up @@ -210,6 +211,7 @@ public void readExternal(DataInputStream in, PrototypeFactory pf) throws IOExcep
cssID = ExtUtil.nullIfEmpty(ExtUtil.readString(in));
endpointAction = (EndpointAction)ExtUtil.read(in, new ExtWrapNullable(EndpointAction.class), pf);
showBorder = ExtUtil.readBool(in);
showShading = ExtUtil.readBool(in);
}

@Override
Expand Down Expand Up @@ -241,6 +243,7 @@ public void writeExternal(DataOutputStream out) throws IOException {
ExtUtil.writeString(out, ExtUtil.emptyIfNull(cssID));
ExtUtil.write(out, new ExtWrapNullable(endpointAction));
ExtUtil.writeBool(out, showBorder);
ExtUtil.writeBool(out, showShading);
}

public int getGridX() {
Expand Down Expand Up @@ -284,6 +287,10 @@ public boolean getShowBorder() {
return showBorder;
}

public boolean getShowShading() {
return showShading;
}

public static class Builder {
final DetailField field;

Expand Down Expand Up @@ -410,5 +417,7 @@ public void setEndpointAction(EndpointAction endpointAction) {
public void setShowBorder(boolean showBorder) {
field.showBorder = showBorder;
}

public void setShowShading(boolean showShading) { field.showShading = showShading; }
}
}
6 changes: 6 additions & 0 deletions src/main/java/org/commcare/suite/model/Style.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class Style {
private String verticalAlign;

private boolean showBorder;
private boolean showShading;

public Style(){}

Expand All @@ -38,6 +39,7 @@ public Style(DetailField detail){
verticalAlign = detail.getVerticalAlign();
horizontalAlign = detail.getHorizontalAlign();
showBorder = detail.getShowBorder();
showShading = detail.getShowShading();
}

enum DisplayFormat {
Expand Down Expand Up @@ -125,4 +127,8 @@ public String getVerticalAlign() {
public boolean getShowBorder() {
return showBorder;
}

public boolean getShowShading() {
return showShading;
}
}
3 changes: 3 additions & 0 deletions src/main/java/org/commcare/xml/StyleParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public Integer parse() throws InvalidStructureException, IOException, XmlPullPar
String showBorder = parser.getAttributeValue(null, "show-border");
builder.setShowBorder(Boolean.parseBoolean(showBorder));

String showShading = parser.getAttributeValue(null, "show-shading");
builder.setShowShading(Boolean.parseBoolean(showShading));

parser.nextTag();

return Integer.valueOf(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,13 @@ public void testDetailWithBorder() {
assertTrue(field1.getShowBorder());
}

@Test
public void testDetailWithShading() {
Detail detail = mApp.getSession().getPlatform().getDetail("m0_case_short");
DetailField field1 = detail.getFields()[0];
assertTrue(field1.getShowShading());
}

@Test
public void testDefaultEndpointRelevancy_shouldBeTrue() {
Endpoint endpoint = mApp.getSession().getPlatform().getEndpoint("endpoint_with_no_relevancy");
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/app_structure/suite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</field>
</lookup>
<field>
<style horz-align="left" vert-align="center" font-size="small" show-border="true">
<style horz-align="left" vert-align="center" font-size="small" show-border="true" show-shading="true">
<grid grid-height="2" grid-width="3" grid-x="3" grid-y="5"/>
</style>
<header>
Expand Down

0 comments on commit eaf846c

Please sign in to comment.