Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-01-11 14:46:35 +01:00
commit b3e41d04cd
82 changed files with 1671 additions and 940 deletions

View file

@ -40,7 +40,7 @@
<uses-feature android:name="com.sec.feature.spen_usp" android:required="false"/> <uses-feature android:name="com.sec.feature.spen_usp" android:required="false"/>
<uses-sdk android:targetSdkVersion="21" android:minSdkVersion="9" <uses-sdk android:targetSdkVersion="21" android:minSdkVersion="9"
tools:overrideLibrary="com.getkeepsafe.taptargetview, studio.carbonylgroup.textfieldboxes"/> tools:overrideLibrary="com.getkeepsafe.taptargetview, studio.carbonylgroup.textfieldboxes, android.support.customtabs"/>
<supports-screens android:resizeable="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" <supports-screens android:resizeable="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true"
android:xlargeScreens="true" android:anyDensity="true" /> android:xlargeScreens="true" android:anyDensity="true" />

View file

@ -389,6 +389,7 @@ dependencies {
compile 'com.android.support:cardview-v7:26.1.0' compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:appcompat-v7:26.1.0' compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0' compile 'com.android.support:design:26.1.0'
compile 'com.android.support:customtabs:26.1.0'
compile fileTree(include: ['*.jar'], exclude: ['QtAndroid-bundled.jar', 'QtAndroidAccessibility-bundled.jar', 'OsmAndCore_android.jar', 'OsmAndCore_wrapper.jar', 'android-support-multidex.jar'], dir: 'libs') compile fileTree(include: ['*.jar'], exclude: ['QtAndroid-bundled.jar', 'QtAndroidAccessibility-bundled.jar', 'OsmAndCore_android.jar', 'OsmAndCore_wrapper.jar', 'android-support-multidex.jar'], dir: 'libs')
legacyCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar" legacyCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar"
qtcoredebugCompile "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar" qtcoredebugCompile "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar"

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<nine-patch android:src="@drawable/bg_contextmenu_dots_dark" /> <nine-patch android:src="@drawable/bg_contextmenu_shadow_top_light" />
</item> </item>
<item> <item>
<shape> <shape>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item> <item>
<nine-patch android:src="@drawable/bg_contextmenu_dots_light" /> <nine-patch android:src="@drawable/bg_contextmenu_shadow_top_light" />
</item> </item>
<item> <item>
<shape> <shape>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/route_info_bg_dark" />
<stroke
android:width="1dp"
android:color="@color/route_info_divider_dark" />
<corners android:radius="3dp" />
</shape>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/route_info_bg_light" />
<stroke
android:width="1dp"
android:color="@color/route_info_divider_light" />
<corners android:radius="3dp" />
</shape>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<nine-patch android:src="@drawable/bg_contextmenu_shadow_top_light" />
</item>
<item>
<shape>
<solid android:color="@color/ctx_menu_bg_dark" />
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<nine-patch android:src="@drawable/bg_contextmenu_shadow_right_light" />
</item>
<item>
<shape>
<solid
android:color="@color/ctx_menu_bg_dark" />
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<nine-patch android:src="@drawable/bg_contextmenu_shadow_top_light" />
</item>
<item>
<shape>
<solid android:color="@color/ctx_menu_bg_light" />
</shape>
</item>
</layer-list>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<nine-patch android:src="@drawable/bg_contextmenu_shadow_right_light" />
</item>
<item>
<shape>
<solid
android:color="@color/ctx_menu_bg_light" />
</shape>
</item>
</layer-list>

View file

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

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/ctx_menu_buttons_bg_dark" />
<stroke
android:width="1dp"
android:color="@color/ctx_menu_controller_button_outline_color_dark_n" />
<corners android:radius="3dp" />
</shape>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/ctx_menu_controller_button_bg_color_dark_p" />
<stroke
android:width="1dp"
android:color="@color/ctx_menu_controller_button_outline_color_dark_p" />
<corners android:radius="3dp" />
</shape>

View file

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

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/ctx_menu_buttons_bg_light" />
<stroke
android:width="1dp"
android:color="@color/ctx_menu_info_divider_light" />
<corners android:radius="3dp" />
</shape>

View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/ctx_menu_controller_button_bg_color_light_p" />
<stroke
android:width="1dp"
android:color="@color/ctx_menu_controller_button_outline_color_light_p" />
<corners android:radius="3dp" />
</shape>

View file

@ -49,7 +49,7 @@
android:id="@+id/waypoints" android:id="@+id/waypoints"
android:layout_width="@dimen/list_item_height" android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height" android:layout_height="@dimen/list_item_height"
android:background="?attr/dashboard_button" android:background="?attr/selectableItemBackground"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/map_action_waypoints"/> android:src="@drawable/map_action_waypoints"/>
</LinearLayout> </LinearLayout>
@ -74,16 +74,19 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<FrameLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:background="?attr/selectableItemBackground"
android:id="@+id/FromLayout" android:id="@+id/FromLayout"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="@dimen/list_item_height" android:layout_height="@dimen/list_item_height"
@ -130,39 +133,19 @@
android:layout_marginRight="@dimen/list_header_text_left_margin" android:layout_marginRight="@dimen/list_header_text_left_margin"
android:src="@drawable/ic_action_arrow_drop_down"/> android:src="@drawable/ic_action_arrow_drop_down"/>
<View
android:id="@+id/from_layout_empty_view"
android:layout_width="@dimen/route_info_directions_margin"
android:layout_height="match_parent"/>
</LinearLayout> </LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View <View
android:layout_marginStart="@dimen/route_info_divider_margin" android:layout_marginStart="@dimen/route_info_divider_margin"
android:layout_marginLeft="@dimen/route_info_divider_margin" android:layout_marginLeft="@dimen/route_info_divider_margin"
android:layout_marginRight="@dimen/route_info_directions_margin"
android:layout_marginEnd="@dimen/route_info_directions_margin"
android:id="@+id/dividerFromDropDown" android:id="@+id/dividerFromDropDown"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:background="@color/dashboard_divider_dark" android:background="@color/dashboard_divider_dark"
android:focusable="false"/> android:focusable="false"/>
<View
android:id="@+id/divider_from_drop_down_empty"
android:layout_gravity="end"
android:layout_width="@dimen/route_info_directions_margin"
android:layout_height="1dp"
android:focusable="false"
android:background="@color/dashboard_divider_dark"/>
</FrameLayout>
<LinearLayout <LinearLayout
android:background="?attr/selectableItemBackground"
android:id="@+id/ViaLayout" android:id="@+id/ViaLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/list_item_height" android:layout_height="@dimen/list_item_height"
@ -216,6 +199,7 @@
android:focusable="false"/> android:focusable="false"/>
<LinearLayout <LinearLayout
android:background="?attr/selectableItemBackground"
android:id="@+id/ToLayout" android:id="@+id/ToLayout"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="@dimen/list_item_height" android:layout_height="@dimen/list_item_height"
@ -262,18 +246,13 @@
android:layout_marginRight="@dimen/list_header_text_left_margin" android:layout_marginRight="@dimen/list_header_text_left_margin"
android:src="@drawable/ic_action_arrow_drop_down"/> android:src="@drawable/ic_action_arrow_drop_down"/>
<View
android:id="@+id/to_layout_empty_view"
android:layout_width="@dimen/route_info_directions_margin"
android:layout_height="match_parent"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<ImageView <ImageView
android:background="?attr/selectableItemBackground"
android:id="@+id/swap_direction_image_view" android:id="@+id/swap_direction_image_view"
android:visibility="gone"
android:paddingRight="@dimen/route_info_icon_padding_right" android:paddingRight="@dimen/route_info_icon_padding_right"
android:paddingLeft="@dimen/route_info_icon_padding_right" android:paddingLeft="@dimen/route_info_icon_padding_right"
android:layout_gravity="end" android:layout_gravity="end"
@ -281,7 +260,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
</FrameLayout> </LinearLayout>
<View <View
android:id="@+id/dividerToDropDown" android:id="@+id/dividerToDropDown"
@ -300,7 +279,7 @@
android:id="@+id/Info" android:id="@+id/Info"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/dashboard_button" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height" android:minHeight="@dimen/list_item_height"
android:orientation="horizontal"> android:orientation="horizontal">
@ -308,7 +287,7 @@
android:id="@+id/Prev" android:id="@+id/Prev"
android:layout_width="@dimen/list_item_height" android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height" android:layout_height="@dimen/list_item_height"
android:background="?attr/dashboard_button" android:background="?attr/selectableItemBackground"
android:contentDescription="@string/shared_string_previous" android:contentDescription="@string/shared_string_previous"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_prev"/> android:src="@drawable/ic_prev"/>
@ -407,7 +386,7 @@
android:layout_width="@dimen/list_item_height" android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height" android:layout_height="@dimen/list_item_height"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:background="?attr/dashboard_button" android:background="?attr/selectableItemBackground"
android:contentDescription="@string/shared_string_next" android:contentDescription="@string/shared_string_next"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_next"/> android:src="@drawable/ic_next"/>

View file

@ -1,65 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:background="?attr/selectableItemBackground"
android:orientation="horizontal"
android:paddingBottom="12dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp">
<net.osmand.plus.widgets.TextViewEx
android:textAllCaps="true"
osmand:typeface="@string/font_roboto_medium"
android:id="@+id/route_ref"
android:layout_width="32dp"
android:layout_height="18dp"
android:background="@drawable/transport_stop_route_bg"
android:gravity="center"
android:textColor="@color/color_white"
android:textSize="@dimen/default_sub_text_size_small"
tools:text="3"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:orientation="vertical">
<TextView
android:textSize="16sp"
android:id="@+id/route_desc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="№5: Льва Толстого площа - Белицкая улица (25м)"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingTop="8dp">
<ImageView
android:id="@+id/route_type_icon"
android:layout_marginRight="@dimen/context_menu_transport_grid_spacing"
android:layout_marginEnd="@dimen/context_menu_transport_grid_spacing"
android:layout_width="@dimen/context_menu_transport_icon_size"
android:layout_height="@dimen/context_menu_transport_icon_size"
tools:src="@drawable/ic_action_polygom_dark"/>
<TextView
android:id="@+id/route_type_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Метро "/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -97,20 +97,21 @@
android:layout_height="@dimen/context_menu_sub_info_height" android:layout_height="@dimen/context_menu_sub_info_height"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <net.osmand.plus.widgets.TextViewEx
android:layout_marginRight="@dimen/context_menu_padding_margin_small" android:layout_marginRight="@dimen/context_menu_padding_margin_small"
android:layout_marginEnd="@dimen/context_menu_padding_margin_small" android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
tools:text="Museum" tools:text="Museum"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/context_menu_line3" android:id="@+id/context_menu_line3"
osmand:typeface="@string/font_roboto_medium"
style="@style/TextAppearance.ContextMenuSubtitle"/> style="@style/TextAppearance.ContextMenuSubtitle"/>
<TextView <TextView
android:layout_marginRight="@dimen/context_menu_padding_margin_small" android:layout_marginRight="@dimen/context_menu_padding_margin_small"
android:layout_marginEnd="@dimen/context_menu_padding_margin_small" android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
tools:text="Closed till 10:00" tools:text="Closed till 10:00"
android:id="@+id/opening_hours_text_view" android:id="@+id/additional_info_text_view"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"/>
@ -174,7 +175,7 @@
android:paddingRight="@dimen/context_menu_button_padding_x" android:paddingRight="@dimen/context_menu_button_padding_x"
android:textAllCaps="true" android:textAllCaps="true"
android:text="@string/recording_context_menu_play" android:text="@string/recording_context_menu_play"
tools:textColor="?attr/contextMenuButtonColor" tools:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"/> android:textSize="@dimen/default_desc_text_size"/>
<TextView <TextView
@ -209,7 +210,7 @@
android:paddingLeft="@dimen/context_menu_button_padding_x" android:paddingLeft="@dimen/context_menu_button_padding_x"
android:paddingRight="@dimen/context_menu_button_padding_x" android:paddingRight="@dimen/context_menu_button_padding_x"
android:text="@string/shared_string_delete" android:text="@string/shared_string_delete"
tools:textColor="?attr/contextMenuButtonColor" tools:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"/> android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout> </LinearLayout>
@ -246,7 +247,7 @@
android:paddingLeft="@dimen/context_menu_button_padding_x" android:paddingLeft="@dimen/context_menu_button_padding_x"
android:paddingRight="@dimen/context_menu_button_padding_x" android:paddingRight="@dimen/context_menu_button_padding_x"
android:text="@string/shared_string_download" android:text="@string/shared_string_download"
tools:textColor="?attr/contextMenuButtonColor" tools:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"/> android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout> </LinearLayout>
@ -270,8 +271,8 @@
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingLeft="@dimen/context_menu_button_padding_x" android:paddingLeft="@dimen/context_menu_button_padding_x"
android:paddingRight="@dimen/context_menu_button_padding_x" android:paddingRight="@dimen/context_menu_button_padding_x"
android:text="@string/shared_string_delete" android:text="@string/shared_string_others"
tools:textColor="?attr/contextMenuButtonColor" tools:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"/> android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout> </LinearLayout>
@ -305,9 +306,9 @@
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingLeft="@dimen/context_menu_button_padding_x" android:paddingLeft="@dimen/context_menu_button_padding_x"
android:paddingRight="@dimen/context_menu_button_padding_x" android:paddingRight="@dimen/context_menu_button_padding_x"
android:text="@string/shared_string_others" android:text="@string/shared_string_delete"
android:textAllCaps="true" android:textAllCaps="true"
tools:textColor="?attr/contextMenuButtonColor" tools:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"/> osmand:typeface="@string/font_roboto_medium"/>
@ -382,8 +383,8 @@
android:background="?attr/ctx_menu_divider"/> android:background="?attr/ctx_menu_divider"/>
<LinearLayout <LinearLayout
android:paddingLeft="@dimen/context_menu_padding_margin_small" android:paddingLeft="@dimen/map_widget_icon_margin"
android:paddingRight="@dimen/context_menu_padding_margin_small" android:paddingRight="@dimen/map_widget_icon_margin"
android:id="@+id/context_menu_buttons" android:id="@+id/context_menu_buttons"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View file

@ -18,7 +18,7 @@
android:paddingLeft="@dimen/route_info_buttons_padding_left_right" android:paddingLeft="@dimen/route_info_buttons_padding_left_right"
android:paddingRight="@dimen/route_info_buttons_padding_left_right" android:paddingRight="@dimen/route_info_buttons_padding_left_right"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:background="?attr/dashboard_button" android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_action_test_light" /> android:src="@drawable/ic_action_test_light" />
<View <View
@ -40,7 +40,7 @@
android:paddingLeft="@dimen/route_info_buttons_padding_left_right" android:paddingLeft="@dimen/route_info_buttons_padding_left_right"
android:paddingRight="@dimen/route_info_buttons_padding_left_right" android:paddingRight="@dimen/route_info_buttons_padding_left_right"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:background="?attr/dashboard_button" android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_action_test_light" /> android:src="@drawable/ic_action_test_light" />
<View <View
@ -62,7 +62,7 @@
android:paddingLeft="@dimen/route_info_buttons_padding_left_right" android:paddingLeft="@dimen/route_info_buttons_padding_left_right"
android:paddingRight="@dimen/route_info_buttons_padding_left_right" android:paddingRight="@dimen/route_info_buttons_padding_left_right"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:background="?attr/dashboard_button" android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_action_test_light" /> android:src="@drawable/ic_action_test_light" />
<TextView <TextView

View file

@ -2,13 +2,14 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:minHeight="@dimen/list_item_height" android:minHeight="@dimen/list_item_height"
android:orientation="vertical" android:orientation="vertical"
android:baselineAligned="false"> android:baselineAligned="false">
<LinearLayout <LinearLayout
android:id="@+id/content" android:id="@+id/content"
android:background="?attr/expandable_list_item_background" android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/list_content_padding" android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding" android:paddingRight="@dimen/list_content_padding"
android:orientation="horizontal" android:orientation="horizontal"
@ -18,8 +19,8 @@
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="@dimen/content_padding_small" android:paddingBottom="@dimen/multi_selection_menu_padding_bottom"
android:paddingTop="@dimen/list_content_padding" android:paddingTop="@dimen/multi_selection_menu_padding_top"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">
@ -42,7 +43,7 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:paddingTop="@dimen/list_content_padding" android:paddingTop="@dimen/multi_selection_menu_padding_top"
android:id="@+id/context_menu_icon_layout" android:id="@+id/context_menu_icon_layout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -64,6 +65,6 @@
android:id="@+id/divider" android:id="@+id/divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:background="?attr/dashboard_divider"/> tools:background="@color/multi_selection_menu_divider_dark"/>
</LinearLayout> </LinearLayout>

View file

@ -29,7 +29,7 @@
android:id="@+id/divider" android:id="@+id/divider"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:background="?attr/dashboard_divider"/> tools:background="@color/multi_selection_menu_divider_dark"/>
<FrameLayout <FrameLayout
android:id="@+id/cancel_row" android:id="@+id/cancel_row"
@ -44,7 +44,6 @@
android:layout_gravity="center" android:layout_gravity="center"
android:text="@string/shared_string_close" android:text="@string/shared_string_close"
android:textAllCaps="true" android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/> android:textStyle="bold"/>
</FrameLayout> </FrameLayout>

View file

@ -10,7 +10,7 @@
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/header_title" android:id="@+id/header_title"
android:textAppearance="@style/TextAppearance.ListItemTitle" android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium" osmand:typeface="@string/font_roboto_regular"
android:gravity="center_vertical" android:gravity="center_vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"

View file

@ -49,7 +49,7 @@
android:id="@+id/waypoints" android:id="@+id/waypoints"
android:layout_width="@dimen/list_item_height" android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height" android:layout_height="@dimen/list_item_height"
android:background="?attr/dashboard_button" android:background="?attr/selectableItemBackground"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/map_action_waypoints"/> android:src="@drawable/map_action_waypoints"/>
</LinearLayout> </LinearLayout>
@ -73,16 +73,19 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<FrameLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:background="?attr/selectableItemBackground"
android:id="@+id/FromLayout" android:id="@+id/FromLayout"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="@dimen/list_item_height" android:layout_height="@dimen/list_item_height"
@ -131,39 +134,19 @@
android:layout_marginRight="@dimen/list_header_text_left_margin" android:layout_marginRight="@dimen/list_header_text_left_margin"
android:src="@drawable/ic_action_arrow_drop_down"/> android:src="@drawable/ic_action_arrow_drop_down"/>
<View
android:id="@+id/from_layout_empty_view"
android:layout_width="@dimen/route_info_directions_margin"
android:layout_height="match_parent"/>
</LinearLayout> </LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View <View
android:layout_marginStart="@dimen/route_info_divider_margin" android:layout_marginStart="@dimen/route_info_divider_margin"
android:layout_marginLeft="@dimen/route_info_divider_margin" android:layout_marginLeft="@dimen/route_info_divider_margin"
android:layout_marginRight="@dimen/route_info_directions_margin"
android:layout_marginEnd="@dimen/route_info_directions_margin"
android:id="@+id/dividerFromDropDown" android:id="@+id/dividerFromDropDown"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="1dp"
android:background="@color/dashboard_divider_dark" android:background="@color/dashboard_divider_dark"
android:focusable="false"/> android:focusable="false"/>
<View
android:id="@+id/divider_from_drop_down_empty"
android:layout_gravity="end"
android:layout_width="@dimen/route_info_directions_margin"
android:layout_height="1dp"
android:focusable="false"
android:background="@color/dashboard_divider_dark"/>
</FrameLayout>
<LinearLayout <LinearLayout
android:background="?attr/selectableItemBackground"
android:id="@+id/ViaLayout" android:id="@+id/ViaLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/list_item_height" android:layout_height="@dimen/list_item_height"
@ -219,6 +202,7 @@
android:focusable="false"/> android:focusable="false"/>
<LinearLayout <LinearLayout
android:background="?attr/selectableItemBackground"
android:id="@+id/ToLayout" android:id="@+id/ToLayout"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="@dimen/list_item_height" android:layout_height="@dimen/list_item_height"
@ -267,16 +251,12 @@
android:layout_marginRight="@dimen/list_header_text_left_margin" android:layout_marginRight="@dimen/list_header_text_left_margin"
android:src="@drawable/ic_action_arrow_drop_down"/> android:src="@drawable/ic_action_arrow_drop_down"/>
<View
android:id="@+id/to_layout_empty_view"
android:layout_width="@dimen/route_info_directions_margin"
android:layout_height="match_parent"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<ImageView <ImageView
android:background="?attr/selectableItemBackground"
android:id="@+id/swap_direction_image_view" android:id="@+id/swap_direction_image_view"
android:paddingRight="@dimen/route_info_icon_padding_right" android:paddingRight="@dimen/route_info_icon_padding_right"
android:paddingLeft="@dimen/route_info_icon_padding_right" android:paddingLeft="@dimen/route_info_icon_padding_right"
@ -285,7 +265,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
</FrameLayout> </LinearLayout>
<View <View
android:id="@+id/dividerToDropDown" android:id="@+id/dividerToDropDown"
@ -304,7 +284,7 @@
android:id="@+id/Info" android:id="@+id/Info"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/dashboard_button" android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height" android:minHeight="@dimen/list_item_height"
android:orientation="horizontal"> android:orientation="horizontal">
@ -312,7 +292,7 @@
android:id="@+id/Prev" android:id="@+id/Prev"
android:layout_width="@dimen/list_item_height" android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height" android:layout_height="@dimen/list_item_height"
android:background="?attr/dashboard_button" android:background="?attr/selectableItemBackground"
android:contentDescription="@string/shared_string_previous" android:contentDescription="@string/shared_string_previous"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_prev"/> android:src="@drawable/ic_prev"/>
@ -366,7 +346,7 @@
android:layout_marginRight="@dimen/list_content_padding" android:layout_marginRight="@dimen/list_content_padding"
android:contentDescription="@string/info_button" android:contentDescription="@string/info_button"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_action_time"/> android:src="@drawable/ic_action_time_span"/>
<LinearLayout <LinearLayout
android:id="@+id/InfoDuration" android:id="@+id/InfoDuration"
@ -411,7 +391,7 @@
android:layout_width="@dimen/list_item_height" android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height" android:layout_height="@dimen/list_item_height"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:background="?attr/dashboard_button" android:background="?attr/selectableItemBackground"
android:contentDescription="@string/shared_string_next" android:contentDescription="@string/shared_string_next"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_next"/> android:src="@drawable/ic_next"/>

View file

@ -7,6 +7,7 @@
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:foreground="?attr/selectableItemBackground"
android:textAllCaps="true" android:textAllCaps="true"
osmand:typeface="@string/font_roboto_medium" osmand:typeface="@string/font_roboto_medium"
android:textColor="@color/color_white" android:textColor="@color/color_white"

View file

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
osmand:layout_scrollFlags="scroll|enterAlways"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
osmand:contentInsetLeft="0dp"
osmand:contentInsetStart="0dp"
osmand:contentInsetRight="0dp"
osmand:contentInsetEnd="0dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dashboard_map_toolbar"
android:gravity="center_vertical">
<ImageButton
android:id="@+id/back_button"
style="@style/Widget.AppCompat.ActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:src="@drawable/ic_arrow_back"/>
<View
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/select_language_text_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="@dimen/content_padding_small"
android:layout_marginTop="@dimen/content_padding_small"
android:layout_marginLeft="@dimen/context_menu_padding_margin_small"
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
tools:background="?attr/ctx_menu_controller_bg"
android:gravity="center_vertical"
android:padding="@dimen/context_menu_padding_margin_tiny"
android:textAllCaps="true"
tools:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="RU"/>
</LinearLayout>
<TextView
android:id="@+id/title_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingTop="@dimen/list_header_padding"
android:paddingBottom="@dimen/list_header_padding"
android:textSize="@dimen/map_button_text_size"
tools:text="Title"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
osmand:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/content_padding"/>
</android.support.v4.widget.NestedScrollView>
<net.osmand.plus.widgets.TextViewEx
osmand:typeface="@string/font_roboto_medium"
android:layout_margin="@dimen/content_padding"
android:id="@+id/read_full_article"
android:layout_gravity="bottom|center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:background="@drawable/bt_round_long_night"
android:text="@string/read_full_article"
android:gravity="center_vertical"
android:textAllCaps="true"
tools:textColor="?attr/ctx_menu_controller_text_color"/>
</android.support.design.widget.CoordinatorLayout>

View file

@ -175,4 +175,9 @@
<dimen name="multi_selection_header_height">78dp</dimen> <dimen name="multi_selection_header_height">78dp</dimen>
<dimen name="wikipedia_button_left_padding">29dp</dimen>
<dimen name="multi_selection_menu_padding_top">20dp</dimen>
<dimen name="multi_selection_menu_padding_bottom">23dp</dimen>
</resources> </resources>

View file

@ -25,6 +25,7 @@
<attr name="bg_point_editor_view" format="reference" /> <attr name="bg_point_editor_view" format="reference" />
<attr name="ctx_menu_info_view_bg" format="reference" /> <attr name="ctx_menu_info_view_bg" format="reference" />
<attr name="ctx_menu_controller_bg" format="reference" /> <attr name="ctx_menu_controller_bg" format="reference" />
<attr name="ctx_menu_controller_text_color" format="reference" />
<attr name="ctx_menu_divider" format="reference" /> <attr name="ctx_menu_divider" format="reference" />
<attr name="bottom_menu_view_bg" format="reference" /> <attr name="bottom_menu_view_bg" format="reference" />
<attr name="left_menu_view_bg" format="reference" /> <attr name="left_menu_view_bg" format="reference" />

View file

@ -341,7 +341,7 @@
<color name="ctx_menu_bottom_view_bg_light">#ffffff</color> <color name="ctx_menu_bottom_view_bg_light">#ffffff</color>
<color name="ctx_menu_bottom_view_bg_dark">#17191a</color> <color name="ctx_menu_bottom_view_bg_dark">#17191a</color>
<color name="ctx_menu_bottom_view_icon_light">#b3b3b3</color> <color name="ctx_menu_bottom_view_icon_light">#b3b3b3</color>
<color name="ctx_menu_bottom_view_icon_dark">#536dfe</color> <color name="ctx_menu_bottom_view_icon_dark">#454a4d</color>
<color name="ctx_menu_bottom_view_text_color_light">#212121</color> <color name="ctx_menu_bottom_view_text_color_light">#212121</color>
<color name="ctx_menu_bottom_view_text_color_dark">#cccccc</color> <color name="ctx_menu_bottom_view_text_color_dark">#cccccc</color>
<color name="ctx_menu_bottom_view_secondary_text_color_light">#a6a6a6</color> <color name="ctx_menu_bottom_view_secondary_text_color_light">#a6a6a6</color>
@ -349,9 +349,11 @@
<color name="ctx_menu_amenity_opened_text_color">#5baf3f</color> <color name="ctx_menu_amenity_opened_text_color">#5baf3f</color>
<color name="ctx_menu_amenity_closed_text_color">#c66545</color> <color name="ctx_menu_amenity_closed_text_color">#c66545</color>
<color name="ctx_menu_bottom_view_divider_light">#f2f2f2</color> <color name="ctx_menu_bottom_view_divider_light">#f2f2f2</color>
<color name="ctx_menu_bottom_view_divider_dark">#536dfe</color> <color name="ctx_menu_bottom_view_divider_dark">#222526</color>
<color name="ctx_menu_bottom_view_url_color_light">#536dfe</color> <color name="ctx_menu_bottom_view_url_color_light">#536dfe</color>
<color name="ctx_menu_bottom_view_url_color_dark">#d28521</color> <color name="ctx_menu_bottom_view_url_color_dark">#d28521</color>
<color name="ctx_menu_controller_disabled_text_color_light">#b3b3b3</color>
<color name="ctx_menu_controller_disabled_text_color_dark">#666666</color>
<color name="route_info_bg_light">#ffffff</color> <color name="route_info_bg_light">#ffffff</color>
<color name="route_info_bg_dark">#17191a</color> <color name="route_info_bg_dark">#17191a</color>
@ -371,4 +373,9 @@
<color name="route_info_checked_mode_icon_color_dark">#d28521</color> <color name="route_info_checked_mode_icon_color_dark">#d28521</color>
<color name="route_info_unchecked_mode_icon_color">#727272</color> <color name="route_info_unchecked_mode_icon_color">#727272</color>
<color name="multi_selection_menu_divider_light">#f0f0f0</color>
<color name="multi_selection_menu_divider_dark">#222526</color>
<color name="multi_selection_menu_close_btn_light">#2f7af5</color>
<color name="multi_selection_menu_close_btn_dark">#e69122</color>
</resources> </resources>

View file

@ -247,4 +247,9 @@
<dimen name="route_info_modes_height">48dp</dimen> <dimen name="route_info_modes_height">48dp</dimen>
<dimen name="multi_selection_header_height">52dp</dimen> <dimen name="multi_selection_header_height">52dp</dimen>
<dimen name="wikipedia_button_left_padding">19dp</dimen>
<dimen name="multi_selection_menu_padding_top">13dp</dimen>
<dimen name="multi_selection_menu_padding_bottom">15dp</dimen>
</resources> </resources>

View file

@ -132,6 +132,7 @@
<item name="dashboard_button">@drawable/dashboard_button_light</item> <item name="dashboard_button">@drawable/dashboard_button_light</item>
<item name="ctx_menu_info_view_bg">@color/ctx_menu_info_view_bg_light</item> <item name="ctx_menu_info_view_bg">@color/ctx_menu_info_view_bg_light</item>
<item name="ctx_menu_controller_bg">@drawable/context_menu_controller_bg_light</item> <item name="ctx_menu_controller_bg">@drawable/context_menu_controller_bg_light</item>
<item name="ctx_menu_controller_text_color">@drawable/context_menu_controller_text_color_light</item>
<item name="ctx_menu_divider">@color/ctx_menu_buttons_divider_light</item> <item name="ctx_menu_divider">@color/ctx_menu_buttons_divider_light</item>
<item name="search_background">@color/search_background_dark</item> <item name="search_background">@color/search_background_dark</item>
<item name="actionModeCloseDrawable">@drawable/ic_action_mode_back</item> <item name="actionModeCloseDrawable">@drawable/ic_action_mode_back</item>
@ -321,6 +322,7 @@
<item name="dashboard_button">@drawable/dashboard_button_dark</item> <item name="dashboard_button">@drawable/dashboard_button_dark</item>
<item name="ctx_menu_info_view_bg">@color/ctx_menu_info_view_bg_dark</item> <item name="ctx_menu_info_view_bg">@color/ctx_menu_info_view_bg_dark</item>
<item name="ctx_menu_controller_bg">@drawable/context_menu_controller_bg_dark</item> <item name="ctx_menu_controller_bg">@drawable/context_menu_controller_bg_dark</item>
<item name="ctx_menu_controller_text_color">@drawable/context_menu_controller_text_color_dark</item>
<item name="ctx_menu_divider">@color/ctx_menu_buttons_divider_dark</item> <item name="ctx_menu_divider">@color/ctx_menu_buttons_divider_dark</item>
<item name="search_background">@color/color_white</item> <item name="search_background">@color/color_white</item>
<item name="switch_ex_background">@drawable/switch_ex_background_dark</item> <item name="switch_ex_background">@drawable/switch_ex_background_dark</item>

View file

@ -4,6 +4,7 @@ package net.osmand;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.PointF; import android.graphics.PointF;
@ -11,6 +12,7 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable; import android.graphics.drawable.StateListDrawable;
import android.os.Build; import android.os.Build;
import android.os.IBinder; import android.os.IBinder;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.text.TextUtils; import android.text.TextUtils;
@ -118,6 +120,21 @@ public class AndroidUtils {
return null; return null;
} }
public static ColorStateList createColorStateList(Context ctx, boolean night,
@ColorRes int lightNormal, @ColorRes int lightPressed,
@ColorRes int darkNormal, @ColorRes int darkPressed) {
return new ColorStateList(
new int[][]{
new int[]{android.R.attr.state_pressed},
new int[]{}
},
new int[]{
ContextCompat.getColor(ctx, night ? darkPressed : lightPressed),
ContextCompat.getColor(ctx, night ? darkNormal : lightNormal)
}
);
}
public static StateListDrawable createStateListDrawable(Context ctx, boolean night, public static StateListDrawable createStateListDrawable(Context ctx, boolean night,
@DrawableRes int lightNormal, @DrawableRes int lightPressed, @DrawableRes int lightNormal, @DrawableRes int lightPressed,
@DrawableRes int darkNormal, @DrawableRes int darkPressed) { @DrawableRes int darkNormal, @DrawableRes int darkPressed) {
@ -198,6 +215,12 @@ public class AndroidUtils {
); );
} }
public static int resolveAttribute(Context ctx, int attribute) {
TypedValue outValue = new TypedValue();
ctx.getTheme().resolveAttribute(attribute, outValue, true);
return outValue.resourceId;
}
public static int getStatusBarHeight(Context ctx) { public static int getStatusBarHeight(Context ctx) {
int result = 0; int result = 0;
int resourceId = ctx.getResources().getIdentifier("status_bar_height", "dimen", "android"); int resourceId = ctx.getResources().getIdentifier("status_bar_height", "dimen", "android");

View file

@ -842,9 +842,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
boolean mapControlsVisible = findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE; boolean mapControlsVisible = findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE;
boolean night = app.getDaynightHelper().isNightModeForMapControls(); boolean night = app.getDaynightHelper().isNightModeForMapControls();
boolean quickSearchTopBar = getTopToolbarController(TopToolbarControllerType.QUICK_SEARCH) != null; boolean quickSearchTopBar = getTopToolbarController(TopToolbarControllerType.QUICK_SEARCH) != null;
boolean contextMenuTopBar = getTopToolbarController(TopToolbarControllerType.CONTEXT_MENU) != null;
boolean mapTopBar = findViewById(R.id.map_top_bar).getVisibility() == View.VISIBLE; boolean mapTopBar = findViewById(R.id.map_top_bar).getVisibility() == View.VISIBLE;
boolean markerTopBar = findViewById(R.id.map_markers_top_bar).getVisibility() == View.VISIBLE; boolean markerTopBar = findViewById(R.id.map_markers_top_bar).getVisibility() == View.VISIBLE;
if ((quickSearchTopBar || mapTopBar) && mapControlsVisible) { if (((quickSearchTopBar || mapTopBar) && mapControlsVisible) || contextMenuTopBar) {
colorId = night ? R.color.status_bar_route_dark : R.color.status_bar_route_light; colorId = night ? R.color.status_bar_route_dark : R.color.status_bar_route_light;
} else if (markerTopBar && mapControlsVisible) { } else if (markerTopBar && mapControlsVisible) {
colorId = R.color.status_bar_dark; colorId = R.color.status_bar_dark;
@ -1885,11 +1886,13 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
public void showTopToolbar(TopToolbarController controller) { public void showTopToolbar(TopToolbarController controller) {
MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer(); MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer();
mapInfoLayer.addTopToolbarController(controller); mapInfoLayer.addTopToolbarController(controller);
updateStatusBarColor();
} }
public void hideTopToolbar(TopToolbarController controller) { public void hideTopToolbar(TopToolbarController controller) {
MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer(); MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer();
mapInfoLayer.removeTopToolbarController(controller); mapInfoLayer.removeTopToolbarController(controller);
updateStatusBarColor();
} }
public void registerActivityResultListener(ActivityResultListener listener) { public void registerActivityResultListener(ActivityResultListener listener) {

View file

@ -78,7 +78,7 @@ public class AppModeDialog {
} else { } else {
if (useMapTheme) { if (useMapTheme) {
iv.setImageDrawable(ctx.getIconsCache().getIcon(mode.getSmallIconDark(), R.color.route_info_unchecked_mode_icon_color)); iv.setImageDrawable(ctx.getIconsCache().getIcon(mode.getSmallIconDark(), R.color.route_info_unchecked_mode_icon_color));
AndroidUtils.setBackground(ctx, iv, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); iv.setBackgroundResource(AndroidUtils.resolveAttribute(ctx, android.R.attr.selectableItemBackground));
} else { } else {
iv.setImageDrawable(ctx.getIconsCache().getThemedIcon(mode.getSmallIconDark())); iv.setImageDrawable(ctx.getIconsCache().getThemedIcon(mode.getSmallIconDark()));
} }

View file

@ -42,7 +42,7 @@ public class AudioVideoNoteMenuBuilder extends MenuBuilder {
DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(view.getContext()); DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(view.getContext());
DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext()); DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext());
Date date = new Date(recording.getFile().lastModified()); Date date = new Date(recording.getFile().lastModified());
buildRow(view, R.drawable.ic_action_data, dateFormat.format(date) + "" + timeFormat.format(date), buildRow(view, R.drawable.ic_action_data, null, dateFormat.format(date) + "" + timeFormat.format(date),
0, false, null, false, 0, false, null, false); 0, false, null, false, 0, false, null, false);
buildPlainMenuItems(view); buildPlainMenuItems(view);

View file

@ -86,7 +86,7 @@ public class AudioVideoNoteMenuController extends MenuController {
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
if (mRecording.isPhoto()) { if (mRecording.isPhoto()) {
return getIcon(R.drawable.ic_action_photo_dark, R.color.audio_video_icon_color); return getIcon(R.drawable.ic_action_photo_dark, R.color.audio_video_icon_color);
} else if (mRecording.isAudio()) { } else if (mRecording.isAudio()) {

View file

@ -3,6 +3,7 @@ package net.osmand.plus.mapcontextmenu;
import android.app.Dialog; import android.app.Dialog;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
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.Fragment; import android.support.v4.app.Fragment;
@ -37,7 +38,7 @@ import net.osmand.plus.mapcontextmenu.MenuController.MenuType;
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController; import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController; import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
import net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController; import net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute; import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
import net.osmand.plus.mapcontextmenu.editors.PointEditor; import net.osmand.plus.mapcontextmenu.editors.PointEditor;
import net.osmand.plus.mapcontextmenu.editors.RtePtEditor; import net.osmand.plus.mapcontextmenu.editors.RtePtEditor;
@ -418,7 +419,10 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
} }
public boolean navigateInPedestrianMode() { public boolean navigateInPedestrianMode() {
return menuController instanceof ParkingPositionMenuController; if (menuController != null) {
return menuController.navigateInPedestrianMode();
}
return false;
} }
public boolean close() { public boolean close() {
@ -597,7 +601,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
historyStack.add(menuData); historyStack.add(menuData);
} }
if (!(menuController instanceof MapDataMenuController)) { if (!(menuController instanceof MapDataMenuController)) {
menuController.buildMapDownloadButton(latLon); menuController.buildMapDownloadButtonAndSizeInfo(latLon);
} }
return true; return true;
} else { } else {
@ -1135,13 +1139,37 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
return menuController != null && menuController.displayDistanceDirection(); return menuController != null && menuController.displayDistanceDirection();
} }
public boolean displayAdditionalTypeStrInHours() { public String getSubtypeStr() {
return menuController != null && menuController.displayAdditionalTypeStrInHours(); if (menuController != null) {
return menuController.getSubtypeStr();
}
return "";
} }
public int getTimeStrColor() { public Drawable getSubtypeIcon() {
if (menuController != null) { if (menuController != null) {
return menuController.getTimeStrColor(); return menuController.getSubtypeIcon();
}
return null;
}
public int getAdditionalInfoColor() {
if (menuController != null) {
return menuController.getAdditionalInfoColor();
}
return 0;
}
public String getAdditionalInfo() {
if (menuController != null) {
return menuController.getAdditionalInfoStr();
}
return "";
}
public int getAdditionalInfoIconRes() {
if (menuController != null) {
return menuController.getAdditionalInfoIconRes();
} }
return 0; return 0;
} }

View file

@ -14,6 +14,7 @@ import android.support.v4.content.ContextCompat;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.GestureDetector; import android.view.GestureDetector;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.VelocityTracker; import android.view.VelocityTracker;
@ -34,6 +35,7 @@ import android.widget.TextView;
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.PointDescription;
import net.osmand.data.QuadPoint; import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -46,10 +48,11 @@ import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.mapcontextmenu.MenuController.MenuState; import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController; import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController; import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute; import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu; import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.TransportStopsLayer;
import net.osmand.plus.views.controls.HorizontalSwipeConfirm; import net.osmand.plus.views.controls.HorizontalSwipeConfirm;
import net.osmand.plus.views.controls.SingleTapConfirm; import net.osmand.plus.views.controls.SingleTapConfirm;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -198,8 +201,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
}); });
// Bottom title button // Bottom title button
final View bottomTitleButton = view.findViewById(R.id.title_button_bottom_view); final View bottomTitleButtonView = view.findViewById(R.id.title_button_bottom_view);
bottomTitleButton.setOnClickListener(new View.OnClickListener() { bottomTitleButtonView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
TitleButtonController bottomTitleButtonController = menu.getBottomTitleButtonController(); TitleButtonController bottomTitleButtonController = menu.getBottomTitleButtonController();
@ -211,8 +214,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
// Progress bar // Progress bar
final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton); final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton);
progressButton.setImageDrawable(getIcon(R.drawable.ic_action_remove_dark, progressButton.setImageDrawable(getIcon(R.drawable.ic_action_remove_dark, R.color.ctx_menu_buttons_icon_color));
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
progressButton.setOnClickListener(new View.OnClickListener() { progressButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -388,7 +390,22 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
GridView transportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_routes_grid); GridView transportStopRoutesGrid = (GridView) view.findViewById(R.id.transport_stop_routes_grid);
List<TransportStopRoute> transportStopRoutes = menu.getTransportStopRoutes(); List<TransportStopRoute> transportStopRoutes = menu.getTransportStopRoutes();
if (transportStopRoutes != null && transportStopRoutes.size() > 0) { if (transportStopRoutes != null && transportStopRoutes.size() > 0) {
TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getContext(), transportStopRoutes); final TransportStopRouteAdapter adapter = new TransportStopRouteAdapter(getMyApplication(), transportStopRoutes, nightMode);
adapter.setListener(new TransportStopRouteAdapter.OnClickListener() {
@Override
public void onClick(int position) {
TransportStopRoute route = adapter.getItem(position);
if (route != null) {
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE,
route.getDescription(getMapActivity().getMyApplication(), false));
menu.show(menu.getLatLon(), pd, route);
TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
stopsLayer.setRoute(route);
int cz = route.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox());
getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
}
}
});
transportStopRoutesGrid.setAdapter(adapter); transportStopRoutesGrid.setAdapter(adapter);
transportStopRoutesGrid.setVisibility(View.VISIBLE); transportStopRoutesGrid.setVisibility(View.VISIBLE);
} else { } else {
@ -513,6 +530,23 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
return view; return view;
} }
private void toggleDetailsHideButton() {
int menuState = menu.getCurrentMenuState();
final boolean showShowHideButton = menuState == MenuState.HALF_SCREEN || (!menu.isLandscapeLayout() && menuState == MenuState.FULL_SCREEN);
TextView detailsButton = (TextView) view.findViewById(R.id.context_menu_details_button);
detailsButton.setText(showShowHideButton ? R.string.shared_string_collapse : R.string.description);
detailsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (showShowHideButton) {
openMenuHeaderOnly();
} else {
openMenuFullScreen();
}
}
});
}
private void deactivate(View view) { private void deactivate(View view) {
view.setEnabled(false); view.setEnabled(false);
view.setAlpha(0.5f); view.setAlpha(0.5f);
@ -547,6 +581,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
changeMenuState(getViewY(), true, true, false); changeMenuState(getViewY(), true, true, false);
} }
public void openMenuHeaderOnly() {
changeMenuState(getViewY(), true, false, true);
}
public void openMenuHalfScreen() { public void openMenuHalfScreen() {
int oldMenuState = menu.getCurrentMenuState(); int oldMenuState = menu.getCurrentMenuState();
if (oldMenuState == MenuState.HEADER_ONLY) { if (oldMenuState == MenuState.HEADER_ONLY) {
@ -579,6 +617,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
restoreCustomMapRatio(); restoreCustomMapRatio();
menu.updateControlsVisibility(true); menu.updateControlsVisibility(true);
doBeforeMenuStateChange(oldMenuState, newMenuState); doBeforeMenuStateChange(oldMenuState, newMenuState);
toggleDetailsHideButton();
} }
applyPosY(currentY, needCloseMenu, needMapAdjust, oldMenuState, newMenuState, 0); applyPosY(currentY, needCloseMenu, needMapAdjust, oldMenuState, newMenuState, 0);
@ -675,7 +714,22 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
origMarkerY = box.getCenterPixelY(); origMarkerY = box.getCenterPixelY();
} }
private void updateButtonsAndProgress() { private void enableDisableButtons(View buttonView, TextView button, boolean enabled) {
if (enabled) {
ColorStateList buttonColorStateList = AndroidUtils.createColorStateList(getContext(), nightMode,
R.color.ctx_menu_controller_button_text_color_light_n, R.color.ctx_menu_controller_button_text_color_light_p,
R.color.ctx_menu_controller_button_text_color_dark_n, R.color.ctx_menu_controller_button_text_color_dark_p);
buttonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light);
button.setTextColor(buttonColorStateList);
} else {
buttonView.setBackgroundResource(nightMode ? R.drawable.context_menu_controller_disabled_bg_dark: R.drawable.context_menu_controller_disabled_bg_light);
button.setTextColor(ContextCompat.getColor(getContext(), nightMode ? R.color.ctx_menu_controller_disabled_text_color_dark : R.color.ctx_menu_controller_disabled_text_color_light));
}
button.setEnabled(enabled);
}
public void updateButtonsAndProgress() {
if (view != null) { if (view != null) {
TitleButtonController leftTitleButtonController = menu.getLeftTitleButtonController(); TitleButtonController leftTitleButtonController = menu.getLeftTitleButtonController();
TitleButtonController rightTitleButtonController = menu.getRightTitleButtonController(); TitleButtonController rightTitleButtonController = menu.getRightTitleButtonController();
@ -684,10 +738,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
TitleButtonController rightDownloadButtonController = menu.getRightDownloadButtonController(); TitleButtonController rightDownloadButtonController = menu.getRightDownloadButtonController();
TitleProgressController titleProgressController = menu.getTitleProgressController(); TitleProgressController titleProgressController = menu.getTitleProgressController();
ColorStateList textColorStateList = ContextCompat.getColorStateList(getContext(),
nightMode ? R.color.context_menu_controller_text_color_dark : R.color.context_menu_controller_text_color_light);
int buttonViewBackgroundResId = nightMode ? R.drawable.context_menu_controller_bg_dark : R.drawable.context_menu_controller_bg_light;
// Title buttons // Title buttons
boolean showTitleButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null); boolean showTitleButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null);
final View titleButtonsContainer = view.findViewById(R.id.title_button_container); final View titleButtonsContainer = view.findViewById(R.id.title_button_container);
@ -698,16 +748,15 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
final TextView leftTitleButton = (TextView) view.findViewById(R.id.title_button); final TextView leftTitleButton = (TextView) view.findViewById(R.id.title_button);
final TextView titleButtonRightText = (TextView) view.findViewById(R.id.title_button_right_text); final TextView titleButtonRightText = (TextView) view.findViewById(R.id.title_button_right_text);
if (leftTitleButtonController != null) { if (leftTitleButtonController != null) {
enableDisableButtons(leftTitleButtonView, leftTitleButton, leftTitleButtonController.enabled);
leftTitleButton.setText(leftTitleButtonController.caption); leftTitleButton.setText(leftTitleButtonController.caption);
leftTitleButton.setTextColor(textColorStateList);
if (leftTitleButtonController.visible) { if (leftTitleButtonController.visible) {
leftTitleButtonView.setVisibility(View.VISIBLE); leftTitleButtonView.setVisibility(View.VISIBLE);
leftTitleButtonView.setBackgroundResource(buttonViewBackgroundResId);
Drawable leftIcon = leftTitleButtonController.getLeftIcon(); Drawable leftIcon = leftTitleButtonController.getLeftIcon();
if (leftIcon != null) { Drawable rightIcon = leftTitleButtonController.getRightIcon();
leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null); leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
leftTitleButton.setCompoundDrawablePadding(dpToPx(8f)); leftTitleButton.setCompoundDrawablePadding(dpToPx(8f));
} ((LinearLayout) leftTitleButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
if (leftTitleButtonController.needRightText) { if (leftTitleButtonController.needRightText) {
titleButtonRightText.setText(leftTitleButtonController.rightTextCaption); titleButtonRightText.setText(leftTitleButtonController.rightTextCaption);
@ -727,16 +776,15 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
final View rightTitleButtonView = view.findViewById(R.id.title_button_right_view); final View rightTitleButtonView = view.findViewById(R.id.title_button_right_view);
final TextView rightTitleButton = (TextView) view.findViewById(R.id.title_button_right); final TextView rightTitleButton = (TextView) view.findViewById(R.id.title_button_right);
if (rightTitleButtonController != null) { if (rightTitleButtonController != null) {
enableDisableButtons(rightTitleButtonView, rightTitleButton, rightTitleButtonController.enabled);
rightTitleButton.setText(rightTitleButtonController.caption); rightTitleButton.setText(rightTitleButtonController.caption);
rightTitleButton.setTextColor(textColorStateList);
rightTitleButtonView.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE); rightTitleButtonView.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
if (rightTitleButtonController.visible) {
rightTitleButtonView.setBackgroundResource(buttonViewBackgroundResId);
}
Drawable leftIcon = rightTitleButtonController.getLeftIcon(); Drawable leftIcon = rightTitleButtonController.getLeftIcon();
rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null); Drawable rightIcon = rightTitleButtonController.getRightIcon();
rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
rightTitleButton.setCompoundDrawablePadding(dpToPx(8f)); rightTitleButton.setCompoundDrawablePadding(dpToPx(8f));
((LinearLayout) rightTitleButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
} else { } else {
rightTitleButtonView.setVisibility(View.INVISIBLE); rightTitleButtonView.setVisibility(View.INVISIBLE);
} }
@ -745,16 +793,15 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
final View bottomTitleButtonView = view.findViewById(R.id.title_button_bottom_view); final View bottomTitleButtonView = view.findViewById(R.id.title_button_bottom_view);
final TextView bottomTitleButton = (TextView) view.findViewById(R.id.title_button_bottom); final TextView bottomTitleButton = (TextView) view.findViewById(R.id.title_button_bottom);
if (bottomTitleButtonController != null) { if (bottomTitleButtonController != null) {
enableDisableButtons(bottomTitleButtonView, bottomTitleButton, bottomTitleButtonController.enabled);
bottomTitleButton.setText(bottomTitleButtonController.caption); bottomTitleButton.setText(bottomTitleButtonController.caption);
bottomTitleButton.setTextColor(textColorStateList);
bottomTitleButtonView.setVisibility(bottomTitleButtonController.visible ? View.VISIBLE : View.GONE); bottomTitleButtonView.setVisibility(bottomTitleButtonController.visible ? View.VISIBLE : View.GONE);
if (bottomTitleButtonController.visible) {
bottomTitleButtonView.setBackgroundResource(buttonViewBackgroundResId);
}
Drawable leftIcon = bottomTitleButtonController.getLeftIcon(); Drawable leftIcon = bottomTitleButtonController.getLeftIcon();
bottomTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null); Drawable rightIcon = bottomTitleButtonController.getRightIcon();
bottomTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
bottomTitleButton.setCompoundDrawablePadding(dpToPx(8f)); bottomTitleButton.setCompoundDrawablePadding(dpToPx(8f));
((LinearLayout) bottomTitleButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
} else { } else {
bottomTitleButtonView.setVisibility(View.GONE); bottomTitleButtonView.setVisibility(View.GONE);
} }
@ -771,18 +818,15 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
final View leftDownloadButtonView = view.findViewById(R.id.download_button_left_view); final View leftDownloadButtonView = view.findViewById(R.id.download_button_left_view);
final TextView leftDownloadButton = (TextView) view.findViewById(R.id.download_button_left); final TextView leftDownloadButton = (TextView) view.findViewById(R.id.download_button_left);
if (leftDownloadButtonController != null) { if (leftDownloadButtonController != null) {
enableDisableButtons(leftDownloadButtonView, leftDownloadButton, leftDownloadButtonController.enabled);
leftDownloadButton.setText(leftDownloadButtonController.caption); leftDownloadButton.setText(leftDownloadButtonController.caption);
leftDownloadButton.setTextColor(textColorStateList);
leftDownloadButtonView.setVisibility(leftDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE); leftDownloadButtonView.setVisibility(leftDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
if (leftDownloadButtonController.visible) {
leftDownloadButtonView.setBackgroundResource(buttonViewBackgroundResId);
}
Drawable leftIcon = leftDownloadButtonController.getLeftIcon(); Drawable leftIcon = leftDownloadButtonController.getLeftIcon();
if (leftIcon != null) { Drawable rightIcon = leftDownloadButtonController.getRightIcon();
leftDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null); leftDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
leftDownloadButton.setCompoundDrawablePadding(dpToPx(8f)); leftDownloadButton.setCompoundDrawablePadding(dpToPx(8f));
} ((LinearLayout) leftDownloadButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
} else { } else {
leftDownloadButtonView.setVisibility(View.INVISIBLE); leftDownloadButtonView.setVisibility(View.INVISIBLE);
} }
@ -791,16 +835,15 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
final View rightDownloadButtonView = view.findViewById(R.id.download_button_right_view); final View rightDownloadButtonView = view.findViewById(R.id.download_button_right_view);
final TextView rightDownloadButton = (TextView) view.findViewById(R.id.download_button_right); final TextView rightDownloadButton = (TextView) view.findViewById(R.id.download_button_right);
if (rightDownloadButtonController != null) { if (rightDownloadButtonController != null) {
enableDisableButtons(rightDownloadButtonView, rightDownloadButton, rightDownloadButtonController.enabled);
rightDownloadButton.setText(rightDownloadButtonController.caption); rightDownloadButton.setText(rightDownloadButtonController.caption);
rightDownloadButton.setTextColor(textColorStateList);
rightDownloadButtonView.setVisibility(rightDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE); rightDownloadButtonView.setVisibility(rightDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
if (rightDownloadButtonController.visible) {
rightDownloadButtonView.setBackgroundResource(buttonViewBackgroundResId);
}
Drawable leftIcon = rightDownloadButtonController.getLeftIcon(); Drawable leftIcon = rightDownloadButtonController.getLeftIcon();
rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null); Drawable rightIcon = rightDownloadButtonController.getRightIcon();
rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
rightDownloadButton.setCompoundDrawablePadding(dpToPx(8f)); rightDownloadButton.setCompoundDrawablePadding(dpToPx(8f));
((LinearLayout) rightDownloadButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
} else { } else {
rightDownloadButtonView.setVisibility(View.INVISIBLE); rightDownloadButtonView.setVisibility(View.INVISIBLE);
} }
@ -835,8 +878,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
if (app != null && view != null) { if (app != null && view != null) {
final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view); final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view);
Drawable icon = menu.getLeftIcon(); Drawable icon = menu.getRightIcon();
int iconId = menu.getLeftIconId(); int iconId = menu.getRightIconId();
if (icon != null) { if (icon != null) {
iconView.setImageDrawable(icon); iconView.setImageDrawable(icon);
iconView.setVisibility(View.VISIBLE); iconView.setVisibility(View.VISIBLE);
@ -929,8 +972,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
OsmandApplication app = getMyApplication(); OsmandApplication app = getMyApplication();
if (app != null && view != null) { if (app != null && view != null) {
final ImageView buttonFavorite = (ImageView) view.findViewById(R.id.context_menu_fav_image_view); final ImageView buttonFavorite = (ImageView) view.findViewById(R.id.context_menu_fav_image_view);
buttonFavorite.setImageDrawable(getIcon(menu.getFavActionIconId(), buttonFavorite.setImageDrawable(getIcon(menu.getFavActionIconId(), R.color.ctx_menu_buttons_icon_color));
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
String favActionString = getString(menu.getFavActionStringId()); String favActionString = getString(menu.getFavActionStringId());
buttonFavorite.setContentDescription(favActionString); buttonFavorite.setContentDescription(favActionString);
((TextView) view.findViewById(R.id.context_menu_fav_text_view)).setText(favActionString); ((TextView) view.findViewById(R.id.context_menu_fav_text_view)).setText(favActionString);
@ -945,6 +987,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
this.initLayout = true; this.initLayout = true;
this.centered = true; this.centered = true;
} }
updateButtonsAndProgress();
runLayoutListener(); runLayoutListener();
} }
} }
@ -1132,61 +1175,43 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} }
line2Str.append(streetStr); line2Str.append(streetStr);
} }
if (!TextUtils.isEmpty(line2Str)) {
line2.setText(line2Str.toString()); line2.setText(line2Str.toString());
line2.setVisibility(View.VISIBLE);
} else {
line2.setVisibility(View.GONE);
}
} }
TextView line3 = (TextView) view.findViewById(R.id.context_menu_line3); TextView line3 = (TextView) view.findViewById(R.id.context_menu_line3);
String additionalTypeStr = menu.getAdditionalTypeStr(); String subtypeStr = menu.getSubtypeStr();
boolean displayAdditionalTypeStrInHours = menu.displayAdditionalTypeStrInHours(); if (TextUtils.isEmpty(subtypeStr)) {
boolean emptyAdditionalTypeStr = TextUtils.isEmpty(additionalTypeStr);
if (emptyAdditionalTypeStr || displayAdditionalTypeStrInHours) {
line3.setVisibility(View.GONE); line3.setVisibility(View.GONE);
} else { } else {
line3.setVisibility(View.VISIBLE); line3.setVisibility(View.VISIBLE);
line3.setText(additionalTypeStr); line3.setText(subtypeStr);
Drawable icon = menu.getAdditionalLineTypeIcon(); Drawable icon = menu.getSubtypeIcon();
line3.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); line3.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
line3.setCompoundDrawablePadding(dpToPx(5f)); line3.setCompoundDrawablePadding(dpToPx(5f));
} }
TextView openingHoursTextView = (TextView) view.findViewById(R.id.opening_hours_text_view); TextView additionalInfoTextView = (TextView) view.findViewById(R.id.additional_info_text_view);
OpeningHoursInfo openingHoursInfo = menu.getOpeningHoursInfo(); String additionalInfoStr = menu.getAdditionalInfo();
boolean containsOpeningHours = openingHoursInfo != null && openingHoursInfo.containsInfo(); if (!TextUtils.isEmpty(additionalInfoStr)) {
if (containsOpeningHours || (displayAdditionalTypeStrInHours && !emptyAdditionalTypeStr)) { int colorId = menu.getAdditionalInfoColor();
int colorId; int additionalInfoIconRes = menu.getAdditionalInfoIconRes();
if (containsOpeningHours) {
colorId = openingHoursInfo.isOpened() ? R.color.ctx_menu_amenity_opened_text_color : R.color.ctx_menu_amenity_closed_text_color;
} else {
colorId = menu.getTimeStrColor();
}
String timeInfo = "";
if (containsOpeningHours) {
if (openingHoursInfo.isOpened24_7()) {
timeInfo = getString(R.string.shared_string_is_open_24_7);
} else if (!Algorithms.isEmpty(openingHoursInfo.getNearToOpeningTime())) {
timeInfo = getString(R.string.will_open_at) + " " + openingHoursInfo.getNearToOpeningTime();
} else if (!Algorithms.isEmpty(openingHoursInfo.getOpeningTime())) {
timeInfo = getString(R.string.open_from) + " " + openingHoursInfo.getOpeningTime();
} else if (!Algorithms.isEmpty(openingHoursInfo.getNearToClosingTime())) {
timeInfo = getString(R.string.will_close_at) + " " + openingHoursInfo.getNearToClosingTime();
} else if (!Algorithms.isEmpty(openingHoursInfo.getClosingTime())) {
timeInfo = getString(R.string.open_till) + " " + openingHoursInfo.getClosingTime();
} else if (!Algorithms.isEmpty(openingHoursInfo.getOpeningDay())) {
timeInfo = getString(R.string.will_open_on) + " " + openingHoursInfo.getOpeningDay() + ".";
}
} else {
timeInfo = additionalTypeStr;
}
if (colorId != 0) { if (colorId != 0) {
openingHoursTextView.setTextColor(ContextCompat.getColor(getContext(), colorId)); additionalInfoTextView.setTextColor(ContextCompat.getColor(getContext(), colorId));
Drawable drawable = getIcon(R.drawable.ic_action_opening_hour_16, colorId); if (additionalInfoIconRes != 0) {
openingHoursTextView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null); Drawable additionalIcon = getIcon(additionalInfoIconRes, colorId);
openingHoursTextView.setCompoundDrawablePadding(dpToPx(8)); additionalInfoTextView.setCompoundDrawablesWithIntrinsicBounds(additionalIcon, null, null, null);
additionalInfoTextView.setCompoundDrawablePadding(dpToPx(8));
} }
openingHoursTextView.setText(timeInfo); }
openingHoursTextView.setVisibility(View.VISIBLE); additionalInfoTextView.setText(additionalInfoStr);
additionalInfoTextView.setVisibility(View.VISIBLE);
} else { } else {
openingHoursTextView.setVisibility(View.GONE); additionalInfoTextView.setVisibility(View.GONE);
} }
} }
updateCompassVisibility(); updateCompassVisibility();
@ -1482,7 +1507,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
boolean progressVisible = menu.getTitleProgressController() != null && menu.getTitleProgressController().visible; boolean progressVisible = menu.getTitleProgressController() != null && menu.getTitleProgressController().visible;
updateButtonsAndProgress(); updateButtonsAndProgress();
if (wasProgressVisible != progressVisible) { if (wasProgressVisible != progressVisible) {
runLayoutListener(); refreshTitle();
} }
} }
} }
@ -1491,7 +1516,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
if (created) { if (created) {
menu.updateData(); menu.updateData();
updateButtonsAndProgress(); updateButtonsAndProgress();
runLayoutListener(); refreshTitle();
} }
} }

