Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make way-points non-select-able when a tool is selected in editor #1186

Merged
merged 2 commits into from
Oct 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 64 additions & 64 deletions Android/src/org/droidplanner/android/activities/EditorActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.widget.AbsListView;
import android.widget.ImageButton;
import android.widget.RadioButton;
Expand All @@ -56,7 +58,7 @@
*/
public class EditorActivity extends DrawerNavigationUI implements OnPathFinishedListener,
OnEditorToolSelected, MissionDetailFragment.OnMissionDetailListener, OnEditorInteraction,
Callback, MissionSelection.OnSelectionUpdateListener {
Callback, MissionSelection.OnSelectionUpdateListener, OnClickListener, OnLongClickListener {

/**
* Used to retrieve the item detail window when the activity is destroyed,
Expand Down Expand Up @@ -98,6 +100,8 @@ public class EditorActivity extends DrawerNavigationUI implements OnPathFinished
private View mContainerItemDetail;

private ActionMode contextualActionBar;
private RadioButton normalToggle;
private RadioButton splineToggle;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand All @@ -121,71 +125,20 @@ public void onCreate(Bundle savedInstanceState) {
infoView = (TextView) findViewById(R.id.editorInfoWindow);

final ImageButton resetMapBearing = (ImageButton) findViewById(R.id.map_orientation_button);
resetMapBearing.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(planningMapFragment != null) {
planningMapFragment.updateMapBearing(0);
}
}
});

resetMapBearing.setOnClickListener(this);
final ImageButton zoomToFit = (ImageButton) findViewById(R.id.zoom_to_fit_button);
zoomToFit.setVisibility(View.VISIBLE);
zoomToFit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(planningMapFragment != null){
planningMapFragment.zoomToFit();
}
}
});

ImageButton mGoToMyLocation = (ImageButton) findViewById(R.id.my_location_button);
mGoToMyLocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
planningMapFragment.goToMyLocation();
}
});
mGoToMyLocation.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
planningMapFragment.setAutoPanMode(AutoPanMode.USER);
return true;
}
});

ImageButton mGoToDroneLocation = (ImageButton) findViewById(R.id.drone_location_button);
mGoToDroneLocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
planningMapFragment.goToDroneLocation();
}
});
mGoToDroneLocation.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
planningMapFragment.setAutoPanMode(AutoPanMode.DRONE);
return true;
}
});

final RadioButton normalToggle = (RadioButton) findViewById(R.id.normalWpToggle);
normalToggle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mIsSplineEnabled = !normalToggle.isChecked();
}
});

final RadioButton splineToggle = (RadioButton) findViewById(R.id.splineWpToggle);
splineToggle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mIsSplineEnabled = splineToggle.isChecked();
}
});
zoomToFit.setOnClickListener(this);
final ImageButton mGoToMyLocation = (ImageButton) findViewById(R.id.my_location_button);
mGoToMyLocation.setOnClickListener(this);
mGoToMyLocation.setOnLongClickListener(this);
final ImageButton mGoToDroneLocation = (ImageButton) findViewById(R.id.drone_location_button);
mGoToDroneLocation.setOnClickListener(this);
mGoToDroneLocation.setOnLongClickListener(this);
normalToggle = (RadioButton) findViewById(R.id.normalWpToggle);
normalToggle.setOnClickListener(this);
splineToggle = (RadioButton) findViewById(R.id.splineWpToggle);
splineToggle.setOnClickListener(this);

if(savedInstanceState != null){
mIsSplineEnabled = savedInstanceState.getBoolean(EXTRA_IS_SPLINE_ENABLED);
Expand All @@ -206,6 +159,50 @@ public void onClick(View v) {
gestureMapFragment.setOnPathFinishedListener(this);
}

@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.map_orientation_button:
if(planningMapFragment != null) {
planningMapFragment.updateMapBearing(0);
}
break;
case R.id.zoom_to_fit_button:
if(planningMapFragment != null){
planningMapFragment.zoomToFit();
}
break;
case R.id.splineWpToggle:
mIsSplineEnabled = splineToggle.isChecked();
break;
case R.id.normalWpToggle:
mIsSplineEnabled = !normalToggle.isChecked();
break;
case R.id.drone_location_button:
planningMapFragment.goToDroneLocation();
break;
case R.id.my_location_button:
planningMapFragment.goToMyLocation();
break;
default:
break;
}
}

@Override
public boolean onLongClick(View view) {
switch (view.getId()) {
case R.id.drone_location_button:
planningMapFragment.setAutoPanMode(AutoPanMode.DRONE);
return true;
case R.id.my_location_button:
planningMapFragment.setAutoPanMode(AutoPanMode.USER);
return true;
default:
return false;
}
}

@Override
public void onResume() {
super.onResume();
Expand Down Expand Up @@ -369,6 +366,7 @@ public void editorToolChanged(EditorTools tools) {
}

private void setupTool(EditorTools tool) {
planningMapFragment.skipMarkerClickEvents(false);
switch (tool) {
case DRAW:
enableSplineToggle(true);
Expand All @@ -385,6 +383,7 @@ private void setupTool(EditorTools tool) {
// Enable the spline selection toggle
enableSplineToggle(true);
gestureMapFragment.disableGestureDetection();
planningMapFragment.skipMarkerClickEvents(true);
break;

case TRASH:
Expand Down Expand Up @@ -679,4 +678,5 @@ public void onNo() {}
public CharSequence[][] getHelpItems() {
return new CharSequence[][] { {}, {} };
}

}
7 changes: 7 additions & 0 deletions Android/src/org/droidplanner/android/fragments/DroneMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,11 @@ public void updateMapBearing(float bearing){
mMapFragment.updateCameraBearing(bearing);
}

/**
* Ignore marker clicks on the map and instead report the event as a mapClick
* @param skip if it should skip further events
*/
public void skipMarkerClickEvents(boolean skip){
mMapFragment.skipMarkerClickEvents(skip);
}
}
7 changes: 7 additions & 0 deletions Android/src/org/droidplanner/android/maps/DPMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,11 @@ interface OnMarkerDragListener {
* @param coords
*/
public void zoomToFitMyLocation(List<Coord2D> coords);

/**
* Ignore marker clicks on the map and instead report the event as a mapClick
* @param skip if it should skip further events
*/
public void skipMarkerClickEvents(boolean skip);

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public class GoogleMapFragment extends SupportMapFragment implements DPMap, Loca
private DPMap.OnMarkerDragListener mMarkerDragListener;
private android.location.LocationListener mLocationListener;

protected boolean useMarkerClickAsMapClick = false;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup viewGroup,
Bundle bundle) {
Expand Down Expand Up @@ -591,14 +593,15 @@ public void goToDroneLocation() {
}

private void setupMapListeners() {
mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
final GoogleMap.OnMapClickListener onMapClickListener = new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
if (mMapClickListener != null) {
mMapClickListener.onMapClick(DroneHelper.LatLngToCoord(latLng));
}
}
});
};
mMap.setOnMapClickListener(onMapClickListener);

mMap.setOnMapLongClickListener(new GoogleMap.OnMapLongClickListener() {
@Override
Expand Down Expand Up @@ -641,6 +644,10 @@ public void onMarkerDragEnd(Marker marker) {
mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
if (useMarkerClickAsMapClick) {
onMapClickListener.onMapClick(marker.getPosition());
return true;
}
if (mMarkerClickListener != null) {
return mMarkerClickListener.onMarkerClick(mBiMarkersMap.getKey(marker));
}
Expand Down Expand Up @@ -771,4 +778,9 @@ public void onLocationChanged(Location location) {
mLocationListener.onLocationChanged(location);
}
}

@Override
public void skipMarkerClickEvents(boolean skip) {
useMarkerClickAsMapClick = skip;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -597,4 +597,10 @@ public void onDroneEvent(DroneInterfaces.DroneEventsType event, Drone drone) {
break;
}
}

@Override
public void skipMarkerClickEvents(boolean skip) {
// TODO Auto-generated method stub

}
}