Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-09-15 11:15:08 +02:00
commit 27342be426
65 changed files with 3330 additions and 861 deletions

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="@color/dashboard_divider_light"/>
</shape>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/marker_circle_background_light_n"
android:insetBottom="14dp"
android:insetLeft="14dp"
android:insetRight="14dp"
android:insetTop="14dp"/>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/marker_circle_background_p_with_inset" android:state_pressed="true"/>
<item android:drawable="@drawable/marker_circle_background_light_n_with_inset"/>
</selector>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="@color/map_markers_on_map_color"/>
</shape>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/marker_circle_background_on_map_n"
android:insetBottom="14dp"
android:insetLeft="14dp"
android:insetRight="14dp"
android:insetTop="14dp"/>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/marker_circle_background_p_with_inset" android:state_pressed="true"/>
<item android:drawable="@drawable/marker_circle_background_on_map_n_with_inset"/>
</selector>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid
android:color="@color/map_widget_blue"/>
</shape>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/marker_circle_background_p"
android:insetBottom="14dp"
android:insetLeft="14dp"
android:insetRight="14dp"
android:insetTop="14dp">
</inset>

View file

@ -46,10 +46,10 @@
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_content_margin" android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
android:layout_marginLeft="@dimen/measurement_tool_content_margin" android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginRight="@dimen/measurement_tool_content_margin" android:layout_marginRight="@dimen/bottom_sheet_content_margin"
android:layout_marginStart="@dimen/measurement_tool_content_margin" android:layout_marginStart="@dimen/bottom_sheet_content_margin"
android:background="@null" android:background="@null"
tools:src="@drawable/ic_action_ruler"/> tools:src="@drawable/ic_action_ruler"/>
@ -60,10 +60,10 @@
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_content_margin" android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
android:layout_marginLeft="@dimen/measurement_tool_content_margin" android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginRight="@dimen/measurement_tool_content_margin" android:layout_marginRight="@dimen/bottom_sheet_content_margin"
android:layout_marginStart="@dimen/measurement_tool_content_margin" android:layout_marginStart="@dimen/bottom_sheet_content_margin"
android:background="@null" android:background="@null"
tools:src="@drawable/ic_action_arrow_down"/> tools:src="@drawable/ic_action_arrow_down"/>

View file

@ -4,7 +4,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="@dimen/measurement_tool_content_padding"> android:padding="@dimen/bottom_sheet_content_padding">
<TextView <TextView
android:layout_width="0dp" android:layout_width="0dp"
@ -16,7 +16,7 @@
android:id="@+id/toggle_show_on_map" android:id="@+id/toggle_show_on_map"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/measurement_tool_content_margin" android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginStart="@dimen/measurement_tool_content_margin"/> android:layout_marginStart="@dimen/bottom_sheet_content_margin"/>
</LinearLayout> </LinearLayout>

View file

@ -4,53 +4,65 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
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.v7.widget.Toolbar <android.support.design.widget.AppBarLayout
android:id="@+id/map_markers_toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar" android:layout_height="@dimen/dashboard_map_toolbar">
android:background="@color/osmand_orange"
android:minHeight="@dimen/dashboard_map_toolbar"
android:theme="?attr/toolbar_theme"
app:contentInsetLeft="54dp"
app:contentInsetStart="54dp">
<LinearLayout <android.support.v7.widget.Toolbar
android:id="@+id/map_markers_toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="match_parent"
android:gravity="center_vertical"> app:contentInsetLeft="54dp"
app:contentInsetStart="54dp">
<TextView <LinearLayout
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:gravity="center_vertical">
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:text="@string/map_markers"
android:textColor="@color/color_white"
android:textSize="@dimen/default_list_text_size_large"/>
<ImageButton <net.osmand.plus.widgets.TextViewEx
android:id="@+id/options_button" android:layout_width="0dp"
style="@style/Widget.AppCompat.ActionButton" android:layout_height="match_parent"
android:layout_width="48dp" android:layout_weight="1"
android:layout_height="48dp" android:ellipsize="end"
android:src="@drawable/ic_overflow_menu_white"/> android:gravity="center_vertical"
</LinearLayout> android:maxLines="1"
android:text="@string/map_markers"
android:textColor="@color/color_white"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/dialog_header_text_size"/>
</android.support.v7.widget.Toolbar> <ImageButton
android:id="@+id/options_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@drawable/ic_overflow_menu_white"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1"> android:layout_weight="1"
android:background="?attr/ctx_menu_info_view_bg">
<net.osmand.plus.LockableViewPager <!-- Coordinator layout is needed in order to display the snackbar above the bottom navigation -->
android:id="@+id/map_markers_view_pager" <android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="wrap_content">
<net.osmand.plus.LockableViewPager
android:id="@+id/map_markers_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</android.support.design.widget.CoordinatorLayout>
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
@ -67,7 +79,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/bg_color" android:background="?attr/bg_color"
app:itemBackground="?attr/bg_color" app:itemBackground="?attr/bg_color"
app:itemIconTint="@color/bottom_navigation_color_selector" app:itemIconTint="@drawable/bottom_navigation_color_selector"
app:itemTextColor="@color/bottom_navigation_color_selector" app:itemTextColor="@drawable/bottom_navigation_color_selector"
app:menu="@menu/map_markers_bottom_navigation"/> app:menu="@menu/map_markers_bottom_navigation"/>
</LinearLayout> </LinearLayout>

View file

@ -0,0 +1,164 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:background="?attr/bg_color"
android:orientation="vertical">
<ScrollView
android:id="@+id/history_marker_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_selected_item_title_height"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView
android:id="@+id/map_marker_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_flag_dark"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/map_marker_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:textStyle="bold"
android:textSize="@dimen/default_list_text_size"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="Bloemstraat 179"/>
<net.osmand.plus.widgets.TextViewEx
osmand:typeface="@string/font_roboto_regular"
android:id="@+id/map_marker_passed_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
tools:text="Passed: July 28"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:id="@+id/make_active_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:layout_marginTop="@dimen/bottom_sheet_content_margin_small"
android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView
android:id="@+id/make_active_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_reset_to_default_dark"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/make_active"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</LinearLayout>
<LinearLayout
android:id="@+id/delete_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView
android:id="@+id/delete_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_delete_dark"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/shared_string_delete"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout
android:id="@+id/cancel_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
<TextView
android:id="@+id/cancel_row_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/shared_string_close"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout>

View file

@ -21,34 +21,34 @@
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_title_height" android:layout_height="@dimen/bottom_sheet_title_height"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding" android:paddingStart="@dimen/bottom_sheet_content_padding"
android:text="@string/marker_options" android:text="@string/shared_string_options"
android:textAppearance="@style/TextAppearance.ListItemTitle" android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/> osmand:typeface="@string/font_roboto_medium"/>
<LinearLayout <LinearLayout
android:id="@+id/sort_by_row" android:id="@+id/sort_by_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/sort_by_icon" android:id="@+id/sort_by_icon"
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_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_sort_waypoint_dark"/> tools:src="@drawable/ic_sort_waypoint_dark"/>
<TextView <TextView
@ -63,22 +63,22 @@
<LinearLayout <LinearLayout
android:id="@+id/show_direction_row" android:id="@+id/show_direction_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/show_direction_icon" android:id="@+id/show_direction_icon"
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_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_sort_waypoint_dark"/> tools:background="@drawable/ic_action_device_top"/>
<TextView <TextView
android:layout_width="0dp" android:layout_width="0dp"
@ -113,21 +113,21 @@
<LinearLayout <LinearLayout
android:id="@+id/build_route_row" android:id="@+id/build_route_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/build_route_icon" android:id="@+id/build_route_icon"
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_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/map_directions"/> tools:src="@drawable/map_directions"/>
<TextView <TextView
@ -142,21 +142,21 @@
<LinearLayout <LinearLayout
android:id="@+id/save_as_new_track_row" android:id="@+id/save_as_new_track_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/save_as_new_track_icon" android:id="@+id/save_as_new_track_icon"
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_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_polygom_dark"/> tools:src="@drawable/ic_action_polygom_dark"/>
<TextView <TextView
@ -180,21 +180,21 @@
<LinearLayout <LinearLayout
android:id="@+id/move_all_to_history_row" android:id="@+id/move_all_to_history_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/move_all_to_history_icon" android:id="@+id/move_all_to_history_icon"
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_history2"/> tools:src="@drawable/ic_action_history2"/>
<TextView <TextView
@ -218,7 +218,7 @@
<FrameLayout <FrameLayout
android:id="@+id/cancel_row" android:id="@+id/cancel_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measure_distance_bottom_sheet_cancel_button_height" android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground"> android:background="?attr/selectableItemBackground">
<TextView <TextView

View file

@ -0,0 +1,275 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<ScrollView
android:id="@+id/marker_show_direction_scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/show_direction_title"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_title_height"
android:gravity="center_vertical"
android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding"
android:text="@string/show_direction"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/>
<TextView
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_descr_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:text="@string/measurement_tool_save_as_new_track_descr"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/>
<LinearLayout
android:id="@+id/images_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/bottom_sheet_content_margin"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_content_margin_small"
android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginRight="@dimen/bottom_sheet_content_margin_small"
android:layout_marginStart="@dimen/bottom_sheet_content_margin"
android:layout_weight="1">
<ImageView
android:id="@+id/top_bar_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
android:foreground="?attr/selectableItemBackground"
tools:src="@drawable/img_help_trip_route_points_night"/>
<TextView
android:id="@+id/top_bar_image_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/top_bar_image"
android:layout_alignStart="@id/top_bar_image"
android:layout_marginLeft="@dimen/bottom_sheet_image_text_margin_start"
android:layout_marginStart="@dimen/bottom_sheet_image_text_margin_start"
android:layout_marginTop="@dimen/bottom_sheet_content_margin_small"
android:text="@string/top_bar"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_split_segments_sub"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
android:layout_marginLeft="@dimen/bottom_sheet_content_margin_small"
android:layout_marginRight="@dimen/bottom_sheet_content_margin"
android:layout_marginStart="@dimen/bottom_sheet_content_margin_small"
android:layout_weight="1">
<ImageView
android:id="@+id/widget_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:adjustViewBounds="true"
android:foreground="?attr/selectableItemBackground"
tools:src="@drawable/img_help_trip_track_night"/>
<TextView
android:id="@+id/widget_image_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/widget_image"
android:layout_alignStart="@id/widget_image"
android:layout_marginLeft="@dimen/bottom_sheet_image_text_margin_start"
android:layout_marginStart="@dimen/bottom_sheet_image_text_margin_start"
android:layout_marginTop="@dimen/bottom_sheet_content_margin_small"
android:text="@string/widget"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_split_segments_sub"/>
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:id="@+id/top_bar_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:foreground="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView
android:id="@+id/top_bar_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:background="@drawable/ic_action_device_top"
tools:src="@drawable/ic_action_device_topbar"/>
<TextView
android:id="@+id/top_bar_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/top_bar_icon"
android:layout_toRightOf="@id/top_bar_icon"
android:maxLines="1"
android:text="@string/top_bar"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<RadioButton
android:focusable="false"
android:clickable="false"
android:background="@null"
android:id="@+id/top_bar_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/widget_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:foreground="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView
android:id="@+id/widget_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:background="@drawable/ic_action_device_top"
tools:src="@drawable/ic_action_device_widget"/>
<TextView
android:id="@+id/widget_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/widget_icon"
android:layout_toRightOf="@id/widget_icon"
android:maxLines="1"
android:text="@string/widget"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<RadioButton
android:focusable="false"
android:clickable="false"
android:background="@null"
android:id="@+id/widget_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/none_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
android:foreground="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView
android:id="@+id/none_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:background="@drawable/ic_action_device_top"/>
<TextView
android:id="@+id/none_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@id/none_icon"
android:layout_toRightOf="@id/none_icon"
android:maxLines="1"
android:text="@string/shared_string_none"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<RadioButton
android:focusable="false"
android:clickable="false"
android:background="@null"
android:id="@+id/none_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout
android:id="@+id/cancel_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/shared_string_cancel"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout>

View file

@ -41,10 +41,10 @@
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_content_margin" android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
android:layout_marginLeft="@dimen/measurement_tool_content_margin" android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginRight="@dimen/measurement_tool_content_margin" android:layout_marginRight="@dimen/bottom_sheet_content_margin"
android:layout_marginStart="@dimen/measurement_tool_content_margin" android:layout_marginStart="@dimen/bottom_sheet_content_margin"
android:background="@null" android:background="@null"
tools:src="@drawable/ic_action_ruler"/> tools:src="@drawable/ic_action_ruler"/>
@ -55,10 +55,10 @@
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_content_margin" android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
android:layout_marginLeft="@dimen/measurement_tool_content_margin" android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginRight="@dimen/measurement_tool_content_margin" android:layout_marginRight="@dimen/bottom_sheet_content_margin"
android:layout_marginStart="@dimen/measurement_tool_content_margin" android:layout_marginStart="@dimen/bottom_sheet_content_margin"
android:background="@null" android:background="@null"
tools:src="@drawable/ic_action_arrow_down"/> tools:src="@drawable/ic_action_arrow_down"/>

View file

@ -22,12 +22,12 @@
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/options_title" android:id="@+id/options_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_title_height" android:layout_height="@dimen/bottom_sheet_title_height"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding" android:paddingStart="@dimen/bottom_sheet_content_padding"
android:text="@string/shared_string_options" android:text="@string/shared_string_options"
android:textAppearance="@style/TextAppearance.ListItemTitle" android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/> osmand:typeface="@string/font_roboto_medium"/>
@ -35,21 +35,21 @@
<RelativeLayout <RelativeLayout
android:id="@+id/snap_to_road_row" android:id="@+id/snap_to_road_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/snap_to_road_icon" android:id="@+id/snap_to_road_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_snap_to_road"/> tools:src="@drawable/ic_action_snap_to_road"/>
<android.support.v7.widget.SwitchCompat <android.support.v7.widget.SwitchCompat
@ -59,8 +59,8 @@
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/measurement_tool_content_margin" android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginStart="@dimen/measurement_tool_content_margin" android:layout_marginStart="@dimen/bottom_sheet_content_margin"
android:background="@null" android:background="@null"
android:clickable="false" android:clickable="false"
android:focusable="false" android:focusable="false"
@ -108,13 +108,13 @@
<RelativeLayout <RelativeLayout
android:id="@+id/save_as_new_segment_row" android:id="@+id/save_as_new_segment_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding" android:paddingStart="@dimen/bottom_sheet_content_padding"
android:visibility="gone"> android:visibility="gone">
<ImageView <ImageView
@ -122,8 +122,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_polygom_dark"/> tools:src="@drawable/ic_action_polygom_dark"/>
<TextView <TextView
@ -140,21 +140,21 @@
<RelativeLayout <RelativeLayout
android:id="@+id/save_as_new_track_row" android:id="@+id/save_as_new_track_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/save_as_new_track_icon" android:id="@+id/save_as_new_track_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_polygom_dark"/> tools:src="@drawable/ic_action_polygom_dark"/>
<TextView <TextView
@ -171,21 +171,21 @@
<RelativeLayout <RelativeLayout
android:id="@+id/add_to_the_track_row" android:id="@+id/add_to_the_track_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/add_to_the_track_icon" android:id="@+id/add_to_the_track_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_split_interval"/> tools:src="@drawable/ic_action_split_interval"/>
<TextView <TextView
@ -211,21 +211,21 @@
<RelativeLayout <RelativeLayout
android:id="@+id/clear_all_row" android:id="@+id/clear_all_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/clear_all_icon" android:id="@+id/clear_all_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_reset_to_default_dark"/> tools:src="@drawable/ic_action_reset_to_default_dark"/>
<TextView <TextView
@ -251,7 +251,7 @@
<FrameLayout <FrameLayout
android:id="@+id/cancel_row" android:id="@+id/cancel_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measure_distance_bottom_sheet_cancel_button_height" android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground"> android:background="?attr/selectableItemBackground">
<TextView <TextView

View file

@ -16,28 +16,28 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="@dimen/measurement_tool_content_padding_small"> android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/save_as_new_track_title" android:id="@+id/save_as_new_track_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_title_height" android:layout_height="@dimen/bottom_sheet_title_height"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding" android:paddingStart="@dimen/bottom_sheet_content_padding"
android:text="@string/shared_string_save_as_gpx" android:text="@string/shared_string_save_as_gpx"
android:textAppearance="@style/TextAppearance.ListItemTitle" android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/> osmand:typeface="@string/font_roboto_medium"/>
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_descr_height" android:layout_height="@dimen/bottom_sheet_descr_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding" android:paddingStart="@dimen/bottom_sheet_content_padding"
android:text="@string/measurement_tool_save_as_new_track_descr" android:text="@string/measurement_tool_save_as_new_track_descr"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/> android:textSize="@dimen/default_desc_text_size"/>
@ -46,16 +46,16 @@
android:id="@+id/images_row" android:id="@+id/images_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="16dp" android:layout_marginBottom="@dimen/bottom_sheet_content_margin"
android:orientation="horizontal"> android:orientation="horizontal">
<RelativeLayout <RelativeLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/measurement_tool_content_margin_small" android:layout_marginEnd="@dimen/bottom_sheet_content_margin_small"
android:layout_marginLeft="@dimen/measurement_tool_content_margin" android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginRight="@dimen/measurement_tool_content_margin_small" android:layout_marginRight="@dimen/bottom_sheet_content_margin_small"
android:layout_marginStart="@dimen/measurement_tool_content_margin" android:layout_marginStart="@dimen/bottom_sheet_content_margin"
android:layout_weight="1"> android:layout_weight="1">
<ImageView <ImageView
@ -73,9 +73,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignLeft="@id/route_point_image" android:layout_alignLeft="@id/route_point_image"
android:layout_alignStart="@id/route_point_image" android:layout_alignStart="@id/route_point_image"
android:layout_marginLeft="@dimen/measurement_tool_bottom_image_text_margin_start" android:layout_marginLeft="@dimen/bottom_sheet_image_text_margin_start"
android:layout_marginStart="@dimen/measurement_tool_bottom_image_text_margin_start" android:layout_marginStart="@dimen/bottom_sheet_image_text_margin_start"
android:layout_marginTop="@dimen/measurement_tool_content_margin_small" android:layout_marginTop="@dimen/bottom_sheet_content_margin_small"
android:text="@string/route_point" android:text="@string/route_point"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_split_segments_sub"/> android:textSize="@dimen/default_split_segments_sub"/>
@ -84,10 +84,10 @@
<RelativeLayout <RelativeLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/measurement_tool_content_margin" android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
android:layout_marginLeft="@dimen/measurement_tool_content_margin_small" android:layout_marginLeft="@dimen/bottom_sheet_content_margin_small"
android:layout_marginRight="@dimen/measurement_tool_content_margin" android:layout_marginRight="@dimen/bottom_sheet_content_margin"
android:layout_marginStart="@dimen/measurement_tool_content_margin_small" android:layout_marginStart="@dimen/bottom_sheet_content_margin_small"
android:layout_weight="1"> android:layout_weight="1">
<ImageView <ImageView
@ -105,9 +105,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignLeft="@id/line_image" android:layout_alignLeft="@id/line_image"
android:layout_alignStart="@id/line_image" android:layout_alignStart="@id/line_image"
android:layout_marginLeft="@dimen/measurement_tool_bottom_image_text_margin_start" android:layout_marginLeft="@dimen/bottom_sheet_image_text_margin_start"
android:layout_marginStart="@dimen/measurement_tool_bottom_image_text_margin_start" android:layout_marginStart="@dimen/bottom_sheet_image_text_margin_start"
android:layout_marginTop="@dimen/measurement_tool_content_margin_small" android:layout_marginTop="@dimen/bottom_sheet_content_margin_small"
android:text="@string/line" android:text="@string/line"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_split_segments_sub"/> android:textSize="@dimen/default_split_segments_sub"/>
@ -118,21 +118,21 @@
<RelativeLayout <RelativeLayout
android:id="@+id/save_as_route_point_row" android:id="@+id/save_as_route_point_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/route_point_icon" android:id="@+id/route_point_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_route_points"/> tools:src="@drawable/ic_action_route_points"/>
<TextView <TextView
@ -149,21 +149,21 @@
<RelativeLayout <RelativeLayout
android:id="@+id/save_as_line_row" android:id="@+id/save_as_line_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/line_icon" android:id="@+id/line_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_split_interval"/> tools:src="@drawable/ic_action_split_interval"/>
<TextView <TextView
@ -189,7 +189,7 @@
<FrameLayout <FrameLayout
android:id="@+id/cancel_row" android:id="@+id/cancel_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measure_distance_bottom_sheet_cancel_button_height" android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground"> android:background="?attr/selectableItemBackground">
<TextView <TextView

View file

@ -16,24 +16,24 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="@dimen/measurement_tool_content_padding_small"> android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_selected_point_title_height" android:layout_height="@dimen/bottom_sheet_selected_item_title_height"
android:minHeight="@dimen/measurement_tool_selected_point_title_height" android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/selected_point_icon" android:id="@+id/selected_point_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_measure_point"/> tools:src="@drawable/ic_action_measure_point"/>
<LinearLayout <LinearLayout
@ -74,8 +74,8 @@
android:textAppearance="@style/TextAppearance.ListItemTitle" android:textAppearance="@style/TextAppearance.ListItemTitle"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_list_text_size"
android:layout_marginLeft="@dimen/measurement_tool_content_margin_small" android:layout_marginLeft="@dimen/bottom_sheet_content_margin_small"
android:layout_marginRight="@dimen/measurement_tool_content_margin_small" android:layout_marginRight="@dimen/bottom_sheet_content_margin_small"
tools:text="A: 345 m"/> tools:text="A: 345 m"/>
<android.support.v7.widget.AppCompatTextView <android.support.v7.widget.AppCompatTextView
@ -101,21 +101,21 @@
<RelativeLayout <RelativeLayout
android:id="@+id/move_point_row" android:id="@+id/move_point_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/move_point_icon" android:id="@+id/move_point_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_move_point"/> tools:src="@drawable/ic_action_move_point"/>
<TextView <TextView
@ -132,21 +132,21 @@
<RelativeLayout <RelativeLayout
android:id="@+id/delete_point_row" android:id="@+id/delete_point_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/delete_point_icon" android:id="@+id/delete_point_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_remove_dark"/> tools:src="@drawable/ic_action_remove_dark"/>
<TextView <TextView
@ -172,21 +172,21 @@
<RelativeLayout <RelativeLayout
android:id="@+id/add_point_after_row" android:id="@+id/add_point_after_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/add_point_after_icon" android:id="@+id/add_point_after_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_addpoint_above"/> tools:src="@drawable/ic_action_addpoint_above"/>
<TextView <TextView
@ -203,21 +203,21 @@
<RelativeLayout <RelativeLayout
android:id="@+id/add_point_before_row" android:id="@+id/add_point_before_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/add_point_before_icon" android:id="@+id/add_point_before_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_addpoint_below"/> tools:src="@drawable/ic_action_addpoint_below"/>
<TextView <TextView
@ -243,7 +243,7 @@
<FrameLayout <FrameLayout
android:id="@+id/cancel_row" android:id="@+id/cancel_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measure_distance_bottom_sheet_cancel_button_height" android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground"> android:background="?attr/selectableItemBackground">
<TextView <TextView

View file

@ -16,27 +16,27 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="@dimen/measurement_tool_content_padding_small"> android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
<TextView <TextView
android:id="@+id/choose_navigation_title" android:id="@+id/choose_navigation_title"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_title_height" android:layout_height="@dimen/bottom_sheet_title_height"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding" android:paddingStart="@dimen/bottom_sheet_content_padding"
android:text="@string/choose_navigation_type" android:text="@string/choose_navigation_type"
android:textAppearance="@style/TextAppearance.ListItemTitle"/> android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_descr_height" android:layout_height="@dimen/bottom_sheet_descr_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding" android:paddingStart="@dimen/bottom_sheet_content_padding"
android:text="@string/measurement_tool_snap_to_road_descr" android:text="@string/measurement_tool_snap_to_road_descr"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/> android:textSize="@dimen/default_desc_text_size"/>
@ -50,7 +50,7 @@
<FrameLayout <FrameLayout
android:id="@+id/cancel_row" android:id="@+id/cancel_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measure_distance_bottom_sheet_cancel_button_height" android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground"> android:background="?attr/selectableItemBackground">
<TextView <TextView

View file

@ -3,21 +3,21 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_bottom_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/measurement_tool_bottom_list_item_height" android:minHeight="@dimen/bottom_sheet_list_item_height"
android:paddingEnd="@dimen/measurement_tool_content_padding" android:paddingEnd="@dimen/bottom_sheet_content_padding"
android:paddingLeft="@dimen/measurement_tool_content_padding" android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/measurement_tool_content_padding" android:paddingRight="@dimen/bottom_sheet_content_padding"
android:paddingStart="@dimen/measurement_tool_content_padding"> android:paddingStart="@dimen/bottom_sheet_content_padding">
<ImageView <ImageView
android:id="@+id/icon" android:id="@+id/icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/measurement_tool_bottom_icon_margin" android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:src="@drawable/ic_action_car_dark"/> tools:src="@drawable/ic_action_car_dark"/>
<TextView <TextView

View file

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants">
<include layout="@layout/list_item_divider"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:background="?attr/bg_color">
<android.support.v7.widget.AppCompatTextView
android:id="@+id/date_title"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:gravity="center_vertical"
tools:text="Today"/>
<ImageButton
android:id="@+id/date_options_button"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical|end"
android:background="@null"
android:focusableInTouchMode="true"
tools:src="@drawable/ic_overflow_menu_white"/>
</LinearLayout>
</LinearLayout>

