Merge pull request #4492 from osmandapp/sasha_pasha_branch

Sasha pasha branch
This commit is contained in:
Alexey 2017-09-29 16:03:37 +03:00 committed by GitHub
commit f1e07956d1
26 changed files with 1393 additions and 320 deletions

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:color="@color/map_widget_blue" android:state_pressed="true"/>
<item android:color="@color/bg_color_dark"/>
</selector>

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="@color/map_widget_blue" android:state_pressed="true"/>
<item android:drawable="@color/bg_color_light"/>
</selector>

View file

@ -51,33 +51,53 @@
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_weight="1"> android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/markers_distance_text_view"
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_marginLeft="@dimen/measurement_tool_text_margin"
android:layout_marginRight="@dimen/measurement_tool_text_margin_small"
android:layout_marginStart="@dimen/measurement_tool_text_margin"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="1.39 km,"/>
<TextView
android:id="@+id/markers_time_text_view"
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_list_text_size"
tools:text="~ 45 min."/>
</LinearLayout>
<TextView <TextView
android:id="@+id/markers_distance_text_view" android:id="@+id/markers_count_text_view"
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_text_margin_small"
android:layout_marginLeft="@dimen/measurement_tool_text_margin" android:layout_marginLeft="@dimen/measurement_tool_text_margin"
android:layout_marginRight="@dimen/measurement_tool_text_margin_small"
android:layout_marginStart="@dimen/measurement_tool_text_margin" android:layout_marginStart="@dimen/measurement_tool_text_margin"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="1.39 km,"/>
<TextView
android:id="@+id/markers_time_text_view"
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:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_sub_text_size"
tools:text="~ 45 min."/> tools:text="3 markers"/>
</LinearLayout> </LinearLayout>
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
@ -104,6 +124,7 @@
android:background="?attr/dashboard_divider"/> android:background="?attr/dashboard_divider"/>
<LinearLayout <LinearLayout
android:id="@+id/buttons_row"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="@dimen/measurement_tool_controls_height" android:layout_height="@dimen/measurement_tool_controls_height"
android:layout_weight="0.5"> android:layout_weight="0.5">

View file

@ -68,33 +68,39 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes <net.osmand.plus.OsmandTextFieldBoxes
android:id="@+id/latitude_box"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
app:labelText="@string/navigate_point_latitude">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText <studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:hint="50:00.0000"
android:id="@+id/latitude_edit_text" android:id="@+id/latitude_edit_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
</studio.carbonylgroup.textfieldboxes.TextFieldBoxes> </net.osmand.plus.OsmandTextFieldBoxes>
<View <View
android:layout_width="16dp" android:layout_width="16dp"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes <net.osmand.plus.OsmandTextFieldBoxes
android:id="@+id/longitude_box"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
app:labelText="@string/navigate_point_longitude">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText <studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:hint="50:00.0000"
android:id="@+id/longitude_edit_text" android:id="@+id/longitude_edit_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
</studio.carbonylgroup.textfieldboxes.TextFieldBoxes> </net.osmand.plus.OsmandTextFieldBoxes>
</LinearLayout> </LinearLayout>
@ -104,17 +110,24 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<studio.carbonylgroup.textfieldboxes.TextFieldBoxes <net.osmand.plus.OsmandTextFieldBoxes
android:id="@+id/name_box"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
app:labelText="@string/shared_string_name">
<studio.carbonylgroup.textfieldboxes.ExtendedEditText <studio.carbonylgroup.textfieldboxes.ExtendedEditText
android:hint="@string/access_hint_enter_name"
android:id="@+id/name_edit_text" android:id="@+id/name_edit_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
</studio.carbonylgroup.textfieldboxes.TextFieldBoxes> </net.osmand.plus.OsmandTextFieldBoxes>
<View
android:layout_width="16dp"
android:layout_height="match_parent"/>
<View <View
android:layout_width="0dp" android:layout_width="0dp"
@ -131,13 +144,14 @@
</LinearLayout> </LinearLayout>
<FrameLayout <LinearLayout
android:id="@+id/keyboard_layout"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<GridView <GridView
osmand:visibility="gone"
android:id="@+id/keyboard_grid_view" android:id="@+id/keyboard_grid_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -147,6 +161,47 @@
android:stretchMode="columnWidth" android:stretchMode="columnWidth"
android:numColumns="3"/> android:numColumns="3"/>
</FrameLayout> <View
android:id="@+id/keyboard_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:background="?attr/bg_color"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="56dp">
<ImageView
android:id="@+id/show_hide_keyboard_icon"
android:padding="@dimen/bottom_sheet_content_padding"
android:background="?attr/selectableItemBackground"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
osmand:src="@drawable/ic_action_arrow_down"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/>
<net.osmand.plus.widgets.TextViewEx
android:maxLines="1"
android:ellipsize="end"
android:id="@+id/add_marker"
android:textAllCaps="true"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="@color/keyboard_color"
osmand:typeface="@string/font_roboto_regular"
android:text="@string/shared_string_add"/>
</LinearLayout>
</LinearLayout>
</FrameLayout> </FrameLayout>

View file

@ -0,0 +1,73 @@
<?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_coordinate_input_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/coordinate_input_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/fast_coordinates_input"
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/fast_coordinates_input_descr"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/>
<include layout="@layout/marker_coordinate_formats"/>
</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_close"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout>

View file

@ -0,0 +1,120 @@
<?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_coordinate_input_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/coordinate_input_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/shared_string_options"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/>
<LinearLayout
android:id="@+id/use_system_keyboard_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height"
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">
<ImageView
android:layout_gravity="center_vertical"
android:id="@+id/use_system_keyboard_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_keyboard"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/use_system_keyboard"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/use_system_keyboard_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:background="@null"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<TextView
android:textColor="?android:textColorSecondary"
android:ellipsize="end"
android:maxLines="1"
android:textAllCaps="true"
android:paddingTop="@dimen/bottom_sheet_content_padding_small"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small"
android:paddingLeft="@dimen/bottom_sheet_content_padding"
android:paddingRight="@dimen/bottom_sheet_content_padding"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/coordinates_format"/>
<include layout="@layout/marker_coordinate_formats"/>
</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_close"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout>

View file

@ -111,6 +111,7 @@
android:background="?attr/dashboard_divider"/> android:background="?attr/dashboard_divider"/>
<LinearLayout <LinearLayout
android:visibility="gone"
android:id="@+id/coordinate_input_row" android:id="@+id/coordinate_input_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_list_item_height" android:layout_height="@dimen/bottom_sheet_list_item_height"

View file

@ -46,33 +46,53 @@
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_weight="1"> android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/markers_distance_text_view"
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_marginLeft="@dimen/measurement_tool_text_margin"
android:layout_marginRight="@dimen/measurement_tool_text_margin_small"
android:layout_marginStart="@dimen/measurement_tool_text_margin"
android:ellipsize="end"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="1.39 km,"/>
<TextView
android:id="@+id/markers_time_text_view"
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_list_text_size"
tools:text="~ 45 min."/>
</LinearLayout>
<TextView <TextView
android:id="@+id/markers_distance_text_view" android:id="@+id/markers_count_text_view"
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_text_margin_small"
android:layout_marginLeft="@dimen/measurement_tool_text_margin" android:layout_marginLeft="@dimen/measurement_tool_text_margin"
android:layout_marginRight="@dimen/measurement_tool_text_margin_small"
android:layout_marginStart="@dimen/measurement_tool_text_margin" android:layout_marginStart="@dimen/measurement_tool_text_margin"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="1.39 km,"/>
<TextView
android:id="@+id/markers_time_text_view"
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:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size" android:textSize="@dimen/default_sub_text_size"
tools:text="~ 45 min."/> tools:text="3 markers"/>
</LinearLayout> </LinearLayout>
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
@ -123,6 +143,7 @@
</FrameLayout> </FrameLayout>
<LinearLayout <LinearLayout
android:id="@+id/buttons_row"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/measurement_tool_controls_height"> android:layout_height="@dimen/measurement_tool_controls_height">

View file

@ -1,16 +1,19 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="56dp" android:layout_height="56dp"
android:background="?attr/bg_color"
android:orientation="vertical"> android:orientation="vertical">
<TextView <net.osmand.plus.widgets.TextViewEx
android:id="@+id/keyboard_item" android:id="@+id/keyboard_item"
android:textAllCaps="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center"
android:textColor="@color/keyboard_color"
osmand:typeface="@string/font_roboto_regular"
tools:text="3"/> tools:text="3"/>
</LinearLayout> </LinearLayout>

View file

@ -7,11 +7,21 @@
android:descendantFocusability="blocksDescendants" android:descendantFocusability="blocksDescendants"
android:orientation="vertical"> android:orientation="vertical">
<include <LinearLayout
android:id="@+id/top_divider" android:id="@+id/top_divider"
layout="@layout/list_item_divider" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"/> tools:visibility="visible">
<View
android:layout_width="match_parent"
android:layout_height="4dp"/>
<include layout="@layout/card_top_divider"/>
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/main_layout" android:id="@+id/main_layout"

View file

@ -0,0 +1,123 @@
<?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">
<LinearLayout
android:id="@+id/degrees_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/degrees_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_coordinates_latitude"/>
<TextView
android:id="@+id/degrees_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="DDD.DD"/>
<RadioButton
android:id="@+id/degrees_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</LinearLayout>
<LinearLayout
android:id="@+id/minutes_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/minutes_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_coordinates_latitude"/>
<TextView
android:id="@+id/minutes_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="DDD MM.MM"/>
<RadioButton
android:id="@+id/minutes_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</LinearLayout>
<LinearLayout
android:id="@+id/seconds_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/seconds_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_coordinates_latitude"/>
<TextView
android:id="@+id/seconds_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:maxLines="1"
android:textAppearance="@style/TextAppearance.ListItemTitle"
tools:text="DDD MM SS.SS"/>
<RadioButton
android:id="@+id/seconds_radio_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:focusable="false"/>
</LinearLayout>
</LinearLayout>

View file

