diff --git a/Android/build.gradle b/Android/build.gradle index d2e9e2c90b..4d7b680dd8 100644 --- a/Android/build.gradle +++ b/Android/build.gradle @@ -29,8 +29,8 @@ android { applicationId 'org.droidplanner.android' minSdkVersion 14 targetSdkVersion 21 - versionCode 310 - versionName "alpha v3.0.10" + versionCode 30010 + versionName getGitVersion() } sourceSets { @@ -96,7 +96,7 @@ android { * @return The most recent git tag to be used as version name for the app. */ def getGitVersion(){ - def cmd = "git describe --tag --dirty" + def cmd = "git describe --tag" try { def proc = cmd.execute() return proc.text.trim() diff --git a/Android/src/org/droidplanner/android/activities/EditorActivity.java b/Android/src/org/droidplanner/android/activities/EditorActivity.java index e62cb722b9..0c1492a3e0 100644 --- a/Android/src/org/droidplanner/android/activities/EditorActivity.java +++ b/Android/src/org/droidplanner/android/activities/EditorActivity.java @@ -493,15 +493,17 @@ public void onPathFinished(List path) { List points = planningMapFragment.projectPathIntoMap(path); switch (getTool()) { case DRAW: - if (mIsSplineEnabled) { - missionProxy.addSplineWaypoints(points); - } else { - missionProxy.addWaypoints(points); - } + if(missionProxy != null) { + if (mIsSplineEnabled) { + missionProxy.addSplineWaypoints(points); + } else { + missionProxy.addWaypoints(points); + } + } break; case POLY: - if (path.size() > 2) { + if (missionProxy != null && path.size() > 2) { missionProxy.addSurveyPolygon(points); } else { editorToolsFragment.setTool(EditorTools.POLY); diff --git a/Android/src/org/droidplanner/android/fragments/FlightMapFragment.java b/Android/src/org/droidplanner/android/fragments/FlightMapFragment.java index 6e05b4fd2e..b3de224110 100644 --- a/Android/src/org/droidplanner/android/fragments/FlightMapFragment.java +++ b/Android/src/org/droidplanner/android/fragments/FlightMapFragment.java @@ -24,6 +24,7 @@ import com.google.android.gms.maps.model.LatLng; import com.o3dr.services.android.lib.coordinate.LatLong; import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; +import com.o3dr.services.android.lib.drone.property.Gps; public class FlightMapFragment extends DroneMap implements DPMap.OnMapLongClickListener, DPMap.OnMarkerClickListener, DPMap.OnMarkerDragListener, GuidedDialogListener { @@ -115,7 +116,7 @@ public void onApiDisconnected(){ @Override public void onMapLongClick(LatLong coord) { - if (drone.isConnected()) { + if (drone != null && drone.isConnected()) { if (drone.getGuidedState().isInitialized()) { drone.sendGuidedPoint(coord, false); } else { @@ -177,7 +178,8 @@ public void goToMyLocation() { public void goToDroneLocation() { super.goToDroneLocation(); - if (!this.drone.getGps().isValid()) + final Gps droneGps = this.drone.getGps(); + if (droneGps == null || !droneGps.isValid()) return; final int pressCount = mAppPrefs.prefs.getInt(PREF_DRONE_LOCATION_FIRST_PRESS, diff --git a/Android/src/org/droidplanner/android/maps/providers/google_map/GoogleMapFragment.java b/Android/src/org/droidplanner/android/maps/providers/google_map/GoogleMapFragment.java index 60a418d7a9..26d0d8220b 100644 --- a/Android/src/org/droidplanner/android/maps/providers/google_map/GoogleMapFragment.java +++ b/Android/src/org/droidplanner/android/maps/providers/google_map/GoogleMapFragment.java @@ -94,15 +94,13 @@ public void onReceive(Context context, Intent intent) { if (!drone.isConnected()) return; - GoogleMap map = getMap(); - Gps droneGps = drone.getGps(); - if (map == null || droneGps == null) + final Gps droneGps = drone.getGps(); + if (droneGps == null) return; if (mPanMode.get() == AutoPanMode.DRONE && droneGps.isValid()) { - final float currentZoomLevel = map.getCameraPosition().zoom; final LatLong droneLocation = droneGps.getPosition(); - updateCamera(droneLocation, currentZoomLevel); + updateCamera(droneLocation); } } }; @@ -492,11 +490,29 @@ protected void doRun() { } } + private void updateCamera(final LatLong coord){ + if(coord != null){ + getMapAsync(new OnMapReadyCallback() { + @Override + public void onMapReady(GoogleMap googleMap) { + final float zoomLevel = googleMap.getCameraPosition().zoom; + googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(DroneHelper.CoordToLatLang(coord), + zoomLevel)); + } + }); + } + } + @Override - public void updateCamera(LatLong coord, float zoomLevel) { + public void updateCamera(final LatLong coord, final float zoomLevel) { if (coord != null) { - getMap().animateCamera(CameraUpdateFactory.newLatLngZoom( - DroneHelper.CoordToLatLang(coord), zoomLevel)); + getMapAsync(new OnMapReadyCallback() { + @Override + public void onMapReady(GoogleMap googleMap) { + googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom( + DroneHelper.CoordToLatLang(coord), zoomLevel)); + } + }); } } @@ -635,7 +651,7 @@ public void zoomToFit(List coords) { @Override public void onMapReady(GoogleMap googleMap) { CameraUpdate animation = CameraUpdateFactory.newLatLngBounds(bounds, 100); - getMap().animateCamera(animation); + googleMap.animateCamera(animation); } }); } @@ -822,10 +838,6 @@ public double getMapRotation() { } } - private boolean isMapLayoutFinished() { - return getMap() != null && getView() != null && getView().getWidth() > 0; - } - @Override public void onLocationChanged(Location location) { Log.d(TAG, "User location changed."); diff --git a/Android/src/org/droidplanner/android/proxy/mission/item/fragments/MissionSurveyFragment.java b/Android/src/org/droidplanner/android/proxy/mission/item/fragments/MissionSurveyFragment.java index 9325ae3765..c67236551e 100644 --- a/Android/src/org/droidplanner/android/proxy/mission/item/fragments/MissionSurveyFragment.java +++ b/Android/src/org/droidplanner/android/proxy/mission/item/fragments/MissionSurveyFragment.java @@ -189,6 +189,9 @@ private void checkIfValid(Survey survey) { } private void updateViews() { + if(isDetached()) + return; + updateTextViews(); updateSeekBars(); }