View file

@ -5,8 +5,10 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
@ -17,7 +19,6 @@ import android.text.TextUtils;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -27,6 +28,7 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.binary.BinaryMapIndexReader; import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.Amenity; import net.osmand.data.Amenity;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
@ -51,7 +53,7 @@ import net.osmand.plus.mapcontextmenu.builders.cards.CardsRowBuilder;
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard;
import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask; import net.osmand.plus.mapcontextmenu.builders.cards.ImageCard.GetImageCardsTask;
import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard; import net.osmand.plus.mapcontextmenu.builders.cards.NoImagesCard;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute; import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.render.RenderingIcons;
import net.osmand.plus.views.TransportStopsLayer; import net.osmand.plus.views.TransportStopsLayer;
@ -99,6 +101,7 @@ public class MenuBuilder {
public class PlainMenuItem { public class PlainMenuItem {
private int iconId; private int iconId;
private String buttonText;
private String text; private String text;
private boolean needLinks; private boolean needLinks;
private boolean url; private boolean url;
@ -106,10 +109,11 @@ public class MenuBuilder {
private CollapsableView collapsableView; private CollapsableView collapsableView;
private OnClickListener onClickListener; private OnClickListener onClickListener;
public PlainMenuItem(int iconId, String text, boolean needLinks, boolean url, public PlainMenuItem(int iconId, String buttonText, String text, boolean needLinks, boolean url,
boolean collapsable, CollapsableView collapsableView, boolean collapsable, CollapsableView collapsableView,
OnClickListener onClickListener) { OnClickListener onClickListener) {
this.iconId = iconId; this.iconId = iconId;
this.buttonText = buttonText;
this.text = text; this.text = text;
this.needLinks = needLinks; this.needLinks = needLinks;
this.url = url; this.url = url;
@ -122,6 +126,10 @@ public class MenuBuilder {
return iconId; return iconId;
} }
public String getButtonText() {
return buttonText;
}
public String getText() { public String getText() {
return text; return text;
} }
@ -289,7 +297,7 @@ public class MenuBuilder {
buildTitleRow(view); buildTitleRow(view);
} }
if (showTransportRoutes()) { if (showTransportRoutes()) {
buildRow(view, 0, app.getString(R.string.transport_Routes), 0, true, getCollapsableTransportStopRoutesView(view.getContext(), false), buildRow(view, 0, null, app.getString(R.string.transport_Routes), 0, true, getCollapsableTransportStopRoutesView(view.getContext(), false),
false, 0, false, null, true); false, 0, false, null, true);
} }
buildNearestWikiRow(view); buildNearestWikiRow(view);
@ -324,7 +332,7 @@ public class MenuBuilder {
protected void buildPlainMenuItems(View view) { protected void buildPlainMenuItems(View view) {
for (PlainMenuItem item : plainMenuItems) { for (PlainMenuItem item : plainMenuItems) {
buildRow(view, item.getIconId(), item.getText(), 0, item.collapsable, item.collapsableView, buildRow(view, item.getIconId(), item.getButtonText(), item.getText(), 0, item.collapsable, item.collapsableView,
item.isNeedLinks(), 0, item.isUrl(), item.getOnClickListener(), false); item.isNeedLinks(), 0, item.isUrl(), item.getOnClickListener(), false);
} }
} }
@ -349,14 +357,14 @@ public class MenuBuilder {
if (mapContextMenu != null) { if (mapContextMenu != null) {
String title = mapContextMenu.getTitleStr(); String title = mapContextMenu.getTitleStr();
if (title.length() > TITLE_LIMIT) { if (title.length() > TITLE_LIMIT) {
buildRow(view, R.drawable.ic_action_note_dark, title, 0, false, null, false, 0, false, null, false); buildRow(view, R.drawable.ic_action_note_dark, null, title, 0, false, null, false, 0, false, null, false);
} }
} }
} }
protected void buildNearestWikiRow(View view) { protected void buildNearestWikiRow(View view) {
if (processNearstWiki() && nearestWiki.size() > 0) { if (processNearstWiki() && nearestWiki.size() > 0) {
buildRow(view, R.drawable.ic_action_wikipedia, app.getString(R.string.wiki_around) + " (" + nearestWiki.size()+")", 0, buildRow(view, R.drawable.ic_action_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size()+")", 0,
true, getCollapsableWikiView(view.getContext(), true), true, getCollapsableWikiView(view.getContext(), true),
false, 0, false, null, false); false, 0, false, null, false);
} }
@ -380,7 +388,7 @@ public class MenuBuilder {
} }
} }
}); });
buildRow(view, R.drawable.ic_action_photo_dark, app.getString(R.string.online_photos), 0, true, buildRow(view, R.drawable.ic_action_photo_dark, null, app.getString(R.string.online_photos), 0, true,
collapsableView, false, 1, false, null, false); collapsableView, false, 1, false, null, false);
if (needUpdateOnly && onlinePhotoCards != null) { if (needUpdateOnly && onlinePhotoCards != null) {
@ -437,14 +445,14 @@ public class MenuBuilder {
firstRow = false; firstRow = false;
} }
public View buildRow(View view, int iconId, String text, int textColor, public View buildRow(View view, int iconId, String buttonText, String text, int textColor,
boolean collapsable, final CollapsableView collapsableView, boolean collapsable, final CollapsableView collapsableView,
boolean needLinks, int textLinesLimit, boolean isUrl, OnClickListener onClickListener, boolean matchWidthDivider) { boolean needLinks, int textLinesLimit, boolean isUrl, OnClickListener onClickListener, boolean matchWidthDivider) {
return buildRow(view, iconId == 0 ? null : getRowIcon(iconId), text, textColor, null, collapsable, collapsableView, return buildRow(view, iconId == 0 ? null : getRowIcon(iconId), buttonText, text, textColor, null, collapsable, collapsableView,
needLinks, textLinesLimit, isUrl, onClickListener, matchWidthDivider); needLinks, textLinesLimit, isUrl, onClickListener, matchWidthDivider);
} }
public View buildRow(final View view, Drawable icon, final String text, int textColor, String secondaryText, public View buildRow(final View view, Drawable icon, final String buttonText, final String text, int textColor, String secondaryText,
boolean collapsable, final CollapsableView collapsableView, boolean needLinks, boolean collapsable, final CollapsableView collapsableView, boolean needLinks,
int textLinesLimit, boolean isUrl, OnClickListener onClickListener, boolean matchWidthDivider) { int textLinesLimit, boolean isUrl, OnClickListener onClickListener, boolean matchWidthDivider) {
@ -461,7 +469,7 @@ public class MenuBuilder {
ll.setOrientation(LinearLayout.HORIZONTAL); ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(llParams); ll.setLayoutParams(llParams);
ll.setBackgroundResource(resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground)); ll.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
ll.setOnLongClickListener(new View.OnLongClickListener() { ll.setOnLongClickListener(new View.OnLongClickListener() {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
@ -538,6 +546,20 @@ public class MenuBuilder {
llText.addView(textViewSecondary); llText.addView(textViewSecondary);
} }
//Button
if (!TextUtils.isEmpty(buttonText)) {
TextViewEx buttonTextView = new TextViewEx(view.getContext());
LinearLayout.LayoutParams buttonTextViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
buttonTextViewParams.gravity = Gravity.CENTER_VERTICAL;
buttonTextViewParams.setMargins(dpToPx(8), 0, dpToPx(8), 0);
buttonTextView.setLayoutParams(buttonTextViewParams);
buttonTextView.setTypeface(FontCache.getRobotoMedium(view.getContext()));
buttonTextView.setAllCaps(true);
buttonTextView.setTextColor(ContextCompat.getColor(view.getContext(), !light ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n));
buttonTextView.setText(buttonText);
ll.addView(buttonTextView);
}
final ImageView iconViewCollapse = new ImageView(view.getContext()); final ImageView iconViewCollapse = new ImageView(view.getContext());
if (collapsable && collapsableView != null) { if (collapsable && collapsableView != null) {
// Icon // Icon
@ -614,7 +636,7 @@ public class MenuBuilder {
ll.setOrientation(LinearLayout.HORIZONTAL); ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(llParams); ll.setLayoutParams(llParams);
ll.setBackgroundResource(resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground)); ll.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
// Empty // Empty
LinearLayout llIcon = new LinearLayout(view.getContext()); LinearLayout llIcon = new LinearLayout(view.getContext());
@ -635,7 +657,7 @@ public class MenuBuilder {
buttonView.setPadding(dpToPx(10f), 0, dpToPx(10f), 0); buttonView.setPadding(dpToPx(10f), 0, dpToPx(10f), 0);
buttonView.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); buttonView.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
//buttonView.setTextSize(view.getResources().getDimension(resolveAttribute(view.getContext(), R.dimen.default_desc_text_size))); //buttonView.setTextSize(view.getResources().getDimension(resolveAttribute(view.getContext(), R.dimen.default_desc_text_size)));
buttonView.setTextColor(view.getResources().getColor(resolveAttribute(view.getContext(), R.attr.contextMenuButtonColor))); buttonView.setTextColor(view.getResources().getColor(AndroidUtils.resolveAttribute(view.getContext(), R.attr.contextMenuButtonColor)));
buttonView.setText(text); buttonView.setText(text);
if (buttonIcon != null) { if (buttonIcon != null) {
@ -671,13 +693,17 @@ public class MenuBuilder {
} }
public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl, OnClickListener onClickListener) { public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl, OnClickListener onClickListener) {
plainMenuItems.add(new PlainMenuItem(iconId, text, needLinks, isUrl, false, null, onClickListener)); plainMenuItems.add(new PlainMenuItem(iconId, null, text, needLinks, isUrl, false, null, onClickListener));
}
public void addPlainMenuItem(int iconId, String buttonText, String text, boolean needLinks, boolean isUrl, OnClickListener onClickListener) {
plainMenuItems.add(new PlainMenuItem(iconId, buttonText, text, needLinks, isUrl, false, null, onClickListener));
} }
public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl, public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl,
boolean collapsable, CollapsableView collapsableView, boolean collapsable, CollapsableView collapsableView,
OnClickListener onClickListener) { OnClickListener onClickListener) {
plainMenuItems.add(new PlainMenuItem(iconId, text, needLinks, isUrl, collapsable, collapsableView, onClickListener)); plainMenuItems.add(new PlainMenuItem(iconId, null, text, needLinks, isUrl, collapsable, collapsableView, onClickListener));
} }
public void clearPlainMenuItems() { public void clearPlainMenuItems() {
@ -699,12 +725,6 @@ public class MenuBuilder {
} }
} }
public int resolveAttribute(Context ctx, int attribute) {
TypedValue outValue = new TypedValue();
ctx.getTheme().resolveAttribute(attribute, outValue, true);
return outValue.resourceId;
}
public int dpToPx(float dp) { public int dpToPx(float dp) {
Resources r = app.getResources(); Resources r = app.getResources();
return (int) TypedValue.applyDimension( return (int) TypedValue.applyDimension(
@ -714,69 +734,90 @@ public class MenuBuilder {
); );
} }
private void buildTransportRouteRow(ViewGroup parent, TransportStopRoute r, OnClickListener listener) { private View buildTransportRowItem(View view, TransportStopRoute route, OnClickListener listener) {
if (!isFirstRow()) { LinearLayout baseView = new LinearLayout(view.getContext());
baseView.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llBaseViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
baseView.setLayoutParams(llBaseViewParams);
baseView.setPadding(dpToPx(16), 0, dpToPx(16), dpToPx(12));
baseView.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
TextViewEx transportRect = new TextViewEx(view.getContext());
LinearLayout.LayoutParams trParams = new LinearLayout.LayoutParams(dpToPx(32), dpToPx(18));
trParams.setMargins(0, dpToPx(16), 0, 0);
transportRect.setLayoutParams(trParams);
transportRect.setGravity(Gravity.CENTER);
transportRect.setAllCaps(true);
transportRect.setTypeface(FontCache.getRobotoMedium(view.getContext()));
transportRect.setTextColor(Color.WHITE);
transportRect.setTextSize(10);
GradientDrawable shape = new GradientDrawable();
shape.setShape(GradientDrawable.RECTANGLE);
shape.setCornerRadius(dpToPx(3));
shape.setColor(route.getColor(mapActivity.getMyApplication(), !light));
transportRect.setBackgroundDrawable(shape);
transportRect.setText(route.route.getRef());
baseView.addView(transportRect);
LinearLayout infoView = new LinearLayout(view.getContext());
infoView.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams infoViewLayoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
infoViewLayoutParams.setMargins(dpToPx(16), dpToPx(12), dpToPx(16), 0);
infoView.setLayoutParams(infoViewLayoutParams);
baseView.addView(infoView);
TextView titleView = new TextView(view.getContext());
LinearLayout.LayoutParams titleParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
titleView.setLayoutParams(titleParams);
titleView.setTextSize(16);
titleView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));
titleView.setText(route.getDescription(getMapActivity().getMyApplication(), true));
infoView.addView(titleView);
LinearLayout typeView = new LinearLayout(view.getContext());
typeView.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams typeViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
typeViewParams.setMargins(0, dpToPx(8), 0, 0);
typeView.setGravity(Gravity.CENTER);
typeView.setLayoutParams(typeViewParams);
infoView.addView(typeView);
ImageView typeImageView = new ImageView(view.getContext());
LinearLayout.LayoutParams typeImageParams = new LinearLayout.LayoutParams(dpToPx(16), dpToPx(16));
typeImageParams.setMargins(dpToPx(4), 0, dpToPx(4), 0);
typeImageView.setLayoutParams(typeImageParams);
int drawableResId = route.type == null ? R.drawable.ic_action_polygom_dark : route.type.getResourceId();
typeImageView.setImageDrawable(getRowIcon(drawableResId));
typeView.addView(typeImageView);
TextView typeTextView = new TextView(view.getContext());
LinearLayout.LayoutParams typeTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
typeTextView.setLayoutParams(typeTextParams);
typeTextView.setText(route.getTypeStrRes());
typeView.addView(typeTextView);
baseView.setOnClickListener(listener);
((ViewGroup) view).addView(baseView);
return baseView;
}
private void buildTransportRouteRow(ViewGroup parent, TransportStopRoute r, OnClickListener listener, boolean showDivider) {
buildTransportRowItem(parent, r, listener);
if (showDivider) {
buildRowDivider(parent); buildRowDivider(parent);
} }
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.ctx_menu_transport_route_layout, parent, false);
TextView routeDesc = (TextView) view.findViewById(R.id.route_desc);
routeDesc.setText(r.getDescription(getMapActivity().getMyApplication(), true));
routeDesc.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));
int drawableResId = r.type == null ? R.drawable.ic_action_polygom_dark : r.type.getResourceId();
((ImageView) view.findViewById(R.id.route_type_icon)).setImageDrawable(getRowIcon(drawableResId));
((TextView) view.findViewById(R.id.route_ref)).setText(r.route.getRef());
view.setOnClickListener(listener);
int typeResId;
switch (r.type) {
case BUS:
typeResId = R.string.poi_route_bus_ref;
break;
case TRAM:
typeResId = R.string.poi_route_tram_ref;
break;
case FERRY:
typeResId = R.string.poi_route_ferry_ref;
break;
case TRAIN:
typeResId = R.string.poi_route_train_ref;
break;
case SHARE_TAXI:
typeResId = R.string.poi_route_share_taxi_ref;
break;
case FUNICULAR:
typeResId = R.string.poi_route_funicular_ref;
break;
case LIGHT_RAIL:
typeResId = R.string.poi_route_light_rail_ref;
break;
case MONORAIL:
typeResId = R.string.poi_route_monorail_ref;
break;
case TROLLEYBUS:
typeResId = R.string.poi_route_trolleybus_ref;
break;
case RAILWAY:
typeResId = R.string.poi_route_railway_ref;
break;
case SUBWAY:
typeResId = R.string.poi_route_subway_ref;
break;
default:
typeResId = R.string.poi_filter_public_transport;
break;
}
((TextView) view.findViewById(R.id.route_type_text)).setText(typeResId);
parent.addView(view);
rowBuilt();
} }
private CollapsableView getCollapsableTransportStopRoutesView(final Context context, boolean collapsed) { private CollapsableView getCollapsableTransportStopRoutesView(final Context context, boolean collapsed) {
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, false); LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, false);
for (final TransportStopRoute r : routes) { for (int i = 0; i < routes.size(); i++) {
final TransportStopRoute r = routes.get(i);
View.OnClickListener listener = new View.OnClickListener() { View.OnClickListener listener = new View.OnClickListener() {
@Override @Override
public void onClick(View arg0) { public void onClick(View arg0) {
@ -785,12 +826,13 @@ public class MenuBuilder {
r.getDescription(getMapActivity().getMyApplication(), false)); r.getDescription(getMapActivity().getMyApplication(), false));
mm.show(latLon, pd, r); mm.show(latLon, pd, r);
TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer(); TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
stopsLayer.setRoute(r.route); stopsLayer.setRoute(r);
int cz = r.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox()); int cz = r.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox());
getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom()); getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
} }
}; };
buildTransportRouteRow(view, r, listener); boolean showDivider = i < routes.size() - 1;
buildTransportRouteRow(view, r, listener, showDivider);
} }
return new CollapsableView(view, collapsed); return new CollapsableView(view, collapsed);
@ -949,16 +991,9 @@ public class MenuBuilder {
int paddingSides = dpToPx(10f); int paddingSides = dpToPx(10f);
button.setPadding(paddingSides, 0, paddingSides, 0); button.setPadding(paddingSides, 0, paddingSides, 0);
if (!selected) { if (!selected) {
ColorStateList buttonColorStateList = new ColorStateList( ColorStateList buttonColorStateList = AndroidUtils.createColorStateList(context, !light,
new int[][] { R.color.ctx_menu_controller_button_text_color_light_n, R.color.ctx_menu_controller_button_text_color_light_p,
new int[]{android.R.attr.state_pressed}, R.color.ctx_menu_controller_button_text_color_dark_n, R.color.ctx_menu_controller_button_text_color_dark_p);
new int[]{}
},
new int[] {
context.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_p : R.color.ctx_menu_controller_button_text_color_dark_p),
context.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n)
}
);
button.setTextColor(buttonColorStateList); button.setTextColor(buttonColorStateList);
} else { } else {
button.setTextColor(ContextCompat.getColor(context, light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark)); button.setTextColor(ContextCompat.getColor(context, light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));

View file

@ -4,6 +4,7 @@ import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -51,7 +52,7 @@ import net.osmand.plus.mapcontextmenu.controllers.RenderedObjectMenuController;
import net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController; import net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController;
import net.osmand.plus.mapcontextmenu.controllers.TransportRouteController; import net.osmand.plus.mapcontextmenu.controllers.TransportRouteController;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController; import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute; import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController; import net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController;
import net.osmand.plus.mapcontextmenu.other.ShareMenu; import net.osmand.plus.mapcontextmenu.other.ShareMenu;
import net.osmand.plus.mapillary.MapillaryImage; import net.osmand.plus.mapillary.MapillaryImage;
@ -225,8 +226,8 @@ public abstract class MenuController extends BaseMenuController {
return true; return true;
} }
public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl, OnClickListener onClickListener) { public void addPlainMenuItem(int iconId, String buttonText, String text, boolean needLinks, boolean isUrl, OnClickListener onClickListener) {
builder.addPlainMenuItem(iconId, text, needLinks, isUrl, onClickListener); builder.addPlainMenuItem(iconId, buttonText, text, needLinks, isUrl, onClickListener);
} }
public void clearPlainMenuItems() { public void clearPlainMenuItems() {
@ -239,7 +240,7 @@ public abstract class MenuController extends BaseMenuController {
protected void addMyLocationToPlainItems(LatLon latLon) { protected void addMyLocationToPlainItems(LatLon latLon) {
OsmandSettings st = ((OsmandApplication) getMapActivity().getApplicationContext()).getSettings(); OsmandSettings st = ((OsmandApplication) getMapActivity().getApplicationContext()).getSettings();
addPlainMenuItem(R.drawable.ic_action_get_my_location, PointDescription.getLocationName(getMapActivity(), addPlainMenuItem(R.drawable.ic_action_get_my_location, null, PointDescription.getLocationName(getMapActivity(),
latLon.getLatitude(), latLon.getLongitude(), true).replaceAll("\n", " "), false, false, null); latLon.getLatitude(), latLon.getLongitude(), true).replaceAll("\n", " "), false, false, null);
//if (st.COORDINATES_FORMAT.get() != PointDescription.OLC_FORMAT) //if (st.COORDINATES_FORMAT.get() != PointDescription.OLC_FORMAT)
// addPlainMenuItem(R.drawable.ic_action_get_my_location, PointDescription.getLocationOlcName( // addPlainMenuItem(R.drawable.ic_action_get_my_location, PointDescription.getLocationOlcName(
@ -386,15 +387,11 @@ public abstract class MenuController extends BaseMenuController {
return false; return false;
} }
public boolean displayAdditionalTypeStrInHours() { public int getRightIconId() {
return false;
}
public int getLeftIconId() {
return 0; return 0;
} }
public Drawable getLeftIcon() { public Drawable getRightIcon() {
return null; return null;
} }
@ -402,10 +399,14 @@ public abstract class MenuController extends BaseMenuController {
return null; return null;
} }
public Drawable getAdditionalLineTypeIcon() { public Drawable getSubtypeIcon() {
return null; return null;
} }
public boolean navigateInPedestrianMode() {
return false;
}
public int getFavActionIconId() { public int getFavActionIconId() {
return R.drawable.map_action_fav_dark; return R.drawable.map_action_fav_dark;
} }
@ -432,16 +433,29 @@ public abstract class MenuController extends BaseMenuController {
return ""; return "";
} }
public String getAdditionalTypeStr() { public String getSubtypeStr() {
return ""; return "";
} }
public int getTimeStrColor() { public int getAdditionalInfoColor() {
if (indexItem != null) {
return R.color.icon_color;
}
return 0; return 0;
} }
public OpeningHoursInfo getOpeningHoursInfo() { public String getAdditionalInfoStr() {
return null; if (indexItem != null) {
return getMapActivity().getString(R.string.file_size_in_mb, indexItem.getArchiveSizeMB());
}
return "";
}
public int getAdditionalInfoIconRes() {
if (indexItem != null) {
return R.drawable.ic_sdcard_16;
}
return 0;
} }
public String getCommonTypeStr() { public String getCommonTypeStr() {
@ -531,11 +545,14 @@ public abstract class MenuController extends BaseMenuController {
public abstract class TitleButtonController { public abstract class TitleButtonController {
public String caption = ""; public String caption = "";
public int leftIconId = 0; public int leftIconId = 0;
public int rightIconId = 0;
public boolean needRightText = false; public boolean needRightText = false;
public String rightTextCaption = ""; public String rightTextCaption = "";
public boolean visible = true; public boolean visible = true;
public boolean needColorizeIcon = true; public boolean needColorizeIcon = true;
public Drawable leftIcon; public Drawable leftIcon;
public Drawable rightIcon;
public boolean enabled = true;
public Drawable getLeftIcon() { public Drawable getLeftIcon() {
if (leftIcon != null) { if (leftIcon != null) {
@ -543,7 +560,7 @@ public abstract class MenuController extends BaseMenuController {
} }
if (leftIconId != 0) { if (leftIconId != 0) {
if (needColorizeIcon) { if (needColorizeIcon) {
return getIcon(leftIconId, isLight() ? R.color.map_widget_blue : R.color.osmand_orange); return getIcon(leftIconId, getColorRes());
} }
return ContextCompat.getDrawable(getMapActivity(), leftIconId); return ContextCompat.getDrawable(getMapActivity(), leftIconId);
} else { } else {
@ -551,6 +568,30 @@ public abstract class MenuController extends BaseMenuController {
} }
} }
public Drawable getRightIcon() {
if (rightIcon != null) {
return rightIcon;
}
if (rightIconId != 0) {
if (needColorizeIcon) {
return getIcon(rightIconId, getColorRes());
}
return ContextCompat.getDrawable(getMapActivity(), rightIconId);
} else {
return null;
}
}
private int getColorRes() {
int colorRes;
if (enabled) {
colorRes = isLight() ? R.color.map_widget_blue : R.color.osmand_orange;
} else {
colorRes = isLight() ? R.color.ctx_menu_controller_disabled_text_color_light : R.color.ctx_menu_controller_disabled_text_color_dark;
}
return colorRes;
}
public abstract void buttonPressed(); public abstract void buttonPressed();
} }
@ -619,7 +660,7 @@ public abstract class MenuController extends BaseMenuController {
} }
} }
public void buildMapDownloadButton(final LatLon latLon) { public void buildMapDownloadButtonAndSizeInfo(final LatLon latLon) {
new AsyncTask<Void, Void, BinaryMapDataObject>() { new AsyncTask<Void, Void, BinaryMapDataObject>() {
ResourceManager rm; ResourceManager rm;
@ -774,6 +815,11 @@ public abstract class MenuController extends BaseMenuController {
public ContextMenuToolbarController(MenuController menuController) { public ContextMenuToolbarController(MenuController menuController) {
super(TopToolbarControllerType.CONTEXT_MENU); super(TopToolbarControllerType.CONTEXT_MENU);
this.menuController = menuController; this.menuController = menuController;
setBgIds(R.color.actionbar_light_color, R.color.actionbar_dark_color,
R.color.actionbar_light_color, R.color.actionbar_dark_color);
setBackBtnIconClrIds(R.color.color_white, R.color.color_white);
setCloseBtnIconClrIds(R.color.color_white, R.color.color_white);
setTitleTextClrIds(R.color.color_white, R.color.color_white);
} }
public MenuController getMenuController() { public MenuController getMenuController() {

View file

@ -11,16 +11,13 @@ import net.osmand.util.Algorithms;
public abstract class MenuTitleController { public abstract class MenuTitleController {
protected int leftIconId; protected int rightIconId;
protected Drawable leftIcon; protected Drawable rightIcon;
protected String nameStr = ""; protected String nameStr = "";
protected String typeStr = ""; protected String typeStr = "";
protected String additionalTypeStr = "";
protected String commonTypeStr = ""; protected String commonTypeStr = "";
protected Drawable secondLineTypeIcon; protected Drawable secondLineTypeIcon;
protected Drawable additionalLineTypeIcon;
protected String streetStr = ""; protected String streetStr = "";
protected OpeningHoursInfo openingHoursInfo;
private AddressLookupRequest addressLookupRequest; private AddressLookupRequest addressLookupRequest;
@ -68,22 +65,18 @@ public abstract class MenuTitleController {
return !addressNotFoundStr.equals(title) && !searchAddressStr.equals(title); return !addressNotFoundStr.equals(title) && !searchAddressStr.equals(title);
} }
public int getLeftIconId() { public int getRightIconId() {
return leftIconId; return rightIconId;
} }
public Drawable getLeftIcon() { public Drawable getRightIcon() {
return leftIcon; return rightIcon;
} }
public Drawable getTypeIcon() { public Drawable getTypeIcon() {
return secondLineTypeIcon; return secondLineTypeIcon;
} }
public Drawable getAdditionalLineTypeIcon() {
return additionalLineTypeIcon;
}
public String getTypeStr() { public String getTypeStr() {
MenuController menuController = getMenuController(); MenuController menuController = getMenuController();
if (menuController != null && menuController.needTypeStr()) { if (menuController != null && menuController.needTypeStr()) {
@ -93,15 +86,6 @@ public abstract class MenuTitleController {
} }
} }
public String getAdditionalTypeStr() {
MenuController menuController = getMenuController();
if (menuController != null) {
return additionalTypeStr;
} else {
return "";
}
}
public String getStreetStr() { public String getStreetStr() {
if (needStreetName()) { if (needStreetName()) {
if (searchingAddress()) { if (searchingAddress()) {
@ -114,10 +98,6 @@ public abstract class MenuTitleController {
} }
} }
public OpeningHoursInfo getOpeningHoursInfo() {
return openingHoursInfo;
}
protected void initTitle() { protected void initTitle() {
searchAddressStr = PointDescription.getSearchAddressStr(getMapActivity()); searchAddressStr = PointDescription.getSearchAddressStr(getMapActivity());
addressNotFoundStr = PointDescription.getAddressNotFoundStr(getMapActivity()); addressNotFoundStr = PointDescription.getAddressNotFoundStr(getMapActivity());
@ -131,8 +111,6 @@ public abstract class MenuTitleController {
if (needStreetName()) { if (needStreetName()) {
acquireStreetName(); acquireStreetName();
} }
acquireOpeningHoursInfo();
} }
protected boolean needStreetName() { protected boolean needStreetName() {
@ -147,16 +125,14 @@ public abstract class MenuTitleController {
protected void acquireIcons() { protected void acquireIcons() {
MenuController menuController = getMenuController(); MenuController menuController = getMenuController();
leftIconId = 0; rightIconId = 0;
leftIcon = null; rightIcon = null;
secondLineTypeIcon = null; secondLineTypeIcon = null;
additionalLineTypeIcon = null;
if (menuController != null) { if (menuController != null) {
leftIconId = menuController.getLeftIconId(); rightIconId = menuController.getRightIconId();
leftIcon = menuController.getLeftIcon(); rightIcon = menuController.getRightIcon();
secondLineTypeIcon = menuController.getSecondLineTypeIcon(); secondLineTypeIcon = menuController.getSecondLineTypeIcon();
additionalLineTypeIcon = menuController.getAdditionalLineTypeIcon();
} }
} }
@ -170,7 +146,6 @@ public abstract class MenuTitleController {
if (menuController != null) { if (menuController != null) {
nameStr = menuController.getNameStr(); nameStr = menuController.getNameStr();
typeStr = menuController.getTypeStr(); typeStr = menuController.getTypeStr();
additionalTypeStr = menuController.getAdditionalTypeStr();
commonTypeStr = menuController.getCommonTypeStr(); commonTypeStr = menuController.getCommonTypeStr();
} }
@ -211,13 +186,6 @@ public abstract class MenuTitleController {
getMapActivity().getMyApplication().getGeocodingLookupService().lookupAddress(addressLookupRequest); getMapActivity().getMyApplication().getGeocodingLookupService().lookupAddress(addressLookupRequest);
} }
protected void acquireOpeningHoursInfo() {
MenuController menuController = getMenuController();
if (menuController != null) {
openingHoursInfo = menuController.getOpeningHoursInfo();
}
}
protected void onSearchAddressDone() { protected void onSearchAddressDone() {
} }

View file

@ -1,5 +1,8 @@
package net.osmand.plus.mapcontextmenu; package net.osmand.plus.mapcontextmenu;
import android.content.Context;
import net.osmand.plus.R;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
public class OpeningHoursInfo { public class OpeningHoursInfo {
@ -68,12 +71,20 @@ public class OpeningHoursInfo {
this.openingDay = openingDay; this.openingDay = openingDay;
} }
public boolean containsInfo() { public String getInfo(Context context) {
return opened24_7 if (isOpened24_7()) {
|| !Algorithms.isEmpty(openingTime) return context.getString(R.string.shared_string_is_open_24_7);
|| !Algorithms.isEmpty(nearToOpeningTime) } else if (!Algorithms.isEmpty(getNearToOpeningTime())) {
|| !Algorithms.isEmpty(closingTime) return context.getString(R.string.will_open_at) + " " + getNearToOpeningTime();
|| !Algorithms.isEmpty(nearToClosingTime) } else if (!Algorithms.isEmpty(getOpeningTime())) {
|| !Algorithms.isEmpty(openingDay); return context.getString(R.string.open_from) + " " + getOpeningTime();
} else if (!Algorithms.isEmpty(getNearToClosingTime())) {
return context.getString(R.string.will_close_at) + " " + getNearToClosingTime();
} else if (!Algorithms.isEmpty(getClosingTime())) {
return context.getString(R.string.open_till) + " " + getClosingTime();
} else if (!Algorithms.isEmpty(getOpeningDay())) {
return context.getString(R.string.will_open_on) + " " + getOpeningDay() + ".";
}
return "";
} }
} }

View file

@ -1,6 +1,6 @@
package net.osmand.plus.mapcontextmenu; package net.osmand.plus.mapcontextmenu;
import android.content.Context; import android.graphics.drawable.GradientDrawable;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -9,26 +9,56 @@ import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute; import net.osmand.plus.transport.TransportStopRoute;
import java.util.List; import java.util.List;
public class TransportStopRouteAdapter extends ArrayAdapter<TransportStopRoute> { public class TransportStopRouteAdapter extends ArrayAdapter<TransportStopRoute> {
public TransportStopRouteAdapter(@NonNull Context context, @NonNull List<TransportStopRoute> objects) { private boolean nightMode;
super(context, 0, objects); private OnClickListener listener;
private OsmandApplication app;
public TransportStopRouteAdapter(@NonNull OsmandApplication application, @NonNull List<TransportStopRoute> objects, boolean nightMode) {
super(application, 0, objects);
this.nightMode = nightMode;
this.app = application;
}
public void setListener(OnClickListener listener) {
this.listener = listener;
} }
@NonNull @NonNull
@Override @Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
if (convertView == null) { if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.transport_stop_route_item, parent, false); convertView = LayoutInflater.from(getContext()).inflate(R.layout.transport_stop_route_item, parent, false);
} }
((TextView) convertView.findViewById(R.id.transport_stop_route_text)).setText(getItem(position).route.getRef()); TransportStopRoute transportStopRoute = getItem(position);
if (transportStopRoute != null) {
TextView transportStopRouteTextView = (TextView) convertView.findViewById(R.id.transport_stop_route_text);
transportStopRouteTextView.setText(transportStopRoute.route.getRef());
GradientDrawable gradientDrawableBg = (GradientDrawable) transportStopRouteTextView.getBackground();
gradientDrawableBg.setColor(transportStopRoute.getColor(app, nightMode));
}
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (listener != null) {
listener.onClick(position);
}
}
});
return convertView; return convertView;
} }
public interface OnClickListener {
void onClick(int position);
}
} }

View file

@ -0,0 +1,291 @@
package net.osmand.plus.mapcontextmenu;
import android.app.Dialog;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.customtabs.CustomTabsIntent;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.support.v4.app.DialogFragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.PopupMenu;
import android.text.Html;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.data.Amenity;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.util.Algorithms;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
public class WikipediaDialogFragment extends DialogFragment {
public static final String TAG = "WikipediaDialogFragment";
private View mainView;
private boolean darkMode;
private Amenity amenity;
private String lang;
public void setAmenity(Amenity amenity) {
this.amenity = amenity;
}
public void setLanguage(String lang) {
this.lang = lang;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
OsmandApplication app = getMyApplication();
darkMode = app.getDaynightHelper().isNightMode() || !app.getSettings().isLightContent();
int themeId = darkMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
setStyle(STYLE_NO_FRAME, themeId);
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = new Dialog(getContext(), getTheme());
if (!getMyApplication().getSettings().DO_NOT_USE_ANIMATIONS.get()) {
dialog.getWindow().getAttributes().windowAnimations = R.style.Animations_Alpha;
}
return dialog;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mainView = inflater.inflate(R.layout.wikipedia_dialog_fragment, container, false);
mainView.setBackgroundColor(ContextCompat.getColor(getContext(), darkMode ? R.color.ctx_menu_bottom_view_bg_dark : R.color.ctx_menu_bottom_view_bg_light));
AppBarLayout appBarLayout = (AppBarLayout) mainView.findViewById(R.id.app_bar);
appBarLayout.setBackgroundColor(ContextCompat.getColor(getContext(), darkMode ? R.color.ctx_menu_buttons_bg_dark: R.color.ctx_menu_buttons_bg_light));
int toolbarTextColor = ContextCompat.getColor(getContext(), R.color.dashboard_subheader_text_light);
ImageButton backButton = (ImageButton) mainView.findViewById(R.id.back_button);
backButton.setImageDrawable(getMyApplication().getIconsCache().getPaintedIcon(R.drawable.ic_arrow_back, toolbarTextColor));
backButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
TextView titleTextView = (TextView) mainView.findViewById(R.id.title_text_view);
titleTextView.setTextColor(toolbarTextColor);
ColorStateList buttonColorStateList = AndroidUtils.createColorStateList(getContext(), darkMode,
R.color.ctx_menu_controller_button_text_color_light_n, R.color.ctx_menu_controller_button_text_color_light_p,
R.color.ctx_menu_controller_button_text_color_dark_n, R.color.ctx_menu_controller_button_text_color_dark_p);
final TextView readFullArticleButton = (TextView) mainView.findViewById(R.id.read_full_article);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) readFullArticleButton.getLayoutParams();
params.setBehavior(new CoordinatorLayout.Behavior() {
@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
return dependency instanceof AppBarLayout;
}
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
if (dependency instanceof AppBarLayout) {
int readFullArticleButtonHeight = child.getMeasuredHeight();
if (readFullArticleButtonHeight != 0) {
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams();
int viewBottomMargin = lp.bottomMargin;
int distanceToScroll = child.getHeight() + viewBottomMargin;
float ratio = dependency.getY() / readFullArticleButtonHeight;
child.setTranslationY(-distanceToScroll * ratio);
}
}
return true;
}
});
readFullArticleButton.setLayoutParams(params);
readFullArticleButton.setBackgroundResource(darkMode ? R.drawable.bt_round_long_night : R.drawable.bt_round_long_day);
readFullArticleButton.setTextColor(buttonColorStateList);
int paddingLeft = (int) getResources().getDimension(R.dimen.wikipedia_button_left_padding);
int paddingRight = (int) getResources().getDimension(R.dimen.dialog_content_margin);
readFullArticleButton.setPadding(paddingLeft, 0, paddingRight, 0);
readFullArticleButton.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_world_globe_dark), null, null, null);
readFullArticleButton.setCompoundDrawablePadding((int) getResources().getDimension(R.dimen.content_padding_small));
final TextView selectLanguageTextView = mainView.findViewById(R.id.select_language_text_view);
selectLanguageTextView.setTextColor(buttonColorStateList);
selectLanguageTextView.setCompoundDrawablesWithIntrinsicBounds(getIcon(R.drawable.ic_action_map_language), null, null, null);
selectLanguageTextView.setCompoundDrawablePadding((int) getResources().getDimension(R.dimen.context_menu_padding_margin_small));
selectLanguageTextView.setBackgroundResource(darkMode ? R.drawable.wikipedia_select_lang_bg_dark : R.drawable.wikipedia_select_lang_bg_light);
return mainView;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
populateWiki();
}
@Override
public void onDestroyView() {
Dialog dialog = getDialog();
if (dialog != null) {
dialog.setDismissMessage(null);
}
super.onDestroyView();
}
private void populateWiki() {
if (amenity != null) {
String preferredLanguage = lang;
if (TextUtils.isEmpty(preferredLanguage)) {
preferredLanguage = getMyApplication().getLanguage();
}
final String title = TextUtils.isEmpty(preferredLanguage) ? amenity.getName() : amenity.getName(lang);
((TextView) mainView.findViewById(R.id.title_text_view)).setText(title);
String lng = amenity.getContentLanguage("content", preferredLanguage, "en");
if (Algorithms.isEmpty(lng)) {
lng = "en";
}
final String langSelected = lng;
mainView.findViewById(R.id.read_full_article).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String article = "https://" + langSelected.toLowerCase() + ".wikipedia.org/wiki/" + title.replace(' ', '_');
showFullArticle(Uri.parse(article));
}
});
final TextView selectLanguageTextView = mainView.findViewById(R.id.select_language_text_view);
selectLanguageTextView.setText(langSelected);
selectLanguageTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPopupLangMenu(selectLanguageTextView, langSelected);
}
});
String content = amenity.getDescription(langSelected);
TextView articleTextView = (TextView) mainView.findViewById(R.id.content);
Spannable spannableContent = new SpannableString(Html.fromHtml(content));
int length = spannableContent.length();
spannableContent.setSpan(new RelativeSizeSpan(1.2f), 0, length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
int contentTextColor = ContextCompat.getColor(getContext(), darkMode ? R.color.ctx_menu_bottom_view_text_color_dark : R.color.ctx_menu_bottom_view_text_color_light);
spannableContent.setSpan(new ForegroundColorSpan(contentTextColor), 0, length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
articleTextView.setText(spannableContent);
}
}
private void showFullArticle(Uri uri) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
CustomTabsIntent customTabsIntent = new CustomTabsIntent.Builder()
.setToolbarColor(ContextCompat.getColor(getContext(), darkMode ? R.color.actionbar_dark_color : R.color.actionbar_light_color))
.build();
customTabsIntent.launchUrl(getContext(), uri);
} else {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(uri);
startActivity(i);
}
}
private void showPopupLangMenu(View view, final String langSelected) {
final PopupMenu optionsMenu = new PopupMenu(getContext(), view, Gravity.RIGHT);
Set<String> namesSet = new TreeSet<>();
namesSet.addAll(amenity.getNames("content", "en"));
namesSet.addAll(amenity.getNames("description", "en"));
Map<String, String> names = new HashMap<>();
for (String n : namesSet) {
names.put(n, FileNameTranslationHelper.getVoiceName(getContext(), n));
}
String selectedLangName = names.get(langSelected);
if (selectedLangName != null) {
names.remove(langSelected);
}
Map<String, String> sortedNames = AndroidUtils.sortByValue(names);
if (selectedLangName != null) {
MenuItem item = optionsMenu.getMenu().add(selectedLangName);
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
setLanguage(langSelected);
populateWiki();
return true;
}
});
}
for (final Map.Entry<String, String> e : sortedNames.entrySet()) {
MenuItem item = optionsMenu.getMenu().add(e.getValue());
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
setLanguage(e.getKey());
populateWiki();
return true;
}
});
}
optionsMenu.show();
}
private Drawable getIcon(int resId) {
int colorId = darkMode ? R.color.ctx_menu_controller_button_text_color_dark_n : R.color.ctx_menu_controller_button_text_color_light_n;
return getMyApplication().getIconsCache().getIcon(resId, colorId);
}
private OsmandApplication getMyApplication() {
return (OsmandApplication) getActivity().getApplication();
}
public static boolean showInstance(AppCompatActivity activity, Amenity amenity) {
try {
if (!amenity.getType().isWiki()) {
return false;
}
OsmandApplication app = (OsmandApplication) activity.getApplication();
String lang = app.getSettings().MAP_PREFERRED_LOCALE.get();
WikipediaDialogFragment wikipediaDialogFragment = new WikipediaDialogFragment();
wikipediaDialogFragment.setAmenity(amenity);
wikipediaDialogFragment.setLanguage(lang);
wikipediaDialogFragment.setRetainInstance(true);
wikipediaDialogFragment.show(activity.getSupportFragmentManager(), TAG);
return true;
} catch (RuntimeException e) {
return false;
}
}
}