View file

@ -1,123 +1,154 @@
<?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:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="wrap_content"
android:background="?attr/bg_color" android:descendantFocusability="blocksDescendants"
android:descendantFocusability="blocksDescendants"> android:orientation="vertical">
<LinearLayout <LinearLayout
android:id="@+id/main_layout"
android:background="?attr/bg_color"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content">
android:background="?attr/selectableItemBackground">
<android.support.v7.widget.AppCompatImageView
android:id="@+id/map_marker_reorder_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingStart="16dp"
android:paddingTop="16dp"
android:tint="?attr/secondary_icon_color"
tools:src="@drawable/ic_action_reorder"/>
<android.support.v7.widget.AppCompatImageView
android:id="@+id/map_marker_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
tools:src="@drawable/ic_action_flag_dark"/>
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="56dp"
android:layout_gravity="center_vertical" android:background="?attr/selectableItemBackground">
android:layout_weight="1"
android:orientation="vertical">
<android.support.v7.widget.AppCompatTextView <android.support.v7.widget.AppCompatImageView
android:id="@+id/map_marker_title" android:id="@+id/map_marker_reorder_icon"
android:layout_width="match_parent" android:layout_width="56dp"
android:layout_height="wrap_content" android:layout_height="56dp"
android:textColor="?android:textColorPrimary" android:scaleType="centerInside"
android:textSize="@dimen/default_desc_text_size" android:layout_gravity="center_vertical"
tools:text="Van Gogh Museum"/> android:tint="?attr/secondary_icon_color"
tools:src="@drawable/ic_action_reorder"/>
<View
tools:visibility="visible"
android:visibility="gone"
android:id="@+id/flag_icon_left_space"
android:layout_width="16dp"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatImageView
android:id="@+id/map_marker_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="16dp"
android:layout_marginEnd="16dp"
tools:src="@drawable/ic_action_flag_dark"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content"> android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageView <LinearLayout
android:id="@+id/map_marker_direction_icon" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="28dp">
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
tools:src="@drawable/ic_direction_arrow"/>
<android.support.v7.widget.AppCompatTextView <android.support.v7.widget.AppCompatTextView
android:id="@+id/map_marker_distance" android:layout_marginBottom="2dp"
android:layout_width="wrap_content" android:layout_gravity="bottom"
android:layout_height="wrap_content" android:id="@+id/map_marker_title"
android:layout_gravity="center_vertical" android:layout_width="match_parent"
android:layout_marginLeft="4dp" android:layout_height="wrap_content"
android:layout_marginRight="4dp" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textSize="@dimen/default_sub_text_size" android:textColor="?android:textColorPrimary"
tools:text="213 m"/> android:textSize="@dimen/default_list_text_size"
tools:text="Van Gogh Museum"/>
<android.support.v7.widget.AppCompatTextView </LinearLayout>
android:id="@+id/map_marker_point_text_view"
android:layout_width="wrap_content" <LinearLayout
android:layout_height="wrap_content" android:layout_marginTop="1dp"
android:layout_gravity="center_vertical" android:layout_width="match_parent"
android:text="•" android:layout_height="wrap_content">
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size" <ImageView
android:visibility="gone" android:id="@+id/map_marker_direction_icon"
tools:visibility="visible"/> android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginRight="4dp"
android:layout_marginEnd="4dp"
tools:src="@drawable/ic_direction_arrow"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/map_marker_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:maxLines="1"
android:textSize="@dimen/default_desc_text_size"
tools:text="213 m"/>
<View
android:id="@+id/map_marker_left_point_space"
android:layout_width="4dp"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/map_marker_point_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="•"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
android:visibility="gone"
tools:visibility="visible"/>
<View
android:id="@+id/map_marker_right_point_space"
android:layout_width="4dp"
android:layout_height="wrap_content"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/map_marker_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"
tools:text="Amsterdam Weekend"/>
</LinearLayout>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/map_marker_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"
tools:text="Amsterdam Weekend"/>
</LinearLayout> </LinearLayout>
<ImageButton
android:id="@+id/map_marker_options_button"
android:layout_width="56dp"
android:layout_height="56dp"
android:background="@drawable/marker_circle_background_light_with_inset"
android:focusableInTouchMode="true"
tools:src="@drawable/ic_action_marker_passed"/>
</LinearLayout> </LinearLayout>
<ImageButton <View
android:id="@+id/map_marker_options_button" android:id="@+id/divider"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="1dp"
android:layout_gravity="center_vertical|end" android:layout_marginLeft="56dp"
android:background="?attr/selectableItemBackground" android:layout_marginStart="56dp"
android:focusableInTouchMode="true" android:background="?attr/dashboard_divider"/>
android:paddingBottom="16dp"
android:paddingLeft="14dp"
android:paddingRight="14dp"
android:paddingTop="16dp"
tools:src="@drawable/ic_overflow_menu_white"/>
</LinearLayout> </LinearLayout>
<View <include layout="@layout/card_bottom_divider"
android:layout_width="wrap_content" tools:visibility="visible"
android:layout_height="1dp" android:visibility="gone"
android:layout_gravity="bottom" android:id="@+id/bottom_shadow"/>
android:layout_marginLeft="56dp"
android:layout_marginStart="56dp"
android:background="?attr/dashboard_divider"/>
</FrameLayout> </LinearLayout>

View file

@ -9,21 +9,21 @@
android:id="@+id/gpx_name_et" android:id="@+id/gpx_name_et"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/measurement_tool_content_margin" android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
android:layout_marginLeft="@dimen/measurement_tool_content_margin" android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginRight="@dimen/measurement_tool_content_margin" android:layout_marginRight="@dimen/bottom_sheet_content_margin"
android:layout_marginStart="@dimen/measurement_tool_content_margin" android:layout_marginStart="@dimen/bottom_sheet_content_margin"
android:layout_marginTop="@dimen/measurement_tool_content_margin" android:layout_marginTop="@dimen/bottom_sheet_content_margin"
android:inputType="text"/> android:inputType="text"/>
<TextView <TextView
android:id="@+id/file_exists_text_view" android:id="@+id/file_exists_text_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/measurement_tool_content_margin" android:layout_marginEnd="@dimen/bottom_sheet_content_margin"
android:layout_marginLeft="@dimen/measurement_tool_content_margin" android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginRight="@dimen/measurement_tool_content_margin" android:layout_marginRight="@dimen/bottom_sheet_content_margin"
android:layout_marginStart="@dimen/measurement_tool_content_margin" android:layout_marginStart="@dimen/bottom_sheet_content_margin"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:text="@string/file_with_name_already_exists" android:text="@string/file_with_name_already_exists"
android:textColor="@color/marker_red" android:textColor="@color/marker_red"
@ -38,7 +38,7 @@
<RelativeLayout <RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="@dimen/measurement_tool_content_padding"> android:padding="@dimen/bottom_sheet_content_padding">
<android.support.v7.widget.SwitchCompat <android.support.v7.widget.SwitchCompat
android:id="@+id/toggle_show_on_map" android:id="@+id/toggle_show_on_map"
@ -47,8 +47,8 @@
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/measurement_tool_content_margin" android:layout_marginLeft="@dimen/bottom_sheet_content_margin"
android:layout_marginStart="@dimen/measurement_tool_content_margin"/> android:layout_marginStart="@dimen/bottom_sheet_content_margin"/>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"

View file

@ -2,8 +2,13 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <menu xmlns:android="http://schemas.android.com/apk/res/android">
<item <item
android:id="@+id/action_active" android:id="@+id/action_active"
android:icon="@drawable/ic_map" android:icon="@drawable/ic_action_markers_list"
android:title="@string/osm_live_active"/> android:title="@string/shared_string_list"/>
<item
android:id="@+id/action_groups"
android:icon="@drawable/ic_action_folder"
android:title="@string/shared_string_groups" />
<item <item
android:id="@+id/action_history" android:id="@+id/action_history"

View file

@ -91,14 +91,14 @@
<dimen name="my_places_empty_state_text_button_padding_right">90dp</dimen> <dimen name="my_places_empty_state_text_button_padding_right">90dp</dimen>
<dimen name="my_places_empty_state_text_button_padding_top">96dp</dimen> <dimen name="my_places_empty_state_text_button_padding_top">96dp</dimen>
<dimen name="measure_distance_bottom_sheet_cancel_button_height">72dp</dimen> <dimen name="bottom_sheet_cancel_button_height">72dp</dimen>
<dimen name="landscape_bottom_sheet_dialog_fragment_width">540dp</dimen> <dimen name="landscape_bottom_sheet_dialog_fragment_width">540dp</dimen>
<dimen name="measurement_tool_select_radius">30dp</dimen> <dimen name="measurement_tool_select_radius">30dp</dimen>
<dimen name="measurement_tool_content_margin">24dp</dimen> <dimen name="bottom_sheet_content_margin">24dp</dimen>
<dimen name="measurement_tool_content_margin_small">12dp</dimen> <dimen name="bottom_sheet_content_margin_small">12dp</dimen>
<dimen name="measurement_tool_content_padding">24dp</dimen> <dimen name="bottom_sheet_content_padding">24dp</dimen>
<dimen name="measurement_tool_content_padding_small">12dp</dimen> <dimen name="bottom_sheet_content_padding_small">12dp</dimen>
<dimen name="measurement_tool_divider_margin">12dp</dimen> <dimen name="measurement_tool_divider_margin">12dp</dimen>
<dimen name="measurement_tool_content_padding_medium">18dp</dimen> <dimen name="measurement_tool_content_padding_medium">18dp</dimen>
<dimen name="measurement_tool_text_margin_small">6dp</dimen> <dimen name="measurement_tool_text_margin_small">6dp</dimen>
@ -113,14 +113,14 @@
<dimen name="measurement_tool_button_margin">12dp</dimen> <dimen name="measurement_tool_button_margin">12dp</dimen>
<dimen name="measurement_tool_button_padding">12dp</dimen> <dimen name="measurement_tool_button_padding">12dp</dimen>
<dimen name="measurement_tool_button_height">54dp</dimen> <dimen name="measurement_tool_button_height">54dp</dimen>
<dimen name="measurement_tool_bottom_title_height">78dp</dimen> <dimen name="bottom_sheet_title_height">78dp</dimen>
<dimen name="measurement_tool_bottom_descr_height">66dp</dimen> <dimen name="bottom_sheet_descr_height">66dp</dimen>
<dimen name="measurement_tool_bottom_list_item_height">72dp</dimen> <dimen name="bottom_sheet_list_item_height">72dp</dimen>
<dimen name="measurement_tool_bottom_icon_margin">36dp</dimen> <dimen name="bottom_sheet_icon_margin">36dp</dimen>
<dimen name="measurement_tool_bottom_divider_margin_top">11dp</dimen> <dimen name="measurement_tool_bottom_divider_margin_top">11dp</dimen>
<dimen name="measurement_tool_bottom_divider_margin_bottom">12dp</dimen> <dimen name="measurement_tool_bottom_divider_margin_bottom">12dp</dimen>
<dimen name="measurement_tool_bottom_divider_margin_start">96dp</dimen> <dimen name="measurement_tool_bottom_divider_margin_start">96dp</dimen>
<dimen name="measurement_tool_bottom_image_text_margin_start">15dp</dimen> <dimen name="bottom_sheet_image_text_margin_start">15dp</dimen>
<dimen name="measurement_tool_selected_point_title_height">84dp</dimen> <dimen name="bottom_sheet_selected_item_title_height">84dp</dimen>
</resources> </resources>

View file

@ -258,5 +258,8 @@
<color name="map_background_color_dark">#101821</color> <color name="map_background_color_dark">#101821</color>
<color name="fab_green">#46bd2a</color> <color name="fab_green">#46bd2a</color>
<color name="map_markers_on_map_divider_color">#0d464a</color>
<color name="map_markers_on_map_color">#17828a</color>
<color name="show_direction_menu_selected_item_bg">#f2f4ff</color>
</resources> </resources>

View file

@ -156,14 +156,14 @@
<dimen name="my_places_empty_state_text_button_padding_right">60dp</dimen> <dimen name="my_places_empty_state_text_button_padding_right">60dp</dimen>
<dimen name="my_places_empty_state_text_button_padding_top">64dp</dimen> <dimen name="my_places_empty_state_text_button_padding_top">64dp</dimen>
<dimen name="measure_distance_bottom_sheet_cancel_button_height">48dp</dimen> <dimen name="bottom_sheet_cancel_button_height">48dp</dimen>
<dimen name="landscape_bottom_sheet_dialog_fragment_width">360dp</dimen> <dimen name="landscape_bottom_sheet_dialog_fragment_width">360dp</dimen>
<dimen name="measurement_tool_select_radius">20dp</dimen> <dimen name="measurement_tool_select_radius">20dp</dimen>
<dimen name="measurement_tool_content_margin">16dp</dimen> <dimen name="bottom_sheet_content_margin">16dp</dimen>
<dimen name="measurement_tool_content_margin_small">8dp</dimen> <dimen name="bottom_sheet_content_margin_small">8dp</dimen>
<dimen name="measurement_tool_content_padding">16dp</dimen> <dimen name="bottom_sheet_content_padding">16dp</dimen>
<dimen name="measurement_tool_content_padding_small">8dp</dimen> <dimen name="bottom_sheet_content_padding_small">8dp</dimen>
<dimen name="measurement_tool_divider_margin">8dp</dimen> <dimen name="measurement_tool_divider_margin">8dp</dimen>
<dimen name="measurement_tool_content_padding_medium">12dp</dimen> <dimen name="measurement_tool_content_padding_medium">12dp</dimen>
<dimen name="measurement_tool_text_margin_small">4dp</dimen> <dimen name="measurement_tool_text_margin_small">4dp</dimen>
@ -178,13 +178,13 @@
<dimen name="measurement_tool_button_margin">8dp</dimen> <dimen name="measurement_tool_button_margin">8dp</dimen>
<dimen name="measurement_tool_button_padding">8dp</dimen> <dimen name="measurement_tool_button_padding">8dp</dimen>
<dimen name="measurement_tool_button_height">36dp</dimen> <dimen name="measurement_tool_button_height">36dp</dimen>
<dimen name="measurement_tool_bottom_title_height">52dp</dimen> <dimen name="bottom_sheet_title_height">52dp</dimen>
<dimen name="measurement_tool_bottom_descr_height">44dp</dimen> <dimen name="bottom_sheet_descr_height">44dp</dimen>
<dimen name="measurement_tool_bottom_list_item_height">48dp</dimen> <dimen name="bottom_sheet_list_item_height">48dp</dimen>
<dimen name="measurement_tool_bottom_icon_margin">24dp</dimen> <dimen name="bottom_sheet_icon_margin">24dp</dimen>
<dimen name="measurement_tool_bottom_divider_margin_top">7dp</dimen> <dimen name="measurement_tool_bottom_divider_margin_top">7dp</dimen>
<dimen name="measurement_tool_bottom_divider_margin_bottom">8dp</dimen> <dimen name="measurement_tool_bottom_divider_margin_bottom">8dp</dimen>
<dimen name="measurement_tool_bottom_divider_margin_start">64dp</dimen> <dimen name="measurement_tool_bottom_divider_margin_start">64dp</dimen>
<dimen name="measurement_tool_bottom_image_text_margin_start">10dp</dimen> <dimen name="bottom_sheet_image_text_margin_start">10dp</dimen>
<dimen name="measurement_tool_selected_point_title_height">56dp</dimen> <dimen name="bottom_sheet_selected_item_title_height">56dp</dimen>
</resources> </resources>

View file

@ -9,11 +9,25 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="map_orientation_change_in_accordance_with_speed">Map orientation change in accordance with speed</string>
<string name="map_orientation_change_in_accordance_with_speed_descr">Use built in compass instead of direction of movement to determine map orientation at low speed</string>
<string name="all_markers_moved_to_history">All markers moved to History</string>
<string name="marker_moved_to_history">Marker moved to History</string>
<string name="marker_moved_to_active">Marker moved to Active</string>
<string name="shared_string_list">List</string>
<string name="shared_string_groups">Groups</string>
<string name="passed">Passed: %1$s</string>
<string name="make_active">Make active</string>
<string name="today">Today</string>
<string name="yesterday">Yesterday</string>
<string name="last_seven_days">Last 7 days</string>
<string name="this_year">This year</string>
<string name="widget">Widget</string>
<string name="top_bar">Top bar</string>
<string name="move_all_to_history">Move all to history</string> <string name="move_all_to_history">Move all to history</string>
<string name="build_route">Build route</string> <string name="build_route">Build route</string>
<string name="show_direction">Show direction</string> <string name="show_direction">Show direction</string>
<string name="sort_by">Sort by</string> <string name="sort_by">Sort by</string>
<string name="marker_options">Marker options</string>
<string name="do_not_use_animations">Do not use animations</string> <string name="do_not_use_animations">Do not use animations</string>
<string name="do_not_use_animations_descr">Disables animations in the app</string> <string name="do_not_use_animations_descr">Disables animations in the app</string>
<string name="keep_showing_on_map">Keep showing on map</string> <string name="keep_showing_on_map">Keep showing on map</string>

View file

@ -1,55 +1,92 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<ListPreference android:title="@string/router_service" android:key="router_service" android:summary="@string/router_service_descr" /> <ListPreference
android:key="router_service"
android:summary="@string/router_service_descr"
android:title="@string/router_service"/>
<PreferenceCategory android:key="routing_preferences" android:title="@string/routing_preferences_descr"> <PreferenceCategory
<CheckBoxPreference android:summary="@string/fast_route_mode_descr" android:title="@string/fast_route_mode" android:key="routing_preferences"
android:key="fast_route_mode" /> android:title="@string/routing_preferences_descr">
<Preference android:title="@string/avoid_in_routing_title" android:summary="@string/avoid_in_routing_descr" android:key="avoid_in_routing"/> <CheckBoxPreference
<Preference android:title="@string/prefer_in_routing_title" android:summary="@string/prefer_in_routing_descr" android:key="prefer_in_routing"/> android:key="fast_route_mode"
</PreferenceCategory> android:summary="@string/fast_route_mode_descr"
android:title="@string/fast_route_mode"/>
<Preference
android:key="avoid_in_routing"
android:summary="@string/avoid_in_routing_descr"
android:title="@string/avoid_in_routing_title"/>
<Preference
android:key="prefer_in_routing"
android:summary="@string/prefer_in_routing_descr"
android:title="@string/prefer_in_routing_title"/>
</PreferenceCategory>
<PreferenceCategory android:key="guidance_preferences" android:title="@string/guidance_preferences_descr"> <PreferenceCategory
<ListPreference android:key="auto_follow_route" android:title="@string/choose_auto_follow_route" android:key="guidance_preferences"
android:summary="@string/choose_auto_follow_route_descr" /> android:title="@string/guidance_preferences_descr">
<Preference android:key="auto_zoom_map_on_off" android:title="@string/auto_zoom_map" <ListPreference
android:summary="@string/auto_zoom_map_descr" /> android:key="auto_follow_route"
<CheckBoxPreference android:title="@string/snap_to_road" android:summary="@string/snap_to_road_descr" android:key="snap_to_road" /> android:summary="@string/choose_auto_follow_route_descr"
<Preference android:title="@string/show_warnings_title" android:summary="@string/show_warnings_descr" android:key="show_routing_alarms"/> android:title="@string/choose_auto_follow_route"/>
<Preference android:title="@string/speak_title" android:summary="@string/speak_descr" android:key="speak_routing_alarms"/> <Preference
<ListPreference android:key="auto_zoom_map_on_off"
android:key="keep_informing" android:summary="@string/auto_zoom_map_descr"
android:title="@string/keep_informing" android:title="@string/auto_zoom_map"/>
android:summary="@string/keep_informing_descr" /> <CheckBoxPreference
<ListPreference android:key="snap_to_road"
android:key="arrival_distance_factor" android:summary="@string/snap_to_road_descr"
android:title="@string/arrival_distance" android:title="@string/snap_to_road"/>
android:summary="@string/arrival_distance_descr" /> <Preference
<ListPreference android:key="show_routing_alarms"
android:key="default_speed_system" android:summary="@string/show_warnings_descr"
android:title="@string/default_speed_system" android:title="@string/show_warnings_title"/>
android:summary="@string/default_speed_system_descr" /> <Preference
<ListPreference android:key="speak_routing_alarms"
android:key="speed_limit_exceed" android:summary="@string/speak_descr"
android:title="@string/speed_limit_exceed" android:title="@string/speak_title"/>
android:summary="@string/speed_limit_exceed_message"/> <ListPreference
<!-- android:key="keep_informing"
<CheckBoxPreference android:title="@string/show_zoom_buttons_navigation" android:summary="@string/show_zoom_buttons_navigation_descr" android:key="show_zoom_buttons_navigation" /> android:summary="@string/keep_informing_descr"
--> android:title="@string/keep_informing"/>
<ListPreference <ListPreference
android:key="wake_on_voice_int" android:key="arrival_distance_factor"
android:title="@string/wake_on_voice" android:summary="@string/arrival_distance_descr"
android:summary="@string/wake_on_voice_descr" /> android:title="@string/arrival_distance"/>
<!-- <ListPreference
<ListPreference android:key="default_speed_system"
android:key="delay_to_start_navigation" android:summary="@string/default_speed_system_descr"
android:title="@string/delay_to_start_navigation" android:title="@string/default_speed_system"/>
android:summary="@string/delay_to_start_navigation_descr" /> <ListPreference
--> android:key="speed_limit_exceed"
</PreferenceCategory> android:summary="@string/speed_limit_exceed_message"
android:title="@string/speed_limit_exceed"/>
<ListPreference
android:key="speed_for_map_to_direction_of_movement"
android:summary="@string/map_orientation_change_in_accordance_with_speed_descr"
android:title="@string/map_orientation_change_in_accordance_with_speed"/>
<!--
<CheckBoxPreference android:title="@string/show_zoom_buttons_navigation" android:summary="@string/show_zoom_buttons_navigation_descr" android:key="show_zoom_buttons_navigation" />
-->
<ListPreference
android:key="wake_on_voice_int"
android:summary="@string/wake_on_voice_descr"
android:title="@string/wake_on_voice"/>
<!--
<ListPreference
android:key="delay_to_start_navigation"
android:title="@string/delay_to_start_navigation"
android:summary="@string/delay_to_start_navigation_descr" />
-->
</PreferenceCategory>
<PreferenceCategory android:title="@string/voice_pref_title" android:key="voice"> <PreferenceCategory
<ListPreference android:title="@string/voice_provider" android:key="voice_provider" android:summary="@string/voice_provider_descr"></ListPreference> android:key="voice"
</PreferenceCategory> android:title="@string/voice_pref_title">
<ListPreference
android:key="voice_provider"
android:summary="@string/voice_provider_descr"
android:title="@string/voice_provider"/>
</PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View file

