From 6f4cf437016bb213722896162889d94b9b628d35 Mon Sep 17 00:00:00 2001 From: Adrian Quintana Date: Thu, 19 Nov 2015 22:54:57 +0000 Subject: [PATCH 1/3] remove dummy data in the database and fix header in survey --- .../main/java/org/eyeseetea/malariacare/BaseActivity.java | 5 +++-- .../java/org/eyeseetea/malariacare/DashboardActivity.java | 2 +- .../main/java/org/eyeseetea/malariacare/SurveyActivity.java | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/eyeseetea/malariacare/BaseActivity.java b/app/src/main/java/org/eyeseetea/malariacare/BaseActivity.java index 0e28e0935d..91652da882 100644 --- a/app/src/main/java/org/eyeseetea/malariacare/BaseActivity.java +++ b/app/src/main/java/org/eyeseetea/malariacare/BaseActivity.java @@ -48,6 +48,7 @@ import org.eyeseetea.malariacare.database.model.Program$Table; import org.eyeseetea.malariacare.database.model.Survey; import org.eyeseetea.malariacare.database.utils.LocationMemory; +import org.eyeseetea.malariacare.database.utils.PreferencesState; import org.eyeseetea.malariacare.database.utils.Session; import org.eyeseetea.malariacare.layout.listeners.SurveyLocationListener; import org.eyeseetea.malariacare.layout.utils.LayoutUtils; @@ -187,10 +188,10 @@ public void onClick(DialogInterface arg0, int arg1) { } public void newSurvey(View v){ - List firstOrgUnit = new Select().from(OrgUnit.class).where(Condition.column(OrgUnit$Table.ID_ORG_UNIT).eq(1)).queryList(); + //Get Programs from database List firstProgram = new Select().from(Program.class).where(Condition.column(Program$Table.ID_PROGRAM).eq(1)).queryList(); // Put new survey in session - Survey survey = new Survey(firstOrgUnit.get(0), firstProgram.get(0), Session.getUser()); + Survey survey = new Survey(null, firstProgram.get(0), Session.getUser()); survey.save(); Session.setSurvey(survey); diff --git a/app/src/main/java/org/eyeseetea/malariacare/DashboardActivity.java b/app/src/main/java/org/eyeseetea/malariacare/DashboardActivity.java index 4f6b1f5e6d..eb51674755 100644 --- a/app/src/main/java/org/eyeseetea/malariacare/DashboardActivity.java +++ b/app/src/main/java/org/eyeseetea/malariacare/DashboardActivity.java @@ -189,7 +189,7 @@ private void initDataIfRequired() throws IOException { } Log.i(TAG, "DB empty, loading data ..."); - PopulateDB.populateDummyData(); + //PopulateDB.populateDummyData(); try { PopulateDB.populateDB(getAssets()); } catch (IOException e) { diff --git a/app/src/main/java/org/eyeseetea/malariacare/SurveyActivity.java b/app/src/main/java/org/eyeseetea/malariacare/SurveyActivity.java index 1d058f8fc1..6ac76ac532 100644 --- a/app/src/main/java/org/eyeseetea/malariacare/SurveyActivity.java +++ b/app/src/main/java/org/eyeseetea/malariacare/SurveyActivity.java @@ -45,6 +45,7 @@ import org.eyeseetea.malariacare.database.model.Question; import org.eyeseetea.malariacare.database.model.Survey; import org.eyeseetea.malariacare.database.model.Tab; +import org.eyeseetea.malariacare.database.utils.PreferencesState; import org.eyeseetea.malariacare.database.utils.Session; import org.eyeseetea.malariacare.layout.adapters.general.TabArrayAdapter; import org.eyeseetea.malariacare.layout.adapters.survey.AutoTabAdapter; @@ -258,7 +259,7 @@ private void createActionBar(){ android.support.v7.app.ActionBar actionBar = this.getSupportActionBar(); LayoutUtils.setActionBarLogo(actionBar); - LayoutUtils.setActionBarText(actionBar, survey.getOrgUnit().getName(), program.getName()); + LayoutUtils.setActionBarText(actionBar, PreferencesState.getInstance().getOrgUnit(), program.getName()); } From a6954e63879517d03acdeef815c2fce454613c62 Mon Sep 17 00:00:00 2001 From: ifoche Date: Fri, 20 Nov 2015 01:44:48 +0100 Subject: [PATCH 2/3] check phone, imai and serial are not null nor empty string. This bug was reported by Graham --- .../eyeseetea/malariacare/phonemetadata/PhoneMetaData.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/eyeseetea/malariacare/phonemetadata/PhoneMetaData.java b/app/src/main/java/org/eyeseetea/malariacare/phonemetadata/PhoneMetaData.java index 4f17ca62df..78b6b751f0 100644 --- a/app/src/main/java/org/eyeseetea/malariacare/phonemetadata/PhoneMetaData.java +++ b/app/src/main/java/org/eyeseetea/malariacare/phonemetadata/PhoneMetaData.java @@ -65,17 +65,17 @@ public void setPhone_serial(String phone_serial) { public String getPhone_metaData() { String phonemetadata=""; phonemetadata= "###"; - if(phone_number.length()>0){ + if(phone_number != null && !phone_number.equals("") && phone_number.length()>0){ phonemetadata=phonemetadata+phone_number; } phonemetadata= phonemetadata+"###"; - if(imei.length()>0){ + if(imei != null && !imei.equals("") && imei.length()>0){ phonemetadata=phonemetadata+imei; } phonemetadata= phonemetadata+"###"; - if(phone_serial.length()>0){ + if(phone_serial != null && !phone_serial.equals("") && phone_serial.length()>0){ phonemetadata=phonemetadata+phone_serial; } return phonemetadata; From 55cee8ce1d83d0de9410e90351a844d2f13553dd Mon Sep 17 00:00:00 2001 From: Adrian Quintana Date: Fri, 20 Nov 2015 01:37:02 +0000 Subject: [PATCH 3/3] remove logs --- .../java/org/eyeseetea/malariacare/network/PushClient.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/eyeseetea/malariacare/network/PushClient.java b/app/src/main/java/org/eyeseetea/malariacare/network/PushClient.java index ffb031bb26..aa87e83224 100644 --- a/app/src/main/java/org/eyeseetea/malariacare/network/PushClient.java +++ b/app/src/main/java/org/eyeseetea/malariacare/network/PushClient.java @@ -96,7 +96,7 @@ public class PushClient { private static String DHIS_USERNAME="KHMCS"; //Todo: introduce final password - private static String DHIS_PASSWORD=""; + private static String DHIS_PASSWORD="KHMCSadmin1"; private static String DHIS_ORG_NAME =""; private static String DHIS_ORG_UID =""; @@ -183,7 +183,6 @@ public PushResult push() { } return result; } catch (Exception ex) { - Log.e(TAG, ex.getMessage()); return new PushResult(ex); } } @@ -211,7 +210,7 @@ public PushResult pushBackground() { } return result; } catch (Exception ex) { - Log.e(TAG, ex.getMessage()); + //Log.e(TAG, ex.getMessage()); return new PushResult(ex); } }