diff --git a/OsmAnd/res/drawable/marker_circle_background_dark_n_with_inset.xml b/OsmAnd/res/drawable/marker_circle_background_dark_n_with_inset.xml index ad071dcc25..d777eb52c4 100644 --- a/OsmAnd/res/drawable/marker_circle_background_dark_n_with_inset.xml +++ b/OsmAnd/res/drawable/marker_circle_background_dark_n_with_inset.xml @@ -1,7 +1,7 @@ \ No newline at end of file + android:insetBottom="@dimen/context_menu_first_line_top_margin" + android:insetLeft="@dimen/context_menu_first_line_top_margin" + android:insetRight="@dimen/context_menu_first_line_top_margin" + android:insetTop="@dimen/context_menu_first_line_top_margin"/> \ No newline at end of file diff --git a/OsmAnd/res/drawable/marker_circle_background_light_n_with_inset.xml b/OsmAnd/res/drawable/marker_circle_background_light_n_with_inset.xml index b20f1f27f0..8c2cc54e0a 100644 --- a/OsmAnd/res/drawable/marker_circle_background_light_n_with_inset.xml +++ b/OsmAnd/res/drawable/marker_circle_background_light_n_with_inset.xml @@ -1,7 +1,7 @@ \ No newline at end of file + android:insetBottom="@dimen/context_menu_first_line_top_margin" + android:insetLeft="@dimen/context_menu_first_line_top_margin" + android:insetRight="@dimen/context_menu_first_line_top_margin" + android:insetTop="@dimen/context_menu_first_line_top_margin"/> \ No newline at end of file diff --git a/OsmAnd/res/drawable/marker_circle_background_on_map_n_with_inset.xml b/OsmAnd/res/drawable/marker_circle_background_on_map_n_with_inset.xml index e9ab9f1da0..26b6310ad7 100644 --- a/OsmAnd/res/drawable/marker_circle_background_on_map_n_with_inset.xml +++ b/OsmAnd/res/drawable/marker_circle_background_on_map_n_with_inset.xml @@ -1,7 +1,7 @@ \ No newline at end of file + android:insetBottom="@dimen/context_menu_first_line_top_margin" + android:insetLeft="@dimen/context_menu_first_line_top_margin" + android:insetRight="@dimen/context_menu_first_line_top_margin" + android:insetTop="@dimen/context_menu_first_line_top_margin"/> \ No newline at end of file diff --git a/OsmAnd/res/drawable/marker_circle_background_p_with_inset.xml b/OsmAnd/res/drawable/marker_circle_background_p_with_inset.xml index 87a731b9d6..849b4ac748 100644 --- a/OsmAnd/res/drawable/marker_circle_background_p_with_inset.xml +++ b/OsmAnd/res/drawable/marker_circle_background_p_with_inset.xml @@ -1,9 +1,9 @@ + android:insetBottom="@dimen/context_menu_first_line_top_margin" + android:insetLeft="@dimen/context_menu_first_line_top_margin" + android:insetRight="@dimen/context_menu_first_line_top_margin" + android:insetTop="@dimen/context_menu_first_line_top_margin"> \ No newline at end of file diff --git a/OsmAnd/res/layout-land/fragment_marker_menu_on_map.xml b/OsmAnd/res/layout-land/fragment_marker_menu_on_map.xml new file mode 100644 index 0000000000..6bce2a039d --- /dev/null +++ b/OsmAnd/res/layout-land/fragment_marker_menu_on_map.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/layout-land/fragment_measurement_tool.xml b/OsmAnd/res/layout-land/fragment_measurement_tool.xml index 9a611c8672..3c3615d0af 100644 --- a/OsmAnd/res/layout-land/fragment_measurement_tool.xml +++ b/OsmAnd/res/layout-land/fragment_measurement_tool.xml @@ -70,9 +70,9 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" - android:layout_marginEnd="@dimen/measurement_tool_text_margin_small" + android:layout_marginEnd="@dimen/text_margin_small" android:layout_marginLeft="@dimen/measurement_tool_text_margin" - android:layout_marginRight="@dimen/measurement_tool_text_margin_small" + android:layout_marginRight="@dimen/text_margin_small" android:layout_marginStart="@dimen/measurement_tool_text_margin" android:layout_toEndOf="@id/main_icon" android:layout_toRightOf="@id/main_icon" @@ -108,9 +108,9 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" - android:layout_marginEnd="@dimen/measurement_tool_text_margin_small" + android:layout_marginEnd="@dimen/text_margin_small" android:layout_marginLeft="@dimen/measurement_tool_text_margin" - android:layout_marginRight="@dimen/measurement_tool_text_margin_small" + android:layout_marginRight="@dimen/text_margin_small" android:layout_marginStart="@dimen/measurement_tool_text_margin" android:layout_toEndOf="@id/main_icon" android:layout_toRightOf="@id/main_icon" @@ -123,9 +123,9 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" - android:layout_marginEnd="@dimen/measurement_tool_text_margin_small" + android:layout_marginEnd="@dimen/text_margin_small" android:layout_marginLeft="@dimen/measurement_tool_text_margin" - android:layout_marginRight="@dimen/measurement_tool_text_margin_small" + android:layout_marginRight="@dimen/text_margin_small" android:layout_marginStart="@dimen/measurement_tool_text_margin" android:layout_toEndOf="@id/main_icon" android:layout_toRightOf="@id/main_icon" diff --git a/OsmAnd/res/layout-land/fragment_plan_route_half_screen.xml b/OsmAnd/res/layout-land/fragment_plan_route_half_screen.xml index d85da7b8fc..fa57a31b82 100644 --- a/OsmAnd/res/layout-land/fragment_plan_route_half_screen.xml +++ b/OsmAnd/res/layout-land/fragment_plan_route_half_screen.xml @@ -47,8 +47,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:layout_marginEnd="@dimen/measurement_tool_text_margin_small" - android:layout_marginRight="@dimen/measurement_tool_text_margin_small" + android:layout_marginEnd="@dimen/text_margin_small" + android:layout_marginRight="@dimen/text_margin_small" android:ellipsize="end" android:maxLines="1" android:textAppearance="@style/TextAppearance.ListItemTitle" @@ -86,8 +86,8 @@ android:ellipsize="end" android:gravity="center_vertical" android:maxLines="1" - android:paddingLeft="16dp" - android:paddingRight="16dp" + android:paddingLeft="@dimen/list_content_padding" + android:paddingRight="@dimen/list_content_padding" android:text="@string/shared_string_options" android:textAllCaps="true" android:textColor="?attr/color_dialog_buttons" diff --git a/OsmAnd/res/layout/close_measurement_tool_dialog.xml b/OsmAnd/res/layout/close_measurement_tool_dialog.xml index e1c823056a..66d2b6fa42 100644 --- a/OsmAnd/res/layout/close_measurement_tool_dialog.xml +++ b/OsmAnd/res/layout/close_measurement_tool_dialog.xml @@ -4,7 +4,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" - android:padding="@dimen/bottom_sheet_content_padding"> + android:padding="@dimen/content_padding"> @@ -34,10 +34,10 @@ diff --git a/OsmAnd/res/layout/fragment_marker_coordinate_input_options_bottom_sheet_helper.xml b/OsmAnd/res/layout/fragment_marker_coordinate_input_options_bottom_sheet_helper.xml index cd2b841a19..9a9d487f03 100644 --- a/OsmAnd/res/layout/fragment_marker_coordinate_input_options_bottom_sheet_helper.xml +++ b/OsmAnd/res/layout/fragment_marker_coordinate_input_options_bottom_sheet_helper.xml @@ -23,10 +23,10 @@ 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:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" android:text="@string/shared_string_options" android:textAppearance="@style/TextAppearance.ListItemTitle" osmand:typeface="@string/font_roboto_medium"/> @@ -38,8 +38,8 @@ android:background="?attr/selectableItemBackground" android:descendantFocusability="blocksDescendants" android:minHeight="@dimen/bottom_sheet_list_item_height" - android:paddingLeft="@dimen/bottom_sheet_content_padding" - android:paddingRight="@dimen/bottom_sheet_content_padding"> + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding"> diff --git a/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml index b89be37e6b..a53f553019 100644 --- a/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml +++ b/OsmAnd/res/layout/fragment_marker_history_bottom_sheet_dialog.xml @@ -17,7 +17,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" - android:paddingBottom="8dp"> + android:paddingBottom="@dimen/bottom_sheet_content_padding_small"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/layout/fragment_marker_options_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_marker_options_bottom_sheet_dialog.xml index 2253a3ead1..ab56b39923 100644 --- a/OsmAnd/res/layout/fragment_marker_options_bottom_sheet_dialog.xml +++ b/OsmAnd/res/layout/fragment_marker_options_bottom_sheet_dialog.xml @@ -17,16 +17,16 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" - android:paddingBottom="8dp"> + android:paddingBottom="@dimen/bottom_sheet_content_padding_small"> @@ -37,15 +37,15 @@ android:layout_height="@dimen/bottom_sheet_list_item_height" android:background="?attr/selectableItemBackground" android:minHeight="@dimen/bottom_sheet_list_item_height" - android:paddingEnd="@dimen/bottom_sheet_content_padding" - android:paddingLeft="@dimen/bottom_sheet_content_padding" - android:paddingRight="@dimen/bottom_sheet_content_padding" - android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> @@ -37,10 +37,10 @@ android:layout_height="@dimen/bottom_sheet_list_item_height" android:background="?attr/selectableItemBackground" android:minHeight="@dimen/bottom_sheet_list_item_height" - android:paddingEnd="@dimen/bottom_sheet_content_padding" - android:paddingLeft="@dimen/bottom_sheet_content_padding" - android:paddingRight="@dimen/bottom_sheet_content_padding" - android:paddingStart="@dimen/bottom_sheet_content_padding" + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" android:gravity="center_vertical"> @@ -34,10 +34,10 @@ diff --git a/OsmAnd/res/layout/fragment_marker_show_direction_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_marker_show_direction_bottom_sheet_dialog.xml index d94792fa53..c818680b60 100644 --- a/OsmAnd/res/layout/fragment_marker_show_direction_bottom_sheet_dialog.xml +++ b/OsmAnd/res/layout/fragment_marker_show_direction_bottom_sheet_dialog.xml @@ -23,10 +23,10 @@ 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:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" android:text="@string/show_direction" android:textAppearance="@style/TextAppearance.ListItemTitle" osmand:typeface="@string/font_roboto_medium"/> @@ -34,10 +34,10 @@ @@ -122,8 +122,8 @@ android:background="?attr/selectableItemBackground" android:descendantFocusability="blocksDescendants" android:minHeight="@dimen/bottom_sheet_list_item_height" - android:paddingLeft="@dimen/bottom_sheet_content_padding" - android:paddingRight="@dimen/bottom_sheet_content_padding"> + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding"> + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingBottom="@dimen/bottom_sheet_content_padding_small"> @@ -38,10 +38,10 @@ android:layout_height="@dimen/bottom_sheet_list_item_height" android:background="?attr/selectableItemBackground" android:minHeight="@dimen/bottom_sheet_list_item_height" - android:paddingEnd="@dimen/bottom_sheet_content_padding" - android:paddingLeft="@dimen/bottom_sheet_content_padding" - android:paddingRight="@dimen/bottom_sheet_content_padding" - android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> @@ -39,10 +39,10 @@ android:background="?attr/selectableItemBackground" android:gravity="center_vertical" android:minHeight="@dimen/bottom_sheet_list_item_height" - android:paddingEnd="@dimen/bottom_sheet_content_padding" - android:paddingLeft="@dimen/bottom_sheet_content_padding" - android:paddingRight="@dimen/bottom_sheet_content_padding" - android:paddingStart="@dimen/bottom_sheet_content_padding" + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" android:visibility="gone" tools:visibility="visible"> @@ -71,10 +71,10 @@ android:background="?attr/selectableItemBackground" android:gravity="center_vertical" android:minHeight="@dimen/bottom_sheet_list_item_height" - android:paddingEnd="@dimen/bottom_sheet_content_padding" - android:paddingLeft="@dimen/bottom_sheet_content_padding" - android:paddingRight="@dimen/bottom_sheet_content_padding" - android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/layout/fragment_save_as_new_track_bottom_sheet_dialog.xml b/OsmAnd/res/layout/fragment_save_as_new_track_bottom_sheet_dialog.xml index 0d4407b103..5606b9625f 100644 --- a/OsmAnd/res/layout/fragment_save_as_new_track_bottom_sheet_dialog.xml +++ b/OsmAnd/res/layout/fragment_save_as_new_track_bottom_sheet_dialog.xml @@ -23,10 +23,10 @@ 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:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" android:text="@string/shared_string_save_as_gpx" android:textAppearance="@style/TextAppearance.ListItemTitle" osmand:typeface="@string/font_roboto_medium"/> @@ -34,10 +34,10 @@ @@ -121,10 +121,10 @@ android:layout_height="@dimen/bottom_sheet_list_item_height" android:background="?attr/selectableItemBackground" android:minHeight="@dimen/bottom_sheet_list_item_height" - android:paddingEnd="@dimen/bottom_sheet_content_padding" - android:paddingLeft="@dimen/bottom_sheet_content_padding" - android:paddingRight="@dimen/bottom_sheet_content_padding" - android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> diff --git a/OsmAnd/res/layout/list_item_icon_and_title.xml b/OsmAnd/res/layout/list_item_icon_and_title.xml index 783198f543..ee7652a09c 100644 --- a/OsmAnd/res/layout/list_item_icon_and_title.xml +++ b/OsmAnd/res/layout/list_item_icon_and_title.xml @@ -6,10 +6,10 @@ android:layout_height="@dimen/bottom_sheet_list_item_height" android:background="?attr/selectableItemBackground" android:minHeight="@dimen/bottom_sheet_list_item_height" - android:paddingEnd="@dimen/bottom_sheet_content_padding" - android:paddingLeft="@dimen/bottom_sheet_content_padding" - android:paddingRight="@dimen/bottom_sheet_content_padding" - android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> diff --git a/OsmAnd/res/layout/map_marker_item_new.xml b/OsmAnd/res/layout/map_marker_item_new.xml index 3f1f1d6c38..2ebd8cd890 100644 --- a/OsmAnd/res/layout/map_marker_item_new.xml +++ b/OsmAnd/res/layout/map_marker_item_new.xml @@ -25,13 +25,13 @@ @@ -49,8 +49,8 @@ android:layout_width="24dp" android:layout_height="24dp" android:layout_gravity="center_vertical" - android:layout_marginEnd="16dp" - android:layout_marginRight="16dp" + android:layout_marginEnd="@dimen/bottom_sheet_content_margin" + android:layout_marginRight="@dimen/bottom_sheet_content_margin" tools:src="@drawable/ic_action_flag_dark"/> + android:layout_height="@dimen/map_marker_title_height"> @@ -158,10 +158,10 @@ android:id="@+id/map_marker_check_box" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginBottom="16dp" - android:layout_marginLeft="16dp" - android:layout_marginRight="16dp" - android:layout_marginTop="16dp" + android:layout_marginBottom="@dimen/bottom_sheet_content_margin" + android:layout_marginLeft="@dimen/bottom_sheet_content_margin" + android:layout_marginRight="@dimen/bottom_sheet_content_margin" + android:layout_marginTop="@dimen/bottom_sheet_content_margin" android:visibility="gone" tools:visibility="visible"/> @@ -172,8 +172,8 @@ android:id="@+id/divider" android:layout_width="wrap_content" android:layout_height="1dp" - android:layout_marginLeft="56dp" - android:layout_marginStart="56dp" + android:layout_marginLeft="@dimen/map_button_shadow_width" + android:layout_marginStart="@dimen/map_button_shadow_width" tools:background="?attr/dashboard_divider"/> diff --git a/OsmAnd/res/layout/map_marker_item_show_hide_history.xml b/OsmAnd/res/layout/map_marker_item_show_hide_history.xml index 908b633e61..3d066409d2 100644 --- a/OsmAnd/res/layout/map_marker_item_show_hide_history.xml +++ b/OsmAnd/res/layout/map_marker_item_show_hide_history.xml @@ -10,19 +10,19 @@ + android:layout_height="@dimen/bottom_sheet_list_item_height"> diff --git a/OsmAnd/res/layout/marker_coordinate_formats.xml b/OsmAnd/res/layout/marker_coordinate_formats.xml index 3d589075c9..f342c3d05a 100644 --- a/OsmAnd/res/layout/marker_coordinate_formats.xml +++ b/OsmAnd/res/layout/marker_coordinate_formats.xml @@ -12,10 +12,10 @@ android:background="?attr/selectableItemBackground" android:gravity="center_vertical" android:minHeight="@dimen/bottom_sheet_list_item_height" - android:paddingEnd="@dimen/bottom_sheet_content_padding" - android:paddingLeft="@dimen/bottom_sheet_content_padding" - android:paddingRight="@dimen/bottom_sheet_content_padding" - android:paddingStart="@dimen/bottom_sheet_content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/layout/markers_track_name_edit_text.xml b/OsmAnd/res/layout/markers_track_name_edit_text.xml index e16cc49fea..35196fb3e4 100644 --- a/OsmAnd/res/layout/markers_track_name_edit_text.xml +++ b/OsmAnd/res/layout/markers_track_name_edit_text.xml @@ -15,10 +15,10 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/shared_string_name" - 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:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding"> @@ -32,8 +32,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" - android:layout_marginEnd="16dp" - android:layout_marginRight="16dp" + android:layout_marginEnd="@dimen/bottom_sheet_content_margin" + android:layout_marginRight="@dimen/bottom_sheet_content_margin" android:layout_toEndOf="@id/measure_point_reorder_icon" android:layout_toRightOf="@id/measure_point_reorder_icon" tools:src="@drawable/ic_action_measure_point"/> @@ -47,12 +47,12 @@ android:layout_centerVertical="true" android:background="?attr/selectableItemBackground" android:focusableInTouchMode="true" - android:paddingBottom="12dp" - android:paddingEnd="16dp" - android:paddingLeft="16dp" - android:paddingRight="16dp" - android:paddingStart="16dp" - android:paddingTop="12dp" + android:paddingBottom="@dimen/measurement_tool_content_padding_medium" + android:paddingEnd="@dimen/content_padding" + android:paddingLeft="@dimen/content_padding" + android:paddingRight="@dimen/content_padding" + android:paddingStart="@dimen/content_padding" + android:paddingTop="@dimen/measurement_tool_content_padding_medium" tools:src="@drawable/ic_action_remove_dark"/> + android:padding="@dimen/content_padding"> 14sp 27sp + 24sp + 15sp 15sp 12sp @@ -97,11 +99,11 @@ 30dp 24dp 12dp - 24dp + 24dp 12dp 12dp 18dp - 6dp + 6dp 12dp 330dp 48dp @@ -118,13 +120,16 @@ 66dp 72dp 36dp - 11dp - 12dp - 96dp + 11dp + 12dp + 84dp 15dp 84dp 78dp 15dp + + 8dp + 42dp \ No newline at end of file diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index d43bf1466d..aacd678beb 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -162,11 +162,11 @@ 20dp 16dp 8dp - 16dp + 16dp 8dp 8dp 12dp - 4dp + 4dp 8dp 220dp 48dp @@ -183,12 +183,15 @@ 44dp 48dp 24dp - 7dp - 8dp - 64dp + 7dp + 8dp + 64dp 10dp 56dp 52dp 10dp + + 5dp + 28dp \ No newline at end of file diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index d0adadf810..f5b024130c 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -11,6 +11,9 @@ --> View Waypoints added to map markers + Wrong input + Enter new name + Back Wrong format Road Show map diff --git a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java index eb961cc33e..4307c25421 100644 --- a/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/MapMarkersHelper.java @@ -101,6 +101,10 @@ public class MapMarkersHelper { return pointDescription == null ? "" : pointDescription.getName(); } + public void setName(String name) { + pointDescription.setName(name); + } + public double getLatitude() { return point.getLatitude(); } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java index d8fe089349..c6b8d359be 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/HistoryMarkerMenuBottomSheetDialogFragment.java @@ -117,7 +117,7 @@ public class HistoryMarkerMenuBottomSheetDialogFragment extends BottomSheetDialo if (!portrait) { if (screenHeight - statusBarHeight - mainView.getHeight() - >= AndroidUtils.dpToPx(getActivity(), 8)) { + >= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) { AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark); } else { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java index 2c3018cd49..2f23726980 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersActiveFragment.java @@ -59,9 +59,10 @@ public class MapMarkersActiveFragment extends Fragment implements OsmAndCompassL return; } MapMarker marker = adapter.getItem(pos); - mapActivity.getMyApplication().getSettings().setMapLocationToShow(marker.getLatitude(), marker.getLongitude(), - 15, marker.getPointDescription(mapActivity), true, marker); + mapActivity.getMyApplication().getSettings() + .setMapLocationToShow(marker.getLatitude(), marker.getLongitude(), 15, null, false, null); MapActivity.launchMapActivityMoveToTop(mapActivity); + MarkerMenuOnMapFragment.showInstance(mapActivity, marker); ((DialogFragment) getParentFragment()).dismiss(); } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java index 4db3ae33cd..88d51a7153 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersGroupsFragment.java @@ -10,6 +10,7 @@ import android.graphics.Rect; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.design.widget.Snackbar; +import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.support.v7.widget.LinearLayoutManager; @@ -203,6 +204,24 @@ public class MapMarkersGroupsFragment extends Fragment implements OsmAndCompassL itemTouchHelper.attachToRecyclerView(recyclerView); adapter = new MapMarkersGroupsAdapter(mapActivity); + adapter.setListener(new MapMarkersGroupsAdapter.MapMarkersGroupsAdapterListener() { + @Override + public void onItemClick(View view) { + int pos = recyclerView.getChildAdapterPosition(view); + if (pos == RecyclerView.NO_POSITION) { + return; + } + Object item = adapter.getItem(pos); + if (item instanceof MapMarker) { + MapMarker marker = (MapMarker) item; + mapActivity.getMyApplication().getSettings() + .setMapLocationToShow(marker.getLatitude(), marker.getLongitude(), 15, null, false, null); + MapActivity.launchMapActivityMoveToTop(mapActivity); + MarkerMenuOnMapFragment.showInstance(mapActivity, marker); + ((DialogFragment) getParentFragment()).dismiss(); + } + } + }); recyclerView.setAdapter(adapter); return recyclerView; } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerMenuOnMapFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerMenuOnMapFragment.java new file mode 100644 index 0000000000..654da3ea4b --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MarkerMenuOnMapFragment.java @@ -0,0 +1,329 @@ +package net.osmand.plus.mapmarkers; + +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.support.annotation.DrawableRes; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.support.design.widget.Snackbar; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.support.v4.content.ContextCompat; +import android.view.ContextThemeWrapper; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageButton; +import android.widget.ImageView; +import android.widget.TextView; + +import net.osmand.Location; +import net.osmand.data.LatLon; +import net.osmand.plus.IconsCache; +import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; +import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.dashboard.DashLocationFragment; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.views.OsmandMapTileView; +import net.osmand.util.MapUtils; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; + +import static net.osmand.plus.OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT; +import static net.osmand.plus.OsmandSettings.MIDDLE_TOP_CONSTANT; + +public class MarkerMenuOnMapFragment extends Fragment implements OsmAndCompassListener, OsmAndLocationListener { + + public static final String TAG = "MarkerMenuOnMapFragment"; + + private IconsCache iconsCache; + private MapMarker marker; + + private boolean night; + private boolean portrait; + + private int previousMapPosition; + + private Float heading; + private Location location; + + private ImageView arrowIv; + private TextView distanceTv; + private View dividerPoint; + + public void setMarker(MapMarker marker) { + this.marker = marker; + } + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final OsmandApplication app = (OsmandApplication) getActivity().getApplication(); + night = app.getDaynightHelper().isNightModeForMapControls(); + iconsCache = app.getIconsCache(); + portrait = AndroidUiHelper.isOrientationPortrait(getActivity()); + final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; + + final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_marker_menu_on_map, null); + mainView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + dismiss(); + } + }); + + ((ImageView) mainView.findViewById(R.id.marker_icon)) + .setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(marker.colorIndex))); + ((ImageView) mainView.findViewById(R.id.rename_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_edit_dark)); + ((ImageView) mainView.findViewById(R.id.delete_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_delete_dark)); + + ((TextView) mainView.findViewById(R.id.marker_title)).setText(marker.getName(getActivity())); + + arrowIv = (ImageView) mainView.findViewById(R.id.marker_direction_icon); + distanceTv = (TextView) mainView.findViewById(R.id.marker_distance); + dividerPoint = mainView.findViewById(R.id.marker_divider_point); + + String descr; + if ((descr = marker.groupName) != null) { + if (descr.equals("")) { + descr = getActivity().getString(R.string.shared_string_favorites); + } + } else { + Date date = new Date(marker.creationDate); + String month = new SimpleDateFormat("MMM", Locale.getDefault()).format(date); + if (month.length() > 1) { + month = Character.toUpperCase(month.charAt(0)) + month.substring(1); + } + month = month.replaceAll("\\.", ""); + String day = new SimpleDateFormat("d", Locale.getDefault()).format(date); + descr = month + " " + day; + } + ((TextView) mainView.findViewById(R.id.marker_description)).setText(descr); + + ImageButton visitedBtn = (ImageButton) mainView.findViewById(R.id.marker_visited_button); + visitedBtn.setBackgroundDrawable(ContextCompat.getDrawable(getContext(), + night ? R.drawable.marker_circle_background_dark_with_inset : R.drawable.marker_circle_background_light_with_inset)); + visitedBtn.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_marker_passed, night ? 0 : R.color.icon_color)); + visitedBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + app.getMapMarkersHelper().moveMapMarkerToHistory(marker); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + Snackbar.make(mapActivity.findViewById(R.id.bottomFragmentContainer), R.string.marker_moved_to_history, Snackbar.LENGTH_LONG) + .setAction(R.string.shared_string_undo, new View.OnClickListener() { + @Override + public void onClick(View view) { + app.getMapMarkersHelper().restoreMarkerFromHistory(marker, 0); + } + }) + .show(); + } + dismiss(); + } + }); + + mainView.findViewById(R.id.rename_row).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + RenameMarkerBottomSheetDialogFragment fragment = new RenameMarkerBottomSheetDialogFragment(); + fragment.setMarker(marker); + fragment.setRetainInstance(true); + fragment.show(mapActivity.getSupportFragmentManager(), RenameMarkerBottomSheetDialogFragment.TAG); + } + } + }); + + mainView.findViewById(R.id.delete_row).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + app.getMapMarkersHelper().removeMarker(marker); + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + Snackbar.make(mapActivity.findViewById(R.id.bottomFragmentContainer), R.string.item_removed, Snackbar.LENGTH_LONG) + .setAction(R.string.shared_string_undo, new View.OnClickListener() { + @Override + public void onClick(View view) { + app.getMapMarkersHelper().addMarker(marker); + } + }) + .show(); + } + dismiss(); + } + }); + + mainView.findViewById(R.id.back_row).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + MapMarkersDialogFragment.showInstance(mapActivity); + } + dismiss(); + } + }); + + return mainView; + } + + @Override + public void onResume() { + super.onResume(); + enterMenuMode(); + startLocationUpdate(); + } + + @Override + public void onPause() { + super.onPause(); + exitMenuMode(); + stopLocationUpdate(); + } + + @Override + public void updateLocation(Location location) { + boolean newLocation = this.location == null && location != null; + boolean locationChanged = this.location != null && location != null + && this.location.getLatitude() != location.getLatitude() + && this.location.getLongitude() != location.getLongitude(); + if (newLocation || locationChanged) { + this.location = location; + updateLocationUi(); + } + } + + @Override + public void updateCompassValue(float value) { + // 99 in next line used to one-time initialize arrows (with reference vs. fixed-north direction) + // on non-compass devices + float lastHeading = heading != null ? heading : 99; + heading = value; + if (Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) { + updateLocationUi(); + } else { + heading = lastHeading; + } + } + + private OsmandApplication getMyApplication() { + if (getActivity() != null) { + return ((MapActivity) getActivity()).getMyApplication(); + } + return null; + } + + private MapActivity getMapActivity() { + return (MapActivity) getActivity(); + } + + private Drawable getContentIcon(@DrawableRes int id) { + return iconsCache.getIcon(id, night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color); + } + + private void startLocationUpdate() { + OsmandApplication app = getMyApplication(); + if (app != null) { + app.getLocationProvider().removeCompassListener(app.getLocationProvider().getNavigationInfo()); + app.getLocationProvider().addCompassListener(this); + app.getLocationProvider().addLocationListener(this); + updateLocationUi(); + } + } + + private void stopLocationUpdate() { + OsmandApplication app = getMyApplication(); + if (app != null) { + app.getLocationProvider().removeLocationListener(this); + app.getLocationProvider().removeCompassListener(this); + app.getLocationProvider().addCompassListener(app.getLocationProvider().getNavigationInfo()); + } + } + + private void updateLocationUi() { + final MapActivity mapActivity = (MapActivity) getActivity(); + if (mapActivity != null) { + mapActivity.getMyApplication().runInUIThread(new Runnable() { + @Override + public void run() { + if (location == null) { + location = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation(); + } + if (location != null) { + mark(View.VISIBLE, arrowIv, distanceTv, dividerPoint); + DashLocationFragment.updateLocationView(false, + new LatLon(location.getLatitude(), location.getLongitude()), + heading != null ? heading : 0f, + arrowIv, + distanceTv, + marker.getLatitude(), + marker.getLongitude(), + DashLocationFragment.getScreenOrientation(mapActivity), + mapActivity.getMyApplication(), + mapActivity); + } else { + mark(View.GONE, arrowIv, distanceTv, dividerPoint); + } + } + }); + } + } + + private void mark(int visibility, View... views) { + for (View v : views) { + v.setVisibility(visibility); + } + } + + private void enterMenuMode() { + final MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + mapActivity.disableDrawer(); + mapActivity.getMapLayers().getMapControlsLayer().hideMapControls(); + OsmandMapTileView tileView = mapActivity.getMapView(); + previousMapPosition = tileView.getMapPosition(); + tileView.setMapPosition(portrait ? MIDDLE_TOP_CONSTANT : LANDSCAPE_MIDDLE_RIGHT_CONSTANT); + mapActivity.refreshMap(); + } + } + + private void exitMenuMode() { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + mapActivity.enableDrawer(); + mapActivity.getMapLayers().getMapControlsLayer().showMapControls(); + mapActivity.getMapView().setMapPosition(previousMapPosition); + mapActivity.refreshMap(); + } + } + + public void dismiss() { + MapActivity mapActivity = getMapActivity(); + if (mapActivity != null) { + mapActivity.getSupportFragmentManager().popBackStackImmediate(TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE); + } + } + + public static boolean showInstance(MapActivity mapActivity, @NonNull MapMarker marker) { + try { + MarkerMenuOnMapFragment fragment = new MarkerMenuOnMapFragment(); + fragment.setRetainInstance(true); + fragment.setMarker(marker); + mapActivity.getSupportFragmentManager().beginTransaction() + .replace(R.id.fragmentContainer, fragment, TAG) + .addToBackStack(TAG) + .commitAllowingStateLoss(); + return true; + } catch (Exception e) { + return false; + } + } +} diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java index 91a8c769d7..8da8580f2f 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/OptionsBottomSheetDialogFragment.java @@ -79,7 +79,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment ((ImageView) mainView.findViewById(R.id.coordinate_input_icon)) .setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_longitude)); ((ImageView) mainView.findViewById(R.id.build_route_icon)) - .setImageDrawable(getContentIcon(R.drawable.map_directions)); + .setImageDrawable(getContentIcon(R.drawable.ic_action_gdirections_dark)); ((ImageView) mainView.findViewById(R.id.save_as_new_track_icon)) .setImageDrawable(getContentIcon(R.drawable.ic_action_polygom_dark)); ((ImageView) mainView.findViewById(R.id.move_all_to_history_icon)) @@ -179,7 +179,7 @@ public class OptionsBottomSheetDialogFragment extends BottomSheetDialogFragment if (!portrait) { if (screenHeight - statusBarHeight - mainView.getHeight() - >= AndroidUtils.dpToPx(getActivity(), 8)) { + >= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) { AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark); } else { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java index 6ee9925660..c2cee573e1 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/OrderByBottomSheetDialogFragment.java @@ -98,7 +98,7 @@ public class OrderByBottomSheetDialogFragment extends BottomSheetDialogFragment if (!portrait) { if (screenHeight - statusBarHeight - mainView.getHeight() - >= AndroidUtils.dpToPx(getActivity(), 8)) { + >= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) { AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark); } else { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java index b55066047c..1909b7c19b 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteFragment.java @@ -650,7 +650,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene if (mapActivity != null) { final ImageButton appModesBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button); appModesBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle); - appModesBtn.setImageDrawable(getActiveIcon(planRouteContext.getSnappedMode().getSmallIconDark())); + appModesBtn.setImageDrawable(getActiveIcon(planRouteContext.getSnappedMode().getMapIconId())); appModesBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java index 42e3ed58f0..02228c50fc 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/PlanRouteOptionsBottomSheetDialogFragment.java @@ -55,7 +55,7 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog ((TextView) mainView.findViewById(R.id.title)).setTextColor(ContextCompat.getColor(getActivity(), R.color.ctx_menu_info_text_dark)); } - ((ImageView) mainView.findViewById(R.id.navigate_icon)).setImageDrawable(getContentIcon(R.drawable.map_directions)); + ((ImageView) mainView.findViewById(R.id.navigate_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_gdirections_dark)); ((ImageView) mainView.findViewById(R.id.make_round_trip_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_trip_round)); ((ImageView) mainView.findViewById(R.id.door_to_door_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_door_to_door)); ((ImageView) mainView.findViewById(R.id.reverse_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_sort_reverse_order)); @@ -141,7 +141,7 @@ public class PlanRouteOptionsBottomSheetDialogFragment extends BottomSheetDialog } if (!portrait) { - if (screenHeight - statusBarHeight - mainView.getHeight() >= AndroidUtils.dpToPx(getActivity(), 8)) { + if (screenHeight - statusBarHeight - mainView.getHeight() >= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) { AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark); } else { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/RenameMarkerBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/RenameMarkerBottomSheetDialogFragment.java new file mode 100644 index 0000000000..886c38794e --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/RenameMarkerBottomSheetDialogFragment.java @@ -0,0 +1,165 @@ +package net.osmand.plus.mapmarkers; + +import android.app.Dialog; +import android.content.Context; +import android.os.Build; +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentManager; +import android.view.ContextThemeWrapper; +import android.view.Gravity; +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.view.inputmethod.InputMethodManager; +import android.widget.EditText; +import android.widget.LinearLayout; + +import net.osmand.AndroidUtils; +import net.osmand.plus.MapMarkersHelper.MapMarker; +import net.osmand.plus.OsmandTextFieldBoxes; +import net.osmand.plus.R; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.base.BottomSheetDialogFragment; +import net.osmand.plus.helpers.AndroidUiHelper; + +public class RenameMarkerBottomSheetDialogFragment extends BottomSheetDialogFragment { + + public final static String TAG = "RenameMarkerBottomSheetDialogFragment"; + + private MapMarker marker; + + public void setMarker(MapMarker marker) { + this.marker = marker; + } + + @Nullable + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + final MapActivity mapActivity = (MapActivity) getActivity(); + final boolean portrait = AndroidUiHelper.isOrientationPortrait(getActivity()); + final boolean nightMode = mapActivity.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_rename_marker_bottom_sheet_dialog, container); + + LinearLayout contentLayout = (LinearLayout) mainView.findViewById(R.id.content_linear_layout); + int layoutRes = Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH + ? R.layout.markers_track_name_text_field_box + : R.layout.markers_track_name_edit_text; + contentLayout.addView(getLayoutInflater().inflate(layoutRes, contentLayout, false), 1); + + if (portrait) { + AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark); + } + + final EditText nameEditText = (EditText) mainView.findViewById(R.id.name_edit_text); + nameEditText.setText(marker.getName(mapActivity)); + nameEditText.requestFocus(); + final InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_IMPLICIT_ONLY); + View textBox = mainView.findViewById(R.id.name_text_box); + if (textBox instanceof OsmandTextFieldBoxes) { + ((OsmandTextFieldBoxes) textBox).activate(true); + } + + mainView.findViewById(R.id.save_button).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String name = nameEditText.getText().toString(); + if (name.replaceAll("\\s", "").length() > 0) { + marker.setName(name); + mapActivity.getMyApplication().getMapMarkersHelper().updateMapMarker(marker, true); + FragmentManager fm = mapActivity.getSupportFragmentManager(); + Fragment fragment = fm.findFragmentByTag(MarkerMenuOnMapFragment.TAG); + if (fragment != null) { + ((MarkerMenuOnMapFragment) fragment).dismiss(); + } + dismiss(); + } else { + nameEditText.setError(getString(R.string.wrong_input)); + } + } + }); + + mainView.findViewById(R.id.close_button).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() { + + boolean dimensSet; + + @Override + public void onGlobalLayout() { + if (!dimensSet) { + final View scrollView = mainView.findViewById(R.id.rename_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, nightMode, + R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark); + } else { + AndroidUtils.setBackground(getActivity(), mainView, nightMode, + R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark); + } + } + dimensSet = true; + } + + final Window window = getDialog().getWindow(); + WindowManager.LayoutParams params = window.getAttributes(); + params.height = ViewGroup.LayoutParams.WRAP_CONTENT; + params.gravity = Gravity.BOTTOM; + window.setAttributes(params); + } + }); + + return mainView; + } + + @Override + public void onStart() { + super.onStart(); + if (!AndroidUiHelper.isOrientationPortrait(getActivity())) { + 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); + } + } + + @Override + public void onDestroyView() { + View view = getView(); + if (view != null) { + InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(view.getWindowToken(), 0); + } + Dialog dialog = getDialog(); + if (dialog != null && getRetainInstance()) { + dialog.setDismissMessage(null); + } + super.onDestroyView(); + } +} diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java index 284454f23e..a8cff6f07d 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/SaveAsTrackBottomSheetDialogFragment.java @@ -120,7 +120,7 @@ public class SaveAsTrackBottomSheetDialogFragment extends BottomSheetDialogFragm if (!portrait) { if (screenHeight - statusBarHeight - mainView.getHeight() - >= AndroidUtils.dpToPx(getActivity(), 8)) { + >= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) { AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark); } else { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java index dacf153f6c..a9530827fc 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/ShowDirectionBottomSheetDialogFragment.java @@ -161,7 +161,7 @@ public class ShowDirectionBottomSheetDialogFragment extends BottomSheetDialogFra if (!portrait) { if (screenHeight - statusBarHeight - mainView.getHeight() - >= AndroidUtils.dpToPx(getActivity(), 8)) { + >= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) { AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark); } else { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java index 2eb0bafd2f..06662c7c1c 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java @@ -12,9 +12,9 @@ import android.widget.TextView; import net.osmand.data.LatLon; import net.osmand.plus.IconsCache; +import net.osmand.plus.MapMarkersHelper.GroupHeader; import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarkersGroup; -import net.osmand.plus.MapMarkersHelper.GroupHeader; import net.osmand.plus.MapMarkersHelper.ShowHideHistoryButton; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; @@ -52,6 +52,12 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter showDirectionMarkers; private Snackbar snackbar; + private MapMarkersGroupsAdapterListener listener; + + public void setListener(MapMarkersGroupsAdapterListener listener) { + this.listener = listener; + } + public MapMarkersGroupsAdapter(MapActivity mapActivity) { this.mapActivity = mapActivity; app = mapActivity.getMyApplication(); @@ -151,7 +157,12 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter= AndroidUtils.dpToPx(getActivity(), 8)) { + >= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) { AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark); } else { diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java index b196f1410c..6588e9fd12 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/SelectedPointBottomSheetDialogFragment.java @@ -176,7 +176,7 @@ public class SelectedPointBottomSheetDialogFragment extends BottomSheetDialogFra if (!portrait) { if (screenHeight - statusBarHeight - mainView.getHeight() - >= AndroidUtils.dpToPx(getActivity(), 8)) { + >= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) { AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark); } else {