@ -797,7 +797,7 @@ public class OsmandAidlApi {
List<MapMarker> mapMarkers = markersHelper.getMapMarkers(); List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
for (MapMarker m : mapMarkers) { for (MapMarker m : mapMarkers) {
if (m.getOnlyName().equals(marker.getName()) && latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) { if (m.getOnlyName().equals(marker.getName()) && latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) {
markersHelper.removeMapMarker(m); markersHelper.moveMapMarkerToHistory(m);
refreshMap(); refreshMap();
return true; return true;
} }
@ -818,7 +818,10 @@ public class OsmandAidlApi {
if (m.getOnlyName().equals(markerPrev.getName()) && latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) { if (m.getOnlyName().equals(markerPrev.getName()) && latLon.equals(new LatLon(m.getLatitude(), m.getLongitude()))) {
PointDescription pd = new PointDescription( PointDescription pd = new PointDescription(
PointDescription.POINT_TYPE_MAP_MARKER, markerNew.getName() != null ? markerNew.getName() : ""); PointDescription.POINT_TYPE_MAP_MARKER, markerNew.getName() != null ? markerNew.getName() : "");
MapMarker marker = new MapMarker(m.point, pd, m.colorIndex, m.selected, m.creationDate, m.index); MapMarker marker = new MapMarker(m.point, pd, m.colorIndex, m.selected, m.index);
marker.id = m.id;
marker.creationDate = m.creationDate;
marker.visitedDate = m.visitedDate;
markersHelper.moveMapMarker(marker, latLonNew); markersHelper.moveMapMarker(marker, latLonNew);
refreshMap(); refreshMap();
return true; return true;

View file

@ -29,6 +29,7 @@ import net.osmand.plus.download.ui.AbstractLoadLocalIndexTask;
import net.osmand.plus.helpers.AvoidSpecificRoads; import net.osmand.plus.helpers.AvoidSpecificRoads;
import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.liveupdates.LiveUpdatesHelper; import net.osmand.plus.liveupdates.LiveUpdatesHelper;
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
import net.osmand.plus.monitoring.LiveMonitoringHelper; import net.osmand.plus.monitoring.LiveMonitoringHelper;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.poi.PoiFiltersHelper; import net.osmand.plus.poi.PoiFiltersHelper;
@ -373,6 +374,7 @@ public class AppInitializer implements IProgress {
app.rendererRegistry = startupInit(new RendererRegistry(app), RendererRegistry.class); app.rendererRegistry = startupInit(new RendererRegistry(app), RendererRegistry.class);
app.geocodingLookupService = startupInit(new GeocodingLookupService(app), GeocodingLookupService.class); app.geocodingLookupService = startupInit(new GeocodingLookupService(app), GeocodingLookupService.class);
app.targetPointsHelper = startupInit(new TargetPointsHelper(app), TargetPointsHelper.class); app.targetPointsHelper = startupInit(new TargetPointsHelper(app), TargetPointsHelper.class);
app.mapMarkersDbHelper = startupInit(new MapMarkersDbHelper(app), MapMarkersDbHelper.class);
app.mapMarkersHelper = startupInit(new MapMarkersHelper(app), MapMarkersHelper.class); app.mapMarkersHelper = startupInit(new MapMarkersHelper(app), MapMarkersHelper.class);
app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class); app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class);
} }
@ -499,6 +501,7 @@ public class AppInitializer implements IProgress {
startBgTime = System.currentTimeMillis(); startBgTime = System.currentTimeMillis();
app.favorites.loadFavorites(); app.favorites.loadFavorites();
notifyEvent(InitEvents.FAVORITES_INITIALIZED); notifyEvent(InitEvents.FAVORITES_INITIALIZED);
app.mapMarkersHelper.syncAllGroups();
// init poi types before indexes and before POI // init poi types before indexes and before POI
initPoiTypes(); initPoiTypes();
notifyEvent(InitEvents.POI_TYPES_INITIALIZED); notifyEvent(InitEvents.POI_TYPES_INITIALIZED);

View file

@ -7,6 +7,7 @@ import net.osmand.PlatformUtil;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor; import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -20,6 +21,7 @@ import java.text.Collator;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -63,9 +65,9 @@ public class FavouritesDbHelper {
favoriteGroups.clear(); favoriteGroups.clear();
File internalFile = getInternalFile(); File internalFile = getInternalFile();
if(!internalFile.exists()) { if (!internalFile.exists()) {
File dbPath = context.getDatabasePath(FAVOURITE_DB_NAME); File dbPath = context.getDatabasePath(FAVOURITE_DB_NAME);
if(dbPath.exists()) { if (dbPath.exists()) {
loadAndCheckDatabasePoints(); loadAndCheckDatabasePoints();
saveCurrentPointsIntoFile(); saveCurrentPointsIntoFile();
} }
@ -77,27 +79,27 @@ public class FavouritesDbHelper {
loadGPXFile(getExternalFile(), extPoints); loadGPXFile(getExternalFile(), extPoints);
boolean changed = merge(extPoints, points); boolean changed = merge(extPoints, points);
for(FavouritePoint pns : points.values()) { for (FavouritePoint pns : points.values()) {
FavoriteGroup group = getOrCreateGroup(pns, 0); FavoriteGroup group = getOrCreateGroup(pns, 0);
group.points.add(pns); group.points.add(pns);
} }
sortAll(); sortAll();
recalculateCachedFavPoints(); recalculateCachedFavPoints();
if(changed) { if (changed) {
saveCurrentPointsIntoFile(); saveCurrentPointsIntoFile();
} }
favouritesUpdated(); favouritesUpdated();
} }
private void favouritesUpdated(){ private void favouritesUpdated() {
} }
private boolean merge(Map<String, FavouritePoint> source, Map<String, FavouritePoint> destination) { private boolean merge(Map<String, FavouritePoint> source, Map<String, FavouritePoint> destination) {
boolean changed = false; boolean changed = false;
for(String ks : source.keySet()) { for (String ks : source.keySet()) {
if(!destination.containsKey(ks)) { if (!destination.containsKey(ks)) {
changed = true; changed = true;
destination.put(ks, source.get(ks)); destination.put(ks, source.get(ks));
} }
@ -106,26 +108,31 @@ public class FavouritesDbHelper {
} }
private File getInternalFile() { private File getInternalFile() {
return context.getFileStreamPath(FILE_TO_BACKUP); return context.getFileStreamPath(FILE_TO_BACKUP);
} }
public void delete(Set<FavoriteGroup> groupsToDelete, Set<FavouritePoint> favoritesSelected) { public void delete(Set<FavoriteGroup> groupsToDelete, Set<FavouritePoint> favoritesSelected) {
if (favoritesSelected != null) { if (favoritesSelected != null) {
Set<FavoriteGroup> groupsToSync = new HashSet<>();
for (FavouritePoint p : favoritesSelected) { for (FavouritePoint p : favoritesSelected) {
FavoriteGroup group = flatGroups.get(p.getCategory()); FavoriteGroup group = flatGroups.get(p.getCategory());
if (group != null) { if (group != null) {
group.points.remove(p); group.points.remove(p);
groupsToSync.add(group);
} }
cachedFavoritePoints.remove(p); cachedFavoritePoints.remove(p);
} }
for (FavoriteGroup gr : groupsToSync) {
context.getMapMarkersHelper().syncGroup(new MarkersSyncGroup(gr.name, gr.name, MarkersSyncGroup.FAVORITES_TYPE));
}
} }
if (groupsToDelete != null) { if (groupsToDelete != null) {
for (FavoriteGroup g : groupsToDelete) { for (FavoriteGroup g : groupsToDelete) {
flatGroups.remove(g.name); flatGroups.remove(g.name);
favoriteGroups.remove(g); favoriteGroups.remove(g);
cachedFavoritePoints.removeAll(g.points); cachedFavoritePoints.removeAll(g.points);
context.getMapMarkersHelper().removeMarkersSyncGroup(g.name, true);
} }
} }
saveCurrentPointsIntoFile(); saveCurrentPointsIntoFile();
@ -140,6 +147,7 @@ public class FavouritesDbHelper {
FavoriteGroup group = flatGroups.get(p.getCategory()); FavoriteGroup group = flatGroups.get(p.getCategory());
if (group != null) { if (group != null) {
group.points.remove(p); group.points.remove(p);
context.getMapMarkersHelper().syncGroup(new MarkersSyncGroup(group.name, group.name, MarkersSyncGroup.FAVORITES_TYPE));
} }
cachedFavoritePoints.remove(p); cachedFavoritePoints.remove(p);
} }
@ -169,6 +177,7 @@ public class FavouritesDbHelper {
sortAll(); sortAll();
saveCurrentPointsIntoFile(); saveCurrentPointsIntoFile();
} }
context.getMapMarkersHelper().syncGroup(new MarkersSyncGroup(group.name, group.name, MarkersSyncGroup.FAVORITES_TYPE));
return true; return true;
} }
@ -201,7 +210,7 @@ public class FavouritesDbHelper {
} }
} }
} }
if ((index.length() > 0 || emoticons) ) { if ((index.length() > 0 || emoticons)) {
AlertDialog.Builder builder = new AlertDialog.Builder(uiContext); AlertDialog.Builder builder = new AlertDialog.Builder(uiContext);
builder.setTitle(R.string.fav_point_dublicate); builder.setTitle(R.string.fav_point_dublicate);
if (emoticons) { if (emoticons) {
@ -215,7 +224,7 @@ public class FavouritesDbHelper {
return null; return null;
} }
public static String checkEmoticons(String name){ public static String checkEmoticons(String name) {
char[] chars = name.toCharArray(); char[] chars = name.toCharArray();
int index; int index;
char ch1; char ch1;
@ -225,16 +234,15 @@ public class FavouritesDbHelper {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
while (index < chars.length) { while (index < chars.length) {
ch1 = chars[index]; ch1 = chars[index];
if ((int)ch1 == 0xD83C) { if ((int) ch1 == 0xD83C) {
ch2 = chars[index+1]; ch2 = chars[index + 1];
if ((int)ch2 >= 0xDF00 && (int)ch2 <= 0xDFFF) { if ((int) ch2 >= 0xDF00 && (int) ch2 <= 0xDFFF) {
index += 2; index += 2;
continue; continue;
} }
} } else if ((int) ch1 == 0xD83D) {
else if ((int)ch1 == 0xD83D) { ch2 = chars[index + 1];
ch2 = chars[index+1]; if ((int) ch2 >= 0xDC00 && (int) ch2 <= 0xDDFF) {
if ((int)ch2 >= 0xDC00 && (int)ch2 <= 0xDDFF) {
index += 2; index += 2;
continue; continue;
} }
@ -264,14 +272,15 @@ public class FavouritesDbHelper {
} }
sortAll(); sortAll();
saveCurrentPointsIntoFile(); saveCurrentPointsIntoFile();
context.getMapMarkersHelper().syncGroup(new MarkersSyncGroup(category, category, MarkersSyncGroup.FAVORITES_TYPE));
return true; return true;
} }
public boolean editFavourite(FavouritePoint p, double lat, double lon) { public boolean editFavourite(FavouritePoint p, double lat, double lon) {
p.setLatitude(lat); p.setLatitude(lat);
p.setLongitude(lon); p.setLongitude(lon);
saveCurrentPointsIntoFile(); saveCurrentPointsIntoFile();
context.getMapMarkersHelper().syncGroup(new MarkersSyncGroup(p.getCategory(), p.getCategory(), MarkersSyncGroup.FAVORITES_TYPE));
return true; return true;
} }
@ -279,7 +288,7 @@ public class FavouritesDbHelper {
try { try {
Map<String, FavouritePoint> deletedInMemory = new LinkedHashMap<String, FavouritePoint>(); Map<String, FavouritePoint> deletedInMemory = new LinkedHashMap<String, FavouritePoint>();
loadGPXFile(getInternalFile(), deletedInMemory); loadGPXFile(getInternalFile(), deletedInMemory);
for(FavouritePoint fp : cachedFavoritePoints) { for (FavouritePoint fp : cachedFavoritePoints) {
deletedInMemory.remove(getKey(fp)); deletedInMemory.remove(getKey(fp));
} }
saveFile(cachedFavoritePoints, getInternalFile()); saveFile(cachedFavoritePoints, getInternalFile());
@ -312,18 +321,17 @@ public class FavouritesDbHelper {
} }
private String saveExternalFile(Set<String> deleted) { private String saveExternalFile(Set<String> deleted) {
Map<String, FavouritePoint> all = new LinkedHashMap<String, FavouritePoint>(); Map<String, FavouritePoint> all = new LinkedHashMap<String, FavouritePoint>();
loadGPXFile(getExternalFile(), all); loadGPXFile(getExternalFile(), all);
List<FavouritePoint> favoritePoints = new ArrayList<FavouritePoint>(cachedFavoritePoints); List<FavouritePoint> favoritePoints = new ArrayList<FavouritePoint>(cachedFavoritePoints);
if(deleted != null) { if (deleted != null) {
for(String key : deleted) { for (String key : deleted) {
all.remove(key); all.remove(key);
} }
} }
// remove already existing in memory // remove already existing in memory
for(FavouritePoint p : favoritePoints) { for (FavouritePoint p : favoritePoints) {
all.remove(getKey(p)); all.remove(getKey(p));
} }
// save favoritePoints from memory in order to update existing // save favoritePoints from memory in order to update existing
@ -332,18 +340,16 @@ public class FavouritesDbHelper {
} }
private String getKey(FavouritePoint p) { private String getKey(FavouritePoint p) {
return p.getName() + DELIMETER + p.getCategory(); return p.getName() + DELIMETER + p.getCategory();
} }
public boolean deleteGroup(FavoriteGroup group) { public boolean deleteGroup(FavoriteGroup group) {
boolean remove = favoriteGroups.remove(group); boolean remove = favoriteGroups.remove(group);
if (remove) { if (remove) {
flatGroups.remove(group.name); flatGroups.remove(group.name);
saveCurrentPointsIntoFile(); saveCurrentPointsIntoFile();
context.getMapMarkersHelper().removeMarkersSyncGroup(group.name, true);
return true; return true;
} }
return false; return false;
@ -355,26 +361,26 @@ public class FavouritesDbHelper {
public File getBackupFile() { public File getBackupFile() {
File fld = new File(context.getAppPath(null), BACKUP_FOLDER); File fld = new File(context.getAppPath(null), BACKUP_FOLDER);
if(!fld.exists()) { if (!fld.exists()) {
fld.mkdirs(); fld.mkdirs();
} }
int back = 1; int back = 1;
String backPrefix = "" + back; String backPrefix = "" + back;
File firstModified = null; File firstModified = null;
long firstModifiedMin = System.currentTimeMillis(); long firstModifiedMin = System.currentTimeMillis();
while(back <= BACKUP_CNT) { while (back <= BACKUP_CNT) {
backPrefix = "" + back; backPrefix = "" + back;
if(back < 10) { if (back < 10) {
backPrefix = "0"+backPrefix; backPrefix = "0" + backPrefix;
} }
File bak = new File(fld, "favourites_bak_" + backPrefix +".gpx.bz2"); File bak = new File(fld, "favourites_bak_" + backPrefix + ".gpx.bz2");
if (!bak.exists()) { if (!bak.exists()) {
return bak; return bak;
} else if (bak.lastModified() < firstModifiedMin) { } else if (bak.lastModified() < firstModifiedMin) {
firstModified = bak; firstModified = bak;
firstModifiedMin = bak.lastModified(); firstModifiedMin = bak.lastModified();
} }
back ++; back++;
} }
return firstModified; return firstModified;
} }
@ -395,10 +401,10 @@ public class FavouritesDbHelper {
WptPt pt = new WptPt(); WptPt pt = new WptPt();
pt.lat = p.getLatitude(); pt.lat = p.getLatitude();
pt.lon = p.getLongitude(); pt.lon = p.getLongitude();
if(!p.isVisible()) { if (!p.isVisible()) {
pt.getExtensionsToWrite().put(HIDDEN, "true"); pt.getExtensionsToWrite().put(HIDDEN, "true");
} }
if(p.getColor() != 0) { if (p.getColor() != 0) {
pt.setColor(p.getColor()); pt.setColor(p.getColor());
} }
pt.name = p.getName(); pt.name = p.getName();
@ -437,8 +443,8 @@ public class FavouritesDbHelper {
public List<FavouritePoint> getVisibleFavouritePoints() { public List<FavouritePoint> getVisibleFavouritePoints() {
List<FavouritePoint> fp = new ArrayList<>(); List<FavouritePoint> fp = new ArrayList<>();
for(FavouritePoint p : cachedFavoritePoints) { for (FavouritePoint p : cachedFavoritePoints) {
if(p.isVisible()) { if (p.isVisible()) {
fp.add(p); fp.add(p);
} }
} }
@ -476,7 +482,7 @@ public class FavouritesDbHelper {
} }
} }
private FavouritePoint findFavoriteByAllProperties(String category, String name, double lat, double lon){ private FavouritePoint findFavoriteByAllProperties(String category, String name, double lat, double lon) {
if (flatGroups.containsKey(category)) { if (flatGroups.containsKey(category)) {
FavoriteGroup fg = flatGroups.get(category); FavoriteGroup fg = flatGroups.get(category);
for (FavouritePoint fv : fg.points) { for (FavouritePoint fv : fg.points) {
@ -489,10 +495,9 @@ public class FavouritesDbHelper {
} }
public void recalculateCachedFavPoints() {
public void recalculateCachedFavPoints(){
ArrayList<FavouritePoint> temp = new ArrayList<FavouritePoint>(); ArrayList<FavouritePoint> temp = new ArrayList<FavouritePoint>();
for(FavoriteGroup f : favoriteGroups){ for (FavoriteGroup f : favoriteGroups) {
temp.addAll(f.points); temp.addAll(f.points);
} }
cachedFavoritePoints = temp; cachedFavoritePoints = temp;
@ -553,7 +558,7 @@ public class FavouritesDbHelper {
private boolean loadGPXFile(File file, Map<String, FavouritePoint> points) { private boolean loadGPXFile(File file, Map<String, FavouritePoint> points) {
if(!file.exists()) { if (!file.exists()) {
return false; return false;
} }
GPXFile res = GPXUtilities.loadGPXFile(context, file); GPXFile res = GPXUtilities.loadGPXFile(context, file);
@ -585,37 +590,43 @@ public class FavouritesDbHelper {
} }
public void editFavouriteGroup(FavoriteGroup group, String newName, int color, boolean visible) { public void editFavouriteGroup(FavoriteGroup group, String newName, int color, boolean visible) {
if(color != 0 && group.color != color) { MapMarkersHelper markersHelper = context.getMapMarkersHelper();
if (color != 0 && group.color != color) {
FavoriteGroup gr = flatGroups.get(group.name); FavoriteGroup gr = flatGroups.get(group.name);
group.color = color; group.color = color;
for(FavouritePoint p : gr.points) { for (FavouritePoint p : gr.points) {
p.setColor(color); p.setColor(color);
} }
} }
if(group.visible != visible) { if (group.visible != visible) {
FavoriteGroup gr = flatGroups.get(group.name); FavoriteGroup gr = flatGroups.get(group.name);
group.visible = visible; group.visible = visible;
for(FavouritePoint p : gr.points) { for (FavouritePoint p : gr.points) {
p.setVisible(visible); p.setVisible(visible);
} }
markersHelper.syncGroup(new MarkersSyncGroup(gr.name, gr.name, MarkersSyncGroup.FAVORITES_TYPE));
} }
if (!group.name.equals(newName)) { if (!group.name.equals(newName)) {
FavoriteGroup gr = flatGroups.remove(group.name); FavoriteGroup gr = flatGroups.remove(group.name);
markersHelper.removeMarkersSyncGroup(group.name, true);
gr.name = newName; gr.name = newName;
FavoriteGroup renamedGroup = flatGroups.get(gr.name); FavoriteGroup renamedGroup = flatGroups.get(gr.name);
boolean existing = renamedGroup != null; boolean existing = renamedGroup != null;
if(renamedGroup == null) { if (renamedGroup == null) {
renamedGroup = gr; renamedGroup = gr;
flatGroups.put(gr.name, gr); flatGroups.put(gr.name, gr);
} else { } else {
favoriteGroups.remove(gr); favoriteGroups.remove(gr);
} }
for(FavouritePoint p : gr.points) { for (FavouritePoint p : gr.points) {
p.setCategory(newName); p.setCategory(newName);
if(existing) { if (existing) {
renamedGroup.points.add(p); renamedGroup.points.add(p);
} }
} }
MarkersSyncGroup syncGroup = new MarkersSyncGroup(renamedGroup.name, renamedGroup.name, MarkersSyncGroup.FAVORITES_TYPE);
markersHelper.addMarkersSyncGroup(syncGroup);
markersHelper.syncGroup(syncGroup);
} }
saveCurrentPointsIntoFile(); saveCurrentPointsIntoFile();
} }
@ -680,13 +691,13 @@ public class FavouritesDbHelper {
} }
public void onUpgrade(SQLiteConnection db, int oldVersion, int newVersion) { public void onUpgrade(SQLiteConnection db, int oldVersion, int newVersion) {
if(oldVersion == 1){ if (oldVersion == 1) {
db.execSQL("ALTER TABLE " + FAVOURITE_TABLE_NAME + " ADD " + FAVOURITE_COL_CATEGORY + " text"); db.execSQL("ALTER TABLE " + FAVOURITE_TABLE_NAME + " ADD " + FAVOURITE_COL_CATEGORY + " text");
db.execSQL("UPDATE " + FAVOURITE_TABLE_NAME + " SET category = ?", new Object[] { "" }); //$NON-NLS-1$ //$NON-NLS-2$ db.execSQL("UPDATE " + FAVOURITE_TABLE_NAME + " SET category = ?", new Object[]{""}); //$NON-NLS-1$ //$NON-NLS-2$
} }
} }
private void loadAndCheckDatabasePoints(){ private void loadAndCheckDatabasePoints() {
if (favoriteGroups == null) { if (favoriteGroups == null) {
SQLiteConnection db = openConnection(true); SQLiteConnection db = openConnection(true);
if (db != null) { if (db != null) {
@ -727,17 +738,17 @@ public class FavouritesDbHelper {
if (db != null) { if (db != null) {
try { try {
db.execSQL( db.execSQL(
"DELETE FROM " + FAVOURITE_TABLE_NAME + " WHERE category = ? AND " + whereNameLatLon(), new Object[] { p.getCategory(), p.getName(), p.getLatitude(), p.getLongitude() }); //$NON-NLS-1$ //$NON-NLS-2$ "DELETE FROM " + FAVOURITE_TABLE_NAME + " WHERE category = ? AND " + whereNameLatLon(), new Object[]{p.getCategory(), p.getName(), p.getLatitude(), p.getLongitude()}); //$NON-NLS-1$ //$NON-NLS-2$
FavouritePoint fp = findFavoriteByAllProperties(p.getCategory(), p.getName(), p.getLatitude(), p.getLongitude()); FavouritePoint fp = findFavoriteByAllProperties(p.getCategory(), p.getName(), p.getLatitude(), p.getLongitude());
if (fp != null) { if (fp != null) {
FavoriteGroup group = flatGroups.get(p.getCategory()); FavoriteGroup group = flatGroups.get(p.getCategory());
if(group != null) { if (group != null) {
group.points.remove(fp); group.points.remove(fp);
} }
cachedFavoritePoints.remove(fp); cachedFavoritePoints.remove(fp);
} }
saveCurrentPointsIntoFile(); saveCurrentPointsIntoFile();
} finally{ } finally {
db.close(); db.close();
} }
return true; return true;
@ -747,7 +758,7 @@ public class FavouritesDbHelper {
public boolean addFavouriteDB(FavouritePoint p) { public boolean addFavouriteDB(FavouritePoint p) {
if(p.getName().equals("") && flatGroups.containsKey(p.getCategory())){ if (p.getName().equals("") && flatGroups.containsKey(p.getCategory())) {
return true; return true;
} }
SQLiteConnection db = openConnection(false); SQLiteConnection db = openConnection(false);
@ -755,8 +766,8 @@ public class FavouritesDbHelper {
try { try {
db.execSQL( db.execSQL(
"INSERT INTO " + FAVOURITE_TABLE_NAME + " (" + FAVOURITE_COL_NAME + ", " + FAVOURITE_COL_CATEGORY + ", " "INSERT INTO " + FAVOURITE_TABLE_NAME + " (" + FAVOURITE_COL_NAME + ", " + FAVOURITE_COL_CATEGORY + ", "
+ FAVOURITE_COL_LAT + ", " + FAVOURITE_COL_LON + ")" + " VALUES (?, ?, ?, ?)", new Object[] { p.getName(), p.getCategory(), p.getLatitude(), p.getLongitude() }); //$NON-NLS-1$ //$NON-NLS-2$ + FAVOURITE_COL_LAT + ", " + FAVOURITE_COL_LON + ")" + " VALUES (?, ?, ?, ?)", new Object[]{p.getName(), p.getCategory(), p.getLatitude(), p.getLongitude()}); //$NON-NLS-1$ //$NON-NLS-2$
FavoriteGroup group = getOrCreateGroup(p, 0); FavoriteGroup group = getOrCreateGroup(p, 0);
if (!p.getName().equals("")) { if (!p.getName().equals("")) {
p.setVisible(group.visible); p.setVisible(group.visible);
p.setColor(group.color); p.setColor(group.color);
@ -773,14 +784,13 @@ public class FavouritesDbHelper {
} }
public boolean editFavouriteNameDB(FavouritePoint p, String newName, String category) { public boolean editFavouriteNameDB(FavouritePoint p, String newName, String category) {
SQLiteConnection db = openConnection(false); SQLiteConnection db = openConnection(false);
if (db != null) { if (db != null) {
try { try {
String oldCategory = p.getCategory(); String oldCategory = p.getCategory();
db.execSQL( db.execSQL(
"UPDATE " + FAVOURITE_TABLE_NAME + " SET " + FAVOURITE_COL_NAME + " = ?, " + FAVOURITE_COL_CATEGORY + "= ? WHERE " + whereNameLatLon(), new Object[] { newName, category, p.getName(), p.getLatitude(), p.getLongitude() }); //$NON-NLS-1$ //$NON-NLS-2$ "UPDATE " + FAVOURITE_TABLE_NAME + " SET " + FAVOURITE_COL_NAME + " = ?, " + FAVOURITE_COL_CATEGORY + "= ? WHERE " + whereNameLatLon(), new Object[]{newName, category, p.getName(), p.getLatitude(), p.getLongitude()}); //$NON-NLS-1$ //$NON-NLS-2$
p.setName(newName); p.setName(newName);
p.setCategory(category); p.setCategory(category);
if (!oldCategory.equals(category)) { if (!oldCategory.equals(category)) {
@ -808,7 +818,7 @@ public class FavouritesDbHelper {
if (db != null) { if (db != null) {
try { try {
db.execSQL( db.execSQL(
"UPDATE " + FAVOURITE_TABLE_NAME + " SET latitude = ?, longitude = ? WHERE " + whereNameLatLon(), new Object[] { lat, lon, p.getName(), p.getLatitude(), p.getLongitude() }); //$NON-NLS-1$ //$NON-NLS-2$ "UPDATE " + FAVOURITE_TABLE_NAME + " SET latitude = ?, longitude = ? WHERE " + whereNameLatLon(), new Object[]{lat, lon, p.getName(), p.getLatitude(), p.getLongitude()}); //$NON-NLS-1$ //$NON-NLS-2$
p.setLatitude(lat); p.setLatitude(lat);
p.setLongitude(lon); p.setLongitude(lon);
saveCurrentPointsIntoFile(); saveCurrentPointsIntoFile();
@ -826,6 +836,4 @@ public class FavouritesDbHelper {
} }
} }

View file

@ -1,24 +1,40 @@
package net.osmand.plus; package net.osmand.plus;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.text.format.DateFormat;
import net.osmand.IndexConstants;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.LocationPoint; import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale;
import static net.osmand.data.PointDescription.POINT_TYPE_MAP_MARKER;
public class MapMarkersHelper { public class MapMarkersHelper {
public static final int MAP_MARKERS_COLORS_COUNT = 7; public static final int MAP_MARKERS_COLORS_COUNT = 7;
private List<MapMarker> mapMarkers = new ArrayList<>(); private List<MapMarker> mapMarkers = new LinkedList<>();
private List<MapMarker> mapMarkersHistory = new ArrayList<>(); private List<MapMarker> mapMarkersHistory = new LinkedList<>();
private OsmandSettings settings; private OsmandSettings settings;
private List<MapMarkerChangedListener> listeners = new ArrayList<>(); private List<MapMarkerChangedListener> listeners = new ArrayList<>();
private OsmandApplication ctx; private OsmandApplication ctx;
private MapMarkersDbHelper markersDbHelper;
private boolean startFromMyLocation; private boolean startFromMyLocation;
public interface MapMarkerChangedListener { public interface MapMarkerChangedListener {
@ -28,6 +44,7 @@ public class MapMarkersHelper {
} }
public static class MapMarker implements LocationPoint { public static class MapMarker implements LocationPoint {
public String id;
public LatLon point; public LatLon point;
private PointDescription pointDescription; private PointDescription pointDescription;
public int colorIndex; public int colorIndex;
@ -36,19 +53,22 @@ public class MapMarkersHelper {
public boolean selected; public boolean selected;
public int dist; public int dist;
public long creationDate; public long creationDate;
public long visitedDate;
public String nextKey;
public String groupKey;
public String groupName;
public MapMarker(LatLon point, PointDescription name, int colorIndex, public MapMarker(LatLon point, PointDescription name, int colorIndex,
boolean selected, long creationDate, int index) { boolean selected, int index) {
this.point = point; this.point = point;
this.pointDescription = name; this.pointDescription = name;
this.colorIndex = colorIndex; this.colorIndex = colorIndex;
this.selected = selected; this.selected = selected;
this.creationDate = creationDate;
this.index = index; this.index = index;
} }
public PointDescription getPointDescription(Context ctx) { public PointDescription getPointDescription(Context ctx) {
return new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, ctx.getString(R.string.map_marker), return new PointDescription(POINT_TYPE_MAP_MARKER, ctx.getString(R.string.map_marker),
getOnlyName()); getOnlyName());
} }
@ -139,11 +159,40 @@ public class MapMarkersHelper {
} }
} }
public static class MarkersSyncGroup {
public static final int FAVORITES_TYPE = 0;
public static final int GPX_TYPE = 1;
private String id;
private String name;
private int type;
public MarkersSyncGroup(@NonNull String id, @NonNull String name, int type) {
this.id = id;
this.name = name;
this.type = type;
}
public String getId() {
return id;
}
public String getName() {
return name;
}
public int getType() {
return type;
}
}
public MapMarkersHelper(OsmandApplication ctx) { public MapMarkersHelper(OsmandApplication ctx) {
this.ctx = ctx; this.ctx = ctx;
settings = ctx.getSettings(); settings = ctx.getSettings();
markersDbHelper = ctx.getMapMarkersDbHelper();
startFromMyLocation = settings.ROUTE_MAP_MARKERS_START_MY_LOC.get(); startFromMyLocation = settings.ROUTE_MAP_MARKERS_START_MY_LOC.get();
readFromSettings(); loadMarkers();
} }
public boolean isStartFromMyLocation() { public boolean isStartFromMyLocation() {
@ -157,86 +206,212 @@ public class MapMarkersHelper {
public void lookupAddressAll() { public void lookupAddressAll() {
for (MapMarker mapMarker : mapMarkers) { for (MapMarker mapMarker : mapMarkers) {
lookupAddress(mapMarker, false); lookupAddress(mapMarker);
} }
for (MapMarker mapMarker : mapMarkersHistory) { for (MapMarker mapMarker : mapMarkersHistory) {
lookupAddress(mapMarker, true); lookupAddress(mapMarker);
} }
} }
private void readFromSettings() { private void loadMarkers() {
mapMarkers.clear(); mapMarkers.clear();
mapMarkersHistory.clear(); mapMarkersHistory.clear();
List<LatLon> ips = settings.getMapMarkersPoints();
List<String> desc = settings.getMapMarkersPointDescriptions(ips.size());
List<Integer> colors = settings.getMapMarkersColors(ips.size());
List<Boolean> selections = settings.getMapMarkersSelections(ips.size());
List<Long> creationDates = settings.getMapMarkersCreationDates(ips.size());
int colorIndex = 0;
for (int i = 0; i < ips.size(); i++) {
if (colors.size() > i) {
colorIndex = colors.get(i);
}
MapMarker mapMarker = new MapMarker(ips.get(i),
PointDescription.deserializeFromString(desc.get(i), ips.get(i)), colorIndex,
selections.get(i), creationDates.get(i), i);
mapMarkers.add(mapMarker);
}
ips = settings.getMapMarkersHistoryPoints(); List<MapMarker> activeMarkers = markersDbHelper.getActiveMarkers();
desc = settings.getMapMarkersHistoryPointDescriptions(ips.size()); mapMarkers.addAll(activeMarkers);
colors = settings.getMapMarkersHistoryColors(ips.size()); checkAndFixActiveMarkersOrderIfNeeded();
creationDates = settings.getMapMarkersHistoryCreationDates(ips.size());
for (int i = 0; i < ips.size(); i++) { List<MapMarker> markersHistory = markersDbHelper.getMarkersHistory();
if (colors.size() > i) { sortMarkers(markersHistory, true);
colorIndex = colors.get(i); mapMarkersHistory.addAll(markersHistory);
}
MapMarker mapMarker = new MapMarker(ips.get(i),
PointDescription.deserializeFromString(desc.get(i), ips.get(i)),
colorIndex, false, creationDates.get(i), i);
mapMarker.history = true;
mapMarkersHistory.add(mapMarker);
}
if (!ctx.isApplicationInitializing()) { if (!ctx.isApplicationInitializing()) {
lookupAddressAll(); lookupAddressAll();
} }
} }
private void lookupAddress(final MapMarker mapMarker, final boolean history) { public void checkAndFixActiveMarkersOrderIfNeeded() {
if (!mapMarkers.isEmpty()) {
if (mapMarkers.size() > 1) {
for (int i = 0; i < mapMarkers.size() - 1; i++) {
MapMarker first = mapMarkers.get(i);
MapMarker second = mapMarkers.get(i + 1);
if (!first.nextKey.equals(second.id)) {
markersDbHelper.changeActiveMarkerPosition(first, second);
first.nextKey = second.id;
}
}
}
MapMarker tail = mapMarkers.get(mapMarkers.size() - 1);
if (!tail.nextKey.equals(MapMarkersDbHelper.TAIL_NEXT_VALUE)) {
markersDbHelper.changeActiveMarkerPosition(tail, null);
}
}
}
private void sortMarkers(List<MapMarker> markers, final boolean history) {
Collections.sort(markers, new Comparator<MapMarker>() {
@Override
public int compare(MapMarker mapMarker1, MapMarker mapMarker2) {
long firstMarkerDate = history ? mapMarker1.visitedDate : mapMarker1.creationDate;
long secondMarkerDate = history ? mapMarker2.visitedDate : mapMarker2.creationDate;
if (firstMarkerDate > secondMarkerDate) {
return -1;
} else if (firstMarkerDate == secondMarkerDate) {
return 0;
} else {
return 1;
}
}
});
}
private void lookupAddress(final MapMarker mapMarker) {
if (mapMarker != null && mapMarker.pointDescription.isSearchingAddress(ctx)) { if (mapMarker != null && mapMarker.pointDescription.isSearchingAddress(ctx)) {
cancelPointAddressRequests(mapMarker.point); cancelPointAddressRequests(mapMarker.point);
GeocodingLookupService.AddressLookupRequest lookupRequest = new GeocodingLookupService.AddressLookupRequest(mapMarker.point, new GeocodingLookupService.OnAddressLookupResult() { GeocodingLookupService.AddressLookupRequest lookupRequest =
@Override new GeocodingLookupService.AddressLookupRequest(mapMarker.point, new GeocodingLookupService.OnAddressLookupResult() {
public void geocodingDone(String address) { @Override
if (Algorithms.isEmpty(address)) { public void geocodingDone(String address) {
mapMarker.pointDescription.setName(PointDescription.getAddressNotFoundStr(ctx)); if (Algorithms.isEmpty(address)) {
} else { mapMarker.pointDescription.setName(PointDescription.getAddressNotFoundStr(ctx));
mapMarker.pointDescription.setName(address); } else {
} mapMarker.pointDescription.setName(address);
if (history) { }
settings.updateMapMarkerHistory(mapMarker.point.getLatitude(), mapMarker.point.getLongitude(), markersDbHelper.updateMarker(mapMarker);
mapMarker.pointDescription, mapMarker.colorIndex, mapMarker.creationDate); updateMarker(mapMarker);
} else { }
settings.updateMapMarker(mapMarker.point.getLatitude(), mapMarker.point.getLongitude(), }, null);
mapMarker.pointDescription, mapMarker.colorIndex, mapMarker.selected, mapMarker.creationDate);
}
updateMarker(mapMarker);
}
}, null);
ctx.getGeocodingLookupService().lookupAddress(lookupRequest); ctx.getGeocodingLookupService().lookupAddress(lookupRequest);
} }
} }
public void removeMapMarker(int index) { public void syncAllGroups() {
settings.deleteMapMarker(index); List<MarkersSyncGroup> groups = markersDbHelper.getAllGroups();
MapMarker mapMarker = mapMarkers.remove(index); for (MarkersSyncGroup gr : groups) {
cancelPointAddressRequests(mapMarker.point); syncGroup(gr);
int ind = 0; }
for (MapMarker marker : mapMarkers) { }
marker.index = ind++;
public void syncGroup(MarkersSyncGroup group) {
if (markersDbHelper.getGroup(group.getId()) == null) {
return;
}
List<MapMarker> dbMarkers = markersDbHelper.getMarkersFromGroup(group);
if (group.getType() == MarkersSyncGroup.FAVORITES_TYPE) {
FavouritesDbHelper.FavoriteGroup favGroup = ctx.getFavorites().getGroup(group.name);
if (favGroup == null) {
return;
}
if (!favGroup.visible) {
removeActiveMarkersFromSyncGroup(group.id);
return;
}
List<FavouritePoint> favPoints = favGroup.points;
for (FavouritePoint fp : favPoints) {
LatLon fpLatLon = new LatLon(fp.getLatitude(), fp.getLongitude());
boolean exists = false;
for (MapMarker marker : dbMarkers) {
if (marker.id.equals(group.getId() + fp.getName(ctx))) {
exists = true;
if (!marker.history && !marker.point.equals(fpLatLon)) {
for (MapMarker m : mapMarkers) {
if (m.id.equals(marker.id)) {
m.point = fpLatLon;
updateMapMarker(m, true);
break;
}
}
}
dbMarkers.remove(marker);
break;
}
}
if (!exists) {
addMarkers(Collections.singletonList(fpLatLon),
Collections.singletonList(new PointDescription(POINT_TYPE_MAP_MARKER, fp.getName())), group);
}
}
if (!dbMarkers.isEmpty()) {
for (MapMarker marker : dbMarkers) {
if (!marker.history) {
markersDbHelper.removeMarker(marker, false);
mapMarkers.remove(marker);
checkAndFixActiveMarkersOrderIfNeeded();
refresh();
}
}
}
} else {
}
}
public void moveMapMarkerToHistory(MapMarker marker) {
if (marker != null) {
cancelPointAddressRequests(marker.point);
markersDbHelper.moveMarkerToHistory(marker);
mapMarkers.remove(marker);
marker.history = true;
marker.nextKey = MapMarkersDbHelper.HISTORY_NEXT_VALUE;
mapMarkersHistory.add(marker);
checkAndFixActiveMarkersOrderIfNeeded();
sortMarkers(mapMarkersHistory, true);
refresh();
}
}
public void addMarker(MapMarker marker) {
if (marker != null) {
markersDbHelper.addMarker(marker);
if (marker.history) {
mapMarkersHistory.add(marker);
sortMarkers(mapMarkersHistory, true);
} else {
mapMarkers.add(marker);
checkAndFixActiveMarkersOrderIfNeeded();
}
refresh();
}
}
public void restoreMarkerFromHistory(MapMarker marker, int position) {
if (marker != null) {
markersDbHelper.restoreMapMarkerFromHistory(marker);
mapMarkersHistory.remove(marker);
marker.history = false;
mapMarkers.add(position, marker);
checkAndFixActiveMarkersOrderIfNeeded();
sortMarkers(mapMarkersHistory, true);
refresh();
}
}
public void restoreMarkersFromHistory(List<MapMarker> markers) {
if (markers != null) {
for (MapMarker marker : markers) {
markersDbHelper.restoreMapMarkerFromHistory(marker);
mapMarkersHistory.remove(marker);
marker.history = false;
mapMarkers.add(marker);
}
checkAndFixActiveMarkersOrderIfNeeded();
sortMarkers(mapMarkersHistory, true);
refresh();
}
}
public void removeMarkerFromHistory(MapMarker marker) {
if (marker != null) {
markersDbHelper.removeMarker(marker, true);
mapMarkersHistory.remove(marker);
refresh();
} }
refresh();
} }
public List<MapMarker> getMapMarkers() { public List<MapMarker> getMapMarkers() {
@ -293,58 +468,73 @@ public class MapMarkersHelper {
public void reverseActiveMarkersOrder() { public void reverseActiveMarkersOrder() {
cancelAddressRequests(); cancelAddressRequests();
Collections.reverse(mapMarkers);
List<MapMarker> markers = new ArrayList<>(mapMarkers.size()); checkAndFixActiveMarkersOrderIfNeeded();
for (int i = mapMarkers.size() - 1; i >= 0; i--) {
MapMarker marker = mapMarkers.get(i);
markers.add(marker);
}
mapMarkers = markers;
saveMapMarkers(mapMarkers, null);
} }
public void removeActiveMarkers() { public void moveAllActiveMarkersToHistory() {
cancelAddressRequests(); cancelAddressRequests();
for (int i = mapMarkers.size() - 1; i>= 0; i--) { long timestamp = System.currentTimeMillis();
MapMarker marker = mapMarkers.get(i); markersDbHelper.moveAllActiveMarkersToHistory(timestamp);
addMapMarkerHistory(marker); for (MapMarker marker : mapMarkers) {
marker.visitedDate = timestamp;
marker.history = true;
marker.nextKey = MapMarkersDbHelper.HISTORY_NEXT_VALUE;
} }
settings.clearActiveMapMarkers(); mapMarkersHistory.addAll(mapMarkers);
readFromSettings(); mapMarkers.clear();
sortMarkers(mapMarkersHistory, true);
refresh(); refresh();
} }
public void removeMarkersHistory() { public void removeMarkersHistory() {
cancelAddressRequests(); cancelAddressRequests();
settings.clearMapMarkersHistory(); markersDbHelper.clearAllMarkersHistory();
readFromSettings(); mapMarkersHistory.clear();
refresh(); refresh();
} }
public void addMapMarker(MapMarker marker, int index) { public void addMarkersSyncGroup(MarkersSyncGroup group) {
settings.insertMapMarker(marker.getLatitude(), marker.getLongitude(), marker.pointDescription, if (group != null) {
marker.colorIndex, marker.selected, marker.creationDate, index); if (markersDbHelper.getGroup(group.getId()) == null) {
readFromSettings(); markersDbHelper.addGroup(group.getId(), group.getName(), group.getType());
}
}
}
public void removeMarkersSyncGroup(String id, boolean removeActiveMarkers) {
if (id != null) {
markersDbHelper.removeMarkersSyncGroup(id);
if (removeActiveMarkers) {
removeActiveMarkersFromSyncGroup(id);
}
}
}
public void removeActiveMarkersFromSyncGroup(String syncGroupId) {
if (syncGroupId != null) {
markersDbHelper.removeActiveMarkersFromSyncGroup(syncGroupId);
for (Iterator<MapMarker> iterator = mapMarkers.iterator(); iterator.hasNext(); ) {
if (iterator.next().groupKey.equals(syncGroupId)) {
iterator.remove();
}
}
checkAndFixActiveMarkersOrderIfNeeded();
refresh();
}
} }
public void addMapMarker(LatLon point, PointDescription historyName) { public void addMapMarker(LatLon point, PointDescription historyName) {
List<LatLon> points = new ArrayList<>(1); addMarkers(Collections.singletonList(point), Collections.singletonList(historyName), null);
List<PointDescription> historyNames = new ArrayList<>(1);
points.add(point);
historyNames.add(historyName);
addMapMarkers(points, historyNames);
} }
public void addMapMarkers(List<LatLon> points, List<PointDescription> historyNames) { public void addMapMarkers(List<LatLon> points, List<PointDescription> historyNames, @Nullable MarkersSyncGroup group) {
addMarkers(points, historyNames, group);
}
private void addMarkers(List<LatLon> points, List<PointDescription> historyNames, @Nullable MarkersSyncGroup group) {
if (points.size() > 0) { if (points.size() > 0) {
int colorIndex = -1; int colorIndex = -1;
double[] latitudes = new double[points.size()];
double[] longitudes = new double[points.size()];
List<PointDescription> pointDescriptions = new ArrayList<>();
int[] colorIndexes = new int[points.size()];
int[] positions = new int[points.size()];
boolean[] selections = new boolean[points.size()];
int[] indexes = new int[points.size()];
for (int i = 0; i < points.size(); i++) { for (int i = 0; i < points.size(); i++) {
LatLon point = points.get(i); LatLon point = points.get(i);
PointDescription historyName = historyNames.get(i); PointDescription historyName = historyNames.get(i);
@ -359,7 +549,7 @@ public class MapMarkersHelper {
} }
if (colorIndex == -1) { if (colorIndex == -1) {
if (mapMarkers.size() > 0) { if (mapMarkers.size() > 0) {
colorIndex = (mapMarkers.get(0).colorIndex + 1) % MAP_MARKERS_COLORS_COUNT; colorIndex = (mapMarkers.get(mapMarkers.size() - 1).colorIndex + 1) % MAP_MARKERS_COLORS_COUNT;
} else { } else {
colorIndex = 0; colorIndex = 0;
} }
@ -367,33 +557,28 @@ public class MapMarkersHelper {
colorIndex = (colorIndex + 1) % MAP_MARKERS_COLORS_COUNT; colorIndex = (colorIndex + 1) % MAP_MARKERS_COLORS_COUNT;
} }
latitudes[i] = point.getLatitude(); MapMarker marker = new MapMarker(point, pointDescription, colorIndex, false, 0);
longitudes[i] = point.getLongitude(); if (group != null) {
pointDescriptions.add(pointDescription); marker.id = group.getId() + marker.getName(ctx);
colorIndexes[i] = colorIndex; if (markersDbHelper.getMarker(marker.id) != null) {
positions[i] = -1 - i; continue;
selections[i] = false; }
indexes[i] = 0; marker.groupName = group.getName();
marker.groupKey = group.getId();
}
marker.history = false;
marker.nextKey = MapMarkersDbHelper.TAIL_NEXT_VALUE;
markersDbHelper.addMarker(marker);
mapMarkers.add(marker);
checkAndFixActiveMarkersOrderIfNeeded();
} }
/* adding map marker to second topbar's row
if (sortedMapMarkers.size() > 0) {
MapMarker firstMarker = sortedMapMarkers.get(0);
settings.updateMapMarker(firstMarker.getLatitude(), firstMarker.getLongitude(),
firstMarker.pointDescription, firstMarker.colorIndex, -points.size(), firstMarker.selected);
}
*/
settings.insertMapMarkers(latitudes, longitudes, pointDescriptions, colorIndexes, positions,
selections, indexes);
readFromSettings();
} }
} }
public void updateMapMarker(MapMarker marker, boolean refresh) { public void updateMapMarker(MapMarker marker, boolean refresh) {
if (marker != null) { if (marker != null) {
settings.updateMapMarker(marker.getLatitude(), marker.getLongitude(), markersDbHelper.updateMarker(marker);
marker.pointDescription, marker.colorIndex, marker.selected, marker.creationDate);
if (refresh) { if (refresh) {
readFromSettings();
refresh(); refresh();
} }
} }
@ -401,35 +586,24 @@ public class MapMarkersHelper {
public void moveMapMarker(@Nullable MapMarker marker, LatLon latLon) { public void moveMapMarker(@Nullable MapMarker marker, LatLon latLon) {
if (marker != null) { if (marker != null) {
settings.moveMapMarker(new LatLon(marker.getLatitude(), marker.getLongitude()), latLon, LatLon point = new LatLon(latLon.getLatitude(), latLon.getLongitude());
marker.pointDescription, marker.colorIndex, marker.selected, marker.creationDate); int index = mapMarkers.indexOf(marker);
marker.point = new LatLon(latLon.getLatitude(), latLon.getLongitude()); if (index != -1) {
readFromSettings(); mapMarkers.get(index).point = point;
}
marker.point = point;
markersDbHelper.updateMarker(marker);
checkAndFixActiveMarkersOrderIfNeeded();
refresh(); refresh();
} }
} }
public void removeMapMarker(MapMarker marker) { public void moveMarkerToTop(MapMarker marker) {
if (marker != null) { int i = mapMarkers.indexOf(marker);
settings.deleteMapMarker(marker.index); if (i != -1 && mapMarkers.size() > 1) {
readFromSettings(); mapMarkers.remove(i);
refresh(); mapMarkers.add(0, marker);
} checkAndFixActiveMarkersOrderIfNeeded();
}
public void addMapMarkerHistory(MapMarker marker) {
if (marker != null) {
settings.insertMapMarkerHistory(marker.getLatitude(), marker.getLongitude(),
marker.pointDescription, marker.colorIndex, marker.creationDate, 0);
readFromSettings();
refresh();
}
}
public void removeMapMarkerHistory(MapMarker marker) {
if (marker != null) {
settings.deleteMapMarkerHistory(marker.index);
readFromSettings();
refresh(); refresh();
} }
} }
@ -466,7 +640,7 @@ public class MapMarkersHelper {
} }
if (markers != null || markersHistory != null) { if (markers != null || markersHistory != null) {
readFromSettings(); loadMarkers();
refresh(); refresh();
} }
} }
@ -513,4 +687,28 @@ public class MapMarkersHelper {
ctx.getGeocodingLookupService().cancel(latLon); ctx.getGeocodingLookupService().cancel(latLon);
} }
} }
public void generateGpx() {
final File dir = ctx.getAppPath(IndexConstants.GPX_INDEX_DIR + "/map markers");
if (!dir.exists()) {
dir.mkdirs();
}
Date date = new Date();
String fileName = DateFormat.format("yyyy-MM-dd", date).toString() + "_" + new SimpleDateFormat("HH-mm_EEE", Locale.US).format(date);
File fout = new File(dir, fileName + ".gpx");
int ind = 1;
while (fout.exists()) {
fout = new File(dir, fileName + "_" + (++ind) + ".gpx");
}
GPXUtilities.GPXFile file = new GPXUtilities.GPXFile();
for (MapMarker marker : markersDbHelper.getActiveMarkers()) {
GPXUtilities.WptPt wpt = new GPXUtilities.WptPt();
wpt.lat = marker.getLatitude();
wpt.lon = marker.getLongitude();
wpt.setColor(ctx.getResources().getColor(MapMarker.getColorId(marker.colorIndex)));
wpt.name = marker.getOnlyName();
file.points.add(wpt);
}
GPXUtilities.writeGpxFile(fout, file, ctx);
}
} }

View file

@ -47,6 +47,7 @@ import net.osmand.plus.helpers.AvoidSpecificRoads;
import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.helpers.WaypointHelper;
import net.osmand.plus.inapp.InAppHelper; import net.osmand.plus.inapp.InAppHelper;
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu; import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu;
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
import net.osmand.plus.monitoring.LiveMonitoringHelper; import net.osmand.plus.monitoring.LiveMonitoringHelper;
import net.osmand.plus.poi.PoiFiltersHelper; import net.osmand.plus.poi.PoiFiltersHelper;
import net.osmand.plus.render.RendererRegistry; import net.osmand.plus.render.RendererRegistry;
@ -107,6 +108,7 @@ public class OsmandApplication extends MultiDexApplication {
LiveMonitoringHelper liveMonitoringHelper; LiveMonitoringHelper liveMonitoringHelper;
TargetPointsHelper targetPointsHelper; TargetPointsHelper targetPointsHelper;
MapMarkersHelper mapMarkersHelper; MapMarkersHelper mapMarkersHelper;
MapMarkersDbHelper mapMarkersDbHelper;
WaypointHelper waypointHelper; WaypointHelper waypointHelper;
DownloadIndexesThread downloadIndexesThread; DownloadIndexesThread downloadIndexesThread;
AvoidSpecificRoads avoidSpecificRoads; AvoidSpecificRoads avoidSpecificRoads;
@ -615,6 +617,10 @@ public class OsmandApplication extends MultiDexApplication {
return mapMarkersHelper; return mapMarkersHelper;
} }
public MapMarkersDbHelper getMapMarkersDbHelper() {
return mapMarkersDbHelper;
}
public void showShortToastMessage(final int msgId, final Object... args) { public void showShortToastMessage(final int msgId, final Object... args) {
uiHandler.post(new Runnable() { uiHandler.post(new Runnable() {
@Override @Override

View file

@ -6,6 +6,8 @@ import android.app.backup.BackupAgentHelper;
import android.app.backup.FileBackupHelper; import android.app.backup.FileBackupHelper;
import android.app.backup.SharedPreferencesBackupHelper; import android.app.backup.SharedPreferencesBackupHelper;
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
/** /**
* Requires android API from android-8 * Requires android API from android-8
*/ */
@ -25,7 +27,7 @@ public class OsmandBackupAgent extends BackupAgentHelper {
SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this, prefs); SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this, prefs);
addHelper("osmand.settings", helper); addHelper("osmand.settings", helper);
FileBackupHelper fileBackupHelper = new FileBackupHelper(this, FavouritesDbHelper.FILE_TO_BACKUP); FileBackupHelper fileBackupHelper = new FileBackupHelper(this, FavouritesDbHelper.FILE_TO_BACKUP, "../databases/" + MapMarkersDbHelper.DB_NAME);
addHelper(FavouritesDbHelper.FILE_TO_BACKUP, fileBackupHelper); addHelper("osmand.files", fileBackupHelper);
} }
} }

View file

@ -855,6 +855,9 @@ public class OsmandSettings {
public final OsmandPreference<Float> SPEED_LIMIT_EXCEED = public final OsmandPreference<Float> SPEED_LIMIT_EXCEED =
new FloatPreference("speed_limit_exceed", 5f).makeProfile(); new FloatPreference("speed_limit_exceed", 5f).makeProfile();
public final OsmandPreference<Float> SWITCH_MAP_DIRECTION_TO_COMPASS =
new FloatPreference("speed_for_map_to_direction_of_movement", 0f).makeProfile();
// this value string is synchronized with settings_pref.xml preference name // this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> USE_TRACKBALL_FOR_MOVEMENTS = public final OsmandPreference<Boolean> USE_TRACKBALL_FOR_MOVEMENTS =
new BooleanPreference("use_trackball_for_movements", true).makeGlobal(); new BooleanPreference("use_trackball_for_movements", true).makeGlobal();

View file

@ -30,6 +30,7 @@ import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.IconsCache; import net.osmand.plus.IconsCache;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.base.BottomSheetDialogFragment; import net.osmand.plus.base.BottomSheetDialogFragment;
@ -188,7 +189,9 @@ public class EditFavoriteGroupDialogFragment extends BottomSheetDialogFragment {
points.add(new LatLon(fp.getLatitude(), fp.getLongitude())); points.add(new LatLon(fp.getLatitude(), fp.getLongitude()));
names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, fp.getName())); names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, fp.getName()));
} }
markersHelper.addMapMarkers(points, names); MarkersSyncGroup syncGroup = new MarkersSyncGroup(group.name, group.name, MarkersSyncGroup.FAVORITES_TYPE);
markersHelper.addMarkersSyncGroup(syncGroup);
markersHelper.addMapMarkers(points, names, syncGroup);
dismiss(); dismiss();
MapActivity.launchMapActivityMoveToTop(getActivity()); MapActivity.launchMapActivityMoveToTop(getActivity());
} }

View file

@ -36,6 +36,7 @@ import net.osmand.data.PointDescription;
import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
@ -57,6 +58,7 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -80,7 +82,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
private OsmandApplication app; private OsmandApplication app;
private boolean selectionMode = false; private boolean selectionMode = false;
private Set<FavouritePoint> favoritesSelected = new LinkedHashSet<>(); private LinkedHashMap<String, Set<FavouritePoint>> favoritesSelected = new LinkedHashMap<>();
private Set<FavoriteGroup> groupsToDelete = new LinkedHashSet<>(); private Set<FavoriteGroup> groupsToDelete = new LinkedHashSet<>();
private ActionMode actionMode; private ActionMode actionMode;
Drawable arrowImage; Drawable arrowImage;
@ -127,7 +129,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
@Override @Override
protected String doInBackground(Void... params) { protected String doInBackground(Void... params) {
helper.delete(groupsToDelete, favoritesSelected); helper.delete(groupsToDelete, getSelectedFavorites());
favoritesSelected.clear(); favoritesSelected.clear();
groupsToDelete.clear(); groupsToDelete.clear();
return getString(R.string.favourites_delete_multiple_succesful); return getString(R.string.favourites_delete_multiple_succesful);
@ -206,14 +208,35 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
initListExpandedState(); initListExpandedState();
} }
private int getSelectedFavoritesCount() {
int count = 0;
for (Set<FavouritePoint> set : favoritesSelected.values()) {
if (set != null) {
count += set.size();
}
}
return count;
}
private Set<FavouritePoint> getSelectedFavorites() {
Set<FavouritePoint> result = new LinkedHashSet<>();
for (Set<FavouritePoint> set : favoritesSelected.values()) {
if (set != null) {
result.addAll(set);
}
}
return result;
}
public void reloadData() { public void reloadData() {
favouritesAdapter.synchronizeGroups(); favouritesAdapter.synchronizeGroups();
favouritesAdapter.notifyDataSetInvalidated(); favouritesAdapter.notifyDataSetInvalidated();
} }
private void updateSelectionMode(ActionMode m) { private void updateSelectionMode(ActionMode m) {
if (favoritesSelected.size() > 0) { int size = getSelectedFavoritesCount();
m.setTitle(favoritesSelected.size() + " " + getMyApplication().getString(R.string.shared_string_selected_lowercase)); if (size > 0) {
m.setTitle(size + " " + getMyApplication().getString(R.string.shared_string_selected_lowercase));
} else { } else {
m.setTitle(""); m.setTitle("");
} }
@ -224,11 +247,22 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
if (selectionMode) { if (selectionMode) {
CheckBox ch = (CheckBox) v.findViewById(R.id.toggle_item); CheckBox ch = (CheckBox) v.findViewById(R.id.toggle_item);
FavouritePoint model = favouritesAdapter.getChild(groupPosition, childPosition); FavouritePoint model = favouritesAdapter.getChild(groupPosition, childPosition);
FavoriteGroup group = favouritesAdapter.getGroup(groupPosition);
ch.setChecked(!ch.isChecked()); ch.setChecked(!ch.isChecked());
if (ch.isChecked()) { if (ch.isChecked()) {
favoritesSelected.add(model); Set<FavouritePoint> set = favoritesSelected.get(group.name);
if (set != null) {
set.add(model);
} else {
set = new LinkedHashSet<>();
set.add(model);
favoritesSelected.put(group.name, set);
}
} else { } else {
favoritesSelected.remove(model); Set<FavouritePoint> set = favoritesSelected.get(group.name);
if (set != null) {
set.remove(model);
}
} }
updateSelectionMode(actionMode); updateSelectionMode(actionMode);
} else { } else {
@ -308,14 +342,14 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
public void showProgressBar() { public void showProgressBar() {
OsmandActionBarActivity activity = getActionBarActivity(); OsmandActionBarActivity activity = getActionBarActivity();
if(activity != null) { if (activity != null) {
activity.setSupportProgressBarIndeterminateVisibility(true); activity.setSupportProgressBarIndeterminateVisibility(true);
} }
} }
public void hideProgressBar() { public void hideProgressBar() {
OsmandActionBarActivity activity = getActionBarActivity(); OsmandActionBarActivity activity = getActionBarActivity();
if(activity != null) { if (activity != null) {
activity.setSupportProgressBarIndeterminateVisibility(false); activity.setSupportProgressBarIndeterminateVisibility(false);
} }
} }
@ -366,20 +400,29 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
} }
private void selectMapMarkersImpl() { private void selectMapMarkersImpl() {
if(!favoritesSelected.isEmpty()) { if (getSelectedFavoritesCount() > 0) {
if (getSettings().USE_MAP_MARKERS.get()) { if (getSettings().USE_MAP_MARKERS.get()) {
MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper(); MapMarkersHelper markersHelper = getMyApplication().getMapMarkersHelper();
List<LatLon> points = new ArrayList<>(favoritesSelected.size()); List<LatLon> points = new LinkedList<>();
List<PointDescription> names = new ArrayList<>(favoritesSelected.size()); List<PointDescription> names = new LinkedList<>();
for (FavouritePoint fp : favoritesSelected) { for (Map.Entry<String, Set<FavouritePoint>> entry : favoritesSelected.entrySet()) {
points.add(new LatLon(fp.getLatitude(), fp.getLongitude())); FavoriteGroup favGr = helper.getGroup(entry.getKey());
names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, fp.getName())); MarkersSyncGroup syncGr = new MarkersSyncGroup(favGr.name, favGr.name, MarkersSyncGroup.FAVORITES_TYPE);
if (entry.getValue().size() == favGr.points.size()) {
markersHelper.addMarkersSyncGroup(syncGr);
}
for (FavouritePoint fp : entry.getValue()) {
points.add(new LatLon(fp.getLatitude(), fp.getLongitude()));
names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, fp.getName()));
}
markersHelper.addMapMarkers(points, names, syncGr);
points.clear();
names.clear();
} }
markersHelper.addMapMarkers(points, names);
MapActivity.launchMapActivityMoveToTop(getActivity()); MapActivity.launchMapActivityMoveToTop(getActivity());
} else { } else {
final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper(); final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
for (FavouritePoint fp : favoritesSelected) { for (FavouritePoint fp : getSelectedFavorites()) {
targetPointsHelper.navigateToPoint(new LatLon(fp.getLatitude(), fp.getLongitude()), false, targetPointsHelper.navigateToPoint(new LatLon(fp.getLatitude(), fp.getLongitude()), false,
targetPointsHelper.getIntermediatePoints().size() + 1, targetPointsHelper.getIntermediatePoints().size() + 1,
new PointDescription(PointDescription.POINT_TYPE_FAVORITE, fp.getName())); new PointDescription(PointDescription.POINT_TYPE_FAVORITE, fp.getName()));
@ -441,10 +484,11 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
} }
private void deleteFavoritesAction() { private void deleteFavoritesAction() {
if (groupsToDelete.size() + favoritesSelected.size() > 0) { int size = getSelectedFavoritesCount();
if (groupsToDelete.size() + size > 0) {
AlertDialog.Builder b = new AlertDialog.Builder(getActivity()); AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
b.setMessage(getString(R.string.favorite_delete_multiple, favoritesSelected.size(), groupsToDelete.size())); b.setMessage(getString(R.string.favorite_delete_multiple, size, groupsToDelete.size()));
b.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() { b.setPositiveButton(R.string.shared_string_delete, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
@ -463,13 +507,13 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
StringBuilder html = new StringBuilder(); StringBuilder html = new StringBuilder();
html.append("<h1>My Favorites</h1>"); html.append("<h1>My Favorites</h1>");
for (FavoriteGroup group : groups) { for (FavoriteGroup group : groups) {
html.append("<h3>"+group.name+"</h3>"); html.append("<h3>" + group.name + "</h3>");
for(FavouritePoint fp : group.points) { for (FavouritePoint fp : group.points) {
String url = "geo:"+((float)fp.getLatitude())+","+((float)fp.getLongitude())+"?m="+fp.getName(); String url = "geo:" + ((float) fp.getLatitude()) + "," + ((float) fp.getLongitude()) + "?m=" + fp.getName();
html.append("<p>" + fp.getName() + " - " + "<a href=\"" + url + "\">geo:" html.append("<p>" + fp.getName() + " - " + "<a href=\"" + url + "\">geo:"
+ ((float) fp.getLatitude()) + "," + ((float) fp.getLongitude()) + "</a><br>"); + ((float) fp.getLatitude()) + "," + ((float) fp.getLongitude()) + "</a><br>");
if(!Algorithms.isEmpty(fp.getDescription())) { if (!Algorithms.isEmpty(fp.getDescription())) {
html.append(": " + fp.getDescription()); html.append(": " + fp.getDescription());
} }
html.append("</p>"); html.append("</p>");
@ -521,7 +565,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
@Override @Override
protected void onPostExecute(Void res) { protected void onPostExecute(Void res) {
hideProgressBar(); hideProgressBar();
if(getActivity() == null) { if (getActivity() == null) {
// user quit application // user quit application
return; return;
} }
@ -763,13 +807,17 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
if (ch.isChecked()) { if (ch.isChecked()) {
groupsToDelete.add(model); groupsToDelete.add(model);
if (fvs != null) { if (fvs != null) {
favoritesSelected.addAll(fvs); Set<FavouritePoint> set = favoritesSelected.get(model.name);
if (set != null) {
set.addAll(model.points);
} else {
set = new LinkedHashSet<>(model.points);
favoritesSelected.put(model.name, set);
}
} }
} else { } else {
groupsToDelete.remove(model); groupsToDelete.remove(model);
if (fvs != null) { favoritesSelected.remove(model.name);
favoritesSelected.removeAll(fvs);
}
} }
favouritesAdapter.notifyDataSetInvalidated(); favouritesAdapter.notifyDataSetInvalidated();
updateSelectionMode(actionMode); updateSelectionMode(actionMode);
@ -820,6 +868,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon); ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon);
final FavouritePoint model = getChild(groupPosition, childPosition); final FavouritePoint model = getChild(groupPosition, childPosition);
final FavoriteGroup group = getGroup(groupPosition);
boolean visible = model.isVisible(); boolean visible = model.isVisible();
row.setTag(model); row.setTag(model);
@ -864,16 +913,26 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item); final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
if (selectionMode) { if (selectionMode) {
ch.setVisibility(View.VISIBLE); ch.setVisibility(View.VISIBLE);
ch.setChecked(favoritesSelected.contains(model)); ch.setChecked(favoritesSelected.get(group.name) != null && favoritesSelected.get(group.name).contains(model));
row.findViewById(R.id.favourite_icon).setVisibility(View.GONE); row.findViewById(R.id.favourite_icon).setVisibility(View.GONE);
ch.setOnClickListener(new View.OnClickListener() { ch.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (ch.isChecked()) { if (ch.isChecked()) {
favoritesSelected.add(model); Set<FavouritePoint> set = favoritesSelected.get(group.name);
if (set != null) {
set.add(model);
} else {
set = new LinkedHashSet<>();
set.add(model);
favoritesSelected.put(group.name, set);
}
} else { } else {
favoritesSelected.remove(model); Set<FavouritePoint> set = favoritesSelected.get(group.name);
if (set != null) {
set.remove(model);
}
} }
updateSelectionMode(actionMode); updateSelectionMode(actionMode);
} }

View file

@ -614,18 +614,6 @@ public class MapActivityActions implements DialogProvider {
}).createItem()); }).createItem());
if (settings.USE_MAP_MARKERS.get()) { if (settings.USE_MAP_MARKERS.get()) {
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.map_markers, mapActivity) optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.map_markers, mapActivity)
.setIcon(R.drawable.ic_action_flag_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
app.logEvent(mapActivity, "drawer_markers_open");
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.MAP_MARKERS);
return false;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitle("New map markers")
.setIcon(R.drawable.ic_action_flag_dark) .setIcon(R.drawable.ic_action_flag_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() { .setListener(new ContextMenuAdapter.ItemClickListener() {
@Override @Override

View file

@ -202,12 +202,14 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
speedNames[i] = speedLimitsKm[i] + " " + getString(R.string.km_h); speedNames[i] = speedLimitsKm[i] + " " + getString(R.string.km_h);
} }
registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimitsKm); registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimitsKm);
registerListPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS, screen, speedNames, speedLimitsKm);
} else { } else {
String[] speedNames = new String[speedLimitsKm.length]; String[] speedNames = new String[speedLimitsKm.length];
for (int i =0; i<speedNames.length;i++){ for (int i =0; i<speedNames.length;i++){
speedNames[i] = speedLimitsMiles[i] + " " + getString(R.string.mile_per_hour); speedNames[i] = speedLimitsMiles[i] + " " + getString(R.string.mile_per_hour);
} }
registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimitsKm); registerListPreference(settings.SPEED_LIMIT_EXCEED, screen, speedNames, speedLimitsKm);
registerListPreference(settings.SWITCH_MAP_DIRECTION_TO_COMPASS, screen, speedNames, speedLimitsKm);
} }
PreferenceCategory category = (PreferenceCategory) screen.findPreference("guidance_preferences"); PreferenceCategory category = (PreferenceCategory) screen.findPreference("guidance_preferences");

View file

@ -123,7 +123,9 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
public void updateCompassValue(float val) { public void updateCompassValue(float val) {
heading = val; heading = val;
if (mapView != null) { if (mapView != null) {
if (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_COMPASS && !routePlanningMode) { float speedForDirectionOfMovement = settings.SWITCH_MAP_DIRECTION_TO_COMPASS.get();
boolean smallSpeedForDirectionOfMovement = speedForDirectionOfMovement != 0 && getMyLocation() != null && isSmallSpeedForDirectionOfMovement(getMyLocation(), speedForDirectionOfMovement);
if ((settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_COMPASS || (settings.ROTATE_MAP.get() == OsmandSettings.ROTATE_MAP_BEARING && smallSpeedForDirectionOfMovement)) && !routePlanningMode) {
if (Math.abs(MapUtils.degreesDiff(mapView.getRotate(), -val)) > 1) { if (Math.abs(MapUtils.degreesDiff(mapView.getRotate(), -val)) > 1) {
mapView.setRotate(-val); mapView.setRotate(-val);
} }
@ -201,13 +203,17 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
zoom = autozoom(location); zoom = autozoom(location);
} }
int currentMapRotation = settings.ROTATE_MAP.get(); int currentMapRotation = settings.ROTATE_MAP.get();
float speedForDirectionOfMovement = settings.SWITCH_MAP_DIRECTION_TO_COMPASS.get();
boolean smallSpeedForDirectionOfMovement = speedForDirectionOfMovement != 0 && isSmallSpeedForDirectionOfMovement(location, speedForDirectionOfMovement);
boolean smallSpeedForCompass = isSmallSpeedForCompass(location); boolean smallSpeedForCompass = isSmallSpeedForCompass(location);
boolean smallSpeedForAnimation = isSmallSpeedForAnimation(location); boolean smallSpeedForAnimation = isSmallSpeedForAnimation(location);
// boolean virtualBearing = fMode && settings.SNAP_TO_ROAD.get(); // boolean virtualBearing = fMode && settings.SNAP_TO_ROAD.get();
showViewAngle = (!location.hasBearing() || smallSpeedForCompass) && (tb != null && showViewAngle = (!location.hasBearing() || smallSpeedForCompass) && (tb != null &&
tb.containsLatLon(location.getLatitude(), location.getLongitude())); tb.containsLatLon(location.getLatitude(), location.getLongitude()));
if (currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING) { if (currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING) {
if (location.hasBearing() && !smallSpeedForCompass) { if (smallSpeedForDirectionOfMovement) {
showViewAngle = routePlanningMode;
} else if (location.hasBearing() && !smallSpeedForCompass) {
// special case when bearing equals to zero (we don't change anything) // special case when bearing equals to zero (we don't change anything)
if (location.getBearing() != 0f) { if (location.getBearing() != 0f) {
rotation = -location.getBearing(); rotation = -location.getBearing();
@ -216,7 +222,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
} else if(currentMapRotation == OsmandSettings.ROTATE_MAP_COMPASS) { } else if(currentMapRotation == OsmandSettings.ROTATE_MAP_COMPASS) {
showViewAngle = routePlanningMode; // disable compass rotation in that mode showViewAngle = routePlanningMode; // disable compass rotation in that mode
} }
registerUnregisterSensor(location); registerUnregisterSensor(location, smallSpeedForDirectionOfMovement);
if (settings.ANIMATE_MY_LOCATION.get() && !smallSpeedForAnimation && !movingToMyLocation && if (settings.ANIMATE_MY_LOCATION.get() && !smallSpeedForAnimation && !movingToMyLocation &&
settings.WAKE_ON_VOICE_INT.get() == 0) { settings.WAKE_ON_VOICE_INT.get() == 0) {
mapView.getAnimatedDraggingThread().startMoving( mapView.getAnimatedDraggingThread().startMoving(
@ -233,7 +239,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
} else if(location != null) { } else if(location != null) {
showViewAngle = (!location.hasBearing() || isSmallSpeedForCompass(location)) && (tb != null && showViewAngle = (!location.hasBearing() || isSmallSpeedForCompass(location)) && (tb != null &&
tb.containsLatLon(location.getLatitude(), location.getLongitude())); tb.containsLatLon(location.getLatitude(), location.getLongitude()));
registerUnregisterSensor(location); registerUnregisterSensor(location, false);
} }
RoutingHelper routingHelper = app.getRoutingHelper(); RoutingHelper routingHelper = app.getRoutingHelper();
followingMode = routingHelper.isFollowingMode(); followingMode = routingHelper.isFollowingMode();
@ -252,6 +258,10 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
} }
} }
public static boolean isSmallSpeedForDirectionOfMovement(Location location, float speedToDirectionOfMovement) {
return !location.hasSpeed() || location.getSpeed() < speedToDirectionOfMovement;
}
public static boolean isSmallSpeedForCompass(Location location) { public static boolean isSmallSpeedForCompass(Location location) {
return !location.hasSpeed() || location.getSpeed() < 0.5; return !location.hasSpeed() || location.getSpeed() < 0.5;
} }
@ -285,14 +295,15 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
&& !settings.CENTER_POSITION_ON_MAP.get() ? && !settings.CENTER_POSITION_ON_MAP.get() ?
OsmandSettings.BOTTOM_CONSTANT : OsmandSettings.CENTER_CONSTANT); OsmandSettings.BOTTOM_CONSTANT : OsmandSettings.CENTER_CONSTANT);
} }
registerUnregisterSensor(app.getLocationProvider().getLastKnownLocation()); registerUnregisterSensor(app.getLocationProvider().getLastKnownLocation(), false);
} }
private void registerUnregisterSensor(net.osmand.Location location) { private void registerUnregisterSensor(net.osmand.Location location, boolean smallSpeedForDirectionOfMovement) {
int currentMapRotation = settings.ROTATE_MAP.get(); int currentMapRotation = settings.ROTATE_MAP.get();
boolean registerCompassListener = ((showViewAngle || contextMenu != null) && location != null) boolean registerCompassListener = ((showViewAngle || contextMenu != null) && location != null)
|| (currentMapRotation == OsmandSettings.ROTATE_MAP_COMPASS && !routePlanningMode); || (currentMapRotation == OsmandSettings.ROTATE_MAP_COMPASS && !routePlanningMode)
|| (currentMapRotation == OsmandSettings.ROTATE_MAP_BEARING && smallSpeedForDirectionOfMovement);
// show point view only if gps enabled // show point view only if gps enabled
if(sensorRegistered != registerCompassListener) { if(sensorRegistered != registerCompassListener) {
app.getLocationProvider().registerOrUnregisterCompassListener(registerCompassListener); app.getLocationProvider().registerOrUnregisterCompassListener(registerCompassListener);

View file

@ -120,6 +120,12 @@ public abstract class DashLocationFragment extends DashBaseFragment {
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h, public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, TextView txt, LatLon toLoc, ImageView arrow, int arrowResId, TextView txt, LatLon toLoc,
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) { int screenOrientation, OsmandApplication app, Context ctx, boolean paint) {
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, 0, txt, toLoc, screenOrientation, app, ctx, paint);
}
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, int color, TextView txt, LatLon toLoc,
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) {
float[] mes = new float[2]; float[] mes = new float[2];
if (fromLoc != null && toLoc != null) { if (fromLoc != null && toLoc != null) {
Location.distanceBetween(toLoc.getLatitude(), toLoc.getLongitude(), fromLoc.getLatitude(), fromLoc.getLongitude(), mes); Location.distanceBetween(toLoc.getLatitude(), toLoc.getLongitude(), fromLoc.getLatitude(), fromLoc.getLongitude(), mes);
@ -136,7 +142,7 @@ public abstract class DashLocationFragment extends DashBaseFragment {
} else { } else {
dd = (DirectionDrawable) arrow.getDrawable(); dd = (DirectionDrawable) arrow.getDrawable();
} }
dd.setImage(arrowResId, useCenter ? R.color.color_distance : R.color.color_myloc_distance); dd.setImage(arrowResId, color == 0 ? useCenter ? R.color.color_distance : R.color.color_myloc_distance : color);
if (fromLoc == null || h == null || toLoc == null) { if (fromLoc == null || h == null || toLoc == null) {
dd.setAngle(0); dd.setAngle(0);
} else { } else {

View file

@ -354,7 +354,7 @@ public class MapMarkerDialogHelper {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
listAdapter.notifyDataSetInvalidated(); listAdapter.notifyDataSetInvalidated();
markersHelper.removeActiveMarkers(); markersHelper.moveAllActiveMarkersToHistory();
if (markersHelper.getMapMarkersHistory().size() == 0) { if (markersHelper.getMapMarkersHistory().size() == 0) {
mapActivity.getDashboard().hideDashboard(); mapActivity.getDashboard().hideDashboard();
} else if (helperCallbacks != null) { } else if (helperCallbacks != null) {

View file

@ -10,7 +10,6 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.MapMarkerDialogHelper; import net.osmand.plus.helpers.MapMarkerDialogHelper;
import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapillary.MapillaryPlugin;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
public class MapMarkerMenuController extends MenuController { public class MapMarkerMenuController extends MenuController {
@ -25,8 +24,7 @@ public class MapMarkerMenuController extends MenuController {
leftTitleButtonController = new TitleButtonController() { leftTitleButtonController = new TitleButtonController() {
@Override @Override
public void buttonPressed() { public void buttonPressed() {
markersHelper.removeMapMarker(getMapMarker().index); markersHelper.moveMapMarkerToHistory(getMapMarker());
markersHelper.addMapMarkerHistory(getMapMarker());
getMapActivity().getContextMenu().close(); getMapActivity().getContextMenu().close();
} }
}; };

View file

@ -0,0 +1,149 @@
package net.osmand.plus.mapmarkers;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.R;
import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class HistoryMarkerMenuBottomSheetDialogFragment extends BottomSheetDialogFragment {
public final static String TAG = "HistoryMarkerMenuBottomSheetDialogFragment";
public static final String MARKER_POSITION = "marker_position";
public static final String MARKER_NAME = "marker_name";
public static final String MARKER_COLOR_INDEX = "marker_color_index";
public static final String MARKER_VISITED_DATE = "marker_visited_date";
private HistoryMarkerMenuFragmentListener listener;
private boolean portrait;
public void setListener(HistoryMarkerMenuFragmentListener listener) {
this.listener = listener;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_history_bottom_sheet_dialog, container);
if (portrait) {
AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
}
Bundle arguments = getArguments();
if (arguments != null) {
final int pos = arguments.getInt(MARKER_POSITION);
String markerName = arguments.getString(MARKER_NAME);
int markerColorIndex = arguments.getInt(MARKER_COLOR_INDEX);
long markerVisitedDate = arguments.getLong(MARKER_VISITED_DATE);
((TextView) mainView.findViewById(R.id.map_marker_title)).setText(markerName);
((ImageView) mainView.findViewById(R.id.map_marker_icon)).setImageDrawable(getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(markerColorIndex)));
((TextView) mainView.findViewById(R.id.map_marker_passed_info)).setText(getString(R.string.passed, new SimpleDateFormat("MMM dd", Locale.getDefault()).format(new Date(markerVisitedDate))));
mainView.findViewById(R.id.make_active_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener != null) {
listener.onMakeMarkerActive(pos);
}
dismiss();
}
});
mainView.findViewById(R.id.delete_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener != null) {
listener.onDeleteMarker(pos);
}
dismiss();
}
});
}
((ImageView) mainView.findViewById(R.id.make_active_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_reset_to_default_dark));
((ImageView) mainView.findViewById(R.id.delete_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_delete_dark));
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
final View scrollView = mainView.findViewById(R.id.history_marker_scroll_view);
int scrollViewHeight = scrollView.getHeight();
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
if (scrollViewHeight > spaceForScrollView) {
scrollView.getLayoutParams().height = spaceForScrollView;
scrollView.requestLayout();
}
if (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight()
>= AndroidUtils.dpToPx(getActivity(), 8)) {
AndroidUtils.setBackground(getActivity(), mainView, false,
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else {
AndroidUtils.setBackground(getActivity(), mainView, false,
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
}
}
ViewTreeObserver obs = mainView.getViewTreeObserver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
obs.removeOnGlobalLayoutListener(this);
} else {
obs.removeGlobalOnLayoutListener(this);
}
}
});
return mainView;
}
@Override
public void onStart() {
super.onStart();
if (!portrait) {
final Window window = getDialog().getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
window.setAttributes(params);
}
}
interface HistoryMarkerMenuFragmentListener {
void onMakeMarkerActive(int pos);
void onDeleteMarker(int pos);
}
}

View file

@ -49,7 +49,7 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
@Override @Override
public void onItemClick(View view) { public void onItemClick(View view) {
int pos = recyclerView.indexOfChild(view); int pos = recyclerView.getChildAdapterPosition(view);
MapMarker marker = adapter.getItem(pos); MapMarker marker = adapter.getItem(pos);
mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(), mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(),
15, marker.getPointDescription(mapActivity), true, marker); 15, marker.getPointDescription(mapActivity), true, marker);
@ -67,7 +67,9 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
public void onDragEnded(RecyclerView.ViewHolder holder) { public void onDragEnded(RecyclerView.ViewHolder holder) {
toPosition = holder.getAdapterPosition(); toPosition = holder.getAdapterPosition();
if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) { if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) {
mapActivity.getMyApplication().getMapMarkersHelper().saveMapMarkers(adapter.getItems(), null); hideSnackbar();
mapActivity.getMyApplication().getMapMarkersHelper().checkAndFixActiveMarkersOrderIfNeeded();
adapter.notifyDataSetChanged();
} }
} }
}); });
@ -121,15 +123,27 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
return null; return null;
} }
void setShowDirectionEnabled(boolean showDirectionEnabled) {
if (adapter != null) {
adapter.setShowDirectionEnabled(showDirectionEnabled);
}
}
void updateAdapter() { void updateAdapter() {
if (adapter != null) { if (adapter != null) {
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
} }
void hideSnackbar() {
if (adapter != null) {
adapter.hideSnackbar();
}
}
private void updateLocationUi() { private void updateLocationUi() {
final MapActivity mapActivity = (MapActivity) getActivity(); final MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity != null) { if (mapActivity != null && adapter != null) {
mapActivity.getMyApplication().runInUIThread(new Runnable() { mapActivity.getMyApplication().runInUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -141,7 +155,7 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL
adapter.setUseCenter(useCenter); adapter.setUseCenter(useCenter);
adapter.setLocation(useCenter ? mapActivity.getMapLocation() : new LatLon(location.getLatitude(), location.getLongitude())); adapter.setLocation(useCenter ? mapActivity.getMapLocation() : new LatLon(location.getLatitude(), location.getLongitude()));
adapter.setHeading(useCenter ? -mapActivity.getMapRotate() : heading); adapter.setHeading(useCenter ? -mapActivity.getMapRotate() : heading != null ? heading : 99);
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
}); });

View file

@ -0,0 +1,509 @@
package net.osmand.plus.mapmarkers;
import android.support.annotation.Nullable;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
import net.osmand.plus.helpers.SearchHistoryHelper;
import java.util.Calendar;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
public class MapMarkersDbHelper {
private static final int DB_VERSION = 2;
public static final String DB_NAME = "map_markers_db";
private static final String MARKERS_TABLE_NAME = "map_markers";
private static final String MARKERS_COL_ID = "marker_id";
private static final String MARKERS_COL_LAT = "marker_lat";
private static final String MARKERS_COL_LON = "marker_lon";
private static final String MARKERS_COL_DESCRIPTION = "marker_description";
private static final String MARKERS_COL_ACTIVE = "marker_active";
private static final String MARKERS_COL_ADDED = "marker_added";
private static final String MARKERS_COL_VISITED = "marker_visited";
private static final String MARKERS_COL_GROUP_NAME = "group_name";
private static final String MARKERS_COL_GROUP_KEY = "group_key";
private static final String MARKERS_COL_COLOR = "marker_color";
private static final String MARKERS_COL_NEXT_KEY = "marker_next_key";
private static final String MARKERS_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " +
MARKERS_TABLE_NAME + " (" +
MARKERS_COL_ID + " TEXT PRIMARY KEY, " +
MARKERS_COL_LAT + " double, " +
MARKERS_COL_LON + " double, " +
MARKERS_COL_DESCRIPTION + " TEXT, " +
MARKERS_COL_ACTIVE + " int, " + // 1 = true, 0 = false
MARKERS_COL_ADDED + " long, " +
MARKERS_COL_VISITED + " long, " +
MARKERS_COL_GROUP_NAME + " TEXT, " +
MARKERS_COL_GROUP_KEY + " TEXT, " +
MARKERS_COL_COLOR + " int, " +
MARKERS_COL_NEXT_KEY + " TEXT);";
private static final String MARKERS_TABLE_SELECT = "SELECT " +
MARKERS_COL_ID + ", " +
MARKERS_COL_LAT + ", " +
MARKERS_COL_LON + ", " +
MARKERS_COL_DESCRIPTION + ", " +
MARKERS_COL_ACTIVE + ", " +
MARKERS_COL_ADDED + ", " +
MARKERS_COL_VISITED + ", " +
MARKERS_COL_GROUP_NAME + ", " +
MARKERS_COL_GROUP_KEY + ", " +
MARKERS_COL_COLOR + ", " +
MARKERS_COL_NEXT_KEY +
" FROM " + MARKERS_TABLE_NAME;
private static final String GROUPS_TABLE_NAME = "map_markers_groups";
private static final String GROUPS_COL_ID = "group_id";
private static final String GROUPS_COL_NAME = "group_name";
private static final String GROUPS_COL_TYPE = "group_type";
private static final String GROUPS_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " +
GROUPS_TABLE_NAME + " (" +
GROUPS_COL_ID + " TEXT PRIMARY KEY, " +
GROUPS_COL_NAME + " TEXT, " +
GROUPS_COL_TYPE + " int);";
private static final String GROUPS_TABLE_SELECT = "SELECT " +
GROUPS_COL_ID + ", " +
GROUPS_COL_NAME + ", " +
GROUPS_COL_TYPE +
" FROM " + GROUPS_TABLE_NAME;
public static final String TAIL_NEXT_VALUE = "tail_next";
public static final String HISTORY_NEXT_VALUE = "history_next";
private final OsmandApplication context;
public MapMarkersDbHelper(OsmandApplication context) {
this.context = context;
}
private SQLiteConnection openConnection(boolean readonly) {
SQLiteConnection conn = context.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly);
int version = conn.getVersion();
if (version == 0 || DB_VERSION != version) {
if (readonly) {
conn.close();
conn = context.getSQLiteAPI().getOrCreateDatabase(DB_NAME, false);
}
version = conn.getVersion();
conn.setVersion(DB_VERSION);
if (version == 0) {
onCreate(conn);
} else {
onUpgrade(conn, version, DB_VERSION);
}
}
return conn;
}
private void onCreate(SQLiteConnection db) {
db.execSQL(MARKERS_TABLE_CREATE);
db.execSQL(GROUPS_TABLE_CREATE);
saveExistingMarkersToDb();
}
private void onUpgrade(SQLiteConnection db, int oldVersion, int newVersion) {
}
private void saveExistingMarkersToDb() {
OsmandSettings settings = context.getSettings();
List<LatLon> ips = settings.getMapMarkersPoints();
List<String> desc = settings.getMapMarkersPointDescriptions(ips.size());
List<Integer> colors = settings.getMapMarkersColors(ips.size());
int colorIndex = 0;
for (int i = 0; i < ips.size(); i++) {
if (colors.size() > i) {
colorIndex = colors.get(i);
}
MapMarker marker = new MapMarker(ips.get(i), PointDescription.deserializeFromString(desc.get(i), ips.get(i)),
colorIndex, false, i);
marker.history = false;
addMarker(marker, true);
}
ips = settings.getMapMarkersHistoryPoints();
desc = settings.getMapMarkersHistoryPointDescriptions(ips.size());
colors = settings.getMapMarkersHistoryColors(ips.size());
for (int i = 0; i < ips.size(); i++) {
if (colors.size() > i) {
colorIndex = colors.get(i);
}
MapMarker marker = new MapMarker(ips.get(i), PointDescription.deserializeFromString(desc.get(i), ips.get(i)),
colorIndex, false, i);
marker.history = true;
addMarker(marker, true);
}
}
public void addGroup(String id, String name, int type) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
db.execSQL("INSERT INTO " + GROUPS_TABLE_NAME + " VALUES (?, ?, ?)", new Object[]{id, name, type});
} finally {
db.close();
}
}
}
public List<MarkersSyncGroup> getAllGroups() {
List<MarkersSyncGroup> res = new LinkedList<>();
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
SQLiteCursor query = db.rawQuery(GROUPS_TABLE_SELECT, null);
if (query.moveToFirst()) {
do {
res.add(readSyncGroup(query));
} while (query.moveToNext());
}
query.close();
} finally {
db.close();
}
}
return res;
}
@Nullable
public MarkersSyncGroup getGroup(String id) {
MarkersSyncGroup res = null;
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
SQLiteCursor query = db.rawQuery(GROUPS_TABLE_SELECT + " WHERE " + GROUPS_COL_ID + " = ?", new String[]{id});
if (query.moveToFirst()) {
res = readSyncGroup(query);
}
query.close();
} finally {
db.close();
}
}
return res;
}
private MarkersSyncGroup readSyncGroup(SQLiteCursor query) {
String id = query.getString(0);
String name = query.getString(1);
int type = query.getInt(2);
return new MarkersSyncGroup(id, name, type);
}
public void removeMarkersSyncGroup(String id) {
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
db.execSQL("DELETE FROM " + GROUPS_TABLE_NAME + " WHERE " + GROUPS_COL_ID + " = ?", new Object[]{id});
} finally {
db.close();
}
}
}
public void removeActiveMarkersFromSyncGroup(String syncGroupId) {
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME +
" WHERE " + MARKERS_COL_GROUP_KEY + " = ?" +
" AND " + MARKERS_COL_ACTIVE + " = ?",
new Object[]{syncGroupId, 1});
} finally {
db.close();
}
}
}
public void addMarker(MapMarker marker) {
addMarker(marker, false);
}
private void addMarker(MapMarker marker, boolean saveExisting) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
insertLast(db, marker, saveExisting);
} finally {
db.close();
}
}
}
private void insertLast(SQLiteConnection db, MapMarker marker, boolean saveExisting) {
long currentTime;
if (saveExisting) {
Calendar cal = Calendar.getInstance();
cal.add(Calendar.MONTH, -1);
currentTime = cal.getTimeInMillis();
} else {
currentTime = System.currentTimeMillis();
}
if (marker.id == null) {
marker.id = String.valueOf(currentTime) + String.valueOf(new Random().nextInt(900) + 100);
}
marker.creationDate = currentTime;
String descr = PointDescription.serializeToString(marker.getOriginalPointDescription());
int active = marker.history ? 0 : 1;
long visited = saveExisting ? currentTime : 0;
PointDescription pointDescription = marker.getOriginalPointDescription();
if (pointDescription != null && !pointDescription.isSearchingAddress(context)) {
SearchHistoryHelper.getInstance(context)
.addNewItemToHistory(marker.getLatitude(), marker.getLongitude(), pointDescription);
}
if (!marker.history) {
db.execSQL("UPDATE " + MARKERS_TABLE_NAME + " SET " + MARKERS_COL_NEXT_KEY + " = ? " +
"WHERE " + MARKERS_COL_NEXT_KEY + " = ?", new Object[]{marker.id, TAIL_NEXT_VALUE});
}
db.execSQL("INSERT INTO " + MARKERS_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
new Object[]{marker.id, marker.getLatitude(), marker.getLongitude(), descr, active,
currentTime, visited, marker.groupName, marker.groupKey, marker.colorIndex,
marker.history ? HISTORY_NEXT_VALUE : TAIL_NEXT_VALUE});
}
public List<MapMarker> getMarkersFromGroup(MarkersSyncGroup group) {
List<MapMarker> res = new LinkedList<>();
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_GROUP_KEY + " = ?",
new String[]{group.getId()});
if (query.moveToFirst()) {
do {
res.add(readItem(query));
} while (query.moveToNext());
}
query.close();
} finally {
db.close();
}
}
return res;
}
@Nullable
public MapMarker getMarker(String id) {
MapMarker res = null;
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ID + " = ?", new String[]{id});
if (query.moveToFirst()) {
res = readItem(query);
}
query.close();
} finally {
db.close();
}
}
return res;
}
public List<MapMarker> getActiveMarkers() {
List<MapMarker> res = new LinkedList<>();
HashMap<String, MapMarker> markers = new LinkedHashMap<>();
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
new String[]{String.valueOf(1)});
if (query.moveToFirst()) {
do {
MapMarker marker = readItem(query);
markers.put(marker.id, marker);
} while (query.moveToNext());
}
query.close();
} finally {
db.close();
}
buildLinkedList(markers, res);
}
return res;
}
private MapMarker readItem(SQLiteCursor query) {
String id = query.getString(0);
double lat = query.getDouble(1);
double lon = query.getDouble(2);
String desc = query.getString(3);
boolean active = query.getInt(4) == 1;
long added = query.getLong(5);
long visited = query.getLong(6);
String groupName = query.getString(7);
String groupKey = query.getString(8);
int colorIndex = query.getInt(9);
String nextKey = query.getString(10);
LatLon latLon = new LatLon(lat, lon);
MapMarker marker = new MapMarker(latLon, PointDescription.deserializeFromString(desc, latLon),
colorIndex, false, 0);
marker.id = id;
marker.history = !active;
marker.creationDate = added;
marker.visitedDate = visited;
marker.groupName = groupName;
marker.groupKey = groupKey;
marker.nextKey = nextKey;
return marker;
}
private void buildLinkedList(HashMap<String, MapMarker> markers, List<MapMarker> res) {
if (!markers.isEmpty()) {
int count = 1;
for (MapMarker marker : markers.values()) {
if (!markers.keySet().contains(marker.nextKey) || count == markers.size()) {
res.add(0, marker);
markers.remove(marker.id);
break;
}
count++;
}
buildLinkedList(markers, res);
}
}
public void updateMarker(MapMarker marker) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
String descr = PointDescription.serializeToString(marker.getOriginalPointDescription());
db.execSQL("UPDATE " + MARKERS_TABLE_NAME + " SET " +
MARKERS_COL_LAT + " = ?, " +
MARKERS_COL_LON + " = ?, " +
MARKERS_COL_DESCRIPTION + " = ?, " +
MARKERS_COL_COLOR + " = ? " +
"WHERE " + MARKERS_COL_ID + " = ?",
new Object[]{marker.getLatitude(), marker.getLongitude(), descr, marker.colorIndex, marker.id});
} finally {
db.close();
}
}
}
public void changeActiveMarkerPosition(MapMarker moved, @Nullable MapMarker next) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
db.execSQL("UPDATE " + MARKERS_TABLE_NAME + " SET " + MARKERS_COL_NEXT_KEY + " = ? " +
"WHERE " + MARKERS_COL_ID + " = ?", new Object[]{next == null ? TAIL_NEXT_VALUE : next.id, moved.id});
} finally {
db.close();
}
}
}
public void moveMarkerToHistory(MapMarker marker) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
marker.visitedDate = System.currentTimeMillis();
db.execSQL("UPDATE " + MARKERS_TABLE_NAME + " SET " +
MARKERS_COL_ACTIVE + " = ?, " +
MARKERS_COL_VISITED + " = ?, " +
MARKERS_COL_NEXT_KEY + " = ? " +
"WHERE " + MARKERS_COL_ID + " = ?", new Object[]{0, marker.visitedDate, HISTORY_NEXT_VALUE, marker.id});
} finally {
db.close();
}
}
}
public void moveAllActiveMarkersToHistory(long timestamp) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
db.execSQL("UPDATE " + MARKERS_TABLE_NAME + " SET " +
MARKERS_COL_ACTIVE + " = ?, " +
MARKERS_COL_VISITED + " = ?, " +
MARKERS_COL_NEXT_KEY + " = ? " +
"WHERE " + MARKERS_COL_ACTIVE + " = ?", new Object[]{0, timestamp, HISTORY_NEXT_VALUE, 1});
} finally {
db.close();
}
}
}
public void restoreMapMarkerFromHistory(MapMarker marker) {
SQLiteConnection db = openConnection(false);
if (db != null) {
try {
db.execSQL("UPDATE " + MARKERS_TABLE_NAME + " SET " +
MARKERS_COL_ACTIVE + " = ? " +
"WHERE " + MARKERS_COL_ID + " = ? " +
"AND " + MARKERS_COL_ACTIVE + " = ?",
new Object[]{1, marker.id, 0});
} finally {
db.close();
}
}
}
public List<MapMarker> getMarkersHistory() {
List<MapMarker> markers = new LinkedList<>();
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
new String[]{String.valueOf(0)});
if (query.moveToFirst()) {
do {
markers.add(readItem(query));
} while (query.moveToNext());
}
query.close();
} finally {
db.close();
}
}
return markers;
}
public void removeMarker(MapMarker marker, boolean history) {
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME +
" WHERE " + MARKERS_COL_ID + " = ?" +
" AND " + MARKERS_COL_ACTIVE + " = ?",
new Object[]{marker.id, history ? 0 : 1});
} finally {
db.close();
}
}
}
public void clearAllMarkersHistory() {
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
new Object[]{0});
} finally {
db.close();
}
}
}
}

View file

@ -4,30 +4,47 @@ import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.BottomNavigationView; import android.support.design.widget.BottomNavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.plus.LockableViewPager; import net.osmand.plus.LockableViewPager;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
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.dashboard.DashboardOnMap;
import net.osmand.plus.mapmarkers.ShowDirectionBottomSheetDialogFragment.ShowDirectionFragmentListener;
import net.osmand.plus.mapmarkers.MarkerOptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener; import net.osmand.plus.mapmarkers.MarkerOptionsBottomSheetDialogFragment.MarkerOptionsFragmentListener;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map;
public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragment { public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragment {
public static final String TAG = "MapMarkersDialogFragment"; public static final String TAG = "MapMarkersDialogFragment";
private MapMarkersActiveFragment activeFragment;
private MapMarkersGroupsFragment groupsFragment;
private MapMarkersHistoryFragment historyFragment;
private Snackbar snackbar;
private LockableViewPager viewPager;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -40,11 +57,37 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
List<Fragment> fragments = getChildFragmentManager().getFragments();
if (fragments != null) {
for (Fragment fragment : fragments) {
if (fragment instanceof MapMarkersActiveFragment) {
activeFragment = (MapMarkersActiveFragment) fragment;
} else if (fragment instanceof MapMarkersGroupsFragment) {
groupsFragment = (MapMarkersGroupsFragment) fragment;
} else if (fragment instanceof MapMarkersHistoryFragment) {
historyFragment = (MapMarkersHistoryFragment) fragment;
}
}
}
if (activeFragment == null) {
activeFragment = new MapMarkersActiveFragment();
}
if (groupsFragment == null) {
groupsFragment = new MapMarkersGroupsFragment();
}
if (historyFragment == null) {
historyFragment = new MapMarkersHistoryFragment();
}
FragmentManager fragmentManager = getChildFragmentManager(); FragmentManager fragmentManager = getChildFragmentManager();
Fragment markerOptionsFragment = fragmentManager.findFragmentByTag(MarkerOptionsBottomSheetDialogFragment.TAG); Fragment markerOptionsFragment = fragmentManager.findFragmentByTag(MarkerOptionsBottomSheetDialogFragment.TAG);
if (markerOptionsFragment != null) { if (markerOptionsFragment != null) {
((MarkerOptionsBottomSheetDialogFragment) markerOptionsFragment).setListener(createMarkerOptionsFragmentListener()); ((MarkerOptionsBottomSheetDialogFragment) markerOptionsFragment).setListener(createMarkerOptionsFragmentListener());
} }
Fragment showDirectionFragment = fragmentManager.findFragmentByTag(ShowDirectionBottomSheetDialogFragment.TAG);
if (showDirectionFragment != null) {
((ShowDirectionBottomSheetDialogFragment) showDirectionFragment).setListener(createShowDirectionFragmentListener());
}
View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container); View mainView = inflater.inflate(R.layout.fragment_map_markers_dialog, container);
@ -66,7 +109,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
} }
}); });
final LockableViewPager viewPager = mainView.findViewById(R.id.map_markers_view_pager); viewPager = mainView.findViewById(R.id.map_markers_view_pager);
viewPager.setSwipeLocked(true); viewPager.setSwipeLocked(true);
final MapMarkersViewPagerAdapter adapter = new MapMarkersViewPagerAdapter(getChildFragmentManager()); final MapMarkersViewPagerAdapter adapter = new MapMarkersViewPagerAdapter(getChildFragmentManager());
viewPager.setAdapter(adapter); viewPager.setAdapter(adapter);
@ -77,21 +120,33 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch (menuItem.getItemId()) { switch (menuItem.getItemId()) {
case R.id.action_active: case R.id.action_active:
((MapMarkersActiveFragment) adapter.getItem(0)).startLocationUpdate(); activeFragment.startLocationUpdate();
if (viewPager.getCurrentItem() != 0) { if (viewPager.getCurrentItem() != 0) {
((MapMarkersActiveFragment) adapter.getItem(0)).updateAdapter(); activeFragment.updateAdapter();
historyFragment.hideSnackbar();
} }
viewPager.setCurrentItem(0); viewPager.setCurrentItem(0);
optionsButton.setVisibility(View.VISIBLE); optionsButton.setVisibility(View.VISIBLE);
return true; return true;
case R.id.action_history: case R.id.action_groups:
((MapMarkersActiveFragment) adapter.getItem(0)).stopLocationUpdate(); activeFragment.stopLocationUpdate();
if (viewPager.getCurrentItem() != 1) { if (viewPager.getCurrentItem() != 1) {
((MapMarkersHistoryFragment) adapter.getItem(1)).updateAdapter(); groupsFragment.updateAdapter();
activeFragment.hideSnackbar();
historyFragment.hideSnackbar();
} }
viewPager.setCurrentItem(1); viewPager.setCurrentItem(1);
optionsButton.setVisibility(View.GONE); optionsButton.setVisibility(View.GONE);
return true; return true;
case R.id.action_history:
activeFragment.stopLocationUpdate();
if (viewPager.getCurrentItem() != 2) {
historyFragment.updateAdapter();
activeFragment.hideSnackbar();
}
viewPager.setCurrentItem(2);
optionsButton.setVisibility(View.GONE);
return true;
} }
return false; return false;
} }
@ -106,6 +161,9 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
private MarkerOptionsFragmentListener createMarkerOptionsFragmentListener() { private MarkerOptionsFragmentListener createMarkerOptionsFragmentListener() {
return new MarkerOptionsFragmentListener() { return new MarkerOptionsFragmentListener() {
final MapActivity mapActivity = getMapActivity();
@Override @Override
public void sortByOnClick() { public void sortByOnClick() {
Toast.makeText(getContext(), "Sort by", Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "Sort by", Toast.LENGTH_SHORT).show();
@ -113,26 +171,61 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
@Override @Override
public void showDirectionOnClick() { public void showDirectionOnClick() {
Toast.makeText(getContext(), "Show direction", Toast.LENGTH_SHORT).show(); ShowDirectionBottomSheetDialogFragment fragment = new ShowDirectionBottomSheetDialogFragment();
fragment.setListener(createShowDirectionFragmentListener());
fragment.show(mapActivity.getSupportFragmentManager(), ShowDirectionBottomSheetDialogFragment.TAG);
} }
@Override @Override
public void buildRouteOnClick() { public void buildRouteOnClick() {
Toast.makeText(getContext(), "Build route", Toast.LENGTH_SHORT).show(); mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.MAP_MARKERS_SELECTION);
dismiss();
} }
@Override @Override
public void saveAsNewTrackOnClick() { public void saveAsNewTrackOnClick() {
Toast.makeText(getContext(), "Save as new track", Toast.LENGTH_SHORT).show(); mapActivity.getMyApplication().getMapMarkersHelper().generateGpx();
} }
@Override @Override
public void moveAllToHistoryOnClick() { public void moveAllToHistoryOnClick() {
Toast.makeText(getContext(), "Move all to history", Toast.LENGTH_SHORT).show(); final MapMarkersHelper helper = mapActivity.getMyApplication().getMapMarkersHelper();
final List<MapMarkersHelper.MapMarker> markers = new ArrayList<>(helper.getMapMarkers());
helper.moveAllActiveMarkersToHistory();
activeFragment.updateAdapter();
snackbar = Snackbar.make(viewPager, R.string.all_markers_moved_to_history, Snackbar.LENGTH_LONG)
.setAction(R.string.shared_string_undo, new View.OnClickListener() {
@Override
public void onClick(View view) {
helper.restoreMarkersFromHistory(markers);
activeFragment.updateAdapter();
}
});
View snackBarView = snackbar.getView();
TextView tv = (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_action);
tv.setTextColor(ContextCompat.getColor(mapActivity, R.color.color_dialog_buttons_dark));
snackbar.show();
} }
}; };
} }
private ShowDirectionFragmentListener createShowDirectionFragmentListener() {
return new ShowDirectionFragmentListener() {
final MapActivity mapActivity = getMapActivity();
@Override
public void onMapMarkersModeChanged(boolean showDirectionEnabled) {
mapActivity.getMapLayers().getMapWidgetRegistry().updateMapMarkersMode(mapActivity);
activeFragment.setShowDirectionEnabled(showDirectionEnabled);
activeFragment.updateAdapter();
}
};
}
private MapActivity getMapActivity() {
return (MapActivity) getActivity();
}
public static boolean showInstance(@NonNull MapActivity mapActivity) { public static boolean showInstance(@NonNull MapActivity mapActivity) {
try { try {
@ -153,7 +246,7 @@ public class MapMarkersDialogFragment extends android.support.v4.app.DialogFragm
MapMarkersViewPagerAdapter(FragmentManager fm) { MapMarkersViewPagerAdapter(FragmentManager fm) {
super(fm); super(fm);
fragments = Arrays.asList(new MapMarkersActiveFragment(), new MapMarkersHistoryFragment()); fragments = Arrays.asList(activeFragment, groupsFragment, historyFragment);
} }
@Override @Override

View file

@ -0,0 +1,37 @@
package net.osmand.plus.mapmarkers;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapmarkers.adapters.MapMarkersGroupsAdapter;
public class MapMarkersGroupsFragment extends Fragment {
public static final String TAG = "MapMarkersGroupsFragment";
private MapMarkersGroupsAdapter adapter;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final RecyclerView recyclerView = new RecyclerView(getContext());
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
final MapActivity mapActivity = (MapActivity) getActivity();
adapter = new MapMarkersGroupsAdapter(mapActivity);
return recyclerView;
}
void updateAdapter() {
if (adapter != null) {
adapter.notifyDataSetChanged();
}
}
}

View file

@ -1,52 +1,261 @@
package net.osmand.plus.mapmarkers; package net.osmand.plus.mapmarkers;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment; import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
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.helper.ItemTouchHelper;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView;
import net.osmand.data.PointDescription; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapmarkers.adapters.MapMarkerDateViewHolder;
import net.osmand.plus.mapmarkers.adapters.MapMarkerItemViewHolder;
import net.osmand.plus.mapmarkers.adapters.MapMarkersHistoryAdapter; import net.osmand.plus.mapmarkers.adapters.MapMarkersHistoryAdapter;
public class MapMarkersHistoryFragment extends Fragment { public class MapMarkersHistoryFragment extends Fragment implements MapMarkersHelper.MapMarkerChangedListener {
MapMarkersHistoryAdapter adapter; private MapMarkersHistoryAdapter adapter;
private OsmandApplication app;
private Paint backgroundPaint = new Paint();
private Paint iconPaint = new Paint();
private Paint textPaint = new Paint();
private Snackbar snackbar;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = getMyApplication();
}
@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 boolean night = !app.getSettings().isLightContent();
final MapActivity mapActivity = (MapActivity) getActivity();
backgroundPaint.setColor(ContextCompat.getColor(getActivity(), night ? R.color.dashboard_divider_dark : R.color.dashboard_divider_light));
backgroundPaint.setStyle(Paint.Style.FILL_AND_STROKE);
backgroundPaint.setAntiAlias(true);
iconPaint.setAntiAlias(true);
iconPaint.setFilterBitmap(true);
iconPaint.setDither(true);
textPaint.setTextSize(getResources().getDimension(R.dimen.default_desc_text_size));
textPaint.setFakeBoldText(true);
textPaint.setAntiAlias(true);
final String delStr = getString(R.string.shared_string_delete).toUpperCase();
final String activateStr = getString(R.string.local_index_mi_restore).toUpperCase();
Rect bounds = new Rect();
textPaint.getTextBounds(activateStr, 0, activateStr.length(), bounds);
final int activateStrWidth = bounds.width();
final int textHeight = bounds.height();
Fragment historyMarkerMenuFragment = mapActivity.getSupportFragmentManager().findFragmentByTag(HistoryMarkerMenuBottomSheetDialogFragment.TAG);
if (historyMarkerMenuFragment != null) {
((HistoryMarkerMenuBottomSheetDialogFragment) historyMarkerMenuFragment).setListener(createHistoryMarkerMenuListener());
}
final RecyclerView recyclerView = new RecyclerView(getContext()); final RecyclerView recyclerView = new RecyclerView(getContext());
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
final MapActivity mapActivity = (MapActivity) getActivity();
ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) {
private float marginSides = getResources().getDimension(R.dimen.list_content_padding);
private Bitmap deleteBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_delete_dark);
private Bitmap resetBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_reset_to_default_dark);
private boolean iconHidden;
@Override
public int getSwipeDirs(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
if (viewHolder instanceof MapMarkerDateViewHolder) {
return 0;
}
return super.getSwipeDirs(recyclerView, viewHolder);
}
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE && viewHolder instanceof MapMarkerItemViewHolder) {
if (!iconHidden && isCurrentlyActive) {
((MapMarkerItemViewHolder) viewHolder).optionsBtn.setVisibility(View.GONE);
iconHidden = true;
}
View itemView = viewHolder.itemView;
int colorIcon;
int colorText;
if (Math.abs(dX) > itemView.getWidth() / 2) {
colorIcon = R.color.map_widget_blue;
colorText = R.color.map_widget_blue;
} else {
colorIcon = night ? 0 : R.color.icon_color;
colorText = R.color.dashboard_subheader_text_light;
}
if (colorIcon != 0) {
iconPaint.setColorFilter(new PorterDuffColorFilter(ContextCompat.getColor(getActivity(), colorIcon), PorterDuff.Mode.SRC_IN));
}
textPaint.setColor(ContextCompat.getColor(getActivity(), colorText));
float textMarginTop = ((float) itemView.getHeight() - (float) textHeight) / 2;
if (dX > 0) {
c.drawRect(itemView.getLeft(), itemView.getTop(), dX, itemView.getBottom(), backgroundPaint);
float iconMarginTop = ((float) itemView.getHeight() - (float) deleteBitmap.getHeight()) / 2;
c.drawBitmap(deleteBitmap, itemView.getLeft() + marginSides, itemView.getTop() + iconMarginTop, iconPaint);
c.drawText(delStr, itemView.getLeft() + 2 * marginSides + deleteBitmap.getWidth(), itemView.getTop() + textMarginTop + textHeight, textPaint);
} else {
c.drawRect(itemView.getRight() + dX, itemView.getTop(), itemView.getRight(), itemView.getBottom(), backgroundPaint);
float iconMarginTop = ((float) itemView.getHeight() - (float) resetBitmap.getHeight()) / 2;
c.drawBitmap(resetBitmap, itemView.getRight() - resetBitmap.getWidth() - marginSides, itemView.getTop() + iconMarginTop, iconPaint);
c.drawText(activateStr, itemView.getRight() - resetBitmap.getWidth() - 2 * marginSides - activateStrWidth, itemView.getTop() + textMarginTop + textHeight, textPaint);
}
}
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
@Override
public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
if (viewHolder instanceof MapMarkerItemViewHolder) {
((MapMarkerItemViewHolder) viewHolder).optionsBtn.setVisibility(View.VISIBLE);
iconHidden = false;
}
super.clearView(recyclerView, viewHolder);
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, final int direction) {
final int pos = viewHolder.getAdapterPosition();
Object item = adapter.getItem(pos);
if (item instanceof MapMarker) {
final MapMarker marker = (MapMarker) item;
int snackbarStringRes;
if (direction == ItemTouchHelper.LEFT) {
app.getMapMarkersHelper().restoreMarkerFromHistory((MapMarker) item, 0);
snackbarStringRes = R.string.marker_moved_to_active;
} else {
app.getMapMarkersHelper().removeMarkerFromHistory((MapMarker) item);
snackbarStringRes = R.string.item_removed;
}
adapter.notifyItemRemoved(pos);
snackbar = Snackbar.make(viewHolder.itemView, snackbarStringRes, Snackbar.LENGTH_LONG)
.setAction(R.string.shared_string_undo, new View.OnClickListener() {
@Override
public void onClick(View view) {
if (direction == ItemTouchHelper.LEFT) {
app.getMapMarkersHelper().moveMapMarkerToHistory(marker);
} else {
app.getMapMarkersHelper().addMarker(marker);
}
}
});
View snackBarView = snackbar.getView();
TextView tv = (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_action);
tv.setTextColor(ContextCompat.getColor(mapActivity, R.color.color_dialog_buttons_dark));
snackbar.show();
}
}
};
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(simpleItemTouchCallback);
itemTouchHelper.attachToRecyclerView(recyclerView);
adapter = new MapMarkersHistoryAdapter(mapActivity.getMyApplication()); adapter = new MapMarkersHistoryAdapter(mapActivity.getMyApplication());
adapter.setAdapterListener(new MapMarkersHistoryAdapter.MapMarkersHistoryAdapterListener() { adapter.setAdapterListener(new MapMarkersHistoryAdapter.MapMarkersHistoryAdapterListener() {
@Override @Override
public void onItemClick(View view) { public void onItemClick(View view) {
int pos = recyclerView.indexOfChild(view); int pos = recyclerView.getChildAdapterPosition(view);
MapMarker marker = adapter.getItem(pos); Object item = adapter.getItem(pos);
mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(), if (item instanceof MapMarker) {
15, new PointDescription(PointDescription.POINT_TYPE_LOCATION, marker.getPointDescription(mapActivity).getName()), MapMarker marker = (MapMarker) item;
false, null); HistoryMarkerMenuBottomSheetDialogFragment fragment = new HistoryMarkerMenuBottomSheetDialogFragment();
MapActivity.launchMapActivityMoveToTop(mapActivity); Bundle arguments = new Bundle();
((DialogFragment) getParentFragment()).dismiss(); arguments.putInt(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_POSITION, pos);
arguments.putString(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_NAME, marker.getName(mapActivity));
arguments.putInt(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_COLOR_INDEX, marker.colorIndex);
arguments.putLong(HistoryMarkerMenuBottomSheetDialogFragment.MARKER_VISITED_DATE, marker.visitedDate);
fragment.setArguments(arguments);
fragment.setListener(createHistoryMarkerMenuListener());
fragment.show(mapActivity.getSupportFragmentManager(), HistoryMarkerMenuBottomSheetDialogFragment.TAG);
}
} }
}); });
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
app.getMapMarkersHelper().addListener(this);
return recyclerView; return recyclerView;
} }
void hideSnackbar() {
if (snackbar != null && snackbar.isShown()) {
snackbar.dismiss();
}
}
private HistoryMarkerMenuBottomSheetDialogFragment.HistoryMarkerMenuFragmentListener createHistoryMarkerMenuListener() {
return new HistoryMarkerMenuBottomSheetDialogFragment.HistoryMarkerMenuFragmentListener() {
@Override
public void onMakeMarkerActive(int pos) {
Object item = adapter.getItem(pos);
if (item instanceof MapMarker) {
app.getMapMarkersHelper().restoreMarkerFromHistory((MapMarker) item, 0);
adapter.notifyItemRemoved(pos);
}
}
@Override
public void onDeleteMarker(int pos) {
Object item = adapter.getItem(pos);
if (item instanceof MapMarker) {
app.getMapMarkersHelper().removeMarkerFromHistory((MapMarker) item);
adapter.notifyItemRemoved(pos);
}
}
};
}
@Override
public void onDestroy() {
app.getMapMarkersHelper().removeListener(this);
super.onDestroy();
}
void updateAdapter() { void updateAdapter() {
if (adapter != null) { if (adapter != null) {
adapter.createHeaders();
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
} }
public OsmandApplication getMyApplication() {
return (OsmandApplication) getActivity().getApplication();
}
@Override
public void onMapMarkerChanged(MapMarker mapMarker) {
updateAdapter();
}
@Override
public void onMapMarkersChanged() {
updateAdapter();
}
} }

