Skip to content

Commit 5a909fb

Browse files
committed
Improvements to library
1 parent fb1fe18 commit 5a909fb

File tree

12 files changed

+119
-44
lines changed

12 files changed

+119
-44
lines changed

app/build.gradle

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,15 @@ android {
3030
repositories {
3131
maven {
3232
url = uri("https://maven.pkg.github.com/digitalhealthintegration/recovers-integration-sample")
33+
credentials {
34+
username = System.getenv('GITHUB_USER')
35+
password = System.getenv('GITHUB_TOKEN')
36+
}
3337
}
3438
}
39+
testOptions {
40+
unitTests.returnDefaultValues = true
41+
}
3542
}
3643

3744

@@ -41,8 +48,9 @@ dependencies {
4148
implementation 'com.google.android.material:material:1.3.0'
4249
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
4350
implementation 'org.jetbrains:annotations:15.0'
44-
implementation 'com.iprd:intent-proto:0'
51+
implementation('com.iprd:intent-proto:0.19')
4552
testImplementation 'junit:junit:4.+'
4653
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
4754
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
55+
testImplementation 'org.json:json:20180813'
4856
}

app/src/main/java/com/iprd/testapplication/MainActivity.java

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import org.json.JSONObject;
1818
import com.iprd.intent_proto.*;
1919