@ -1,97 +0,0 @@
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/list_item_divider"/>
<LinearLayout
android:id="@+id/background_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatImageView
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_gravity="center_vertical"
android:scaleType="centerInside"
android:src="@drawable/map_pedestrian_location"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:minHeight="56dp"
android:orientation="vertical"
android:paddingBottom="12dp"
android:paddingTop="10dp">
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/my_location"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:ellipsize="end"
android:maxLines="2"
android:text="@string/add_location_as_first_point_descr"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginLeft="56dp"
android:layout_marginStart="56dp">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/use_location_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingEnd="@dimen/measurement_tool_text_button_padding_small"
android:paddingRight="@dimen/measurement_tool_text_button_padding_small"
android:text="@string/use_location"
android:textColor="?attr/color_dialog_buttons"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/do_not_use_location_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingLeft="@dimen/measurement_tool_text_button_padding_small"
android:paddingStart="@dimen/measurement_tool_text_button_padding_small"
android:text="@string/shared_string_do_not_use"
android:textColor="?attr/color_dialog_buttons"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -264,4 +264,6 @@
<color name="marker_circle_button_color_dark">#525e66</color> <color name="marker_circle_button_color_dark">#525e66</color>
<color name="keyboard_color">#545454</color>
</resources> </resources>

View file

@ -9,6 +9,11 @@
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="shared_string_markers">Markers</string>
<string name="coordinates_format">Coordinates format</string>
<string name="use_system_keyboard">Use system keyboard</string>
<string name="fast_coordinates_input_descr">Choose coordinate format before start. You can always change it by tapping Options.</string>
<string name="fast_coordinates_input">Fast Coordinates input</string>
<string name="routing_attr_avoid_ice_roads_fords_name">Avoid ice roads, fords</string> <string name="routing_attr_avoid_ice_roads_fords_name">Avoid ice roads, fords</string>
<string name="routing_attr_avoid_ice_roads_fords_description">Avoid ice roads and fords</string> <string name="routing_attr_avoid_ice_roads_fords_description">Avoid ice roads and fords</string>
<string name="use_location">Use location</string> <string name="use_location">Use location</string>

View file

@ -0,0 +1,88 @@
package net.osmand.plus;
import android.content.Context;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import studio.carbonylgroup.textfieldboxes.TextFieldBoxes;
public class OsmandTextFieldBoxes extends TextFieldBoxes {
private boolean useOsmandKeyboard;
public void setUseOsmandKeyboard(boolean useOsmandKeyboard) {
this.useOsmandKeyboard = useOsmandKeyboard;
}
public OsmandTextFieldBoxes(Context context) {
super(context);
}
public OsmandTextFieldBoxes(Context context, AttributeSet attrs) {
super(context, attrs);
}
public OsmandTextFieldBoxes(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
if (editText != null) {
this.panel.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if(!OsmandTextFieldBoxes.this.isActivated()) {
OsmandTextFieldBoxes.this.activate(true);
}
OsmandTextFieldBoxes.this.setHasFocus(true);
if (!useOsmandKeyboard) {
OsmandTextFieldBoxes.this.inputMethodManager.showSoftInput(OsmandTextFieldBoxes.this.editText, InputMethodManager.SHOW_IMPLICIT);
}
}
});
this.iconImageButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
select();
}
});
}
}
public void select() {
if(!OsmandTextFieldBoxes.this.isActivated()) {
OsmandTextFieldBoxes.this.activate(true);
}
OsmandTextFieldBoxes.this.setHasFocus(true);
if (!useOsmandKeyboard) {
OsmandTextFieldBoxes.this.inputMethodManager.showSoftInput(OsmandTextFieldBoxes.this.editText, InputMethodManager.SHOW_IMPLICIT);
}
}
@Override
public void activate(boolean animated) {
super.activate(animated);
}
@Override
protected void deactivate() {
if(this.editText.getText().toString().isEmpty()) {
ViewCompat.animate(this.floatingLabel).alpha(1.0F).scaleX(1.0F).scaleY(1.0F).translationY(0.0F).setDuration((long)this.ANIMATION_DURATION);
this.editTextLayout.setVisibility(View.INVISIBLE);
if(this.editText.hasFocus()) {
if (!useOsmandKeyboard) {
this.inputMethodManager.hideSoftInputFromWindow(this.editText.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);
}
this.editText.clearFocus();
}
}
this.activated = false;
}
}

View file

@ -0,0 +1,261 @@
package net.osmand.plus.mapmarkers;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.SwitchCompat;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.data.PointDescription;
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 CoordinateInputBottomSheetDialogFragment extends BottomSheetDialogFragment {
public final static String TAG = "CoordinateInputBottomSheetDialogFragment";
private boolean portrait;
private View mainView;
private boolean night;
private int coordinateFormat = -1;
private boolean useOsmandKeyboard = true;
private CoordinateInputFormatChangeListener listener;
private boolean shouldClose;
public void setListener(CoordinateInputFormatChangeListener listener) {
this.listener = listener;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle args = getArguments();
if (args != null) {
coordinateFormat = args.getInt(CoordinateInputDialogFragment.COORDINATE_FORMAT);
useOsmandKeyboard = args.getBoolean(CoordinateInputDialogFragment.USE_OSMAND_KEYBOARD);
} else {
shouldClose = true;
}
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final MapActivity mapActivity = (MapActivity) getActivity();
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
night = !mapActivity.getMyApplication().getSettings().isLightContent();
final int themeRes = night ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), coordinateFormat == -1 ?
R.layout.fragment_marker_coordinate_input_bottom_sheet_dialog : R.layout.fragment_marker_coordinate_input_options_bottom_sheet_helper, container);
if (portrait) {
AndroidUtils.setBackground(getActivity(), mainView, night, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
}
if (night) {
((TextView) mainView.findViewById(R.id.coordinate_input_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
}
ImageView degreesIcon = (ImageView) mainView.findViewById(R.id.degrees_icon);
TextView degreesText = (TextView) mainView.findViewById(R.id.degrees_text);
if (coordinateFormat == PointDescription.FORMAT_DEGREES) {
degreesIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
degreesText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue));
((RadioButton) mainView.findViewById(R.id.degrees_radio_button)).setChecked(true);
} else {
degreesIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
}
degreesText.setText(PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_DEGREES));
ImageView minutesIcon = (ImageView) mainView.findViewById(R.id.minutes_icon);
TextView minutesText = (TextView) mainView.findViewById(R.id.minutes_text);
if (coordinateFormat == PointDescription.FORMAT_MINUTES) {
minutesIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
minutesText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue));
((RadioButton) mainView.findViewById(R.id.minutes_radio_button)).setChecked(true);
} else {
minutesIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
}
minutesText.setText(PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_MINUTES));
ImageView secondsIcon = (ImageView) mainView.findViewById(R.id.seconds_icon);
TextView secondsText = (TextView) mainView.findViewById(R.id.seconds_text);
if (coordinateFormat == PointDescription.FORMAT_SECONDS) {
secondsIcon.setImageDrawable(getIcon(R.drawable.ic_action_coordinates_latitude, R.color.dashboard_blue));
secondsText.setTextColor(ContextCompat.getColor(mapActivity, R.color.dashboard_blue));
((RadioButton) mainView.findViewById(R.id.seconds_radio_button)).setChecked(true);
} else {
secondsIcon.setImageDrawable(getContentIcon(R.drawable.ic_action_coordinates_latitude));
}
secondsText.setText(PointDescription.formatToHumanString(getContext(), PointDescription.FORMAT_SECONDS));
if (coordinateFormat != -1) {
((CompoundButton) mainView.findViewById(R.id.use_system_keyboard_switch)).setChecked(!useOsmandKeyboard);
((ImageView) mainView.findViewById(R.id.use_system_keyboard_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_keyboard));
mainView.findViewById(R.id.use_system_keyboard_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
useOsmandKeyboard = !useOsmandKeyboard;
((CompoundButton) mainView.findViewById(R.id.use_system_keyboard_switch)).setChecked(!useOsmandKeyboard);
if (listener != null) {
listener.onKeyboardChanged(useOsmandKeyboard);
}
}
});
highlightSelectedItem(true);
}
View.OnClickListener formatChangeListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
highlightSelectedItem(false);
switch (view.getId()) {
case R.id.degrees_row:
coordinateFormat = PointDescription.FORMAT_DEGREES;
break;
case R.id.minutes_row:
coordinateFormat = PointDescription.FORMAT_MINUTES;
break;
case R.id.seconds_row:
coordinateFormat = PointDescription.FORMAT_SECONDS;
break;
default:
throw new IllegalArgumentException("Unsupported format");
}
highlightSelectedItem(true);
if (listener != null) {
listener.onCoordinateFormatChanged(coordinateFormat);
}
if (shouldClose) {
dismiss();
}
}
};
mainView.findViewById(R.id.degrees_row).setOnClickListener(formatChangeListener);
mainView.findViewById(R.id.minutes_row).setOnClickListener(formatChangeListener);
mainView.findViewById(R.id.seconds_row).setOnClickListener(formatChangeListener);
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
if (shouldClose && listener != null) {
listener.onCancel();
}
}
});
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_coordinate_input_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);
}
}
@Override
public void onCancel(DialogInterface dialog) {
super.onCancel(dialog);
if (shouldClose && listener != null) {
listener.onCancel();
}
}
@Override
protected Drawable getContentIcon(@DrawableRes int id) {
return getIcon(id, night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
}
private void highlightSelectedItem(boolean check) {
int iconColor = check ? R.color.dashboard_blue : night ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color;
int textColor = ContextCompat.getColor(getContext(), check ? (night ? R.color.color_dialog_buttons_dark : R.color.dashboard_blue) : night ? R.color.color_white : R.color.color_black);
switch (coordinateFormat) {
case PointDescription.FORMAT_DEGREES:
((TextView) mainView.findViewById(R.id.degrees_text)).setTextColor(textColor);
((ImageView) mainView.findViewById(R.id.degrees_icon)).setImageDrawable((getIcon(R.drawable.ic_action_coordinates_latitude, iconColor)));
((RadioButton) mainView.findViewById(R.id.degrees_radio_button)).setChecked(check);
break;
case PointDescription.FORMAT_MINUTES:
((TextView) mainView.findViewById(R.id.minutes_text)).setTextColor(textColor);
((ImageView) mainView.findViewById(R.id.minutes_icon)).setImageDrawable((getIcon(R.drawable.ic_action_coordinates_latitude, iconColor)));
((RadioButton) mainView.findViewById(R.id.minutes_radio_button)).setChecked(check);
break;
case PointDescription.FORMAT_SECONDS:
((TextView) mainView.findViewById(R.id.seconds_text)).setTextColor(textColor);
((ImageView) mainView.findViewById(R.id.seconds_icon)).setImageDrawable((getIcon(R.drawable.ic_action_coordinates_latitude, iconColor)));
((RadioButton) mainView.findViewById(R.id.seconds_radio_button)).setChecked(check);
break;
}
}
interface CoordinateInputFormatChangeListener {
void onCoordinateFormatChanged(int format);
void onKeyboardChanged(boolean useOsmandKeyboard);
void onCancel();
}
}

View file

@ -5,29 +5,56 @@ 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.v4.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.support.v4.content.ContextCompat; import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.InputFilter;
import android.text.InputType; import android.text.InputType;
import android.text.TextWatcher;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.WindowManager; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.EditText; import android.widget.EditText;
import android.widget.GridView; import android.widget.GridView;
import android.widget.TextView; import android.widget.ImageView;
import net.osmand.AndroidUtils;
import net.osmand.data.PointDescription;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandTextFieldBoxes;
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.widgets.TextViewEx;
import java.util.ArrayList;
import java.util.List;
import studio.carbonylgroup.textfieldboxes.ExtendedEditText;
public class CoordinateInputDialogFragment extends DialogFragment { public class CoordinateInputDialogFragment extends DialogFragment {
public static final String TAG = "CoordinateInputDialogFragment"; public static final String TAG = "CoordinateInputDialogFragment";
public static final String COORDINATE_FORMAT = "coordinate_format";
public static final String USE_OSMAND_KEYBOARD = "use_osmand_keyboard";
private static final int DELETE_BUTTON_POSITION = 9;
private static final int CLEAR_BUTTON_POSITION = 11;
private static final int DEGREES_MAX_LENGTH = 6;
private static final int MINUTES_MAX_LENGTH = 9;
private static final int SECONDS_MAX_LENGTH = 12;
private boolean lightTheme; private boolean lightTheme;
private EditText focusedEditText;
private boolean useOsmandKeyboard = true;
private int coordinateFormat = -1;
private List<OsmandTextFieldBoxes> textFieldBoxes;
private ExtendedEditText nameEditText;
private List<ExtendedEditText> extendedLatLonEditTexts;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
@ -36,6 +63,10 @@ public class CoordinateInputDialogFragment extends DialogFragment {
lightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME; lightTheme = app.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
int themeId = lightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme; int themeId = lightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
setStyle(STYLE_NO_FRAME, themeId); setStyle(STYLE_NO_FRAME, themeId);
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
fragment.setListener(createCoordinateInputFormatChangeListener());
fragment.show(getMapActivity().getSupportFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG);
} }
@Nullable @Nullable
@ -43,11 +74,14 @@ public class CoordinateInputDialogFragment extends DialogFragment {
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View mainView = inflater.inflate(R.layout.fragment_coordinate_input_dialog, container); final View mainView = inflater.inflate(R.layout.fragment_coordinate_input_dialog, container);
final MapActivity mapActivity = getMapActivity(); final MapActivity mapActivity = getMapActivity();
final IconsCache ic = getMyApplication().getIconsCache();
Fragment coordinateInputBottomSheetDialogFragment = mapActivity.getSupportFragmentManager().findFragmentByTag(CoordinateInputBottomSheetDialogFragment.TAG);
if (coordinateInputBottomSheetDialogFragment != null) {
((CoordinateInputBottomSheetDialogFragment) coordinateInputBottomSheetDialogFragment).setListener(createCoordinateInputFormatChangeListener());
}
Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.coordinate_input_toolbar); Toolbar toolbar = (Toolbar) mainView.findViewById(R.id.coordinate_input_toolbar);
if (!lightTheme) {
toolbar.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.actionbar_dark_color));
}
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back)); toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back));
toolbar.setNavigationOnClickListener(new View.OnClickListener() { toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@ -60,51 +94,238 @@ public class CoordinateInputDialogFragment extends DialogFragment {
optionsButton.setOnClickListener(new View.OnClickListener() { optionsButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment();
Bundle args = new Bundle();
args.putInt(COORDINATE_FORMAT, coordinateFormat);
args.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard);
fragment.setArguments(args);
fragment.setListener(createCoordinateInputFormatChangeListener());
fragment.show(getMapActivity().getSupportFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG);
} }
}); });
final EditText latitudeEditText = (EditText) mainView.findViewById(R.id.latitude_edit_text); textFieldBoxes = new ArrayList<>();
final EditText longitudeEditText = (EditText) mainView.findViewById(R.id.longitude_edit_text); final OsmandTextFieldBoxes latitudeBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.latitude_box);
final EditText nameEditText = (EditText) mainView.findViewById(R.id.name_edit_text); textFieldBoxes.add(latitudeBox);
final OsmandTextFieldBoxes longitudeBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.longitude_box);
textFieldBoxes.add(longitudeBox);
final OsmandTextFieldBoxes nameBox = (OsmandTextFieldBoxes) mainView.findViewById(R.id.name_box);
textFieldBoxes.add(nameBox);
View.OnTouchListener editTextOnTouchListener = new View.OnTouchListener() { extendedLatLonEditTexts = new ArrayList<>();
final ExtendedEditText latitudeEditText = (ExtendedEditText) mainView.findViewById(R.id.latitude_edit_text);
extendedLatLonEditTexts.add(latitudeEditText);
final ExtendedEditText longitudeEditText = (ExtendedEditText) mainView.findViewById(R.id.longitude_edit_text);
extendedLatLonEditTexts.add(longitudeEditText);
nameEditText = (ExtendedEditText) mainView.findViewById(R.id.name_edit_text);
final View.OnFocusChangeListener focusChangeListener = new View.OnFocusChangeListener() {
@Override @Override
public boolean onTouch(View view, MotionEvent motionEvent) { public void onFocusChange(View view, boolean b) {
EditText editText = null; ExtendedEditText editText = null;
OsmandTextFieldBoxes fieldBox = null;
switch (view.getId()) { switch (view.getId()) {
case R.id.latitude_edit_text: case R.id.latitude_edit_text:
editText = latitudeEditText; editText = latitudeEditText;
fieldBox = latitudeBox;
break; break;
case R.id.longitude_edit_text: case R.id.longitude_edit_text:
editText = longitudeEditText; editText = longitudeEditText;
fieldBox = longitudeBox;
break; break;
case R.id.name_edit_text: case R.id.name_edit_text:
editText = nameEditText; editText = nameEditText;
fieldBox = nameBox;
break; break;
} }
if (editText != null) { if (fieldBox != null) {
editText.requestFocus(); if (b) {
fieldBox.setHasFocus(true);
focusedEditText = editText;
} else {
fieldBox.setHasFocus(false);
focusedEditText = null;
}
} }
return true;
} }
}; };
latitudeEditText.setOnTouchListener(editTextOnTouchListener); TextWatcher textWatcher = new TextWatcher() {
longitudeEditText.setOnTouchListener(editTextOnTouchListener); int len = 0;
nameEditText.setOnTouchListener(editTextOnTouchListener);
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (focusedEditText != null) {
String str = focusedEditText.getText().toString();
len = str.length();
}
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
if (focusedEditText != null && focusedEditText != nameEditText) {
String str = focusedEditText.getText().toString();
int strLength = str.length();
if (strLength == 2 && len < strLength) {
String strToAppend;
if (coordinateFormat == PointDescription.FORMAT_DEGREES) {
strToAppend = ".";
} else {
strToAppend = ":";
}
focusedEditText.append(strToAppend);
} else if (strLength == 5 && coordinateFormat != PointDescription.FORMAT_DEGREES && len < strLength) {
String strToAppend;
if (coordinateFormat == PointDescription.FORMAT_MINUTES) {
strToAppend = ".";
} else {
strToAppend = ":";
}
focusedEditText.append(strToAppend);
} else if (strLength == 8 && coordinateFormat == PointDescription.FORMAT_SECONDS && len < strLength) {
focusedEditText.append(".");
} else if ((strLength == DEGREES_MAX_LENGTH && coordinateFormat == PointDescription.FORMAT_DEGREES)
|| (strLength == MINUTES_MAX_LENGTH && coordinateFormat == PointDescription.FORMAT_MINUTES)
|| (strLength == SECONDS_MAX_LENGTH && coordinateFormat == PointDescription.FORMAT_SECONDS)) {
if (focusedEditText == latitudeEditText) {
longitudeBox.select();
} else {
nameBox.select();
}
}
}
}
};
latitudeEditText.setOnFocusChangeListener(focusChangeListener);
longitudeEditText.setOnFocusChangeListener(focusChangeListener);
nameEditText.setOnFocusChangeListener(focusChangeListener);
latitudeEditText.addTextChangedListener(textWatcher);
longitudeEditText.addTextChangedListener(textWatcher);
nameEditText.addTextChangedListener(textWatcher);
changeKeyboardInBoxes();
changeKeyboardInEditTexts();
View keyboardLayout = mainView.findViewById(R.id.keyboard_layout);
AndroidUtils.setBackground(mapActivity, keyboardLayout, !lightTheme, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
String[] keyboardItems = new String[] { "1", "2", "3", String[] keyboardItems = new String[] { "1", "2", "3",
"4", "5", "6", "4", "5", "6",
"7", "8", "9", "7", "8", "9",
getString(R.string.shared_string_delete), "0", getString(R.string.shared_string_clear) }; getString(R.string.shared_string_delete), "0", getString(R.string.shared_string_clear) };
GridView keyboardGrid = (GridView) mainView.findViewById(R.id.keyboard_grid_view); final GridView keyboardGrid = (GridView) mainView.findViewById(R.id.keyboard_grid_view);
KeyboardAdapter keyboardAdapter = new KeyboardAdapter(mapActivity, keyboardItems); final KeyboardAdapter keyboardAdapter = new KeyboardAdapter(mapActivity, keyboardItems);
keyboardGrid.setAdapter(keyboardAdapter); keyboardGrid.setAdapter(keyboardAdapter);
keyboardGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
if (focusedEditText != null) {
switch (i) {
case DELETE_BUTTON_POSITION:
String str = focusedEditText.getText().toString();
if (str.length() > 0) {
str = str.substring(0, str.length() - 1);
focusedEditText.setText(str);
}
break;
case CLEAR_BUTTON_POSITION:
focusedEditText.setText("");
break;
default:
focusedEditText.append(keyboardAdapter.getItem(i));
}
}
}
});
final ImageView showHideKeyBoardIcon = (ImageView) mainView.findViewById(R.id.show_hide_keyboard_icon);
final View keyboardDivider = mainView.findViewById(R.id.keyboard_divider);
showHideKeyBoardIcon.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_arrow_down));
showHideKeyBoardIcon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int keyboardVisibility = keyboardGrid.getVisibility();
if (keyboardVisibility == View.VISIBLE) {
keyboardGrid.setVisibility(View.GONE);
keyboardDivider.setVisibility(View.GONE);
showHideKeyBoardIcon.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_arrow_up));
} else {
keyboardGrid.setVisibility(View.VISIBLE);
keyboardDivider.setVisibility(View.VISIBLE);
showHideKeyBoardIcon.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_arrow_down));
}
}
});
return mainView; return mainView;
} }
@Override
public void onDestroyView() {
focusedEditText = null;
if (getDialog() != null && getRetainInstance()) {
getDialog().setDismissMessage(null);
}
super.onDestroyView();
}
private CoordinateInputBottomSheetDialogFragment.CoordinateInputFormatChangeListener createCoordinateInputFormatChangeListener() {
return new CoordinateInputBottomSheetDialogFragment.CoordinateInputFormatChangeListener() {
@Override
public void onCoordinateFormatChanged(int format) {
coordinateFormat = format;
changeEditTextLengths();
}
@Override
public void onKeyboardChanged(boolean useOsmandKeyboard) {
CoordinateInputDialogFragment.this.useOsmandKeyboard = useOsmandKeyboard;
changeKeyboardInBoxes();
changeKeyboardInEditTexts();
}
@Override
public void onCancel() {
dismiss();
}
};
}
private void changeEditTextLengths() {
int maxLength;
if (coordinateFormat == PointDescription.FORMAT_DEGREES) {
maxLength = DEGREES_MAX_LENGTH;
} else if (coordinateFormat == PointDescription.FORMAT_MINUTES) {
maxLength = MINUTES_MAX_LENGTH;
} else {
maxLength = SECONDS_MAX_LENGTH;
}
InputFilter[] filtersArray = new InputFilter[] {new InputFilter.LengthFilter(maxLength)};
for (ExtendedEditText extendedEditText : extendedLatLonEditTexts) {
extendedEditText.setFilters(filtersArray);
}
}
public void changeKeyboardInBoxes() {
for (OsmandTextFieldBoxes textFieldBox : textFieldBoxes) {
textFieldBox.setUseOsmandKeyboard(useOsmandKeyboard);
}
}
public void changeKeyboardInEditTexts() {
for (ExtendedEditText extendedEditText : extendedLatLonEditTexts) {
extendedEditText.setInputType(useOsmandKeyboard ? InputType.TYPE_NULL : InputType.TYPE_CLASS_TEXT);
}
nameEditText.setInputType(useOsmandKeyboard ? InputType.TYPE_NULL : InputType.TYPE_CLASS_TEXT);
}
private MapActivity getMapActivity() { private MapActivity getMapActivity() {
return (MapActivity) getActivity(); return (MapActivity) getActivity();
} }
@ -119,6 +340,7 @@ public class CoordinateInputDialogFragment extends DialogFragment {
return false; return false;
} }
CoordinateInputDialogFragment fragment = new CoordinateInputDialogFragment(); CoordinateInputDialogFragment fragment = new CoordinateInputDialogFragment();
fragment.setRetainInstance(true);
fragment.show(mapActivity.getSupportFragmentManager(), TAG); fragment.show(mapActivity.getSupportFragmentManager(), TAG);
return true; return true;
} catch (RuntimeException e) { } catch (RuntimeException e) {
@ -128,8 +350,8 @@ public class CoordinateInputDialogFragment extends DialogFragment {
private class KeyboardAdapter extends ArrayAdapter<String> { private class KeyboardAdapter extends ArrayAdapter<String> {
KeyboardAdapter(@NonNull Context context, String[] items) { KeyboardAdapter(@NonNull Context context, @NonNull String[] objects) {
super(context, 0, items); super(context, 0, objects);
} }
@NonNull @NonNull
@ -138,8 +360,16 @@ public class CoordinateInputDialogFragment extends DialogFragment {
if (convertView == null) { if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.input_coordinate_keyboard_item, parent, false); convertView = LayoutInflater.from(getContext()).inflate(R.layout.input_coordinate_keyboard_item, parent, false);
} }
convertView.setBackgroundResource(lightTheme ? R.drawable.keyboard_item_light_bg : R.drawable.keyboard_item_dark_bg);
((TextView) convertView.findViewById(R.id.keyboard_item)).setText(getItem(position)); TextViewEx keyboardItem = (TextViewEx) convertView.findViewById(R.id.keyboard_item);
// if (position == DELETE_BUTTON_POSITION || position == CLEAR_BUTTON_POSITION) {
// keyboardItem.setTextSize(getResources().getDimension(R.dimen.default_list_text_size));
// } else {
// keyboardItem.setTextSize(getResources().getDimension(R.dimen.map_button_text_size));
// }
keyboardItem.setText(getItem(position));
return convertView; return convertView;
} }

View file

@ -1,6 +1,7 @@
package net.osmand.plus.mapmarkers; package net.osmand.plus.mapmarkers;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -14,6 +15,7 @@ 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;
import android.view.ViewTreeObserver;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -22,11 +24,14 @@ import android.widget.Toast;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
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.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
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.base.MapViewTrackingUtilities; import net.osmand.plus.base.MapViewTrackingUtilities;
@ -40,9 +45,11 @@ import net.osmand.plus.views.MapMarkersLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
import net.osmand.util.MapUtils;
import java.util.List;
import static net.osmand.plus.OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT; import static net.osmand.plus.OsmandSettings.LANDSCAPE_MIDDLE_RIGHT_CONSTANT;
import static net.osmand.plus.OsmandSettings.MIDDLE_TOP_CONSTANT;
public class PlanRouteFragment extends Fragment implements OsmAndLocationListener { public class PlanRouteFragment extends Fragment implements OsmAndLocationListener {
@ -56,6 +63,8 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
private int previousMapPosition; private int previousMapPosition;
private int selectedCount = 0; private int selectedCount = 0;
private int toolbarHeight;
private Location location; private Location location;
private boolean locationUpdateStarted; private boolean locationUpdateStarted;
@ -69,6 +78,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
private ImageView upDownIconIv; private ImageView upDownIconIv;
private TextView distanceTv; private TextView distanceTv;
private TextView timeTv; private TextView timeTv;
private TextView countTv;
@Nullable @Nullable
@Override @Override
@ -88,6 +98,8 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
hideMarkersListFragment(); hideMarkersListFragment();
} }
toolbarHeight = mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar);
iconsCache = mapActivity.getMyApplication().getIconsCache(); iconsCache = mapActivity.getMyApplication().getIconsCache();
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls(); nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme; final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
@ -102,6 +114,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
distanceTv = (TextView) mainView.findViewById(R.id.markers_distance_text_view); distanceTv = (TextView) mainView.findViewById(R.id.markers_distance_text_view);
timeTv = (TextView) mainView.findViewById(R.id.markers_time_text_view); timeTv = (TextView) mainView.findViewById(R.id.markers_time_text_view);
countTv = (TextView) mainView.findViewById(R.id.markers_count_text_view);
enterPlanRouteMode(); enterPlanRouteMode();
@ -129,15 +142,20 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
@Override @Override
public void onClick(View view) { public void onClick(View view) {
int activeMarkersCount = markersHelper.getMapMarkers().size(); int activeMarkersCount = markersHelper.getMapMarkers().size();
if (selectedCount == activeMarkersCount) { if (selectedCount == activeMarkersCount && markersHelper.isStartFromMyLocation()) {
markersHelper.deselectAllActiveMarkers(); markersHelper.deselectAllActiveMarkers();
markersHelper.setStartFromMyLocation(false);
selectedCount = 0; selectedCount = 0;
} else { } else {
markersHelper.selectAllActiveMarkers(); markersHelper.selectAllActiveMarkers();
markersHelper.setStartFromMyLocation(true);
selectedCount = activeMarkersCount; selectedCount = activeMarkersCount;
} }
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
updateText();
updateSelectButton(); updateSelectButton();
showMarkersRouteOnMap();
mapActivity.refreshMap();
} }
}); });
@ -161,7 +179,9 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
toolbarController.setOnBackButtonClickListener(new View.OnClickListener() { toolbarController.setOnBackButtonClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
quit(false); if (quit(false)) {
MapMarkersDialogFragment.showInstance(mapActivity);
}
} }
}); });
mapActivity.showTopToolbar(toolbarController); mapActivity.showTopToolbar(toolbarController);
@ -183,11 +203,17 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
@Override @Override
public void onItemClick(View view) { public void onItemClick(View view) {
int pos = markersRv.getChildAdapterPosition(view); int pos = markersRv.getChildAdapterPosition(view);
MapMarker marker = adapter.getItem(pos); if (pos == 0) {
selectedCount = marker.selected ? selectedCount - 1 : selectedCount + 1; markersHelper.setStartFromMyLocation(!mapActivity.getMyApplication().getSettings().ROUTE_MAP_MARKERS_START_MY_LOC.get());
marker.selected = !marker.selected; } else {
MapMarker marker = adapter.getItem(pos);
selectedCount = marker.selected ? selectedCount - 1 : selectedCount + 1;
marker.selected = !marker.selected;
}
adapter.notifyItemChanged(pos); adapter.notifyItemChanged(pos);
updateSelectButton(); updateSelectButton();
updateText();
showMarkersRouteOnMap();
} }
@Override @Override
@ -201,7 +227,14 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
toPosition = holder.getAdapterPosition(); toPosition = holder.getAdapterPosition();
if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) { if (toPosition >= 0 && fromPosition >= 0 && toPosition != fromPosition) {
mapActivity.getMyApplication().getMapMarkersHelper().checkAndFixActiveMarkersOrderIfNeeded(); mapActivity.getMyApplication().getMapMarkersHelper().checkAndFixActiveMarkersOrderIfNeeded();
adapter.notifyDataSetChanged(); mapActivity.getMyApplication().getSettings().MAP_MARKERS_ORDER_BY_MODE.set(OsmandSettings.MapMarkersOrderByMode.CUSTOM);
mapActivity.refreshMap();
try {
adapter.notifyDataSetChanged();
} catch (Exception e) {
// to avoid crash because of:
// java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling
}
} }
} }
}); });
@ -211,6 +244,34 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
markersRv.setLayoutManager(new LinearLayoutManager(getContext())); markersRv.setLayoutManager(new LinearLayoutManager(getContext()));
markersRv.setAdapter(adapter); markersRv.setAdapter(adapter);
final int screenH = AndroidUtils.getScreenHeight(mapActivity);
final int statusBarH = AndroidUtils.getStatusBarHeight(mapActivity);
final int navBarH = AndroidUtils.getNavBarHeight(mapActivity);
final int availableHeight = (screenH - statusBarH - navBarH) / 2;
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (portrait) {
int upDownRowH = mainView.findViewById(R.id.up_down_row).getHeight();
int buttonsRowH = mainView.findViewById(R.id.buttons_row).getHeight();
int listContainerH = availableHeight - upDownRowH - buttonsRowH;
View listContainer = mainView.findViewById(R.id.markers_list_container);
listContainer.getLayoutParams().height = listContainerH;
listContainer.requestLayout();
}
showMarkersList();
ViewTreeObserver obs = mainView.getViewTreeObserver();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
obs.removeOnGlobalLayoutListener(this);
} else {
obs.removeGlobalOnLayoutListener(this);
}
}
});
return view; return view;
} }
@ -278,6 +339,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
public void onApplicationModeItemClick(ApplicationMode mode) { public void onApplicationModeItemClick(ApplicationMode mode) {
appMode = mode; appMode = mode;
setupAppModesBtn(); setupAppModesBtn();
updateText();
} }
}; };
} }
@ -310,10 +372,11 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
} }
if (appMode == null) { if (appMode == null) {
appMode = mapActivity.getMyApplication().getSettings().getApplicationMode(); appMode = ApplicationMode.DEFAULT;
} }
setupAppModesBtn(); setupAppModesBtn();
showMarkersRouteOnMap();
mapActivity.refreshMap(); mapActivity.refreshMap();
updateText(); updateText();
updateSelectButton(); updateSelectButton();
@ -331,6 +394,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
public void onClick(View view) { public void onClick(View view) {
SnapToRoadBottomSheetDialogFragment fragment = new SnapToRoadBottomSheetDialogFragment(); SnapToRoadBottomSheetDialogFragment fragment = new SnapToRoadBottomSheetDialogFragment();
fragment.setListener(createSnapToRoadFragmentListener()); fragment.setListener(createSnapToRoadFragmentListener());
fragment.setRemoveDefaultMode(false);
fragment.show(mapActivity.getSupportFragmentManager(), SnapToRoadBottomSheetDialogFragment.TAG); fragment.show(mapActivity.getSupportFragmentManager(), SnapToRoadBottomSheetDialogFragment.TAG);
} }
}); });
@ -367,24 +431,50 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
mapActivity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.GONE); mapActivity.findViewById(R.id.snap_to_road_image_button).setVisibility(View.GONE);
mainView.findViewById(R.id.snap_to_road_progress_bar).setVisibility(View.GONE); mainView.findViewById(R.id.snap_to_road_progress_bar).setVisibility(View.GONE);
markersLayer.clearRoute();
mapActivity.refreshMap(); mapActivity.refreshMap();
} }
} }
private void updateText() { private void updateText() {
distanceTv.setText("1.39 km,"); MapActivity mapActivity = getMapActivity();
timeTv.setText("~ 45 min."); if (mapActivity != null) {
boolean defaultMode = appMode.getStringKey().equals(ApplicationMode.DEFAULT.getStringKey());
float dist = 0;
Location myLoc = mapActivity.getMyApplication().getLocationProvider().getLastStaleKnownLocation();
boolean useLocation = myLoc != null && mapActivity.getMyApplication().getSettings().ROUTE_MAP_MARKERS_START_MY_LOC.get();
List<LatLon> markers = markersHelper.getSelectedMarkersLatLon();
if (useLocation ? markers.size() > 0 : markers.size() > 1) {
if (useLocation) {
dist += MapUtils.getDistance(myLoc.getLatitude(), myLoc.getLongitude(),
markers.get(0).getLatitude(), markers.get(0).getLongitude());
}
for (int i = 1; i < markers.size(); i++) {
dist += MapUtils.getDistance(markers.get(i - 1), markers.get(i));
}
}
distanceTv.setText(OsmAndFormatter.getFormattedDistance(dist, mapActivity.getMyApplication()) + (defaultMode ? "" : ","));
if (defaultMode) {
timeTv.setText("");
} else {
int seconds = (int) (dist / appMode.getDefaultSpeed());
timeTv.setText("~ " + OsmAndFormatter.getFormattedDuration(seconds, mapActivity.getMyApplication()));
}
countTv.setText(mapActivity.getString(R.string.shared_string_markers) + ": " + selectedCount);
}
} }
private void updateSelectButton() { private void updateSelectButton() {
if (selectedCount == markersHelper.getMapMarkers().size()) { if (selectedCount == markersHelper.getMapMarkers().size() && markersHelper.isStartFromMyLocation()) {
((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_deselect_all)); ((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_deselect_all));
} else { } else {
((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_select_all)); ((TextView) mainView.findViewById(R.id.select_all_button)).setText(getString(R.string.shared_string_select_all));
} }
} }
private void updateLocationUi() { private void updateLocationUi() {
final MapActivity mapActivity = (MapActivity) getActivity(); final MapActivity mapActivity = (MapActivity) getActivity();
if (mapActivity != null && adapter != null) { if (mapActivity != null && adapter != null) {
@ -422,7 +512,6 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
MapMarkersLayer markersLayer = getMapMarkersLayer(); MapMarkersLayer markersLayer = getMapMarkersLayer();
if (mapActivity != null && markersLayer != null) { if (mapActivity != null && markersLayer != null) {
markersListOpened = true; markersListOpened = true;
markersLayer.setMarkersListOpened(true);
upDownIconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_down)); upDownIconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_down));
View listContainer = mainView.findViewById(R.id.markers_list_container); View listContainer = mainView.findViewById(R.id.markers_list_container);
if (portrait && listContainer != null) { if (portrait && listContainer != null) {
@ -432,9 +521,7 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
} }
OsmandMapTileView tileView = mapActivity.getMapView(); OsmandMapTileView tileView = mapActivity.getMapView();
previousMapPosition = tileView.getMapPosition(); previousMapPosition = tileView.getMapPosition();
if (portrait) { if (!portrait) {
tileView.setMapPosition(MIDDLE_TOP_CONSTANT);
} else {
tileView.setMapPosition(LANDSCAPE_MIDDLE_RIGHT_CONSTANT); tileView.setMapPosition(LANDSCAPE_MIDDLE_RIGHT_CONSTANT);
} }
mapActivity.refreshMap(); mapActivity.refreshMap();
@ -446,7 +533,6 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
MapMarkersLayer markersLayer = getMapMarkersLayer(); MapMarkersLayer markersLayer = getMapMarkersLayer();
if (mapActivity != null && markersLayer != null) { if (mapActivity != null && markersLayer != null) {
markersListOpened = false; markersListOpened = false;
markersLayer.setMarkersListOpened(false);
upDownIconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_up)); upDownIconIv.setImageDrawable(getContentIcon(R.drawable.ic_action_arrow_up));
View listContainer = mainView.findViewById(R.id.markers_list_container); View listContainer = mainView.findViewById(R.id.markers_list_container);
if (portrait && listContainer != null) { if (portrait && listContainer != null) {
@ -506,6 +592,55 @@ public class PlanRouteFragment extends Fragment implements OsmAndLocationListene
} }
} }
private void showMarkersRouteOnMap() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
List<LatLon> points = markersHelper.getSelectedMarkersLatLon();
mapActivity.getMapLayers().getMapMarkersLayer().setRoute(points);
showRouteOnMap(points);
}
}
private void showRouteOnMap(List<LatLon> points) {
MapActivity mapActivity = getMapActivity();
if (points.size() > 0 && mapActivity != null) {
OsmandMapTileView mapView = mapActivity.getMapView();
double left = 0, right = 0;
double top = 0, bottom = 0;
Location myLocation = mapActivity.getMyApplication().getLocationProvider().getLastStaleKnownLocation();
if (mapActivity.getMyApplication().getMapMarkersHelper().isStartFromMyLocation() && myLocation != null) {
left = myLocation.getLongitude();
right = myLocation.getLongitude();
top = myLocation.getLatitude();
bottom = myLocation.getLatitude();
}
for (LatLon l : points) {
if (left == 0) {
left = l.getLongitude();
right = l.getLongitude();
top = l.getLatitude();
bottom = l.getLatitude();
} else {
left = Math.min(left, l.getLongitude());
right = Math.max(right, l.getLongitude());
top = Math.max(top, l.getLatitude());
bottom = Math.min(bottom, l.getLatitude());
}
}
RotatedTileBox tb = mapView.getCurrentRotatedTileBox().copy();
int tileBoxWidthPx = 0;
int tileBoxHeightPx = 0;
if (portrait) {
tileBoxHeightPx = 3 * (tb.getPixHeight() - mainView.getHeight() - toolbarHeight) / 4;
} else {
tileBoxWidthPx = tb.getPixWidth() - mainView.findViewById(R.id.up_down_row).getWidth();
}
mapView.fitRectToMap(left, right, top, bottom, tileBoxWidthPx, tileBoxHeightPx, toolbarHeight * 3 / 2);
}
}
public boolean quit(boolean hideMarkersListFirst) { public boolean quit(boolean hideMarkersListFirst) {
if (markersListOpened && hideMarkersListFirst) { if (markersListOpened && hideMarkersListFirst) {
hideMarkersList(); hideMarkersList();

View file

@ -281,7 +281,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
} }
} else { } else {
boolean firstItemInDisplayGroup = position - 1 != -1 && getItem(position - 1) instanceof Integer; boolean firstItemInDisplayGroup = position - 1 != -1 && getItem(position - 1) instanceof Integer;
boolean lastItemInDisplayGroup = !(getItem(position) instanceof MapMarker); boolean lastItemInDisplayGroup = position == getItemCount() || !(getItem(position) instanceof MapMarker);
if (firstItemInDisplayGroup && lastItemInDisplayGroup) { if (firstItemInDisplayGroup && lastItemInDisplayGroup) {
items.remove(position - 1); items.remove(position - 1);
} }

View file

@ -132,8 +132,10 @@ public class MapMarkersItemTouchHelperCallback extends ItemTouchHelper.Callback
@Override @Override
public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) { public void clearView(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
super.clearView(recyclerView, viewHolder); super.clearView(recyclerView, viewHolder);
((MapMarkerItemViewHolder) viewHolder).optionsBtn.setVisibility(View.VISIBLE); if (iconHidden) {
iconHidden = false; ((MapMarkerItemViewHolder) viewHolder).optionsBtn.setVisibility(View.VISIBLE);
iconHidden = false;
}
adapter.onItemDismiss(viewHolder); adapter.onItemDismiss(viewHolder);
} }

View file

@ -63,18 +63,22 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
@Override @Override
public void onBindViewHolder(final MapMarkerItemViewHolder holder, int pos) { public void onBindViewHolder(final MapMarkerItemViewHolder holder, int pos) {
boolean night = !mapActivity.getMyApplication().getSettings().isLightContent(); boolean night = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache(); IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
MapMarker marker = markers.get(pos);
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(marker.colorIndex))); boolean locationItem = pos == 0;
holder.iconReorder.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reorder)); boolean firstMarkerItem = pos == 1;
holder.iconDirection.setVisibility(View.GONE); boolean lastMarkerItem = pos == getItemCount() - 1;
MapMarker marker = locationItem ? null : getItem(pos);
holder.mainLayout.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.bg_color_dark : R.color.bg_color_light)); 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.title.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.color_white : R.color.color_black));
holder.divider.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.actionbar_dark_color : R.color.dashboard_divider_light)); holder.title.setText(locationItem ? mapActivity.getString(R.string.shared_string_my_location) : marker.getName(mapActivity));
holder.iconDirection.setVisibility(View.GONE);
holder.optionsBtn.setVisibility(View.GONE); holder.optionsBtn.setVisibility(View.GONE);
holder.description.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.dash_search_icon_dark : R.color.icon_color)); holder.divider.setBackgroundColor(ContextCompat.getColor(mapActivity, night ? R.color.actionbar_dark_color : R.color.dashboard_divider_light));
holder.divider.setVisibility(lastMarkerItem ? View.GONE : View.VISIBLE);
holder.checkBox.setVisibility(View.VISIBLE); holder.checkBox.setVisibility(View.VISIBLE);
holder.checkBox.setOnClickListener(new View.OnClickListener() { holder.checkBox.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -82,75 +86,79 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
listener.onItemClick(holder.itemView); listener.onItemClick(holder.itemView);
} }
}); });
holder.checkBox.setChecked(marker.selected); holder.bottomShadow.setVisibility(lastMarkerItem ? View.VISIBLE : View.GONE);
if (pos == 0 || pos == getItemCount() - 1) { holder.firstDescription.setVisibility((firstMarkerItem || lastMarkerItem) ? View.VISIBLE : View.GONE);
holder.firstDescription.setVisibility(View.VISIBLE); if (firstMarkerItem) {
if (pos == 0) { holder.firstDescription.setText(mapActivity.getString(R.string.shared_string_control_start) + "");
holder.topDivider.setVisibility(View.VISIBLE); } else if (lastMarkerItem) {
holder.firstDescription.setText(mapActivity.getString(R.string.shared_string_control_start) + ""); holder.firstDescription.setText(mapActivity.getString(R.string.shared_string_finish) + "");
} else { }
holder.firstDescription.setText(mapActivity.getString(R.string.shared_string_finish) + "");
} if (locationItem) {
holder.topDivider.setVisibility(View.VISIBLE);
holder.flagIconLeftSpace.setVisibility(View.VISIBLE);
holder.icon.setImageDrawable(ContextCompat.getDrawable(mapActivity, R.drawable.map_pedestrian_location));
holder.point.setVisibility(View.GONE);
holder.checkBox.setChecked(mapActivity.getMyApplication().getMapMarkersHelper().isStartFromMyLocation());
holder.iconReorder.setVisibility(View.GONE);
holder.description.setVisibility(View.GONE);
holder.distance.setVisibility(View.GONE);
} else { } else {
holder.firstDescription.setVisibility(View.GONE);
holder.topDivider.setVisibility(View.GONE); holder.topDivider.setVisibility(View.GONE);
} holder.flagIconLeftSpace.setVisibility(View.GONE);
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_flag_dark, MapMarker.getColorId(marker.colorIndex)));
holder.point.setVisibility(View.VISIBLE);
holder.checkBox.setChecked(marker.selected);
if (pos == getItemCount() - 1) { holder.iconReorder.setVisibility(View.VISIBLE);
holder.bottomShadow.setVisibility(View.VISIBLE); holder.iconReorder.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_reorder));
holder.divider.setVisibility(View.GONE); holder.iconReorder.setOnTouchListener(new View.OnTouchListener() {
} else { @Override
holder.bottomShadow.setVisibility(View.GONE); public boolean onTouch(View view, MotionEvent event) {
holder.divider.setVisibility(View.VISIBLE); if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
} listener.onDragStarted(holder);
}
holder.point.setVisibility(View.VISIBLE); return false;
holder.iconReorder.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) {
listener.onDragStarted(holder);
} }
return false; });
}
});
holder.title.setText(marker.getName(mapActivity)); holder.description.setVisibility(View.VISIBLE);
holder.description.setTextColor(ContextCompat.getColor(mapActivity, night ? R.color.dash_search_icon_dark : R.color.icon_color));
String descr; String descr;
if ((descr = marker.groupName) != null) { if ((descr = marker.groupName) != null) {
if (descr.equals("")) { if (descr.equals("")) {
descr = mapActivity.getString(R.string.shared_string_favorites); descr = mapActivity.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);
}
String day = new SimpleDateFormat("dd", Locale.getDefault()).format(date);
descr = month + " " + day;
} }
} else { holder.description.setText(descr);
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);
}
String day = new SimpleDateFormat("dd", Locale.getDefault()).format(date);
descr = month + " " + day;
}
holder.description.setText(descr);
if (location != null) { if (location != null) {
holder.distance.setTextColor(ContextCompat.getColor(mapActivity, useCenter holder.distance.setVisibility(View.VISIBLE);
? R.color.color_distance : R.color.color_myloc_distance)); holder.distance.setTextColor(ContextCompat.getColor(mapActivity, useCenter
float dist = (float) MapUtils.getDistance(location.getLatitude(), location.getLongitude(), ? R.color.color_distance : R.color.color_myloc_distance));
marker.getLatitude(), marker.getLongitude()); float dist = (float) MapUtils.getDistance(location.getLatitude(), location.getLongitude(),
holder.distance.setText(OsmAndFormatter.getFormattedDistance(dist, mapActivity.getMyApplication())); marker.getLatitude(), marker.getLongitude());
holder.distance.setText(OsmAndFormatter.getFormattedDistance(dist, mapActivity.getMyApplication()));
}
} }
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return markers.size(); return markers.size() + 1;
} }
public MapMarker getItem(int position) { public MapMarker getItem(int position) {
return markers.get(position); return markers.get(position - 1);
} }
@Override @Override
@ -160,7 +168,10 @@ public class MapMarkersListAdapter extends RecyclerView.Adapter<MapMarkerItemVie
@Override @Override
public boolean onItemMove(int from, int to) { public boolean onItemMove(int from, int to) {
Collections.swap(markers, from, to); if (to == 0) {
return false;
}
Collections.swap(markers, from - 1, to - 1);
notifyItemMoved(from, to); notifyItemMoved(from, to);
return true; return true;
} }

View file

@ -11,7 +11,6 @@ import android.view.ContextThemeWrapper;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.animation.Animation;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -36,11 +35,16 @@ public class SnapToRoadBottomSheetDialogFragment extends android.support.design.
private boolean nightMode; private boolean nightMode;
private boolean portrait; private boolean portrait;
private boolean snapToRoadEnabled; private boolean snapToRoadEnabled;
private boolean removeDefaultMode = true;
public void setListener(SnapToRoadFragmentListener listener) { public void setListener(SnapToRoadFragmentListener listener) {
this.listener = listener; this.listener = listener;
} }
public void setRemoveDefaultMode(boolean removeDefaultMode) {
this.removeDefaultMode = removeDefaultMode;
}
@Override @Override
public void setupDialog(Dialog dialog, int style) { public void setupDialog(Dialog dialog, int style) {
super.setupDialog(dialog, style); super.setupDialog(dialog, style);
@ -73,7 +77,9 @@ public class SnapToRoadBottomSheetDialogFragment extends android.support.design.
LinearLayout container = (LinearLayout) mainView.findViewById(R.id.navigation_types_container); LinearLayout container = (LinearLayout) mainView.findViewById(R.id.navigation_types_container);
final List<ApplicationMode> modes = new ArrayList<>(ApplicationMode.values(settings)); final List<ApplicationMode> modes = new ArrayList<>(ApplicationMode.values(settings));
modes.remove(ApplicationMode.DEFAULT); if (removeDefaultMode) {
modes.remove(ApplicationMode.DEFAULT);
}
View.OnClickListener onClickListener = new View.OnClickListener() { View.OnClickListener onClickListener = new View.OnClickListener() {
@Override @Override

View file

@ -727,8 +727,8 @@ public class MapControlsLayer extends OsmandMapLayer {
routePlanningBtn.updateVisibility(showButtons); routePlanningBtn.updateVisibility(showButtons);
menuControl.updateVisibility(showButtons); menuControl.updateVisibility(showButtons);
mapZoomIn.updateVisibility(!routeDialogOpened && !isInExpandedRouteMode()); mapZoomIn.updateVisibility(!routeDialogOpened);
mapZoomOut.updateVisibility(!routeDialogOpened && !isInExpandedRouteMode()); mapZoomOut.updateVisibility(!routeDialogOpened);
compassHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && shouldShowCompass() compassHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && shouldShowCompass()
&& !isInMeasurementToolMode() && !isInPlanRouteMode()); && !isInMeasurementToolMode() && !isInPlanRouteMode());
@ -814,7 +814,7 @@ public class MapControlsLayer extends OsmandMapLayer {
backToLocationControl.iv.setContentDescription(mapActivity.getString(R.string.map_widget_back_to_loc)); backToLocationControl.iv.setContentDescription(mapActivity.getString(R.string.map_widget_back_to_loc));
} }
boolean visible = !(tracked && rh.isFollowingMode()); boolean visible = !(tracked && rh.isFollowingMode());
backToLocationControl.updateVisibility(visible && !dialogOpened && !isInExpandedRouteMode()); backToLocationControl.updateVisibility(visible && !dialogOpened);
if (app.accessibilityEnabled()) { if (app.accessibilityEnabled()) {
backToLocationControl.iv.setClickable(enabled && visible); backToLocationControl.iv.setClickable(enabled && visible);
} }
@ -1136,10 +1136,6 @@ public class MapControlsLayer extends OsmandMapLayer {
return mapActivity.getMapLayers().getMapMarkersLayer().isInPlanRouteMode(); return mapActivity.getMapLayers().getMapMarkersLayer().isInPlanRouteMode();
} }
private boolean isInExpandedRouteMode() {
return mapActivity.getMapLayers().getMapMarkersLayer().isMarkersListOpened();
}
public static View.OnLongClickListener getOnClickMagnifierListener(final OsmandMapTileView view) { public static View.OnLongClickListener getOnClickMagnifierListener(final OsmandMapTileView view) {
return new View.OnLongClickListener() { return new View.OnLongClickListener() {

View file

@ -69,7 +69,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
private float[] calculations = new float[2]; private float[] calculations = new float[2];
private final RenderingLineAttributes lineAttrs = new RenderingLineAttributes("measureDistanceLine"); private final RenderingLineAttributes lineAttrs = new RenderingLineAttributes("measureDistanceLine");
private final RenderingLineAttributes textAttrs = new RenderingLineAttributes("rulerCircle"); private final RenderingLineAttributes textAttrs = new RenderingLineAttributes("rulerLineFont");
private Paint paint; private Paint paint;
private Path path; private Path path;
private List<LatLon> route = new ArrayList<>(); private List<LatLon> route = new ArrayList<>();
@ -77,12 +77,10 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
private TIntArrayList tx = new TIntArrayList(); private TIntArrayList tx = new TIntArrayList();
private TIntArrayList ty = new TIntArrayList(); private TIntArrayList ty = new TIntArrayList();
private Path linePath = new Path(); private Path linePath = new Path();
private String distanceText;
private ContextMenuLayer contextMenuLayer; private ContextMenuLayer contextMenuLayer;
private boolean inPlanRouteMode; private boolean inPlanRouteMode;
private boolean markersListOpened;
public MapMarkersLayer(MapActivity map) { public MapMarkersLayer(MapActivity map) {
this.map = map; this.map = map;
@ -100,14 +98,6 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
this.inPlanRouteMode = inPlanRouteMode; this.inPlanRouteMode = inPlanRouteMode;
} }
public boolean isMarkersListOpened() {
return inPlanRouteMode && markersListOpened;
}
public void setMarkersListOpened(boolean markersListOpened) {
this.markersListOpened = markersListOpened;
}
private void initUI() { private void initUI() {
bitmapPaint = new Paint(); bitmapPaint = new Paint();
bitmapPaint.setDither(true); bitmapPaint.setDither(true);
@ -141,8 +131,8 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
paint.setAlpha(200); paint.setAlpha(200);
float textSize = TEXT_SIZE * map.getResources().getDisplayMetrics().density; float textSize = TEXT_SIZE * map.getResources().getDisplayMetrics().density;
textAttrs.paint.setTextSize(textSize);
textAttrs.paint2.setTextSize(textSize); textAttrs.paint2.setTextSize(textSize);
textAttrs.paint3.setTextSize(textSize);
widgetsFactory = new MapMarkersWidgetsFactory(map); widgetsFactory = new MapMarkersWidgetsFactory(map);
@ -219,25 +209,18 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
} }
@Override @Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) { public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
Location myLoc = map.getMyApplication().getLocationProvider().getLastStaleKnownLocation();
widgetsFactory.updateInfo(myLoc == null
? tileBox.getCenterLatLon() : new LatLon(myLoc.getLatitude(), myLoc.getLongitude()), tileBox.getZoom());
OsmandSettings settings = map.getMyApplication().getSettings(); OsmandSettings settings = map.getMyApplication().getSettings();
Location myLoc = map.getMyApplication().getLocationProvider().getLastStaleKnownLocation();
if (tileBox.getZoom() < 3 || !settings.USE_MAP_MARKERS.get()) {
return;
}
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper(); MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
List<MapMarker> activeMapMarkers = markersHelper.getMapMarkers();
if (route.size() > 0) { if (route.size() > 0) {
path.reset(); path.reset();
boolean first = true; boolean first = true;
Location myLocation = map.getMapViewTrackingUtilities().getMyLocation(); if (markersHelper.isStartFromMyLocation() && myLoc != null) {
if (markersHelper.isStartFromMyLocation() && myLocation != null) { int locationX = tileBox.getPixXFromLonNoRot(myLoc.getLongitude());
int locationX = tileBox.getPixXFromLonNoRot(myLocation.getLongitude()); int locationY = tileBox.getPixYFromLatNoRot(myLoc.getLatitude());
int locationY = tileBox.getPixYFromLatNoRot(myLocation.getLatitude());
path.moveTo(locationX, locationY); path.moveTo(locationX, locationY);
first = false; first = false;
} }
@ -254,12 +237,10 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
canvas.drawPath(path, paint); canvas.drawPath(path, paint);
} }
List<MapMarker> activeMapMarkers = markersHelper.getMapMarkers();
if (settings.SHOW_LINES_TO_FIRST_MARKERS.get() && myLoc != null) { if (settings.SHOW_LINES_TO_FIRST_MARKERS.get() && myLoc != null) {
lineAttrs.updatePaints(view, nightMode, tileBox); lineAttrs.updatePaints(view, nightMode, tileBox);
textAttrs.updatePaints(view, nightMode, tileBox); textAttrs.updatePaints(view, nightMode, tileBox);
textAttrs.paint2.setStyle(Paint.Style.FILL); textAttrs.paint.setStyle(Paint.Style.FILL);
int locX = (int) tileBox.getPixXFromLatLon(myLoc.getLatitude(), myLoc.getLongitude()); int locX = (int) tileBox.getPixXFromLatLon(myLoc.getLatitude(), myLoc.getLongitude());
int locY = (int) tileBox.getPixYFromLatLon(myLoc.getLatitude(), myLoc.getLongitude()); int locY = (int) tileBox.getPixYFromLatLon(myLoc.getLatitude(), myLoc.getLongitude());
@ -286,6 +267,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
float generalDist = (float) MapUtils.getDistance(myLoc.getLatitude(), myLoc.getLongitude(), marker.getLatitude(), marker.getLongitude()); float generalDist = (float) MapUtils.getDistance(myLoc.getLatitude(), myLoc.getLongitude(), marker.getLatitude(), marker.getLongitude());
String generalDistSt = OsmAndFormatter.getFormattedDistance(generalDist, view.getApplication()); String generalDistSt = OsmAndFormatter.getFormattedDistance(generalDist, view.getApplication());
boolean locationInvisible = locX < 0 || locX > tileBox.getPixWidth() || locY < 0 || locY > tileBox.getPixHeight(); boolean locationInvisible = locX < 0 || locX > tileBox.getPixWidth() || locY < 0 || locY > tileBox.getPixHeight();
String distanceText;
if (locationInvisible) { if (locationInvisible) {
float centerToMarkerDist = (float) MapUtils.getDistance(tileBox.getLatLonFromPixel(pos[0], pos[1]), marker.getLatitude(), marker.getLongitude()); float centerToMarkerDist = (float) MapUtils.getDistance(tileBox.getLatLonFromPixel(pos[0], pos[1]), marker.getLatitude(), marker.getLongitude());
String centerToMarkerDistSt = OsmAndFormatter.getFormattedDistance(centerToMarkerDist, view.getApplication()); String centerToMarkerDistSt = OsmAndFormatter.getFormattedDistance(centerToMarkerDist, view.getApplication());
@ -298,7 +280,7 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
distanceText = generalDistSt; distanceText = generalDistSt;
} }
Rect bounds = new Rect(); Rect bounds = new Rect();
textAttrs.paint2.getTextBounds(distanceText, 0, distanceText.length(), bounds); textAttrs.paint.getTextBounds(distanceText, 0, distanceText.length(), bounds);
float hOffset = pm.getLength() / 2 - bounds.width() / 2; float hOffset = pm.getLength() / 2 - bounds.width() / 2;
lineAttrs.paint.setColor(colors[marker.colorIndex]); lineAttrs.paint.setColor(colors[marker.colorIndex]);
@ -309,18 +291,32 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
} }
if (locX >= markerX) { if (locX >= markerX) {
canvas.rotate(180, pos[0], pos[1]); canvas.rotate(180, pos[0], pos[1]);
canvas.drawTextOnPath(distanceText, linePath, hOffset, bounds.height() + VERTICAL_OFFSET, textAttrs.paint3);
canvas.drawTextOnPath(distanceText, linePath, hOffset, bounds.height() + VERTICAL_OFFSET, textAttrs.paint2); canvas.drawTextOnPath(distanceText, linePath, hOffset, bounds.height() + VERTICAL_OFFSET, textAttrs.paint2);
canvas.drawTextOnPath(distanceText, linePath, hOffset, bounds.height() + VERTICAL_OFFSET, textAttrs.paint);
canvas.rotate(-180, pos[0], pos[1]); canvas.rotate(-180, pos[0], pos[1]);
} else { } else {
canvas.drawTextOnPath(distanceText, linePath, hOffset, -VERTICAL_OFFSET, textAttrs.paint3);
canvas.drawTextOnPath(distanceText, linePath, hOffset, -VERTICAL_OFFSET, textAttrs.paint2); canvas.drawTextOnPath(distanceText, linePath, hOffset, -VERTICAL_OFFSET, textAttrs.paint2);
canvas.drawTextOnPath(distanceText, linePath, hOffset, -VERTICAL_OFFSET, textAttrs.paint);
} }
canvas.rotate(tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY()); canvas.rotate(tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
} }
} }
}
for (MapMarker marker : activeMapMarkers) { @Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings nightMode) {
Location myLoc = map.getMyApplication().getLocationProvider().getLastStaleKnownLocation();
widgetsFactory.updateInfo(myLoc == null
? tileBox.getCenterLatLon() : new LatLon(myLoc.getLatitude(), myLoc.getLongitude()), tileBox.getZoom());
OsmandSettings settings = map.getMyApplication().getSettings();
if (tileBox.getZoom() < 3 || !settings.USE_MAP_MARKERS.get()) {
return;
}
MapMarkersHelper markersHelper = map.getMyApplication().getMapMarkersHelper();
for (MapMarker marker : markersHelper.getMapMarkers()) {
if (isLocationVisible(tileBox, marker) && !overlappedByWaypoint(marker) if (isLocationVisible(tileBox, marker) && !overlappedByWaypoint(marker)
&& !isInMotion(marker)) { && !isInMotion(marker)) {
Bitmap bmp = getMapMarkerBitmap(marker.colorIndex); Bitmap bmp = getMapMarkerBitmap(marker.colorIndex);
@ -336,9 +332,8 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
if (settings.SHOW_ARROWS_TO_FIRST_MARKERS.get()) { if (settings.SHOW_ARROWS_TO_FIRST_MARKERS.get()) {
LatLon loc = tileBox.getCenterLatLon(); LatLon loc = tileBox.getCenterLatLon();
List<MapMarker> mapMarkers = markersHelper.getMapMarkers();
int i = 0; int i = 0;
for (MapMarker marker : mapMarkers) { for (MapMarker marker : markersHelper.getMapMarkers()) {
if (!isLocationVisible(tileBox, marker) && !isInMotion(marker)) { if (!isLocationVisible(tileBox, marker) && !isInMotion(marker)) {
canvas.save(); canvas.save();
net.osmand.Location.distanceBetween(loc.getLatitude(), loc.getLongitude(), net.osmand.Location.distanceBetween(loc.getLatitude(), loc.getLongitude(),
@ -414,12 +409,12 @@ public class MapMarkersLayer extends OsmandMapLayer implements IContextMenuProvi
@Override @Override
public boolean disableSingleTap() { public boolean disableSingleTap() {
return false; return inPlanRouteMode;
} }
@Override @Override
public boolean disableLongPressOnMap() { public boolean disableLongPressOnMap() {
return false; return inPlanRouteMode;
} }
@Override @Override

View file

@ -41,6 +41,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
private final ContextMenuLayer contextMenuLayer; private final ContextMenuLayer contextMenuLayer;
private final MeasurementToolLayer measurementToolLayer; private final MeasurementToolLayer measurementToolLayer;
private final MapMarkersLayer mapMarkersLayer;
private ImageView contextMarker; private ImageView contextMarker;
private final MapActivity mapActivity; private final MapActivity mapActivity;
private final OsmandApplication app; private final OsmandApplication app;
@ -66,6 +67,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
settings = activity.getMyApplication().getSettings(); settings = activity.getMyApplication().getSettings();
quickActionRegistry = activity.getMapLayers().getQuickActionRegistry(); quickActionRegistry = activity.getMapLayers().getQuickActionRegistry();
measurementToolLayer = mapActivity.getMapLayers().getMeasurementToolLayer(); measurementToolLayer = mapActivity.getMapLayers().getMeasurementToolLayer();
mapMarkersLayer = mapActivity.getMapLayers().getMapMarkersLayer();
} }
@ -323,6 +325,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInChangeMarkerPositionMode() ||
contextMenuLayer.isInGpxDetailsMode() || contextMenuLayer.isInGpxDetailsMode() ||
measurementToolLayer.isInMeasurementMode() || measurementToolLayer.isInMeasurementMode() ||
mapMarkersLayer.isInPlanRouteMode() ||
mapActivity.getContextMenu().isVisible() && !mapActivity.getContextMenu().findMenuFragment().get().isRemoving() || mapActivity.getContextMenu().isVisible() && !mapActivity.getContextMenu().findMenuFragment().get().isRemoving() ||
mapActivity.getContextMenu().isVisible() && mapActivity.getContextMenu().findMenuFragment().get().isAdded() || mapActivity.getContextMenu().isVisible() && mapActivity.getContextMenu().findMenuFragment().get().isAdded() ||
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() && mapActivity.getContextMenu().getMultiSelectionMenu().getFragmentByTag().isAdded() || mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() && mapActivity.getContextMenu().getMultiSelectionMenu().getFragmentByTag().isAdded() ||

View file

@ -76,10 +76,9 @@ public class RulerControlLayer extends OsmandMapLayer {
private Bitmap centerIconNight; private Bitmap centerIconNight;
private Paint bitmapPaint; private Paint bitmapPaint;
private RenderingLineAttributes lineAttrs; private RenderingLineAttributes lineAttrs;
private RenderingLineAttributes lineFontAttrs;
private RenderingLineAttributes circleAttrs; private RenderingLineAttributes circleAttrs;
private RenderingLineAttributes circleAttrsAlt; private RenderingLineAttributes circleAttrsAlt;
private float circleTextSize;
private float lineTextSize;
private Handler handler; private Handler handler;
@ -122,8 +121,12 @@ public class RulerControlLayer extends OsmandMapLayer {
lineAttrs = new RenderingLineAttributes("rulerLine"); lineAttrs = new RenderingLineAttributes("rulerLine");
circleTextSize = TEXT_SIZE * mapActivity.getResources().getDisplayMetrics().density; float circleTextSize = TEXT_SIZE * mapActivity.getResources().getDisplayMetrics().density;
lineTextSize = DISTANCE_TEXT_SIZE * mapActivity.getResources().getDisplayMetrics().density; float lineTextSize = DISTANCE_TEXT_SIZE * mapActivity.getResources().getDisplayMetrics().density;
lineFontAttrs = new RenderingLineAttributes("rulerLineFont");
lineFontAttrs.paint.setTextSize(lineTextSize);
lineFontAttrs.paint2.setTextSize(lineTextSize);
circleAttrs = new RenderingLineAttributes("rulerCircle"); circleAttrs = new RenderingLineAttributes("rulerCircle");
circleAttrs.paint2.setTextSize(circleTextSize); circleAttrs.paint2.setTextSize(circleTextSize);
@ -179,6 +182,8 @@ public class RulerControlLayer extends OsmandMapLayer {
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings settings) { public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings settings) {
if (rulerModeOn()) { if (rulerModeOn()) {
lineAttrs.updatePaints(view, settings, tb); lineAttrs.updatePaints(view, settings, tb);
lineFontAttrs.updatePaints(view, settings, tb);
lineFontAttrs.paint.setStyle(Style.FILL);
circleAttrs.updatePaints(view, settings, tb); circleAttrs.updatePaints(view, settings, tb);
circleAttrs.paint2.setStyle(Style.FILL); circleAttrs.paint2.setStyle(Style.FILL);
circleAttrsAlt.updatePaints(view, settings, tb); circleAttrsAlt.updatePaints(view, settings, tb);
@ -221,14 +226,7 @@ public class RulerControlLayer extends OsmandMapLayer {
} }
if (mode == RulerMode.FIRST || mode == RulerMode.SECOND) { if (mode == RulerMode.FIRST || mode == RulerMode.SECOND) {
updateData(tb, center); updateData(tb, center);
RenderingLineAttributes attrs; RenderingLineAttributes attrs = mode == RulerMode.FIRST ? circleAttrs : circleAttrsAlt;
if (mode == RulerMode.FIRST) {
circleAttrs.paint2.setTextSize(circleTextSize);
circleAttrs.paint3.setTextSize(circleTextSize);
attrs = circleAttrs;
} else {
attrs = circleAttrsAlt;
}
for (int i = 1; i <= cacheDistances.size(); i++) { for (int i = 1; i <= cacheDistances.size(); i++) {
drawCircle(canvas, tb, i, center, attrs); drawCircle(canvas, tb, i, center, attrs);
} }
@ -268,22 +266,19 @@ public class RulerControlLayer extends OsmandMapLayer {
private void drawTextOnCenterOfPath(Canvas canvas, float x1, float x2, Path path, String text) { private void drawTextOnCenterOfPath(Canvas canvas, float x1, float x2, Path path, String text) {
PathMeasure pm = new PathMeasure(path, false); PathMeasure pm = new PathMeasure(path, false);
Rect bounds = new Rect(); Rect bounds = new Rect();
circleAttrs.paint2.getTextBounds(text, 0, text.length(), bounds); lineFontAttrs.paint.getTextBounds(text, 0, text.length(), bounds);
float hOffset = pm.getLength() / 2 - bounds.width() / 2; float hOffset = pm.getLength() / 2 - bounds.width() / 2;
circleAttrs.paint2.setTextSize(lineTextSize);
circleAttrs.paint3.setTextSize(lineTextSize);
if (x1 >= x2) { if (x1 >= x2) {
float[] pos = new float[2]; float[] pos = new float[2];
pm.getPosTan(pm.getLength() / 2, pos, null); pm.getPosTan(pm.getLength() / 2, pos, null);
canvas.rotate(180, pos[0], pos[1]); canvas.rotate(180, pos[0], pos[1]);
canvas.drawTextOnPath(text, path, hOffset, bounds.height() + VERTICAL_OFFSET, circleAttrs.paint3); canvas.drawTextOnPath(text, path, hOffset, bounds.height() + VERTICAL_OFFSET, lineFontAttrs.paint2);
canvas.drawTextOnPath(text, path, hOffset, bounds.height() + VERTICAL_OFFSET, circleAttrs.paint2); canvas.drawTextOnPath(text, path, hOffset, bounds.height() + VERTICAL_OFFSET, lineFontAttrs.paint);
canvas.rotate(-180, pos[0], pos[1]); canvas.rotate(-180, pos[0], pos[1]);
} else { } else {
canvas.drawTextOnPath(text, path, hOffset, -VERTICAL_OFFSET, circleAttrs.paint3); canvas.drawTextOnPath(text, path, hOffset, -VERTICAL_OFFSET, lineFontAttrs.paint2);
canvas.drawTextOnPath(text, path, hOffset, -VERTICAL_OFFSET, circleAttrs.paint2); canvas.drawTextOnPath(text, path, hOffset, -VERTICAL_OFFSET, lineFontAttrs.paint);
} }
} }