@@ -136,15 +136,15 @@ public class ClientAndroidInterface {
136136 @ NonNull
137137 private final Activity activity ;
138138 @ NonNull
139- private final SQLHandler sqlHandler ;
139+ protected final SQLHandler sqlHandler ;
140140 @ NonNull
141141 private final HashMap <String , String > controls = new HashMap <>();
142142 @ NonNull
143143 private final ArrayList <String > myList = new ArrayList <>();
144144 @ NonNull
145145 private final ArrayList <String > enrolMessages = new ArrayList <>();
146146 @ NonNull
147- private final Global global ;
147+ protected final Global global ;
148148 @ NonNull
149149 private final StorageManager storageManager ;
150150 @ NonNull
@@ -167,6 +167,14 @@ public class ClientAndroidInterface {
167167 .build ();
168168 }
169169
170+ public ClientAndroidInterface (Activity activity , SQLHandler sqlHandler , Global global , Picasso picasso , StorageManager storageManager ) {
171+ this .activity = activity ;
172+ this .sqlHandler = sqlHandler ;
173+ this .global = global ;
174+ this .storageManager = storageManager ;
175+ this .picassoInstance = picasso ;
176+ }
177+
170178 @ JavascriptInterface
171179 @ SuppressWarnings ("unused" )
172180 public void SetUrl (String Url ) {
@@ -666,7 +674,7 @@ public String getHF(int DistrictId, String HFLevel) {
666674 return HFs .toString ();
667675 }
668676
669- private HashMap <String , String > jsonToTable (String jsonString ) {
677+ protected HashMap <String , String > jsonToTable (String jsonString ) {
670678 HashMap <String , String > data = new HashMap <>();
671679 try {
672680 JSONArray array = new JSONArray (jsonString );
@@ -849,7 +857,7 @@ public void addOrUpdateFamilySms(int familyId, Boolean approve, String language)
849857 }
850858 }
851859
852- private int isValidInsureeData (HashMap <String , String > data ) {
860+ protected int isValidInsureeData (HashMap <String , String > data ) {
853861 int Result ;
854862
855863 String InsuranceNumber = data .get ("txtInsuranceNumber" );
@@ -1044,7 +1052,7 @@ else if (ExceedThreshold == 0)
10441052 return rtInsureeId ;
10451053 }
10461054
1047- private String copyImageFromGalleryToApplication (String selectedPath , String InsuranceNumber ) {
1055+ protected String copyImageFromGalleryToApplication (String selectedPath , String InsuranceNumber ) {
10481056 String result = "" ;
10491057
10501058 try {
@@ -2538,10 +2546,14 @@ public int UpdatePolicy(int PolicyId, String PayDate, int policystatus) throws P
25382546 return 1 ;//Update Success
25392547 }
25402548
2549+ protected ProgressDialog createProgressDialog (String title , String message ) {
2550+ return ProgressDialog .show (activity , title , message );
2551+ }
2552+
25412553 @ JavascriptInterface
25422554 @ SuppressWarnings ("unused" )
25432555 public void uploadEnrolment () throws Exception {
2544- final ProgressDialog finalPd = ProgressDialog . show ( activity , activity .getResources ().getString (R .string .Sync ), activity .getResources ().getString (R .string .SyncProcessing ));
2556+ final ProgressDialog finalPd = createProgressDialog ( activity .getResources ().getString (R .string .Sync ), activity .getResources ().getString (R .string .SyncProcessing ));
25452557 activity .runOnUiThread (() -> {
25462558 activity .getWindow ().addFlags (WindowManager .LayoutParams .FLAG_KEEP_SCREEN_ON );
25472559 });
@@ -2790,7 +2802,7 @@ public boolean VerifyPhoto(JSONArray insurees) throws JSONException {
27902802 return result ;
27912803 }
27922804
2793- private int Enrol (int CallerId ) throws UserException , JSONException , IOException {
2805+ protected int Enrol (int CallerId ) throws UserException , JSONException , IOException {
27942806 ArrayList <String > verifiedId = new ArrayList <>();
27952807 myList .clear ();
27962808 int rtEnrolledId = 0 ;
@@ -3121,7 +3133,7 @@ private int Enrol(int CallerId) throws UserException, JSONException, IOException
31213133 return EnrolResult ;
31223134 }
31233135
3124- private int uploadEnrols (
3136+ protected int uploadEnrols (
31253137 @ NonNull JSONArray familyArray ,
31263138 @ NonNull JSONArray insureesArray ,
31273139 @ NonNull JSONArray policiesArray ,
@@ -3570,7 +3582,7 @@ protected void onPostExecute(Boolean aBoolean) {
35703582 }
35713583 }
35723584
3573- private void DeleteUploadedData (final int FamilyId , ArrayList <String > FamilyIDs , int CallerId ) {
3585+ protected void DeleteUploadedData (final int FamilyId , ArrayList <String > FamilyIDs , int CallerId ) {
35743586 if (FamilyIDs .size () == 0 ) {
35753587 FamilyIDs = new ArrayList <>() {{
35763588 add (String .valueOf (FamilyId ));
@@ -4713,6 +4725,10 @@ public void BackToDefaultRarPassword() {
47134725 }
47144726 }
47154727
4728+ protected Family newFetchFamilyExecute (String insuranceNumber ) throws Exception {
4729+ return new FetchFamily ().execute (insuranceNumber );
4730+ }
4731+
47164732 @ JavascriptInterface
47174733 @ SuppressWarnings ("unused" )
47184734 public int ModifyFamily (final String insuranceNumber ) {
@@ -4724,7 +4740,7 @@ public int ModifyFamily(final String insuranceNumber) {
47244740 return 0 ;
47254741 } else {
47264742 try {
4727- Family family = new FetchFamily (). execute (insuranceNumber );
4743+ Family family = newFetchFamilyExecute (insuranceNumber );
47284744 InsertFamilyDataFromOnline (family );
47294745 InsertInsureeDataFromOnline (family .getMembers ());
47304746 InsertPolicyDataFromOnline (family .getPolicies ());
@@ -4752,13 +4768,15 @@ private void InsertFamilyDataFromOnline(@NonNull Family family) throws JSONExcep
47524768
47534769 if (family .getSms () != null ) {
47544770 try {
4771+ System .out .println ("Family SMS: " + family .getSms ().isApproval () + ", " + family .getSms ().getLanguage ());
47554772 addOrUpdateFamilySms (family .getId (),
47564773 family .getSms ().isApproval (),
47574774 family .getSms ().getLanguage ()
47584775 );
47594776 } catch (Exception e ) {
47604777 e .printStackTrace ();
47614778 Log .w ("ModifyFamily" , "No familySMS data in family payload" );
4779+ System .out .println ("problem in try block, handling in catch block" );
47624780 }
47634781 }
47644782 }
@@ -5021,7 +5039,7 @@ public int getFamilyStat(int FamilyId) {
50215039 return status ;
50225040 }
50235041
5024- private int getFamilyStatus (int FamilyId ) throws JSONException {
5042+ protected int getFamilyStatus (int FamilyId ) throws JSONException {
50255043 if (FamilyId < 0 ) return 0 ;
50265044 @ Language ("SQL" )
50275045 String Query = "SELECT isOffline FROM tblFamilies WHERE FamilyId = " + FamilyId ;
@@ -5034,7 +5052,7 @@ private int getFamilyStatus(int FamilyId) throws JSONException {
50345052 else return 0 ;
50355053 }
50365054
5037- private int getInsureeStatus (int InsureeId ) throws JSONException {//herman
5055+ protected int getInsureeStatus (int InsureeId ) throws JSONException {//herman
50385056 if (InsureeId == 0 ) return 1 ;
50395057 @ Language ("SQL" )
50405058 String Query = "SELECT isOffline FROM tblInsuree WHERE InsureeId = " + InsureeId ;
@@ -5252,7 +5270,7 @@ private int getNextAvailablePolicyId() {
52525270 return getMaxIdFromTable ("PolicyId" , "tblPolicy" );
52535271 }
52545272
5255- private int getNextAvailableInsureeId () {
5273+ protected int getNextAvailableInsureeId () {
52565274 return getMaxIdFromTable ("InsureeId" , "tblInsuree" );
52575275 }
52585276
0 commit comments