Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Inigo Lopez de Heredia committed Sep 25, 2014
2 parents a54227d + 6429678 commit e58038f
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 32 deletions.
10 changes: 9 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
Akvo FLOW app
Last update 19 September 2014
Last update 25 September 2014

#ver 2.0.3

Features / Bugfixes
-------------------
* #167 - Empty forms cannot be submitted
* #166 - Font colour blends with background
* #160 - Revert all-caps policy in projects/survey titles

#ver 2.0.2

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.akvo.flow"
android:versionCode="1"
android:versionName="2.0.2" >
android:versionName="2.0.3" >

<uses-sdk
android:minSdkVersion="8"
Expand Down
20 changes: 6 additions & 14 deletions app/src/main/java/org/akvo/flow/activity/SurveyActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,25 +240,13 @@ private void recordDuration(boolean start) {

private void saveState() {
if (!mReadOnly) {
for (QuestionResponse response : mQuestionResponses.values()) {
// Store the response if it contains a value. Otherwise, delete it
if (response.hasValue()) {
response.setRespondentId(mSurveyInstanceId);
mDatabase.createOrUpdateSurveyResponse(response);
} else if (response.getId() != null && response.getId() > 0) {
// if we don't have a value BUT there is an ID, we need to
// remove it since the user blanked out their response
mDatabase.deleteResponse(mSurveyInstanceId, response.getQuestionId());
}
}
mDatabase.updateSurveyStatus(mSurveyInstanceId, SurveyInstanceStatus.SAVED);
mDatabase.updateRecordModifiedDate(mRecordId, System.currentTimeMillis());

// Record meta-data, if applies
if (mSurvey.getId().equals(mSurveyGroup.getRegisterSurveyId())) {
saveRecordMetaData();
}

}
}

Expand Down Expand Up @@ -586,12 +574,16 @@ public void onClick(DialogInterface dialog, int id) {
} else if (QuestionInteractionEvent.QUESTION_ANSWER_EVENT.equals(event.getEventType())) {
String questionId = event.getSource().getQuestion().getId();
QuestionResponse response = event.getSource().getResponse();
if (response != null) {

// Store the response if it contains a value. Otherwise, delete it
if (response != null && response.hasValue()) {
mQuestionResponses.put(questionId, response);
response.setRespondentId(mSurveyInstanceId);
mDatabase.createOrUpdateSurveyResponse(response);
} else {
mQuestionResponses.remove(questionId);
mDatabase.deleteResponse(mSurveyInstanceId, questionId);
}
// TODO: Should we save this Response to the DB straightaway?
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import android.support.v4.content.Loader;
import android.support.v4.widget.CursorAdapter;
import android.support.v7.app.ActionBarActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.ContextMenu;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -279,11 +278,8 @@ public View newView(Context context, Cursor cursor, ViewGroup parent) {
public void bindView(View view, Context context, Cursor cursor) {
final SurveyGroup surveyGroup = SurveyDbAdapter.getSurveyGroup(cursor);

String name = !TextUtils.isEmpty(surveyGroup.getName()) ?
surveyGroup.getName().toUpperCase() : null;

TextView text1 = (TextView)view.findViewById(R.id.text1);
text1.setText(name);
text1.setText(surveyGroup.getName());
text1.setTextColor(getResources().getColorStateList(mTextColor));

// Alternate background
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import android.support.v4.app.ListFragment;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.Loader;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
Expand Down Expand Up @@ -195,9 +194,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
TextView lastSubmissionTitle = (TextView)listItem.findViewById(R.id.date_label);
TextView lastSubmissionView = (TextView)listItem.findViewById(R.id.date);

String name = !TextUtils.isEmpty(surveyInfo.mName) ?
surveyInfo.mName.toUpperCase() : null;
surveyNameView.setText(name);
surveyNameView.setText(surveyInfo.mName);
surveyVersionView.setText("v" + surveyInfo.mVersion);

final boolean enabled = isEnabled(surveyInfo.mId);
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/akvo/flow/ui/view/QuestionView.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private Spanned formText() {
} else {
isFirst = false;
}
text.append("<font color='").append(sColors[i]).append("'>")
text.append("<font color='").append(sColors[i % sColors.length]).append("'>")
.append(txt.getText()).append("</font>");
}
}
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/java/org/akvo/flow/ui/view/SubmitTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ public void refresh(List<Question> invalidQuestions) {
QuestionListAdapter adapter = new QuestionListAdapter(invalidQuestions);
setAdapter(adapter);

if (invalidQuestions.isEmpty()) {
mHeaderView.setText(R.string.submittext);
mSubmitButton.setEnabled(true);
} else {
if (!invalidQuestions.isEmpty()) {
mHeaderView.setText(R.string.error_responses);
mSubmitButton.setEnabled(false);
} else if (mListener.getResponses().isEmpty()) {
mHeaderView.setText(R.string.error_empty_form);
mSubmitButton.setEnabled(false);
} else {
mHeaderView.setText(R.string.submittext);
mSubmitButton.setEnabled(true);
}
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
<item>hi</item>
<item>qu</item>
</string-array>
<!-- must have enough colors for all languages -->
<!-- NOTE: Main color will suits the light theme. Must have enough colors for all languages -->
<string-array name="colors">
<item>white</item>
<item>black</item>
<item>red</item>
<item>blue</item>
<item>yellow</item>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
<string name="reg_form_warning_title">Registration Survey</string>
<string name="reg_form_warning_text">This Data Point already contains a response for this form. Any new responses will be used as the most recent values. Do you want to continue?</string>
<string name="error_img_preview">Can\'t load image preview</string>
<string name="error_empty_form">Empty forms cannot be submitted. Please, add the corresponding responses first.</string>
<!-- RecordList Activity -->
<string name="create_data_point">CREATE NEW DATA POINT</string>
<string name="stats_title">Project Stats</string>
Expand Down

0 comments on commit e58038f

Please sign in to comment.