Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-10-06 17:53:08 +02:00
commit d0bee72aed
18 changed files with 796 additions and 763 deletions

View file

@ -1,53 +1,35 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" 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:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" 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:layout_height="match_parent"
android:background="@color/color_transparent" android:background="@android:color/transparent"
android:clickable="true"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/main_view" android:id="@+id/main_view"
android:layout_width="match_parent" android:layout_width="@dimen/dashboard_land_width"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_gravity="bottom" android:background="?attr/left_menu_view_bg"
android:clickable="true" android:orientation="vertical">
android:orientation="vertical"
tools:background="@drawable/bg_bottom_menu_dark">
<ProgressBar <android.support.v7.widget.Toolbar
android:id="@+id/snap_to_road_progress_bar" android:id="@+id/plan_route_toolbar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="@dimen/dashboard_map_toolbar"
android:minHeight="0dp" android:background="?attr/bg_color"
android:visibility="gone" android:minHeight="@dimen/dashboard_map_toolbar"
tools:visibility="visible"/> app:contentInsetLeft="54dp"
app:contentInsetStart="54dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout <LinearLayout
android:id="@+id/up_down_row" android:layout_width="match_parent"
android:layout_width="0dp" android:layout_height="match_parent"
android:layout_height="@dimen/measurement_tool_controls_height" android:gravity="center_vertical"
android:layout_weight="0.5" android:orientation="horizontal">
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"/>
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
@ -66,9 +48,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/measurement_tool_text_margin_small" 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_marginRight="@dimen/measurement_tool_text_margin_small"
android:layout_marginStart="@dimen/measurement_tool_text_margin"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle" android:textAppearance="@style/TextAppearance.ListItemTitle"
@ -91,8 +71,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" 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:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
@ -101,86 +79,47 @@
</LinearLayout> </LinearLayout>
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/select_all_button" android:id="@+id/options_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center_vertical" android:gravity="center_vertical"
android:maxLines="1" android:maxLines="1"
android:paddingEnd="@dimen/measurement_tool_text_button_padding_small" android:paddingLeft="16dp"
android:paddingLeft="@dimen/measurement_tool_text_button_padding" android:paddingRight="16dp"
android:paddingRight="@dimen/measurement_tool_text_button_padding_small" android:text="@string/shared_string_options"
android:paddingStart="@dimen/measurement_tool_text_button_padding" android:textAllCaps="true"
android:text="@string/shared_string_select_all"
android:textColor="?attr/color_dialog_buttons" android:textColor="?attr/color_dialog_buttons"
osmand:textAllCapsCompat="true" android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"/> osmand:typeface="@string/font_roboto_medium"/>
</LinearLayout> </LinearLayout>
<View </android.support.v7.widget.Toolbar>
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/>
<LinearLayout <ProgressBar
android:id="@+id/buttons_row" android:id="@+id/snap_to_road_progress_bar"
android:layout_width="0dp" style="?android:attr/progressBarStyleHorizontal"
android:layout_height="@dimen/measurement_tool_controls_height" android:layout_width="match_parent"
android:layout_weight="0.5"> android:layout_height="wrap_content"
android:minHeight="0dp"
android:visibility="gone"
tools:visibility="visible"/>
<LinearLayout <FrameLayout
android:id="@+id/sort_button" android:id="@+id/markers_list_container"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/selectableItemBackground" android:background="@color/ctx_menu_info_view_bg_dark">
android:paddingLeft="@dimen/bottom_sheet_content_margin"
android:paddingRight="@dimen/bottom_sheet_content_margin">
<ImageView <android.support.v7.widget.RecyclerView
android:id="@+id/sort_icon" android:id="@+id/markers_recycler_view"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"/>
android:layout_gravity="center_vertical"
android:background="@null"
tools:src="@drawable/ic_action_list_sort"/>
<net.osmand.plus.widgets.TextViewEx <include layout="@layout/card_bottom_divider"/>
android:layout_width="wrap_content" </FrameLayout>
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>
</LinearLayout> </LinearLayout>
</FrameLayout> </LinearLayout>

View file

