Skip to content

Commit

Permalink
Merge pull request #215 from akvo/release/2.0.5
Browse files Browse the repository at this point in the history
Release/2.0.5
  • Loading branch information
ichinaski committed Nov 6, 2014
2 parents 475fbdf + 8f12056 commit 8546e69
Show file tree
Hide file tree
Showing 32 changed files with 654 additions and 272 deletions.
14 changes: 13 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
Akvo FLOW app
Last update 16 October 2014
Last update 05 November 2014

#ver 2.0.5

Features / Bugfixes
-------------------
* #209 - Clear answer on option questions
* #205 - Timezone check on phone
* #200 - App rotation bug
* #196 - Reload all surveys deletes bootstrap surveys
* #193 - Display username in form instance overview
* #186 - Clustering
* #164 - Caddisfly integration

#ver 2.0.4

Expand Down
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
buildToolsVersion "19.1.0"

defaultConfig {
minSdkVersion 8
minSdkVersion 10
targetSdkVersion 19
}

Expand Down Expand Up @@ -49,4 +49,5 @@ dependencies {
compile 'com.android.support:appcompat-v7:19.+'
compile 'com.google.android.gms:play-services:4.0.30'
compile 'org.ocpsoft.prettytime:prettytime:3.2.4.Final'
compile 'com.google.maps.android:android-maps-utils:0.3.3'
}
12 changes: 10 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.akvo.flow"
android:versionCode="1"
android:versionName="2.0.4.1" >
android:versionName="2.0.5" >

<uses-sdk
android:minSdkVersion="8"
android:minSdkVersion="10"
android:targetSdkVersion="19" />

<uses-permission android:name="android.permission.CAMERA" />
Expand Down Expand Up @@ -79,6 +79,13 @@
android:launchMode="singleTop"
android:configChanges="locale|layoutDirection" >
</activity>
<activity
android:name=".activity.TimeCheckActivity"
android:label="@string/time_check_activity"
android:theme="@style/Flow.Dialog"
android:launchMode="singleTop"
android:configChanges="locale|layoutDirection" >
</activity>

<service android:name=".service.DataSyncService" />
<service android:name=".service.SurveyDownloadService" />
Expand All @@ -87,6 +94,7 @@
<service android:name=".service.ExceptionReportingService" />
<service android:name=".service.ApkUpdateService" />
<service android:name=".service.SurveyedLocaleSyncService" />
<service android:name=".service.TimeCheckService" />

<receiver android:name=".broadcast.SyncDataReceiver" >
<intent-filter>
Expand Down
22 changes: 2 additions & 20 deletions app/src/main/java/org/akvo/flow/activity/RecordActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public class RecordActivity extends ActionBarActivity implements SurveyListListe
private SurveyDbAdapter mDatabase;

private ViewPager mPager;
private TabsAdapter mAdapter;
private TextView mRecordTextView;

private String[] mTabs;
Expand All @@ -77,11 +76,9 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.record_activity);

mTabs = getResources().getStringArray(R.array.record_tabs);

mRecordTextView = (TextView) findViewById(R.id.record_text);
mAdapter = new TabsAdapter(getSupportFragmentManager());
mPager = (ViewPager)findViewById(R.id.pager);
mPager.setAdapter(mAdapter);
mPager.setAdapter(new TabsAdapter(getSupportFragmentManager()));
mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
Expand Down Expand Up @@ -132,7 +129,6 @@ public void onResume() {
String recordId = getIntent().getStringExtra(EXTRA_RECORD_ID);
mRecord = mDatabase.getSurveyedLocale(recordId);
displayRecord();
mAdapter.refresh();
}

