Skip to content

Commit

Permalink
Merge pull request #73 from EyeSeeTea/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
adrianq committed Sep 28, 2015
2 parents 0170f20 + 4d50532 commit b120da7
Show file tree
Hide file tree
Showing 68 changed files with 1,293 additions and 519 deletions.
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@
<application
android:name=".EyeSeeTeaApplication"
android:allowBackup="true"
android:icon="@drawable/qualityapp_logo"
android:icon="@drawable/pictureapp_logo"
android:label="@string/app_name"
android:theme="@style/EyeSeeTheme"
tools:replace="android:icon" >

<service android:name=".services.SurveyService" android:exported="false"/>
<service android:name=".services.PushService" android:exported="false"/>

<meta-data
android:name="DATABASE"
Expand Down Expand Up @@ -86,6 +87,8 @@
android:value=".DashboardActivity" />
</activity>

<receiver android:name="org.eyeseetea.malariacare.receivers.AlarmPushReceiver"></receiver>

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/assets/Answers.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1;'RDT';10
1;'RDT';14
2;'Sex';10
3;'Age';12
4;'Specie';11
3;'Age';6
4;'Specie';14
5;'Treatment';11
6;'Risk Group';11
7;'Phone';13
2 changes: 1 addition & 1 deletion app/src/main/assets/Headers.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1;'Malaria Case Surveillance';'Malaria Case Surveillance';1;1
1;'Health System QIS';'Health System QIS';1;1
16 changes: 16 additions & 0 deletions app/src/main/assets/OptionAttributes.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
1;'f38b00'
2;'00b3e3'
3;'003745'
4;'f0d100'
5;'799900'
6;'f38b00'
7;'13a285'
8;'f0d100'
9;'799900'
10;'f38b00'
11;'00b3e3'
12;'f0d100'
13;'799900'
14;'f0d100'
15;'00b3e3'
16;'003745'
38 changes: 16 additions & 22 deletions app/src/main/assets/Options.csv
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
1;'Yes';0.00;1;'question_images/rdt_yes.png'
2;'No';0.00;1;'question_images/rdt_no.png'
3;'Male';0.00;2;'question_images/sex_male.png'
4;'Female';0.00;2;'question_images/sex_female.png'
5;'0-12m';0.00;3;'question_images/age_0m_12m.png'
6;'1-5years';0.00;3;'question_images/age_1y_5y.png'
7;'6-15years';0.00;3;'question_images/age_5y_15y.png'
8;'16-25years';0.00;3;'question_images/age_16y_25y.png'
9;'26-45years';0.00;3;'question_images/age_26y_45y.png'
10;'46+years';0.00;3;'question_images/age_46y.png'
11;'Pf';0.00;4;'question_images/specie_pf.png'
12;'Pv';0.00;4;'question_images/specie_pv.png'
13;'Mix';0.00;4;'question_images/specie_mix.png'
14;'N/A';0.00;4;'question_images/specie_none.png'
15;'Child';0.00;5;'question_images/treatment_child.png'
16;'Adolescent';0.00;5;'question_images/treatment_adolescent.png'
17;'Adult';0.00;5;'question_images/treatment_adult.png'
18;'Referral';0.00;5;'question_images/treatment_referral.png'
19;'In the forest?';0.00;6;'question_images/risk_group_forest.png'
20;'In the plantation?';0.00;6;'question_images/risk_group_plantation.png'
21;'Another country?';0.00;6;'question_images/risk_group_another_country.png'
22;'N/A?';0.00;6;'question_images/risk_group_none.png'
1;'វិជ្ជមាន';'Positive';0.00;1;'question_images/rdt_positive.png';1;'f38b00'
2;'អវិជ្ជមាន';'Negative';0.00;1;'question_images/rdt_negative.png';2;'00b3e3'
3;'មិនបានធ្វើតេស្តឈាម';'Not Tested';0.00;1;'question_images/rdt_no_tested.png';3;'003745'
4;'ប្រុស';'Male';0.00;2;'question_images/sex_male.png';4;'f0d100'
5;'ស្រី';'Female';0.00;2;'question_images/sex_female.png';5;'799900'
6;'ចំរុះ(Mixed)';'Mixed';0.00;4;'question_images/specie_mix.png';6;'f38b00'
7;'ផ្លាស្មូដ្យូម ហ្វាល់ស៊ីប៉ារ៉ូម(Pf)';'Plasmodium falciparum (Pf)';0.00;4;'question_images/specie_pf.png';7;'13a285'
8;'ផ្លាស្មូដ្យូម វីវ៉ាក់(Pv)';'Plasmodium vivax (Pv)';0.00;4;'question_images/specie_pv.png';8;'f0d100'
9;'ផ្តល់ឱសថសំរាប់ក្មេង';'Child';0.00;5;'question_images/treatment_child.png';9;'799900'
10;'ផ្តល់ឱសថសំរាប់មនុស្សជំទង់';'Adolescent';0.00;5;'question_images/treatment_adolescent.png';10;'f38b00'
11;'ផ្តល់ឱសថសំរាប់មនុស្សធំ';'Adult';0.00;5;'question_images/treatment_adult.png';11;'00b3e3'
12;'ធ្វើការបញ្ជូន';'Referral';0.00;5;'question_images/treatment_referral.png';12;'f0d100'
13;'ពីព្រៃ';'Forest';0.00;6;'question_images/risk_group_forest.png';13;'799900'
14;'ពីចំការ';'Plantation';0.00;6;'question_images/risk_group_plantation.png';14;'f0d100'
15;'ពីប្រទេសផ្សេងៗ';'Another Country';0.00;6;'question_images/risk_group_another_country.png';15;'00b3e3'
16;'ផ្សេងៗ';'Other';0.00;6;'question_images/risk_group_none.png';16;'003745'
2 changes: 1 addition & 1 deletion app/src/main/assets/Programs.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1;'IrppF3qERB7';'Malaria Case Surveillance Program'
1;'IrppF3qERB7';'Health System QIS'
14 changes: 7 additions & 7 deletions app/src/main/assets/Questions.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
1;'RDT';'Rapid Diagnostic Test - Malaria';;'RDT';'OEdLEjF6Z8p';1;0;0;1;1;
2;'Sex';'Sex';;'យែនឌ័រ';'uuudizosfpU';2;0;0;1;2;1
3;'Age';'Age';;'ដែលមានអាយុ';'JMM92njKuSc';3;0;0;1;3;1
4;'Specie';'Specie';;'ប្រភេទ';'X6RFHreAu0L';4;0;0;1;4;1
5;'Treatment';'Treatment';;'ការព្យាបាល';'fNpYtVaL7OV';5;0;0;1;5;1
6;'Risk Group';'Risk Group';;'ក្រុមដែលមានហានិភ័យ';'IR2vkwx9D8H';6;0;0;1;6;1
7;'Patient Phone Number';'Patient Phone Number';;'លេខទូរស័ព្ទ របស់អ្នកជម្ងឺ';'rDubghVv1L8';7;0;0;1;7;1
1;'RDT';'What is your patient\'s RDT result?';;'តើលទ្ធផលតេស្តឈាមរបស់អ្នកជំងឺដោយប្រើ ឧបករណ៍ RDT បង្ហាញថាជាអ្វី?';'OEdLEjF6Z8p';1;0;0;1;1;1
2;'Sex';'Male or Female?';;'ប្រុស ឬ ស្រី?';'uuudizosfpU';2;0;0;1;2;1
3;'Age';'How old is your patient (years)?';;'តើអ្នកជំងឺរបស់អ្នកមានអាយុប៉ុន្មាន​(ឆ្នាំ)?';'JMM92njKuSc';3;0;0;1;3;1
4;'Specie';'What type of malaria does your patient have?';;'តើអ្នកជំងឺរបស់អ្នកមានមេរោគគ្រុនចាញ់ប្រភេទអ្វី?';'X6RFHreAu0L';4;0;0;1;4;1
5;'Treatment';'What type of treatment did you provide?';;'តើការព្យាបាលបែបណាដែលអ្នកផ្តល់ជូនអ្នកជំងឺ?';'fNpYtVaL7OV';5;0;0;1;5;1
6;'Risk Group';'Where did your patient get malaria?';;'តើអ្នកជំងឺឆ្លងជំងឺគ្រុនចាញ់ពីកន្លែងណា?';'IR2vkwx9D8H';6;0;0;1;6;1
7;'Phone';'Please enter your patient’s phone number.';;'សូមវាយបញ្ចូលលេខទូរស័ព្ទអ្នកជំងឺ';'rDubghVv1L8';7;0;0;1;7;1
2 changes: 1 addition & 1 deletion app/src/main/assets/Tabs.csv
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1;'Malaria Case Surveillance';1;1;8
1;'Health System QIS';1;1;8
Binary file added app/src/main/assets/fonts/KhmerOS.ttf
Binary file not shown.
Binary file removed app/src/main/assets/question_images/age_0m_12m.png
Binary file not shown.
Binary file removed app/src/main/assets/question_images/age_16y_25y.png
Binary file not shown.
Binary file removed app/src/main/assets/question_images/age_1y_5y.png
Binary file not shown.
Binary file removed app/src/main/assets/question_images/age_26y_45y.png
Binary file not shown.
Binary file removed app/src/main/assets/question_images/age_46y.png
Binary file not shown.
Binary file removed app/src/main/assets/question_images/age_5y_15y.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/assets/question_images/rdt_no.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/assets/question_images/rdt_yes.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/assets/question_images/risk_group_forest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/assets/question_images/risk_group_none.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/assets/question_images/risk_group_plantation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/assets/question_images/sex_female.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/assets/question_images/sex_male.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/assets/question_images/specie_mix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/assets/question_images/specie_none.png
Binary file not shown.
Binary file modified app/src/main/assets/question_images/specie_pf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/assets/question_images/specie_pv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/assets/question_images/treatment_adolescent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/assets/question_images/treatment_adult.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/assets/question_images/treatment_child.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/assets/question_images/treatment_referral.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 44 additions & 2 deletions app/src/main/java/org/eyeseetea/malariacare/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@
package org.eyeseetea.malariacare;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
Expand All @@ -34,7 +37,9 @@
import org.eyeseetea.malariacare.database.model.OrgUnit;
import org.eyeseetea.malariacare.database.model.Program;
import org.eyeseetea.malariacare.database.model.Survey;
import org.eyeseetea.malariacare.database.utils.LocationMemory;
import org.eyeseetea.malariacare.database.utils.Session;
import org.eyeseetea.malariacare.layout.listeners.SurveyLocationListener;
import org.eyeseetea.malariacare.layout.utils.LayoutUtils;
import org.eyeseetea.malariacare.utils.Utils;