@ -2,9 +2,9 @@
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:osmand="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:osmand="http://schemas.android.com/tools"
android:orientation="vertical"> android:orientation="vertical">
<android.support.design.widget.AppBarLayout <android.support.design.widget.AppBarLayout
@ -15,42 +15,43 @@
android:id="@+id/map_markers_toolbar" android:id="@+id/map_markers_toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:minHeight="@dimen/dashboard_map_toolbar"
app:contentInsetLeft="54dp" app:contentInsetLeft="54dp"
app:contentInsetStart="54dp"> app:contentInsetStart="54dp">
<LinearLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical"> android:gravity="center_vertical"
android:orientation="horizontal">
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1"
android:gravity="center_vertical" android:gravity="center_vertical"
android:maxLines="1"
android:text="@string/map_markers" android:text="@string/map_markers"
android:textColor="@color/color_white" 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 <net.osmand.plus.widgets.TextViewEx
android:id="@+id/options_button" android:id="@+id/options_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical" android:background="?attr/selectableItemBackground"
android:ellipsize="end" android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1" android:maxLines="1"
android:paddingRight="16dp"
android:paddingLeft="16dp" android:paddingLeft="16dp"
android:paddingRight="16dp"
android:text="@string/shared_string_options" android:text="@string/shared_string_options"
osmand:typeface="@string/font_roboto_regular"
android:textAllCaps="true" android:textAllCaps="true"
android:textSize="@dimen/default_list_text_size"
android:textColor="@color/color_white" android:textColor="@color/color_white"
android:background="?attr/selectableItemBackground"/> android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_regular"/>
</LinearLayout> </LinearLayout>
</android.support.v7.widget.Toolbar> </android.support.v7.widget.Toolbar>

View file

@ -113,18 +113,11 @@
osmand:typeface="@string/font_roboto_medium"/> osmand:typeface="@string/font_roboto_medium"/>
</LinearLayout> </LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout <FrameLayout
android:id="@+id/markers_list_container" android:id="@+id/markers_list_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_points_list_container_height" android:layout_height="@dimen/measurement_tool_points_list_container_height"
android:background="@color/ctx_menu_info_view_bg_dark" android:background="@color/ctx_menu_info_view_bg_dark">
android:visibility="gone"
tools:visibility="visible">
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/markers_recycler_view" android:id="@+id/markers_recycler_view"
@ -132,71 +125,8 @@
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
<include layout="@layout/card_bottom_divider"/> <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> </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> </LinearLayout>
</FrameLayout> </FrameLayout>

View file

@ -32,6 +32,38 @@
android:textAppearance="@style/TextAppearance.ListItemTitle" android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/> 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 <LinearLayout
android:id="@+id/navigate_row" android:id="@+id/navigate_row"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -216,7 +248,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:text="@string/shared_string_cancel" android:text="@string/shared_string_close"
android:textAllCaps="true" android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons" android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"

View file