View file

@ -3,6 +3,7 @@ package net.osmand.plus.mapmarkers;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -13,6 +14,7 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.base.BottomSheetDialogFragment; import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
@ -32,16 +34,31 @@ public class MarkerOptionsBottomSheetDialogFragment extends BottomSheetDialogFra
@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 int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View mainView = inflater.inflate(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);
if (portrait) { if (portrait) {
AndroidUtils.setBackground(getActivity(), mainView, false, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark); AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
} }
((ImageView) mainView.findViewById(R.id.sort_by_icon)) ((ImageView) mainView.findViewById(R.id.sort_by_icon))
.setImageDrawable(getIcon(R.drawable.ic_sort_waypoint_dark, R.color.on_map_icon_color)); .setImageDrawable(getIcon(R.drawable.ic_sort_waypoint_dark, R.color.on_map_icon_color));
((ImageView) mainView.findViewById(R.id.show_direction_icon)) OsmandSettings.MapMarkersMode mode = getMyApplication().getSettings().MAP_MARKERS_MODE.get();
.setImageDrawable(getIcon(R.drawable.ic_sort_waypoint_dark, R.color.on_map_icon_color)); ImageView showDirectionIcon = (ImageView) mainView.findViewById(R.id.show_direction_icon);
int imageResId = 0;
switch (mode) {
case TOOLBAR:
imageResId = R.drawable.ic_action_device_topbar;
break;
case WIDGETS:
imageResId = R.drawable.ic_action_device_widget;
break;
}
showDirectionIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, R.color.on_map_icon_color));
if (imageResId != 0) {
showDirectionIcon.setImageDrawable(getIcon(imageResId, R.color.dashboard_blue));
}
((ImageView) mainView.findViewById(R.id.build_route_icon)) ((ImageView) mainView.findViewById(R.id.build_route_icon))
.setImageDrawable(getIcon(R.drawable.map_directions, R.color.on_map_icon_color)); .setImageDrawable(getIcon(R.drawable.map_directions, R.color.on_map_icon_color));
((ImageView) mainView.findViewById(R.id.save_as_new_track_icon)) ((ImageView) mainView.findViewById(R.id.save_as_new_track_icon))
@ -49,7 +66,7 @@ public class MarkerOptionsBottomSheetDialogFragment extends BottomSheetDialogFra
((ImageView) mainView.findViewById(R.id.move_all_to_history_icon)) ((ImageView) mainView.findViewById(R.id.move_all_to_history_icon))
.setImageDrawable(getIcon(R.drawable.ic_action_history2, R.color.on_map_icon_color)); .setImageDrawable(getIcon(R.drawable.ic_action_history2, R.color.on_map_icon_color));
((TextView) mainView.findViewById(R.id.show_direction_text_view)).setText("Top bar"); ((TextView) mainView.findViewById(R.id.show_direction_text_view)).setText(getMyApplication().getSettings().MAP_MARKERS_MODE.get().toHumanString(getActivity()));
mainView.findViewById(R.id.sort_by_row).setOnClickListener(new View.OnClickListener() { mainView.findViewById(R.id.sort_by_row).setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -113,7 +130,7 @@ public class MarkerOptionsBottomSheetDialogFragment extends BottomSheetDialogFra
final View scrollView = mainView.findViewById(R.id.marker_options_scroll_view); final View scrollView = mainView.findViewById(R.id.marker_options_scroll_view);
int scrollViewHeight = scrollView.getHeight(); int scrollViewHeight = scrollView.getHeight();
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1); int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.measure_distance_bottom_sheet_cancel_button_height); int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight; int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
if (scrollViewHeight > spaceForScrollView) { if (scrollViewHeight > spaceForScrollView) {
scrollView.getLayoutParams().height = spaceForScrollView; scrollView.getLayoutParams().height = spaceForScrollView;

View file

@ -0,0 +1,239 @@
package net.osmand.plus.mapmarkers;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.helpers.AndroidUiHelper;
public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFragment {
public final static String TAG = "ShowDirectionBottomSheetDialogFragment";
private ShowDirectionFragmentListener listener;
private boolean portrait;
private View mainView;
private boolean night;
public void setListener(ShowDirectionFragmentListener listener) {
this.listener = listener;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
night = !getMyApplication().getSettings().isLightContent();
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_show_direction_bottom_sheet_dialog, container);
if (portrait) {
AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
}
OsmandSettings.MapMarkersMode mode = getMyApplication().getSettings().MAP_MARKERS_MODE.get();
highlightSelectedItem(mode, true);
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
mainView.findViewById(R.id.images_row).setVisibility(View.GONE);
} else {
ImageView topBarImage = (ImageView) mainView.findViewById(R.id.top_bar_image);
ImageView widgetImage = (ImageView) mainView.findViewById(R.id.widget_image);
if (night) {
topBarImage.setImageResource(R.drawable.img_help_markers_topbar_night);
widgetImage.setImageResource(R.drawable.img_help_markers_widgets_night);
} else {
topBarImage.setImageResource(R.drawable.img_help_markers_topbar_day);
widgetImage.setImageResource(R.drawable.img_help_markers_widgets_day);
}
mainView.findViewById(R.id.top_bar_image_text).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return false;
}
});
topBarImage.setOnClickListener(showDirectionOnClickListener);
mainView.findViewById(R.id.widget_image_text).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return false;
}
});
widgetImage.setOnClickListener(showDirectionOnClickListener);
}
if (night) {
((TextView) mainView.findViewById(R.id.show_direction_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
}
ImageView topBarIcon = (ImageView) mainView.findViewById(R.id.top_bar_icon);
topBarIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, R.color.on_map_icon_color));
topBarIcon.setImageDrawable(getIcon(R.drawable.ic_action_device_topbar, R.color.dashboard_blue));
ImageView widgetIcon = (ImageView) mainView.findViewById(R.id.widget_icon);
widgetIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, R.color.on_map_icon_color));
widgetIcon.setImageDrawable(getIcon(R.drawable.ic_action_device_widget, R.color.dashboard_blue));
ImageView noneIcon = (ImageView) mainView.findViewById(R.id.none_icon);
noneIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, R.color.on_map_icon_color));
mainView.findViewById(R.id.top_bar_row).setOnClickListener(showDirectionOnClickListener);
mainView.findViewById(R.id.widget_row).setOnClickListener(showDirectionOnClickListener);
mainView.findViewById(R.id.none_row).setOnClickListener(showDirectionOnClickListener);
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
final int screenHeight = AndroidUtils.getScreenHeight(getActivity());
final int statusBarHeight = AndroidUtils.getStatusBarHeight(getActivity());
final int navBarHeight = AndroidUtils.getNavBarHeight(getActivity());
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
final View scrollView = mainView.findViewById(R.id.marker_show_direction_scroll_view);
int scrollViewHeight = scrollView.getHeight();
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
if (scrollViewHeight > spaceForScrollView) {
scrollView.getLayoutParams().height = spaceForScrollView;
scrollView.requestLayout();
}
if (!portrait) {
if (screenHeight - statusBarHeight - mainView.getHeight()
>= AndroidUtils.dpToPx(getActivity(), 8)) {
AndroidUtils.setBackground(getActivity(), mainView, false,
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
} else {
AndroidUtils.setBackground(getActivity(), mainView, false,
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
}
}
ViewTreeObserver obs = mainView.getViewTreeObserver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
obs.removeOnGlobalLayoutListener(this);
} else {
obs.removeGlobalOnLayoutListener(this);
}
}
});
return mainView;
}
@Override
public void onStart() {
super.onStart();
if (!portrait) {
final Window window = getDialog().getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.width = getActivity().getResources().getDimensionPixelSize(R.dimen.landscape_bottom_sheet_dialog_fragment_width);
window.setAttributes(params);
}
}
private void highlightSelectedItem(OsmandSettings.MapMarkersMode mode, boolean check) {
int iconBgColor = check ? R.color.dashboard_blue : R.color.on_map_icon_color;
int iconColor = check ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue;
int textColor = ContextCompat.getColor(getContext(), check ? R.color.dashboard_blue : night ? R.color.color_white : R.color.color_black);
switch (mode) {
case TOOLBAR:
((RadioButton) mainView.findViewById(R.id.top_bar_radio_button)).setChecked(check);
ImageView topBarIcon = (ImageView) mainView.findViewById(R.id.top_bar_icon);
if (check) {
mainView.findViewById(R.id.top_bar_row).setBackgroundColor(ContextCompat.getColor(getContext(), R.color.show_direction_menu_selected_item_bg));
} else {
mainView.findViewById(R.id.top_bar_row).setBackgroundResource(0);
}
((TextView) mainView.findViewById(R.id.top_bar_text)).setTextColor(textColor);
topBarIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, iconBgColor));
topBarIcon.setImageDrawable(getIcon(R.drawable.ic_action_device_topbar, iconColor));
break;
case WIDGETS:
((RadioButton) mainView.findViewById(R.id.widget_radio_button)).setChecked(check);
ImageView widgetIcon = (ImageView) mainView.findViewById(R.id.widget_icon);
if (check) {
mainView.findViewById(R.id.widget_row).setBackgroundColor(ContextCompat.getColor(getContext(), R.color.show_direction_menu_selected_item_bg));
} else {
mainView.findViewById(R.id.widget_row).setBackgroundResource(0);
}
((TextView) mainView.findViewById(R.id.widget_text)).setTextColor(textColor);
widgetIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, iconBgColor));
widgetIcon.setImageDrawable(getIcon(R.drawable.ic_action_device_widget, iconColor));
break;
case NONE:
((RadioButton) mainView.findViewById(R.id.none_radio_button)).setChecked(check);
ImageView noneIcon = (ImageView) mainView.findViewById(R.id.none_icon);
if (check) {
mainView.findViewById(R.id.none_row).setBackgroundColor(ContextCompat.getColor(getContext(), R.color.show_direction_menu_selected_item_bg));
} else {
mainView.findViewById(R.id.none_row).setBackgroundResource(0);
}
((TextView) mainView.findViewById(R.id.none_text)).setTextColor(textColor);
noneIcon.setBackgroundDrawable(getIcon(R.drawable.ic_action_device_top, iconBgColor));
break;
}
}
private View.OnClickListener showDirectionOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
OsmandSettings.MapMarkersMode previousMode = getMyApplication().getSettings().MAP_MARKERS_MODE.get();
highlightSelectedItem(previousMode, false);
boolean showDirectionEnabled = false;
switch (view.getId()) {
case R.id.top_bar_image:
case R.id.top_bar_row:
getMyApplication().getSettings().MAP_MARKERS_MODE.set(OsmandSettings.MapMarkersMode.TOOLBAR);
highlightSelectedItem(OsmandSettings.MapMarkersMode.TOOLBAR, true);
showDirectionEnabled = true;
break;
case R.id.widget_image:
case R.id.widget_row:
getMyApplication().getSettings().MAP_MARKERS_MODE.set(OsmandSettings.MapMarkersMode.WIDGETS);
highlightSelectedItem(OsmandSettings.MapMarkersMode.WIDGETS, true);
showDirectionEnabled = true;
break;
case R.id.none_row:
getMyApplication().getSettings().MAP_MARKERS_MODE.set(OsmandSettings.MapMarkersMode.NONE);
highlightSelectedItem(OsmandSettings.MapMarkersMode.NONE, true);
showDirectionEnabled = false;
break;
}
if (listener != null) {
listener.onMapMarkersModeChanged(showDirectionEnabled);
}
dismiss();
}
};
interface ShowDirectionFragmentListener {
void onMapMarkersModeChanged(boolean showDirectionEnabled);
}
}

