Skip to content

Commit

Permalink
Merge pull request #143 from EyeSeeTea/development
Browse files Browse the repository at this point in the history
Release 3
  • Loading branch information
adrianq committed Nov 18, 2015
2 parents b120da7 + 86190b0 commit 687059c
Show file tree
Hide file tree
Showing 98 changed files with 4,103 additions and 3,127 deletions.
19 changes: 0 additions & 19 deletions .idea/misc.xml

This file was deleted.

17 changes: 10 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'

android {
compileSdkVersion 21
Expand All @@ -22,8 +22,8 @@ android {
applicationId 'org.eyeseetea.pictureapp'
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "0.1"
versionCode 6
versionName "3.0"
multiDexEnabled true

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand All @@ -47,18 +47,21 @@ android {

dependencies {

compile 'com.android.support:support-v4:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:support-annotations:22.1.0'
compile 'com.android.support:support-v4:21.1.1'
compile 'com.android.support:appcompat-v7:21.1.1'
compile 'com.android.support:support-annotations:21.1.0'

// App dependencies
compile 'com.github.satyan:sugar:1.3'
compile 'com.opencsv:opencsv:3.3'
compile 'com.google.android.gms:play-services:7.0.0'
compile 'com.google.android.gms:play-services:8.1.0'
compile 'com.google.guava:guava:18.0'
compile 'com.squareup.okhttp:okhttp:2.2.0'
compile 'com.googlecode.libphonenumber:libphonenumber:7.0.9'
compile 'com.android.support:multidex:1.0.1'
apt 'com.raizlabs.android:DBFlow-Compiler:2.2.1'
compile 'com.raizlabs.android:DBFlow-Core:2.2.1'
compile 'com.raizlabs.android:DBFlow:2.2.1'
compile('com.crashlytics.sdk.android:crashlytics:2.5.1@aar') {
transitive = true;
}
Expand Down
30 changes: 23 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!--
To retrieve OAuth 2.0 tokens or invalidate tokens to disconnect a user. This disconnect
option is required to comply with the Google+ Sign-In developer policies
-->
<uses-permission android:name="android.permission.USE_CREDENTIALS" /> <!-- To retrieve the account name (email) as part of sign-in: -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- Needed to profile with Debug class -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!--<uses-permission android:name="android.permission.USE_CREDENTIALS" /> To retrieve the account name (email) as part of sign-in: -->
<!--<uses-permission android:name="android.permission.GET_ACCOUNTS" /> To auto-complete the email text field in the login form with the user's emails -->
<!--<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" /> -->
<!-- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> --> <!-- Needed to profile with Debug class -->
<!--<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" tools:node="remove" />
<uses-permission android:name="android.permission.READ_CONTACTS" tools:node="remove" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" tools:node="remove" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" tools:node="remove" />

<application
android:name=".EyeSeeTeaApplication"
Expand Down Expand Up @@ -63,6 +68,17 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".DashboardActivity" />
</activity>
<activity
android:name="org.eyeseetea.malariacare.views.Dialog"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:configChanges="orientation|keyboardHidden|screenSize"
android:finishOnTaskLaunch="true"
android:label="@string/app_name"
android:parentActivityName=".DashboardActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".DashboardActivity" />
</activity>
<activity
android:name="org.eyeseetea.malariacare.SurveyActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/Options.csv
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
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'
16;'ផ្សេងៗ';'Other';0.00;6;'question_images/risk_group_none.png';16;'003745'
55 changes: 44 additions & 11 deletions app/src/main/java/org/eyeseetea/malariacare/BaseActivity.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
* Copyright (c) 2015.
*
* This file is part of Facility QA Tool App.
* This file is part of QIS Survelliance App.
*
* Facility QA Tool App is free software: you can redistribute it and/or modify
* QIS Survelliance App is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Facility QA Tool App is distributed in the hope that it will be useful,
* QIS Survelliance App is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with QIS Survelliance App. If not, see <http://www.gnu.org/licenses/>.
*/

package org.eyeseetea.malariacare;
Expand All @@ -28,14 +28,24 @@
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.text.Html;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.TextView;

import com.raizlabs.android.dbflow.sql.builder.Condition;
import com.raizlabs.android.dbflow.sql.language.Select;

import org.eyeseetea.malariacare.database.model.OrgUnit;
import org.eyeseetea.malariacare.database.model.OrgUnit$Table;
import org.eyeseetea.malariacare.database.model.Program;
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.Session;
Expand Down Expand Up @@ -109,12 +119,12 @@ public boolean onOptionsItemSelected(MenuItem item) {
break;
case R.id.action_about:
debugMessage("User asked for about");
showAlertWithMessage(R.string.settings_menu_about, R.raw.about);
showAlertWithHtmlMessage(R.string.settings_menu_about, R.raw.about);
break;
case R.id.action_logout:
/*case R.id.action_logout:
debugMessage("User asked for logout");
logout();
break;
break;*/
case android.R.id.home:
debugMessage("Go back");
onBackPressed();
Expand Down Expand Up @@ -177,8 +187,8 @@ public void onClick(DialogInterface arg0, int arg1) {
}

public void newSurvey(View v){
List<OrgUnit> firstOrgUnit=OrgUnit.find(OrgUnit.class,null,null,null,null,String.valueOf(1));
List<Program> firstProgram=Program.find(Program.class,null,null,null,null,String.valueOf(1));
List<OrgUnit> firstOrgUnit = new Select().from(OrgUnit.class).where(Condition.column(OrgUnit$Table.ID_ORG_UNIT).eq(1)).queryList();
List<Program> 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.save();
Expand All @@ -193,7 +203,7 @@ public void newSurvey(View v){

private void prepareLocationListener(Survey survey){

locationListener = new SurveyLocationListener(survey.getId());
locationListener = new SurveyLocationListener(survey.getId_survey());
LocationManager locationManager = (LocationManager) LocationMemory.getContext().getSystemService(Context.LOCATION_SERVICE);
if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
Log.d(TAG, "requestLocationUpdates via GPS");
Expand Down Expand Up @@ -252,7 +262,30 @@ private void showAlertWithMessage(int titleId, int rawId){
.setMessage(Utils.convertFromInputStreamToString(message))
.setNeutralButton(android.R.string.ok, null).create().show();
}

/**
* Shows an alert dialog with a big message inside based on a raw resource HTML formatted
* @param titleId Id of the title resource
* @param rawId Id of the raw text resource in HTML format
*/
private void showAlertWithHtmlMessage(int titleId, int rawId){
InputStream message = getApplicationContext().getResources().openRawResource(rawId);
final SpannableString linkedMessage = new SpannableString(Html.fromHtml(Utils.convertFromInputStreamToString(message).toString()));
Linkify.addLinks(linkedMessage, Linkify.ALL);
showAlert(titleId, linkedMessage);
}
/**
* Shows an alert dialog with a given string
* @param titleId Id of the title resource
* @param text String of the message
*/
private void showAlert(int titleId, CharSequence text){
final AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle(getApplicationContext().getString(titleId))
.setMessage(text)
.setNeutralButton(android.R.string.ok, null).create();
dialog.show();
((TextView)dialog.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());
}
/**
* Logs a debug message using current activity SimpleName as tag. Ex:
* SurveyActivity => ".SurveyActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
* Copyright (c) 2015.
*
* This file is part of Facility QA Tool App.
* This file is part of QIS Survelliance App.
*
* Facility QA Tool App is free software: you can redistribute it and/or modify
* QIS Survelliance App is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Facility QA Tool App is distributed in the hope that it will be useful,
* QIS Survelliance App is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with QIS Survelliance App. If not, see <http://www.gnu.org/licenses/>.
*/

package org.eyeseetea.malariacare;
Expand All @@ -25,9 +25,12 @@
import android.view.View;
import android.widget.Spinner;

import com.raizlabs.android.dbflow.sql.language.Select;

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.User;
import org.eyeseetea.malariacare.database.utils.Session;
import org.eyeseetea.malariacare.layout.adapters.general.OrgUnitArrayAdapter;
import org.eyeseetea.malariacare.layout.adapters.general.ProgramArrayAdapter;
Expand Down Expand Up @@ -60,13 +63,13 @@ protected void onCreate(Bundle savedInstanceState) {
this.programDefaultOption = new Program(Constants.DEFAULT_SELECT_OPTION);

//Populate Organization Unit DDL
List<OrgUnit> orgUnitList = OrgUnit.listAll(OrgUnit.class);
List<OrgUnit> orgUnitList = new Select().all().from(OrgUnit.class).queryList();
orgUnitList.add(0, orgUnitDefaultOption);
orgUnitView = (Spinner) findViewById(R.id.org_unit);
orgUnitView.setAdapter(new OrgUnitArrayAdapter(this, orgUnitList));

//Populate Program View DDL
List<Program> programList = OrgUnit.listAll(Program.class);
List<Program> programList = new Select().all().from(Program.class).queryList();
programList.add(0, programDefaultOption);
programView = (Spinner) findViewById(R.id.program);
programView.setAdapter(new ProgramArrayAdapter(this, programList));
Expand Down
31 changes: 23 additions & 8 deletions app/src/main/java/org/eyeseetea/malariacare/DashboardActivity.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/*
* Copyright (c) 2015.
*
* This file is part of Facility QA Tool App.
* This file is part of QIS Survelliance App.
*
* Facility QA Tool App is free software: you can redistribute it and/or modify
* QIS Survelliance App is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Facility QA Tool App is distributed in the hope that it will be useful,
* QIS Survelliance App is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
* along with QIS Survelliance App. If not, see <http://www.gnu.org/licenses/>.
*/

package org.eyeseetea.malariacare;
Expand All @@ -27,7 +27,10 @@
import android.os.Bundle;
import android.util.Log;

import org.eyeseetea.malariacare.database.model.Program;
import com.raizlabs.android.dbflow.sql.language.Select;

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 @@ -48,7 +51,6 @@ protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_dashboard);

if (savedInstanceState == null) {
DashboardUnsentFragment detailsFragment = new DashboardUnsentFragment();
detailsFragment.setArguments(getIntent().getExtras());
Expand All @@ -64,6 +66,7 @@ protected void onCreate(Bundle savedInstanceState) {
ftr.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ftr.commit();
}
Survey.removeInProgress();
}

@Override
Expand All @@ -75,11 +78,19 @@ protected void initTransition(){
public void onResume(){
Log.d(TAG, "onResume");
super.onResume();

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

@Override
protected void onRestart() {
super.onRestart();
Log.i(TAG, "onRestart");
Survey.removeInProgress();
}


@Override
public void onPause(){
Log.d(TAG, "onPause");
Expand Down Expand Up @@ -164,11 +175,15 @@ public void onClick(DialogInterface arg0, int arg1) {
*/
private void initUser(){
user=new User(DUMMY_USER,DUMMY_USER);
User userdb=User.existUser(user);
if(userdb!=null)
user=userdb;
else
user.save();
}

private void initDataIfRequired() throws IOException {
if (Program.count(Program.class, null, null)!=0) {
if (new Select().count().from(Tab.class).count()!=0) {
Log.i(TAG, "DB Already loaded, showing surveys...");
return;
}
Expand Down
Loading

0 comments on commit 687059c

Please sign in to comment.