Add snap to road image button
This commit is contained in:
parent
227e58780a
commit
45d8cbe83b
3 changed files with 60 additions and 13 deletions
|
@ -94,6 +94,15 @@
|
|||
android:background="@drawable/btn_round"
|
||||
android:contentDescription="@string/layer_route"
|
||||
tools:src="@drawable/ic_action_test_light"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/snap_to_road_image_button"
|
||||
android:layout_width="@dimen/map_button_size"
|
||||
android:layout_height="@dimen/map_button_size"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/btn_circle"
|
||||
android:visibility="gone"
|
||||
tools:src="@drawable/ic_action_test_light"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
|
|
@ -126,6 +126,15 @@
|
|||
android:contentDescription="@string/layer_route"
|
||||
tools:src="@drawable/ic_action_test_light"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/snap_to_road_image_button"
|
||||
android:layout_width="@dimen/map_button_size"
|
||||
android:layout_height="@dimen/map_button_size"
|
||||
android:layout_gravity="bottom"
|
||||
android:background="@drawable/btn_circle"
|
||||
android:visibility="gone"
|
||||
tools:src="@drawable/ic_action_test_light"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/map_ruler_layout"
|
||||
android:layout_width="@dimen/map_ruler_width"
|
||||
|
|
|
@ -105,6 +105,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
private NewGpxLine newGpxLine;
|
||||
private boolean gpxPointsAdded;
|
||||
private boolean snapToRoadEnabled;
|
||||
private ApplicationMode snapToRoadAppMode;
|
||||
|
||||
private boolean inMovePointMode;
|
||||
private boolean inAddPointAfterMode;
|
||||
|
@ -225,12 +226,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
@Override
|
||||
public void snapToRoadOnCLick() {
|
||||
if (!snapToRoadEnabled) {
|
||||
previousToolBarTitle = toolBarController.getTitle();
|
||||
toolBarController.setTitle(getString(R.string.snap_to_road));
|
||||
mapActivity.refreshMap();
|
||||
SnapToRoadBottomSheetDialogFragment fragment = new SnapToRoadBottomSheetDialogFragment();
|
||||
fragment.setListener(createSnapToRoadListener());
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), SnapToRoadBottomSheetDialogFragment.TAG);
|
||||
showSnapToRoadMenu();
|
||||
} else {
|
||||
disableSnapToRoadMode();
|
||||
}
|
||||
|
@ -477,6 +473,10 @@ public class MeasurementToolFragment extends Fragment {
|
|||
hidePointsListFragment();
|
||||
}
|
||||
|
||||
if (snapToRoadEnabled) {
|
||||
enableSnapToRoadMode();
|
||||
}
|
||||
|
||||
if (newGpxLine != null && !gpxPointsAdded) {
|
||||
LineType lineType = newGpxLine.getLineType();
|
||||
if (lineType == LineType.ADD_ROUTE_POINTS) {
|
||||
|
@ -518,6 +518,18 @@ public class MeasurementToolFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
private void showSnapToRoadMenu() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
previousToolBarTitle = toolBarController.getTitle();
|
||||
toolBarController.setTitle(getString(R.string.snap_to_road));
|
||||
mapActivity.refreshMap();
|
||||
SnapToRoadBottomSheetDialogFragment fragment = new SnapToRoadBottomSheetDialogFragment();
|
||||
fragment.setListener(createSnapToRoadListener());
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), SnapToRoadBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
}
|
||||
|
||||
private SelectedPointOptionOnClickListener createSelectedPointOptionOnClickListener() {
|
||||
final MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
|
||||
|
@ -586,21 +598,34 @@ public class MeasurementToolFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public void onApplicationModeItemClick(ApplicationMode mode) {
|
||||
snapToRoadAppMode = mode;
|
||||
enableSnapToRoadMode();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void enableSnapToRoadMode() {
|
||||
if (snapToRoadAppMode != null) {
|
||||
toolBarController.setTopBarSwitchVisible(true);
|
||||
toolBarController.setTopBarSwitchChecked(true);
|
||||
snapToRoadEnabled = true;
|
||||
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_snap_to_road));
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
ImageButton snapToRoadBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
|
||||
snapToRoadBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle);
|
||||
snapToRoadBtn.setImageDrawable(getActiveIcon(snapToRoadAppMode.getSmallIconDark()));
|
||||
snapToRoadBtn.setVisibility(View.VISIBLE);
|
||||
snapToRoadBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showSnapToRoadMenu();
|
||||
}
|
||||
});
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void disableSnapToRoadMode() {
|
||||
toolBarController.setTopBarSwitchVisible(false);
|
||||
|
@ -609,6 +634,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_ruler));
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.GONE);
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
@ -1248,6 +1274,9 @@ public class MeasurementToolFragment extends Fragment {
|
|||
if (pointsListOpened) {
|
||||
hidePointsList();
|
||||
}
|
||||
if (snapToRoadEnabled) {
|
||||
disableSnapToRoadMode();
|
||||
}
|
||||
if (newGpxLine != null) {
|
||||
GPXFile gpx = newGpxLine.getGpxFile();
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getTrackActivity());
|
||||
|
|
Loading…
Reference in a new issue