View file

@ -0,0 +1,20 @@
package net.osmand.plus.mapmarkers.adapters;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import net.osmand.plus.R;
public class MapMarkerDateViewHolder extends RecyclerView.ViewHolder {
final TextView date;
final ImageButton optionsBtn;
public MapMarkerDateViewHolder(View itemView) {
super(itemView);
date = itemView.findViewById(R.id.date_title);
optionsBtn = itemView.findViewById(R.id.date_options_button);
}
}

View file

@ -10,24 +10,36 @@ import net.osmand.plus.R;
public class MapMarkerItemViewHolder extends RecyclerView.ViewHolder { public class MapMarkerItemViewHolder extends RecyclerView.ViewHolder {
final View mainLayout;
final ImageView iconDirection; final ImageView iconDirection;
final ImageView iconReorder; final ImageView iconReorder;
final ImageView icon; final ImageView icon;
final TextView title; final TextView title;
final TextView distance; final TextView distance;
final View flagIconLeftSpace;
final View leftPointSpace;
final TextView point; final TextView point;
final View rightPointSpace;
final TextView description; final TextView description;
final ImageButton optionsBtn; public final ImageButton optionsBtn;
final View divider;
final View bottomShadow;
public MapMarkerItemViewHolder(View view) { public MapMarkerItemViewHolder(View view) {
super(view); super(view);
mainLayout = view.findViewById(R.id.main_layout);
iconDirection = (ImageView) view.findViewById(R.id.map_marker_direction_icon); iconDirection = (ImageView) view.findViewById(R.id.map_marker_direction_icon);
iconReorder = (ImageView) view.findViewById(R.id.map_marker_reorder_icon); iconReorder = (ImageView) view.findViewById(R.id.map_marker_reorder_icon);
icon = (ImageView) view.findViewById(R.id.map_marker_icon); icon = (ImageView) view.findViewById(R.id.map_marker_icon);
title = (TextView) view.findViewById(R.id.map_marker_title); title = (TextView) view.findViewById(R.id.map_marker_title);
distance = (TextView) view.findViewById(R.id.map_marker_distance); distance = (TextView) view.findViewById(R.id.map_marker_distance);
flagIconLeftSpace = view.findViewById(R.id.flag_icon_left_space);
leftPointSpace = view.findViewById(R.id.map_marker_left_point_space);
point = (TextView) view.findViewById(R.id.map_marker_point_text_view); point = (TextView) view.findViewById(R.id.map_marker_point_text_view);
rightPointSpace = view.findViewById(R.id.map_marker_right_point_space);
description = (TextView) view.findViewById(R.id.map_marker_description); description = (TextView) view.findViewById(R.id.map_marker_description);
optionsBtn = (ImageButton) view.findViewById(R.id.map_marker_options_button); optionsBtn = (ImageButton) view.findViewById(R.id.map_marker_options_button);
divider = view.findViewById(R.id.divider);
bottomShadow = view.findViewById(R.id.bottom_shadow);
} }
} }

