Skip to content

Commit

Permalink
WIP on implementing GeoShapeOsmMapActivity in terms of the MapFragmen…
Browse files Browse the repository at this point in the history
…t interface, and providing an OSM implementation of MapFragment.
  • Loading branch information
zestyping committed Aug 17, 2018
1 parent 9fb47e3 commit faae3c4
Show file tree
Hide file tree
Showing 9 changed files with 1,107 additions and 454 deletions.
3 changes: 3 additions & 0 deletions collect_app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ the specific language governing permissions and limitations under the License.
<activity
android:name=".activities.GeoPointOsmMapActivity"
android:configChanges="orientation" />
<activity
android:name=".activities.GeoShapeOldOsmMapActivity"
android:configChanges="orientation" />
<activity
android:name=".activities.GeoShapeOsmMapActivity"
android:configChanges="orientation" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public class GeoShapeGoogleMapActivity extends CollectAbstractActivity {
private View zoomDialogView;
private Button zoomPointButton;
private Button zoomLocationButton;
private boolean foundFirstLocation;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -68,7 +67,7 @@ public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.geoshape_layout);

// TODO(ping): Remove when we're ready to use this class.
((TextView) findViewById(R.id.top_text)).setText("new GeoShapeActivity");
((TextView) findViewById(R.id.top_text)).setText("new Google GeoShapeActivity");

createMapFragment().addTo(this, R.id.map_container, this::setupMap);
}
Expand Down Expand Up @@ -99,11 +98,11 @@ private void setupMap(MapFragment newMapFragment) {
}

map = newMapFragment;
map.runOnGpsLocationReady(this::onGpsLocationReady);
map.setGpsLocationEnabled(true);
map.setGpsLocationListener(this::onLocationFix);
map.setLongPressListener(this::addVertex);

helper = new MapHelper(this, newMapFragment);
helper = new MapHelper(this, map);

gpsButton = findViewById(R.id.gps);
gpsButton.setOnClickListener(v -> showZoomDialog());
Expand Down Expand Up @@ -142,7 +141,7 @@ private void setupMap(MapFragment newMapFragment) {

// If there is a last know location go there
if (hasWindowFocus() && map.getGpsLocation() != null) {
foundFirstLocation = true;
// foundFirstLocation = true;
gpsButton.setEnabled(true);
showZoomDialog();
}
Expand Down Expand Up @@ -209,10 +208,9 @@ private String formatPoints(List<MapPoint> points) {
return result;
}

private void onLocationFix(MapPoint point) {
private void onGpsLocationReady(MapFragment map) {
gpsButton.setEnabled(true);
if (hasWindowFocus() && !foundFirstLocation) {
foundFirstLocation = true;
if (hasWindowFocus()) {
showZoomDialog();
}
}
Expand All @@ -225,7 +223,6 @@ private void addVertex(MapPoint point) {
private void clear() {
map.clearFeatures();
shapeId = map.addDraggableShape(new ArrayList<>());
map.setLongPressListener(this::addVertex);
clearButton.setEnabled(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.geoshape_layout);

// TODO(ping): Remove when we're ready to use the new class.
((TextView) findViewById(R.id.top_text)).setText("old GeoShapeActivity");
((TextView) findViewById(R.id.top_text)).setText("old Google GeoShapeActivity");

SupportMapFragment mapFragment = new SupportMapFragment();
getSupportFragmentManager().beginTransaction()
Expand Down
Loading

0 comments on commit faae3c4

Please sign in to comment.