View file

@ -19,6 +19,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.data.Amenity; import net.osmand.data.Amenity;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.osm.AbstractPoiType; import net.osmand.osm.AbstractPoiType;
@ -31,6 +32,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.FontCache; import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.WikipediaDialogFragment;
import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.views.POIMapLayer; import net.osmand.plus.views.POIMapLayer;
import net.osmand.plus.widgets.TextViewEx; import net.osmand.plus.widgets.TextViewEx;
@ -92,7 +94,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
ll.setOrientation(LinearLayout.HORIZONTAL); ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(llParams); ll.setLayoutParams(llParams);
ll.setBackgroundResource(resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground)); ll.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
ll.setOnLongClickListener(new View.OnLongClickListener() { ll.setOnLongClickListener(new View.OnLongClickListener() {
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
@ -131,7 +133,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
llTextParams.setMargins(icon == null ? dpToPx(16f) : 0, collapsable ? dpToPx(13f) : dpToPx(8f), 0, collapsable ? dpToPx(13f) : dpToPx(8f)); llTextParams.setMargins(icon == null ? dpToPx(16f) : 0, collapsable ? dpToPx(13f) : dpToPx(8f), 0, collapsable ? dpToPx(13f) : dpToPx(8f));
textView.setLayoutParams(llTextParams); textView.setLayoutParams(llTextParams);
textView.setTextSize(16); textView.setTextSize(16);
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark)); textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));
boolean textDefined = false; boolean textDefined = false;
if (isPhoneNumber || isUrl) { if (isPhoneNumber || isUrl) {
@ -217,16 +219,9 @@ public class AmenityMenuBuilder extends MenuBuilder {
button.setTextSize(14); button.setTextSize(14);
int paddingSides = dpToPx(10f); int paddingSides = dpToPx(10f);
button.setPadding(paddingSides, 0, paddingSides, 0); button.setPadding(paddingSides, 0, paddingSides, 0);
ColorStateList buttonColorStateList = new ColorStateList( ColorStateList buttonColorStateList = AndroidUtils.createColorStateList(view.getContext(), !light,
new int[][] { R.color.ctx_menu_controller_button_text_color_light_n, R.color.ctx_menu_controller_button_text_color_light_p,
new int[]{android.R.attr.state_pressed}, R.color.ctx_menu_controller_button_text_color_dark_n, R.color.ctx_menu_controller_button_text_color_dark_p);
new int[]{}
},
new int[] {
view.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_p : R.color.ctx_menu_controller_button_text_color_dark_p),
view.getResources().getColor(light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n)
}
);
button.setTextColor(buttonColorStateList); button.setTextColor(buttonColorStateList);
button.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); button.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
button.setSingleLine(true); button.setSingleLine(true);
@ -234,12 +229,12 @@ public class AmenityMenuBuilder extends MenuBuilder {
button.setOnClickListener(new View.OnClickListener() { button.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
POIMapLayer.showWikipediaDialog(view.getContext(), app, amenity); WikipediaDialogFragment.showInstance(mapActivity, amenity);
} }
}); });
button.setAllCaps(true); button.setAllCaps(true);
button.setText(R.string.context_menu_read_full_article); button.setText(R.string.context_menu_read_full_article);
Drawable compoundDrawable = app.getIconsCache().getIcon(R.drawable.ic_action_note_dark, light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n); Drawable compoundDrawable = app.getIconsCache().getIcon(R.drawable.ic_action_read_text, light ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n);
button.setCompoundDrawablesWithIntrinsicBounds(compoundDrawable, null, null, null); button.setCompoundDrawablesWithIntrinsicBounds(compoundDrawable, null, null, null);
button.setCompoundDrawablePadding(dpToPx(8f)); button.setCompoundDrawablePadding(dpToPx(8f));
llText.addView(button); llText.addView(button);
@ -284,7 +279,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
ll.setOnClickListener(new View.OnClickListener() { ll.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
POIMapLayer.showWikipediaDialog(view.getContext(), app, amenity); WikipediaDialogFragment.showInstance(mapActivity, amenity);
} }
}); });
} else if (isText && text.length() > 200) { } else if (isText && text.length() > 200) {
@ -516,10 +511,10 @@ public class AmenityMenuBuilder extends MenuBuilder {
} else { } else {
link = "https://www.openstreetmap.org/way/"; link = "https://www.openstreetmap.org/way/";
} }
buildRow(view, R.drawable.ic_action_info_dark, link + (amenity.getId() >> 1), buildRow(view, R.drawable.ic_action_info_dark, null, link + (amenity.getId() >> 1),
0, false, null, true, 0, true, null, false); 0, false, null, true, 0, true, null, false);
} }
buildRow(view, R.drawable.ic_action_get_my_location, PointDescription.getLocationName(app, buildRow(view, R.drawable.ic_action_get_my_location, null, PointDescription.getLocationName(app,
amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), true) amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), true)
.replaceAll("\n", " "), 0, false, null, false, 0, false, null, false); .replaceAll("\n", " "), 0, false, null, false, 0, false, null, false);
//if (st.COORDINATES_FORMAT.get() != PointDescription.OLC_FORMAT) //if (st.COORDINATES_FORMAT.get() != PointDescription.OLC_FORMAT)