@Override
Expand Down Expand Up @@ -163,7 +159,7 @@ public void onSurveyClick(final String surveyId) {
long[] instances = mDatabase.getSurveyInstances(mRecord.getId(), surveyId,
SurveyInstanceStatus.SAVED);
long instance = instances.length > 0 ? instances[0]
: mDatabase.createSurveyRespondent(surveyId, mUser.getId(), mRecord.getId());
: mDatabase.createSurveyRespondent(surveyId, mUser, mRecord.getId());

Intent i = new Intent(this, SurveyActivity.class);
i.putExtra(ConstantUtil.USER_ID_KEY, mUser.getId());
Expand All @@ -185,20 +181,6 @@ public int getCount() {
return mTabs.length;
}

private String getFragmentTag(int pos){
// Hell of a hack. This should be changed for a more reliable method
return "android:switcher:" + R.id.pager + ":" + pos;
}

public void refresh() {
SurveyListFragment surveyListFragment = (SurveyListFragment) getSupportFragmentManager().
findFragmentByTag(getFragmentTag(POSITION_SURVEYS));

if (surveyListFragment != null && mSurveyGroup != null) {
surveyListFragment.refresh();
}
}

@Override
public Fragment getItem(int position) {
switch (position) {
Expand Down
87 changes: 30 additions & 57 deletions app/src/main/java/org/akvo/flow/activity/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import android.os.StatFs;
import android.support.v7.app.ActionBarActivity;
import android.text.Html;
import android.text.TextUtils;
import android.text.method.DigitsKeyListener;
import android.util.Log;
import android.view.MenuItem;
Expand All @@ -44,7 +45,6 @@
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.TextView.BufferType;
import android.widget.Toast;

import org.akvo.flow.R;
Expand Down Expand Up @@ -171,40 +171,31 @@ public void onClick(DialogInterface dialog, int id) {
}
});
builder.show();
} else if (resources.getString(R.string.reloadsurveyslabel).equals(
val)) {
} else if (resources.getString(R.string.reloadsurveyslabel).equals(val)) {
ViewUtil.showAdminAuthDialog(this,
new ViewUtil.AdminAuthDialogListener() {

@Override
public void onAuthenticated() {
AlertDialog.Builder builder = new AlertDialog.Builder(
SettingsActivity.this);
AlertDialog.Builder builder = new AlertDialog.Builder(SettingsActivity.this);
builder.setTitle(R.string.conftitle);
builder.setMessage(R.string.reloadconftext);
builder.setPositiveButton(R.string.okbutton,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int id) {
SurveyDbAdapter database = new SurveyDbAdapter(
SettingsActivity.this);
public void onClick(DialogInterface dialog, int id) {
Context c = SettingsActivity.this;
SurveyDbAdapter database = new SurveyDbAdapter(c);
database.open();
String[] surveyIds = database.getSurveyIds();
database.deleteAllSurveys();
database.close();
getApplicationContext()
.startService(
new Intent(
SettingsActivity.this,
SurveyDownloadService.class));
Intent i = new Intent(c, SurveyDownloadService.class);
i.putExtra(SurveyDownloadService.EXTRA_SURVEYS, surveyIds);
c.startService(i);
}
});
builder.setNegativeButton(
R.string.cancelbutton,
builder.setNegativeButton(R.string.cancelbutton,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int id) {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
Expand All @@ -220,48 +211,30 @@ public void onClick(
public void onAuthenticated() {
AlertDialog.Builder inputDialog = new AlertDialog.Builder(
SettingsActivity.this);
inputDialog
.setTitle(R.string.downloadsurveylabel);
inputDialog
.setMessage(R.string.downloadsurveyinstr);
inputDialog.setTitle(R.string.downloadsurveylabel);
inputDialog.setMessage(R.string.downloadsurveyinstr);

// Set an EditText view to get user input
final EditText input = new EditText(
SettingsActivity.this);
final EditText input = new EditText(SettingsActivity.this);

input.setKeyListener(new DigitsKeyListener(
false, false));
input.setKeyListener(new DigitsKeyListener(false, false));
inputDialog.setView(input);

inputDialog.setPositiveButton("Ok",
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialog,
int whichButton) {
String value = input.getText()
.toString();
if (value != null
&& value.trim()
.length() > 0) {
if (value.trim()
.equals("0")) {
SurveyDbAdapter database = new SurveyDbAdapter(
SettingsActivity.this);
database.open();
database.reinstallTestSurvey();
database.close();
} else {
Intent downloadIntent = new Intent(
SettingsActivity.this,
SurveyDownloadService.class);
downloadIntent
.putExtra(
ConstantUtil.SURVEY_ID_KEY,
value);
getApplicationContext()
.startService(
downloadIntent);
}
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString().trim();
if ("0".equals(value)) {
SurveyDbAdapter database = new SurveyDbAdapter(
SettingsActivity.this);
database.open();
database.reinstallTestSurvey();
database.close();
} else if (!TextUtils.isEmpty(value)) {
Intent i = new Intent(SettingsActivity.this,
SurveyDownloadService.class);
i.putExtra(SurveyDownloadService.EXTRA_SURVEYS,
new String[]{value});
SettingsActivity.this.startService(i);
}
}
});
Expand Down
43 changes: 24 additions & 19 deletions app/src/main/java/org/akvo/flow/activity/SurveyActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.widget.Toast;

import org.akvo.flow.R;
import org.akvo.flow.dao.SurveyDao;
import org.akvo.flow.dao.SurveyDbAdapter;
import org.akvo.flow.dao.SurveyDbAdapter.SurveyInstanceStatus;
import org.akvo.flow.dao.SurveyDbAdapter.SurveyedLocaleMeta;
import org.akvo.flow.domain.Question;
import org.akvo.flow.domain.QuestionGroup;
import org.akvo.flow.domain.QuestionResponse;
import org.akvo.flow.domain.Survey;
Expand Down Expand Up @@ -72,6 +72,7 @@ public class SurveyActivity extends ActionBarActivity implements SurveyListener,
private static final int PHOTO_ACTIVITY_REQUEST = 1;
private static final int VIDEO_ACTIVITY_REQUEST = 2;
private static final int SCAN_ACTIVITY_REQUEST = 3;
private static final int EXTERNAL_SOURCE_REQUEST = 4;

private static final int MENU_PREFILL = 101;

Expand Down Expand Up @@ -387,19 +388,15 @@ public void onClick(DialogInterface dialog, int clicked) {

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (mRequestQuestionId == null) {
if (mRequestQuestionId == null || resultCode != RESULT_OK) {
mRequestQuestionId = null;
return;// Move along, nothing to see here
}

if (requestCode == PHOTO_ACTIVITY_REQUEST || requestCode == VIDEO_ACTIVITY_REQUEST) {
if (resultCode == RESULT_OK) {
String fileSuffix;
if (requestCode == PHOTO_ACTIVITY_REQUEST) {
fileSuffix = IMAGE_SUFFIX;
} else {
fileSuffix = VIDEO_SUFFIX;
}

switch (requestCode) {
case PHOTO_ACTIVITY_REQUEST:
case VIDEO_ACTIVITY_REQUEST:
String fileSuffix = requestCode == PHOTO_ACTIVITY_REQUEST ? IMAGE_SUFFIX : VIDEO_SUFFIX;
File tmp = getTmpFile(requestCode == PHOTO_ACTIVITY_REQUEST);

// Ensure no image is saved in the DCIM folder
Expand All @@ -414,10 +411,9 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
maxImgSize = Integer.valueOf(maxImgSizePref);
}

String sizeTxt = getResources().getStringArray(R.array.max_image_size_pref)[maxImgSize];

if (ImageUtil.resizeImage(tmp.getAbsolutePath(), imgFile.getAbsolutePath(), maxImgSize)) {
Toast.makeText(this, "Image resized to " + sizeTxt, Toast.LENGTH_LONG).show();
Log.i(TAG, "Image resized to: " +
getResources().getStringArray(R.array.max_image_size_pref)[maxImgSize]);
if (!tmp.delete()) { // must check return value to know if it failed
Log.e(TAG, "Media file delete failed");
}
Expand All @@ -429,11 +425,11 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
Bundle photoData = new Bundle();
photoData.putString(ConstantUtil.MEDIA_FILE_KEY, imgFile.getAbsolutePath());
mAdapter.onQuestionComplete(mRequestQuestionId, photoData);
} else {
Log.e(TAG, "Result of camera op was not ok: " + resultCode);
}
} else if (requestCode == SCAN_ACTIVITY_REQUEST && resultCode == RESULT_OK) {
mAdapter.onQuestionComplete(mRequestQuestionId, data.getExtras());
break;
default:
// SCAN_ACTIVITY_REQUEST or EXTERNAL_SOURCE_REQUEST
mAdapter.onQuestionComplete(mRequestQuestionId, data.getExtras());
break;
}

mRequestQuestionId = null;// Reset the tmp reference
Expand Down Expand Up @@ -585,6 +581,15 @@ public void onClick(DialogInterface dialog, int id) {
mQuestionResponses.remove(questionId);
mDatabase.deleteResponse(mSurveyInstanceId, questionId);
}
} else if (QuestionInteractionEvent.EXTERNAL_SOURCE_EVENT.equals(event.getEventType())) {
mRequestQuestionId = event.getSource().getQuestion().getId();
final Question q = event.getSource().getQuestion();
Intent intent = new Intent(ConstantUtil.EXTERNAL_SOURCE_ACTION);
intent.putExtra(ConstantUtil.EXTERNAL_SOURCE_QUESTION_ID, q.getId());
intent.putExtra(ConstantUtil.EXTERNAL_SOURCE_QUESTION_TITLE, q.getText());
intent.setType(ConstantUtil.EXTERNAL_SOURCE_MIME);
startActivityForResult(Intent.createChooser(intent, getString(R.string.use_external_source)),
+ EXTERNAL_SOURCE_REQUEST);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.akvo.flow.service.ExceptionReportingService;
import org.akvo.flow.service.LocationService;
import org.akvo.flow.service.SurveyDownloadService;
import org.akvo.flow.service.TimeCheckService;
import org.akvo.flow.util.FileUtil;
import org.akvo.flow.util.PlatformUtil;
import org.akvo.flow.util.StatusUtil;
Expand Down Expand Up @@ -137,6 +138,7 @@ public void onClick(DialogInterface dialog, int which) {
startService(new Intent(this, ExceptionReportingService.class));
startService(new Intent(this, DataSyncService.class));
startService(new Intent(this, ApkUpdateService.class));
startService(new Intent(this, TimeCheckService.class));
}
}

Expand Down
Loading

0 comments on commit 8546e69

Please sign in to comment.