commit
8744f44e0e
13 changed files with 354 additions and 190 deletions
|
@ -49,6 +49,8 @@ public class GPXUtilities {
|
|||
private static final String ICON_NAME_EXTENSION = "icon";
|
||||
private static final String DEFAULT_ICON_NAME = "special_star";
|
||||
private static final String BACKGROUND_TYPE_EXTENSION = "background";
|
||||
private static final String PROFILE_TYPE_EXTENSION = "profile";
|
||||
private static final String TRKPT_INDEX_EXTENSION = "trkpt_idx";
|
||||
|
||||
private final static String GPX_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; //$NON-NLS-1$
|
||||
private final static String GPX_TIME_FORMAT_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; //$NON-NLS-1$
|
||||
|
@ -305,6 +307,26 @@ public class GPXUtilities {
|
|||
getExtensionsToWrite().put(BACKGROUND_TYPE_EXTENSION, backType);
|
||||
}
|
||||
|
||||
public String getProfileType() {
|
||||
return getExtensionsToRead().get(PROFILE_TYPE_EXTENSION);
|
||||
}
|
||||
|
||||
public void setProfileType(String profileType) {
|
||||
getExtensionsToWrite().put(PROFILE_TYPE_EXTENSION, profileType);
|
||||
}
|
||||
|
||||
public int getTrkPtIndex() {
|
||||
try {
|
||||
return Integer.parseInt(getExtensionsToRead().get(TRKPT_INDEX_EXTENSION));
|
||||
}catch(NumberFormatException e){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTrkPtIndex(int index) {
|
||||
getExtensionsToWrite().put(TRKPT_INDEX_EXTENSION, String.valueOf(index));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
|
|
@ -70,9 +70,9 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginEnd="@dimen/text_margin_small"
|
||||
android:layout_marginEnd="@dimen/measurement_tool_text_margin"
|
||||
android:layout_marginLeft="@dimen/measurement_tool_text_margin"
|
||||
android:layout_marginRight="@dimen/text_margin_small"
|
||||
android:layout_marginRight="@dimen/measurement_tool_text_margin"
|
||||
android:layout_marginStart="@dimen/measurement_tool_text_margin"
|
||||
android:layout_toEndOf="@id/main_icon"
|
||||
android:layout_toRightOf="@id/main_icon"
|
||||
|
@ -99,6 +99,10 @@
|
|||
android:layout_toLeftOf="@id/up_down_button"
|
||||
android:layout_toRightOf="@id/measurement_points_text_view"
|
||||
android:layout_toStartOf="@id/up_down_button"
|
||||
android:layout_marginEnd="@dimen/measurement_tool_text_margin"
|
||||
android:layout_marginLeft="@dimen/measurement_tool_text_margin"
|
||||
android:layout_marginRight="@dimen/measurement_tool_text_margin"
|
||||
android:layout_marginStart="@dimen/measurement_tool_text_margin"
|
||||
android:textColor="@color/color_distance"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text=" – 700 m"/>
|
||||
|
@ -154,39 +158,38 @@
|
|||
android:id="@+id/options_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/measurement_tool_button_padding"
|
||||
android:layout_marginBottom="@dimen/measurement_tool_button_padding"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingEnd="@dimen/measurement_tool_text_button_padding_small"
|
||||
android:paddingLeft="@dimen/measurement_tool_text_button_padding"
|
||||
android:paddingRight="@dimen/measurement_tool_text_button_padding_small"
|
||||
android:paddingStart="@dimen/measurement_tool_text_button_padding"
|
||||
android:paddingLeft="@dimen/measurement_tool_text_button_padding"
|
||||
android:text="@string/shared_string_options"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
</FrameLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/undo_point_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingEnd="@dimen/measurement_tool_undo_redo_padding_small"
|
||||
android:paddingLeft="@dimen/measurement_tool_undo_redo_padding"
|
||||
android:paddingRight="@dimen/measurement_tool_undo_redo_padding_small"
|
||||
android:paddingStart="@dimen/measurement_tool_undo_redo_padding_small"
|
||||
android:padding="@dimen/measurement_tool_undo_redo_padding_small"
|
||||
tools:src="@drawable/ic_action_undo_dark"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/redo_point_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="@dimen/measurement_tool_button_padding"
|
||||
android:layout_marginStart="@dimen/measurement_tool_button_padding"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingEnd="@dimen/measurement_tool_undo_redo_padding"
|
||||
android:paddingLeft="@dimen/measurement_tool_undo_redo_padding_small"
|
||||
android:paddingRight="@dimen/measurement_tool_undo_redo_padding"
|
||||
android:paddingStart="@dimen/measurement_tool_undo_redo_padding_small"
|
||||
android:padding="@dimen/measurement_tool_undo_redo_padding_small"
|
||||
tools:src="@drawable/ic_action_redo_dark"/>
|
||||
|
||||
<FrameLayout
|
||||
|
@ -204,16 +207,15 @@
|
|||
android:layout_marginRight="@dimen/measurement_tool_button_margin"
|
||||
android:layout_marginTop="@dimen/measurement_tool_button_margin"
|
||||
android:background="?attr/btn_round"
|
||||
osmand:drawableLeftCompat="@drawable/ic_action_plus"
|
||||
osmand:drawableStartCompat="@drawable/ic_action_plus"
|
||||
android:maxLines="1"
|
||||
android:maxLines="1"
|
||||
android:minHeight="@dimen/measurement_tool_button_height"
|
||||
android:paddingLeft="@dimen/measurement_tool_button_padding"
|
||||
android:paddingRight="@dimen/measurement_tool_button_padding"
|
||||
android:text="@string/shared_string_add"
|
||||
android:textColor="@color/color_white"
|
||||
android:paddingEnd="@dimen/measurement_tool_button_padding"
|
||||
android:paddingStart="@dimen/measurement_tool_button_padding" />
|
||||
android:textAllCaps="false"
|
||||
android:paddingEnd="@dimen/measurement_tool_button_padding"
|
||||
android:paddingStart="@dimen/measurement_tool_button_padding" />
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -242,8 +244,9 @@
|
|||
android:paddingRight="@dimen/measurement_tool_button_padding"
|
||||
android:text="@string/shared_string_apply"
|
||||
android:textColor="@color/color_white"
|
||||
android:paddingEnd="@dimen/measurement_tool_button_padding"
|
||||
android:paddingStart="@dimen/measurement_tool_button_padding" />
|
||||
android:textAllCaps="false"
|
||||
android:paddingEnd="@dimen/measurement_tool_button_padding"
|
||||
android:paddingStart="@dimen/measurement_tool_button_padding" />
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/cancel_move_point_button"
|
||||
|
@ -304,8 +307,9 @@
|
|||
android:paddingRight="@dimen/measurement_tool_button_padding"
|
||||
android:text="@string/shared_string_apply"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:paddingEnd="@dimen/measurement_tool_button_padding"
|
||||
android:paddingStart="@dimen/measurement_tool_button_padding" />
|
||||
android:textAllCaps="false"
|
||||
android:paddingEnd="@dimen/measurement_tool_button_padding"
|
||||
android:paddingStart="@dimen/measurement_tool_button_padding" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/add_point_before_after_button"
|
||||
|
@ -316,15 +320,14 @@
|
|||
android:layout_marginRight="@dimen/measurement_tool_button_margin"
|
||||
android:layout_marginTop="@dimen/measurement_tool_button_margin"
|
||||
android:background="?attr/btn_round"
|
||||
osmand:drawableLeftCompat="@drawable/ic_action_plus"
|
||||
osmand:drawableStartCompat="@drawable/ic_action_plus"
|
||||
android:minHeight="@dimen/measurement_tool_button_height"
|
||||
android:paddingLeft="@dimen/measurement_tool_button_padding"
|
||||
android:paddingRight="@dimen/measurement_tool_button_padding"
|
||||
android:text="@string/shared_string_add"
|
||||
android:textColor="@color/color_white"
|
||||
android:paddingStart="@dimen/measurement_tool_button_padding"
|
||||
android:paddingEnd="@dimen/measurement_tool_button_padding" />
|
||||
android:textAllCaps="false"
|
||||
android:paddingStart="@dimen/measurement_tool_button_padding"
|
||||
android:paddingEnd="@dimen/measurement_tool_button_padding" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -39,10 +39,10 @@
|
|||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
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:layout_marginEnd="@dimen/measurement_tool_text_button_padding"
|
||||
android:layout_marginLeft="@dimen/measurement_tool_text_button_padding"
|
||||
android:layout_marginRight="@dimen/measurement_tool_text_button_padding"
|
||||
android:layout_marginStart="@dimen/measurement_tool_text_button_padding"
|
||||
android:background="@null"
|
||||
tools:src="@drawable/ic_action_ruler"/>
|
||||
|
||||
|
@ -64,11 +64,11 @@
|
|||
android:id="@+id/measurement_distance_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginTop="@dimen/measurement_tool_button_padding"
|
||||
android:layout_marginEnd="@dimen/text_margin_small"
|
||||
android:layout_marginLeft="@dimen/measurement_tool_text_margin"
|
||||
android:layout_marginLeft="@dimen/measurement_tool_text_button_padding"
|
||||
android:layout_marginRight="@dimen/text_margin_small"
|
||||
android:layout_marginStart="@dimen/measurement_tool_text_margin"
|
||||
android:layout_marginStart="@dimen/measurement_tool_text_button_padding"
|
||||
android:layout_toEndOf="@id/main_icon"
|
||||
android:layout_toRightOf="@id/main_icon"
|
||||
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||
|
@ -78,7 +78,7 @@
|
|||
android:id="@+id/measurement_points_text_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginTop="@dimen/measurement_tool_button_padding"
|
||||
android:layout_toEndOf="@id/measurement_distance_text_view"
|
||||
android:layout_toRightOf="@id/measurement_distance_text_view"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
|
@ -87,17 +87,15 @@
|
|||
|
||||
<TextView
|
||||
android:id="@+id/distance_to_center_text_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/measurement_points_text_view"
|
||||
android:layout_toLeftOf="@id/up_down_button"
|
||||
android:layout_toRightOf="@id/measurement_points_text_view"
|
||||
android:layout_toStartOf="@id/up_down_button"
|
||||
android:textColor="@color/color_distance"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:layout_below="@id/measurement_points_text_view"
|
||||
android:layout_alignStart="@+id/measurement_distance_text_view"
|
||||
android:layout_alignLeft="@+id/measurement_distance_text_view"
|
||||
android:maxLines="1"
|
||||
tools:text=" – 700 m"/>
|
||||
android:textColor="@color/color_distance"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
tools:text=" – 700 m" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/move_point_text"
|
||||
|
@ -161,7 +159,11 @@
|
|||
<LinearLayout
|
||||
android:id="@+id/measure_mode_controls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/measurement_tool_controls_height">
|
||||
android:layout_height="@dimen/measurement_tool_controls_height"
|
||||
android:paddingTop="@dimen/measurement_tool_button_padding_top"
|
||||
android:paddingBottom="@dimen/measurement_tool_button_padding_top"
|
||||
android:paddingLeft="@dimen/measurement_tool_button_margin"
|
||||
android:paddingRight="@dimen/measurement_tool_button_margin">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
|
@ -176,36 +178,28 @@
|
|||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingEnd="@dimen/measurement_tool_text_button_padding_small"
|
||||
android:paddingLeft="@dimen/measurement_tool_text_button_padding"
|
||||
android:paddingRight="@dimen/measurement_tool_text_button_padding_small"
|
||||
android:paddingStart="@dimen/measurement_tool_text_button_padding"
|
||||
android:padding="@dimen/measurement_tool_text_button_padding_small"
|
||||
android:text="@string/shared_string_options"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
</FrameLayout>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/undo_point_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingEnd="@dimen/measurement_tool_undo_redo_padding_small"
|
||||
android:paddingLeft="@dimen/measurement_tool_undo_redo_padding"
|
||||
android:paddingRight="@dimen/measurement_tool_undo_redo_padding_small"
|
||||
android:paddingStart="@dimen/measurement_tool_undo_redo_padding"
|
||||
android:padding="@dimen/measurement_tool_undo_redo_padding_small"
|
||||
tools:src="@drawable/ic_action_undo_dark"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/redo_point_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/measurement_tool_button_padding"
|
||||
android:layout_marginStart="@dimen/measurement_tool_button_padding"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingEnd="@dimen/measurement_tool_undo_redo_padding"
|
||||
android:paddingLeft="@dimen/measurement_tool_undo_redo_padding_small"
|
||||
android:paddingRight="@dimen/measurement_tool_undo_redo_padding"
|
||||
android:paddingStart="@dimen/measurement_tool_undo_redo_padding_small"
|
||||
android:padding="@dimen/measurement_tool_undo_redo_padding_small"
|
||||
tools:src="@drawable/ic_action_redo_dark"/>
|
||||
|
||||
<FrameLayout
|
||||
|
@ -218,13 +212,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginBottom="@dimen/measurement_tool_button_margin"
|
||||
android:layout_marginEnd="@dimen/measurement_tool_button_margin"
|
||||
android:layout_marginRight="@dimen/measurement_tool_button_margin"
|
||||
android:layout_marginTop="@dimen/measurement_tool_button_margin"
|
||||
android:background="?attr/btn_round"
|
||||
osmand:drawableLeftCompat="@drawable/ic_action_plus"
|
||||
osmand:drawableStartCompat="@drawable/ic_action_plus"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:minHeight="@dimen/measurement_tool_button_height"
|
||||
|
@ -232,6 +220,7 @@
|
|||
android:paddingRight="@dimen/measurement_tool_button_padding"
|
||||
android:text="@string/shared_string_add"
|
||||
android:textColor="@color/color_white"
|
||||
android:textAllCaps="false"
|
||||
android:paddingEnd="@dimen/measurement_tool_button_padding"
|
||||
android:paddingStart="@dimen/measurement_tool_button_padding" />
|
||||
</FrameLayout>
|
||||
|
@ -261,6 +250,7 @@
|
|||
android:paddingRight="@dimen/measurement_tool_button_padding"
|
||||
android:text="@string/shared_string_apply"
|
||||
android:textColor="@color/color_white"
|
||||
android:textAllCaps="false"
|
||||
android:paddingEnd="@dimen/measurement_tool_button_padding"
|
||||
android:paddingStart="@dimen/measurement_tool_button_padding" />
|
||||
|
||||
|
@ -268,15 +258,12 @@
|
|||
android:id="@+id/cancel_move_point_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="@dimen/measurement_tool_button_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="12dp"
|
||||
android:paddingStart="16dp"
|
||||
android:padding="@dimen/measurement_tool_text_button_padding_small"
|
||||
android:text="@string/shared_string_cancel"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -292,15 +279,12 @@
|
|||
android:id="@+id/cancel_point_before_after_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="@dimen/measurement_tool_button_margin"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="@dimen/measurement_tool_text_button_padding_small"
|
||||
android:paddingLeft="@dimen/measurement_tool_text_button_padding"
|
||||
android:paddingRight="@dimen/measurement_tool_text_button_padding_small"
|
||||
android:paddingStart="@dimen/measurement_tool_text_button_padding"
|
||||
android:padding="@dimen/measurement_tool_text_button_padding_small"
|
||||
android:text="@string/shared_string_cancel"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<View
|
||||
|
@ -322,6 +306,7 @@
|
|||
android:paddingRight="@dimen/measurement_tool_button_padding"
|
||||
android:text="@string/shared_string_apply"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textAllCaps="false"
|
||||
android:paddingEnd="@dimen/measurement_tool_button_padding"
|
||||
android:paddingStart="@dimen/measurement_tool_button_padding" />
|
||||
|
||||
|
@ -334,13 +319,12 @@
|
|||
android:layout_marginRight="@dimen/measurement_tool_button_margin"
|
||||
android:layout_marginTop="@dimen/measurement_tool_button_margin"
|
||||
android:background="?attr/btn_round"
|
||||
osmand:drawableLeftCompat="@drawable/ic_action_plus"
|
||||
osmand:drawableStartCompat="@drawable/ic_action_plus"
|
||||
android:minHeight="@dimen/measurement_tool_button_height"
|
||||
android:paddingLeft="@dimen/measurement_tool_button_padding"
|
||||
android:paddingRight="@dimen/measurement_tool_button_padding"
|
||||
android:text="@string/shared_string_add"
|
||||
android:textColor="@color/color_white"
|
||||
android:textAllCaps="false"
|
||||
android:paddingEnd="@dimen/measurement_tool_button_padding"
|
||||
android:paddingStart="@dimen/measurement_tool_button_padding" />
|
||||
</LinearLayout>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -14,10 +13,10 @@
|
|||
android:layout_height="@dimen/dashboard_map_toolbar"
|
||||
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||
android:visibility="gone"
|
||||
app:contentInsetLeft="54dp"
|
||||
app:contentInsetStart="54dp"
|
||||
app:contentInsetRight="0dp"
|
||||
app:contentInsetEnd="0dp"
|
||||
osmand:contentInsetLeft="@dimen/toolbar_inset_start"
|
||||
osmand:contentInsetStart="@dimen/toolbar_inset_start"
|
||||
osmand:contentInsetRight="0dp"
|
||||
osmand:contentInsetEnd="0dp"
|
||||
tools:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
|
@ -53,8 +52,8 @@
|
|||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:paddingStart="@dimen/content_padding"
|
||||
android:paddingEnd="@dimen/content_padding" />
|
||||
android:paddingStart="@dimen/content_padding"
|
||||
android:paddingEnd="@dimen/content_padding" />
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
|
@ -63,8 +62,8 @@
|
|||
android:id="@+id/toolbar_divider"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="54dp"
|
||||
android:layout_marginStart="54dp"
|
||||
android:layout_marginLeft="@dimen/toolbar_inset_start"
|
||||
android:layout_marginStart="@dimen/toolbar_inset_start"
|
||||
android:visibility="gone"
|
||||
tools:background="?attr/dashboard_divider"
|
||||
tools:visibility="visible"/>
|
||||
|
@ -81,7 +80,7 @@
|
|||
<LinearLayout
|
||||
android:id="@+id/up_down_row"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/measurement_tool_up_down_row_height"
|
||||
android:layout_height="@dimen/route_info_modes_height"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
|
@ -151,10 +150,10 @@
|
|||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="1"
|
||||
android:paddingEnd="@dimen/measurement_tool_text_button_padding_small"
|
||||
android:paddingLeft="@dimen/measurement_tool_text_button_padding"
|
||||
android:paddingRight="@dimen/measurement_tool_text_button_padding_small"
|
||||
android:paddingStart="@dimen/measurement_tool_text_button_padding"
|
||||
android:paddingEnd="@dimen/route_info_details_padding"
|
||||
android:paddingLeft="@dimen/route_info_buttons_padding_top_bottom"
|
||||
android:paddingRight="@dimen/route_info_details_padding"
|
||||
android:paddingStart="@dimen/route_info_buttons_padding_top_bottom"
|
||||
android:text="@string/shared_string_select_all"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
osmand:textAllCapsCompat="true"
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
<dimen name="measurement_tool_text_margin">12dp</dimen>
|
||||
<dimen name="measurement_tool_points_list_container_height">330dp</dimen>
|
||||
<dimen name="measurement_tool_up_down_row_height">48dp</dimen>
|
||||
<dimen name="measurement_tool_controls_height">78dp</dimen>
|
||||
<dimen name="measurement_tool_controls_height">84dp</dimen>
|
||||
<dimen name="measurement_tool_text_button_padding_small">18dp</dimen>
|
||||
<dimen name="measurement_tool_text_button_padding">24dp</dimen>
|
||||
<dimen name="measurement_tool_undo_redo_padding_small">18dp</dimen>
|
||||
|
@ -88,6 +88,7 @@
|
|||
<dimen name="measurement_tool_undo_redo_padding">24dp</dimen>
|
||||
<dimen name="measurement_tool_button_margin">12dp</dimen>
|
||||
<dimen name="measurement_tool_button_padding">12dp</dimen>
|
||||
<dimen name="measurement_tool_button_padding_top">15dp</dimen>
|
||||
<dimen name="measurement_tool_button_height">54dp</dimen>
|
||||
|
||||
<!--Route info-->
|
||||
|
|
|
@ -251,15 +251,16 @@
|
|||
<dimen name="text_margin_small">4dp</dimen>
|
||||
<dimen name="measurement_tool_text_margin">8dp</dimen>
|
||||
<dimen name="measurement_tool_points_list_container_height">220dp</dimen>
|
||||
<dimen name="measurement_tool_up_down_row_height">48dp</dimen>
|
||||
<dimen name="measurement_tool_controls_height">52dp</dimen>
|
||||
<dimen name="measurement_tool_text_button_padding_small">12dp</dimen>
|
||||
<dimen name="measurement_tool_up_down_row_height">60dp</dimen>
|
||||
<dimen name="measurement_tool_controls_height">56dp</dimen>
|
||||
<dimen name="measurement_tool_text_button_padding_small">8dp</dimen>
|
||||
<dimen name="measurement_tool_text_button_padding">16dp</dimen>
|
||||
<dimen name="measurement_tool_undo_redo_padding_small">12dp</dimen>
|
||||
<dimen name="measurement_tool_undo_redo_padding_small">6dp</dimen>
|
||||
<dimen name="measurement_tool_undo_redo_padding_medium">14dp</dimen>
|
||||
<dimen name="measurement_tool_undo_redo_padding">16dp</dimen>
|
||||
<dimen name="measurement_tool_button_margin">8dp</dimen>
|
||||
<dimen name="measurement_tool_button_padding">8dp</dimen>
|
||||
<dimen name="measurement_tool_button_padding_top">10dp</dimen>
|
||||
<dimen name="measurement_tool_button_height">36dp</dimen>
|
||||
<dimen name="bottom_sheet_title_height">52dp</dimen>
|
||||
<dimen name="bottom_sheet_descr_height">44dp</dimen>
|
||||
|
@ -340,6 +341,7 @@
|
|||
<dimen name="toolbar_height">56dp</dimen>
|
||||
<dimen name="toolbar_height_expanded">96dp</dimen>
|
||||
<dimen name="toolbar_inset_start_with_navigation">72dp</dimen>
|
||||
<dimen name="toolbar_inset_start">54dp</dimen>
|
||||
|
||||
<dimen name="wikivoyage_search_list_header_height">36dp</dimen>
|
||||
<dimen name="wikivoyage_article_card_icon_size">80dp</dimen>
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
Thx - Hardy
|
||||
|
||||
-->
|
||||
<string name="add_to_a_track">Add to a Track</string>
|
||||
<string name="plan_a_route">Plan a route</string>
|
||||
<string name="route_between_points">Route between points</string>
|
||||
<string name="set_working_days_to_continue">You need to set working days to continue</string>
|
||||
<string name="osm_edit_closed_note">Closed OSM Note</string>
|
||||
<string name="app_mode_go_cart">Go-cart</string>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -21,7 +20,6 @@ import android.widget.Toast;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
|
@ -425,7 +423,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
|
||||
adapter.addItem(itemBuilder
|
||||
.setTitleId(R.string.measurement_tool, mapActivity)
|
||||
.setTitleId(R.string.plan_a_route, mapActivity)
|
||||
.setId(MAP_CONTEXT_MENU_MEASURE_DISTANCE)
|
||||
.setIcon(R.drawable.ic_action_ruler)
|
||||
.setOrder(MEASURE_DISTANCE_ITEM_ORDER)
|
||||
|
@ -473,7 +471,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
// new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
|
||||
// REQUEST_LOCATION_FOR_DIRECTIONS_NAVIGATION_PERMISSION);
|
||||
//}
|
||||
} else if (standardId == R.string.measurement_tool) {
|
||||
} else if (standardId == R.string.plan_a_route) {
|
||||
mapActivity.getContextMenu().close();
|
||||
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager(), new LatLon(latitude, longitude));
|
||||
} else if (standardId == R.string.avoid_road) {
|
||||
|
@ -932,7 +930,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.plan_a_route, mapActivity)
|
||||
.setId(DRAWER_MEASURE_DISTANCE_ID)
|
||||
.setIcon(R.drawable.ic_action_ruler)
|
||||
.setListener(new ItemClickListener() {
|
||||
|
|
|
@ -10,13 +10,14 @@ import net.osmand.GPXUtilities.TrkSegment;
|
|||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.measurementtool.command.MeasurementCommandManager;
|
||||
import net.osmand.plus.routing.RouteCalculationParams;
|
||||
import net.osmand.plus.routing.RouteCalculationResult;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.router.RouteCalculationProgress;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -45,6 +46,7 @@ public class MeasurementEditingContext {
|
|||
private boolean inSnapToRoadMode;
|
||||
private boolean needUpdateCacheForSnap;
|
||||
private int calculatedPairs;
|
||||
|
||||
private SnapToRoadProgressListener progressListener;
|
||||
private ApplicationMode snapToRoadAppMode;
|
||||
private RouteCalculationProgress calculationProgress;
|
||||
|
@ -112,12 +114,12 @@ public class MeasurementEditingContext {
|
|||
this.progressListener = progressListener;
|
||||
}
|
||||
|
||||
ApplicationMode getSnapToRoadAppMode() {
|
||||
public ApplicationMode getSnapToRoadAppMode() {
|
||||
return snapToRoadAppMode;
|
||||
}
|
||||
|
||||
void setSnapToRoadAppMode(ApplicationMode snapToRoadAppMode) {
|
||||
if (this.snapToRoadAppMode != null
|
||||
if (this.snapToRoadAppMode != null && snapToRoadAppMode != null
|
||||
&& !this.snapToRoadAppMode.getStringKey().equals(snapToRoadAppMode.getStringKey())) {
|
||||
snappedToRoadPoints.clear();
|
||||
updateCacheForSnapIfNeeded(true);
|
||||
|
@ -260,6 +262,54 @@ public class MeasurementEditingContext {
|
|||
}
|
||||
}
|
||||
|
||||
void addPoints() {
|
||||
List<WptPt> points = getNewGpxData().getTrkSegment().points;
|
||||
if (isSnapToRoadTrack()) {
|
||||
List<WptPt> routePoints = getNewGpxData().getGpxFile().getRoutePoints();
|
||||
int prevPointIndex = 0;
|
||||
for (int i = 0; i < routePoints.size() - 1; i++) {
|
||||
Pair<WptPt, WptPt> pair = new Pair<>(routePoints.get(i), routePoints.get(i + 1));
|
||||
int startIndex = pair.first.getTrkPtIndex();
|
||||
if (startIndex < 0 || startIndex < prevPointIndex || startIndex >= points.size()) {
|
||||
startIndex = findPointIndex(pair.first, points, prevPointIndex);
|
||||
}
|
||||
int endIndex = pair.second.getTrkPtIndex() + 1;
|
||||
if (endIndex < 0 || endIndex < startIndex || endIndex >= points.size()) {
|
||||
endIndex = findPointIndex(pair.second, points, startIndex);
|
||||
}
|
||||
if (startIndex >= 0 && endIndex >= 0) {
|
||||
List<WptPt> cacheSegment = new ArrayList<>();
|
||||
for (int j = startIndex; j < endIndex && j < points.size(); j++) {
|
||||
cacheSegment.add(points.get(j));
|
||||
prevPointIndex = j;
|
||||
}
|
||||
snappedToRoadPoints.put(pair, cacheSegment);
|
||||
}
|
||||
}
|
||||
addPoints(routePoints);
|
||||
} else {
|
||||
addPoints(points);
|
||||
}
|
||||
}
|
||||
|
||||
private int findPointIndex(WptPt point, List<WptPt> points, int firstIndex) {
|
||||
double minDistance = Double.MAX_VALUE;
|
||||
int index = 0;
|
||||
for (int i = Math.max(0, firstIndex); i < points.size(); i++) {
|
||||
double distance = MapUtils.getDistance(point.lat, point.lon, points.get(i).lat, points.get(i).lon);
|
||||
if (distance < minDistance) {
|
||||
minDistance = distance;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
boolean isSnapToRoadTrack() {
|
||||
return !getNewGpxData().getTrkSegment().points.isEmpty()
|
||||
&& !getNewGpxData().getGpxFile().getRoutePoints().isEmpty();
|
||||
}
|
||||
|
||||
private void updateCacheForSnapIfNeeded(boolean both) {
|
||||
if (needUpdateCacheForSnap) {
|
||||
recreateCacheForSnap(beforeCacheForSnap = new TrkSegment(), before);
|
||||
|
@ -342,6 +392,9 @@ public class MeasurementEditingContext {
|
|||
}
|
||||
calculatedPairs++;
|
||||
snappedToRoadPoints.put(currentPair, pts);
|
||||
int trkptIndex = currentPair.first.getTrkPtIndex();
|
||||
trkptIndex += pts.size() - 1;
|
||||
currentPair.second.setTrkPtIndex(trkptIndex);
|
||||
updateCacheForSnapIfNeeded(true);
|
||||
application.runInUIThread(new Runnable() {
|
||||
@Override
|
||||
|
|
|
@ -36,8 +36,11 @@ import androidx.recyclerview.widget.ItemTouchHelper;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.FileUtils;
|
||||
import net.osmand.GPXUtilities;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.Route;
|
||||
|
@ -46,11 +49,9 @@ import net.osmand.GPXUtilities.TrkSegment;
|
|||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.Version;
|
||||
|
@ -71,6 +72,9 @@ import net.osmand.plus.measurementtool.command.ClearPointsCommand;
|
|||
import net.osmand.plus.measurementtool.command.MovePointCommand;
|
||||
import net.osmand.plus.measurementtool.command.RemovePointCommand;
|
||||
import net.osmand.plus.measurementtool.command.ReorderPointCommand;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.settings.backend.OsmandSettings;
|
||||
import net.osmand.plus.views.MapControlsLayer;
|
||||
import net.osmand.plus.views.controls.ReorderItemTouchHelperCallback;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
|
||||
|
@ -107,6 +111,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
private ImageView undoBtn;
|
||||
private ImageView redoBtn;
|
||||
private ImageView mainIcon;
|
||||
private Snackbar snackbar;
|
||||
|
||||
private boolean wasCollapseButtonVisible;
|
||||
private boolean progressBarVisible;
|
||||
|
@ -220,7 +225,15 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
|
||||
mainIcon = (ImageView) mainView.findViewById(R.id.main_icon);
|
||||
final NewGpxData newGpxData = editingCtx.getNewGpxData();
|
||||
if (editingCtx.getNewGpxData() != null) {
|
||||
if (newGpxData != null) {
|
||||
List<WptPt> points = newGpxData.getGpxFile().getRoutePoints();
|
||||
if (!points.isEmpty()) {
|
||||
ApplicationMode snapToRoadAppMode = ApplicationMode
|
||||
.valueOfStringKey(points.get(points.size() - 1).getProfileType(), null);
|
||||
if (snapToRoadAppMode != null) {
|
||||
enableSnapToRoadMode(snapToRoadAppMode);
|
||||
}
|
||||
}
|
||||
ActionType actionType = newGpxData.getActionType();
|
||||
if (actionType == ActionType.ADD_SEGMENT || actionType == ActionType.EDIT_SEGMENT) {
|
||||
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_polygom_dark));
|
||||
|
@ -369,7 +382,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
public void onMeasure(float distance, float bearing) {
|
||||
String distStr = OsmAndFormatter.getFormattedDistance(distance, mapActivity.getMyApplication());
|
||||
String azimuthStr = OsmAndFormatter.getFormattedAzimuth(bearing, getMyApplication());
|
||||
distanceToCenterTv.setText(String.format(" – %1$s • %2$s", distStr, azimuthStr));
|
||||
distanceToCenterTv.setText(String.format("%1$s • %2$s", distStr, azimuthStr));
|
||||
TextViewCompat.setAutoSizeTextTypeUniformWithConfiguration(
|
||||
distanceToCenterTv, 12, 18, 2, TypedValue.COMPLEX_UNIT_SP
|
||||
);
|
||||
|
@ -467,9 +480,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
|
||||
enterMeasurementMode();
|
||||
|
||||
if (editingCtx.isInSnapToRoadMode()) {
|
||||
showSnapToRoadControls();
|
||||
}
|
||||
showSnapToRoadControls();
|
||||
|
||||
if (newGpxData != null && !gpxPointsAdded) {
|
||||
ActionType actionType = newGpxData.getActionType();
|
||||
|
@ -560,10 +571,11 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
if (rememberPreviousTitle) {
|
||||
previousToolBarTitle = toolBarController.getTitle();
|
||||
}
|
||||
toolBarController.setTitle(getString(R.string.snap_to_road));
|
||||
toolBarController.setTitle(getString(R.string.route_between_points));
|
||||
mapActivity.refreshMap();
|
||||
SnapToRoadBottomSheetDialogFragment fragment = new SnapToRoadBottomSheetDialogFragment();
|
||||
fragment.setListener(createSnapToRoadFragmentListener());
|
||||
fragment.setShowStraightLine(true);
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), SnapToRoadBottomSheetDialogFragment.TAG);
|
||||
}
|
||||
}
|
||||
|
@ -583,10 +595,24 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void directions() {
|
||||
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
|
||||
if (mapControlsLayer != null) {
|
||||
mapControlsLayer.doRoute(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addToGpxOnClick() {
|
||||
if (mapActivity != null && measurementLayer != null) {
|
||||
if (editingCtx.getPointsCount() > 0) {
|
||||
if (editingCtx.isInSnapToRoadMode()) {
|
||||
editingCtx.getPoints().clear();
|
||||
editingCtx.getPoints().addAll(editingCtx.getBeforePoints());
|
||||
editingCtx.getBeforePoints().clear();
|
||||
editingCtx.getBeforePoints().addAll(editingCtx.getBeforeTrkSegmentLine().points);
|
||||
}
|
||||
addToGpx(mapActivity);
|
||||
} else {
|
||||
Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
|
||||
|
@ -713,7 +739,13 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
|
||||
@Override
|
||||
public void onApplicationModeItemClick(ApplicationMode mode) {
|
||||
enableSnapToRoadMode(mode);
|
||||
if (mode == null) {
|
||||
disableSnapToRoadMode();
|
||||
editingCtx.setSnapToRoadAppMode(null);
|
||||
showSnapToRoadControls();
|
||||
} else {
|
||||
enableSnapToRoadMode(mode);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -721,6 +753,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
private void removePoint(MeasurementToolLayer layer, int position) {
|
||||
editingCtx.getCommandManager().execute(new RemovePointCommand(layer, position));
|
||||
adapter.notifyDataSetChanged();
|
||||
enable(undoBtn);
|
||||
disable(redoBtn);
|
||||
updateText();
|
||||
saved = false;
|
||||
|
@ -803,14 +836,16 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
private void showSnapToRoadControls() {
|
||||
final MapActivity mapActivity = getMapActivity();
|
||||
final ApplicationMode appMode = editingCtx.getSnapToRoadAppMode();
|
||||
if (mapActivity != null && appMode != null) {
|
||||
toolBarController.setTopBarSwitchVisible(true);
|
||||
toolBarController.setTopBarSwitchChecked(true);
|
||||
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_snap_to_road));
|
||||
|
||||
if (mapActivity != null) {
|
||||
Drawable icon;
|
||||
if (appMode == null) {
|
||||
icon = getActiveIcon(R.drawable.ic_action_split_interval);
|
||||
} else {
|
||||
icon = getIcon(appMode.getIconRes(), appMode.getIconColorInfo().getColor(nightMode));
|
||||
}
|
||||
ImageButton snapToRoadBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
|
||||
snapToRoadBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle);
|
||||
snapToRoadBtn.setImageDrawable(getIcon(appMode.getIconRes(), appMode.getIconColorInfo().getColor(nightMode)));
|
||||
snapToRoadBtn.setImageDrawable(icon);
|
||||
snapToRoadBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
@ -818,7 +853,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
});
|
||||
snapToRoadBtn.setVisibility(View.VISIBLE);
|
||||
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
@ -829,14 +863,25 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_ruler));
|
||||
editingCtx.setInSnapToRoadMode(false);
|
||||
editingCtx.cancelSnapToRoad();
|
||||
visibleSnapToRoadIcon(false);
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.GONE);
|
||||
mainView.findViewById(R.id.snap_to_road_progress_bar).setVisibility(View.GONE);
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
private void visibleSnapToRoadIcon(boolean show) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
if (show) {
|
||||
mapActivity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mapActivity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void displayRoutePoints() {
|
||||
final MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
|
||||
|
@ -851,11 +896,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
|
||||
private void displaySegmentPoints() {
|
||||
final MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
|
||||
TrkSegment segment = editingCtx.getNewGpxData().getTrkSegment();
|
||||
List<WptPt> points = segment.points;
|
||||
if (measurementLayer != null) {
|
||||
editingCtx.addPoints(points);
|
||||
editingCtx.addPoints();
|
||||
adapter.notifyDataSetChanged();
|
||||
updateText();
|
||||
}
|
||||
|
@ -898,6 +940,10 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
if (measurementLayer != null) {
|
||||
WptPt newPoint = measurementLayer.getMovedPointToApply();
|
||||
ApplicationMode applicationMode = editingCtx.getSnapToRoadAppMode();
|
||||
if (applicationMode != null) {
|
||||
newPoint.setProfileType(applicationMode.getStringKey());
|
||||
}
|
||||
WptPt oldPoint = editingCtx.getOriginalPointToMove();
|
||||
int position = editingCtx.getSelectedPointPosition();
|
||||
editingCtx.getCommandManager().execute(new MovePointCommand(measurementLayer, oldPoint, newPoint, position));
|
||||
|
@ -1309,6 +1355,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
editingCtx.exportRouteAsGpx(trackName, new MeasurementEditingContext.ExportAsGpxListener() {
|
||||
@Override
|
||||
public void onExportAsGpxFinished(GPXFile gpx) {
|
||||
gpx.addRoutePoints(editingCtx.getPoints());
|
||||
final Exception res = GPXUtilities.writeGpxFile(toSave, gpx);
|
||||
gpx.path = toSave.getAbsolutePath();
|
||||
OsmandApplication app = getMyApplication();
|
||||
|
@ -1404,9 +1451,17 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
if (openTrackActivity) {
|
||||
dismiss(activity);
|
||||
} else {
|
||||
Toast.makeText(activity,
|
||||
MessageFormat.format(getString(R.string.gpx_saved_sucessfully), toSave.getAbsolutePath()),
|
||||
Toast.LENGTH_LONG).show();
|
||||
snackbar = Snackbar.make(activity.getLayout(),
|
||||
MessageFormat.format(getString(R.string.gpx_saved_sucessfully), toSave.getName()),
|
||||
Snackbar.LENGTH_LONG)
|
||||
.setAction(R.string.shared_string_rename, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
FileUtils.renameFile(getActivity(), toSave, null);
|
||||
}
|
||||
});
|
||||
UiUtilities.setupSnackbar(snackbar, nightMode);
|
||||
snackbar.show();
|
||||
if (close) {
|
||||
dismiss(activity);
|
||||
}
|
||||
|
@ -1594,6 +1649,8 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
}
|
||||
if (editingCtx.isInSnapToRoadMode()) {
|
||||
disableSnapToRoadMode();
|
||||
} else {
|
||||
visibleSnapToRoadIcon(false);
|
||||
}
|
||||
if (editingCtx.getNewGpxData() != null) {
|
||||
GPXFile gpx = editingCtx.getNewGpxData().getGpxFile();
|
||||
|
|
|
@ -7,15 +7,15 @@ import android.graphics.Paint;
|
|||
import android.graphics.Path;
|
||||
import android.graphics.PointF;
|
||||
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadPoint;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.GPXUtilities.TrkSegment;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.views.ContextMenuLayer;
|
||||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
@ -207,9 +207,9 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
|||
WptPt lastPoint = editingCtx.getPoints().get(editingCtx.getPointsCount() - 1);
|
||||
LatLon centerLatLon = tb.getCenterLatLon();
|
||||
distance = (float) MapUtils.getDistance(
|
||||
lastPoint.lat, lastPoint.lon, centerLatLon.getLatitude(), centerLatLon.getLongitude());
|
||||
lastPoint.lat, lastPoint.lon, centerLatLon.getLatitude(), centerLatLon.getLongitude());
|
||||
bearing = getLocationFromLL(lastPoint.lat, lastPoint.lon)
|
||||
.bearingTo(getLocationFromLL(centerLatLon.getLatitude(), centerLatLon.getLongitude()));
|
||||
.bearingTo(getLocationFromLL(centerLatLon.getLatitude(), centerLatLon.getLongitude()));
|
||||
}
|
||||
measureDistanceToCenterListener.onMeasure(distance, bearing);
|
||||
}
|
||||
|
@ -231,13 +231,13 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
|||
float locY = tb.getPixYFromLatLon(pt.lat, pt.lon);
|
||||
tx.add(locX);
|
||||
ty.add(locY);
|
||||
tx.add((float)tb.getCenterPixelX());
|
||||
ty.add((float)tb.getCenterPixelY());
|
||||
tx.add((float) tb.getCenterPixelX());
|
||||
ty.add((float) tb.getCenterPixelY());
|
||||
}
|
||||
if (after.points.size() > 0) {
|
||||
if (before.points.size() == 0) {
|
||||
tx.add((float)tb.getCenterPixelX());
|
||||
ty.add((float)tb.getCenterPixelY());
|
||||
tx.add((float) tb.getCenterPixelX());
|
||||
ty.add((float) tb.getCenterPixelY());
|
||||
}
|
||||
WptPt pt = after.points.get(0);
|
||||
float locX = tb.getPixXFromLatLon(pt.lat, pt.lon);
|
||||
|
@ -322,6 +322,11 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
|||
pt.lon = l.getLongitude();
|
||||
boolean allowed = editingCtx.getPointsCount() == 0 || !editingCtx.getPoints().get(editingCtx.getPointsCount() - 1).equals(pt);
|
||||
if (allowed) {
|
||||
|
||||
ApplicationMode applicationMode = editingCtx.getSnapToRoadAppMode();
|
||||
if (applicationMode != null) {
|
||||
pt.setProfileType(applicationMode.getStringKey());
|
||||
}
|
||||
editingCtx.addPoint(pt);
|
||||
return pt;
|
||||
}
|
||||
|
@ -338,6 +343,10 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
|||
pressedPointLatLon = null;
|
||||
boolean allowed = editingCtx.getPointsCount() == 0 || !editingCtx.getPoints().get(editingCtx.getPointsCount() - 1).equals(pt);
|
||||
if (allowed) {
|
||||
ApplicationMode applicationMode = editingCtx.getSnapToRoadAppMode();
|
||||
if (applicationMode != null) {
|
||||
pt.setProfileType(applicationMode.getStringKey());
|
||||
}
|
||||
editingCtx.addPoint(pt);
|
||||
moveMapToLatLon(lat, lon);
|
||||
return pt;
|
||||
|
|
|
@ -6,7 +6,7 @@ import android.view.View;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithCompoundButton;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BottomSheetItemWithDescription;
|
||||
import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.DividerHalfItem;
|
||||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||
|
@ -27,19 +27,20 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
|||
@Override
|
||||
public void createMenuItems(Bundle savedInstanceState) {
|
||||
Bundle args = getArguments();
|
||||
boolean snapToRoadEnabled = args.getBoolean(SNAP_TO_ROAD_ENABLED_KEY);
|
||||
boolean addLineMode = args.getBoolean(ADD_LINE_MODE_KEY);
|
||||
boolean snapToRoadEnabled = false;
|
||||
boolean addLineMode = false;
|
||||
if (args != null) {
|
||||
snapToRoadEnabled = args.getBoolean(SNAP_TO_ROAD_ENABLED_KEY);
|
||||
addLineMode = args.getBoolean(ADD_LINE_MODE_KEY);
|
||||
}
|
||||
|
||||
items.add(new TitleItem(getString(R.string.shared_string_options)));
|
||||
|
||||
BaseBottomSheetItem snapToRoadItem = new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setChecked(snapToRoadEnabled)
|
||||
.setDescription(getString(snapToRoadEnabled ? R.string.shared_string_on : R.string.shared_string_off))
|
||||
.setIcon(snapToRoadEnabled
|
||||
? getActiveIcon(R.drawable.ic_action_snap_to_road)
|
||||
: getContentIcon(R.drawable.ic_action_snap_to_road))
|
||||
.setTitle(getString(R.string.snap_to_road))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_descr_and_switch_56dp)
|
||||
BaseBottomSheetItem snapToRoadItem = new BottomSheetItemWithDescription.Builder()
|
||||
.setDescription(getString(R.string.routing_profile_straightline))
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_split_interval))
|
||||
.setTitle(getString(R.string.route_between_points))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_descr_56dp)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -54,6 +55,24 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
|||
|
||||
items.add(new DividerHalfItem(getContext()));
|
||||
|
||||
BaseBottomSheetItem directions = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_gdirections_dark))
|
||||
.setTitle(getString(R.string.get_directions))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.directions();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(directions);
|
||||
|
||||
items.add(new DividerHalfItem(getContext()));
|
||||
|
||||
if (addLineMode && !snapToRoadEnabled) {
|
||||
BaseBottomSheetItem saveAsNewSegmentItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
|
||||
|
@ -72,21 +91,7 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
|||
items.add(saveAsNewSegmentItem);
|
||||
} else if (addLineMode) {
|
||||
|
||||
BaseBottomSheetItem saveAsNewTrackItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
|
||||
.setTitle(getString(R.string.shared_string_save_as_gpx))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.saveAsNewTrackOnClick();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(saveAsNewTrackItem);
|
||||
items.add(getSaveAsNewTrackItem());
|
||||
|
||||
BaseBottomSheetItem saveAsNewSegmentItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
|
||||
|
@ -104,25 +109,11 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
|||
.create();
|
||||
items.add(saveAsNewSegmentItem);
|
||||
} else {
|
||||
BaseBottomSheetItem saveAsNewTrackItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_polygom_dark))
|
||||
.setTitle(getString(R.string.shared_string_save_as_gpx))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.saveAsNewTrackOnClick();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
items.add(saveAsNewTrackItem);
|
||||
items.add(getSaveAsNewTrackItem());
|
||||
|
||||
BaseBottomSheetItem addToTrackItem = new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_split_interval))
|
||||
.setTitle(getString(R.string.add_segment_to_the_track))
|
||||
.setTitle(getString(R.string.add_to_a_track))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -156,6 +147,23 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
|||
items.add(clearAllItem);
|
||||
}
|
||||
|
||||
private BaseBottomSheetItem getSaveAsNewTrackItem() {
|
||||
return new SimpleBottomSheetItem.Builder()
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_save_to_file))
|
||||
.setTitle(getString(R.string.edit_filter_save_as_menu_item))
|
||||
.setLayoutId(R.layout.bottom_sheet_item_simple)
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.saveAsNewTrackOnClick();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
})
|
||||
.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDismissButtonTextId() {
|
||||
return R.string.shared_string_close;
|
||||
|
@ -165,6 +173,8 @@ public class OptionsBottomSheetDialogFragment extends MenuBottomSheetDialogFragm
|
|||
|
||||
void snapToRoadOnCLick();
|
||||
|
||||
void directions();
|
||||
|
||||
void addToGpxOnClick();
|
||||
|
||||
void saveAsNewTrackOnClick();
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.measurementtool;
|
|||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
@ -16,11 +17,12 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
|
|||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -28,12 +30,14 @@ import java.util.List;
|
|||
public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragment {
|
||||
|
||||
public static final String TAG = "SnapToRoadBottomSheetDialogFragment";
|
||||
public static final int STRAIGHT_LINE_TAG = -1;
|
||||
|
||||
private SnapToRoadFragmentListener listener;
|
||||
private boolean nightMode;
|
||||
private boolean portrait;
|
||||
private boolean snapToRoadEnabled;
|
||||
private boolean removeDefaultMode = true;
|
||||
private boolean showStraightLine = false;
|
||||
|
||||
public void setListener(SnapToRoadFragmentListener listener) {
|
||||
this.listener = listener;
|
||||
|
@ -43,6 +47,10 @@ public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragme
|
|||
this.removeDefaultMode = removeDefaultMode;
|
||||
}
|
||||
|
||||
public void setShowStraightLine(boolean showStraightLine) {
|
||||
this.showStraightLine = showStraightLine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupDialog(Dialog dialog, int style) {
|
||||
super.setupDialog(dialog, style);
|
||||
|
@ -77,23 +85,29 @@ public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragme
|
|||
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
snapToRoadEnabled = true;
|
||||
snapToRoadEnabled = false;
|
||||
if (listener != null) {
|
||||
listener.onApplicationModeItemClick(modes.get((int) view.getTag()));
|
||||
ApplicationMode mode = null;
|
||||
if ((int) view.getTag() != STRAIGHT_LINE_TAG) {
|
||||
mode = modes.get((int) view.getTag());
|
||||
snapToRoadEnabled = true;
|
||||
}
|
||||
listener.onApplicationModeItemClick(mode);
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
};
|
||||
|
||||
if (showStraightLine) {
|
||||
Drawable icon = app.getUIUtilities().getIcon(R.drawable.ic_action_split_interval, nightMode);
|
||||
addProfileView(container, onClickListener, STRAIGHT_LINE_TAG, icon,
|
||||
app.getText(R.string.routing_profile_straightline));
|
||||
}
|
||||
|
||||
for (int i = 0; i < modes.size(); i++) {
|
||||
ApplicationMode mode = modes.get(i);
|
||||
View row = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.list_item_icon_and_title, null);
|
||||
((ImageView) row.findViewById(R.id.icon)).setImageDrawable(
|
||||
app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
|
||||
((TextView) row.findViewById(R.id.title)).setText(mode.toHumanString());
|
||||
row.setOnClickListener(onClickListener);
|
||||
row.setTag(i);
|
||||
container.addView(row);
|
||||
Drawable icon = app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode));
|
||||
addProfileView(container, onClickListener, i, icon, mode.toHumanString());
|
||||
}
|
||||
|
||||
if (!portrait) {
|
||||
|
@ -111,6 +125,15 @@ public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragme
|
|||
((View) mainView.getParent()).setBackgroundResource(0);
|
||||
}
|
||||
|
||||
private void addProfileView(LinearLayout container, View.OnClickListener onClickListener, Object tag, Drawable icon, CharSequence title) {
|
||||
View row = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.list_item_icon_and_title, null);
|
||||
((ImageView) row.findViewById(R.id.icon)).setImageDrawable(icon);
|
||||
((TextView) row.findViewById(R.id.title)).setText(title);
|
||||
row.setOnClickListener(onClickListener);
|
||||
row.setTag(tag);
|
||||
container.addView(row);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
|
Loading…
Reference in a new issue