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()); } 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); } } 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;