Skip to content

Commit

Permalink
Merge branch 'release/2.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Inigo Lopez de Heredia committed Mar 17, 2015
2 parents 943a982 + a7fc4a7 commit 83550a7
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 35 deletions.
11 changes: 11 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
Akvo FLOW app release notes
===========================

#ver 2.1.3
Date: 17 March 2015

New and noteworthy
------------------
* Geoshapes editor displays a GPS position accuracy indicator, with a green/red color based on the accuracy threshold [#272]

Resolved issues
---------------
* Datapoint name generation removes leading/trailing hyphens and space characters [#273]

#ver 2.1.2.1
Date: 24 February 2015

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.1.2.1" >
android:versionName="2.1.3" >

<uses-sdk
android:minSdkVersion="10"
Expand Down
67 changes: 47 additions & 20 deletions app/src/main/java/org/akvo/flow/activity/GeoshapeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
package org.akvo.flow.activity;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.location.Criteria;
import android.graphics.Color;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.text.TextUtils;
Expand All @@ -39,6 +37,7 @@
import com.google.android.gms.maps.GoogleMap.OnMapLongClickListener;
import com.google.android.gms.maps.GoogleMap.OnMarkerDragListener;
import com.google.android.gms.maps.GoogleMap.OnMarkerClickListener;
import com.google.android.gms.maps.GoogleMap.OnMyLocationChangeListener;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
Expand All @@ -55,11 +54,12 @@
import org.json.JSONException;
import org.json.JSONObject;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

public class GeoshapeActivity extends ActionBarActivity implements OnMapClickListener,
OnMapLongClickListener, OnMarkerDragListener, OnMarkerClickListener {
OnMapLongClickListener, OnMarkerDragListener, OnMarkerClickListener, OnMyLocationChangeListener {
private static final String JSON_TYPE = "type";
private static final String JSON_GEOMETRY = "geometry";
private static final String JSON_COORDINATES = "coordinates";
Expand All @@ -76,10 +76,13 @@ public class GeoshapeActivity extends ActionBarActivity implements OnMapClickLis

private boolean mAllowPoints, mAllowLine, mAllowPolygon;
private boolean mManualInput;
private boolean mCentered;// We only want to center the map once
private boolean mReadOnly;

private View mFeatureMenu;
private View mClearPointBtn;
private TextView mFeatureName;
private TextView mAccuracy;
private GoogleMap mMap;

@Override
Expand All @@ -92,37 +95,36 @@ protected void onCreate(Bundle savedInstanceState) {
mFeatures = new ArrayList<>();
mMap = ((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map)).getMap();

View addPointBtn = findViewById(R.id.add_point_btn);
View clearFeatureBtn = findViewById(R.id.clear_feature_btn);
mFeatureMenu = findViewById(R.id.feature_menu);
mFeatureName = (TextView)findViewById(R.id.feature_name);
mAccuracy = (TextView)findViewById(R.id.accuracy);
mClearPointBtn = findViewById(R.id.clear_point_btn);
mClearPointBtn.setOnClickListener(mFeatureMenuListener);
findViewById(R.id.add_point_btn).setOnClickListener(mFeatureMenuListener);
findViewById(R.id.clear_feature_btn).setOnClickListener(mFeatureMenuListener);
findViewById(R.id.properties).setOnClickListener(mFeatureMenuListener);

mAllowPoints = getIntent().getBooleanExtra(ConstantUtil.EXTRA_ALLOW_POINTS, true);
mAllowLine = getIntent().getBooleanExtra(ConstantUtil.EXTRA_ALLOW_LINE, true);
mAllowPolygon = getIntent().getBooleanExtra(ConstantUtil.EXTRA_ALLOW_POLYGON, true);
mManualInput = getIntent().getBooleanExtra(ConstantUtil.EXTRA_MANUAL_INPUT, true);
mReadOnly = getIntent().getBooleanExtra(ConstantUtil.READONLY_KEY, false);

if (!mReadOnly) {
mClearPointBtn.setOnClickListener(mFeatureMenuListener);
addPointBtn.setOnClickListener(mFeatureMenuListener);
clearFeatureBtn.setOnClickListener(mFeatureMenuListener);
} else {
mClearPointBtn.setVisibility(View.GONE);
addPointBtn.setVisibility(View.GONE);
clearFeatureBtn.setVisibility(View.GONE);
}

initMap();

String geoJSON = getIntent().getStringExtra(ConstantUtil.GEOSHAPE_RESULT);
if (!TextUtils.isEmpty(geoJSON)) {
load(geoJSON);
} else {
// If user location is known, center map
LocationManager manager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
String provider = manager.getBestProvider(criteria, true);
if (provider != null) {
Location location = manager.getLastKnownLocation(provider);
if (location != null) {
LatLng position = new LatLng(location.getLatitude(), location.getLongitude());
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(position, 10));
}
}
mCentered = true;
}
}

Expand All @@ -131,6 +133,7 @@ private void initMap() {
mMap.setMyLocationEnabled(true);
mMap.setOnMarkerClickListener(this);
mMap.setOnMapClickListener(this);
mMap.setOnMyLocationChangeListener(this);
if (mManualInput) {
mMap.setOnMapLongClickListener(this);
mMap.setOnMarkerDragListener(this);
Expand Down Expand Up @@ -164,6 +167,11 @@ private void addPoint(LatLng point) {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.geoshape_activity, menu);
if (mReadOnly) {
menu.findItem(R.id.add_feature).setVisible(false);
menu.findItem(R.id.save).setVisible(false);
}

if (!mAllowPoints) {
menu.findItem(R.id.add_points).setVisible(false);
}
Expand Down Expand Up @@ -220,6 +228,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
@Override
public void onResume() {
super.onResume();

}

private View.OnClickListener mFeatureMenuListener = new View.OnClickListener() {
Expand Down Expand Up @@ -459,4 +468,22 @@ public void onMarkerDragEnd(Marker marker) {
}
}

@Override
public void onMyLocationChange(Location location) {
Log.i(TAG, "onMyLocationChange() - " + location);
if (location != null && location.hasAccuracy()) {
mAccuracy.setText(getString(R.string.accuracy) + ": "
+ new DecimalFormat("#").format(location.getAccuracy()) + "m");
if (location.getAccuracy() <= ACCURACY_THRESHOLD) {
mAccuracy.setTextColor(getResources().getColor(R.color.button_green));
} else {
mAccuracy.setTextColor(Color.RED);
}
if (!mCentered) {
LatLng position = new LatLng(location.getLatitude(), location.getLongitude());
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(position, 10));
mCentered = true;
}
}
}
}
17 changes: 8 additions & 9 deletions app/src/main/java/org/akvo/flow/activity/SurveyActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
import org.akvo.flow.event.QuestionInteractionListener;
import org.akvo.flow.event.SurveyListener;
import org.akvo.flow.ui.adapter.SurveyTabAdapter;
import org.akvo.flow.ui.view.QuestionGroupTab;
import org.akvo.flow.ui.view.QuestionView;
import org.akvo.flow.util.ConstantUtil;
import org.akvo.flow.util.FileUtil;
import org.akvo.flow.util.FileUtil.FileType;
Expand Down Expand Up @@ -262,18 +260,19 @@ private void saveRecordMetaData() {

// Check the responses given to these questions (marked as name)
// and concatenate them so it becomes the Locale name.
if (localeNameQuestions.size() > 0) {
for (int i=0; i<localeNameQuestions.size(); i++) {
QuestionResponse questionResponse = mDatabase.getResponse(mSurveyInstanceId,
localeNameQuestions.get(i));

if (!localeNameQuestions.isEmpty()) {
boolean first = true;
for (String questionId : localeNameQuestions) {
QuestionResponse questionResponse = mDatabase.getResponse(mSurveyInstanceId, questionId);
String answer = questionResponse != null ? questionResponse.getValue() : null;

if (!TextUtils.isEmpty(answer)) {
if (i > 0) {
if (!first) {
builder.append(" - ");
} else {
first = false;
}
builder.append(answer);
builder.append(answer.trim());
}
}
mDatabase.updateSurveyedLocale(mSurveyInstanceId, builder.toString(),
Expand Down
15 changes: 10 additions & 5 deletions app/src/main/java/org/akvo/flow/ui/view/GeoshapeQuestionView.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,12 @@ public GeoshapeQuestionView(Context context, Question q, SurveyListener surveyLi

private void init() {
setQuestionView(R.layout.geoshape_question_view);

mResponseView = findViewById(R.id.response_view);
mMapBtn = (Button)findViewById(R.id.capture_shape_btn);

mMapBtn.setOnClickListener(this);
if (isReadOnly()) {
mMapBtn.setVisibility(View.GONE);
mMapBtn.setText(R.string.view_shape);
}

mMapBtn.setOnClickListener(this);
}

private void displayResponseView() {
Expand All @@ -67,6 +64,7 @@ public void onClick(View v) {
data.putBoolean(ConstantUtil.EXTRA_ALLOW_LINE, getQuestion().isAllowLine());
data.putBoolean(ConstantUtil.EXTRA_ALLOW_POLYGON, getQuestion().isAllowPolygon());
data.putBoolean(ConstantUtil.EXTRA_MANUAL_INPUT, !getQuestion().isLocked());
data.putBoolean(ConstantUtil.READONLY_KEY, isReadOnly());
if (!TextUtils.isEmpty(mValue)) {
data.putString(ConstantUtil.GEOSHAPE_RESULT, mValue);
}
Expand All @@ -89,13 +87,20 @@ public void rehydrate(QuestionResponse resp) {
super.rehydrate(resp);
mValue = resp.getValue();
displayResponseView();

if (isReadOnly() && !TextUtils.isEmpty(mValue)) {
mMapBtn.setVisibility(VISIBLE);
}
}

@Override
public void resetQuestion(boolean fireEvent) {
super.resetQuestion(fireEvent);
mValue = null;
displayResponseView();
if (isReadOnly()) {
mMapBtn.setVisibility(GONE);
}
}

@Override
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/layout/geoshape_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
android:layout_width="match_parent"
android:layout_height="match_parent" />

<TextView
android:id="@+id/accuracy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:textSize="16sp" />

<RelativeLayout
android:id="@+id/feature_menu"
android:layout_width="match_parent"
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ Version</string>
<string name="type_code">introducir código</string>
<string name="or">o</string>
<string name="capture_shape">capturar figura</string>
<string name="view_shape">ver figura</string>
<string name="clear_point_title">Borrar punto</string>
<string name="clear_point_text">¿Quiere borrar este punto?</string>
<string name="clear_feature_title">Borrar figura</string>
Expand Down Expand Up @@ -209,6 +210,8 @@ Version</string>
<string name="location_unknown">Posición desconocida</string>
<string name="location_inaccurate">La geoposición no no es lo suficientemente precisa</string>
<string name="geoshape_response">FIgura capturada correctamente</string>
<string name="add_point_title">Añadir punto</string>
<string name="add_point_text">¿Quiere añadir un punto en esta posición?</string>
<!--Misc-->
<string name="okbutton">OK</string>
<string name="cancelbutton">Cancelar</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
<string name="type_code">entrez code</string>
<string name="or">ou</string>
<string name="capture_shape">Capturer la surface</string>
<string name="view_shape">voir la forme</string>
<string name="clear_point_title">Supprimer point</string>
<string name="clear_point_text">Voulez vous effacer ce point?</string>
<string name="clear_feature_title">Supprimer cette fonction</string>
Expand Down Expand Up @@ -206,6 +207,8 @@
<string name="location_unknown">Cet endroit n\'est pas reconnu</string>
<string name="location_inaccurate">La location n\'est pas assez précise.</string>
<string name="geoshape_response">Surface enregistrée avec succès </string>
<string name="add_point_title">Créer un point</string>
<string name="add_point_text">Voulez vous ajouter un point a cet endroit?</string>
<!--Misc-->
<string name="okbutton">OK</string>
<string name="cancelbutton">Annuler</string>
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="type_code">type code</string>
<string name="or">or</string>
<string name="capture_shape">capture shape</string>
<string name="view_shape">view shape</string>
<string name="clear_point_title">Delete point</string>
<string name="clear_point_text">Do you want to remove this point?</string>
<string name="clear_feature_title">Delete feature</string>
Expand Down

0 comments on commit 83550a7

Please sign in to comment.