Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
9873fadf14
16 changed files with 632 additions and 225 deletions
BIN
OsmAnd/res/drawable-hdpi/ic_action_trip_round.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/ic_action_trip_round.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
OsmAnd/res/drawable-mdpi/ic_action_trip_round.png
Normal file
BIN
OsmAnd/res/drawable-mdpi/ic_action_trip_round.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_action_trip_round.png
Normal file
BIN
OsmAnd/res/drawable-xhdpi/ic_action_trip_round.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_trip_round.png
Normal file
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_trip_round.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
|
@ -0,0 +1,226 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/sort_by_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_title_height"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingStart="@dimen/bottom_sheet_content_padding"
|
||||
android:text="@string/shared_string_options"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/navigate_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingStart="@dimen/bottom_sheet_content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/navigate_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/map_directions"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_navigate"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/make_round_trip_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingStart="@dimen/bottom_sheet_content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/make_round_trip_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_trip_round"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/make_round_trip"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:text="@string/make_round_trip_descr"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/make_round_trip_switch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_content_margin"
|
||||
android:background="@null"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:focusableInTouchMode="false"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="@dimen/bottom_sheet_content_padding_small"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_title_height"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingStart="@dimen/bottom_sheet_content_padding"
|
||||
android:text="@string/sort_by"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/door_to_door_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingStart="@dimen/bottom_sheet_content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/door_to_door_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_sort_door_to_door"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/intermediate_items_sort_by_distance"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/reverse_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingStart="@dimen/bottom_sheet_content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/reverse_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_sort_reverse_order"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_reverse_order"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/cancel_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/shared_string_cancel"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:textStyle="bold"/>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -1,117 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/sort_by_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_title_height"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingStart="@dimen/bottom_sheet_content_padding"
|
||||
android:text="@string/sort_by"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/door_to_door_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingStart="@dimen/bottom_sheet_content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/door_to_door_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_sort_door_to_door"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:text="@string/intermediate_items_sort_by_distance"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/reverse_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_list_item_height"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="@dimen/bottom_sheet_list_item_height"
|
||||
android:paddingEnd="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_padding"
|
||||
android:paddingStart="@dimen/bottom_sheet_content_padding">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/reverse_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
|
||||
tools:src="@drawable/ic_action_sort_reverse_order"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_reverse_order"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/cancel_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/shared_string_cancel"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:textStyle="bold"/>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -9,6 +9,9 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="make_round_trip_descr">Add copy of start point as destination.</string>
|
||||
<string name="make_round_trip">Make round trip</string>
|
||||
<string name="shared_string_navigate">Navigate</string>
|
||||
<string name="shared_string_markers">Markers</string>
|
||||
<string name="coordinates_format">Coordinates format</string>
|
||||
<string name="use_system_keyboard">Use system keyboard</string>
|
||||
|
@ -30,8 +33,8 @@
|
|||
<string name="group_will_be_removed_after_restart">Group will be removed after restart</string>
|
||||
<string name="show_guide_line">Show guide line</string>
|
||||
<string name="show_arrows_on_the_map">Show arrows on the map</string>
|
||||
<string name="show_passed">Show \'Last used\' date</string>
|
||||
<string name="hide_passed">Hide \'Last used\' date</string>
|
||||
<string name="show_passed">Show passed</string>
|
||||
<string name="hide_passed">Hide passed</string>
|
||||
<string name="remove_from_map_markers">Remove from Map Markers</string>
|
||||
<string name="descendingly">descending</string>
|
||||
<string name="ascendingly">ascending</string>
|
||||
|
@ -45,7 +48,7 @@
|
|||
<string name="marker_moved_to_active">Map marker moved to active</string>
|
||||
<string name="shared_string_list">List</string>
|
||||
<string name="shared_string_groups">Groups</string>
|
||||
<string name="passed">Last used: %1$s</string>
|
||||
<string name="passed">Passed: %1$s</string>
|
||||
<string name="make_active">Make active</string>
|
||||
<string name="today">Today</string>
|
||||
<string name="yesterday">Yesterday</string>
|
||||
|
@ -270,7 +273,7 @@
|
|||
<string name="osmo_share_location">Share</string>
|
||||
<string name="osmo_pause_location">Pause</string>
|
||||
<string name="osmo_service_running">OsMo service is running</string>
|
||||
<string name="trip_rec_notification_settings">Trip recording (no data)</string>
|
||||
<string name="trip_rec_notification_settings">Enable recording quick start</string>
|
||||
<string name="trip_rec_notification_settings_desc">Display a system notification allowing to start trip recording</string>
|
||||
<string name="shared_string_notifications">Notifications</string>
|
||||
<string name="shared_string_continue">Continue</string>
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.util.Pair;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
|
@ -27,6 +28,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static net.osmand.data.PointDescription.POINT_TYPE_MAP_MARKER;
|
||||
|
||||
|
@ -42,6 +44,9 @@ public class MapMarkersHelper {
|
|||
private MapMarkersDbHelper markersDbHelper;
|
||||
private boolean startFromMyLocation;
|
||||
|
||||
private final Map<Pair<WptPt, WptPt>, List<WptPt>> snappedToRoadPoints = new ConcurrentHashMap<>();
|
||||
private ApplicationMode snappedMode;
|
||||
|
||||
public interface MapMarkerChangedListener {
|
||||
void onMapMarkerChanged(MapMarker mapMarker);
|
||||
|
||||
|
@ -231,6 +236,18 @@ public class MapMarkersHelper {
|
|||
createMapMarkersGroups();
|
||||
}
|
||||
|
||||
public Map<Pair<WptPt, WptPt>, List<WptPt>> getSnappedToRoadPoints() {
|
||||
return snappedToRoadPoints;
|
||||
}
|
||||
|
||||
public ApplicationMode getSnappedMode() {
|
||||
return snappedMode;
|
||||
}
|
||||
|
||||
public void setSnappedMode(ApplicationMode snappedMode) {
|
||||
this.snappedMode = snappedMode;
|
||||
}
|
||||
|
||||
public boolean isStartFromMyLocation() {
|
||||
return startFromMyLocation;
|
||||
}
|
||||
|
|
|
@ -788,9 +788,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
mapActivity.enableDrawer();
|
||||
|
||||
getMyApplication().getMapMarkersHelper().removeListener(this);
|
||||
if (mapActivity.getMapLayers().getMapMarkersLayer().clearRoute()) {
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
// if (mapActivity.getMapLayers().getMapMarkersLayer().clearRoute()) {
|
||||
// mapActivity.refreshMap();
|
||||
// }
|
||||
if (swipeDismissListener != null) {
|
||||
swipeDismissListener.discardUndo();
|
||||
}
|
||||
|
@ -1691,7 +1691,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
public void showMarkersRouteOnMap() {
|
||||
MapMarkersHelper helper = getMyApplication().getMapMarkersHelper();
|
||||
List<LatLon> points = helper.getSelectedMarkersLatLon();
|
||||
mapActivity.getMapLayers().getMapMarkersLayer().setRoute(points);
|
||||
// mapActivity.getMapLayers().getMapMarkersLayer().setRoute(points);
|
||||
showRouteOnMap(points);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.support.v4.content.ContextCompat;
|
|||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||
import android.util.Pair;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -20,6 +21,7 @@ import android.view.ViewGroup;
|
|||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -29,6 +31,8 @@ import net.osmand.TspAnt;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
|
@ -38,26 +42,35 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.mapmarkers.PlanRouteSortByBottomSheetDialogFragment.PlanRouteSortByFragmentListener;
|
||||
import net.osmand.plus.mapmarkers.PlanRouteOptionsBottomSheetDialogFragment.PlanRouteOptionsFragmentListener;
|
||||
import net.osmand.plus.mapmarkers.adapters.MapMarkersItemTouchHelperCallback;
|
||||
import net.osmand.plus.mapmarkers.adapters.MapMarkersListAdapter;
|
||||
import net.osmand.plus.measurementtool.RecyclerViewFragment;
|
||||
import net.osmand.plus.measurementtool.SnapToRoadBottomSheetDialogFragment;
|
||||
import net.osmand.plus.measurementtool.SnapToRoadBottomSheetDialogFragment.SnapToRoadFragmentListener;
|
||||
import net.osmand.plus.routing.RouteCalculationParams;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.MapMarkersLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||
import net.osmand.router.RouteCalculationProgress;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import static net.osmand.plus.OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT;
|
||||
|
||||
public class PlanRouteFragment extends Fragment {
|
||||
|
||||
public static final String TAG = "PlanRouteFragment";
|
||||
private static final int MAX_DIST_FOR_SNAP_TO_ROAD = 500 * 1000; // 500 km
|
||||
|
||||
private MapMarkersHelper markersHelper;
|
||||
private MapMarkersListAdapter adapter;
|
||||
|
@ -81,11 +94,19 @@ public class PlanRouteFragment extends Fragment {
|
|||
private TextView timeTv;
|
||||
private TextView countTv;
|
||||
|
||||
private final Queue<Pair<WptPt, WptPt>> snapToRoadPairsToCalculate = new ConcurrentLinkedQueue<>();
|
||||
private Map<Pair<WptPt, WptPt>, List<WptPt>> snappedToRoadPoints;
|
||||
private TrkSegment snapTrkSegment = new TrkSegment();
|
||||
private RouteCalculationProgress calculationProgress;
|
||||
private int calculatedPairs;
|
||||
private boolean progressBarVisible;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
final MapActivity mapActivity = getMapActivity();
|
||||
markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
|
||||
snappedToRoadPoints = markersHelper.getSnappedToRoadPoints();
|
||||
|
||||
// Handling screen rotation
|
||||
FragmentManager fragmentManager = mapActivity.getSupportFragmentManager();
|
||||
|
@ -93,9 +114,9 @@ public class PlanRouteFragment extends Fragment {
|
|||
if (snapToRoadFragment != null) {
|
||||
((SnapToRoadBottomSheetDialogFragment) snapToRoadFragment).setListener(createSnapToRoadFragmentListener());
|
||||
}
|
||||
Fragment sortByFragment = fragmentManager.findFragmentByTag(PlanRouteSortByBottomSheetDialogFragment.TAG);
|
||||
Fragment sortByFragment = fragmentManager.findFragmentByTag(PlanRouteOptionsBottomSheetDialogFragment.TAG);
|
||||
if (sortByFragment != null) {
|
||||
((PlanRouteSortByBottomSheetDialogFragment) sortByFragment).setListener(createSortByFragmentListener());
|
||||
((PlanRouteOptionsBottomSheetDialogFragment) sortByFragment).setListener(createOptionsFragmentListener());
|
||||
}
|
||||
// If rotate the screen from landscape to portrait when the list of markers is displayed then
|
||||
// the RecyclerViewFragment will exist without view. This is necessary to remove it.
|
||||
|
@ -158,9 +179,8 @@ public class PlanRouteFragment extends Fragment {
|
|||
}
|
||||
adapter.calculateStartAndFinishPos();
|
||||
adapter.notifyDataSetChanged();
|
||||
updateText();
|
||||
updateSelectButton();
|
||||
showMarkersRouteOnMap();
|
||||
recreateSnapTrkSegment();
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
});
|
||||
|
@ -168,9 +188,7 @@ public class PlanRouteFragment extends Fragment {
|
|||
mainView.findViewById(R.id.sort_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
PlanRouteSortByBottomSheetDialogFragment fragment = new PlanRouteSortByBottomSheetDialogFragment();
|
||||
fragment.setListener(createSortByFragmentListener());
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), PlanRouteSortByBottomSheetDialogFragment.TAG);
|
||||
Toast.makeText(mapActivity, "Sort", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -192,6 +210,15 @@ public class PlanRouteFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
});
|
||||
toolbarController.setSaveViewTextId(R.string.shared_string_options);
|
||||
toolbarController.setOnSaveViewClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
PlanRouteOptionsBottomSheetDialogFragment fragment = new PlanRouteOptionsBottomSheetDialogFragment();
|
||||
fragment.setListener(createOptionsFragmentListener());
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), PlanRouteOptionsBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
});
|
||||
mapActivity.showTopToolbar(toolbarController);
|
||||
|
||||
if (portrait) {
|
||||
|
@ -203,6 +230,7 @@ public class PlanRouteFragment extends Fragment {
|
|||
adapter = new MapMarkersListAdapter(mapActivity);
|
||||
adapter.setHasStableIds(true);
|
||||
adapter.calculateStartAndFinishPos();
|
||||
adapter.setSnappedToRoadPoints(snappedToRoadPoints);
|
||||
final ItemTouchHelper touchHelper = new ItemTouchHelper(new MapMarkersItemTouchHelperCallback(adapter));
|
||||
touchHelper.attachToRecyclerView(markersRv);
|
||||
adapter.setAdapterListener(new MapMarkersListAdapter.MapMarkersListAdapterListener() {
|
||||
|
@ -227,8 +255,7 @@ public class PlanRouteFragment extends Fragment {
|
|||
adapter.calculateStartAndFinishPos();
|
||||
adapter.notifyDataSetChanged();
|
||||
updateSelectButton();
|
||||
updateText();
|
||||
showMarkersRouteOnMap();
|
||||
recreateSnapTrkSegment();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -251,8 +278,7 @@ public class PlanRouteFragment extends Fragment {
|
|||
// to avoid crash because of:
|
||||
// java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling
|
||||
}
|
||||
updateText();
|
||||
showMarkersRouteOnMap();
|
||||
recreateSnapTrkSegment();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -296,6 +322,10 @@ public class PlanRouteFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
if (progressBarVisible) {
|
||||
showProgressBar();
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -337,18 +367,36 @@ public class PlanRouteFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public void onApplicationModeItemClick(ApplicationMode mode) {
|
||||
appMode = mode;
|
||||
setupAppModesBtn();
|
||||
updateText();
|
||||
if (appMode != null && appMode != mode) {
|
||||
appMode = mode;
|
||||
snappedToRoadPoints.clear();
|
||||
markersHelper.setSnappedMode(mode);
|
||||
recreateSnapTrkSegment();
|
||||
setupAppModesBtn();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private PlanRouteSortByFragmentListener createSortByFragmentListener() {
|
||||
return new PlanRouteSortByFragmentListener() {
|
||||
private PlanRouteOptionsFragmentListener createOptionsFragmentListener() {
|
||||
return new PlanRouteOptionsFragmentListener() {
|
||||
|
||||
private MapActivity mapActivity = getMapActivity();
|
||||
|
||||
@Override
|
||||
public void navigateOnClick() {
|
||||
if (mapActivity != null) {
|
||||
Toast.makeText(mapActivity, "navigate", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeRoundTripOnClick() {
|
||||
if (mapActivity != null) {
|
||||
Toast.makeText(mapActivity, "mare round trip", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doorToDoorOnClick() {
|
||||
if (mapActivity != null) {
|
||||
|
@ -367,6 +415,7 @@ public class PlanRouteFragment extends Fragment {
|
|||
markersHelper.reverseActiveMarkersOrder();
|
||||
adapter.calculateStartAndFinishPos();
|
||||
adapter.notifyDataSetChanged();
|
||||
recreateSnapTrkSegment();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -399,15 +448,14 @@ public class PlanRouteFragment extends Fragment {
|
|||
wasCollapseButtonVisible = false;
|
||||
}
|
||||
|
||||
if (appMode == null) {
|
||||
if ((appMode = markersHelper.getSnappedMode()) == null) {
|
||||
appMode = ApplicationMode.DEFAULT;
|
||||
}
|
||||
setupAppModesBtn();
|
||||
|
||||
selectedCount = mapActivity.getMyApplication().getMapMarkersHelper().getSelectedMarkersCount();
|
||||
showMarkersRouteOnMap();
|
||||
recreateSnapTrkSegment();
|
||||
mapActivity.refreshMap();
|
||||
updateText();
|
||||
updateSelectButton();
|
||||
}
|
||||
}
|
||||
|
@ -460,7 +508,8 @@ public class PlanRouteFragment extends Fragment {
|
|||
mapActivity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.GONE);
|
||||
mainView.findViewById(R.id.snap_to_road_progress_bar).setVisibility(View.GONE);
|
||||
|
||||
markersLayer.clearRoute();
|
||||
cancelSnapToRoad();
|
||||
markersLayer.setRoute(null);
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
@ -468,20 +517,13 @@ public class PlanRouteFragment extends Fragment {
|
|||
private void updateText() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
boolean defaultMode = appMode.getStringKey().equals(ApplicationMode.DEFAULT.getStringKey());
|
||||
boolean defaultMode = appMode == ApplicationMode.DEFAULT;
|
||||
|
||||
float dist = 0;
|
||||
Location myLoc = mapActivity.getMyApplication().getLocationProvider().getLastStaleKnownLocation();
|
||||
boolean useLocation = myLoc != null && mapActivity.getMyApplication().getSettings().ROUTE_MAP_MARKERS_START_MY_LOC.get();
|
||||
List<LatLon> markers = markersHelper.getSelectedMarkersLatLon();
|
||||
if (useLocation ? markers.size() > 0 : markers.size() > 1) {
|
||||
if (useLocation) {
|
||||
dist += MapUtils.getDistance(myLoc.getLatitude(), myLoc.getLongitude(),
|
||||
markers.get(0).getLatitude(), markers.get(0).getLongitude());
|
||||
}
|
||||
for (int i = 1; i < markers.size(); i++) {
|
||||
dist += MapUtils.getDistance(markers.get(i - 1), markers.get(i));
|
||||
}
|
||||
for (int i = 1; i < snapTrkSegment.points.size(); i++) {
|
||||
WptPt pt1 = snapTrkSegment.points.get(i - 1);
|
||||
WptPt pt2 = snapTrkSegment.points.get(i);
|
||||
dist += MapUtils.getDistance(pt1.lat, pt1.lon, pt2.lat, pt2.lon);
|
||||
}
|
||||
distanceTv.setText(OsmAndFormatter.getFormattedDistance(dist, mapActivity.getMyApplication()) + (defaultMode ? "" : ","));
|
||||
|
||||
|
@ -584,16 +626,17 @@ public class PlanRouteFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
private void showMarkersRouteOnMap() {
|
||||
private void showMarkersRouteOnMap(boolean adjustMap) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
List<LatLon> points = markersHelper.getSelectedMarkersLatLon();
|
||||
mapActivity.getMapLayers().getMapMarkersLayer().setRoute(points);
|
||||
showRouteOnMap(points);
|
||||
mapActivity.getMapLayers().getMapMarkersLayer().setRoute(snapTrkSegment);
|
||||
if (adjustMap) {
|
||||
showRouteOnMap(snapTrkSegment.points);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showRouteOnMap(List<LatLon> points) {
|
||||
private void showRouteOnMap(List<WptPt> points) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (points.size() > 0 && mapActivity != null) {
|
||||
OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
|
@ -606,17 +649,17 @@ public class PlanRouteFragment extends Fragment {
|
|||
top = myLocation.getLatitude();
|
||||
bottom = myLocation.getLatitude();
|
||||
}
|
||||
for (LatLon l : points) {
|
||||
for (WptPt pt : points) {
|
||||
if (left == 0) {
|
||||
left = l.getLongitude();
|
||||
right = l.getLongitude();
|
||||
top = l.getLatitude();
|
||||
bottom = l.getLatitude();
|
||||
left = pt.getLongitude();
|
||||
right = pt.getLongitude();
|
||||
top = pt.getLatitude();
|
||||
bottom = pt.getLatitude();
|
||||
} else {
|
||||
left = Math.min(left, l.getLongitude());
|
||||
right = Math.max(right, l.getLongitude());
|
||||
top = Math.max(top, l.getLatitude());
|
||||
bottom = Math.min(bottom, l.getLatitude());
|
||||
left = Math.min(left, pt.getLongitude());
|
||||
right = Math.max(right, pt.getLongitude());
|
||||
top = Math.max(top, pt.getLatitude());
|
||||
bottom = Math.min(bottom, pt.getLatitude());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -721,12 +764,204 @@ public class PlanRouteFragment extends Fragment {
|
|||
mapActivity.getMyApplication().getMapMarkersHelper().addSelectedMarkersToTop(res);
|
||||
adapter.calculateStartAndFinishPos();
|
||||
adapter.notifyDataSetChanged();
|
||||
updateText();
|
||||
showMarkersRouteOnMap();
|
||||
recreateSnapTrkSegment();
|
||||
}
|
||||
}.execute();
|
||||
}
|
||||
|
||||
private void cancelSnapToRoad() {
|
||||
hideProgressBar();
|
||||
snapToRoadPairsToCalculate.clear();
|
||||
if (calculationProgress != null) {
|
||||
calculationProgress.isCancelled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleRouteCalculateIfNotEmpty(List<WptPt> points) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity == null || points.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
findPairsToCalculate(points);
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (!snapToRoadPairsToCalculate.isEmpty() && !routingHelper.isRouteBeingCalculated()) {
|
||||
routingHelper.startRouteCalculationThread(getParams(app), true, true);
|
||||
app.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showProgressBar();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void findPairsToCalculate(List<WptPt> points) {
|
||||
snapToRoadPairsToCalculate.clear();
|
||||
for (int i = 0; i < points.size() - 1; i++) {
|
||||
Pair<WptPt, WptPt> pair = new Pair<>(points.get(i), points.get(i + 1));
|
||||
if (snappedToRoadPoints.get(pair) == null) {
|
||||
double dist = MapUtils.getDistance(pair.first.lat, pair.first.lon, pair.second.lat, pair.second.lon);
|
||||
if (dist < MAX_DIST_FOR_SNAP_TO_ROAD) {
|
||||
snapToRoadPairsToCalculate.add(pair);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void recreateSnapTrkSegment() {
|
||||
recreateSnapTrkSegment(true);
|
||||
}
|
||||
|
||||
private void recreateSnapTrkSegment(boolean adjustMap) {
|
||||
snapTrkSegment.points.clear();
|
||||
List<WptPt> points = getPointsToCalculate();
|
||||
if (appMode == ApplicationMode.DEFAULT) {
|
||||
snapTrkSegment.points.addAll(points);
|
||||
} else if (points.size() > 1) {
|
||||
for (int i = 0; i < points.size() - 1; i++) {
|
||||
Pair<WptPt, WptPt> pair = new Pair<>(points.get(i), points.get(i + 1));
|
||||
List<WptPt> pts = snappedToRoadPoints.get(pair);
|
||||
if (pts != null) {
|
||||
snapTrkSegment.points.addAll(pts);
|
||||
} else {
|
||||
scheduleRouteCalculateIfNotEmpty(points);
|
||||
snapTrkSegment.points.addAll(Arrays.asList(pair.first, pair.second));
|
||||
}
|
||||
}
|
||||
}
|
||||
showMarkersRouteOnMap(adjustMap);
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.getMyApplication().runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateText();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private List<WptPt> getPointsToCalculate() {
|
||||
List<WptPt> points = new LinkedList<>();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
Location myLoc = mapActivity.getMyApplication().getLocationProvider().getLastStaleKnownLocation();
|
||||
if (markersHelper.isStartFromMyLocation() && myLoc != null) {
|
||||
addWptPt(points, myLoc.getLatitude(), myLoc.getLongitude());
|
||||
}
|
||||
for (LatLon l : markersHelper.getSelectedMarkersLatLon()) {
|
||||
addWptPt(points, l.getLatitude(), l.getLongitude());
|
||||
}
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
private void addWptPt(List<WptPt> points, double lat, double lon) {
|
||||
WptPt pt = new WptPt();
|
||||
pt.lat = lat;
|
||||
pt.lon = lon;
|
||||
points.add(pt);
|
||||
}
|
||||
|
||||
private void showProgressBar() {
|
||||
ProgressBar progressBar = (ProgressBar) mainView.findViewById(R.id.snap_to_road_progress_bar);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setMinimumHeight(0);
|
||||
progressBar.setProgress(0);
|
||||
progressBarVisible = true;
|
||||
}
|
||||
|
||||
private void updateProgress(int progress) {
|
||||
((ProgressBar) mainView.findViewById(R.id.snap_to_road_progress_bar)).setProgress(progress);
|
||||
}
|
||||
|
||||
private void refresh() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
private void hideProgressBar() {
|
||||
mainView.findViewById(R.id.snap_to_road_progress_bar).setVisibility(View.GONE);
|
||||
progressBarVisible = false;
|
||||
}
|
||||
|
||||
private RouteCalculationParams getParams(final OsmandApplication app) {
|
||||
final Pair<WptPt, WptPt> currentPair = snapToRoadPairsToCalculate.poll();
|
||||
|
||||
Location start = new Location("");
|
||||
start.setLatitude(currentPair.first.getLatitude());
|
||||
start.setLongitude(currentPair.first.getLongitude());
|
||||
|
||||
LatLon end = new LatLon(currentPair.second.getLatitude(), currentPair.second.getLongitude());
|
||||
|
||||
final RouteCalculationParams params = new RouteCalculationParams();
|
||||
params.inSnapToRoadMode = true;
|
||||
params.start = start;
|
||||
params.end = end;
|
||||
RoutingHelper.applyApplicationSettings(params, app.getSettings(), appMode);
|
||||
params.mode = appMode;
|
||||
params.ctx = app;
|
||||
params.calculationProgress = calculationProgress = new RouteCalculationProgress();
|
||||
params.calculationProgressCallback = new RoutingHelper.RouteCalculationProgressCallback() {
|
||||
@Override
|
||||
public void updateProgress(int progress) {
|
||||
int pairs = calculatedPairs + snapToRoadPairsToCalculate.size();
|
||||
if (pairs != 0) {
|
||||
int pairProgress = 100 / pairs;
|
||||
progress = calculatedPairs * pairProgress + progress / pairs;
|
||||
}
|
||||
PlanRouteFragment.this.updateProgress(progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestPrivateAccessRouting() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
calculatedPairs = 0;
|
||||
}
|
||||
};
|
||||
params.resultListener = new RouteCalculationParams.RouteCalculationResultListener() {
|
||||
@Override
|
||||
public void onRouteCalculated(List<Location> locations) {
|
||||
ArrayList<WptPt> pts = new ArrayList<>(locations.size());
|
||||
for (Location loc : locations) {
|
||||
WptPt pt = new WptPt();
|
||||
pt.lat = loc.getLatitude();
|
||||
pt.lon = loc.getLongitude();
|
||||
pts.add(pt);
|
||||
}
|
||||
calculatedPairs++;
|
||||
snappedToRoadPoints.put(currentPair, pts);
|
||||
recreateSnapTrkSegment(false);
|
||||
app.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
adapter.notifyDataSetChanged();
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
if (!snapToRoadPairsToCalculate.isEmpty()) {
|
||||
app.getRoutingHelper().startRouteCalculationThread(getParams(app), true, true);
|
||||
} else {
|
||||
app.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
hideProgressBar();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
private class PlanRouteToolbarController extends TopToolbarController {
|
||||
|
||||
PlanRouteToolbarController() {
|
||||
|
@ -737,6 +972,7 @@ public class PlanRouteFragment extends Fragment {
|
|||
setBgIds(R.drawable.gradient_toolbar, R.drawable.gradient_toolbar,
|
||||
R.drawable.gradient_toolbar, R.drawable.gradient_toolbar);
|
||||
setCloseBtnVisible(false);
|
||||
setSaveViewVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,15 +21,15 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
|
||||
public class PlanRouteSortByBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||
public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||
|
||||
public final static String TAG = "PlanRouteSortByBottomSheetDialogFragment";
|
||||
public final static String TAG = "PlanRouteOptionsBottomSheetDialogFragment";
|
||||
|
||||
private boolean portrait;
|
||||
private boolean night;
|
||||
private PlanRouteSortByFragmentListener listener;
|
||||
private PlanRouteOptionsFragmentListener listener;
|
||||
|
||||
public void setListener(PlanRouteSortByFragmentListener listener) {
|
||||
public void setListener(PlanRouteOptionsFragmentListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class PlanRouteSortByBottomSheetDialogFragment extends BottomSheetDialogF
|
|||
night = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
|
||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_plan_route_sort_by_bottom_sheet_dialog, container);
|
||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_plan_route_options_bottom_sheet_dialog, container);
|
||||
if (portrait) {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||
}
|
||||
|
@ -49,9 +49,29 @@ public class PlanRouteSortByBottomSheetDialogFragment extends BottomSheetDialogF
|
|||
((TextView) mainView.findViewById(R.id.title)).setTextColor(ContextCompat.getColor(getActivity(), R.color.ctx_menu_info_text_dark));
|
||||
}
|
||||
|
||||
((ImageView) mainView.findViewById(R.id.navigate_icon)).setImageDrawable(getContentIcon(R.drawable.map_directions));
|
||||
((ImageView) mainView.findViewById(R.id.make_round_trip_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_trip_round));
|
||||
((ImageView) mainView.findViewById(R.id.door_to_door_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_door_to_door));
|
||||
((ImageView) mainView.findViewById(R.id.reverse_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_reverse_order));
|
||||
|
||||
mainView.findViewById(R.id.navigate_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.navigateOnClick();
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
mainView.findViewById(R.id.make_round_trip_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.makeRoundTripOnClick();
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
mainView.findViewById(R.id.door_to_door_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -133,7 +153,11 @@ public class PlanRouteSortByBottomSheetDialogFragment extends BottomSheetDialogF
|
|||
return getIcon(id, night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
|
||||
}
|
||||
|
||||
interface PlanRouteSortByFragmentListener {
|
||||
interface PlanRouteOptionsFragmentListener {
|
||||
|
||||
void navigateOnClick();
|
||||
|
||||
void makeRoundTripOnClick();
|
||||
|
||||
void doorToDoorOnClick();
|
||||
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.mapmarkers.adapters;
|
|||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.view.MotionEventCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Pair;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
@ -10,6 +11,7 @@ import android.view.ViewGroup;
|
|||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
|
@ -23,6 +25,7 @@ import java.util.Collections;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder>
|
||||
implements MapMarkersItemTouchHelperCallback.ItemTouchHelperAdapter {
|
||||
|
@ -37,10 +40,16 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
|||
private int finishPos = -1;
|
||||
private int firstSelectedMarkerPos = -1;
|
||||
|
||||
private Map<Pair<WptPt, WptPt>, List<WptPt>> snappedToRoadPoints;
|
||||
|
||||
public void setAdapterListener(MapMarkersListAdapterListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void setSnappedToRoadPoints(Map<Pair<WptPt, WptPt>, List<WptPt>> snappedToRoadPoints) {
|
||||
this.snappedToRoadPoints = snappedToRoadPoints;
|
||||
}
|
||||
|
||||
public MapMarkersListAdapter(MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
markers = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers();
|
||||
|
@ -65,7 +74,6 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
|||
IconsCache iconsCache = app.getIconsCache();
|
||||
|
||||
boolean locationItem = pos == 0;
|
||||
boolean firstMarkerItem = pos == 1;
|
||||
boolean lastMarkerItem = pos == getItemCount() - 1;
|
||||
boolean start = pos == startPos;
|
||||
boolean finish = pos == finishPos && startPos != finishPos;
|
||||
|
@ -99,6 +107,13 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
|||
holder.firstDescription.setText(mapActivity.getString(R.string.shared_string_finish) + " • ");
|
||||
}
|
||||
|
||||
boolean iconSettled = false;
|
||||
if ((start || finish) && !locationItem) {
|
||||
int res = start ? R.drawable.ic_action_point_start : R.drawable.ic_action_point_destination;
|
||||
holder.icon.setImageDrawable(iconsCache.getIcon(res, MapMarker.getColorId(marker.colorIndex)));
|
||||
iconSettled = true;
|
||||
}
|
||||
|
||||
if (locationItem) {
|
||||
holder.topDivider.setVisibility(View.VISIBLE);
|
||||
holder.flagIconLeftSpace.setVisibility(View.VISIBLE);
|
||||
|
@ -111,7 +126,9 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
|||
} else {
|
||||
holder.topDivider.setVisibility(View.GONE);
|
||||
holder.flagIconLeftSpace.setVisibility(View.GONE);
|
||||
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(marker.colorIndex)));
|
||||
if (!iconSettled) {
|
||||
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(marker.colorIndex)));
|
||||
}
|
||||
holder.point.setVisibility(View.VISIBLE);
|
||||
holder.checkBox.setChecked(marker.selected);
|
||||
|
||||
|
@ -157,7 +174,21 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
|
|||
: getPreviousSelectedMarkerLatLon(pos - 1);
|
||||
float dist = 0;
|
||||
if (first != null && marker != null) {
|
||||
dist = (float) MapUtils.getDistance(first, marker.point);
|
||||
WptPt pt1 = new WptPt();
|
||||
pt1.lat = first.getLatitude();
|
||||
pt1.lon = first.getLongitude();
|
||||
WptPt pt2 = new WptPt();
|
||||
pt2.lat = marker.getLatitude();
|
||||
pt2.lon = marker.getLongitude();
|
||||
List<WptPt> points = snappedToRoadPoints.get(new Pair<>(pt1, pt2));
|
||||
if (points != null) {
|
||||
for (int i = 0; i < points.size() - 1; i++) {
|
||||
dist += (float) MapUtils.getDistance(points.get(i).lat, points.get(i).lon,
|
||||
points.get(i + 1).lat, points.get(i + 1).lon);
|
||||
}
|
||||
} else {
|
||||
dist = (float) MapUtils.getDistance(pt1.lat, pt1.lon, pt2.lat, pt2.lon);
|
||||
}
|
||||
}
|
||||
holder.distance.setText(OsmAndFormatter.getFormattedDistance(dist, app));
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import net.osmand.plus.ApplicationMode;
|
|||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.measurementtool.command.MeasurementCommandManager;
|
||||
import net.osmand.plus.routing.RouteCalculationParams;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
|
@ -259,8 +258,6 @@ public class MeasurementEditingContext {
|
|||
}
|
||||
|
||||
private RouteCalculationParams getParams() {
|
||||
OsmandSettings settings = application.getSettings();
|
||||
|
||||
final Pair<WptPt, WptPt> currentPair = snapToRoadPairsToCalculate.poll();
|
||||
|
||||
Location start = new Location("");
|
||||
|
@ -273,9 +270,7 @@ public class MeasurementEditingContext {
|
|||
params.inSnapToRoadMode = true;
|
||||
params.start = start;
|
||||
params.end = end;
|
||||
params.leftSide = settings.DRIVING_REGION.get().leftHandDriving;
|
||||
params.fast = settings.FAST_ROUTE_MODE.getModeValue(snapToRoadAppMode);
|
||||
params.type = settings.ROUTER_SERVICE.getModeValue(snapToRoadAppMode);
|
||||
RoutingHelper.applyApplicationSettings(params, application.getSettings(), snapToRoadAppMode);
|
||||
params.mode = snapToRoadAppMode;
|
||||
params.ctx = application;
|
||||
params.calculationProgress = calculationProgress = new RouteCalculationProgress();
|
||||
|
|
|
@ -1008,6 +1008,12 @@ public class RoutingHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public static void applyApplicationSettings(RouteCalculationParams params, OsmandSettings settings, ApplicationMode mode) {
|
||||
params.leftSide = settings.DRIVING_REGION.get().leftHandDriving;
|
||||
params.fast = settings.FAST_ROUTE_MODE.getModeValue(mode);
|
||||
params.type = settings.ROUTER_SERVICE.getModeValue(mode);
|
||||
}
|
||||
|
||||
public void setProgressBar(RouteCalculationProgressCallback progressRoute) {
|
||||
this.progressRoute = progressRoute;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadPoint;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
|
@ -71,8 +72,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
private final RenderingLineAttributes lineAttrs = new RenderingLineAttributes("measureDistanceLine");
|
||||
private final RenderingLineAttributes textAttrs = new RenderingLineAttributes("rulerLineFont");
|
||||
private Paint paint;
|
||||
private Path path;
|
||||
private List<LatLon> route = new ArrayList<>();
|
||||
private TrkSegment route;
|
||||
|
||||
private TIntArrayList tx = new TIntArrayList();
|
||||
private TIntArrayList ty = new TIntArrayList();
|
||||
|
@ -120,7 +120,6 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
bitmapPaintDestTeal = createPaintDest(R.color.marker_teal);
|
||||
bitmapPaintDestPurple = createPaintDest(R.color.marker_purple);
|
||||
|
||||
path = new Path();
|
||||
paint = new Paint();
|
||||
paint.setStyle(Paint.Style.STROKE);
|
||||
paint.setStrokeWidth(7 * view.getDensity());
|
||||
|
@ -191,15 +190,8 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
}
|
||||
}
|
||||
|
||||
public void setRoute(List<LatLon> points) {
|
||||
route.clear();
|
||||
route.addAll(points);
|
||||
}
|
||||
|
||||
public boolean clearRoute() {
|
||||
boolean res = route.size() > 0;
|
||||
route.clear();
|
||||
return res;
|
||||
public void setRoute(TrkSegment route) {
|
||||
this.route = route;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -214,26 +206,10 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
|
||||
List<MapMarker> activeMapMarkers = markersHelper.getMapMarkers();
|
||||
|
||||
if (route.size() > 0) {
|
||||
path.reset();
|
||||
boolean first = true;
|
||||
if (markersHelper.isStartFromMyLocation() && myLoc != null) {
|
||||
int locationX = tileBox.getPixXFromLonNoRot(myLoc.getLongitude());
|
||||
int locationY = tileBox.getPixYFromLatNoRot(myLoc.getLatitude());
|
||||
path.moveTo(locationX, locationY);
|
||||
first = false;
|
||||
}
|
||||
for (LatLon point : route) {
|
||||
int locationX = tileBox.getPixXFromLonNoRot(point.getLongitude());
|
||||
int locationY = tileBox.getPixYFromLatNoRot(point.getLatitude());
|
||||
if (first) {
|
||||
path.moveTo(locationX, locationY);
|
||||
first = false;
|
||||
} else {
|
||||
path.lineTo(locationX, locationY);
|
||||
}
|
||||
}
|
||||
canvas.drawPath(path, paint);
|
||||
if (route != null && route.points.size() > 0) {
|
||||
route.renders.clear();
|
||||
route.renders.add(new Renderable.StandardTrack(new ArrayList<>(route.points), 17.2));
|
||||
route.drawRenderers(view.getZoom(), paint, canvas, tileBox);
|
||||
}
|
||||
|
||||
if (markersHelper.isStartFromMyLocation() && myLoc != null) {
|
||||
|
|
|
@ -249,6 +249,8 @@ public class MapInfoWidgetsFactory {
|
|||
String title = "";
|
||||
String description = null;
|
||||
|
||||
int saveViewTextId = -1;
|
||||
|
||||
OnClickListener onBackButtonClickListener;
|
||||
OnClickListener onTitleClickListener;
|
||||
OnClickListener onCloseButtonClickListener;
|
||||
|
@ -337,6 +339,10 @@ public class MapInfoWidgetsFactory {
|
|||
this.saveViewVisible = visible;
|
||||
}
|
||||
|
||||
public void setSaveViewTextId(int id) {
|
||||
this.saveViewTextId = id;
|
||||
}
|
||||
|
||||
public void setTopBarSwitchVisible(boolean visible) {
|
||||
this.topBarSwitchVisible = visible;
|
||||
}
|
||||
|
@ -649,6 +655,10 @@ public class MapInfoWidgetsFactory {
|
|||
refreshButton.setVisibility(View.GONE);
|
||||
}
|
||||
if (controller.saveViewVisible) {
|
||||
if (controller.saveViewTextId != -1) {
|
||||
saveView.setText(map.getString(controller.saveViewTextId));
|
||||
saveView.setContentDescription(map.getString(controller.saveViewTextId));
|
||||
}
|
||||
if (saveView.getVisibility() == View.GONE) {
|
||||
saveView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -749,7 +759,7 @@ public class MapInfoWidgetsFactory {
|
|||
if (text == null) {
|
||||
text = "";
|
||||
} else {
|
||||
if(type[0] == null){
|
||||
if (type[0] == null) {
|
||||
showMarker = true;
|
||||
} else {
|
||||
turnDrawable.setColor(R.color.nav_arrow);
|
||||
|
@ -784,16 +794,16 @@ public class MapInfoWidgetsFactory {
|
|||
rt.getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get()),
|
||||
rt.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)),
|
||||
rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)),
|
||||
"»");
|
||||
"»");
|
||||
}
|
||||
if (text == null) {
|
||||
text = "";
|
||||
} else {
|
||||
Location lastKnownLocation = locationProvider.getLastKnownLocation();
|
||||
if(!Algorithms.isEmpty(text) && lastKnownLocation != null) {
|
||||
if (!Algorithms.isEmpty(text) && lastKnownLocation != null) {
|
||||
double dist =
|
||||
CurrentPositionHelper.getOrthogonalDistance(rt, lastKnownLocation);
|
||||
if(dist < 50) {
|
||||
if (dist < 50) {
|
||||
showMarker = true;
|
||||
} else {
|
||||
text = map.getResources().getString(R.string.shared_string_near) + " " + text;
|
||||
|
|
Loading…
Reference in a new issue