View file

@ -1,22 +1,29 @@
package net.osmand.plus.mapmarkers.adapters; package net.osmand.plus.mapmarkers.adapters;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MotionEventCompat; import android.support.v4.view.MotionEventCompat;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.IconsCache; import net.osmand.plus.IconsCache;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandSettings;
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.dashboard.DashLocationFragment; import net.osmand.plus.dashboard.DashLocationFragment;
import java.text.SimpleDateFormat;
import java.util.Collections; import java.util.Collections;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale;
public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder>
implements MapMarkersItemTouchHelperCallback.ItemTouchHelperAdapter { implements MapMarkersItemTouchHelperCallback.ItemTouchHelperAdapter {
@ -24,15 +31,24 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
private MapActivity mapActivity; private MapActivity mapActivity;
private List<MapMarker> markers; private List<MapMarker> markers;
private MapMarkersActiveAdapterListener listener; private MapMarkersActiveAdapterListener listener;
private Snackbar snackbar;
private boolean showDirectionEnabled;
private LatLon location; private LatLon location;
private Float heading; private Float heading;
private boolean useCenter; private boolean useCenter;
private int screenOrientation; private int screenOrientation;
private boolean night;
public MapMarkersActiveAdapter(MapActivity mapActivity) { public MapMarkersActiveAdapter(MapActivity mapActivity) {
this.mapActivity = mapActivity; this.mapActivity = mapActivity;
markers = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers(); markers = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers();
night = !mapActivity.getMyApplication().getSettings().isLightContent();
showDirectionEnabled = mapActivity.getMyApplication().getSettings().MAP_MARKERS_MODE.get() != OsmandSettings.MapMarkersMode.NONE;
}
public void setShowDirectionEnabled(boolean showDirectionEnabled) {
this.showDirectionEnabled = showDirectionEnabled;
} }
public void setAdapterListener(MapMarkersActiveAdapterListener listener) { public void setAdapterListener(MapMarkersActiveAdapterListener listener) {
@ -56,7 +72,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
} }
@Override @Override
public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false); View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
view.setOnClickListener(new View.OnClickListener() { view.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -68,11 +84,51 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
} }
@Override @Override
public void onBindViewHolder(final MapMarkerItemViewHolder holder, int pos) { public void onBindViewHolder(final MapMarkerItemViewHolder holder, final int pos) {
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache(); IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
MapMarker marker = markers.get(pos); MapMarker marker = markers.get(pos);
holder.iconReorder.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reorder)); ImageView markerImageViewToUpdate;
int drawableResToUpdate;
int markerColor = MapMarker.getColorId(marker.colorIndex);
LatLon markerLatLon = new LatLon(marker.getLatitude(), marker.getLongitude());
if (showDirectionEnabled && pos < 2) {
holder.iconDirection.setVisibility(View.GONE);
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_arrow_marker_diretion, markerColor));
holder.mainLayout.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.markers_top_bar_background));
holder.title.setTextColor(ContextCompat.getColor(mapActivity, R.color.color_white));
holder.divider.setBackgroundColor(ContextCompat.getColor(mapActivity, R.color.map_markers_on_map_divider_color));
holder.optionsBtn.setBackgroundDrawable(mapActivity.getResources().getDrawable(R.drawable.marker_circle_background_on_map_with_inset));
holder.optionsBtn.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_marker_passed, R.color.color_white));
holder.iconReorder.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_reorder, R.color.dashboard_subheader_text_dark));
holder.description.setTextColor(ContextCompat.getColor(mapActivity, R.color.map_markers_on_map_color));
drawableResToUpdate = R.drawable.ic_arrow_marker_diretion;
markerImageViewToUpdate = holder.icon;
} else {
holder.iconDirection.setVisibility(View.VISIBLE);
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, markerColor));
holder.mainLayout.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.bg_color_dark : R.color.bg_color_light));
holder.title.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.color_white : R.color.color_black));
holder.divider.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.dashboard_divider_dark : R.color.dashboard_divider_light));
holder.optionsBtn.setBackgroundDrawable(mapActivity.getResources().getDrawable(R.drawable.marker_circle_background_light_with_inset));
holder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_marker_passed));
holder.iconReorder.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reorder));
holder.description.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.dash_search_icon_dark : R.color.icon_color));
drawableResToUpdate = R.drawable.ic_direction_arrow;
markerImageViewToUpdate = holder.iconDirection;
}
if (pos == getItemCount() - 1) {
holder.bottomShadow.setVisibility(View.VISIBLE);
holder.divider.setVisibility(View.GONE);
} else {
holder.bottomShadow.setVisibility(View.GONE);
holder.divider.setVisibility(View.VISIBLE);
}
holder.iconReorder.setOnTouchListener(new View.OnTouchListener() { holder.iconReorder.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View view, MotionEvent event) { public boolean onTouch(View view, MotionEvent event) {
@ -83,14 +139,18 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
} }
}); });
int color = MapMarker.getColorId(marker.colorIndex);
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
holder.title.setText(marker.getName(mapActivity)); holder.title.setText(marker.getName(mapActivity));
holder.description.setText(marker.creationDate + ""); String descr;
if ((descr = marker.groupName) != null) {
if (descr.equals("")) {
descr = mapActivity.getString(R.string.shared_string_favorites);
}
} else {
descr = new SimpleDateFormat("MMM dd", Locale.getDefault()).format(new Date(marker.creationDate));
}
holder.description.setText(descr);
holder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_remove_dark));
holder.optionsBtn.setOnClickListener(new View.OnClickListener() { holder.optionsBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -99,35 +159,39 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
return; return;
} }
final MapMarker marker = markers.get(position); final MapMarker marker = markers.get(position);
final boolean[] undone = new boolean[1];
mapActivity.getMyApplication().getMapMarkersHelper().removeMapMarker(marker.index); mapActivity.getMyApplication().getMapMarkersHelper().moveMapMarkerToHistory(marker);
notifyItemRemoved(position); notifyItemRemoved(position);
if (showDirectionEnabled && position < 2 && getItemCount() > 1) {
notifyItemChanged(1);
} else if (position == getItemCount()) {
notifyItemChanged(position - 1);
}
Snackbar.make(holder.itemView, R.string.item_removed, Snackbar.LENGTH_LONG) snackbar = Snackbar.make(holder.itemView, mapActivity.getString(R.string.marker_moved_to_history), Snackbar.LENGTH_LONG)
.setAction(R.string.shared_string_undo, new View.OnClickListener() { .setAction(R.string.shared_string_undo, new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
undone[0] = true; mapActivity.getMyApplication().getMapMarkersHelper().restoreMarkerFromHistory(marker, position);
mapActivity.getMyApplication().getMapMarkersHelper().addMapMarker(marker, position);
notifyItemInserted(position); notifyItemInserted(position);
} if (showDirectionEnabled && position < 2 && getItemCount() > 2) {
}) notifyItemChanged(2);
.addCallback(new Snackbar.Callback() { } else if (position == getItemCount() - 1) {
@Override notifyItemChanged(position - 1);
public void onDismissed(Snackbar transientBottomBar, int event) {
if (!undone[0]) {
mapActivity.getMyApplication().getMapMarkersHelper().addMapMarkerHistory(marker);
} }
} }
}).show(); });
View snackBarView = snackbar.getView();
TextView tv = (TextView) snackBarView.findViewById(android.support.design.R.id.snackbar_action);
tv.setTextColor(ContextCompat.getColor(mapActivity, R.color.color_dialog_buttons_dark));
snackbar.show();
} }
}); });
DashLocationFragment.updateLocationView(useCenter, location, DashLocationFragment.updateLocationView(useCenter, location,
heading, holder.iconDirection, holder.distance, heading, markerImageViewToUpdate, drawableResToUpdate, pos < 2 ? markerColor : 0,
marker.getLatitude(), marker.getLongitude(), holder.distance, markerLatLon,
screenOrientation, mapActivity.getMyApplication(), mapActivity); screenOrientation, mapActivity.getMyApplication(), mapActivity, true);
} }
@Override @Override
@ -143,6 +207,12 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
return markers; return markers;
} }
public void hideSnackbar() {
if (snackbar != null && snackbar.isShown()) {
snackbar.dismiss();
}
}
@Override @Override
public boolean onItemMove(int from, int to) { public boolean onItemMove(int from, int to) {
Collections.swap(markers, from, to); Collections.swap(markers, from, to);

View file

@ -0,0 +1,51 @@
package net.osmand.plus.mapmarkers.adapters;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import net.osmand.plus.IconsCache;
import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import java.util.List;
public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> {
private MapActivity mapActivity;
private List<MapMarkersHelper.MapMarker> markers;
private boolean night;
public MapMarkersGroupsAdapter(MapActivity mapActivity) {
this.mapActivity = mapActivity;
markers = mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers();
night = !mapActivity.getMyApplication().getSettings().isLightContent();
}
@Override
public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
return new MapMarkerItemViewHolder(view);
}
@Override
public void onBindViewHolder(MapMarkerItemViewHolder mapMarkerItemViewHolder, int i) {
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
MapMarkersHelper.MapMarker marker = markers.get(i);
}
@Override
public int getItemCount() {
return markers.size();
}
public MapMarkersHelper.MapMarker getItem(int position) {
return markers.get(position);
}
public List<MapMarkersHelper.MapMarker> getItems() {
return markers;
}
}

View file

@ -10,17 +10,76 @@ import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale;
public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<MapMarkerItemViewHolder> { public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int DATE_TYPE = 1;
private static final int MARKER_TYPE = 2;
private static final int TODAY_HEADER = 56;
private static final int YESTERDAY_HEADER = 57;
private static final int LAST_SEVEN_DAYS_HEADER = 58;
private static final int THIS_YEAR_HEADER = 59;
private OsmandApplication app; private OsmandApplication app;
private List<MapMarker> markers; private List<Object> items = new ArrayList<>();
private MapMarkersHistoryAdapterListener listener; private MapMarkersHistoryAdapterListener listener;
public MapMarkersHistoryAdapter(OsmandApplication app) { public MapMarkersHistoryAdapter(OsmandApplication app) {
this.app = app; this.app = app;
markers = app.getMapMarkersHelper().getMapMarkersHistory(); createHeaders();
}
public void createHeaders() {
items.clear();
List<MapMarker> markersHistory = app.getMapMarkersHelper().getMapMarkersHistory();
int previousHeader = -1;
int monthsDisplayed = 0;
Calendar currentDateCalendar = Calendar.getInstance();
currentDateCalendar.setTimeInMillis(System.currentTimeMillis());
int currentDay = currentDateCalendar.get(Calendar.DAY_OF_YEAR);
int currentMonth = currentDateCalendar.get(Calendar.MONTH);
int currentYear = currentDateCalendar.get(Calendar.YEAR);
Calendar markerCalendar = Calendar.getInstance();
for (int i = 0; i < markersHistory.size(); i++) {
MapMarker marker = markersHistory.get(i);
markerCalendar.setTimeInMillis(marker.visitedDate);
int markerDay = markerCalendar.get(Calendar.DAY_OF_YEAR);
int markerMonth = markerCalendar.get(Calendar.MONTH);
int markerYear = markerCalendar.get(Calendar.YEAR);
if (markerYear == currentYear) {
if (markerDay == currentDay && previousHeader != TODAY_HEADER) {
items.add(TODAY_HEADER);
previousHeader = TODAY_HEADER;
} else if (markerDay == currentDay - 1 && previousHeader != YESTERDAY_HEADER) {
items.add(YESTERDAY_HEADER);
previousHeader = YESTERDAY_HEADER;
} else if (currentDay - markerDay >= 2 && currentDay - markerDay <= 8 && previousHeader != LAST_SEVEN_DAYS_HEADER) {
items.add(LAST_SEVEN_DAYS_HEADER);
previousHeader = LAST_SEVEN_DAYS_HEADER;
} else if (currentDay - markerDay > 8 && monthsDisplayed < 3 && previousHeader != markerMonth) {
items.add(markerMonth);
previousHeader = markerMonth;
monthsDisplayed += 1;
} else if (currentMonth - markerMonth >= 4 && previousHeader != THIS_YEAR_HEADER) {
items.add(THIS_YEAR_HEADER);
previousHeader = THIS_YEAR_HEADER;
}
} else if (previousHeader != markerYear) {
items.add(markerYear);
previousHeader = markerYear;
}
items.add(marker);
}
} }
public void setAdapterListener(MapMarkersHistoryAdapterListener listener) { public void setAdapterListener(MapMarkersHistoryAdapterListener listener) {
@ -28,52 +87,109 @@ public class MapMarkersHistoryAdapter extends RecyclerView.Adapter<MapMarkerItem
} }
@Override @Override
public MapMarkerItemViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false); if (viewType == MARKER_TYPE) {
view.setOnClickListener(new View.OnClickListener() { View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_new, viewGroup, false);
@Override view.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) { @Override
listener.onItemClick(view); public void onClick(View view) {
} listener.onItemClick(view);
}); }
return new MapMarkerItemViewHolder(view); });
return new MapMarkerItemViewHolder(view);
} else if (viewType == DATE_TYPE) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.map_marker_item_date, viewGroup, false);
return new MapMarkerDateViewHolder(view);
} else {
throw new IllegalArgumentException("Unsupported view type");
}
} }
@Override @Override
public void onBindViewHolder(final MapMarkerItemViewHolder holder, int pos) { public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
IconsCache iconsCache = app.getIconsCache(); IconsCache iconsCache = app.getIconsCache();
MapMarker marker = markers.get(pos); if (holder instanceof MapMarkerItemViewHolder) {
final MapMarkerItemViewHolder itemViewHolder = (MapMarkerItemViewHolder) holder;
final MapMarker marker = (MapMarker) getItem(position);
itemViewHolder.iconReorder.setVisibility(View.GONE);
holder.iconReorder.setVisibility(View.GONE); int color = MapMarker.getColorId(marker.colorIndex);
itemViewHolder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
int color = MapMarker.getColorId(marker.colorIndex); itemViewHolder.title.setText(marker.getName(app));
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, color));
holder.title.setText(marker.getName(app)); itemViewHolder.description.setText(app.getString(R.string.passed, new SimpleDateFormat("MMM dd", Locale.getDefault()).format(new Date(marker.visitedDate))));
holder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_refresh_dark)); itemViewHolder.optionsBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reset_to_default_dark));
holder.optionsBtn.setOnClickListener(new View.OnClickListener() { itemViewHolder.optionsBtn.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
int position = holder.getAdapterPosition(); int position = itemViewHolder.getAdapterPosition();
if (position < 0) { if (position < 0) {
return; return;
}
app.getMapMarkersHelper().restoreMarkerFromHistory(marker, 0);
notifyItemRemoved(position);
} }
MapMarker marker = markers.get(position); });
app.getMapMarkersHelper().removeMapMarkerHistory(marker); itemViewHolder.flagIconLeftSpace.setVisibility(View.VISIBLE);
app.getMapMarkersHelper().addMapMarker(marker, 0); itemViewHolder.iconDirection.setVisibility(View.GONE);
notifyItemRemoved(position); itemViewHolder.leftPointSpace.setVisibility(View.GONE);
itemViewHolder.rightPointSpace.setVisibility(View.GONE);
if (position == getItemCount() - 1) {
itemViewHolder.bottomShadow.setVisibility(View.VISIBLE);
itemViewHolder.divider.setVisibility(View.GONE);
} else {
itemViewHolder.bottomShadow.setVisibility(View.GONE);
itemViewHolder.divider.setVisibility(View.VISIBLE);
} }
}); } else if (holder instanceof MapMarkerDateViewHolder) {
final MapMarkerDateViewHolder dateViewHolder = (MapMarkerDateViewHolder) holder;
final Integer dateHeader = (Integer) getItem(position);
String dateString;
if (dateHeader == TODAY_HEADER) {
dateString = app.getString(R.string.today);
} else if (dateHeader == YESTERDAY_HEADER) {
dateString = app.getString(R.string.yesterday);
} else if (dateHeader == LAST_SEVEN_DAYS_HEADER) {
dateString = app.getString(R.string.last_seven_days);
} else if (dateHeader == THIS_YEAR_HEADER) {
dateString = app.getString(R.string.this_year);
} else if (dateHeader / 100 == 0) {
dateString = getMonth(dateHeader);
} else {
dateString = String.valueOf(dateHeader);
}
dateViewHolder.date.setText(dateString);
}
}
@Override
public int getItemViewType(int position) {
Object item = items.get(position);
if (item instanceof MapMarker) {
return MARKER_TYPE;
} else if (item instanceof Integer) {
return DATE_TYPE;
} else {
throw new IllegalArgumentException("Unsupported view type");
}
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return markers.size(); return items.size();
} }
public MapMarker getItem(int position) { public Object getItem(int position) {
return markers.get(position); return items.get(position);
}
private String getMonth(int month) {
SimpleDateFormat dateFormat = new SimpleDateFormat("LLLL", Locale.getDefault());
Date date = new Date();
date.setMonth(month);
return dateFormat.format(date);
} }
public interface MapMarkersHistoryAdapterListener { public interface MapMarkersHistoryAdapterListener {

View file

@ -141,7 +141,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment
final View scrollView = mainView.findViewById(R.id.measure_options_scroll_view); final View scrollView = mainView.findViewById(R.id.measure_options_scroll_view);
int scrollViewHeight = scrollView.getHeight(); int scrollViewHeight = scrollView.getHeight();
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1); int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.measure_distance_bottom_sheet_cancel_button_height); int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight; int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
if (scrollViewHeight > spaceForScrollView) { if (scrollViewHeight > spaceForScrollView) {
scrollView.getLayoutParams().height = spaceForScrollView; scrollView.getLayoutParams().height = spaceForScrollView;

View file

@ -102,7 +102,7 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends BottomSheetDialogFr
final View scrollView = mainView.findViewById(R.id.save_as_new_track_scroll_view); final View scrollView = mainView.findViewById(R.id.save_as_new_track_scroll_view);
int scrollViewHeight = scrollView.getHeight(); int scrollViewHeight = scrollView.getHeight();
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1); int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.measure_distance_bottom_sheet_cancel_button_height); int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight; int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
if (scrollViewHeight > spaceForScrollView) { if (scrollViewHeight > spaceForScrollView) {
scrollView.getLayoutParams().height = spaceForScrollView; scrollView.getLayoutParams().height = spaceForScrollView;

View file

@ -167,7 +167,7 @@ public class SelectedPointBottomSheetDialogFragment extends BottomSheetDialogFra
final View scrollView = mainView.findViewById(R.id.selected_point_options_scroll_view); final View scrollView = mainView.findViewById(R.id.selected_point_options_scroll_view);
int scrollViewHeight = scrollView.getHeight(); int scrollViewHeight = scrollView.getHeight();
int dividerHeight = AndroidUtils.dpToPx(getContext(), 1); int dividerHeight = AndroidUtils.dpToPx(getContext(), 1);
int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.measure_distance_bottom_sheet_cancel_button_height); int cancelButtonHeight = getContext().getResources().getDimensionPixelSize(R.dimen.bottom_sheet_cancel_button_height);
int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight; int spaceForScrollView = screenHeight - statusBarHeight - navBarHeight - dividerHeight - cancelButtonHeight;
if (scrollViewHeight > spaceForScrollView) { if (scrollViewHeight > spaceForScrollView) {
scrollView.getLayoutParams().height = spaceForScrollView; scrollView.getLayoutParams().height = spaceForScrollView;

View file

@ -44,6 +44,7 @@ import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
import net.osmand.plus.IconsCache; import net.osmand.plus.IconsCache;
import net.osmand.plus.MapMarkersHelper; import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MarkersSyncGroup;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -607,7 +608,10 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, i.name)); names.add(new PointDescription(PointDescription.POINT_TYPE_MAP_MARKER, i.name));
} }
} }
markersHelper.addMapMarkers(points, names); File gpx = getGpxDataItem().getFile();
MarkersSyncGroup syncGroup = new MarkersSyncGroup(gpx.getAbsolutePath(), trimExtension(gpx.getName()), MarkersSyncGroup.GPX_TYPE);
markersHelper.addMarkersSyncGroup(syncGroup);
markersHelper.addMapMarkers(points, names, syncGroup);
MapActivity.launchMapActivityMoveToTop(getActivity()); MapActivity.launchMapActivityMoveToTop(getActivity());
} else { } else {
final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper(); final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
@ -626,6 +630,14 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
} }
} }
private String trimExtension(String src) {
int index = src.lastIndexOf('.');
if (index != -1) {
return src.substring(0, index);
}
return src;
}
private void enterFavoritesMode() { private void enterFavoritesMode() {
actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() { actionMode = getActionBarActivity().startSupportActionMode(new ActionMode.Callback() {

View file

@ -493,16 +493,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
@Override @Override
public void setSelectedObject(Object o) { public void setSelectedObject(Object o) {
if (o instanceof MapMarker) { if (o instanceof MapMarker) {
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper(); map.getMyApplication().getMapMarkersHelper().moveMarkerToTop((MapMarker) o);
MapMarker marker = (MapMarker) o;
List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
int i = mapMarkers.indexOf(marker);
if (i != -1) {
mapMarkers.remove(i);
mapMarkers.add(0, marker);
markersHelper.saveMapMarkers(mapMarkers, null);
marker.index = 0;
}
} }
} }

View file

@ -131,9 +131,7 @@ public class MapMarkersWidgetsFactory {
private void removeMarker(int index) { private void removeMarker(int index) {
if (helper.getMapMarkers().size() > index) { if (helper.getMapMarkers().size() > index) {
MapMarker marker = helper.getMapMarkers().get(index); helper.moveMapMarkerToHistory(helper.getMapMarkers().get(index));
helper.removeMapMarker(marker.index);
helper.addMapMarkerHistory(marker);
} }
} }

View file

@ -345,16 +345,7 @@ public class MapWidgetRegistry {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
settings.MAP_MARKERS_MODE.set(MapMarkersMode.values()[which]); settings.MAP_MARKERS_MODE.set(MapMarkersMode.values()[which]);
for (MapWidgetRegInfo info : rightWidgetSet) { updateMapMarkersMode(map);
if ("map_marker_1st".equals(info.key) || "map_marker_2nd".equals(info.key)) {
setVisibility(info, settings.MAP_MARKERS_MODE.get().isWidgets(), false);
}
}
MapInfoLayer mil = map.getMapLayers().getMapInfoLayer();
if (mil != null) {
mil.recreateControls();
}
map.refreshMap();
dialog.dismiss(); dialog.dismiss();
cm.getItem(pos).setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map)); cm.getItem(pos).setDescription(settings.MAP_MARKERS_MODE.get().toHumanString(map));
ad.notifyDataSetChanged(); ad.notifyDataSetChanged();
@ -367,6 +358,19 @@ public class MapWidgetRegistry {
} }
} }
public void updateMapMarkersMode(MapActivity mapActivity) {
for (MapWidgetRegInfo info : rightWidgetSet) {
if ("map_marker_1st".equals(info.key) || "map_marker_2nd".equals(info.key)) {
setVisibility(info, settings.MAP_MARKERS_MODE.get().isWidgets(), false);
}
}
MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer();
if (mil != null) {
mil.recreateControls();
}
mapActivity.refreshMap();
}
private void addControlId(final MapActivity map, ContextMenuAdapter cm, private void addControlId(final MapActivity map, ContextMenuAdapter cm,
@StringRes int stringId, OsmandPreference<Boolean> pref) { @StringRes int stringId, OsmandPreference<Boolean> pref) {
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(stringId, map) cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(stringId, map)