View file

@ -78,7 +78,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
int disabledColor = light ? R.color.secondary_text_light : R.color.secondary_text_dark; int disabledColor = light ? R.color.secondary_text_light : R.color.secondary_text_dark;
color = favoriteGroup.visible ? (color | 0xff000000) : view.getResources().getColor(disabledColor); color = favoriteGroup.visible ? (color | 0xff000000) : view.getResources().getColor(disabledColor);
String name = view.getContext().getString(R.string.context_menu_points_of_group); String name = view.getContext().getString(R.string.context_menu_points_of_group);
buildRow(view, app.getIconsCache().getPaintedIcon(R.drawable.ic_action_folder, color), name, 0, null, buildRow(view, app.getIconsCache().getPaintedIcon(R.drawable.ic_action_folder, color), null, name, 0, null,
true, getCollapsableFavouritesView(view.getContext(), true, favoriteGroup, fav), true, getCollapsableFavouritesView(view.getContext(), true, favoriteGroup, fav),
false, 0, false, null, false); false, 0, false, null, false);
} }

View file

@ -34,7 +34,7 @@ public class GpxItemMenuBuilder extends MenuBuilder {
String description = GpxUiHelper.getDescription(app, item.analysis, false); String description = GpxUiHelper.getDescription(app, item.analysis, false);
String[] lines = description.split("\n"); String[] lines = description.split("\n");
for (String line : lines) { for (String line : lines) {
buildRow(view, R.drawable.ic_action_info_dark, line, 0, false, null, false, 0, false, null, false); buildRow(view, R.drawable.ic_action_info_dark, null, line, 0, false, null, false, 0, false, null, false);
} }
} }

View file

@ -44,23 +44,23 @@ public class WptPtMenuBuilder extends MenuBuilder {
DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext()); DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext());
Date date = new Date(wpt.time); Date date = new Date(wpt.time);
buildRow(view, R.drawable.ic_action_data, buildRow(view, R.drawable.ic_action_data,
dateFormat.format(date) + "" + timeFormat.format(date), 0, false, null, false, 0, false, null, false); null, dateFormat.format(date) + "" + timeFormat.format(date), 0, false, null, false, 0, false, null, false);
} }
if (wpt.speed > 0) { if (wpt.speed > 0) {
buildRow(view, R.drawable.ic_action_speed, buildRow(view, R.drawable.ic_action_speed,
OsmAndFormatter.getFormattedSpeed((float)wpt.speed, app), 0, false, null, false, 0, false, null, false); null, OsmAndFormatter.getFormattedSpeed((float)wpt.speed, app), 0, false, null, false, 0, false, null, false);
} }
if (!Double.isNaN(wpt.ele)) { if (!Double.isNaN(wpt.ele)) {
buildRow(view, R.drawable.ic_action_altitude, buildRow(view, R.drawable.ic_action_altitude,
OsmAndFormatter.getFormattedDistance((float) wpt.ele, app), 0, false, null, false, 0, false, null, false); null, OsmAndFormatter.getFormattedDistance((float) wpt.ele, app), 0, false, null, false, 0, false, null, false);
} }
if (!Double.isNaN(wpt.hdop)) { if (!Double.isNaN(wpt.hdop)) {
buildRow(view, R.drawable.ic_action_gps_info, buildRow(view, R.drawable.ic_action_gps_info,
Algorithms.capitalizeFirstLetterAndLowercase(app.getString(R.string.plugin_distance_point_hdop)) + ": " + (int)wpt.hdop, 0, null, Algorithms.capitalizeFirstLetterAndLowercase(app.getString(R.string.plugin_distance_point_hdop)) + ": " + (int)wpt.hdop, 0,
false, null, false, 0, false, null, false); false, null, false, 0, false, null, false);
} }
if (!Algorithms.isEmpty(wpt.desc)) { if (!Algorithms.isEmpty(wpt.desc)) {
final View row = buildRow(view, R.drawable.ic_action_note_dark, wpt.desc, 0, false, null, true, 10, false, null, false); final View row = buildRow(view, R.drawable.ic_action_note_dark, null, wpt.desc, 0, false, null, true, 10, false, null, false);
row.setOnClickListener(new View.OnClickListener() { row.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -70,7 +70,7 @@ public class WptPtMenuBuilder extends MenuBuilder {
}); });
} }
if (!Algorithms.isEmpty(wpt.comment)) { if (!Algorithms.isEmpty(wpt.comment)) {
final View rowc = buildRow(view, R.drawable.ic_action_note_dark, wpt.comment, 0, final View rowc = buildRow(view, R.drawable.ic_action_note_dark, null, wpt.comment, 0,
false, null, true, 10, false, null, false); false, null, true, 10, false, null, false);
rowc.setOnClickListener(new View.OnClickListener() { rowc.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -96,7 +96,7 @@ public class WptPtMenuBuilder extends MenuBuilder {
File file = new File(gpx.path); File file = new File(gpx.path);
String gpxName = file.getName().replace(".gpx", "").replace("/", " ").replace("_", " "); String gpxName = file.getName().replace(".gpx", "").replace("/", " ").replace("_", " ");
int color = getPointColor(wpt, getFileColor(selectedGpxFile)); int color = getPointColor(wpt, getFileColor(selectedGpxFile));
buildRow(view, app.getIconsCache().getPaintedIcon(R.drawable.ic_type_waypoints_group, color), title, 0, gpxName, buildRow(view, app.getIconsCache().getPaintedIcon(R.drawable.ic_type_waypoints_group, color), null, title, 0, gpxName,
true, getCollapsableWaypointsView(view.getContext(), true, gpx, wpt), true, getCollapsableWaypointsView(view.getContext(), true, gpx, wpt),
false, 0, false, null, false); false, 0, false, null, false);
} }

View file

@ -49,7 +49,7 @@ public class AMapPointMenuController extends MenuController {
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
return getIcon(R.drawable.ic_action_get_my_location); return getIcon(R.drawable.ic_action_get_my_location);
} }

View file

@ -1,7 +1,5 @@
package net.osmand.plus.mapcontextmenu.controllers; package net.osmand.plus.mapcontextmenu.controllers;
import android.view.View;
import net.osmand.data.Amenity; import net.osmand.data.Amenity;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
@ -14,16 +12,15 @@ import net.osmand.osm.PoiType;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
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.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapcontextmenu.OpeningHoursInfo; import net.osmand.plus.mapcontextmenu.OpeningHoursInfo;
import net.osmand.plus.mapcontextmenu.WikipediaDialogFragment;
import net.osmand.plus.mapcontextmenu.builders.AmenityMenuBuilder; import net.osmand.plus.mapcontextmenu.builders.AmenityMenuBuilder;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute; import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.render.RenderingIcons;
import net.osmand.plus.resources.TransportIndexRepository; import net.osmand.plus.resources.TransportIndexRepository;
import net.osmand.plus.views.POIMapLayer; import net.osmand.plus.transport.TransportStopType;
import net.osmand.plus.views.TransportStopsLayer;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import net.osmand.util.OpeningHoursParser; import net.osmand.util.OpeningHoursParser;
@ -39,6 +36,7 @@ public class AmenityMenuController extends MenuController {
private Amenity amenity; private Amenity amenity;
private List<TransportStopRoute> routes = new ArrayList<>(); private List<TransportStopRoute> routes = new ArrayList<>();
private OpeningHoursInfo openingHoursInfo;
private MapMarker marker; private MapMarker marker;
@ -71,12 +69,14 @@ public class AmenityMenuController extends MenuController {
leftTitleButtonController = new TitleButtonController() { leftTitleButtonController = new TitleButtonController() {
@Override @Override
public void buttonPressed() { public void buttonPressed() {
POIMapLayer.showWikipediaDialog(mapActivity, mapActivity.getMyApplication(), amenity); WikipediaDialogFragment.showInstance(mapActivity, amenity);
} }
}; };
leftTitleButtonController.caption = getMapActivity().getString(R.string.context_menu_read_article); leftTitleButtonController.caption = getMapActivity().getString(R.string.context_menu_read_article);
leftTitleButtonController.leftIcon = getIcon(R.drawable.ic_action_note_dark, isLight() ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n); leftTitleButtonController.leftIcon = getIcon(R.drawable.ic_action_read_text, isLight() ? R.color.ctx_menu_controller_button_text_color_light_n : R.color.ctx_menu_controller_button_text_color_dark_n);
} }
openingHoursInfo = processOpeningHours(amenity);
} }
@Override @Override
@ -108,11 +108,11 @@ public class AmenityMenuController extends MenuController {
} }
@Override @Override
public int getLeftIconId() { public int getRightIconId() {
return getLeftIconId(amenity); return getRightIconId(amenity);
} }
private static int getLeftIconId(Amenity amenity) { private static int getRightIconId(Amenity amenity) {
String id = null; String id = null;
PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType()); PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
if (st != null) { if (st != null) {
@ -146,8 +146,27 @@ public class AmenityMenuController extends MenuController {
} }
@Override @Override
public OpeningHoursInfo getOpeningHoursInfo() { public int getAdditionalInfoColor() {
return processOpeningHours(amenity); if (openingHoursInfo != null) {
return openingHoursInfo.isOpened() ? R.color.ctx_menu_amenity_opened_text_color : R.color.ctx_menu_amenity_closed_text_color;
}
return super.getAdditionalInfoColor();
}
@Override
public String getAdditionalInfoStr() {
if (openingHoursInfo != null) {
return openingHoursInfo.getInfo(getMapActivity());
}
return super.getAdditionalInfoStr();
}
@Override
public int getAdditionalInfoIconRes() {
if (openingHoursInfo != null) {
return R.drawable.ic_action_opening_hour_16;
}
return super.getAdditionalInfoIconRes();
} }
public static String getTypeStr(Amenity amenity) { public static String getTypeStr(Amenity amenity) {
@ -201,7 +220,7 @@ public class AmenityMenuController extends MenuController {
public static void addPlainMenuItems(Amenity amenity, String typeStr, MenuBuilder builder) { public static void addPlainMenuItems(Amenity amenity, String typeStr, MenuBuilder builder) {
if (!Algorithms.isEmpty(typeStr)) { if (!Algorithms.isEmpty(typeStr)) {
int resId = getLeftIconId(amenity); int resId = getRightIconId(amenity);
if (resId == 0) { if (resId == 0) {
PoiCategory pc = amenity.getType(); PoiCategory pc = amenity.getType();
resId = RenderingIcons.getBigIconResourceId(pc.getIconKeyName()); resId = RenderingIcons.getBigIconResourceId(pc.getIconKeyName());
@ -254,7 +273,7 @@ public class AmenityMenuController extends MenuController {
if (rts != null) { if (rts != null) {
for (TransportRoute rs : rts) { for (TransportRoute rs : rts) {
if (!containsRef(rs)) { if (!containsRef(rs)) {
TransportStopController.TransportStopType type = TransportStopController.TransportStopType.findType(rs.getType()); TransportStopType type = TransportStopType.findType(rs.getType());
TransportStopRoute r = new TransportStopRoute(); TransportStopRoute r = new TransportStopRoute();
r.type = type; r.type = type;
r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName(); r.desc = useEnglishNames ? rs.getEnName(true) : rs.getName();

View file

@ -18,6 +18,7 @@ import net.osmand.plus.mapcontextmenu.OpeningHoursInfo;
import net.osmand.plus.mapcontextmenu.builders.FavouritePointMenuBuilder; import net.osmand.plus.mapcontextmenu.builders.FavouritePointMenuBuilder;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment; import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import java.util.ArrayList; import java.util.ArrayList;
@ -27,7 +28,8 @@ public class FavouritePointMenuController extends MenuController {
private FavouritePoint fav; private FavouritePoint fav;
private MapMarker mapMarker; private MapMarker mapMarker;
private List<TransportStopController.TransportStopRoute> routes = new ArrayList<>(); private List<TransportStopRoute> routes = new ArrayList<>();
private OpeningHoursInfo openingHoursInfo;
public FavouritePointMenuController(MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) { public FavouritePointMenuController(MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) {
super(new FavouritePointMenuBuilder(mapActivity, fav), pointDescription, mapActivity); super(new FavouritePointMenuBuilder(mapActivity, fav), pointDescription, mapActivity);
@ -50,6 +52,11 @@ public class FavouritePointMenuController extends MenuController {
routes = transportStopController.processTransportStop(); routes = transportStopController.processTransportStop();
builder.setRoutes(routes); builder.setRoutes(routes);
} }
Object originObject = getBuilder().getOriginObject();
if (originObject instanceof Amenity) {
openingHoursInfo = AmenityMenuController.processOpeningHours((Amenity) originObject);
}
} }
@Override @Override
@ -65,7 +72,7 @@ public class FavouritePointMenuController extends MenuController {
} }
@Override @Override
public List<TransportStopController.TransportStopRoute> getTransportStopRoutes() { public List<TransportStopRoute> getTransportStopRoutes() {
return routes; return routes;
} }
@ -95,7 +102,7 @@ public class FavouritePointMenuController extends MenuController {
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), fav.getColor(), false); return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), fav.getColor(), false);
} }
@ -106,7 +113,7 @@ public class FavouritePointMenuController extends MenuController {
@Override @Override
public Drawable getSecondLineTypeIcon() { public Drawable getSecondLineTypeIcon() {
return getIcon(R.drawable.ic_action_group_name_16); return getIcon(R.drawable.ic_action_group_name_16, isLight() ? R.color.icon_color : R.color.ctx_menu_bottom_view_icon_dark);
} }
@Override @Override
@ -132,7 +139,7 @@ public class FavouritePointMenuController extends MenuController {
@Override @Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) { public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
if (!Algorithms.isEmpty(fav.getDescription())) { if (!Algorithms.isEmpty(fav.getDescription())) {
addPlainMenuItem(R.drawable.ic_action_note_dark, fav.getDescription(), true, false, null); addPlainMenuItem(R.drawable.ic_action_note_dark, null, fav.getDescription(), true, false, null);
} }
Object originObject = getBuilder().getOriginObject(); Object originObject = getBuilder().getOriginObject();
if (originObject != null) { if (originObject != null) {
@ -146,11 +153,26 @@ public class FavouritePointMenuController extends MenuController {
} }
@Override @Override
public OpeningHoursInfo getOpeningHoursInfo() { public int getAdditionalInfoColor() {
Object originObject = getBuilder().getOriginObject(); if (openingHoursInfo != null) {
if (originObject instanceof Amenity) { return openingHoursInfo.isOpened() ? R.color.ctx_menu_amenity_opened_text_color : R.color.ctx_menu_amenity_closed_text_color;
return AmenityMenuController.processOpeningHours((Amenity) originObject);
} }
return null; return 0;
}
@Override
public String getAdditionalInfoStr() {
if (openingHoursInfo != null) {
return openingHoursInfo.getInfo(getMapActivity());
}
return "";
}
@Override
public int getAdditionalInfoIconRes() {
if (openingHoursInfo != null) {
return R.drawable.ic_action_opening_hour_16;
}
return 0;
} }
} }

View file

@ -45,7 +45,7 @@ public class GpxItemMenuController extends MenuController {
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
return getIcon(R.drawable.ic_action_polygom_dark, R.color.osmand_orange); return getIcon(R.drawable.ic_action_polygom_dark, R.color.osmand_orange);
} }
} }

View file

@ -52,7 +52,7 @@ public class HistoryMenuController extends MenuController {
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
return getIcon(SearchHistoryFragment.getItemIcon(entry.getName())); return getIcon(SearchHistoryFragment.getItemIcon(entry.getName()));
} }

View file

@ -53,7 +53,7 @@ public class ImpassibleRoadsMenuController extends MenuController {
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
return ContextCompat.getDrawable(getMapActivity(), R.drawable.map_pin_avoid_road); return ContextCompat.getDrawable(getMapActivity(), R.drawable.map_pin_avoid_road);
} }
} }

View file

@ -118,23 +118,6 @@ public class MapDataMenuController extends MenuController {
leftDownloadButtonController.leftIconId = R.drawable.ic_action_import; leftDownloadButtonController.leftIconId = R.drawable.ic_action_import;
rightDownloadButtonController = new TitleButtonController() { rightDownloadButtonController = new TitleButtonController() {
@Override
public void buttonPressed() {
if (indexItem != null) {
if (backuped) {
deleteItem(indexItem.getBackupFile(app));
} else {
deleteItem(indexItem.getTargetFile(app));
}
} else if (localIndexInfo != null) {
deleteItem(new File(localIndexInfo.getPathToData()));
}
}
};
rightDownloadButtonController.caption = getMapActivity().getString(R.string.shared_string_delete);
rightDownloadButtonController.leftIconId = R.drawable.ic_action_delete_dark;
bottomTitleButtonController = new TitleButtonController() {
@Override @Override
public void buttonPressed() { public void buttonPressed() {
getMapActivity().getContextMenu().close(); getMapActivity().getContextMenu().close();
@ -158,7 +141,25 @@ public class MapDataMenuController extends MenuController {
mapActivity.getContextMenu().getLatLon(), selectedObjects); mapActivity.getContextMenu().getLatLon(), selectedObjects);
} }
}; };
bottomTitleButtonController.caption = getMapActivity().getString(R.string.download_select_map_types); rightDownloadButtonController.caption = getMapActivity().getString(R.string.download_select_map_types);
rightDownloadButtonController.leftIconId = R.drawable.ic_plugin_srtm;
bottomTitleButtonController = new TitleButtonController() {
@Override
public void buttonPressed() {
if (indexItem != null) {
if (backuped) {
deleteItem(indexItem.getBackupFile(app));
} else {
deleteItem(indexItem.getTargetFile(app));
}
} else if (localIndexInfo != null) {
deleteItem(new File(localIndexInfo.getPathToData()));
}
}
};
bottomTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_delete);
bottomTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark;
titleProgressController = new TitleProgressController() { titleProgressController = new TitleProgressController() {
@Override @Override
@ -178,6 +179,39 @@ public class MapDataMenuController extends MenuController {
updateData(); updateData();
} }
@Override
public boolean displayDistanceDirection() {
return true;
}
@Override
public int getAdditionalInfoColor() {
return R.color.icon_color;
}
@Override
public String getAdditionalInfoStr() {
double mb = 0;
if (backuped) {
if (localIndexInfo != null) {
mb = localIndexInfo.getSize();
} else if (indexItem != null) {
mb = indexItem.getArchiveSizeMB();
}
} else if (indexItem != null) {
mb = indexItem.getArchiveSizeMB();
}
if (mb != 0) {
return getMapActivity().getString(R.string.file_size_in_mb, mb);
}
return "";
}
@Override
public int getAdditionalInfoIconRes() {
return R.drawable.ic_sdcard_16;
}
@Override @Override
protected void setObject(Object object) { protected void setObject(Object object) {
if (object instanceof DownloadMapObject) { if (object instanceof DownloadMapObject) {
@ -197,7 +231,7 @@ public class MapDataMenuController extends MenuController {
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
int iconResId; int iconResId;
if (getDownloadActivityType() != null) { if (getDownloadActivityType() != null) {
iconResId = getDownloadActivityType().getIconResource(); iconResId = getDownloadActivityType().getIconResource();
@ -219,6 +253,10 @@ public class MapDataMenuController extends MenuController {
} else { } else {
res = getMapActivity().getString(R.string.shared_string_map); res = getMapActivity().getString(R.string.shared_string_map);
} }
DownloadActivityType downloadActivityType = getDownloadActivityType();
if (downloadActivityType != null) {
res += ", " + downloadActivityType.getString(getMapActivity());
}
if (getMenuType() == MenuType.STANDARD) { if (getMenuType() == MenuType.STANDARD) {
res += "\n"; res += "\n";
} }
@ -233,16 +271,16 @@ public class MapDataMenuController extends MenuController {
@Override @Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) { public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
if (indexItem != null) { if (indexItem != null) {
addPlainMenuItem(R.drawable.ic_action_info_dark, indexItem.getType().getString(getMapActivity()), false, false, null); addPlainMenuItem(R.drawable.ic_action_info_dark, null, indexItem.getType().getString(getMapActivity()), false, false, null);
StringBuilder sizeStr = new StringBuilder(); StringBuilder sizeStr = new StringBuilder();
sizeStr.append(indexItem.getSizeDescription(getMapActivity())); sizeStr.append(indexItem.getSizeDescription(getMapActivity()));
if (backuped) { if (backuped) {
sizeStr.append("").append(LocalIndexType.DEACTIVATED.getHumanString(getMapActivity())); sizeStr.append("").append(LocalIndexType.DEACTIVATED.getHumanString(getMapActivity()));
} }
addPlainMenuItem(R.drawable.ic_action_info_dark, sizeStr.toString(), false, false, null); addPlainMenuItem(R.drawable.ic_action_info_dark, null, sizeStr.toString(), false, false, null);
} else if (localIndexInfo != null) { } else if (localIndexInfo != null) {
if (getDownloadActivityType() != null) { if (getDownloadActivityType() != null) {
addPlainMenuItem(R.drawable.ic_action_info_dark, getDownloadActivityType().getString(getMapActivity()), false, false, null); addPlainMenuItem(R.drawable.ic_action_info_dark, null, getDownloadActivityType().getString(getMapActivity()), false, false, null);
} }
StringBuilder sizeStr = new StringBuilder(); StringBuilder sizeStr = new StringBuilder();
if (localIndexInfo.getSize() >= 0) { if (localIndexInfo.getSize() >= 0) {
@ -259,7 +297,7 @@ public class MapDataMenuController extends MenuController {
sizeStr.append(LocalIndexType.DEACTIVATED.getHumanString(getMapActivity())); sizeStr.append(LocalIndexType.DEACTIVATED.getHumanString(getMapActivity()));
} }
} }
addPlainMenuItem(R.drawable.ic_action_info_dark, sizeStr.toString(), false, false, null); addPlainMenuItem(R.drawable.ic_action_info_dark, null, sizeStr.toString(), false, false, null);
} }
if (!Algorithms.isEmpty(mapObject.getWorldRegion().getParams().getWikiLink())) { if (!Algorithms.isEmpty(mapObject.getWorldRegion().getParams().getWikiLink())) {
String[] items = mapObject.getWorldRegion().getParams().getWikiLink().split(":"); String[] items = mapObject.getWorldRegion().getParams().getWikiLink().split(":");
@ -269,7 +307,7 @@ public class MapDataMenuController extends MenuController {
} else { } else {
url = "https://wikipedia.org/wiki/" + items[0].replace(' ', '_'); url = "https://wikipedia.org/wiki/" + items[0].replace(' ', '_');
} }
addPlainMenuItem(R.drawable.ic_world_globe_dark, url, false, true, null); addPlainMenuItem(R.drawable.ic_world_globe_dark, null, url, false, true, null);
} }
if (!Algorithms.isEmpty(mapObject.getWorldRegion().getParams().getPopulation())) { if (!Algorithms.isEmpty(mapObject.getWorldRegion().getParams().getPopulation())) {
String population = mapObject.getWorldRegion().getParams().getPopulation(); String population = mapObject.getWorldRegion().getParams().getPopulation();
@ -283,14 +321,14 @@ public class MapDataMenuController extends MenuController {
b.insert(0, population.charAt(i)); b.insert(0, population.charAt(i));
k++; k++;
} }
addPlainMenuItem(R.drawable.ic_action_info_dark, getMapActivity().getResources().getString(R.string.poi_population) addPlainMenuItem(R.drawable.ic_action_info_dark, null, getMapActivity().getResources().getString(R.string.poi_population)
+ ": " + b, false, false, null); + ": " + b, false, false, null);
} }
if (indexItem != null) { if (indexItem != null) {
DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(getMapActivity()); DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(getMapActivity());
addPlainMenuItem(R.drawable.ic_action_data, indexItem.getRemoteDate(dateFormat), false, false, null); addPlainMenuItem(R.drawable.ic_action_data, null, indexItem.getRemoteDate(dateFormat), false, false, null);
} else if (localIndexInfo != null) { } else if (localIndexInfo != null) {
addPlainMenuItem(R.drawable.ic_action_data, localIndexInfo.getDescription(), false, false, null); addPlainMenuItem(R.drawable.ic_action_data, null, localIndexInfo.getDescription(), false, false, null);
} }
} }
@ -349,8 +387,8 @@ public class MapDataMenuController extends MenuController {
leftDownloadButtonController.visible = false; leftDownloadButtonController.visible = false;
} }
rightDownloadButtonController.visible = downloaded; bottomTitleButtonController.visible = downloaded;
bottomTitleButtonController.visible = (otherIndexItems != null && otherIndexItems.size() > 0) rightDownloadButtonController.visible = (otherIndexItems != null && otherIndexItems.size() > 0)
|| (otherLocalIndexInfos != null && otherLocalIndexInfos.size() > 0); || (otherLocalIndexInfos != null && otherLocalIndexInfos.size() > 0);
boolean internetConnectionAvailable = boolean internetConnectionAvailable =

View file

@ -89,7 +89,7 @@ public class MapMarkerMenuController extends MenuController {
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
return MapMarkerDialogHelper.getMapMarkerIcon(getMapActivity().getMyApplication(), mapMarker.colorIndex); return MapMarkerDialogHelper.getMapMarkerIcon(getMapActivity().getMyApplication(), mapMarker.colorIndex);
} }

View file

@ -42,7 +42,7 @@ public class MyLocationMenuController extends MenuController {
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
ApplicationMode appMode = getMapActivity().getMyApplication().getSettings().getApplicationMode(); ApplicationMode appMode = getMapActivity().getMyApplication().getSettings().getApplicationMode();
return getMapActivity().getResources().getDrawable(appMode.getResourceLocationDay()); return getMapActivity().getResources().getDrawable(appMode.getResourceLocationDay());
} }

View file

@ -46,7 +46,7 @@ public class PointDescriptionMenuController extends MenuController {
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
return getIcon(SearchHistoryFragment.getItemIcon(getPointDescription())); return getIcon(SearchHistoryFragment.getItemIcon(getPointDescription()));
} }

View file

@ -49,7 +49,7 @@ public class RenderedObjectMenuController extends MenuController {
} }
@Override @Override
public int getLeftIconId() { public int getRightIconId() {
if (renderedObject.getIconRes() != null && RenderingIcons.containsBigIcon(renderedObject.getIconRes())) { if (renderedObject.getIconRes() != null && RenderingIcons.containsBigIcon(renderedObject.getIconRes())) {
return RenderingIcons.getBigIconResourceId(renderedObject.getIconRes()); return RenderingIcons.getBigIconResourceId(renderedObject.getIconRes());
} else { } else {
@ -95,7 +95,7 @@ public class RenderedObjectMenuController extends MenuController {
if (entry.getKey().equalsIgnoreCase("maxheight")) { if (entry.getKey().equalsIgnoreCase("maxheight")) {
AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(entry.getKey()); AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(entry.getKey());
if (pt != null) { if (pt != null) {
addPlainMenuItem(R.drawable.ic_action_note_dark, pt.getTranslation() + ": " + entry.getValue(), false, false, null); addPlainMenuItem(R.drawable.ic_action_note_dark, null, pt.getTranslation() + ": " + entry.getValue(), false, false, null);
} }
} }
} }
@ -110,7 +110,7 @@ public class RenderedObjectMenuController extends MenuController {
} else { } else {
link = "https://www.openstreetmap.org/way/"; link = "https://www.openstreetmap.org/way/";
} }
addPlainMenuItem(R.drawable.ic_action_info_dark, link + (renderedObject.getId() >> 7), true, true, null); addPlainMenuItem(R.drawable.ic_action_info_dark, null, link + (renderedObject.getId() >> 7), true, true, null);
} }
addMyLocationToPlainItems(latLon); addMyLocationToPlainItems(latLon);
} }

View file

@ -79,7 +79,7 @@ public class TargetPointMenuController extends MenuController {
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
if (targetPoint.start) { if (targetPoint.start) {
return getIconOrig(R.drawable.list_startpoint); return getIconOrig(R.drawable.list_startpoint);
} else if (!targetPoint.intermediate) { } else if (!targetPoint.intermediate) {

View file

@ -1,5 +1,6 @@
package net.osmand.plus.mapcontextmenu.controllers; package net.osmand.plus.mapcontextmenu.controllers;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
@ -12,7 +13,7 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute; import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.views.TransportStopsLayer; import net.osmand.plus.views.TransportStopsLayer;
import java.util.List; import java.util.List;
@ -46,6 +47,30 @@ public class TransportRouteController extends MenuController {
mapActivity.getContextMenu().closeToolbar(TransportRouteController.this); mapActivity.getContextMenu().closeToolbar(TransportRouteController.this);
} }
}); });
leftTitleButtonController = new TitleButtonController() {
@Override
public void buttonPressed() {
final int previousStop = getPreviousStop();
if (previousStop != -1) {
showTransportStop(transportRoute.route.getForwardStops().get(previousStop));
}
}
};
leftTitleButtonController.caption = mapActivity.getString(R.string.shared_string_previous);
leftTitleButtonController.leftIconId = R.drawable.ic_arrow_back;
rightTitleButtonController = new TitleButtonController() {
@Override
public void buttonPressed() {
final int nextStop = getNextStop();
if (nextStop != -1) {
showTransportStop(transportRoute.route.getForwardStops().get(nextStop));
}
}
};
rightTitleButtonController.caption = mapActivity.getString(R.string.shared_string_next);
rightTitleButtonController.rightIconId = R.drawable.ic_arrow_forward;
} }
@Override @Override
@ -55,13 +80,18 @@ public class TransportRouteController extends MenuController {
} }
} }
@Override
public boolean navigateInPedestrianMode() {
return true;
}
@Override @Override
protected Object getObject() { protected Object getObject() {
return transportRoute; return transportRoute;
} }
@Override @Override
public int getLeftIconId() { public int getRightIconId() {
return this.transportRoute.type == null ? return this.transportRoute.type == null ?
R.drawable.mx_public_transport : R.drawable.mx_public_transport :
this.transportRoute.type.getTopResourceId(); this.transportRoute.type.getTopResourceId();
@ -77,11 +107,6 @@ public class TransportRouteController extends MenuController {
return false; return false;
} }
@Override
public boolean navigateButtonVisible() {
return false;
}
@Override @Override
public boolean isClosable() { public boolean isClosable() {
return false; return false;
@ -94,13 +119,17 @@ public class TransportRouteController extends MenuController {
@Override @Override
public String getTypeStr() { public String getTypeStr() {
if (transportRoute.refStop != null) { return getPointDescription().getName();
return transportRoute.refStop.getName();
} else if (transportRoute.stop != null) {
return transportRoute.stop.getName();
} else {
return getPointDescription().getTypeName();
} }
private String getStopType() {
return getMapActivity().getString(transportRoute.getTypeStrRes()) + " " + getMapActivity().getString(R.string.transport_Stop).toLowerCase();
}
@Override
public void updateData() {
super.updateData();
updateControllers();
} }
@Override @Override
@ -121,49 +150,31 @@ public class TransportRouteController extends MenuController {
} }
} }
@Override private void updateControllers() {
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, final LatLon latLon) { boolean previousStopEnabled = false;
super.addPlainMenuItems(typeStr, pointDescription, latLon); final int previousStop = getPreviousStop();
List<TransportStop> stops = transportRoute.route.getForwardStops(); if (previousStop != -1) {
boolean useEnglishNames = getMapActivity().getMyApplication().getSettings().usingEnglishNames(); previousStopEnabled = true;
int currentStop = -1;
for (int i = 0; i < stops.size(); i++) {
final TransportStop stop = stops.get(i);
if (stop.getName().equals(transportRoute.stop.getName())) {
currentStop = i;
break;
} }
} leftTitleButtonController.enabled = previousStopEnabled;
int defaultIcon = transportRoute.type == null ? R.drawable.mx_route_bus_ref : transportRoute.type.getResourceId();
int startPosition = 0;
if (!transportRoute.showWholeRoute) {
startPosition = (currentStop == -1 ? 0 : currentStop);
if (currentStop > 0) {
addPlainMenuItem(defaultIcon, getMapActivity().getString(R.string.route_stops_before, currentStop),
false, false, new OnClickListener() {
@Override boolean nextStopEnabled = false;
public void onClick(View arg0) { final int nextStop = getNextStop();
MapContextMenu menu = getMapActivity().getContextMenu(); if (nextStop != -1) {
menu.showOrUpdate(latLon, getPointDescription(), transportRoute); nextStopEnabled = true;
} }
}); rightTitleButtonController.enabled = nextStopEnabled;
} }
}
for (int i = startPosition; i < stops.size(); i++) {
final TransportStop stop = stops.get(i);
final String name = useEnglishNames ? stop.getEnName(true) : stop.getName();
addPlainMenuItem(currentStop == i ? R.drawable.ic_action_marker_dark : defaultIcon,
name, false, false, new OnClickListener() {
@Override private void showTransportStop(TransportStop stop) {
public void onClick(View arg0) {
if (mapContextMenu != null) { if (mapContextMenu != null) {
transportRoute.stop = stop; transportRoute.stop = stop;
transportRoute.refStop = stop; transportRoute.refStop = stop;
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE, PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE,
transportRoute.getDescription(getMapActivity().getMyApplication(), false)); transportRoute.getDescription(getMapActivity().getMyApplication(), false));
updateControllers();
LatLon stopLocation = stop.getLocation(); LatLon stopLocation = stop.getLocation();
if (mapContextMenu.isVisible()) { if (mapContextMenu.isVisible()) {
mapContextMenu.updateMapCenter(stopLocation); mapContextMenu.updateMapCenter(stopLocation);
@ -175,6 +186,84 @@ public class TransportRouteController extends MenuController {
mapContextMenu.setMapZoom(15); mapContextMenu.setMapZoom(15);
mapContextMenu.showOrUpdate(stopLocation, pd, transportRoute); mapContextMenu.showOrUpdate(stopLocation, pd, transportRoute);
} }
}
private int getCurrentStop() {
List<TransportStop> stops = transportRoute.route.getForwardStops();
for (int i = 0; i < stops.size(); i++) {
final TransportStop stop = stops.get(i);
if (stop.getName().equals(transportRoute.stop.getName())) {
return i;
}
}
return -1;
}
private int getNextStop() {
List<TransportStop> stops = transportRoute.route.getForwardStops();
int currentPos = getCurrentStop();
if (currentPos != -1 && currentPos + 1 < stops.size()) {
return currentPos + 1;
}
return -1;
}
private int getPreviousStop() {
int currentPos = getCurrentStop();
if (currentPos > 0) {
return currentPos - 1;
}
return -1;
}
@Override
public String getNameStr() {
if (transportRoute.refStop != null && !TextUtils.isEmpty(transportRoute.refStop.getName())) {
return transportRoute.refStop.getName();
} else if (transportRoute.stop != null && !TextUtils.isEmpty(transportRoute.stop.getName())) {
return transportRoute.stop.getName();
} else if (!TextUtils.isEmpty(getPointDescription().getTypeName())) {
return getPointDescription().getTypeName();
} else {
return getStopType();
}
}
@Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, final LatLon latLon) {
super.addPlainMenuItems(typeStr, pointDescription, latLon);
List<TransportStop> stops = transportRoute.route.getForwardStops();
boolean useEnglishNames = getMapActivity().getMyApplication().getSettings().usingEnglishNames();
int currentStop = getCurrentStop();
int defaultIcon = transportRoute.type == null ? R.drawable.mx_route_bus_ref : transportRoute.type.getResourceId();
int startPosition = 0;
if (!transportRoute.showWholeRoute) {
startPosition = (currentStop == -1 ? 0 : currentStop);
if (currentStop > 0) {
addPlainMenuItem(defaultIcon, getMapActivity().getString(R.string.shared_string_show),
getMapActivity().getString(R.string.route_stops_before, currentStop),
false, false, new OnClickListener() {
@Override
public void onClick(View arg0) {
MapContextMenu menu = getMapActivity().getContextMenu();
menu.showOrUpdate(latLon, getPointDescription(), transportRoute);
}
});
}
}
for (int i = startPosition; i < stops.size(); i++) {
final TransportStop stop = stops.get(i);
String name = useEnglishNames ? stop.getEnName(true) : stop.getName();
if (TextUtils.isEmpty(name)) {
name = getStopType();
}
addPlainMenuItem(currentStop == i ? R.drawable.ic_action_marker_dark : defaultIcon,
null, name, false, false, new OnClickListener() {
@Override
public void onClick(View arg0) {
showTransportStop(stop);
/* /*
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_STOP, PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_STOP,
getMapActivity().getString(R.string.transport_Stop), name); getMapActivity().getString(R.string.transport_Stop), name);
@ -202,7 +291,7 @@ public class TransportRouteController extends MenuController {
TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer(); TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
int cz = transportRoute.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox()); int cz = transportRoute.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox());
getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom()); getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
stopsLayer.setRoute(transportRoute.route); stopsLayer.setRoute(transportRoute);
} }
private void resetRoute() { private void resetRoute() {

View file

@ -6,17 +6,16 @@ import android.view.View.OnClickListener;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect; import net.osmand.data.QuadRect;
import net.osmand.data.RotatedTileBox;
import net.osmand.data.TransportRoute; import net.osmand.data.TransportRoute;
import net.osmand.data.TransportStop; import net.osmand.data.TransportStop;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.resources.TransportIndexRepository; import net.osmand.plus.resources.TransportIndexRepository;
import net.osmand.plus.transport.TransportStopType;
import net.osmand.plus.views.TransportStopsLayer; import net.osmand.plus.views.TransportStopsLayer;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
@ -29,51 +28,6 @@ import java.util.List;
public class TransportStopController extends MenuController { public class TransportStopController extends MenuController {
public enum TransportStopType {
BUS(R.drawable.mx_route_bus_ref, R.drawable.mx_route_bus_ref),
FERRY(R.drawable.mx_route_ferry_ref, R.drawable.mx_route_ferry_ref),
FUNICULAR(R.drawable.mx_route_funicular_ref, R.drawable.mx_route_funicular_ref),
LIGHT_RAIL(R.drawable.mx_route_light_rail_ref, R.drawable.mx_route_light_rail_ref),
MONORAIL(R.drawable.mx_route_monorail_ref, R.drawable.mx_route_monorail_ref),
RAILWAY(R.drawable.mx_route_railway_ref, R.drawable.mx_route_railway_ref),
SHARE_TAXI(R.drawable.mx_route_share_taxi_ref, R.drawable.mx_route_share_taxi_ref),
TRAIN(R.drawable.mx_route_train_ref, R.drawable.mx_route_train_ref),
TRAM(R.drawable.mx_route_tram_ref, R.drawable.mx_railway_tram_stop),
TROLLEYBUS(R.drawable.mx_route_trolleybus_ref, R.drawable.mx_route_trolleybus_ref),
SUBWAY(R.drawable.mx_subway_station, R.drawable.mx_subway_station);
final int resId;
final int topResId;
TransportStopType(int resId, int topResId) {
this.resId = resId;
this.topResId = topResId;
}
public int getResourceId() {
return resId;
}
public int getTopResourceId() {
return topResId;
}
public boolean isTopType() {
return this == TRAM || this == SUBWAY;
}
public static TransportStopType findType(String typeName) {
String tName = typeName.toUpperCase();
for (TransportStopType t : values()) {
if (t.name().equals(tName)) {
return t;
}
}
return null;
}
}
private TransportStop transportStop; private TransportStop transportStop;
private List<TransportStopRoute> routes = new ArrayList<>(); private List<TransportStopRoute> routes = new ArrayList<>();
private TransportStopType topType; private TransportStopType topType;
@ -82,18 +36,21 @@ public class TransportStopController extends MenuController {
PointDescription pointDescription, TransportStop transportStop) { PointDescription pointDescription, TransportStop transportStop) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity); super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
this.transportStop = transportStop; this.transportStop = transportStop;
routes = processTransportStop(); processRoutes();
builder.setRoutes(routes);
} }
@Override @Override
protected void setObject(Object object) { protected void setObject(Object object) {
if (object instanceof TransportStop) { if (object instanceof TransportStop) {
this.transportStop = (TransportStop) object; this.transportStop = (TransportStop) object;
processRoutes();
}
}
private void processRoutes() {
routes = processTransportStop(); routes = processTransportStop();
builder.setRoutes(routes); builder.setRoutes(routes);
} }
}
@Override @Override
protected Object getObject() { protected Object getObject() {
@ -101,7 +58,7 @@ public class TransportStopController extends MenuController {
} }
@Override @Override
public int getLeftIconId() { public int getRightIconId() {
if (topType == null) { if (topType == null) {
return R.drawable.mx_public_transport; return R.drawable.mx_public_transport;
} else { } else {
@ -204,42 +161,4 @@ public class TransportStopController extends MenuController {
return false; return false;
} }
public static class TransportStopRoute {
public TransportStop refStop;
public TransportStopType type;
public String desc;
public TransportRoute route;
public TransportStop stop;
public int distance;
public boolean showWholeRoute;
public String getDescription(OsmandApplication ctx, boolean useDistance) {
if (useDistance && distance > 0) {
String nm = OsmAndFormatter.getFormattedDistance(distance, ctx);
if (refStop != null && !refStop.getName().equals(stop.getName())) {
nm = refStop.getName() + ", " + nm;
}
return desc + " (" + nm + ")";
}
return desc;
}
public int calculateZoom(int startPosition, RotatedTileBox currentRotatedTileBox) {
RotatedTileBox cp = currentRotatedTileBox.copy();
boolean notContains = true;
while (cp.getZoom() > 12 && notContains) {
notContains = false;
List<TransportStop> sts = route.getForwardStops();
for(int i = startPosition; i < sts.size(); i++) {
TransportStop st = sts.get(startPosition);
if (!cp.containsLatLon(st.getLocation())) {
notContains = true;
break;
}
}
cp.setZoom(cp.getZoom() - 1);
}
return cp.getZoom();
}
}
} }

View file

@ -76,17 +76,17 @@ public class WptPtMenuController extends MenuController {
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(),
wpt.getColor(ContextCompat.getColor(getMapActivity(), R.color.gpx_color_point)), false); wpt.getColor(ContextCompat.getColor(getMapActivity(), R.color.gpx_color_point)), false);
} }
@Override @Override
public Drawable getAdditionalLineTypeIcon() { public Drawable getSubtypeIcon() {
if (Algorithms.isEmpty(getAdditionalTypeStr())) { if (Algorithms.isEmpty(getSubtypeStr())) {
return null; return null;
} else { } else {
return getIcon(R.drawable.ic_action_group_name_16); return getIcon(R.drawable.ic_action_group_name_16, isLight() ? R.color.icon_color : R.color.ctx_menu_bottom_view_icon_dark);
} }
} }
@ -111,7 +111,7 @@ public class WptPtMenuController extends MenuController {
} }
@Override @Override
public String getAdditionalTypeStr() { public String getSubtypeStr() {
return wpt.category != null ? wpt.category : ""; return wpt.category != null ? wpt.category : "";
} }

View file

@ -4,6 +4,7 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -38,10 +39,10 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele
view = inflater.inflate(R.layout.menu_obj_selection_fragment, container, false); view = inflater.inflate(R.layout.menu_obj_selection_fragment, container, false);
if (menu.isLandscapeLayout()) { if (menu.isLandscapeLayout()) {
AndroidUtils.setBackground(view.getContext(), view, !menu.isLight(), AndroidUtils.setBackground(view.getContext(), view, !menu.isLight(),
R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark); R.drawable.multi_selection_menu_bg_light_land, R.drawable.multi_selection_menu_bg_dark_land);
} else { } else {
AndroidUtils.setBackground(view.getContext(), view, !menu.isLight(), AndroidUtils.setBackground(view.getContext(), view, !menu.isLight(),
R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark); R.drawable.multi_selection_menu_bg_light, R.drawable.multi_selection_menu_bg_dark);
} }
ListView listView = (ListView) view.findViewById(R.id.list); ListView listView = (ListView) view.findViewById(R.id.list);
@ -49,11 +50,6 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele
AndroidUtils.addStatusBarPadding21v(getActivity(), listView); AndroidUtils.addStatusBarPadding21v(getActivity(), listView);
} }
View headerView = inflater.inflate(R.layout.menu_obj_selection_header, listView, false); View headerView = inflater.inflate(R.layout.menu_obj_selection_header, listView, false);
if (!menu.isLight()) {
((TextViewEx) headerView.findViewById(R.id.header_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
((TextView) view.findViewById(R.id.cancel_row_text)).setTextColor(getResources().getColor(R.color.color_dialog_buttons_dark));
view.findViewById(R.id.divider).setBackgroundResource(R.color.dashboard_divider_dark);
}
headerView.setOnClickListener(null); headerView.setOnClickListener(null);
listView.addHeaderView(headerView); listView.addHeaderView(headerView);
listAdapter = createAdapter(); listAdapter = createAdapter();
@ -62,6 +58,9 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele
runLayoutListener(); runLayoutListener();
view.findViewById(R.id.divider).setBackgroundColor(ContextCompat.getColor(getContext(), menu.isLight() ? R.color.multi_selection_menu_divider_light : R.color.multi_selection_menu_divider_dark));
((TextView) view.findViewById(R.id.cancel_row_text)).setTextColor(ContextCompat.getColor(getContext(), menu.isLight() ? R.color.multi_selection_menu_close_btn_light : R.color.multi_selection_menu_close_btn_dark));
view.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {

View file

@ -259,24 +259,16 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
private void updateViaView(final View parentView) { private void updateViaView(final View parentView) {
String via = generateViaDescription(); String via = generateViaDescription();
View viaLayout = parentView.findViewById(R.id.ViaLayout); View viaLayout = parentView.findViewById(R.id.ViaLayout);
View fromLayoutEmptyView = parentView.findViewById(R.id.from_layout_empty_view); View viaLayoutDivider = parentView.findViewById(R.id.viaLayoutDivider);
View toLayoutEmptyView = parentView.findViewById(R.id.to_layout_empty_view);
View dividerFromDropDownEmpty = parentView.findViewById(R.id.divider_from_drop_down_empty);
ImageView swapDirectionView = (ImageView) parentView.findViewById(R.id.swap_direction_image_view); ImageView swapDirectionView = (ImageView) parentView.findViewById(R.id.swap_direction_image_view);
if (via.length() == 0) { if (via.length() == 0) {
viaLayout.setVisibility(View.GONE); viaLayout.setVisibility(View.GONE);
parentView.findViewById(R.id.viaLayoutDivider).setVisibility(View.GONE); viaLayoutDivider.setVisibility(View.GONE);
dividerFromDropDownEmpty.setVisibility(View.GONE);
fromLayoutEmptyView.setVisibility(View.VISIBLE);
toLayoutEmptyView.setVisibility(View.VISIBLE);
swapDirectionView.setVisibility(View.VISIBLE); swapDirectionView.setVisibility(View.VISIBLE);
} else { } else {
fromLayoutEmptyView.setVisibility(View.GONE);
toLayoutEmptyView.setVisibility(View.GONE);
swapDirectionView.setVisibility(View.GONE); swapDirectionView.setVisibility(View.GONE);
dividerFromDropDownEmpty.setVisibility(View.VISIBLE);
viaLayout.setVisibility(View.VISIBLE); viaLayout.setVisibility(View.VISIBLE);
parentView.findViewById(R.id.viaLayoutDivider).setVisibility(View.VISIBLE); viaLayoutDivider.setVisibility(View.VISIBLE);
((TextView) parentView.findViewById(R.id.ViaView)).setText(via); ((TextView) parentView.findViewById(R.id.ViaView)).setText(via);
} }
@ -294,7 +286,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
swapDirectionView.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_change_navigation_points, swapDirectionView.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_change_navigation_points,
isLight() ? R.color.route_info_control_icon_color_light : R.color.route_info_control_icon_color_dark)); isLight() ? R.color.route_info_control_icon_color_light : R.color.route_info_control_icon_color_dark));
AndroidUtils.setBackground(mapActivity, swapDirectionView, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
swapDirectionView.setOnClickListener(new View.OnClickListener() { swapDirectionView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -638,7 +629,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} else { } else {
infoIcon.setImageDrawable(ctx.getIconsCache().getIcon(R.drawable.ic_action_route_distance, R.color.route_info_unchecked_mode_icon_color)); infoIcon.setImageDrawable(ctx.getIconsCache().getIcon(R.drawable.ic_action_route_distance, R.color.route_info_unchecked_mode_icon_color));
infoIcon.setVisibility(View.VISIBLE); infoIcon.setVisibility(View.VISIBLE);
durationIcon.setImageDrawable(ctx.getIconsCache().getIcon(R.drawable.ic_action_time, R.color.route_info_unchecked_mode_icon_color)); durationIcon.setImageDrawable(ctx.getIconsCache().getIcon(R.drawable.ic_action_time_span, R.color.route_info_unchecked_mode_icon_color));
durationIcon.setVisibility(View.VISIBLE); durationIcon.setVisibility(View.VISIBLE);
infoDistanceView.setVisibility(View.VISIBLE); infoDistanceView.setVisibility(View.VISIBLE);
infoDurationView.setVisibility(View.VISIBLE); infoDurationView.setVisibility(View.VISIBLE);

View file

@ -150,8 +150,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
R.color.route_info_divider_light, R.color.route_info_divider_dark); R.color.route_info_divider_light, R.color.route_info_divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerFromDropDown), nightMode, AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerFromDropDown), nightMode,
R.color.route_info_divider_light, R.color.route_info_divider_dark); R.color.route_info_divider_light, R.color.route_info_divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.divider_from_drop_down_empty), nightMode,
R.color.route_info_divider_light, R.color.route_info_divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.viaLayoutDivider), nightMode, AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.viaLayoutDivider), nightMode,
R.color.route_info_divider_light, R.color.route_info_divider_dark); R.color.route_info_divider_light, R.color.route_info_divider_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerToDropDown), nightMode, AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerToDropDown), nightMode,
@ -170,14 +168,6 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.fromTitle), nightMode); AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.fromTitle), nightMode);
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.InfoTextView), nightMode); AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.InfoTextView), nightMode);
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.FromLayout), nightMode);
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.ViaLayout), nightMode);
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.ToLayout), nightMode);
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.Info), nightMode);
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.Next), nightMode);
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.Prev), nightMode);
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.DistanceText), nightMode); AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.DistanceText), nightMode);
AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.DistanceTitle), nightMode); AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.DistanceTitle), nightMode);
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.DurationText), nightMode); AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.DurationText), nightMode);

View file

@ -38,8 +38,6 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
} }
final MapMultiSelectionMenu.MenuObject item = getItem(position); final MapMultiSelectionMenu.MenuObject item = getItem(position);
if (item != null) { if (item != null) {
convertView.findViewById(R.id.content).setBackgroundResource(menu.isLight()
? R.drawable.expandable_list_item_background_light : R.drawable.expandable_list_item_background_dark);
convertView.setOnClickListener(new View.OnClickListener() { convertView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -51,8 +49,8 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
IconsCache iconsCache = menu.getMapActivity().getMyApplication().getIconsCache(); IconsCache iconsCache = menu.getMapActivity().getMyApplication().getIconsCache();
final View iconLayout = convertView.findViewById(R.id.context_menu_icon_layout); final View iconLayout = convertView.findViewById(R.id.context_menu_icon_layout);
final ImageView iconView = (ImageView) convertView.findViewById(R.id.context_menu_icon_view); final ImageView iconView = (ImageView) convertView.findViewById(R.id.context_menu_icon_view);
Drawable icon = item.getLeftIcon(); Drawable icon = item.getRightIcon();
int iconId = item.getLeftIconId(); int iconId = item.getRightIconId();
if (icon != null) { if (icon != null) {
iconView.setImageDrawable(icon); iconView.setImageDrawable(icon);
iconLayout.setVisibility(View.VISIBLE); iconLayout.setVisibility(View.VISIBLE);
@ -66,7 +64,7 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
// Text line 1 // Text line 1
TextView line1 = (TextView) convertView.findViewById(R.id.context_menu_line1); TextView line1 = (TextView) convertView.findViewById(R.id.context_menu_line1);
((TextView) convertView.findViewById(R.id.context_menu_line1)).setTextColor(ContextCompat.getColor(getContext(), line1.setTextColor(ContextCompat.getColor(getContext(),
!menu.isLight() ? R.color.ctx_menu_title_color_dark : R.color.ctx_menu_title_color_light)); !menu.isLight() ? R.color.ctx_menu_title_color_dark : R.color.ctx_menu_title_color_light));
line1.setText(item.getTitleStr()); line1.setText(item.getTitleStr());
@ -80,9 +78,7 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
// Divider // Divider
View divider = convertView.findViewById(R.id.divider); View divider = convertView.findViewById(R.id.divider);
if (!menu.isLight()) { divider.setBackgroundColor(ContextCompat.getColor(getContext(), menu.isLight() ? R.color.multi_selection_menu_divider_light : R.color.multi_selection_menu_divider_dark));
divider.setBackgroundResource(R.color.dashboard_divider_dark);
}
divider.setVisibility(position != getCount() - 1 ? View.VISIBLE : View.GONE); divider.setVisibility(position != getCount() - 1 ? View.VISIBLE : View.GONE);
} }

View file

@ -56,7 +56,7 @@ public class MapillaryMenuController extends MenuController {
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
return getIcon(R.drawable.ic_action_mapillary, R.color.mapillary_color); return getIcon(R.drawable.ic_action_mapillary, R.color.mapillary_color);
} }

View file

@ -754,26 +754,12 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm
private class KeyboardAdapter extends ArrayAdapter<Object> { private class KeyboardAdapter extends ArrayAdapter<Object> {
private ColorStateList dividerControlColorStateList = new ColorStateList( private ColorStateList dividerControlColorStateList = AndroidUtils.createColorStateList(getContext(), false,
new int[][]{ R.color.keyboard_item_divider_control_color_light, R.color.keyboard_item_divider_control_color_light_pressed,
new int[]{android.R.attr.state_pressed}, 0, 0);
new int[]{} private ColorStateList numberColorStateList = AndroidUtils.createColorStateList(getContext(), false,
}, R.color.keyboard_item_text_color_light, R.color.keyboard_item_text_color_light_pressed,
new int[] { 0, 0);
getResources().getColor(R.color.keyboard_item_divider_control_color_light_pressed),
getResources().getColor(R.color.keyboard_item_divider_control_color_light)
}
);
private ColorStateList numberColorStateList = new ColorStateList(
new int[][]{
new int[]{android.R.attr.state_pressed},
new int[]{}
},
new int[] {
getResources().getColor(R.color.keyboard_item_text_color_light_pressed),
getResources().getColor(R.color.keyboard_item_text_color_light)
}
);
KeyboardAdapter(@NonNull Context context, @NonNull Object[] objects) { KeyboardAdapter(@NonNull Context context, @NonNull Object[] objects) {
super(context, 0, objects); super(context, 0, objects);

View file

@ -30,8 +30,8 @@ public class EditPOIMenuBuilder extends MenuBuilder {
if (osmPoint instanceof OsmNotesPoint) { if (osmPoint instanceof OsmNotesPoint) {
OsmNotesPoint notes = (OsmNotesPoint) osmPoint; OsmNotesPoint notes = (OsmNotesPoint) osmPoint;
buildRow(view, R.drawable.ic_action_note_dark, notes.getText(), 0, false, null, false, 0, false, null, false); buildRow(view, R.drawable.ic_action_note_dark, null, notes.getText(), 0, false, null, false, 0, false, null, false);
buildRow(view, R.drawable.ic_group, notes.getAuthor(), 0, false, null, false, 0, false, null, false); buildRow(view, R.drawable.ic_group, null, notes.getAuthor(), 0, false, null, false, 0, false, null, false);
} else if (osmPoint instanceof OpenstreetmapPoint) { } else if (osmPoint instanceof OpenstreetmapPoint) {
OpenstreetmapPoint point = (OpenstreetmapPoint) osmPoint; OpenstreetmapPoint point = (OpenstreetmapPoint) osmPoint;
@ -56,7 +56,7 @@ public class EditPOIMenuBuilder extends MenuBuilder {
if (resId == 0) { if (resId == 0) {
resId = R.drawable.ic_action_folder_stroke; resId = R.drawable.ic_action_folder_stroke;
} }
buildRow(view, resId, poiTranslation, 0, false, null, false, 0, false, null, false); buildRow(view, resId, null, poiTranslation, 0, false, null, false, 0, false, null, false);
break; break;
} }
} }
@ -67,11 +67,11 @@ public class EditPOIMenuBuilder extends MenuBuilder {
continue; continue;
} }
String text = e.getKey() + "=" + e.getValue(); String text = e.getKey() + "=" + e.getValue();
buildRow(view, R.drawable.ic_action_info_dark, text, 0, false, null, false, 0, false, null, false); buildRow(view, R.drawable.ic_action_info_dark, null, text, 0, false, null, false, 0, false, null, false);
} }
} }
buildRow(view, R.drawable.ic_action_get_my_location, PointDescription.getLocationName(app, buildRow(view, R.drawable.ic_action_get_my_location, null, PointDescription.getLocationName(app,
osmPoint.getLatitude(), osmPoint.getLongitude(), true) osmPoint.getLatitude(), osmPoint.getLongitude(), true)
.replaceAll("\n", " "), 0, false, null, false, 0, false, null, false); .replaceAll("\n", " "), 0, false, null, false, 0, false, null, false);
} }

View file

@ -5,19 +5,24 @@ import android.graphics.drawable.Drawable;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
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.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.osmedit.OsmPoint.Action; import net.osmand.plus.osmedit.OsmPoint.Action;
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment; import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import java.util.Map;
public class EditPOIMenuController extends MenuController { public class EditPOIMenuController extends MenuController {
private OsmPoint osmPoint; private OsmPoint osmPoint;
private OsmEditingPlugin plugin; private OsmEditingPlugin plugin;
private String pointTypeStr; private String category;
private String actionStr;
public EditPOIMenuController(final MapActivity mapActivity, PointDescription pointDescription, OsmPoint osmPoint) { public EditPOIMenuController(final MapActivity mapActivity, PointDescription pointDescription, OsmPoint osmPoint) {
super(new EditPOIMenuBuilder(mapActivity, osmPoint), pointDescription, mapActivity); super(new EditPOIMenuBuilder(mapActivity, osmPoint), pointDescription, mapActivity);
@ -70,30 +75,36 @@ public class EditPOIMenuController extends MenuController {
rightTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_delete); rightTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_delete);
rightTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark; rightTitleButtonController.leftIconId = R.drawable.ic_action_delete_dark;
category = getCategory();
if (osmPoint.getGroup() == OsmPoint.Group.POI) { if (osmPoint.getGroup() == OsmPoint.Group.POI) {
if(osmPoint.getAction() == Action.DELETE) { if(osmPoint.getAction() == Action.DELETE) {
pointTypeStr = getMapActivity().getString(R.string.osm_edit_deleted_poi); actionStr = getMapActivity().getString(R.string.osm_edit_deleted_poi);
} else if(osmPoint.getAction() == Action.MODIFY) { } else if(osmPoint.getAction() == Action.MODIFY) {
pointTypeStr = getMapActivity().getString(R.string.osm_edit_modified_poi); actionStr = getMapActivity().getString(R.string.osm_edit_modified_poi);
} else/* if(osmPoint.getAction() == Action.CREATE) */{ } else/* if(osmPoint.getAction() == Action.CREATE) */{
pointTypeStr = getMapActivity().getString(R.string.osm_edit_created_poi); actionStr = getMapActivity().getString(R.string.osm_edit_created_poi);
} }
} else if (osmPoint.getGroup() == OsmPoint.Group.BUG) { } else if (osmPoint.getGroup() == OsmPoint.Group.BUG) {
if(osmPoint.getAction() == Action.DELETE) { if(osmPoint.getAction() == Action.DELETE) {
pointTypeStr = getMapActivity().getString(R.string.osm_edit_removed_note); actionStr = getMapActivity().getString(R.string.osm_edit_removed_note);
} else if(osmPoint.getAction() == Action.MODIFY) { } else if(osmPoint.getAction() == Action.MODIFY) {
pointTypeStr = getMapActivity().getString(R.string.osm_edit_commented_note); actionStr = getMapActivity().getString(R.string.osm_edit_commented_note);
} else if(osmPoint.getAction() == Action.REOPEN) { } else if(osmPoint.getAction() == Action.REOPEN) {
pointTypeStr = getMapActivity().getString(R.string.osm_edit_reopened_note); actionStr = getMapActivity().getString(R.string.osm_edit_reopened_note);
} else/* if(osmPoint.getAction() == Action.CREATE) */{ } else/* if(osmPoint.getAction() == Action.CREATE) */{
pointTypeStr = getMapActivity().getString(R.string.osm_edit_created_note); actionStr = getMapActivity().getString(R.string.osm_edit_created_note);
} }
} else { } else {
pointTypeStr = ""; actionStr = "";
} }
} }
@Override
public String getTypeStr() {
return category;
}
@Override @Override
protected void setObject(Object object) { protected void setObject(Object object) {
if (object instanceof OsmPoint) { if (object instanceof OsmPoint) {
@ -112,21 +123,85 @@ public class EditPOIMenuController extends MenuController {
@Override @Override
public boolean needTypeStr() { public boolean needTypeStr() {
return !Algorithms.isEmpty(pointTypeStr); return !Algorithms.isEmpty(category);
} }
@Override @Override
public Drawable getLeftIcon() { public boolean displayDistanceDirection() {
return getIcon(R.drawable.ic_action_gabout_dark, R.color.created_poi_icon_color); return true;
} }
@Override @Override
public String getTypeStr() { public String getAdditionalInfoStr() {
return pointTypeStr; return actionStr;
}
@Override
public int getAdditionalInfoColor() {
if (osmPoint.getAction() == Action.DELETE) {
return R.color.color_osm_edit_delete;
} else if (osmPoint.getAction() == Action.MODIFY || osmPoint.getAction() == Action.REOPEN) {
return R.color.color_osm_edit_modify;
} else {
return R.color.color_osm_edit_create;
}
}
@Override
public int getRightIconId() {
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
OpenstreetmapPoint osmP = (OpenstreetmapPoint) osmPoint;
int iconResId = 0;
String poiTranslation = osmP.getEntity().getTag(EditPoiData.POI_TYPE_TAG);
if (poiTranslation != null) {
Map<String, PoiType> poiTypeMap = getMapActivity().getMyApplication().getPoiTypes().getAllTranslatedNames(false);
PoiType poiType = poiTypeMap.get(poiTranslation.toLowerCase());
if (poiType != null) {
String id = null;
if (RenderingIcons.containsBigIcon(poiType.getIconKeyName())) {
id = poiType.getIconKeyName();
} else if (RenderingIcons.containsBigIcon(poiType.getOsmTag() + "_" + poiType.getOsmValue())) {
id = poiType.getOsmTag() + "_" + poiType.getOsmValue();
}
if (id != null) {
iconResId = RenderingIcons.getBigIconResourceId(id);
}
}
}
if (iconResId == 0) {
iconResId = R.drawable.ic_type_info;
}
return iconResId;
} else if (osmPoint.getGroup() == OsmPoint.Group.BUG) {
return R.drawable.ic_type_bug;
} else {
return 0;
}
}
@Override
public int getAdditionalInfoIconRes() {
if (osmPoint.getAction() == Action.DELETE) {
return R.drawable.ic_action_type_delete_16;
} else if (osmPoint.getAction() == Action.MODIFY || osmPoint.getAction() == Action.REOPEN) {
return R.drawable.ic_action_type_edit_16;
} else {
return R.drawable.ic_action_type_add_16;
}
} }
@Override @Override
public boolean needStreetName() { public boolean needStreetName() {
return false; return false;
} }
private String getCategory() {
String category = "";
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
category = ((OpenstreetmapPoint) osmPoint).getEntity().getTag(EditPoiData.POI_TYPE_TAG);
} else if (osmPoint.getGroup() == OsmPoint.Group.BUG) {
category = getMapActivity().getString(R.string.osn_bug_name);
}
return category;
}
} }

View file

@ -73,7 +73,7 @@ public class OsmBugMenuController extends MenuController {
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
if (bug.isOpened()) { if (bug.isOpened()) {
return getIcon(R.drawable.ic_action_gabout_dark, R.color.osm_bug_unresolved_icon_color); return getIcon(R.drawable.ic_action_gabout_dark, R.color.osm_bug_unresolved_icon_color);
} else { } else {
@ -95,7 +95,7 @@ public class OsmBugMenuController extends MenuController {
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) { public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
super.addPlainMenuItems(typeStr, pointDescription, latLon); super.addPlainMenuItems(typeStr, pointDescription, latLon);
for (String description : bug.getCommentDescriptionList()) { for (String description : bug.getCommentDescriptionList()) {
addPlainMenuItem(R.drawable.ic_action_note_dark, description, true, false, null); addPlainMenuItem(R.drawable.ic_action_note_dark, null, description, true, false, null);
} }
} }

View file

@ -96,7 +96,7 @@ public class OsMoMenuController extends MenuController {
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
if (isLight()) { if (isLight()) {
return getIconOrig(R.drawable.widget_osmo_connected_location_day); return getIconOrig(R.drawable.widget_osmo_connected_location_day);
} else { } else {

View file

@ -64,17 +64,17 @@ public class ParkingPositionMenuController extends MenuController {
} }
@Override @Override
public String getAdditionalTypeStr() { public int getAdditionalInfoIconRes() {
return R.drawable.ic_action_opening_hour_16;
}
@Override
public String getAdditionalInfoStr() {
return parkingLeftDescription; return parkingLeftDescription;
} }
@Override @Override
public boolean displayAdditionalTypeStrInHours() { public int getAdditionalInfoColor() {
return true;
}
@Override
public int getTimeStrColor() {
return plugin.getParkingType() ? R.color.ctx_menu_amenity_closed_text_color : isLight() ? R.color.icon_color : R.color.dash_search_icon_dark; return plugin.getParkingType() ? R.color.ctx_menu_amenity_closed_text_color : isLight() ? R.color.icon_color : R.color.dash_search_icon_dark;
} }
@ -83,13 +83,18 @@ public class ParkingPositionMenuController extends MenuController {
return parkingTitle; return parkingTitle;
} }
@Override
public boolean navigateInPedestrianMode() {
return true;
}
@Override @Override
public boolean displayDistanceDirection() { public boolean displayDistanceDirection() {
return true; return true;
} }
@Override @Override
public Drawable getLeftIcon() { public Drawable getRightIcon() {
return getIcon(R.drawable.ic_action_parking_dark, R.color.map_widget_blue); return getIcon(R.drawable.ic_action_parking_dark, R.color.map_widget_blue);
} }

View file

@ -0,0 +1,105 @@
package net.osmand.plus.transport;
import net.osmand.data.RotatedTileBox;
import net.osmand.data.TransportRoute;
import net.osmand.data.TransportStop;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.render.RenderingRuleSearchRequest;
import net.osmand.render.RenderingRulesStorage;
import java.util.List;
public class TransportStopRoute {
public TransportStop refStop;
public TransportStopType type;
public String desc;
public TransportRoute route;
public TransportStop stop;
public int distance;
public boolean showWholeRoute;
private int cachedColor;
private boolean cachedNight;
public String getDescription(OsmandApplication ctx, boolean useDistance) {
if (useDistance && distance > 0) {
String nm = OsmAndFormatter.getFormattedDistance(distance, ctx);
if (refStop != null && !refStop.getName().equals(stop.getName())) {
nm = refStop.getName() + ", " + nm;
}
return desc + " (" + nm + ")";
}
return desc;
}
public int calculateZoom(int startPosition, RotatedTileBox currentRotatedTileBox) {
RotatedTileBox cp = currentRotatedTileBox.copy();
boolean notContains = true;
while (cp.getZoom() > 12 && notContains) {
notContains = false;
List<TransportStop> sts = route.getForwardStops();
for (int i = startPosition; i < sts.size(); i++) {
TransportStop st = sts.get(startPosition);
if (!cp.containsLatLon(st.getLocation())) {
notContains = true;
break;
}
}
cp.setZoom(cp.getZoom() - 1);
}
return cp.getZoom();
}
public int getColor(OsmandApplication ctx, boolean nightMode) {
if (cachedColor == 0 || cachedNight != nightMode) {
cachedColor = ctx.getResources().getColor(R.color.transport_route_line);
cachedNight = nightMode;
if (type != null) {
RenderingRulesStorage rrs = ctx.getRendererRegistry().getCurrentSelectedRenderer();
RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs);
req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode);
String typeStr = type.getRendeAttr();
if (req.searchRenderingAttribute(typeStr)) {
cachedColor = req.getIntPropertyValue(rrs.PROPS.R_ATTR_COLOR_VALUE);
}
}
}
return cachedColor;
}
public int getTypeStrRes() {
if (type != null) {
switch (type) {
case BUS:
return R.string.poi_route_bus_ref;
case TRAM:
return R.string.poi_route_tram_ref;
case FERRY:
return R.string.poi_route_ferry_ref;
case TRAIN:
return R.string.poi_route_train_ref;
case SHARE_TAXI:
return R.string.poi_route_share_taxi_ref;
case FUNICULAR:
return R.string.poi_route_funicular_ref;
case LIGHT_RAIL:
return R.string.poi_route_light_rail_ref;
case MONORAIL:
return R.string.poi_route_monorail_ref;
case TROLLEYBUS:
return R.string.poi_route_trolleybus_ref;
case RAILWAY:
return R.string.poi_route_railway_ref;
case SUBWAY:
return R.string.poi_route_subway_ref;
default:
return R.string.poi_filter_public_transport;
}
} else {
return R.string.poi_filter_public_transport;
}
}
}

View file

@ -0,0 +1,54 @@
package net.osmand.plus.transport;
import net.osmand.plus.R;
public enum TransportStopType {
BUS(R.drawable.mx_route_bus_ref, R.drawable.mx_route_bus_ref, "routeBusColor"),
FERRY(R.drawable.mx_route_ferry_ref, R.drawable.mx_route_ferry_ref, "routeFerryColor"),
FUNICULAR(R.drawable.mx_route_funicular_ref, R.drawable.mx_route_funicular_ref, "routeFunicularColor"),
LIGHT_RAIL(R.drawable.mx_route_light_rail_ref, R.drawable.mx_route_light_rail_ref, "routeLightrailColor"),
MONORAIL(R.drawable.mx_route_monorail_ref, R.drawable.mx_route_monorail_ref, "routeLightrailColor"),
RAILWAY(R.drawable.mx_route_railway_ref, R.drawable.mx_route_railway_ref, "routeTrainColor"),
SHARE_TAXI(R.drawable.mx_route_share_taxi_ref, R.drawable.mx_route_share_taxi_ref, "routeShareTaxiColor"),
TRAIN(R.drawable.mx_route_train_ref, R.drawable.mx_route_train_ref, "routeTrainColor"),
TRAM(R.drawable.mx_route_tram_ref, R.drawable.mx_railway_tram_stop, "routeTramColor"),
TROLLEYBUS(R.drawable.mx_route_trolleybus_ref, R.drawable.mx_route_trolleybus_ref, "routeTrolleybusColor"),
SUBWAY(R.drawable.mx_subway_station, R.drawable.mx_subway_station, "routeTrainColor");
final int resId;
final int topResId;
final String renderAttr;
TransportStopType(int resId, int topResId, String renderAttr) {
this.resId = resId;
this.topResId = topResId;
this.renderAttr = renderAttr;
}
public int getResourceId() {
return resId;
}
public int getTopResourceId() {
return topResId;
}
public String getRendeAttr() {
return renderAttr;
}
public boolean isTopType() {
return this == TRAM || this == SUBWAY;
}
public static TransportStopType findType(String typeName) {
String tName = typeName.toUpperCase();
for (TransportStopType t : values()) {
if (t.name().equals(tName)) {
return t;
}
}
return null;
}
}

View file

@ -504,7 +504,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
view.setLatLon(lat, lon); view.setLatLon(lat, lon);
mInChangeMarkerPositionMode = true; mInChangeMarkerPositionMode = true;
mMoveMarkerBottomSheetHelper.show(menu.getLeftIcon()); mMoveMarkerBottomSheetHelper.show(menu.getRightIcon());
mark(View.INVISIBLE, R.id.map_ruler_layout, mark(View.INVISIBLE, R.id.map_ruler_layout,
R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info); R.id.map_left_widgets_panel, R.id.map_right_widgets_panel, R.id.map_center_info);

View file

@ -295,7 +295,6 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls(); boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
ImageView cancelRouteButton = (ImageView) main.findViewById(R.id.map_cancel_route_button); ImageView cancelRouteButton = (ImageView) main.findViewById(R.id.map_cancel_route_button);
cancelRouteButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.map_action_cancel, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light)); cancelRouteButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.map_action_cancel, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light));
AndroidUtils.setBackground(mapActivity, cancelRouteButton, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
cancelRouteButton.setOnClickListener(new View.OnClickListener() { cancelRouteButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -305,7 +304,6 @@ public class MapControlsLayer extends OsmandMapLayer {
ImageView waypointsButton = (ImageView) main.findViewById(R.id.map_waypoints_route_button); ImageView waypointsButton = (ImageView) main.findViewById(R.id.map_waypoints_route_button);
waypointsButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.map_action_flag_dark, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light)); waypointsButton.setImageDrawable(app.getIconsCache().getIcon(R.drawable.map_action_flag_dark, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light));
AndroidUtils.setBackground(mapActivity, waypointsButton, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
waypointsButton.setOnClickListener(new View.OnClickListener() { waypointsButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -316,7 +314,6 @@ public class MapControlsLayer extends OsmandMapLayer {
ImageView options = (ImageView) main.findViewById(R.id.map_options_route_button); ImageView options = (ImageView) main.findViewById(R.id.map_options_route_button);
options.setImageDrawable(!routeInfo ? app.getIconsCache().getIcon(R.drawable.map_action_settings, options.setImageDrawable(!routeInfo ? app.getIconsCache().getIcon(R.drawable.map_action_settings,
R.color.osmand_orange) : app.getIconsCache().getIcon(R.drawable.map_action_settings, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light)); R.color.osmand_orange) : app.getIconsCache().getIcon(R.drawable.map_action_settings, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light));
AndroidUtils.setBackground(mapActivity, options, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
options.setOnClickListener(new View.OnClickListener() { options.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {

View file

@ -18,6 +18,7 @@ import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat; import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.PopupMenu; import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
@ -289,13 +290,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
return true; return true;
} }
public static void showWikipediaDialog(Context ctx, OsmandApplication app, Amenity a) {
String lang = app.getSettings().MAP_PREFERRED_LOCALE.get();
if (a.getType().isWiki()) {
showWiki(ctx, app, a, lang);
}
}
public static void showDescriptionDialog(Context ctx, OsmandApplication app, String text, String title) { public static void showDescriptionDialog(Context ctx, OsmandApplication app, String text, String title) {
showText(ctx, app, text, title); showText(ctx, app, text, title);
} }
@ -309,122 +303,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
return typedvalueattr.resourceId; return typedvalueattr.resourceId;
} }
@SuppressWarnings("deprecation")
private static void showWiki(final Context ctx, final OsmandApplication app, final Amenity a, final String lang) {
String preferredLang = lang;
if (Algorithms.isEmpty(preferredLang)) {
preferredLang = app.getLanguage();
}
final Dialog dialog = new Dialog(ctx,
app.getSettings().isLightContent() ?
R.style.OsmandLightTheme :
R.style.OsmandDarkTheme);
final String title = Algorithms.isEmpty(preferredLang) ? a.getName() : a.getName(preferredLang);
LinearLayout ll = new LinearLayout(ctx);
ll.setOrientation(LinearLayout.VERTICAL);
final Toolbar topBar = new Toolbar(ctx);
topBar.setClickable(true);
Drawable back = app.getIconsCache().getIcon(R.drawable.ic_arrow_back);
topBar.setNavigationIcon(back);
topBar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
topBar.setTitle(title);
topBar.setBackgroundColor(ContextCompat.getColor(ctx, getResIdFromAttribute(ctx, R.attr.pstsTabBackground)));
topBar.setTitleTextColor(ContextCompat.getColor(ctx, getResIdFromAttribute(ctx, R.attr.pstsTextColor)));
String lng = a.getContentLanguage("content", preferredLang, "en");
if (Algorithms.isEmpty(lng)) {
lng = "en";
}
final String langSelected = lng;
String content = a.getDescription(langSelected);
final Button bottomBar = new Button(ctx);
bottomBar.setText(R.string.read_full_article);
bottomBar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String article = "https://" + langSelected.toLowerCase() + ".wikipedia.org/wiki/" + title.replace(' ', '_');
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(article));
ctx.startActivity(i);
}
});
MenuItem mi = topBar.getMenu().add(langSelected.toUpperCase()).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(final MenuItem item) {
showPopupLangMenu(ctx, topBar, app, a, dialog, langSelected);
return true;
}
});
MenuItemCompat.setShowAsAction(mi, MenuItem.SHOW_AS_ACTION_ALWAYS);
topBar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
dialog.dismiss();
}
});
final WebView wv = new WebView(ctx);
WebSettings settings = wv.getSettings();
settings.setDefaultTextEncodingName("utf-8");
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
settings.setSupportZoom(true);
//Scale web view font size with system font size
float scale = ctx.getResources().getConfiguration().fontScale;
if (android.os.Build.VERSION.SDK_INT >= 14) {
settings.setTextZoom((int) (scale * 100f));
} else {
if (scale <= 0.7f) {
settings.setTextSize(WebSettings.TextSize.SMALLEST);
} else if (scale <= 0.85f) {
settings.setTextSize(WebSettings.TextSize.SMALLER);
} else if (scale <= 1.0f) {
settings.setTextSize(WebSettings.TextSize.NORMAL);
} else if (scale <= 1.15f) {
settings.setTextSize(WebSettings.TextSize.LARGER);
} else {
settings.setTextSize(WebSettings.TextSize.LARGEST);
}
}
wv.loadDataWithBaseURL(null, content, "text/html", "UTF-8", null);
// wv.loadUrl(OsMoService.SIGN_IN_URL + app.getSettings().OSMO_DEVICE_KEY.get());
//For pinch zooming to work WebView must not be inside ScrollView
//ScrollView scrollView = new ScrollView(ctx);
ll.addView(topBar);
LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0);
lp.weight = 1;
//ll.addView(scrollView, lp);
//scrollView.addView(wv);
ll.addView(wv, lp);
ll.addView(bottomBar, new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
dialog.setContentView(ll);
wv.setFocusable(true);
wv.setFocusableInTouchMode(true);
wv.requestFocus(View.FOCUS_DOWN);
wv.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_UP:
if (!v.hasFocus()) {
v.requestFocus();
}
break;
}
return false;
}
});
dialog.setCancelable(true);
dialog.show();
}
private static void showText(final Context ctx, final OsmandApplication app, final String text, String title) { private static void showText(final Context ctx, final OsmandApplication app, final String text, String title) {
final Dialog dialog = new Dialog(ctx, final Dialog dialog = new Dialog(ctx,
app.getSettings().isLightContent() ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme); app.getSettings().isLightContent() ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
@ -471,50 +349,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
dialog.show(); dialog.show();
} }
protected static void showPopupLangMenu(final Context ctx, Toolbar tb,
final OsmandApplication app, final Amenity a,
final Dialog dialog, final String langSelected) {
final PopupMenu optionsMenu = new PopupMenu(ctx, tb, Gravity.RIGHT);
Set<String> namesSet = new TreeSet<>();
namesSet.addAll(a.getNames("content", "en"));
namesSet.addAll(a.getNames("description", "en"));
Map<String, String> names = new HashMap<>();
for (String n : namesSet) {
names.put(n, FileNameTranslationHelper.getVoiceName(ctx, n));
}
String selectedLangName = names.get(langSelected);
if (selectedLangName != null) {
names.remove(langSelected);
}
Map<String, String> sortedNames = AndroidUtils.sortByValue(names);
if (selectedLangName != null) {
MenuItem item = optionsMenu.getMenu().add(selectedLangName);
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
dialog.dismiss();
showWiki(ctx, app, a, langSelected);
return true;
}
});
}
for (final Map.Entry<String, String> e : sortedNames.entrySet()) {
MenuItem item = optionsMenu.getMenu().add(e.getValue());
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
dialog.dismiss();
showWiki(ctx, app, a, e.getKey());
return true;
}
});
}
optionsMenu.show();
}
@Override @Override
public PointDescription getObjectName(Object o) { public PointDescription getObjectName(Object o) {
if (o instanceof Amenity) { if (o instanceof Amenity) {

View file

@ -16,11 +16,11 @@ import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect; import net.osmand.data.QuadRect;
import net.osmand.data.QuadTree; import net.osmand.data.QuadTree;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
import net.osmand.data.TransportRoute;
import net.osmand.data.TransportStop; import net.osmand.data.TransportStop;
import net.osmand.osm.edit.Node; import net.osmand.osm.edit.Node;
import net.osmand.osm.edit.Way; import net.osmand.osm.edit.Way;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import java.util.ArrayList; import java.util.ArrayList;
@ -44,7 +44,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
private RenderingLineAttributes attrs; private RenderingLineAttributes attrs;
private MapLayerData<List<TransportStop>> data; private MapLayerData<List<TransportStop>> data;
private TransportRoute route = null; private TransportStopRoute stopRoute = null;
private boolean showTransportStops; private boolean showTransportStops;
private Path path; private Path path;
@ -66,8 +66,7 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
stopBus = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_transport_stop_bus); stopBus = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_transport_stop_bus);
stopSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_transport_stop_small); stopSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_transport_stop_small);
attrs = new RenderingLineAttributes("transport_route"); attrs = new RenderingLineAttributes("transport_route");
attrs.defaultWidth = (int) (12 * view.getDensity()); attrs.defaultWidth = (int) (6 * view.getDensity());
attrs.defaultColor = view.getResources().getColor(R.color.transport_route_line);
data = new OsmandMapLayer.MapLayerData<List<TransportStop>>() { data = new OsmandMapLayer.MapLayerData<List<TransportStop>>() {
{ {
ZOOM_THRESHOLD = 0; ZOOM_THRESHOLD = 0;
@ -143,12 +142,12 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
} }
} }
public TransportRoute getRoute() { public TransportStopRoute getRoute() {
return route; return stopRoute;
} }
public void setRoute(TransportRoute route) { public void setRoute(TransportStopRoute route) {
this.route = route; this.stopRoute = route;
} }
public boolean isShowTransportStops() { public boolean isShowTransportStops() {
@ -176,17 +175,18 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
return (int) (r * tb.getDensity()); return (int) (r * tb.getDensity());
} }
@Override @Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tb, DrawSettings settings) { public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tb, DrawSettings settings) {
List<TransportStop> objects = null; List<TransportStop> objects = null;
if (tb.getZoom() >= startZoomRoute) { if (tb.getZoom() >= startZoomRoute) {
if (route != null) { if (stopRoute != null) {
objects = route.getForwardStops(); objects = stopRoute.route.getForwardStops();
int color = stopRoute.getColor(mapActivity.getMyApplication(), settings.isNightMode());
attrs.paint.setColor(color);
attrs.updatePaints(view, settings, tb); attrs.updatePaints(view, settings, tb);
try { try {
path.reset(); path.reset();
List<Way> ws = route.getForwardWays(); List<Way> ws = stopRoute.route.getForwardWays();
if (ws != null) { if (ws != null) {
for (Way w : ws) { for (Way w : ws) {
TIntArrayList tx = new TIntArrayList(); TIntArrayList tx = new TIntArrayList();
@ -286,8 +286,8 @@ public class TransportStopsLayer extends OsmandMapLayer implements ContextMenuLa
@Override @Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) { public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> res, boolean unknownLocation) {
if(tileBox.getZoom() >= startZoomRoute && route != null) { if(tileBox.getZoom() >= startZoomRoute && stopRoute != null) {
getFromPoint(tileBox, point, res, route.getForwardStops()); getFromPoint(tileBox, point, res, stopRoute.route.getForwardStops());
} else if (tileBox.getZoom() >= startZoom && data.getResults() != null) { } else if (tileBox.getZoom() >= startZoom && data.getResults() != null) {
getFromPoint(tileBox, point, res, data.getResults()); getFromPoint(tileBox, point, res, data.getResults());
} }