Expand All @@ -49,6 +54,10 @@ public abstract class BaseActivity extends ActionBarActivity {
*/
public static final String SETTINGS_CALLER_ACTIVITY = "SETTINGS_CALLER_ACTIVITY";

private static String TAG=".BaseActivity";

private SurveyLocationListener locationListener;

@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
Expand All @@ -74,7 +83,7 @@ private void initView(Bundle savedInstanceState){
/**
* Customize transitions for these activities
*/
protected void initTransition(){
protected void initTransition() {
this.overridePendingTransition(R.transition.anim_slide_in_left, R.transition.anim_slide_out_left);
}

Expand Down Expand Up @@ -147,7 +156,7 @@ public void onConfigurationChanged(Configuration newConfig) {

protected void goSettings(){
Intent intentSettings=new Intent(this,SettingsActivity.class);
intentSettings.putExtra(SETTINGS_CALLER_ACTIVITY,this.getClass());
intentSettings.putExtra(SETTINGS_CALLER_ACTIVITY, this.getClass());
startActivity(new Intent(this, SettingsActivity.class));
}

Expand Down Expand Up @@ -175,10 +184,43 @@ public void newSurvey(View v){
survey.save();
Session.setSurvey(survey);

//Look for coordinates
prepareLocationListener(survey);

//Call Survey Activity
finishAndGo(SurveyActivity.class);
}

private void prepareLocationListener(Survey survey){

locationListener = new SurveyLocationListener(survey.getId());
LocationManager locationManager = (LocationManager) LocationMemory.getContext().getSystemService(Context.LOCATION_SERVICE);
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
Log.d(TAG, "requestLocationUpdates via GPS");
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
}

if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
Log.d(TAG, "requestLocationUpdates via NETWORK");
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
} else {
Location lastLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

if(lastLocation != null) {
Log.d(TAG, "location not available via GPS|NETWORK, last know: "+lastLocation);
locationListener.saveLocation(lastLocation);
}else{
String defaultLatitude = getApplicationContext().getString(R.string.GPS_LATITUDE_DEFAULT);
String defaultLongitude = getApplicationContext().getString(R.string.GPS_LONGITUDE_DEFAULT);
Location defaultLocation = new Location(getApplicationContext().getString(R.string.GPS_PROVIDER_DEFAULT));
defaultLocation.setLatitude(Double.parseDouble(defaultLatitude));
defaultLocation.setLongitude(Double.parseDouble(defaultLongitude));
Log.d(TAG, "location not available via GPS|NETWORK, default: "+defaultLocation);
locationListener.saveLocation(defaultLocation);
}
}
}

/**
* Finish current activity and launches an activity with the given class
* @param targetActivityClass Given target activity class
Expand Down
64 changes: 4 additions & 60 deletions app/src/main/java/org/eyeseetea/malariacare/DashboardActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,13 @@

import android.app.AlertDialog;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import org.eyeseetea.malariacare.database.model.OrgUnit;
import org.eyeseetea.malariacare.database.model.Program;
import org.eyeseetea.malariacare.database.model.Survey;
import org.eyeseetea.malariacare.database.model.Tab;
import org.eyeseetea.malariacare.database.model.User;
import org.eyeseetea.malariacare.database.utils.PopulateDB;
import org.eyeseetea.malariacare.database.utils.Session;
Expand All @@ -44,17 +36,16 @@
import org.eyeseetea.malariacare.services.SurveyService;

import java.io.IOException;
import java.util.List;


public class DashboardActivity extends BaseActivity {

private final static String TAG=".DDetailsActivity";
private final static String TAG=".DashboardActivity";

private LocationListener locationListener;

@Override
protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_dashboard);

Expand Down Expand Up @@ -82,42 +73,18 @@ protected void initTransition(){

@Override
public void onResume(){
Log.d(TAG, "onResume");
super.onResume();

prepareLocationListener();
AsyncPopulateDB asyncPopulateDB=new AsyncPopulateDB();
asyncPopulateDB.execute((Void) null);
}

@Override
public void onPause(){
Log.d(TAG, "onPause");
super.onPause();

//No locationListener working no need to unregister
if(locationListener==null){
return;
}
LocationManager locationManager=(LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
locationManager.removeUpdates(locationListener);
}

private void prepareLocationListener(){
locationListener=new DashboardLocationListener();
LocationManager locationManager=(LocationManager)this.getSystemService(Context.LOCATION_SERVICE);
if(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)){
Log.d(TAG,"requestLocationUpdates via GPS");
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,locationListener);
}

if(locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)){
Log.d(TAG,"requestLocationUpdates via NETWORK");
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,0,0,locationListener);
}else{
locationListener=null;
Location lastLocation=locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
Log.d(TAG,"location not available via GPS|NETWORK, last know: "+lastLocation);
Session.setLocation(lastLocation);
}
}

public void getSurveysFromService(){
Expand Down Expand Up @@ -217,27 +184,4 @@ private void initDataIfRequired() throws IOException {
}
}

public class DashboardLocationListener implements LocationListener{

@Override
public void onLocationChanged(Location location) {
Log.d(TAG,"onLocationChanged "+location.toString());
Session.setLocation(location);
}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {

}

@Override
public void onProviderEnabled(String provider) {

}

@Override
public void onProviderDisabled(String provider) {

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.eyeseetea.malariacare.database.model.Survey;
import org.eyeseetea.malariacare.database.model.User;
import org.eyeseetea.malariacare.database.model.Value;
import org.eyeseetea.malariacare.database.utils.LocationMemory;

import io.fabric.sdk.android.Fabric;

Expand All @@ -42,6 +43,7 @@ public class EyeSeeTeaApplication extends com.orm.SugarApp {
public void onCreate() {
super.onCreate();
Fabric.with(this, new Crashlytics());
LocationMemory.getInstance().init(getApplicationContext());
// Not previously populated tables
CompositeScore.saveInTx();
QuestionRelation.saveInTx();
Expand Down
Loading

0 comments on commit b120da7

Please sign in to comment.