Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
d0bee72aed
18 changed files with 796 additions and 763 deletions
|
@ -1,53 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="@dimen/dashboard_land_width"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/color_transparent"
|
||||
android:clickable="true">
|
||||
android:background="@android:color/transparent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/main_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:clickable="true"
|
||||
android:orientation="vertical"
|
||||
tools:background="@drawable/bg_bottom_menu_dark">
|
||||
android:layout_width="@dimen/dashboard_land_width"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/left_menu_view_bg"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/snap_to_road_progress_bar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/plan_route_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="0dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="@dimen/dashboard_map_toolbar"
|
||||
android:background="?attr/bg_color"
|
||||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
app:contentInsetLeft="54dp"
|
||||
app:contentInsetStart="54dp">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/up_down_row"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/measurement_tool_controls_height"
|
||||
android:layout_weight="0.5"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/up_down_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
|
||||
android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
|
||||
android:layout_marginRight="@dimen/bottom_sheet_content_margin"
|
||||
android:layout_marginStart="@dimen/bottom_sheet_content_margin"
|
||||
android:background="@null"
|
||||
tools:src="@drawable/ic_action_arrow_down"/>
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
@ -66,9 +48,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/measurement_tool_text_margin_small"
|
||||
android:layout_marginLeft="@dimen/measurement_tool_text_margin"
|
||||
android:layout_marginRight="@dimen/measurement_tool_text_margin_small"
|
||||
android:layout_marginStart="@dimen/measurement_tool_text_margin"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
|
@ -91,8 +71,6 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="@dimen/measurement_tool_text_margin"
|
||||
android:layout_marginStart="@dimen/measurement_tool_text_margin"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
|
@ -101,86 +79,47 @@
|
|||
</LinearLayout>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/select_all_button"
|
||||
android:id="@+id/options_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingEnd="@dimen/measurement_tool_text_button_padding_small"
|
||||
android:paddingLeft="@dimen/measurement_tool_text_button_padding"
|
||||
android:paddingRight="@dimen/measurement_tool_text_button_padding_small"
|
||||
android:paddingStart="@dimen/measurement_tool_text_button_padding"
|
||||
android:text="@string/shared_string_select_all"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:text="@string/shared_string_options"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
osmand:textAllCapsCompat="true"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/buttons_row"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/measurement_tool_controls_height"
|
||||
android:layout_weight="0.5">
|
||||
<ProgressBar
|
||||
android:id="@+id/snap_to_road_progress_bar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="0dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/sort_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_margin"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_margin">
|
||||
<FrameLayout
|
||||
android:id="@+id/markers_list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/ctx_menu_info_view_bg_dark">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sort_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@null"
|
||||
tools:src="@drawable/ic_action_list_sort"/>
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/markers_recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="@dimen/measurement_tool_button_margin"
|
||||
android:layout_marginStart="@dimen/measurement_tool_button_margin"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_sort"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
</LinearLayout>
|
||||
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/save_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:layout_marginEnd="@dimen/measurement_tool_button_margin"
|
||||
android:layout_marginRight="@dimen/measurement_tool_button_margin"
|
||||
android:background="@drawable/btn_round_blue"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:minHeight="@dimen/measurement_tool_button_height"
|
||||
android:text="@string/shared_string_save"
|
||||
android:textColor="@color/color_white"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
<include layout="@layout/card_bottom_divider"/>
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:osmand="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:osmand="http://schemas.android.com/tools"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.design.widget.AppBarLayout
|
||||
|
@ -15,42 +15,43 @@
|
|||
android:id="@+id/map_markers_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
app:contentInsetLeft="54dp"
|
||||
app:contentInsetStart="54dp">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical">
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:text="@string/map_markers"
|
||||
android:textColor="@color/color_white"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/dialog_header_text_size"/>
|
||||
android:textSize="@dimen/dialog_header_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/options_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:text="@string/shared_string_options"
|
||||
osmand:typeface="@string/font_roboto_regular"
|
||||
android:textAllCaps="true"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:textColor="@color/color_white"
|
||||
android:background="?attr/selectableItemBackground"/>
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_regular"/>
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
|
|
@ -113,18 +113,11 @@
|
|||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/markers_list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/measurement_tool_points_list_container_height"
|
||||
android:background="@color/ctx_menu_info_view_bg_dark"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
android:background="@color/ctx_menu_info_view_bg_dark">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/markers_recycler_view"
|
||||
|
@ -132,71 +125,8 @@
|
|||
android:layout_height="match_parent"/>
|
||||
|
||||
<include layout="@layout/card_bottom_divider"/>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="5dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:alpha="0.5"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/bg_shadow_onmap"/>
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/buttons_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/measurement_tool_controls_height">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/sort_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="@dimen/bottom_sheet_content_margin"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_margin">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/sort_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="@null"
|
||||
tools:src="@drawable/ic_action_list_sort"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="@dimen/measurement_tool_button_margin"
|
||||
android:layout_marginStart="@dimen/measurement_tool_button_margin"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:text="@string/shared_string_sort"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
</LinearLayout>
|
||||
|
||||
<Space
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/save_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:layout_marginEnd="@dimen/measurement_tool_button_margin"
|
||||
android:layout_marginRight="@dimen/measurement_tool_button_margin"
|
||||
android:background="@drawable/btn_round_blue"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:minHeight="@dimen/measurement_tool_button_height"
|
||||
android:text="@string/shared_string_save"
|
||||
android:textColor="@color/color_white"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
|
|
|
@ -32,6 +32,38 @@
|
|||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/select_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"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/select_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_select_all"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/select_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
tools:text="Select all"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/navigate_row"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -216,7 +248,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/shared_string_cancel"
|
||||
android:text="@string/shared_string_close"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
|
|
|
@ -1447,6 +1447,26 @@ public class GPXUtilities {
|
|||
((TrkSegment) parse).points.add(wptPt);
|
||||
parserState.push(wptPt);
|
||||
}
|
||||
if (parser.getName().equals("csvattributes")) {
|
||||
String segmentPoints = readText(parser, "csvattributes");
|
||||
String[] pointsArr = segmentPoints.split("\n");
|
||||
for (int i = 0; i < pointsArr.length; i++) {
|
||||
String[] pointAttrs = pointsArr[i].split(",");
|
||||
try {
|
||||
int arrLength = pointsArr.length;
|
||||
if (arrLength > 1) {
|
||||
WptPt wptPt = new WptPt();
|
||||
wptPt.lon = Double.parseDouble(pointAttrs[0]);
|
||||
wptPt.lat = Double.parseDouble(pointAttrs[1]);
|
||||
((TrkSegment) parse).points.add(wptPt);
|
||||
if (arrLength > 2) {
|
||||
wptPt.ele = Double.parseDouble(pointAttrs[2]);
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// main object to parse
|
||||
} else if (parse instanceof WptPt) {
|
||||
if (parser.getName().equals("name")) {
|
||||
|
|
|
@ -4,7 +4,6 @@ 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;
|
||||
|
@ -16,6 +15,7 @@ import net.osmand.plus.GPXUtilities.GPXFile;
|
|||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
|
||||
import net.osmand.plus.mapmarkers.MarkersPlanRouteContext;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
@ -28,7 +28,6 @@ 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;
|
||||
|
||||
|
@ -44,8 +43,7 @@ public class MapMarkersHelper {
|
|||
private MapMarkersDbHelper markersDbHelper;
|
||||
private boolean startFromMyLocation;
|
||||
|
||||
private final Map<Pair<WptPt, WptPt>, List<WptPt>> snappedToRoadPoints = new ConcurrentHashMap<>();
|
||||
private ApplicationMode snappedMode;
|
||||
private MarkersPlanRouteContext planRouteContext;
|
||||
|
||||
public interface MapMarkerChangedListener {
|
||||
void onMapMarkerChanged(MapMarker mapMarker);
|
||||
|
@ -230,22 +228,15 @@ public class MapMarkersHelper {
|
|||
this.ctx = ctx;
|
||||
settings = ctx.getSettings();
|
||||
markersDbHelper = ctx.getMapMarkersDbHelper();
|
||||
planRouteContext = new MarkersPlanRouteContext(ctx);
|
||||
startFromMyLocation = settings.ROUTE_MAP_MARKERS_START_MY_LOC.get();
|
||||
removeDisabledGroups();
|
||||
loadMarkers();
|
||||
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 MarkersPlanRouteContext getPlanRouteContext() {
|
||||
return planRouteContext;
|
||||
}
|
||||
|
||||
public boolean isStartFromMyLocation() {
|
||||
|
|
|
@ -11,7 +11,6 @@ import android.content.DialogInterface;
|
|||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Rect;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
|
@ -59,7 +58,6 @@ import net.osmand.plus.AppInitializer;
|
|||
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
||||
import net.osmand.plus.AppInitializer.InitEvents;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
|
||||
|
@ -315,6 +313,18 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
mIsDestroyed = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
FragmentManager fm = getSupportFragmentManager();
|
||||
Fragment planRouteFragment = fm.findFragmentByTag(PlanRouteFragment.TAG);
|
||||
if (planRouteFragment != null) {
|
||||
fm.beginTransaction()
|
||||
.remove(planRouteFragment)
|
||||
.commitNowAllowingStateLoss();
|
||||
app.getMapMarkersHelper().getPlanRouteContext().setFragmentShowed(true);
|
||||
}
|
||||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
private void checkAppInitialization() {
|
||||
if (app.isApplicationInitializing()) {
|
||||
|
@ -447,7 +457,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
private void changeKeyguardFlags() {
|
||||
if (settings.WAKE_ON_VOICE_INT.get() > 0) {
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED,
|
||||
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
||||
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
||||
} else {
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
||||
}
|
||||
|
@ -558,6 +568,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
super.onResume();
|
||||
long tm = System.currentTimeMillis();
|
||||
|
||||
if (app.getMapMarkersHelper().getPlanRouteContext().isFragmentShowed()) {
|
||||
PlanRouteFragment.showInstance(getSupportFragmentManager(), AndroidUiHelper.isOrientationPortrait(this));
|
||||
}
|
||||
|
||||
if (app.isApplicationInitializing() || DashboardOnMap.staticVisible) {
|
||||
if (!dashboardOnMap.isVisible()) {
|
||||
if (settings.SHOW_DASHBOARD_ON_START.get()) {
|
||||
|
@ -1321,7 +1335,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
Intent intent = getIntent();
|
||||
if (intent != null && intent.getData() != null) {
|
||||
Uri data = intent.getData();
|
||||
if (("http".equalsIgnoreCase(data.getScheme()) || "https".equalsIgnoreCase(data.getScheme()))&& data.getHost() != null && data.getHost().contains("osmand.net") &&
|
||||
if (("http".equalsIgnoreCase(data.getScheme()) || "https".equalsIgnoreCase(data.getScheme())) && data.getHost() != null && data.getHost().contains("osmand.net") &&
|
||||
data.getPath() != null && data.getPath().startsWith("/go")) {
|
||||
String lat = data.getQueryParameter("lat");
|
||||
String lon = data.getQueryParameter("lon");
|
||||
|
@ -1730,7 +1744,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
|
||||
public QuickSearchDialogFragment getQuickSearchDialogFragment() {
|
||||
Fragment fragment = getSupportFragmentManager().findFragmentByTag(QuickSearchDialogFragment.TAG);
|
||||
return fragment!= null && !fragment.isDetached() && !fragment.isRemoving() ? (QuickSearchDialogFragment) fragment : null;
|
||||
return fragment != null && !fragment.isDetached() && !fragment.isRemoving() ? (QuickSearchDialogFragment) fragment : null;
|
||||
}
|
||||
|
||||
public PlanRouteFragment getPlanRouteFragment() {
|
||||
|
|
|
@ -6,68 +6,69 @@
|
|||
http://opensource.org/licenses/gpl-2.0.php
|
||||
-->
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:kml="http://www.opengis.net/kml/2.2"
|
||||
xmlns:gx="http://www.google.com/kml/ext/2.2"
|
||||
<xsl:stylesheet xmlns:atom="http://www.w3.org/2005/Atom"
|
||||
xmlns:ge="http://earth.google.com/kml/2.2"
|
||||
|
||||
xmlns:atom="http://www.w3.org/2005/Atom"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
xmlns:gx="http://www.google.com/kml/ext/2.2"
|
||||
xmlns:kml="http://www.opengis.net/kml/2.2"
|
||||
|
||||
<xsl:output method="xml"
|
||||
indent="yes" />
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
version="1.0">
|
||||
|
||||
<xsl:output indent="yes"
|
||||
method="xml"/>
|
||||
|
||||
<xsl:template match="/">
|
||||
<gpx version="1.1"
|
||||
creator="kml2gpx.xslt"
|
||||
<gpx creator="kml2gpx.xslt"
|
||||
version="1.1"
|
||||
xmlns="http://www.topografix.com/GPX/1/1">
|
||||
<metadata>
|
||||
<name><xsl:value-of select="kml:kml/kml:Document/kml:name"/></name>
|
||||
<author>
|
||||
<name>
|
||||
<xsl:value-of select="kml:kml/kml:Document/atom:author/atom:author"/>
|
||||
</name>
|
||||
</author>
|
||||
</metadata>
|
||||
<xsl:for-each select="//ge:Placemark">
|
||||
<xsl:variable name="lonlat" select="ge:Point/ge:coordinates"/>
|
||||
<xsl:variable name="lon" select="substring-before($lonlat,' ')"/>
|
||||
<xsl:variable name="latele" select="substring-after($lonlat,' ')"/>
|
||||
<xsl:variable name="lat">
|
||||
<metadata>
|
||||
<name><xsl:value-of select="kml:kml/kml:Document/kml:name"/></name>
|
||||
<author>
|
||||
<name>
|
||||
<xsl:value-of select="kml:kml/kml:Document/atom:author/atom:author"/>
|
||||
</name>
|
||||
</author>
|
||||
</metadata>
|
||||
<xsl:for-each select="//ge:Placemark">
|
||||
<xsl:variable name="lonlat" select="ge:Point/ge:coordinates"/>
|
||||
<xsl:variable name="lon" select="substring-before($lonlat,' ')"/>
|
||||
<xsl:variable name="latele" select="substring-after($lonlat,' ')"/>
|
||||
<xsl:variable name="lat">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($latele,' ')">
|
||||
<xsl:value-of select="substring-before($latele,' ')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$latele"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="foldername" select="../ge:name"/>
|
||||
|
||||
<xsl:if test="$lon">
|
||||
<wpt lon="{$lon}" lat="{$lat}">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($latele,' ')">
|
||||
<xsl:value-of select="substring-before($latele,' ')"/>
|
||||
<xsl:when test="contains($latele,',')">
|
||||
<ele><xsl:value-of select="substring-after($latele,',')"/></ele>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$latele"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="foldername" select="../ge:name"/>
|
||||
|
||||
<xsl:if test="$lon">
|
||||
<wpt lon="{$lon}" lat="{$lat}">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($latele,',')">
|
||||
<ele> <xsl:value-of select="substring-after($latele,',')"/></ele>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<type>
|
||||
<xsl:value-of select="$foldername"/>
|
||||
</type>
|
||||
<name>
|
||||
<xsl:value-of select="ge:name"/>
|
||||
</name>
|
||||
<xsl:if test="ge:description">
|
||||
<desc>
|
||||
<xsl:value-of select="ge:description"/>
|
||||
</desc>
|
||||
</xsl:if>
|
||||
</wpt>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
<xsl:for-each select="//kml:Placemark">
|
||||
<xsl:variable name="lonlat" select="kml:Point/kml:coordinates"/>
|
||||
<type>
|
||||
<xsl:value-of select="$foldername"/>
|
||||
</type>
|
||||
<name>
|
||||
<xsl:value-of select="ge:name"/>
|
||||
</name>
|
||||
<xsl:if test="ge:description">
|
||||
<desc>
|
||||
<xsl:value-of select="ge:description"/>
|
||||
</desc>
|
||||
</xsl:if>
|
||||
</wpt>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
<xsl:for-each select="//kml:Placemark">
|
||||
<xsl:if test="kml:Point">
|
||||
<xsl:variable name="lonlat" select="kml:Point/kml:coordinates"/>
|
||||
<xsl:variable name="lon" select="substring-before($lonlat,',')"/>
|
||||
<xsl:variable name="latele" select="substring-after($lonlat,',')"/>
|
||||
<xsl:variable name="lat">
|
||||
|
@ -75,66 +76,76 @@
|
|||
<xsl:when test="contains($latele,',')">
|
||||
<xsl:value-of select="substring-before($latele,',')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$latele"/>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$latele"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="foldername" select="../kml:name"/>
|
||||
|
||||
<xsl:if test="$lon">
|
||||
<wpt lon="{$lon}" lat="{$lat}">
|
||||
<xsl:choose>
|
||||
|
||||
<xsl:if test="$lon">
|
||||
<wpt lon="{$lon}" lat="{$lat}">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($latele,',')">
|
||||
<ele> <xsl:value-of select="substring-after($latele,',')"/></ele>
|
||||
<ele><xsl:value-of select="substring-after($latele,',')"/></ele>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<type>
|
||||
<xsl:value-of select="$foldername"/>
|
||||
</type>
|
||||
<name>
|
||||
<xsl:value-of select="kml:name"/>
|
||||
</name>
|
||||
<xsl:if test="kml:description">
|
||||
<desc>
|
||||
<xsl:value-of select="kml:description"/>
|
||||
</desc>
|
||||
</xsl:if>
|
||||
</wpt>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
<xsl:for-each select="//gx:Track">
|
||||
<trk>
|
||||
<trkseg>
|
||||
<xsl:for-each select="gx:coord">
|
||||
<xsl:variable name="i" select="position()"/>
|
||||
<xsl:variable name="lonlat" select="."/>
|
||||
<xsl:variable name="lon" select="substring-before($lonlat,' ')"/>
|
||||
<xsl:variable name="latele" select="substring-after($lonlat,' ')"/>
|
||||
<xsl:variable name="lat">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($latele,' ')">
|
||||
<xsl:value-of select="substring-before($latele,' ')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$latele"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:value-of select="$foldername"/>
|
||||
</type>
|
||||
<name>
|
||||
<xsl:value-of select="kml:name"/>
|
||||
</name>
|
||||
<xsl:if test="kml:description">
|
||||
<desc>
|
||||
<xsl:value-of select="kml:description"/>
|
||||
</desc>
|
||||
</xsl:if>
|
||||
</wpt>
|
||||
</xsl:if>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="kml:MultiGeometry/kml:LineString/kml:coordinates">
|
||||
<trk>
|
||||
<trkseg>
|
||||
<csvattributes><xsl:value-of select="kml:MultiGeometry/kml:LineString/kml:coordinates"/></csvattributes>
|
||||
</trkseg>
|
||||
</trk>
|
||||
</xsl:if>
|
||||
|
||||
</xsl:for-each>
|
||||
<xsl:for-each select="//gx:Track">
|
||||
<trk>
|
||||
<trkseg>
|
||||
<xsl:for-each select="gx:coord">
|
||||
<xsl:variable name="i" select="position()"/>
|
||||
<xsl:variable name="lonlat" select="."/>
|
||||
<xsl:variable name="lon" select="substring-before($lonlat,' ')"/>
|
||||
<xsl:variable name="latele" select="substring-after($lonlat,' ')"/>
|
||||
<xsl:variable name="lat">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($latele,' ')">
|
||||
<xsl:value-of select="substring-before($latele,' ')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$latele"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<trkpt lon="{$lon}" lat="{$lat}">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($latele,' ')">
|
||||
<ele> <xsl:value-of select="substring-after($latele,' ')"/></ele>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:variable name="ts" select="../kml:when[$i]"/>
|
||||
<xsl:if test="$ts">
|
||||
<time><xsl:value-of select="$ts"/></time>
|
||||
</xsl:if>
|
||||
</trkpt>
|
||||
</xsl:for-each>
|
||||
</trkseg>
|
||||
</trk>
|
||||
<trkpt lon="{$lon}" lat="{$lat}">
|
||||
<xsl:choose>
|
||||
<xsl:when test="contains($latele,' ')">
|
||||
<ele><xsl:value-of select="substring-after($latele,' ')"/></ele>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
<xsl:variable name="ts" select="../kml:when[$i]"/>
|
||||
<xsl:if test="$ts">
|
||||
<time><xsl:value-of select="$ts"/></time>
|
||||
</xsl:if>
|
||||
</trkpt>
|
||||
</xsl:for-each>
|
||||
</trkseg>
|
||||
</trk>
|
||||
</xsl:for-each>
|
||||
</gpx>
|
||||
</xsl:template>
|
||||
|
@ -142,4 +153,4 @@
|
|||
<xsl:template match="gx:Track">
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
</xsl:stylesheet>
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.os.Bundle;
|
|||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -183,10 +182,10 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
|
|||
if (!portrait) {
|
||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
||||
>= AndroidUtils.dpToPx(getActivity(), 8)) {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
||||
} else {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends BottomSheetDialo
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
||||
boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
final boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
|
||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_history_bottom_sheet_dialog, container);
|
||||
|
@ -111,10 +111,10 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends BottomSheetDialo
|
|||
if (!portrait) {
|
||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
||||
>= AndroidUtils.dpToPx(getActivity(), 8)) {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
||||
} else {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import net.osmand.plus.OsmandSettings.MapMarkersOrderByMode;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.TrackActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener;
|
||||
import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener;
|
||||
import net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener;
|
||||
|
@ -209,7 +210,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
|
|||
|
||||
@Override
|
||||
public void buildRouteOnClick() {
|
||||
PlanRouteFragment.showInstance(mapActivity.getSupportFragmentManager());
|
||||
PlanRouteFragment.showInstance(mapActivity.getSupportFragmentManager(), AndroidUiHelper.isOrientationPortrait(mapActivity));
|
||||
dismiss();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,263 @@
|
|||
package net.osmand.plus.mapmarkers;
|
||||
|
||||
import android.util.Pair;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.routing.RouteCalculationParams;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
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.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
public class MarkersPlanRouteContext {
|
||||
|
||||
private static final int MAX_DIST_FOR_SNAP_TO_ROAD = 500 * 1000; // 500 km
|
||||
|
||||
private OsmandApplication app;
|
||||
|
||||
private final Map<Pair<WptPt, WptPt>, List<WptPt>> snappedToRoadPoints = new ConcurrentHashMap<>();
|
||||
private final Queue<Pair<WptPt, WptPt>> snapToRoadPairsToCalculate = new ConcurrentLinkedQueue<>();
|
||||
private final TrkSegment snapTrkSegment = new TrkSegment();
|
||||
|
||||
private ApplicationMode snappedMode;
|
||||
private RouteCalculationProgress calculationProgress;
|
||||
private int calculatedPairs;
|
||||
|
||||
private PlanRouteProgressListener listener;
|
||||
private boolean progressBarVisible;
|
||||
private boolean fragmentShowed;
|
||||
|
||||
Map<Pair<WptPt, WptPt>, List<WptPt>> getSnappedToRoadPoints() {
|
||||
return snappedToRoadPoints;
|
||||
}
|
||||
|
||||
TrkSegment getSnapTrkSegment() {
|
||||
return snapTrkSegment;
|
||||
}
|
||||
|
||||
ApplicationMode getSnappedMode() {
|
||||
return snappedMode;
|
||||
}
|
||||
|
||||
void setSnappedMode(ApplicationMode snappedMode) {
|
||||
this.snappedMode = snappedMode;
|
||||
}
|
||||
|
||||
public PlanRouteProgressListener getListener() {
|
||||
return listener;
|
||||
}
|
||||
|
||||
public void setListener(PlanRouteProgressListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
boolean isProgressBarVisible() {
|
||||
return progressBarVisible;
|
||||
}
|
||||
|
||||
void setProgressBarVisible(boolean progressBarVisible) {
|
||||
this.progressBarVisible = progressBarVisible;
|
||||
}
|
||||
|
||||
public boolean isFragmentShowed() {
|
||||
return fragmentShowed;
|
||||
}
|
||||
|
||||
public void setFragmentShowed(boolean fragmentShowed) {
|
||||
this.fragmentShowed = fragmentShowed;
|
||||
}
|
||||
|
||||
public MarkersPlanRouteContext(OsmandApplication app) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
void cancelSnapToRoad() {
|
||||
listener.hideProgressBar();
|
||||
snapToRoadPairsToCalculate.clear();
|
||||
if (calculationProgress != null) {
|
||||
calculationProgress.isCancelled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleRouteCalculateIfNotEmpty(List<WptPt> points) {
|
||||
if (points.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
findPairsToCalculate(points);
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (!snapToRoadPairsToCalculate.isEmpty() && !routingHelper.isRouteBeingCalculated()) {
|
||||
routingHelper.startRouteCalculationThread(getParams(), true, true);
|
||||
app.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
listener.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void recreateSnapTrkSegment() {
|
||||
recreateSnapTrkSegment(true);
|
||||
}
|
||||
|
||||
private void recreateSnapTrkSegment(boolean adjustMap) {
|
||||
snapTrkSegment.points.clear();
|
||||
List<WptPt> points = getPointsToCalculate();
|
||||
if (snappedMode == 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
listener.showMarkersRouteOnMap(adjustMap);
|
||||
app.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
listener.updateText();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<WptPt> getPointsToCalculate() {
|
||||
MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
||||
List<WptPt> points = new LinkedList<>();
|
||||
Location myLoc = app.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 RouteCalculationParams getParams() {
|
||||
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(), snappedMode);
|
||||
params.mode = snappedMode;
|
||||
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;
|
||||
}
|
||||
listener.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() {
|
||||
listener.refresh();
|
||||
}
|
||||
});
|
||||
if (!snapToRoadPairsToCalculate.isEmpty()) {
|
||||
app.getRoutingHelper().startRouteCalculationThread(getParams(), true, true);
|
||||
} else {
|
||||
app.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
listener.hideProgressBar();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
interface PlanRouteProgressListener {
|
||||
|
||||
void showProgressBar();
|
||||
|
||||
void updateProgress(int progress);
|
||||
|
||||
void hideProgressBar();
|
||||
|
||||
void refresh();
|
||||
|
||||
void updateText();
|
||||
|
||||
void showMarkersRouteOnMap(boolean adjustMap);
|
||||
}
|
||||
}
|
|
@ -39,7 +39,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
||||
boolean nightMode = !getMyApplication().getSettings().isLightContent();
|
||||
final boolean nightMode = !getMyApplication().getSettings().isLightContent();
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
|
||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_options_bottom_sheet_dialog, container);
|
||||
|
@ -157,10 +157,10 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
|
|||
if (!portrait) {
|
||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
||||
>= AndroidUtils.dpToPx(getActivity(), 8)) {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
||||
} else {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class OrderByBottomSheetDialogFragment extends BottomSheetDialogFragment
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
||||
settings = getMyApplication().getSettings();
|
||||
boolean night = !settings.isLightContent();
|
||||
final boolean night = !settings.isLightContent();
|
||||
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
|
||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_order_by_bottom_sheet_dialog, container);
|
||||
|
@ -99,10 +99,10 @@ public class OrderByBottomSheetDialogFragment extends BottomSheetDialogFragment
|
|||
if (!portrait) {
|
||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
||||
>= AndroidUtils.dpToPx(getActivity(), 8)) {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
||||
} else {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@ import android.support.v4.app.FragmentManager;
|
|||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||
import android.util.Pair;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -21,6 +21,7 @@ import android.view.ViewGroup;
|
|||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
@ -45,42 +46,34 @@ import net.osmand.plus.helpers.AndroidUiHelper;
|
|||
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 MarkersPlanRouteContext planRouteContext;
|
||||
|
||||
private MapMarkersListAdapter adapter;
|
||||
private IconsCache iconsCache;
|
||||
private PlanRouteToolbarController toolbarController;
|
||||
private ApplicationMode appMode;
|
||||
|
||||
private int previousMapPosition;
|
||||
private int selectedCount = 0;
|
||||
|
||||
private int toolbarHeight;
|
||||
private int closedListContainerHeight;
|
||||
|
||||
private boolean nightMode;
|
||||
private boolean portrait;
|
||||
|
@ -89,24 +82,46 @@ public class PlanRouteFragment extends Fragment {
|
|||
|
||||
private View mainView;
|
||||
private RecyclerView markersRv;
|
||||
private ImageView upDownIconIv;
|
||||
private TextView distanceTv;
|
||||
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();
|
||||
planRouteContext = markersHelper.getPlanRouteContext();
|
||||
planRouteContext.setListener(new MarkersPlanRouteContext.PlanRouteProgressListener() {
|
||||
@Override
|
||||
public void showProgressBar() {
|
||||
PlanRouteFragment.this.showProgressBar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgress(int progress) {
|
||||
((ProgressBar) mainView.findViewById(R.id.snap_to_road_progress_bar)).setProgress(progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideProgressBar() {
|
||||
mainView.findViewById(R.id.snap_to_road_progress_bar).setVisibility(View.GONE);
|
||||
planRouteContext.setProgressBarVisible(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
adapter.notifyDataSetChanged();
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateText() {
|
||||
PlanRouteFragment.this.updateText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMarkersRouteOnMap(boolean adjustMap) {
|
||||
PlanRouteFragment.this.showMarkersRouteOnMap(adjustMap);
|
||||
}
|
||||
});
|
||||
|
||||
// Handling screen rotation
|
||||
FragmentManager fragmentManager = mapActivity.getSupportFragmentManager();
|
||||
|
@ -114,14 +129,11 @@ public class PlanRouteFragment extends Fragment {
|
|||
if (snapToRoadFragment != null) {
|
||||
((SnapToRoadBottomSheetDialogFragment) snapToRoadFragment).setListener(createSnapToRoadFragmentListener());
|
||||
}
|
||||
Fragment sortByFragment = fragmentManager.findFragmentByTag(PlanRouteOptionsBottomSheetDialogFragment.TAG);
|
||||
if (sortByFragment != null) {
|
||||
((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.
|
||||
if (!portrait) {
|
||||
hideMarkersListFragment();
|
||||
Fragment optionsFragment = fragmentManager.findFragmentByTag(PlanRouteOptionsBottomSheetDialogFragment.TAG);
|
||||
if (optionsFragment != null) {
|
||||
PlanRouteOptionsBottomSheetDialogFragment fragment = (PlanRouteOptionsBottomSheetDialogFragment) optionsFragment;
|
||||
fragment.setSelectAll(!(selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()));
|
||||
fragment.setListener(createOptionsFragmentListener());
|
||||
}
|
||||
|
||||
toolbarHeight = mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar);
|
||||
|
@ -136,101 +148,106 @@ public class PlanRouteFragment extends Fragment {
|
|||
View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_plan_route, null);
|
||||
|
||||
mainView = view.findViewById(R.id.main_view);
|
||||
AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||
|
||||
distanceTv = (TextView) mainView.findViewById(R.id.markers_distance_text_view);
|
||||
timeTv = (TextView) mainView.findViewById(R.id.markers_time_text_view);
|
||||
countTv = (TextView) mainView.findViewById(R.id.markers_count_text_view);
|
||||
|
||||
enterPlanRouteMode();
|
||||
|
||||
View markersListContainer = mainView.findViewById(R.id.markers_list_container);
|
||||
if (portrait && markersListContainer != null) {
|
||||
if (markersListContainer != null) {
|
||||
markersListContainer.setBackgroundColor(backgroundColor);
|
||||
}
|
||||
|
||||
upDownIconIv = (ImageView) mainView.findViewById(R.id.up_down_icon);
|
||||
upDownIconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_up));
|
||||
((ImageView) mainView.findViewById(R.id.sort_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_list_sort));
|
||||
|
||||
mainView.findViewById(R.id.up_down_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (!markersListOpened) {
|
||||
showMarkersList();
|
||||
} else {
|
||||
hideMarkersList();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainView.findViewById(R.id.select_all_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int activeMarkersCount = markersHelper.getMapMarkers().size();
|
||||
if (selectedCount == activeMarkersCount && markersHelper.isStartFromMyLocation()) {
|
||||
markersHelper.deselectAllActiveMarkers();
|
||||
markersHelper.setStartFromMyLocation(false);
|
||||
selectedCount = 0;
|
||||
} else {
|
||||
markersHelper.selectAllActiveMarkers();
|
||||
markersHelper.setStartFromMyLocation(true);
|
||||
selectedCount = activeMarkersCount;
|
||||
}
|
||||
adapter.calculateStartAndFinishPos();
|
||||
adapter.notifyDataSetChanged();
|
||||
updateSelectButton();
|
||||
recreateSnapTrkSegment();
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
});
|
||||
|
||||
mainView.findViewById(R.id.sort_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Toast.makeText(mapActivity, "Sort", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
mainView.findViewById(R.id.save_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Toast.makeText(mapActivity, "Save", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
toolbarController = new PlanRouteToolbarController();
|
||||
toolbarController.setBackBtnIconIds(R.drawable.ic_action_mode_back, R.drawable.ic_action_mode_back);
|
||||
toolbarController.setTitle(getString(R.string.plan_route));
|
||||
toolbarController.setOnBackButtonClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (quit(false)) {
|
||||
MapMarkersDialogFragment.showInstance(mapActivity);
|
||||
}
|
||||
}
|
||||
});
|
||||
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) {
|
||||
markersRv = mainView.findViewById(R.id.markers_recycler_view);
|
||||
AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||
|
||||
((ImageView) mainView.findViewById(R.id.up_down_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_up));
|
||||
|
||||
mainView.findViewById(R.id.up_down_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (!markersListOpened) {
|
||||
showMarkersList();
|
||||
} else {
|
||||
hideMarkersList();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainView.findViewById(R.id.select_all_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
selectAllOnClick();
|
||||
updateSelectButton();
|
||||
}
|
||||
});
|
||||
|
||||
toolbarController = new PlanRouteToolbarController();
|
||||
toolbarController.setBackBtnIconIds(R.drawable.ic_action_mode_back, R.drawable.ic_action_mode_back);
|
||||
toolbarController.setTitle(getString(R.string.plan_route));
|
||||
toolbarController.setOnBackButtonClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (quit(false)) {
|
||||
MapMarkersDialogFragment.showInstance(mapActivity);
|
||||
}
|
||||
}
|
||||
});
|
||||
toolbarController.setSaveViewTextId(R.string.shared_string_options);
|
||||
toolbarController.setOnSaveViewClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
optionsOnClick();
|
||||
}
|
||||
});
|
||||
mapActivity.showTopToolbar(toolbarController);
|
||||
|
||||
final int screenH = AndroidUtils.getScreenHeight(mapActivity);
|
||||
final int statusBarH = AndroidUtils.getStatusBarHeight(mapActivity);
|
||||
final int navBarH = AndroidUtils.getNavBarHeight(mapActivity);
|
||||
final int availableHeight = (screenH - statusBarH - navBarH) / 2;
|
||||
|
||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
int upDownRowH = mainView.findViewById(R.id.up_down_row).getHeight();
|
||||
closedListContainerHeight = availableHeight - upDownRowH;
|
||||
View listContainer = mainView.findViewById(R.id.markers_list_container);
|
||||
listContainer.getLayoutParams().height = closedListContainerHeight;
|
||||
listContainer.requestLayout();
|
||||
|
||||
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
obs.removeOnGlobalLayoutListener(this);
|
||||
} else {
|
||||
obs.removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
markersRv = new RecyclerView(mapActivity);
|
||||
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.plan_route_toolbar);
|
||||
toolbar.setNavigationIcon(getContentIcon(R.drawable.ic_arrow_back));
|
||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (quit(false)) {
|
||||
MapMarkersDialogFragment.showInstance(mapActivity);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
optionsOnClick();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
markersRv = mainView.findViewById(R.id.markers_recycler_view);
|
||||
|
||||
adapter = new MapMarkersListAdapter(mapActivity);
|
||||
adapter.setHasStableIds(true);
|
||||
adapter.calculateStartAndFinishPos();
|
||||
adapter.setSnappedToRoadPoints(snappedToRoadPoints);
|
||||
adapter.setSnappedToRoadPoints(planRouteContext.getSnappedToRoadPoints());
|
||||
final ItemTouchHelper touchHelper = new ItemTouchHelper(new MapMarkersItemTouchHelperCallback(adapter));
|
||||
touchHelper.attachToRecyclerView(markersRv);
|
||||
adapter.setAdapterListener(new MapMarkersListAdapter.MapMarkersListAdapterListener() {
|
||||
|
@ -255,7 +272,7 @@ public class PlanRouteFragment extends Fragment {
|
|||
adapter.calculateStartAndFinishPos();
|
||||
adapter.notifyDataSetChanged();
|
||||
updateSelectButton();
|
||||
recreateSnapTrkSegment();
|
||||
planRouteContext.recreateSnapTrkSegment();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -278,7 +295,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
|
||||
}
|
||||
recreateSnapTrkSegment();
|
||||
planRouteContext.recreateSnapTrkSegment();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -287,48 +304,34 @@ public class PlanRouteFragment extends Fragment {
|
|||
markersRv.setClipToPadding(false);
|
||||
markersRv.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
markersRv.setAdapter(adapter);
|
||||
markersRv.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
}
|
||||
});
|
||||
|
||||
final int screenH = AndroidUtils.getScreenHeight(mapActivity);
|
||||
final int statusBarH = AndroidUtils.getStatusBarHeight(mapActivity);
|
||||
final int navBarH = AndroidUtils.getNavBarHeight(mapActivity);
|
||||
final int availableHeight = (screenH - statusBarH - navBarH) / 2;
|
||||
|
||||
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
if (portrait) {
|
||||
int upDownRowH = mainView.findViewById(R.id.up_down_row).getHeight();
|
||||
int buttonsRowH = mainView.findViewById(R.id.buttons_row).getHeight();
|
||||
int listContainerH = availableHeight - upDownRowH - buttonsRowH;
|
||||
View listContainer = mainView.findViewById(R.id.markers_list_container);
|
||||
listContainer.getLayoutParams().height = listContainerH;
|
||||
listContainer.requestLayout();
|
||||
}
|
||||
|
||||
showMarkersList();
|
||||
|
||||
ViewTreeObserver obs = mainView.getViewTreeObserver();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
obs.removeOnGlobalLayoutListener(this);
|
||||
} else {
|
||||
obs.removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (progressBarVisible) {
|
||||
if (planRouteContext.isProgressBarVisible()) {
|
||||
showProgressBar();
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void selectAllOnClick() {
|
||||
int activeMarkersCount = markersHelper.getMapMarkers().size();
|
||||
if (selectedCount == activeMarkersCount && markersHelper.isStartFromMyLocation()) {
|
||||
markersHelper.deselectAllActiveMarkers();
|
||||
markersHelper.setStartFromMyLocation(false);
|
||||
selectedCount = 0;
|
||||
} else {
|
||||
markersHelper.selectAllActiveMarkers();
|
||||
markersHelper.setStartFromMyLocation(true);
|
||||
selectedCount = activeMarkersCount;
|
||||
}
|
||||
adapter.calculateStartAndFinishPos();
|
||||
adapter.notifyDataSetChanged();
|
||||
planRouteContext.recreateSnapTrkSegment();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
@ -367,11 +370,10 @@ public class PlanRouteFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public void onApplicationModeItemClick(ApplicationMode mode) {
|
||||
if (appMode != null && appMode != mode) {
|
||||
appMode = mode;
|
||||
snappedToRoadPoints.clear();
|
||||
markersHelper.setSnappedMode(mode);
|
||||
recreateSnapTrkSegment();
|
||||
if (planRouteContext.getSnappedMode() != mode) {
|
||||
planRouteContext.getSnappedToRoadPoints().clear();
|
||||
planRouteContext.setSnappedMode(mode);
|
||||
planRouteContext.recreateSnapTrkSegment();
|
||||
setupAppModesBtn();
|
||||
}
|
||||
}
|
||||
|
@ -383,6 +385,11 @@ public class PlanRouteFragment extends Fragment {
|
|||
|
||||
private MapActivity mapActivity = getMapActivity();
|
||||
|
||||
@Override
|
||||
public void selectOnClick() {
|
||||
selectAllOnClick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigateOnClick() {
|
||||
if (mapActivity != null) {
|
||||
|
@ -393,7 +400,7 @@ public class PlanRouteFragment extends Fragment {
|
|||
@Override
|
||||
public void makeRoundTripOnClick() {
|
||||
if (mapActivity != null) {
|
||||
Toast.makeText(mapActivity, "mare round trip", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(mapActivity, "make round trip", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -415,12 +422,20 @@ public class PlanRouteFragment extends Fragment {
|
|||
markersHelper.reverseActiveMarkersOrder();
|
||||
adapter.calculateStartAndFinishPos();
|
||||
adapter.notifyDataSetChanged();
|
||||
recreateSnapTrkSegment();
|
||||
planRouteContext.recreateSnapTrkSegment();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
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);
|
||||
planRouteContext.setProgressBarVisible(true);
|
||||
}
|
||||
|
||||
private void enterPlanRouteMode() {
|
||||
final MapActivity mapActivity = getMapActivity();
|
||||
MapMarkersLayer markersLayer = getMapMarkersLayer();
|
||||
|
@ -448,13 +463,19 @@ public class PlanRouteFragment extends Fragment {
|
|||
wasCollapseButtonVisible = false;
|
||||
}
|
||||
|
||||
if ((appMode = markersHelper.getSnappedMode()) == null) {
|
||||
appMode = ApplicationMode.DEFAULT;
|
||||
if (planRouteContext.getSnappedMode() == null) {
|
||||
planRouteContext.setSnappedMode(ApplicationMode.DEFAULT);
|
||||
}
|
||||
setupAppModesBtn();
|
||||
|
||||
OsmandMapTileView tileView = mapActivity.getMapView();
|
||||
previousMapPosition = tileView.getMapPosition();
|
||||
if (!portrait) {
|
||||
tileView.setMapPosition(LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
|
||||
}
|
||||
|
||||
selectedCount = mapActivity.getMyApplication().getMapMarkersHelper().getSelectedMarkersCount();
|
||||
recreateSnapTrkSegment();
|
||||
planRouteContext.recreateSnapTrkSegment();
|
||||
mapActivity.refreshMap();
|
||||
updateSelectButton();
|
||||
}
|
||||
|
@ -462,10 +483,10 @@ public class PlanRouteFragment extends Fragment {
|
|||
|
||||
private void setupAppModesBtn() {
|
||||
final MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null && appMode != null) {
|
||||
if (mapActivity != null) {
|
||||
final ImageButton appModesBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
|
||||
appModesBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle);
|
||||
appModesBtn.setImageDrawable(getActiveIcon(appMode.getSmallIconDark()));
|
||||
appModesBtn.setImageDrawable(getActiveIcon(planRouteContext.getSnappedMode().getSmallIconDark()));
|
||||
appModesBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -475,6 +496,11 @@ public class PlanRouteFragment extends Fragment {
|
|||
fragment.show(mapActivity.getSupportFragmentManager(), SnapToRoadBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
});
|
||||
if (!portrait) {
|
||||
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) appModesBtn.getLayoutParams();
|
||||
params.leftMargin = mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_land_width);
|
||||
appModesBtn.setLayoutParams(params);
|
||||
}
|
||||
appModesBtn.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
@ -508,15 +534,33 @@ 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);
|
||||
|
||||
cancelSnapToRoad();
|
||||
mapActivity.getMapView().setMapPosition(previousMapPosition);
|
||||
|
||||
planRouteContext.cancelSnapToRoad();
|
||||
markersLayer.setRoute(null);
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
private void optionsOnClick() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
PlanRouteOptionsBottomSheetDialogFragment fragment = new PlanRouteOptionsBottomSheetDialogFragment();
|
||||
fragment.setSelectAll(!(selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()));
|
||||
fragment.setListener(createOptionsFragmentListener());
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), PlanRouteOptionsBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateText() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
TextView distanceTv = (TextView) mainView.findViewById(R.id.markers_distance_text_view);
|
||||
TextView timeTv = (TextView) mainView.findViewById(R.id.markers_time_text_view);
|
||||
TextView countTv = (TextView) mainView.findViewById(R.id.markers_count_text_view);
|
||||
|
||||
ApplicationMode appMode = planRouteContext.getSnappedMode();
|
||||
TrkSegment snapTrkSegment = planRouteContext.getSnapTrkSegment();
|
||||
boolean defaultMode = appMode == ApplicationMode.DEFAULT;
|
||||
|
||||
float dist = 0;
|
||||
|
@ -539,10 +583,12 @@ public class PlanRouteFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void updateSelectButton() {
|
||||
if (selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()) {
|
||||
((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_deselect_all));
|
||||
} else {
|
||||
((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_select_all));
|
||||
if (portrait) {
|
||||
if (selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()) {
|
||||
((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_deselect_all));
|
||||
} else {
|
||||
((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_select_all));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -558,70 +604,29 @@ public class PlanRouteFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
//todo create one method
|
||||
private void showMarkersList() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
MapMarkersLayer markersLayer = getMapMarkersLayer();
|
||||
if (mapActivity != null && markersLayer != null) {
|
||||
if (mapActivity != null && portrait) {
|
||||
markersListOpened = true;
|
||||
upDownIconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_down));
|
||||
mapActivity.findViewById(R.id.bottom_controls_container).setVisibility(View.GONE);
|
||||
((ImageView) mainView.findViewById(R.id.up_down_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_down));
|
||||
View listContainer = mainView.findViewById(R.id.markers_list_container);
|
||||
if (portrait && listContainer != null) {
|
||||
listContainer.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
showMarkersListFragment();
|
||||
if (listContainer != null) {
|
||||
listContainer.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
}
|
||||
OsmandMapTileView tileView = mapActivity.getMapView();
|
||||
previousMapPosition = tileView.getMapPosition();
|
||||
if (!portrait) {
|
||||
tileView.setMapPosition(LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
|
||||
}
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
private void hideMarkersList() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
MapMarkersLayer markersLayer = getMapMarkersLayer();
|
||||
if (mapActivity != null && markersLayer != null) {
|
||||
if (mapActivity != null && portrait) {
|
||||
markersListOpened = false;
|
||||
upDownIconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_up));
|
||||
mapActivity.findViewById(R.id.bottom_controls_container).setVisibility(View.VISIBLE);
|
||||
((ImageView) mainView.findViewById(R.id.up_down_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_up));
|
||||
View listContainer = mainView.findViewById(R.id.markers_list_container);
|
||||
if (portrait && listContainer != null) {
|
||||
listContainer.setVisibility(View.GONE);
|
||||
} else {
|
||||
hideMarkersListFragment();
|
||||
}
|
||||
mapActivity.getMapView().setMapPosition(previousMapPosition);
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
private void showMarkersListFragment() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
View upDownRow = mainView.findViewById(R.id.up_down_row);
|
||||
int screenHeight = AndroidUtils.getScreenHeight(mapActivity) - AndroidUtils.getStatusBarHeight(mapActivity);
|
||||
RecyclerViewFragment fragment = new RecyclerViewFragment();
|
||||
fragment.setRecyclerView(markersRv);
|
||||
fragment.setWidth(upDownRow.getWidth());
|
||||
fragment.setHeight(screenHeight - upDownRow.getHeight());
|
||||
mapActivity.getSupportFragmentManager().beginTransaction()
|
||||
.add(R.id.fragmentContainer, fragment, RecyclerViewFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
}
|
||||
}
|
||||
|
||||
private void hideMarkersListFragment() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
try {
|
||||
FragmentManager manager = mapActivity.getSupportFragmentManager();
|
||||
Fragment fragment = manager.findFragmentByTag(RecyclerViewFragment.TAG);
|
||||
if (fragment != null) {
|
||||
manager.beginTransaction().remove(fragment).commitNowAllowingStateLoss();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignore
|
||||
if (listContainer != null) {
|
||||
listContainer.getLayoutParams().height = closedListContainerHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -629,9 +634,9 @@ public class PlanRouteFragment extends Fragment {
|
|||
private void showMarkersRouteOnMap(boolean adjustMap) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.getMapLayers().getMapMarkersLayer().setRoute(snapTrkSegment);
|
||||
mapActivity.getMapLayers().getMapMarkersLayer().setRoute(planRouteContext.getSnapTrkSegment());
|
||||
if (adjustMap) {
|
||||
showRouteOnMap(snapTrkSegment.points);
|
||||
showRouteOnMap(planRouteContext.getSnapTrkSegment().points);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -670,14 +675,14 @@ public class PlanRouteFragment extends Fragment {
|
|||
if (portrait) {
|
||||
tileBoxHeightPx = 3 * (tb.getPixHeight() - mainView.getHeight() - toolbarHeight) / 4;
|
||||
} else {
|
||||
tileBoxWidthPx = tb.getPixWidth() - mainView.findViewById(R.id.up_down_row).getWidth();
|
||||
tileBoxWidthPx = tb.getPixWidth() - mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_land_width);
|
||||
}
|
||||
mapView.fitRectToMap(left, right, top, bottom, tileBoxWidthPx, tileBoxHeightPx, toolbarHeight * 3 / 2);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean quit(boolean hideMarkersListFirst) {
|
||||
if (markersListOpened && hideMarkersListFirst) {
|
||||
if (portrait && markersListOpened && hideMarkersListFirst) {
|
||||
hideMarkersList();
|
||||
return false;
|
||||
} else {
|
||||
|
@ -687,18 +692,19 @@ public class PlanRouteFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void dismiss(MapActivity activity) {
|
||||
if (markersListOpened) {
|
||||
if (portrait && markersListOpened) {
|
||||
hideMarkersList();
|
||||
}
|
||||
planRouteContext.setFragmentShowed(false);
|
||||
activity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
|
||||
}
|
||||
|
||||
public static boolean showInstance(FragmentManager fragmentManager) {
|
||||
public static boolean showInstance(FragmentManager fragmentManager, boolean portrait) {
|
||||
try {
|
||||
PlanRouteFragment fragment = new PlanRouteFragment();
|
||||
fragment.setRetainInstance(true);
|
||||
fragmentManager.beginTransaction()
|
||||
.add(R.id.bottomFragmentContainer, fragment, PlanRouteFragment.TAG)
|
||||
.add(portrait ? R.id.bottomFragmentContainer : R.id.topFragmentContainer, fragment, PlanRouteFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
|
@ -764,204 +770,11 @@ public class PlanRouteFragment extends Fragment {
|
|||
mapActivity.getMyApplication().getMapMarkersHelper().addSelectedMarkersToTop(res);
|
||||
adapter.calculateStartAndFinishPos();
|
||||
adapter.notifyDataSetChanged();
|
||||
recreateSnapTrkSegment();
|
||||
planRouteContext.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() {
|
||||
|
|
|
@ -28,11 +28,16 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog
|
|||
private boolean portrait;
|
||||
private boolean night;
|
||||
private PlanRouteOptionsFragmentListener listener;
|
||||
private boolean selectAll;
|
||||
|
||||
public void setListener(PlanRouteOptionsFragmentListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void setSelectAll(boolean selectAll) {
|
||||
this.selectAll = selectAll;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
@ -54,6 +59,23 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog
|
|||
((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));
|
||||
|
||||
if (!portrait) {
|
||||
((ImageView) mainView.findViewById(R.id.select_icon))
|
||||
.setImageDrawable(getContentIcon(selectAll ? R.drawable.ic_action_select_all : R.drawable.ic_action_deselect_all));
|
||||
|
||||
((TextView) mainView.findViewById(R.id.select_title))
|
||||
.setText(getString(selectAll ? R.string.shared_string_select_all : R.string.shared_string_deselect_all));
|
||||
|
||||
View selectRow = mainView.findViewById(R.id.select_row);
|
||||
selectRow.setVisibility(View.VISIBLE);
|
||||
selectRow.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
listener.selectOnClick();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
mainView.findViewById(R.id.navigate_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -117,10 +139,10 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog
|
|||
|
||||
if (!portrait) {
|
||||
if (screenHeight - statusBarHeight - mainView.getHeight() >= AndroidUtils.dpToPx(getActivity(), 8)) {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
||||
} else {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
||||
}
|
||||
}
|
||||
|
@ -155,6 +177,8 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog
|
|||
|
||||
interface PlanRouteOptionsFragmentListener {
|
||||
|
||||
void selectOnClick();
|
||||
|
||||
void navigateOnClick();
|
||||
|
||||
void makeRoundTripOnClick();
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.Log;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -25,11 +24,7 @@ import net.osmand.plus.base.BottomSheetDialogFragment;
|
|||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
|
||||
|
||||
import static net.osmand.plus.helpers.GpxImportHelper.GPX_SUFFIX;
|
||||
|
||||
|
@ -49,7 +44,7 @@ public class SaveAsTrackBottomSheetDialogFragment extends BottomSheetDialogFragm
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
MapActivity mapActivity = (MapActivity) getActivity();
|
||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
||||
boolean nightMode = !getMyApplication().getSettings().isLightContent();
|
||||
final boolean nightMode = !getMyApplication().getSettings().isLightContent();
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
|
||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_save_as_track_bottom_sheet_dialog, container);
|
||||
|
@ -126,10 +121,10 @@ public class SaveAsTrackBottomSheetDialogFragment extends BottomSheetDialogFragm
|
|||
if (!portrait) {
|
||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
||||
>= AndroidUtils.dpToPx(getActivity(), 8)) {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
||||
} else {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
AndroidUtils.setBackground(getActivity(), mainView, nightMode,
|
||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,10 +160,10 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
|
|||
if (!portrait) {
|
||||
if (screenHeight - statusBarHeight - mainView.getHeight()
|
||||
>= AndroidUtils.dpToPx(getActivity(), 8)) {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
||||
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
|
||||
} else {
|
||||
AndroidUtils.setBackground(getActivity(), mainView, false,
|
||||
AndroidUtils.setBackground(getActivity(), mainView, night,
|
||||
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue