Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ on:
- '*'
# tags:
# - '!v*'
pull_request:
branches:
- '*'
types: [opened, synchronize, reopened]

jobs:
build:
Expand Down
13 changes: 13 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ apollo {
]
}

tasks.withType(Test).configureEach {
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
showStandardStreams = false
}
}

dependencies {
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
implementation 'com.squareup.okhttp3:okhttp:4.11.0'
Expand All @@ -244,5 +252,10 @@ dependencies {
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})

// unit tests
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:5.5.0'
testImplementation 'org.robolectric:robolectric:4.11.1'
}

Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ public class ClientAndroidInterface {
@NonNull
private final Activity activity;
@NonNull
private final SQLHandler sqlHandler;
protected final SQLHandler sqlHandler;
@NonNull
private final HashMap<String, String> controls = new HashMap<>();
@NonNull
private final ArrayList<String> myList = new ArrayList<>();
@NonNull
private final ArrayList<String> enrolMessages = new ArrayList<>();
@NonNull
private final Global global;
protected final Global global;
@NonNull
private final StorageManager storageManager;
@NonNull
Expand All @@ -167,6 +167,14 @@ public class ClientAndroidInterface {
.build();
}

public ClientAndroidInterface(Activity activity, SQLHandler sqlHandler, Global global, Picasso picasso, StorageManager storageManager) {
this.activity = activity;
this.sqlHandler = sqlHandler;
this.global = global;
this.storageManager = storageManager;
this.picassoInstance = picasso;
}

@JavascriptInterface
@SuppressWarnings("unused")
public void SetUrl(String Url) {
Expand Down Expand Up @@ -666,7 +674,7 @@ public String getHF(int DistrictId, String HFLevel) {
return HFs.toString();
}

private HashMap<String, String> jsonToTable(String jsonString) {
protected HashMap<String, String> jsonToTable(String jsonString) {
HashMap<String, String> data = new HashMap<>();
try {
JSONArray array = new JSONArray(jsonString);
Expand Down Expand Up @@ -849,7 +857,7 @@ public void addOrUpdateFamilySms(int familyId, Boolean approve, String language)
}
}

private int isValidInsureeData(HashMap<String, String> data) {
protected int isValidInsureeData(HashMap<String, String> data) {
int Result;

String InsuranceNumber = data.get("txtInsuranceNumber");
Expand Down Expand Up @@ -1044,7 +1052,7 @@ else if (ExceedThreshold == 0)
return rtInsureeId;
}

private String copyImageFromGalleryToApplication(String selectedPath, String InsuranceNumber) {
protected String copyImageFromGalleryToApplication(String selectedPath, String InsuranceNumber) {
String result = "";

try {
Expand Down Expand Up @@ -2538,10 +2546,14 @@ public int UpdatePolicy(int PolicyId, String PayDate, int policystatus) throws P
return 1;//Update Success
}

protected ProgressDialog createProgressDialog(String title, String message) {
return ProgressDialog.show(activity, title, message);
}

@JavascriptInterface
@SuppressWarnings("unused")
public void uploadEnrolment() throws Exception {
final ProgressDialog finalPd = ProgressDialog.show(activity, activity.getResources().getString(R.string.Sync), activity.getResources().getString(R.string.SyncProcessing));
final ProgressDialog finalPd = createProgressDialog(activity.getResources().getString(R.string.Sync), activity.getResources().getString(R.string.SyncProcessing));
activity.runOnUiThread(() -> {
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
});
Expand Down Expand Up @@ -2790,7 +2802,7 @@ public boolean VerifyPhoto(JSONArray insurees) throws JSONException {
return result;
}

private int Enrol(int CallerId) throws UserException, JSONException, IOException {
protected int Enrol(int CallerId) throws UserException, JSONException, IOException {
ArrayList<String> verifiedId = new ArrayList<>();
myList.clear();
int rtEnrolledId = 0;
Expand Down Expand Up @@ -3121,7 +3133,7 @@ private int Enrol(int CallerId) throws UserException, JSONException, IOException
return EnrolResult;
}

private int uploadEnrols(
protected int uploadEnrols(
@NonNull JSONArray familyArray,
@NonNull JSONArray insureesArray,
@NonNull JSONArray policiesArray,
Expand Down Expand Up @@ -3570,7 +3582,7 @@ protected void onPostExecute(Boolean aBoolean) {
}
}

private void DeleteUploadedData(final int FamilyId, ArrayList<String> FamilyIDs, int CallerId) {
protected void DeleteUploadedData(final int FamilyId, ArrayList<String> FamilyIDs, int CallerId) {
if (FamilyIDs.size() == 0) {
FamilyIDs = new ArrayList<>() {{
add(String.valueOf(FamilyId));
Expand Down Expand Up @@ -5021,7 +5033,7 @@ public int getFamilyStat(int FamilyId) {
return status;
}

private int getFamilyStatus(int FamilyId) throws JSONException {
protected int getFamilyStatus(int FamilyId) throws JSONException {
if (FamilyId < 0) return 0;
@Language("SQL")
String Query = "SELECT isOffline FROM tblFamilies WHERE FamilyId = " + FamilyId;
Expand All @@ -5034,7 +5046,7 @@ private int getFamilyStatus(int FamilyId) throws JSONException {
else return 0;
}

private int getInsureeStatus(int InsureeId) throws JSONException {//herman
protected int getInsureeStatus(int InsureeId) throws JSONException {//herman
if (InsureeId == 0) return 1;
@Language("SQL")
String Query = "SELECT isOffline FROM tblInsuree WHERE InsureeId = " + InsureeId;
Expand Down Expand Up @@ -5252,7 +5264,7 @@ private int getNextAvailablePolicyId() {
return getMaxIdFromTable("PolicyId", "tblPolicy");
}

private int getNextAvailableInsureeId() {
protected int getNextAvailableInsureeId() {
return getMaxIdFromTable("InsureeId", "tblInsuree");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public Login(

@WorkerThread
public void execute(@NonNull String username, @NonNull String password) throws Exception {
if (Global.getGlobal().getOfficerCode() == null) {
Global.getGlobal().setOfficerCode(username);
}
String officerCode = Global.getGlobal().getOfficerCode();
if (officerCode == null) {
throw new IllegalStateException("OfficerCode should not be null on login");
Expand Down
Loading