20+
import java.util.ArrayList;
21+
2022
public class MainActivity extends AppCompatActivity {
2123

2224
public static int NEW_REQUEST_CODE = 401;
@@ -42,7 +44,7 @@ protected void onCreate(Bundle savedInstanceState) {
4244
Button btnEdit = findViewById(R.id.btnEdit);
4345
Button btnRecall = findViewById(R.id.btnRecall);
4446
btnNew.setOnClickListener(v -> {
45-
openSmartHealthAppWithCampaignDetails();
47+
openSmartHealthAppWithCampaignDetailsUsingMessagingProtocol();
4648
});
4749

4850
btnEdit.setOnClickListener(v -> {
@@ -72,6 +74,55 @@ void openSmartHealthApp() {
7274
}
7375
}
7476

77+
void openSmartHealthAppWithCampaignDetailsUsingMessagingProtocol() {
78+
KeyTypeValue keyTypeValue = new KeyTypeValue("key", "type", "value");
79+
ArrayList<KeyTypeValue> udf = new ArrayList<>();
80+
udf.add(keyTypeValue);
81+
ArrayList<Integer> verticals = new ArrayList<>();
82+
verticals.add(2);
83+
CampaignDataClass campaignDataClass =
84+
new CampaignDataClassBuilder()
85+
.setId("6ecb0566-7006-4382-9cdc-202d9010858a")
86+
.setName("Oyo State June 2021 Health Campaign")
87+
.setUrl("https://health.oyostate.gov.ng/tomotiya/")
88+
.setVerticals(verticals)
89+
.setLocationPrecision(2)
90+
.setTimePrecision(5)
91+
.setUdf(udf)
92+
.build();
93+
94+
FamilyMemberDataClass[] familyMemberDataClasses = new FamilyMemberDataClass[]{
95+
new FamilyMemberDataBuilder()
96+
.setDob("1993-09-12")
97+
.setGender("M")
98+
.setHead(true)
99+
.setMemberID("1234")
100+
.setName("kash")
101+
.setStatus(FamilyMemberDataClass.Status.New)
102+
.build()
103+
};
104+
105+
FamilySurveyMessageRequest familySurveyMessageRequest =
106+
new FamilySurveyMessageRequestBuilder()
107+
.setCampaign(campaignDataClass)
108+
.setFamilyID("tempID")
109+
.setHcwUserName("tempUser")
110+
.setPrimaryContactPhone("123456")
111+
.setVerificationMethod("BIOMETRIC")
112+
.setFamilyMembers(familyMemberDataClasses)
113+
.build();
114+
115+
Intent sendIntent = new Intent();
116+
sendIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
117+
sendIntent.putExtra(BUNDLE_INPUT_JSON, familySurveyMessageRequest.toJsonString());
118+
sendIntent.setAction("HOME_SCREEN_IPRD");
119+
sendIntent.setComponent(new ComponentName("com.iprd.opencamplink", "com.iprd.opencamplink.records.OpenCampLinkHomeActivity"));
120+
Intent chooser = Intent.createChooser(sendIntent, "IPRD OCL");
121+
if (sendIntent.resolveActivity(getPackageManager()) != null) {
122+
startActivityForResult(chooser, NEW_REQUEST_CODE);
123+
}
124+
}
125+
75126
void openSmartHealthAppWithCampaignDetails() {
76127
inputJson = "{\n" +
77128
" \"campaign\": {\n" +

intent-proto/build.gradle

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,37 @@ dependencies {
3434

3535
implementation 'androidx.appcompat:appcompat:1.3.1'
3636
implementation 'com.google.android.material:material:1.4.0'
37-
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.11.1'
37+
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.12.3'
3838
testImplementation 'junit:junit:4.+'
3939
androidTestImplementation "com.google.truth:truth:1.1.3"
4040
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
4141
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
42-
implementation "androidx.core:core-ktx:+"
42+
implementation "androidx.core:core-ktx:1.6.0"
4343
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
4444
}
45-
46-
publishing {
47-
repositories {
48-
maven {
49-
name = "GitHubPackages"
50-
url = uri("https://maven.pkg.github.com/digitalhealthintegration/recovers-integration-sample")
51-
credentials {
52-
username = System.getenv('GITHUB_USER')
53-
password = System.getenv('GITHUB_TOKEN')
45+
afterEvaluate {
46+
publishing {
47+
repositories {
48+
maven {
49+
name = "GitHubPackages"
50+
url = uri("https://maven.pkg.github.com/digitalhealthintegration/recovers-integration-sample")
51+
credentials {
52+
username = System.getenv('GITHUB_USER')
53+
password = System.getenv('GITHUB_TOKEN')
54+
}
5455
}
5556
}
56-
}
57-
publications {
58-
gpr(MavenPublication) {
59-
artifact("$buildDir/outputs/aar/${artifactId}-debug.aar")
60-
groupId 'com.iprd'
61-
artifactId 'intent-proto'
62-
version '0.1'
57+
publications {
58+
gpr(MavenPublication) {
59+
from components.release
60+
groupId 'com.iprd'
61+
artifactId 'intent-proto'
62+
version '0.19'
63+
}
6364
}
6465
}
6566
}
67+
6668
repositories {
6769
mavenCentral()
6870
}

intent-proto/src/main/java/com/iprd/intent_proto/BaseRequestMessage.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package com.iprd.intent_proto;
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
45
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import com.fasterxml.jackson.core.JsonProcessingException;
7+
import com.fasterxml.jackson.databind.ObjectMapper;
58

69
@JsonIgnoreProperties(ignoreUnknown = true)
10+
@JsonInclude(JsonInclude.Include.NON_NULL)
711
public class BaseRequestMessage {
812
public CampaignDataClass getCampaign() {
913
return campaign;
@@ -15,4 +19,9 @@ void setCampaign(CampaignDataClass campaign) {
1519

1620
@JsonProperty("campaign")
1721
private CampaignDataClass campaign;
22+
23+
public String toJsonString() throws JsonProcessingException {
24+
ObjectMapper mapper = new ObjectMapper();
25+
return mapper.writeValueAsString(this);
26+
}
1827
}

intent-proto/src/main/java/com/iprd/intent_proto/CampaignDataClass.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.iprd.intent_proto;
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
45
import com.fasterxml.jackson.annotation.JsonProperty;
56

67
import org.json.JSONObject;
@@ -10,6 +11,7 @@
1011

1112

1213
@JsonIgnoreProperties(ignoreUnknown = true)
14+
@JsonInclude(JsonInclude.Include.NON_NULL)
1315
public class CampaignDataClass {
1416
public String getId() {
1517
return id;

intent-proto/src/main/java/com/iprd/intent_proto/FamilyMemberDataBuilder.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,11 @@ public FamilyMemberDataBuilder setGender(String value) {
2828
return this;
2929
}
3030

31-
public FamilyMemberDataBuilder setStatus(String value) {
32-
familyMemberDataClass.setStatus(value);
33-
return this;
34-
}
35-
3631
public FamilyMemberDataBuilder setStatus(FamilyMemberDataClass.Status value) {
3732
familyMemberDataClass.setStatus(value);
3833
return this;
3934
}
35+
4036
private FamilyMemberDataClass familyMemberDataClass;
4137

4238
public FamilyMemberDataBuilder(){

intent-proto/src/main/java/com/iprd/intent_proto/FamilyMemberDataClass.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import java.util.Objects;
66

77
@JsonIgnoreProperties(ignoreUnknown = true)
8+
@JsonInclude(JsonInclude.Include.NON_NULL)
89
public class FamilyMemberDataClass {
910
public FamilyMemberDataClass(){
1011

1112
}
1213

1314
public enum Status{
14-
NEW,UPDATE,DELETE;
15+
New, Update, Delete; // Using Caps for first letter because of backward compatibility
1516
}
1617
@JsonProperty("memberId")
1718
private String memberID;
@@ -42,19 +43,6 @@ public enum Status{
4243
void setGender(String value) { this.gender = value; }
4344

4445
public Status getStatus() { return status; }
45-
void setStatus(String value) {
46-
switch (value){
47-
case "New":
48-
this.status = Status.NEW;
49-
break;
50-
case "Updated":
51-
this.status = Status.UPDATE;
52-
break;
53-
case "Deleted":
54-
this.status = Status.DELETE;
55-
break;
56-
}
57-
}
5846
void setStatus(Status value) {
5947
this.status = value;
6048
}

intent-proto/src/main/java/com/iprd/intent_proto/FamilySurveyMessageRequest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package com.iprd.intent_proto;
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
45
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import com.fasterxml.jackson.core.JsonProcessingException;
7+
import com.fasterxml.jackson.databind.ObjectMapper;
58

69

710
@JsonIgnoreProperties(ignoreUnknown = true)
11+
@JsonInclude(JsonInclude.Include.NON_NULL)
812
public class FamilySurveyMessageRequest extends BaseRequestMessage {
913
public FamilySurveyMessageRequest(){}
1014

@@ -105,4 +109,15 @@ public String getFamilySurveyResponse() {
105109
void setFamilySurveyResponse(String value) {
106110
this.familySurveyResponse = value;
107111
}
112+
113+
@Override
114+
public String toJsonString() {
115+
ObjectMapper mapper = new ObjectMapper();
116+
try {
117+
return mapper.writeValueAsString(this);
118+
} catch (JsonProcessingException e) {
119+
e.printStackTrace();
120+
}
121+
return null;
122+
}
108123
}

intent-proto/src/main/java/com/iprd/intent_proto/KeyTypeValue.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
import android.annotation.SuppressLint;
44

55
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
6+
import com.fasterxml.jackson.annotation.JsonInclude;
67
import com.fasterxml.jackson.annotation.JsonProperty;
78

89
import java.util.Objects;
910

1011

1112
@JsonIgnoreProperties(ignoreUnknown = true)
13+
@JsonInclude(JsonInclude.Include.NON_NULL)
1214
public class KeyTypeValue {
1315

1416
@JsonProperty("k")

intent-proto/src/main/java/com/iprd/intent_proto/ResponseMessage.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package com.iprd.intent_proto;
22

33
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
45
import com.fasterxml.jackson.annotation.JsonProperty;
56

67
import org.json.JSONArray;
78

89
@JsonIgnoreProperties(ignoreUnknown = true)
10+
@JsonInclude(JsonInclude.Include.NON_NULL)
911
public class ResponseMessage {
1012

1113
public String getFamilyId() {
@@ -68,4 +70,5 @@ void setFamilyMembers(JSONArray familyMembers) {
6870
private String resultText;
6971
@JsonProperty("family Members")
7072
private JSONArray familyMembers;
73+
7174
}

0 commit comments

Comments
 (0)