Skip to content

Commit

Permalink
Remove option to save geotrace as polygon
Browse files Browse the repository at this point in the history
  • Loading branch information
lognaturel committed May 20, 2019
1 parent f0cc113 commit a8756e3
Showing 1 changed file with 3 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@

package org.odk.collect.android.activities;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.VisibleForTesting;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
Expand All @@ -29,6 +27,8 @@
import android.widget.Spinner;
import android.widget.TextView;

import androidx.annotation.VisibleForTesting;

import org.odk.collect.android.R;
import org.odk.collect.android.map.GoogleMapFragment;
import org.odk.collect.android.map.MapFragment;
Expand Down Expand Up @@ -84,8 +84,6 @@ public enum OutputMode { GEOTRACE, GEOSHAPE }

private AlertDialog settingsDialog;
private View settingsView;
private AlertDialog polygonOrPolylineDialog;
private View polygonOrPolylineView;

private static final int[] INTERVAL_OPTIONS = {
1, 5, 10, 20, 30, 60, 300, 600, 1200, 1800
Expand Down Expand Up @@ -198,9 +196,6 @@ public MapFragment createMapFragment() {

@Override public void destroy() { }

// This is just for the polygonOrPolylineDialog deprecation warning,
// which will go away in the next release.
@SuppressLint("SetTextI18n")
public void initMap(MapFragment newMapFragment) {
if (newMapFragment == null) { // could not create the map
finish();
Expand Down Expand Up @@ -280,11 +275,7 @@ public void initMap(MapFragment newMapFragment) {
saveButton.setOnClickListener(v -> {
if (!map.getPolyPoints(featureId).isEmpty()) {
if (outputMode == OutputMode.GEOTRACE) {
// This release shows a deprecation warning for the "Save
// as Polygon" button. After the deprecation period,
// we plan to remove the dialog entirely; outputMode
// determines whether a polyline or a polygon will be saved.
polygonOrPolylineDialog.show();
saveAsPolyline();
} else {
saveAsPolygon();
}
Expand All @@ -305,17 +296,6 @@ public void initMap(MapFragment newMapFragment) {
recordButton = findViewById(R.id.record_button);
recordButton.setOnClickListener(v -> recordPoint());

// The polygonOrPolylineDialog will go away in the next release.
polygonOrPolylineView = getLayoutInflater().inflate(R.layout.polygon_polyline_dialog, null);

Button polygonSave = polygonOrPolylineView.findViewById(R.id.polygon_save);
polygonSave.setOnClickListener(v -> saveAsPolygon());
polygonSave.setText(polygonSave.getText() + "\n\n" +
getString(R.string.polygon_save_deprecation_warning));

Button polylineSave = polygonOrPolylineView.findViewById(R.id.polyline_save);
polylineSave.setOnClickListener(v -> saveAsPolyline());

buildDialogs();

findViewById(R.id.layers).setOnClickListener(v -> helper.showLayersDialog());
Expand Down Expand Up @@ -354,7 +334,6 @@ public void initMap(MapFragment newMapFragment) {
}

private void saveAsPolyline() {
polygonOrPolylineDialog.dismiss();
if (map.getPolyPoints(featureId).size() > 1) {
finishWithResult();
} else {
Expand All @@ -363,7 +342,6 @@ private void saveAsPolyline() {
}

private void saveAsPolygon() {
polygonOrPolylineDialog.dismiss();
if (map.getPolyPoints(featureId).size() > 2) {
// Close the polygon.
List<MapPoint> points = map.getPolyPoints(featureId);
Expand Down Expand Up @@ -488,16 +466,6 @@ private void buildDialogs() {
settingsDialog.dismiss();
})
.create();

polygonOrPolylineDialog = new AlertDialog.Builder(this)
.setTitle(getString(R.string.polygon_or_polyline))
.setView(polygonOrPolylineView)
.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.cancel())
.setOnCancelListener(dialog -> {
dialog.cancel();
settingsDialog.dismiss();
})
.create();
}

private void startInput() {
Expand Down

0 comments on commit a8756e3

Please sign in to comment.