@ -1447,6 +1447,26 @@ public class GPXUtilities {
((TrkSegment) parse).points.add(wptPt); ((TrkSegment) parse).points.add(wptPt);
parserState.push(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 // main object to parse
} else if (parse instanceof WptPt) { } else if (parse instanceof WptPt) {
if (parser.getName().equals("name")) { if (parser.getName().equals("name")) {

View file

@ -4,7 +4,6 @@ import android.content.Context;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.util.Pair;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.data.FavouritePoint; 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.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.mapmarkers.MapMarkersDbHelper; import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
import net.osmand.plus.mapmarkers.MarkersPlanRouteContext;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
@ -28,7 +28,6 @@ import java.util.LinkedHashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import static net.osmand.data.PointDescription.POINT_TYPE_MAP_MARKER; import static net.osmand.data.PointDescription.POINT_TYPE_MAP_MARKER;
@ -44,8 +43,7 @@ public class MapMarkersHelper {
private MapMarkersDbHelper markersDbHelper; private MapMarkersDbHelper markersDbHelper;
private boolean startFromMyLocation; private boolean startFromMyLocation;
private final Map<Pair<WptPt, WptPt>, List<WptPt>> snappedToRoadPoints = new ConcurrentHashMap<>(); private MarkersPlanRouteContext planRouteContext;
private ApplicationMode snappedMode;
public interface MapMarkerChangedListener { public interface MapMarkerChangedListener {
void onMapMarkerChanged(MapMarker mapMarker); void onMapMarkerChanged(MapMarker mapMarker);
@ -230,22 +228,15 @@ public class MapMarkersHelper {
this.ctx = ctx; this.ctx = ctx;
settings = ctx.getSettings(); settings = ctx.getSettings();
markersDbHelper = ctx.getMapMarkersDbHelper(); markersDbHelper = ctx.getMapMarkersDbHelper();
planRouteContext = new MarkersPlanRouteContext(ctx);
startFromMyLocation = settings.ROUTE_MAP_MARKERS_START_MY_LOC.get(); startFromMyLocation = settings.ROUTE_MAP_MARKERS_START_MY_LOC.get();
removeDisabledGroups(); removeDisabledGroups();
loadMarkers(); loadMarkers();
createMapMarkersGroups(); createMapMarkersGroups();
} }
public Map<Pair<WptPt, WptPt>, List<WptPt>> getSnappedToRoadPoints() { public MarkersPlanRouteContext getPlanRouteContext() {
return snappedToRoadPoints; return planRouteContext;
}
public ApplicationMode getSnappedMode() {
return snappedMode;
}
public void setSnappedMode(ApplicationMode snappedMode) {
this.snappedMode = snappedMode;
} }
public boolean isStartFromMyLocation() { public boolean isStartFromMyLocation() {

View file

@ -11,7 +11,6 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.Rect;
import android.media.AudioManager; import android.media.AudioManager;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
@ -59,7 +58,6 @@ import net.osmand.plus.AppInitializer;
import net.osmand.plus.AppInitializer.AppInitializeListener; import net.osmand.plus.AppInitializer.AppInitializeListener;
import net.osmand.plus.AppInitializer.InitEvents; import net.osmand.plus.AppInitializer.InitEvents;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener; import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener;
@ -315,6 +313,18 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
mIsDestroyed = false; 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() { private void checkAppInitialization() {
if (app.isApplicationInitializing()) { if (app.isApplicationInitializing()) {
@ -447,7 +457,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
private void changeKeyguardFlags() { private void changeKeyguardFlags() {
if (settings.WAKE_ON_VOICE_INT.get() > 0) { if (settings.WAKE_ON_VOICE_INT.get() > 0) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED, 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 { } else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); 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(); super.onResume();
long tm = System.currentTimeMillis(); long tm = System.currentTimeMillis();
if (app.getMapMarkersHelper().getPlanRouteContext().isFragmentShowed()) {
PlanRouteFragment.showInstance(getSupportFragmentManager(), AndroidUiHelper.isOrientationPortrait(this));
}
if (app.isApplicationInitializing() || DashboardOnMap.staticVisible) { if (app.isApplicationInitializing() || DashboardOnMap.staticVisible) {
if (!dashboardOnMap.isVisible()) { if (!dashboardOnMap.isVisible()) {
if (settings.SHOW_DASHBOARD_ON_START.get()) { if (settings.SHOW_DASHBOARD_ON_START.get()) {
@ -1321,7 +1335,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
Intent intent = getIntent(); Intent intent = getIntent();
if (intent != null && intent.getData() != null) { if (intent != null && intent.getData() != null) {
Uri data = intent.getData(); 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")) { data.getPath() != null && data.getPath().startsWith("/go")) {
String lat = data.getQueryParameter("lat"); String lat = data.getQueryParameter("lat");
String lon = data.getQueryParameter("lon"); String lon = data.getQueryParameter("lon");
@ -1730,7 +1744,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
public QuickSearchDialogFragment getQuickSearchDialogFragment() { public QuickSearchDialogFragment getQuickSearchDialogFragment() {
Fragment fragment = getSupportFragmentManager().findFragmentByTag(QuickSearchDialogFragment.TAG); 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() { public PlanRouteFragment getPlanRouteFragment() {

View file

@ -6,68 +6,69 @@
http://opensource.org/licenses/gpl-2.0.php http://opensource.org/licenses/gpl-2.0.php
--> -->
<xsl:stylesheet version="1.0" <xsl:stylesheet xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:kml="http://www.opengis.net/kml/2.2"
xmlns:gx="http://www.google.com/kml/ext/2.2"
xmlns:ge="http://earth.google.com/kml/2.2" xmlns:ge="http://earth.google.com/kml/2.2"
xmlns:gx="http://www.google.com/kml/ext/2.2"
xmlns:atom="http://www.w3.org/2005/Atom" xmlns:kml="http://www.opengis.net/kml/2.2"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
indent="yes" /> version="1.0">
<xsl:output indent="yes"
method="xml"/>
<xsl:template match="/"> <xsl:template match="/">
<gpx version="1.1" <gpx creator="kml2gpx.xslt"
creator="kml2gpx.xslt" version="1.1"
xmlns="http://www.topografix.com/GPX/1/1"> xmlns="http://www.topografix.com/GPX/1/1">
<metadata> <metadata>
<name><xsl:value-of select="kml:kml/kml:Document/kml:name"/></name> <name><xsl:value-of select="kml:kml/kml:Document/kml:name"/></name>
<author> <author>
<name> <name>
<xsl:value-of select="kml:kml/kml:Document/atom:author/atom:author"/> <xsl:value-of select="kml:kml/kml:Document/atom:author/atom:author"/>
</name> </name>
</author> </author>
</metadata> </metadata>
<xsl:for-each select="//ge:Placemark"> <xsl:for-each select="//ge:Placemark">
<xsl:variable name="lonlat" select="ge:Point/ge:coordinates"/> <xsl:variable name="lonlat" select="ge:Point/ge:coordinates"/>
<xsl:variable name="lon" select="substring-before($lonlat,' ')"/> <xsl:variable name="lon" select="substring-before($lonlat,' ')"/>
<xsl:variable name="latele" select="substring-after($lonlat,' ')"/> <xsl:variable name="latele" select="substring-after($lonlat,' ')"/>
<xsl:variable name="lat"> <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:choose>
<xsl:when test="contains($latele,' ')"> <xsl:when test="contains($latele,',')">
<xsl:value-of select="substring-before($latele,' ')"/> <ele><xsl:value-of select="substring-after($latele,',')"/></ele>
</xsl:when> </xsl:when>
<xsl:otherwise>
<xsl:value-of select="$latele"/>
</xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:variable> <type>
<xsl:variable name="foldername" select="../ge:name"/> <xsl:value-of select="$foldername"/>
</type>
<xsl:if test="$lon"> <name>
<wpt lon="{$lon}" lat="{$lat}"> <xsl:value-of select="ge:name"/>
<xsl:choose> </name>
<xsl:when test="contains($latele,',')"> <xsl:if test="ge:description">
<ele> <xsl:value-of select="substring-after($latele,',')"/></ele> <desc>
</xsl:when> <xsl:value-of select="ge:description"/>
</xsl:choose> </desc>
<type> </xsl:if>
<xsl:value-of select="$foldername"/> </wpt>
</type> </xsl:if>
<name> </xsl:for-each>
<xsl:value-of select="ge:name"/> <xsl:for-each select="//kml:Placemark">
</name> <xsl:if test="kml:Point">
<xsl:if test="ge:description"> <xsl:variable name="lonlat" select="kml:Point/kml:coordinates"/>
<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"/>
<xsl:variable name="lon" select="substring-before($lonlat,',')"/> <xsl:variable name="lon" select="substring-before($lonlat,',')"/>
<xsl:variable name="latele" select="substring-after($lonlat,',')"/> <xsl:variable name="latele" select="substring-after($lonlat,',')"/>
<xsl:variable name="lat"> <xsl:variable name="lat">
@ -75,66 +76,76 @@
<xsl:when test="contains($latele,',')"> <xsl:when test="contains($latele,',')">
<xsl:value-of select="substring-before($latele,',')"/> <xsl:value-of select="substring-before($latele,',')"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="$latele"/> <xsl:value-of select="$latele"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:variable>
<xsl:variable name="foldername" select="../kml:name"/> <xsl:variable name="foldername" select="../kml:name"/>
<xsl:if test="$lon"> <xsl:if test="$lon">
<wpt lon="{$lon}" lat="{$lat}"> <wpt lon="{$lon}" lat="{$lat}">
<xsl:choose> <xsl:choose>
<xsl:when test="contains($latele,',')"> <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:when>
</xsl:choose> </xsl:choose>
<type> <type>
<xsl:value-of select="$foldername"/> <xsl:value-of select="$foldername"/>
</type> </type>
<name> <name>
<xsl:value-of select="kml:name"/> <xsl:value-of select="kml:name"/>
</name> </name>
<xsl:if test="kml:description"> <xsl:if test="kml:description">
<desc> <desc>
<xsl:value-of select="kml:description"/> <xsl:value-of select="kml:description"/>
</desc> </desc>
</xsl:if> </xsl:if>
</wpt> </wpt>
</xsl:if> </xsl:if>
</xsl:for-each> </xsl:if>
<xsl:for-each select="//gx:Track">
<trk> <xsl:if test="kml:MultiGeometry/kml:LineString/kml:coordinates">
<trkseg> <trk>
<xsl:for-each select="gx:coord"> <trkseg>
<xsl:variable name="i" select="position()"/> <csvattributes><xsl:value-of select="kml:MultiGeometry/kml:LineString/kml:coordinates"/></csvattributes>
<xsl:variable name="lonlat" select="."/> </trkseg>
<xsl:variable name="lon" select="substring-before($lonlat,' ')"/> </trk>
<xsl:variable name="latele" select="substring-after($lonlat,' ')"/> </xsl:if>
<xsl:variable name="lat">
<xsl:choose> </xsl:for-each>
<xsl:when test="contains($latele,' ')"> <xsl:for-each select="//gx:Track">
<xsl:value-of select="substring-before($latele,' ')"/> <trk>
</xsl:when> <trkseg>
<xsl:otherwise> <xsl:for-each select="gx:coord">
<xsl:value-of select="$latele"/> <xsl:variable name="i" select="position()"/>
</xsl:otherwise> <xsl:variable name="lonlat" select="."/>
</xsl:choose> <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>
<trkpt lon="{$lon}" lat="{$lat}"> <trkpt lon="{$lon}" lat="{$lat}">
<xsl:choose> <xsl:choose>
<xsl:when test="contains($latele,' ')"> <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:when>
</xsl:choose> </xsl:choose>
<xsl:variable name="ts" select="../kml:when[$i]"/> <xsl:variable name="ts" select="../kml:when[$i]"/>
<xsl:if test="$ts"> <xsl:if test="$ts">
<time><xsl:value-of select="$ts"/></time> <time><xsl:value-of select="$ts"/></time>
</xsl:if> </xsl:if>
</trkpt> </trkpt>
</xsl:for-each> </xsl:for-each>
</trkseg> </trkseg>
</trk> </trk>
</xsl:for-each> </xsl:for-each>
</gpx> </gpx>
</xsl:template> </xsl:template>
@ -142,4 +153,4 @@
<xsl:template match="gx:Track"> <xsl:template match="gx:Track">
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

View file

@ -7,7 +7,6 @@ import android.os.Bundle;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.widget.SwitchCompat;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -183,10 +182,10 @@ public class CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogF
if (!portrait) { if (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight() if (screenHeight - statusBarHeight - mainView.getHeight()
>= AndroidUtils.dpToPx(getActivity(), 8)) { >= 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); R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else { } 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); R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
} }
} }

View file

@ -43,7 +43,7 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends BottomSheetDialo
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
portrait = AndroidUiHelper.isOrientationPortrait(getActivity()); 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 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); 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 (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight() if (screenHeight - statusBarHeight - mainView.getHeight()
>= AndroidUtils.dpToPx(getActivity(), 8)) { >= 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); R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else { } 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); R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
} }
} }

View file

@ -25,6 +25,7 @@ import net.osmand.plus.OsmandSettings.MapMarkersOrderByMode;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.TrackActivity; import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener; import net.osmand.plus.mapmarkers.OptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener;
import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener; import net.osmand.plus.mapmarkers.OrderByBottomSheetDialogFragment.OrderByFragmentListener;
import net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener; import net.osmand.plus.mapmarkers.SaveAsTrackBottomSheetDialogFragment.MarkerSaveAsTrackFragmentListener;
@ -209,7 +210,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
@Override @Override
public void buildRouteOnClick() { public void buildRouteOnClick() {
PlanRouteFragment.showInstance(mapActivity.getSupportFragmentManager()); PlanRouteFragment.showInstance(mapActivity.getSupportFragmentManager(), AndroidUiHelper.isOrientationPortrait(mapActivity));
dismiss(); dismiss();
} }

View file

@ -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);
}
}

View file

@ -39,7 +39,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
MapActivity mapActivity = (MapActivity) getActivity(); MapActivity mapActivity = (MapActivity) getActivity();
portrait = AndroidUiHelper.isOrientationPortrait(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 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); 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 (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight() if (screenHeight - statusBarHeight - mainView.getHeight()
>= AndroidUtils.dpToPx(getActivity(), 8)) { >= 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); R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else { } 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); R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
} }
} }

View file

@ -39,7 +39,7 @@ public class OrderByBottomSheetDialogFragment extends BottomSheetDialogFragment
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
portrait = AndroidUiHelper.isOrientationPortrait(getActivity()); portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
settings = getMyApplication().getSettings(); settings = getMyApplication().getSettings();
boolean night = !settings.isLightContent(); final boolean night = !settings.isLightContent();
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; 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); 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 (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight() if (screenHeight - statusBarHeight - mainView.getHeight()
>= AndroidUtils.dpToPx(getActivity(), 8)) { >= 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); R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else { } 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); R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
} }
} }

View file

@ -12,8 +12,8 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.support.v7.widget.helper.ItemTouchHelper; import android.support.v7.widget.helper.ItemTouchHelper;
import android.util.Pair;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -21,6 +21,7 @@ import android.view.ViewGroup;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; 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.PlanRouteOptionsBottomSheetDialogFragment.PlanRouteOptionsFragmentListener;
import net.osmand.plus.mapmarkers.adapters.MapMarkersItemTouchHelperCallback; import net.osmand.plus.mapmarkers.adapters.MapMarkersItemTouchHelperCallback;
import net.osmand.plus.mapmarkers.adapters.MapMarkersListAdapter; 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;
import net.osmand.plus.measurementtool.SnapToRoadBottomSheetDialogFragment.SnapToRoadFragmentListener; 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.MapMarkersLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
import net.osmand.router.RouteCalculationProgress;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List; 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; import static net.osmand.plus.OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT;
public class PlanRouteFragment extends Fragment { public class PlanRouteFragment extends Fragment {
public static final String TAG = "PlanRouteFragment"; public static final String TAG = "PlanRouteFragment";
private static final int MAX_DIST_FOR_SNAP_TO_ROAD = 500 * 1000; // 500 km
private MapMarkersHelper markersHelper; private MapMarkersHelper markersHelper;
private MarkersPlanRouteContext planRouteContext;
private MapMarkersListAdapter adapter; private MapMarkersListAdapter adapter;
private IconsCache iconsCache; private IconsCache iconsCache;
private PlanRouteToolbarController toolbarController; private PlanRouteToolbarController toolbarController;
private ApplicationMode appMode;
private int previousMapPosition; private int previousMapPosition;
private int selectedCount = 0; private int selectedCount = 0;
private int toolbarHeight; private int toolbarHeight;
private int closedListContainerHeight;
private boolean nightMode; private boolean nightMode;
private boolean portrait; private boolean portrait;
@ -89,24 +82,46 @@ public class PlanRouteFragment extends Fragment {
private View mainView; private View mainView;
private RecyclerView markersRv; 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 @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final MapActivity mapActivity = getMapActivity(); final MapActivity mapActivity = getMapActivity();
markersHelper = mapActivity.getMyApplication().getMapMarkersHelper(); 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 // Handling screen rotation
FragmentManager fragmentManager = mapActivity.getSupportFragmentManager(); FragmentManager fragmentManager = mapActivity.getSupportFragmentManager();
@ -114,14 +129,11 @@ public class PlanRouteFragment extends Fragment {
if (snapToRoadFragment != null) { if (snapToRoadFragment != null) {
((SnapToRoadBottomSheetDialogFragment) snapToRoadFragment).setListener(createSnapToRoadFragmentListener()); ((SnapToRoadBottomSheetDialogFragment) snapToRoadFragment).setListener(createSnapToRoadFragmentListener());
} }
Fragment sortByFragment = fragmentManager.findFragmentByTag(PlanRouteOptionsBottomSheetDialogFragment.TAG); Fragment optionsFragment = fragmentManager.findFragmentByTag(PlanRouteOptionsBottomSheetDialogFragment.TAG);
if (sortByFragment != null) { if (optionsFragment != null) {
((PlanRouteOptionsBottomSheetDialogFragment) sortByFragment).setListener(createOptionsFragmentListener()); PlanRouteOptionsBottomSheetDialogFragment fragment = (PlanRouteOptionsBottomSheetDialogFragment) optionsFragment;
} fragment.setSelectAll(!(selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()));
// If rotate the screen from landscape to portrait when the list of markers is displayed then fragment.setListener(createOptionsFragmentListener());
// the RecyclerViewFragment will exist without view. This is necessary to remove it.
if (!portrait) {
hideMarkersListFragment();
} }
toolbarHeight = mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar); 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); View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_plan_route, null);
mainView = view.findViewById(R.id.main_view); 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(); enterPlanRouteMode();
View markersListContainer = mainView.findViewById(R.id.markers_list_container); View markersListContainer = mainView.findViewById(R.id.markers_list_container);
if (portrait && markersListContainer != null) { if (markersListContainer != null) {
markersListContainer.setBackgroundColor(backgroundColor); 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) { 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 { } 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 = new MapMarkersListAdapter(mapActivity);
adapter.setHasStableIds(true); adapter.setHasStableIds(true);
adapter.calculateStartAndFinishPos(); adapter.calculateStartAndFinishPos();
adapter.setSnappedToRoadPoints(snappedToRoadPoints); adapter.setSnappedToRoadPoints(planRouteContext.getSnappedToRoadPoints());
final ItemTouchHelper touchHelper = new ItemTouchHelper(new MapMarkersItemTouchHelperCallback(adapter)); final ItemTouchHelper touchHelper = new ItemTouchHelper(new MapMarkersItemTouchHelperCallback(adapter));
touchHelper.attachToRecyclerView(markersRv); touchHelper.attachToRecyclerView(markersRv);
adapter.setAdapterListener(new MapMarkersListAdapter.MapMarkersListAdapterListener() { adapter.setAdapterListener(new MapMarkersListAdapter.MapMarkersListAdapterListener() {
@ -255,7 +272,7 @@ public class PlanRouteFragment extends Fragment {
adapter.calculateStartAndFinishPos(); adapter.calculateStartAndFinishPos();
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
updateSelectButton(); updateSelectButton();
recreateSnapTrkSegment(); planRouteContext.recreateSnapTrkSegment();
} }
@Override @Override
@ -278,7 +295,7 @@ public class PlanRouteFragment extends Fragment {
// to avoid crash because of: // to avoid crash because of:
// java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling // 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.setClipToPadding(false);
markersRv.setLayoutManager(new LinearLayoutManager(getContext())); markersRv.setLayoutManager(new LinearLayoutManager(getContext()));
markersRv.setAdapter(adapter); 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); if (planRouteContext.isProgressBarVisible()) {
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) {
showProgressBar(); showProgressBar();
} }
return view; 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 @Override
public void onDestroyView() { public void onDestroyView() {
super.onDestroyView(); super.onDestroyView();
@ -367,11 +370,10 @@ public class PlanRouteFragment extends Fragment {
@Override @Override
public void onApplicationModeItemClick(ApplicationMode mode) { public void onApplicationModeItemClick(ApplicationMode mode) {
if (appMode != null && appMode != mode) { if (planRouteContext.getSnappedMode() != mode) {
appMode = mode; planRouteContext.getSnappedToRoadPoints().clear();
snappedToRoadPoints.clear(); planRouteContext.setSnappedMode(mode);
markersHelper.setSnappedMode(mode); planRouteContext.recreateSnapTrkSegment();
recreateSnapTrkSegment();
setupAppModesBtn(); setupAppModesBtn();
} }
} }
@ -383,6 +385,11 @@ public class PlanRouteFragment extends Fragment {
private MapActivity mapActivity = getMapActivity(); private MapActivity mapActivity = getMapActivity();
@Override
public void selectOnClick() {
selectAllOnClick();
}
@Override @Override
public void navigateOnClick() { public void navigateOnClick() {
if (mapActivity != null) { if (mapActivity != null) {
@ -393,7 +400,7 @@ public class PlanRouteFragment extends Fragment {
@Override @Override
public void makeRoundTripOnClick() { public void makeRoundTripOnClick() {
if (mapActivity != null) { 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(); markersHelper.reverseActiveMarkersOrder();
adapter.calculateStartAndFinishPos(); adapter.calculateStartAndFinishPos();
adapter.notifyDataSetChanged(); 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() { private void enterPlanRouteMode() {
final MapActivity mapActivity = getMapActivity(); final MapActivity mapActivity = getMapActivity();
MapMarkersLayer markersLayer = getMapMarkersLayer(); MapMarkersLayer markersLayer = getMapMarkersLayer();
@ -448,13 +463,19 @@ public class PlanRouteFragment extends Fragment {
wasCollapseButtonVisible = false; wasCollapseButtonVisible = false;
} }
if ((appMode = markersHelper.getSnappedMode()) == null) { if (planRouteContext.getSnappedMode() == null) {
appMode = ApplicationMode.DEFAULT; planRouteContext.setSnappedMode(ApplicationMode.DEFAULT);
} }
setupAppModesBtn(); setupAppModesBtn();
OsmandMapTileView tileView = mapActivity.getMapView();
previousMapPosition = tileView.getMapPosition();
if (!portrait) {
tileView.setMapPosition(LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
}
selectedCount = mapActivity.getMyApplication().getMapMarkersHelper().getSelectedMarkersCount(); selectedCount = mapActivity.getMyApplication().getMapMarkersHelper().getSelectedMarkersCount();
recreateSnapTrkSegment(); planRouteContext.recreateSnapTrkSegment();
mapActivity.refreshMap(); mapActivity.refreshMap();
updateSelectButton(); updateSelectButton();
} }
@ -462,10 +483,10 @@ public class PlanRouteFragment extends Fragment {
private void setupAppModesBtn() { private void setupAppModesBtn() {
final MapActivity mapActivity = getMapActivity(); 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); 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.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() { appModesBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -475,6 +496,11 @@ public class PlanRouteFragment extends Fragment {
fragment.show(mapActivity.getSupportFragmentManager(), SnapToRoadBottomSheetDialogFragment.TAG); 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); 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); mapActivity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.GONE);
mainView.findViewById(R.id.snap_to_road_progress_bar).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); markersLayer.setRoute(null);
mapActivity.refreshMap(); 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() { private void updateText() {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { 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; boolean defaultMode = appMode == ApplicationMode.DEFAULT;
float dist = 0; float dist = 0;
@ -539,10 +583,12 @@ public class PlanRouteFragment extends Fragment {
} }
private void updateSelectButton() { private void updateSelectButton() {
if (selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()) { if (portrait) {
((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_deselect_all)); if (selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()) {
} else { ((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_deselect_all));
((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_select_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() { private void showMarkersList() {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
MapMarkersLayer markersLayer = getMapMarkersLayer(); if (mapActivity != null && portrait) {
if (mapActivity != null && markersLayer != null) {
markersListOpened = true; 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); View listContainer = mainView.findViewById(R.id.markers_list_container);
if (portrait && listContainer != null) { if (listContainer != null) {
listContainer.setVisibility(View.VISIBLE); listContainer.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
} else {
showMarkersListFragment();
} }
OsmandMapTileView tileView = mapActivity.getMapView();
previousMapPosition = tileView.getMapPosition();
if (!portrait) {
tileView.setMapPosition(LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
}
mapActivity.refreshMap();
} }
} }
private void hideMarkersList() { private void hideMarkersList() {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
MapMarkersLayer markersLayer = getMapMarkersLayer(); if (mapActivity != null && portrait) {
if (mapActivity != null && markersLayer != null) {
markersListOpened = false; 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); View listContainer = mainView.findViewById(R.id.markers_list_container);
if (portrait && listContainer != null) { if (listContainer != null) {
listContainer.setVisibility(View.GONE); listContainer.getLayoutParams().height = closedListContainerHeight;
} 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
} }
} }
} }
@ -629,9 +634,9 @@ public class PlanRouteFragment extends Fragment {
private void showMarkersRouteOnMap(boolean adjustMap) { private void showMarkersRouteOnMap(boolean adjustMap) {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { if (mapActivity != null) {
mapActivity.getMapLayers().getMapMarkersLayer().setRoute(snapTrkSegment); mapActivity.getMapLayers().getMapMarkersLayer().setRoute(planRouteContext.getSnapTrkSegment());
if (adjustMap) { if (adjustMap) {
showRouteOnMap(snapTrkSegment.points); showRouteOnMap(planRouteContext.getSnapTrkSegment().points);
} }
} }
} }
@ -670,14 +675,14 @@ public class PlanRouteFragment extends Fragment {
if (portrait) { if (portrait) {
tileBoxHeightPx = 3 * (tb.getPixHeight() - mainView.getHeight() - toolbarHeight) / 4; tileBoxHeightPx = 3 * (tb.getPixHeight() - mainView.getHeight() - toolbarHeight) / 4;
} else { } 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); mapView.fitRectToMap(left, right, top, bottom, tileBoxWidthPx, tileBoxHeightPx, toolbarHeight * 3 / 2);
} }
} }
public boolean quit(boolean hideMarkersListFirst) { public boolean quit(boolean hideMarkersListFirst) {
if (markersListOpened && hideMarkersListFirst) { if (portrait && markersListOpened && hideMarkersListFirst) {
hideMarkersList(); hideMarkersList();
return false; return false;
} else { } else {
@ -687,18 +692,19 @@ public class PlanRouteFragment extends Fragment {
} }
private void dismiss(MapActivity activity) { private void dismiss(MapActivity activity) {
if (markersListOpened) { if (portrait && markersListOpened) {
hideMarkersList(); hideMarkersList();
} }
planRouteContext.setFragmentShowed(false);
activity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss(); activity.getSupportFragmentManager().beginTransaction().remove(this).commitAllowingStateLoss();
} }
public static boolean showInstance(FragmentManager fragmentManager) { public static boolean showInstance(FragmentManager fragmentManager, boolean portrait) {
try { try {
PlanRouteFragment fragment = new PlanRouteFragment(); PlanRouteFragment fragment = new PlanRouteFragment();
fragment.setRetainInstance(true); fragment.setRetainInstance(true);
fragmentManager.beginTransaction() fragmentManager.beginTransaction()
.add(R.id.bottomFragmentContainer, fragment, PlanRouteFragment.TAG) .add(portrait ? R.id.bottomFragmentContainer : R.id.topFragmentContainer, fragment, PlanRouteFragment.TAG)
.commitAllowingStateLoss(); .commitAllowingStateLoss();
return true; return true;
} catch (Exception e) { } catch (Exception e) {
@ -764,204 +770,11 @@ public class PlanRouteFragment extends Fragment {
mapActivity.getMyApplication().getMapMarkersHelper().addSelectedMarkersToTop(res); mapActivity.getMyApplication().getMapMarkersHelper().addSelectedMarkersToTop(res);
adapter.calculateStartAndFinishPos(); adapter.calculateStartAndFinishPos();
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
recreateSnapTrkSegment(); planRouteContext.recreateSnapTrkSegment();
} }
}.execute(); }.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 { private class PlanRouteToolbarController extends TopToolbarController {
PlanRouteToolbarController() { PlanRouteToolbarController() {

View file

@ -28,11 +28,16 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog
private boolean portrait; private boolean portrait;
private boolean night; private boolean night;
private PlanRouteOptionsFragmentListener listener; private PlanRouteOptionsFragmentListener listener;
private boolean selectAll;
public void setListener(PlanRouteOptionsFragmentListener listener) { public void setListener(PlanRouteOptionsFragmentListener listener) {
this.listener = listener; this.listener = listener;
} }
public void setSelectAll(boolean selectAll) {
this.selectAll = selectAll;
}
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 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.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)); ((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() { mainView.findViewById(R.id.navigate_row).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -117,10 +139,10 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog
if (!portrait) { if (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight() >= AndroidUtils.dpToPx(getActivity(), 8)) { 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); R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else { } 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); 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 { interface PlanRouteOptionsFragmentListener {
void selectOnClick();
void navigateOnClick(); void navigateOnClick();
void makeRoundTripOnClick(); void makeRoundTripOnClick();

View file

@ -4,7 +4,6 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.util.Log;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -25,11 +24,7 @@ import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import java.io.File; import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Locale;
import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
import static net.osmand.plus.helpers.GpxImportHelper.GPX_SUFFIX; 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) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
MapActivity mapActivity = (MapActivity) getActivity(); MapActivity mapActivity = (MapActivity) getActivity();
portrait = AndroidUiHelper.isOrientationPortrait(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 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); 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 (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight() if (screenHeight - statusBarHeight - mainView.getHeight()
>= AndroidUtils.dpToPx(getActivity(), 8)) { >= 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); R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else { } 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); R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
} }
} }

View file

@ -160,10 +160,10 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra
if (!portrait) { if (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight() if (screenHeight - statusBarHeight - mainView.getHeight()
>= AndroidUtils.dpToPx(getActivity(), 8)) { >= 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); R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else { } 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); R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
} }
} }