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-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"
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:appcompat-v7: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')
legacyCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@jar"
qtcoredebugCompile "net.osmand:OsmAndCore_androidNativeDebug:0.1-SNAPSHOT@aar"

View file

@ -1,7 +1,7 @@
<?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_dots_dark" />
<nine-patch android:src="@drawable/bg_contextmenu_shadow_top_light" />
</item>
<item>
<shape>

View file

@ -1,7 +1,7 @@
<?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_dots_light" />
<nine-patch android:src="@drawable/bg_contextmenu_shadow_top_light" />
</item>
<item>
<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:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:background="?attr/dashboard_button"
android:background="?attr/selectableItemBackground"
android:scaleType="center"
android:src="@drawable/map_action_waypoints"/>
</LinearLayout>
@ -74,16 +74,19 @@
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<LinearLayout
android:background="?attr/selectableItemBackground"
android:id="@+id/FromLayout"
android:layout_width="fill_parent"
android:layout_height="@dimen/list_item_height"
@ -130,39 +133,19 @@
android:layout_marginRight="@dimen/list_header_text_left_margin"
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>
<FrameLayout
<View
android:layout_marginStart="@dimen/route_info_divider_margin"
android:layout_marginLeft="@dimen/route_info_divider_margin"
android:id="@+id/dividerFromDropDown"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_marginStart="@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:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dashboard_divider_dark"
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>
android:layout_height="1dp"
android:background="@color/dashboard_divider_dark"
android:focusable="false"/>
<LinearLayout
android:background="?attr/selectableItemBackground"
android:id="@+id/ViaLayout"
android:layout_width="match_parent"
android:layout_height="@dimen/list_item_height"
@ -216,6 +199,7 @@
android:focusable="false"/>
<LinearLayout
android:background="?attr/selectableItemBackground"
android:id="@+id/ToLayout"
android:layout_width="fill_parent"
android:layout_height="@dimen/list_item_height"
@ -262,18 +246,13 @@
android:layout_marginRight="@dimen/list_header_text_left_margin"
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>
<ImageView
android:background="?attr/selectableItemBackground"
android:id="@+id/swap_direction_image_view"
android:visibility="gone"
android:paddingRight="@dimen/route_info_icon_padding_right"
android:paddingLeft="@dimen/route_info_icon_padding_right"
android:layout_gravity="end"
@ -281,7 +260,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
</FrameLayout>
</LinearLayout>
<View
android:id="@+id/dividerToDropDown"
@ -300,7 +279,7 @@
android:id="@+id/Info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="?attr/dashboard_button"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/list_item_height"
android:orientation="horizontal">
@ -308,7 +287,7 @@
android:id="@+id/Prev"
android:layout_width="@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:scaleType="center"
android:src="@drawable/ic_prev"/>
@ -407,7 +386,7 @@
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:layout_marginLeft="5dp"
android:background="?attr/dashboard_button"
android:background="?attr/selectableItemBackground"
android:contentDescription="@string/shared_string_next"
android:scaleType="center"
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:orientation="horizontal">
<TextView
<net.osmand.plus.widgets.TextViewEx
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
tools:text="Museum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/context_menu_line3"
osmand:typeface="@string/font_roboto_medium"
style="@style/TextAppearance.ContextMenuSubtitle"/>
<TextView
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
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_height="wrap_content"/>
@ -174,7 +175,7 @@
android:paddingRight="@dimen/context_menu_button_padding_x"
android:textAllCaps="true"
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"/>
<TextView
@ -209,7 +210,7 @@
android:paddingLeft="@dimen/context_menu_button_padding_x"
android:paddingRight="@dimen/context_menu_button_padding_x"
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"/>
</LinearLayout>
@ -246,7 +247,7 @@
android:paddingLeft="@dimen/context_menu_button_padding_x"
android:paddingRight="@dimen/context_menu_button_padding_x"
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"/>
</LinearLayout>
@ -270,8 +271,8 @@
android:gravity="center_vertical"
android:paddingLeft="@dimen/context_menu_button_padding_x"
android:paddingRight="@dimen/context_menu_button_padding_x"
android:text="@string/shared_string_delete"
tools:textColor="?attr/contextMenuButtonColor"
android:text="@string/shared_string_others"
tools:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
@ -305,9 +306,9 @@
android:gravity="center_vertical"
android:paddingLeft="@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"
tools:textColor="?attr/contextMenuButtonColor"
tools:textColor="?attr/ctx_menu_controller_text_color"
android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium"/>
@ -382,8 +383,8 @@
android:background="?attr/ctx_menu_divider"/>
<LinearLayout
android:paddingLeft="@dimen/context_menu_padding_margin_small"
android:paddingRight="@dimen/context_menu_padding_margin_small"
android:paddingLeft="@dimen/map_widget_icon_margin"
android:paddingRight="@dimen/map_widget_icon_margin"
android:id="@+id/context_menu_buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -25,6 +25,7 @@
<attr name="bg_point_editor_view" format="reference" />
<attr name="ctx_menu_info_view_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="bottom_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_dark">#17191a</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_dark">#cccccc</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_closed_text_color">#c66545</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_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_dark">#17191a</color>
@ -371,4 +373,9 @@
<color name="route_info_checked_mode_icon_color_dark">#d28521</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>

View file

@ -247,4 +247,9 @@
<dimen name="route_info_modes_height">48dp</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>

View file

@ -132,6 +132,7 @@
<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_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="search_background">@color/search_background_dark</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="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_text_color">@drawable/context_menu_controller_text_color_dark</item>
<item name="ctx_menu_divider">@color/ctx_menu_buttons_divider_dark</item>
<item name="search_background">@color/color_white</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.app.Activity;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.PointF;
@ -11,6 +12,7 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.os.Build;
import android.os.IBinder;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
@ -118,6 +120,21 @@ public class AndroidUtils {
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,
@DrawableRes int lightNormal, @DrawableRes int lightPressed,
@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) {
int result = 0;
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 night = app.getDaynightHelper().isNightModeForMapControls();
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 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;
} else if (markerTopBar && mapControlsVisible) {
colorId = R.color.status_bar_dark;
@ -1885,11 +1886,13 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
public void showTopToolbar(TopToolbarController controller) {
MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer();
mapInfoLayer.addTopToolbarController(controller);
updateStatusBarColor();
}
public void hideTopToolbar(TopToolbarController controller) {
MapInfoLayer mapInfoLayer = getMapLayers().getMapInfoLayer();
mapInfoLayer.removeTopToolbarController(controller);
updateStatusBarColor();
}
public void registerActivityResultListener(ActivityResultListener listener) {

View file

@ -78,7 +78,7 @@ public class AppModeDialog {
} else {
if (useMapTheme) {
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 {
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 timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext());
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);
buildPlainMenuItems(view);

View file

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

View file

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

View file

@ -14,6 +14,7 @@ import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.VelocityTracker;
@ -34,6 +35,7 @@ import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.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.TitleButtonController;
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.views.AnimateDraggingMapThread;
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.SingleTapConfirm;
import net.osmand.util.Algorithms;
@ -198,8 +201,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
});
// Bottom title button
final View bottomTitleButton = view.findViewById(R.id.title_button_bottom_view);
bottomTitleButton.setOnClickListener(new View.OnClickListener() {
final View bottomTitleButtonView = view.findViewById(R.id.title_button_bottom_view);
bottomTitleButtonView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
TitleButtonController bottomTitleButtonController = menu.getBottomTitleButtonController();
@ -211,8 +214,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
// Progress bar
final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton);
progressButton.setImageDrawable(getIcon(R.drawable.ic_action_remove_dark,
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
progressButton.setImageDrawable(getIcon(R.drawable.ic_action_remove_dark, R.color.ctx_menu_buttons_icon_color));
progressButton.setOnClickListener(new View.OnClickListener() {
@Override
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);
List<TransportStopRoute> transportStopRoutes = menu.getTransportStopRoutes();
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.setVisibility(View.VISIBLE);
} else {
@ -513,6 +530,23 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
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) {
view.setEnabled(false);
view.setAlpha(0.5f);
@ -547,6 +581,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
changeMenuState(getViewY(), true, true, false);
}
public void openMenuHeaderOnly() {
changeMenuState(getViewY(), true, false, true);
}
public void openMenuHalfScreen() {
int oldMenuState = menu.getCurrentMenuState();
if (oldMenuState == MenuState.HEADER_ONLY) {
@ -579,6 +617,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
restoreCustomMapRatio();
menu.updateControlsVisibility(true);
doBeforeMenuStateChange(oldMenuState, newMenuState);
toggleDetailsHideButton();
}
applyPosY(currentY, needCloseMenu, needMapAdjust, oldMenuState, newMenuState, 0);
@ -675,7 +714,22 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
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) {
TitleButtonController leftTitleButtonController = menu.getLeftTitleButtonController();
TitleButtonController rightTitleButtonController = menu.getRightTitleButtonController();
@ -684,10 +738,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
TitleButtonController rightDownloadButtonController = menu.getRightDownloadButtonController();
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
boolean showTitleButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null);
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 titleButtonRightText = (TextView) view.findViewById(R.id.title_button_right_text);
if (leftTitleButtonController != null) {
enableDisableButtons(leftTitleButtonView, leftTitleButton, leftTitleButtonController.enabled);
leftTitleButton.setText(leftTitleButtonController.caption);
leftTitleButton.setTextColor(textColorStateList);
if (leftTitleButtonController.visible) {
leftTitleButtonView.setVisibility(View.VISIBLE);
leftTitleButtonView.setBackgroundResource(buttonViewBackgroundResId);
Drawable leftIcon = leftTitleButtonController.getLeftIcon();
if (leftIcon != null) {
leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
leftTitleButton.setCompoundDrawablePadding(dpToPx(8f));
}
Drawable rightIcon = leftTitleButtonController.getRightIcon();
leftTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
leftTitleButton.setCompoundDrawablePadding(dpToPx(8f));
((LinearLayout) leftTitleButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
if (leftTitleButtonController.needRightText) {
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 TextView rightTitleButton = (TextView) view.findViewById(R.id.title_button_right);
if (rightTitleButtonController != null) {
enableDisableButtons(rightTitleButtonView, rightTitleButton, rightTitleButtonController.enabled);
rightTitleButton.setText(rightTitleButtonController.caption);
rightTitleButton.setTextColor(textColorStateList);
rightTitleButtonView.setVisibility(rightTitleButtonController.visible ? View.VISIBLE : View.INVISIBLE);
if (rightTitleButtonController.visible) {
rightTitleButtonView.setBackgroundResource(buttonViewBackgroundResId);
}
Drawable leftIcon = rightTitleButtonController.getLeftIcon();
rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
Drawable rightIcon = rightTitleButtonController.getRightIcon();
rightTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
rightTitleButton.setCompoundDrawablePadding(dpToPx(8f));
((LinearLayout) rightTitleButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
} else {
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 TextView bottomTitleButton = (TextView) view.findViewById(R.id.title_button_bottom);
if (bottomTitleButtonController != null) {
enableDisableButtons(bottomTitleButtonView, bottomTitleButton, bottomTitleButtonController.enabled);
bottomTitleButton.setText(bottomTitleButtonController.caption);
bottomTitleButton.setTextColor(textColorStateList);
bottomTitleButtonView.setVisibility(bottomTitleButtonController.visible ? View.VISIBLE : View.GONE);
if (bottomTitleButtonController.visible) {
bottomTitleButtonView.setBackgroundResource(buttonViewBackgroundResId);
}
Drawable leftIcon = bottomTitleButtonController.getLeftIcon();
bottomTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
Drawable rightIcon = bottomTitleButtonController.getRightIcon();
bottomTitleButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
bottomTitleButton.setCompoundDrawablePadding(dpToPx(8f));
((LinearLayout) bottomTitleButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
} else {
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 TextView leftDownloadButton = (TextView) view.findViewById(R.id.download_button_left);
if (leftDownloadButtonController != null) {
enableDisableButtons(leftDownloadButtonView, leftDownloadButton, leftDownloadButtonController.enabled);
leftDownloadButton.setText(leftDownloadButtonController.caption);
leftDownloadButton.setTextColor(textColorStateList);
leftDownloadButtonView.setVisibility(leftDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
if (leftDownloadButtonController.visible) {
leftDownloadButtonView.setBackgroundResource(buttonViewBackgroundResId);
}
Drawable leftIcon = leftDownloadButtonController.getLeftIcon();
if (leftIcon != null) {
leftDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
leftDownloadButton.setCompoundDrawablePadding(dpToPx(8f));
}
Drawable rightIcon = leftDownloadButtonController.getRightIcon();
leftDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
leftDownloadButton.setCompoundDrawablePadding(dpToPx(8f));
((LinearLayout) leftDownloadButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
} else {
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 TextView rightDownloadButton = (TextView) view.findViewById(R.id.download_button_right);
if (rightDownloadButtonController != null) {
enableDisableButtons(rightDownloadButtonView, rightDownloadButton, rightDownloadButtonController.enabled);
rightDownloadButton.setText(rightDownloadButtonController.caption);
rightDownloadButton.setTextColor(textColorStateList);
rightDownloadButtonView.setVisibility(rightDownloadButtonController.visible ? View.VISIBLE : View.INVISIBLE);
if (rightDownloadButtonController.visible) {
rightDownloadButtonView.setBackgroundResource(buttonViewBackgroundResId);
}
Drawable leftIcon = rightDownloadButtonController.getLeftIcon();
rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, null, null);
Drawable rightIcon = rightDownloadButtonController.getRightIcon();
rightDownloadButton.setCompoundDrawablesWithIntrinsicBounds(leftIcon, null, rightIcon, null);
rightDownloadButton.setCompoundDrawablePadding(dpToPx(8f));
((LinearLayout) rightDownloadButtonView).setGravity(rightIcon != null ? Gravity.END : Gravity.START);
} else {
rightDownloadButtonView.setVisibility(View.INVISIBLE);
}
@ -835,8 +878,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
OsmandApplication app = getMyApplication();
if (app != null && view != null) {
final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view);
Drawable icon = menu.getLeftIcon();
int iconId = menu.getLeftIconId();
Drawable icon = menu.getRightIcon();
int iconId = menu.getRightIconId();
if (icon != null) {
iconView.setImageDrawable(icon);
iconView.setVisibility(View.VISIBLE);
@ -929,8 +972,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
OsmandApplication app = getMyApplication();
if (app != null && view != null) {
final ImageView buttonFavorite = (ImageView) view.findViewById(R.id.context_menu_fav_image_view);
buttonFavorite.setImageDrawable(getIcon(menu.getFavActionIconId(),
!nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
buttonFavorite.setImageDrawable(getIcon(menu.getFavActionIconId(), R.color.ctx_menu_buttons_icon_color));
String favActionString = getString(menu.getFavActionStringId());
buttonFavorite.setContentDescription(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.centered = true;
}
updateButtonsAndProgress();
runLayoutListener();
}
}
@ -1132,61 +1175,43 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
}
line2Str.append(streetStr);
}
line2.setText(line2Str.toString());
if (!TextUtils.isEmpty(line2Str)) {
line2.setText(line2Str.toString());
line2.setVisibility(View.VISIBLE);
} else {
line2.setVisibility(View.GONE);
}
}
TextView line3 = (TextView) view.findViewById(R.id.context_menu_line3);
String additionalTypeStr = menu.getAdditionalTypeStr();
boolean displayAdditionalTypeStrInHours = menu.displayAdditionalTypeStrInHours();
boolean emptyAdditionalTypeStr = TextUtils.isEmpty(additionalTypeStr);
if (emptyAdditionalTypeStr || displayAdditionalTypeStrInHours) {
String subtypeStr = menu.getSubtypeStr();
if (TextUtils.isEmpty(subtypeStr)) {
line3.setVisibility(View.GONE);
} else {
line3.setVisibility(View.VISIBLE);
line3.setText(additionalTypeStr);
Drawable icon = menu.getAdditionalLineTypeIcon();
line3.setText(subtypeStr);
Drawable icon = menu.getSubtypeIcon();
line3.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
line3.setCompoundDrawablePadding(dpToPx(5f));
}
TextView openingHoursTextView = (TextView) view.findViewById(R.id.opening_hours_text_view);
OpeningHoursInfo openingHoursInfo = menu.getOpeningHoursInfo();
boolean containsOpeningHours = openingHoursInfo != null && openingHoursInfo.containsInfo();
if (containsOpeningHours || (displayAdditionalTypeStrInHours && !emptyAdditionalTypeStr)) {
int colorId;
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;
}
TextView additionalInfoTextView = (TextView) view.findViewById(R.id.additional_info_text_view);
String additionalInfoStr = menu.getAdditionalInfo();
if (!TextUtils.isEmpty(additionalInfoStr)) {
int colorId = menu.getAdditionalInfoColor();
int additionalInfoIconRes = menu.getAdditionalInfoIconRes();
if (colorId != 0) {
openingHoursTextView.setTextColor(ContextCompat.getColor(getContext(), colorId));
Drawable drawable = getIcon(R.drawable.ic_action_opening_hour_16, colorId);
openingHoursTextView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
openingHoursTextView.setCompoundDrawablePadding(dpToPx(8));
additionalInfoTextView.setTextColor(ContextCompat.getColor(getContext(), colorId));
if (additionalInfoIconRes != 0) {
Drawable additionalIcon = getIcon(additionalInfoIconRes, colorId);
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 {
openingHoursTextView.setVisibility(View.GONE);
additionalInfoTextView.setVisibility(View.GONE);
}
}
updateCompassVisibility();
@ -1482,7 +1507,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
boolean progressVisible = menu.getTitleProgressController() != null && menu.getTitleProgressController().visible;
updateButtonsAndProgress();
if (wasProgressVisible != progressVisible) {
runLayoutListener();
refreshTitle();
}
}
}
@ -1491,7 +1516,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
if (created) {
menu.updateData();
updateButtonsAndProgress();
runLayoutListener();
refreshTitle();
}
}

View file

@ -5,8 +5,10 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
@ -17,7 +19,6 @@ import android.text.TextUtils;
import android.text.util.Linkify;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
@ -27,6 +28,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.Amenity;
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.GetImageCardsTask;
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.render.RenderingIcons;
import net.osmand.plus.views.TransportStopsLayer;
@ -99,6 +101,7 @@ public class MenuBuilder {
public class PlainMenuItem {
private int iconId;
private String buttonText;
private String text;
private boolean needLinks;
private boolean url;
@ -106,10 +109,11 @@ public class MenuBuilder {
private CollapsableView collapsableView;
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,
OnClickListener onClickListener) {
this.iconId = iconId;
this.buttonText = buttonText;
this.text = text;
this.needLinks = needLinks;
this.url = url;
@ -122,6 +126,10 @@ public class MenuBuilder {
return iconId;
}
public String getButtonText() {
return buttonText;
}
public String getText() {
return text;
}
@ -289,7 +297,7 @@ public class MenuBuilder {
buildTitleRow(view);
}
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);
}
buildNearestWikiRow(view);
@ -324,7 +332,7 @@ public class MenuBuilder {
protected void buildPlainMenuItems(View view) {
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);
}
}
@ -349,14 +357,14 @@ public class MenuBuilder {
if (mapContextMenu != null) {
String title = mapContextMenu.getTitleStr();
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) {
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),
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);
if (needUpdateOnly && onlinePhotoCards != null) {
@ -437,14 +445,14 @@ public class MenuBuilder {
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 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);
}
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,
int textLinesLimit, boolean isUrl, OnClickListener onClickListener, boolean matchWidthDivider) {
@ -461,7 +469,7 @@ public class MenuBuilder {
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
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() {
@Override
public boolean onLongClick(View v) {
@ -538,6 +546,20 @@ public class MenuBuilder {
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());
if (collapsable && collapsableView != null) {
// Icon
@ -614,7 +636,7 @@ public class MenuBuilder {
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(llParams);
ll.setBackgroundResource(resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
ll.setBackgroundResource(AndroidUtils.resolveAttribute(view.getContext(), android.R.attr.selectableItemBackground));
// Empty
LinearLayout llIcon = new LinearLayout(view.getContext());
@ -635,7 +657,7 @@ public class MenuBuilder {
buttonView.setPadding(dpToPx(10f), 0, dpToPx(10f), 0);
buttonView.setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
//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);
if (buttonIcon != null) {
@ -671,13 +693,17 @@ public class MenuBuilder {
}
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,
boolean collapsable, CollapsableView collapsableView,
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() {
@ -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) {
Resources r = app.getResources();
return (int) TypedValue.applyDimension(
@ -714,69 +734,90 @@ public class MenuBuilder {
);
}
private void buildTransportRouteRow(ViewGroup parent, TransportStopRoute r, OnClickListener listener) {
if (!isFirstRow()) {
private View buildTransportRowItem(View view, TransportStopRoute route, OnClickListener listener) {
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);
}
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) {
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() {
@Override
public void onClick(View arg0) {
@ -785,12 +826,13 @@ public class MenuBuilder {
r.getDescription(getMapActivity().getMyApplication(), false));
mm.show(latLon, pd, r);
TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
stopsLayer.setRoute(r.route);
stopsLayer.setRoute(r);
int cz = r.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox());
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);
@ -949,16 +991,9 @@ public class MenuBuilder {
int paddingSides = dpToPx(10f);
button.setPadding(paddingSides, 0, paddingSides, 0);
if (!selected) {
ColorStateList buttonColorStateList = new ColorStateList(
new int[][] {
new int[]{android.R.attr.state_pressed},
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)
}
);
ColorStateList buttonColorStateList = AndroidUtils.createColorStateList(context, !light,
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);
button.setTextColor(buttonColorStateList);
} 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));

View file

@ -4,6 +4,7 @@ import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
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.TransportRouteController;
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.other.ShareMenu;
import net.osmand.plus.mapillary.MapillaryImage;
@ -225,8 +226,8 @@ public abstract class MenuController extends BaseMenuController {
return true;
}
public void addPlainMenuItem(int iconId, String text, boolean needLinks, boolean isUrl, OnClickListener onClickListener) {
builder.addPlainMenuItem(iconId, text, needLinks, isUrl, onClickListener);
public void addPlainMenuItem(int iconId, String buttonText, String text, boolean needLinks, boolean isUrl, OnClickListener onClickListener) {
builder.addPlainMenuItem(iconId, buttonText, text, needLinks, isUrl, onClickListener);
}
public void clearPlainMenuItems() {
@ -239,7 +240,7 @@ public abstract class MenuController extends BaseMenuController {
protected void addMyLocationToPlainItems(LatLon latLon) {
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);
//if (st.COORDINATES_FORMAT.get() != PointDescription.OLC_FORMAT)
// addPlainMenuItem(R.drawable.ic_action_get_my_location, PointDescription.getLocationOlcName(
@ -386,15 +387,11 @@ public abstract class MenuController extends BaseMenuController {
return false;
}
public boolean displayAdditionalTypeStrInHours() {
return false;
}
public int getLeftIconId() {
public int getRightIconId() {
return 0;
}
public Drawable getLeftIcon() {
public Drawable getRightIcon() {
return null;
}
@ -402,10 +399,14 @@ public abstract class MenuController extends BaseMenuController {
return null;
}
public Drawable getAdditionalLineTypeIcon() {
public Drawable getSubtypeIcon() {
return null;
}
public boolean navigateInPedestrianMode() {
return false;
}
public int getFavActionIconId() {
return R.drawable.map_action_fav_dark;
}
@ -432,16 +433,29 @@ public abstract class MenuController extends BaseMenuController {
return "";
}
public String getAdditionalTypeStr() {
public String getSubtypeStr() {
return "";
}
public int getTimeStrColor() {
public int getAdditionalInfoColor() {
if (indexItem != null) {
return R.color.icon_color;
}
return 0;
}
public OpeningHoursInfo getOpeningHoursInfo() {
return null;
public String getAdditionalInfoStr() {
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() {
@ -531,11 +545,14 @@ public abstract class MenuController extends BaseMenuController {
public abstract class TitleButtonController {
public String caption = "";
public int leftIconId = 0;
public int rightIconId = 0;
public boolean needRightText = false;
public String rightTextCaption = "";
public boolean visible = true;
public boolean needColorizeIcon = true;
public Drawable leftIcon;
public Drawable rightIcon;
public boolean enabled = true;
public Drawable getLeftIcon() {
if (leftIcon != null) {
@ -543,7 +560,7 @@ public abstract class MenuController extends BaseMenuController {
}
if (leftIconId != 0) {
if (needColorizeIcon) {
return getIcon(leftIconId, isLight() ? R.color.map_widget_blue : R.color.osmand_orange);
return getIcon(leftIconId, getColorRes());
}
return ContextCompat.getDrawable(getMapActivity(), leftIconId);
} 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();
}
@ -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>() {
ResourceManager rm;
@ -774,6 +815,11 @@ public abstract class MenuController extends BaseMenuController {
public ContextMenuToolbarController(MenuController menuController) {
super(TopToolbarControllerType.CONTEXT_MENU);
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() {

View file

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

View file

@ -1,5 +1,8 @@
package net.osmand.plus.mapcontextmenu;
import android.content.Context;
import net.osmand.plus.R;
import net.osmand.util.Algorithms;
public class OpeningHoursInfo {
@ -68,12 +71,20 @@ public class OpeningHoursInfo {
this.openingDay = openingDay;
}
public boolean containsInfo() {
return opened24_7
|| !Algorithms.isEmpty(openingTime)
|| !Algorithms.isEmpty(nearToOpeningTime)
|| !Algorithms.isEmpty(closingTime)
|| !Algorithms.isEmpty(nearToClosingTime)
|| !Algorithms.isEmpty(openingDay);
public String getInfo(Context context) {
if (isOpened24_7()) {
return context.getString(R.string.shared_string_is_open_24_7);
} else if (!Algorithms.isEmpty(getNearToOpeningTime())) {
return context.getString(R.string.will_open_at) + " " + getNearToOpeningTime();
} else if (!Algorithms.isEmpty(getOpeningTime())) {
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;
import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
@ -9,26 +9,56 @@ import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController.TransportStopRoute;
import net.osmand.plus.transport.TransportStopRoute;
import java.util.List;
public class TransportStopRouteAdapter extends ArrayAdapter<TransportStopRoute> {
public TransportStopRouteAdapter(@NonNull Context context, @NonNull List<TransportStopRoute> objects) {
super(context, 0, objects);
private boolean nightMode;
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
@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) {
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;
}
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.TextView;
import net.osmand.AndroidUtils;
import net.osmand.data.Amenity;
import net.osmand.data.PointDescription;
import net.osmand.osm.AbstractPoiType;
@ -31,6 +32,7 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.WikipediaDialogFragment;
import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.views.POIMapLayer;
import net.osmand.plus.widgets.TextViewEx;
@ -92,7 +94,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
ll.setOrientation(LinearLayout.HORIZONTAL);
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
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() {
@Override
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));
textView.setLayoutParams(llTextParams);
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;
if (isPhoneNumber || isUrl) {
@ -217,16 +219,9 @@ public class AmenityMenuBuilder extends MenuBuilder {
button.setTextSize(14);
int paddingSides = dpToPx(10f);
button.setPadding(paddingSides, 0, paddingSides, 0);
ColorStateList buttonColorStateList = new ColorStateList(
new int[][] {
new int[]{android.R.attr.state_pressed},
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)
}
);
ColorStateList buttonColorStateList = AndroidUtils.createColorStateList(view.getContext(), !light,
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);
button.setTextColor(buttonColorStateList);
button.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
button.setSingleLine(true);
@ -234,12 +229,12 @@ public class AmenityMenuBuilder extends MenuBuilder {
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
POIMapLayer.showWikipediaDialog(view.getContext(), app, amenity);
WikipediaDialogFragment.showInstance(mapActivity, amenity);
}
});
button.setAllCaps(true);
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.setCompoundDrawablePadding(dpToPx(8f));
llText.addView(button);
@ -284,7 +279,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
ll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
POIMapLayer.showWikipediaDialog(view.getContext(), app, amenity);
WikipediaDialogFragment.showInstance(mapActivity, amenity);
}
});
} else if (isText && text.length() > 200) {
@ -516,10 +511,10 @@ public class AmenityMenuBuilder extends MenuBuilder {
} else {
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);
}
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)
.replaceAll("\n", " "), 0, false, null, false, 0, false, null, false);
//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;
color = favoriteGroup.visible ? (color | 0xff000000) : view.getResources().getColor(disabledColor);
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),
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[] lines = description.split("\n");
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());
Date date = new Date(wpt.time);
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) {
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)) {
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)) {
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);
}
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() {
@Override
public void onClick(View v) {
@ -70,7 +70,7 @@ public class WptPtMenuBuilder extends MenuBuilder {
});
}
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);
rowc.setOnClickListener(new View.OnClickListener() {
@Override
@ -96,7 +96,7 @@ public class WptPtMenuBuilder extends MenuBuilder {
File file = new File(gpx.path);
String gpxName = file.getName().replace(".gpx", "").replace("/", " ").replace("_", " ");
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),
false, 0, false, null, false);
}

View file

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

View file

@ -1,7 +1,5 @@
package net.osmand.plus.mapcontextmenu.controllers;
import android.view.View;
import net.osmand.data.Amenity;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
@ -14,16 +12,15 @@ import net.osmand.osm.PoiType;
import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.mapcontextmenu.OpeningHoursInfo;
import net.osmand.plus.mapcontextmenu.WikipediaDialogFragment;
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.resources.TransportIndexRepository;
import net.osmand.plus.views.POIMapLayer;
import net.osmand.plus.views.TransportStopsLayer;
import net.osmand.plus.transport.TransportStopType;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import net.osmand.util.OpeningHoursParser;
@ -39,6 +36,7 @@ public class AmenityMenuController extends MenuController {
private Amenity amenity;
private List<TransportStopRoute> routes = new ArrayList<>();
private OpeningHoursInfo openingHoursInfo;
private MapMarker marker;
@ -71,12 +69,14 @@ public class AmenityMenuController extends MenuController {
leftTitleButtonController = new TitleButtonController() {
@Override
public void buttonPressed() {
POIMapLayer.showWikipediaDialog(mapActivity, mapActivity.getMyApplication(), amenity);
WikipediaDialogFragment.showInstance(mapActivity, amenity);
}
};
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
@ -108,11 +108,11 @@ public class AmenityMenuController extends MenuController {
}
@Override
public int getLeftIconId() {
return getLeftIconId(amenity);
public int getRightIconId() {
return getRightIconId(amenity);
}
private static int getLeftIconId(Amenity amenity) {
private static int getRightIconId(Amenity amenity) {
String id = null;
PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
if (st != null) {
@ -146,8 +146,27 @@ public class AmenityMenuController extends MenuController {
}
@Override
public OpeningHoursInfo getOpeningHoursInfo() {
return processOpeningHours(amenity);
public int getAdditionalInfoColor() {
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) {
@ -201,7 +220,7 @@ public class AmenityMenuController extends MenuController {
public static void addPlainMenuItems(Amenity amenity, String typeStr, MenuBuilder builder) {
if (!Algorithms.isEmpty(typeStr)) {
int resId = getLeftIconId(amenity);
int resId = getRightIconId(amenity);
if (resId == 0) {
PoiCategory pc = amenity.getType();
resId = RenderingIcons.getBigIconResourceId(pc.getIconKeyName());
@ -254,7 +273,7 @@ public class AmenityMenuController extends MenuController {
if (rts != null) {
for (TransportRoute rs : rts) {
if (!containsRef(rs)) {
TransportStopController.TransportStopType type = TransportStopController.TransportStopType.findType(rs.getType());
TransportStopType type = TransportStopType.findType(rs.getType());
TransportStopRoute r = new TransportStopRoute();
r.type = type;
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.editors.FavoritePointEditor;
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditorFragment;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.util.Algorithms;
import java.util.ArrayList;
@ -27,7 +28,8 @@ public class FavouritePointMenuController extends MenuController {
private FavouritePoint fav;
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) {
super(new FavouritePointMenuBuilder(mapActivity, fav), pointDescription, mapActivity);
@ -50,6 +52,11 @@ public class FavouritePointMenuController extends MenuController {
routes = transportStopController.processTransportStop();
builder.setRoutes(routes);
}
Object originObject = getBuilder().getOriginObject();
if (originObject instanceof Amenity) {
openingHoursInfo = AmenityMenuController.processOpeningHours((Amenity) originObject);
}
}
@Override
@ -65,7 +72,7 @@ public class FavouritePointMenuController extends MenuController {
}
@Override
public List<TransportStopController.TransportStopRoute> getTransportStopRoutes() {
public List<TransportStopRoute> getTransportStopRoutes() {
return routes;
}
@ -95,7 +102,7 @@ public class FavouritePointMenuController extends MenuController {
}
@Override
public Drawable getLeftIcon() {
public Drawable getRightIcon() {
return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(), fav.getColor(), false);
}
@ -106,7 +113,7 @@ public class FavouritePointMenuController extends MenuController {
@Override
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
@ -132,7 +139,7 @@ public class FavouritePointMenuController extends MenuController {
@Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
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();
if (originObject != null) {
@ -146,11 +153,26 @@ public class FavouritePointMenuController extends MenuController {
}
@Override
public OpeningHoursInfo getOpeningHoursInfo() {
Object originObject = getBuilder().getOriginObject();
if (originObject instanceof Amenity) {
return AmenityMenuController.processOpeningHours((Amenity) originObject);
public int getAdditionalInfoColor() {
if (openingHoursInfo != null) {
return openingHoursInfo.isOpened() ? R.color.ctx_menu_amenity_opened_text_color : R.color.ctx_menu_amenity_closed_text_color;
}
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
public Drawable getLeftIcon() {
public Drawable getRightIcon() {
return getIcon(R.drawable.ic_action_polygom_dark, R.color.osmand_orange);
}
}

View file

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

View file

@ -53,7 +53,7 @@ public class ImpassibleRoadsMenuController extends MenuController {
}
@Override
public Drawable getLeftIcon() {
public Drawable getRightIcon() {
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;
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
public void buttonPressed() {
getMapActivity().getContextMenu().close();
@ -158,7 +141,25 @@ public class MapDataMenuController extends MenuController {
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() {
@Override
@ -178,6 +179,39 @@ public class MapDataMenuController extends MenuController {
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
protected void setObject(Object object) {
if (object instanceof DownloadMapObject) {
@ -197,7 +231,7 @@ public class MapDataMenuController extends MenuController {
}
@Override
public Drawable getLeftIcon() {
public Drawable getRightIcon() {
int iconResId;
if (getDownloadActivityType() != null) {
iconResId = getDownloadActivityType().getIconResource();
@ -219,6 +253,10 @@ public class MapDataMenuController extends MenuController {
} else {
res = getMapActivity().getString(R.string.shared_string_map);
}
DownloadActivityType downloadActivityType = getDownloadActivityType();
if (downloadActivityType != null) {
res += ", " + downloadActivityType.getString(getMapActivity());
}
if (getMenuType() == MenuType.STANDARD) {
res += "\n";
}
@ -233,16 +271,16 @@ public class MapDataMenuController extends MenuController {
@Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
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();
sizeStr.append(indexItem.getSizeDescription(getMapActivity()));
if (backuped) {
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) {
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();
if (localIndexInfo.getSize() >= 0) {
@ -259,7 +297,7 @@ public class MapDataMenuController extends MenuController {
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())) {
String[] items = mapObject.getWorldRegion().getParams().getWikiLink().split(":");
@ -269,7 +307,7 @@ public class MapDataMenuController extends MenuController {
} else {
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())) {
String population = mapObject.getWorldRegion().getParams().getPopulation();
@ -283,14 +321,14 @@ public class MapDataMenuController extends MenuController {
b.insert(0, population.charAt(i));
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);
}
if (indexItem != null) {
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) {
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;
}
rightDownloadButtonController.visible = downloaded;
bottomTitleButtonController.visible = (otherIndexItems != null && otherIndexItems.size() > 0)
bottomTitleButtonController.visible = downloaded;
rightDownloadButtonController.visible = (otherIndexItems != null && otherIndexItems.size() > 0)
|| (otherLocalIndexInfos != null && otherLocalIndexInfos.size() > 0);
boolean internetConnectionAvailable =

View file

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

View file

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

View file

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

View file

@ -49,7 +49,7 @@ public class RenderedObjectMenuController extends MenuController {
}
@Override
public int getLeftIconId() {
public int getRightIconId() {
if (renderedObject.getIconRes() != null && RenderingIcons.containsBigIcon(renderedObject.getIconRes())) {
return RenderingIcons.getBigIconResourceId(renderedObject.getIconRes());
} else {
@ -95,7 +95,7 @@ public class RenderedObjectMenuController extends MenuController {
if (entry.getKey().equalsIgnoreCase("maxheight")) {
AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(entry.getKey());
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 {
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);
}

View file

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

View file

@ -1,5 +1,6 @@
package net.osmand.plus.mapcontextmenu.controllers;
import android.text.TextUtils;
import android.view.View;
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.MenuBuilder;
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 java.util.List;
@ -46,6 +47,30 @@ public class TransportRouteController extends MenuController {
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
@ -55,13 +80,18 @@ public class TransportRouteController extends MenuController {
}
}
@Override
public boolean navigateInPedestrianMode() {
return true;
}
@Override
protected Object getObject() {
return transportRoute;
}
@Override
public int getLeftIconId() {
public int getRightIconId() {
return this.transportRoute.type == null ?
R.drawable.mx_public_transport :
this.transportRoute.type.getTopResourceId();
@ -77,11 +107,6 @@ public class TransportRouteController extends MenuController {
return false;
}
@Override
public boolean navigateButtonVisible() {
return false;
}
@Override
public boolean isClosable() {
return false;
@ -94,13 +119,17 @@ public class TransportRouteController extends MenuController {
@Override
public String getTypeStr() {
if (transportRoute.refStop != null) {
return transportRoute.refStop.getName();
} else if (transportRoute.stop != null) {
return transportRoute.stop.getName();
} else {
return getPointDescription().getTypeName();
}
return getPointDescription().getName();
}
private String getStopType() {
return getMapActivity().getString(transportRoute.getTypeStrRes()) + " " + getMapActivity().getString(R.string.transport_Stop).toLowerCase();
}
@Override
public void updateData() {
super.updateData();
updateControllers();
}
@Override
@ -121,25 +150,98 @@ public class TransportRouteController extends MenuController {
}
}
private void updateControllers() {
boolean previousStopEnabled = false;
final int previousStop = getPreviousStop();
if (previousStop != -1) {
previousStopEnabled = true;
}
leftTitleButtonController.enabled = previousStopEnabled;
boolean nextStopEnabled = false;
final int nextStop = getNextStop();
if (nextStop != -1) {
nextStopEnabled = true;
}
rightTitleButtonController.enabled = nextStopEnabled;
}
private void showTransportStop(TransportStop stop) {
if (mapContextMenu != null) {
transportRoute.stop = stop;
transportRoute.refStop = stop;
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE,
transportRoute.getDescription(getMapActivity().getMyApplication(), false));
updateControllers();
LatLon stopLocation = stop.getLocation();
if (mapContextMenu.isVisible()) {
mapContextMenu.updateMapCenter(stopLocation);
} else {
mapContextMenu.setMapCenter(stopLocation);
mapContextMenu.setMapPosition(getMapActivity().getMapView().getMapPosition());
}
mapContextMenu.setCenterMarker(true);
mapContextMenu.setMapZoom(15);
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 = -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;
}
}
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.route_stops_before, currentStop),
addPlainMenuItem(defaultIcon, getMapActivity().getString(R.string.shared_string_show),
getMapActivity().getString(R.string.route_stops_before, currentStop),
false, false, new OnClickListener() {
@Override
@ -152,29 +254,16 @@ public class TransportRouteController extends MenuController {
}
for (int i = startPosition; i < stops.size(); i++) {
final TransportStop stop = stops.get(i);
final String name = useEnglishNames ? stop.getEnName(true) : stop.getName();
String name = useEnglishNames ? stop.getEnName(true) : stop.getName();
if (TextUtils.isEmpty(name)) {
name = getStopType();
}
addPlainMenuItem(currentStop == i ? R.drawable.ic_action_marker_dark : defaultIcon,
name, false, false, new OnClickListener() {
null, name, false, false, new OnClickListener() {
@Override
public void onClick(View arg0) {
if (mapContextMenu != null) {
transportRoute.stop = stop;
transportRoute.refStop = stop;
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_ROUTE,
transportRoute.getDescription(getMapActivity().getMyApplication(), false));
LatLon stopLocation = stop.getLocation();
if (mapContextMenu.isVisible()) {
mapContextMenu.updateMapCenter(stopLocation);
} else {
mapContextMenu.setMapCenter(stopLocation);
mapContextMenu.setMapPosition(getMapActivity().getMapView().getMapPosition());
}
mapContextMenu.setCenterMarker(true);
mapContextMenu.setMapZoom(15);
mapContextMenu.showOrUpdate(stopLocation, pd, transportRoute);
}
showTransportStop(stop);
/*
PointDescription pd = new PointDescription(PointDescription.POINT_TYPE_TRANSPORT_STOP,
getMapActivity().getString(R.string.transport_Stop), name);
@ -202,7 +291,7 @@ public class TransportRouteController extends MenuController {
TransportStopsLayer stopsLayer = getMapActivity().getMapLayers().getTransportStopsLayer();
int cz = transportRoute.calculateZoom(0, getMapActivity().getMapView().getCurrentRotatedTileBox());
getMapActivity().changeZoom(cz - getMapActivity().getMapView().getZoom());
stopsLayer.setRoute(transportRoute.route);
stopsLayer.setRoute(transportRoute);
}
private void resetRoute() {

View file

@ -6,17 +6,16 @@ import android.view.View.OnClickListener;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect;
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.plus.transport.TransportStopRoute;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.resources.TransportIndexRepository;
import net.osmand.plus.transport.TransportStopType;
import net.osmand.plus.views.TransportStopsLayer;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
@ -29,51 +28,6 @@ import java.util.List;
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 List<TransportStopRoute> routes = new ArrayList<>();
private TransportStopType topType;
@ -82,26 +36,29 @@ public class TransportStopController extends MenuController {
PointDescription pointDescription, TransportStop transportStop) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
this.transportStop = transportStop;
routes = processTransportStop();
builder.setRoutes(routes);
processRoutes();
}
@Override
protected void setObject(Object object) {
if (object instanceof TransportStop) {
this.transportStop = (TransportStop) object;
routes = processTransportStop();
builder.setRoutes(routes);
processRoutes();
}
}
private void processRoutes() {
routes = processTransportStop();
builder.setRoutes(routes);
}
@Override
protected Object getObject() {
return transportStop;
}
@Override
public int getLeftIconId() {
public int getRightIconId() {
if (topType == null) {
return R.drawable.mx_public_transport;
} else {
@ -204,42 +161,4 @@ public class TransportStopController extends MenuController {
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
public Drawable getLeftIcon() {
public Drawable getRightIcon() {
return FavoriteImageDrawable.getOrCreate(getMapActivity().getMyApplication(),
wpt.getColor(ContextCompat.getColor(getMapActivity(), R.color.gpx_color_point)), false);
}
@Override
public Drawable getAdditionalLineTypeIcon() {
if (Algorithms.isEmpty(getAdditionalTypeStr())) {
public Drawable getSubtypeIcon() {
if (Algorithms.isEmpty(getSubtypeStr())) {
return null;
} 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
public String getAdditionalTypeStr() {
public String getSubtypeStr() {
return wpt.category != null ? wpt.category : "";
}

View file

@ -4,6 +4,7 @@ import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
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);
if (menu.isLandscapeLayout()) {
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 {
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);
@ -49,11 +50,6 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele
AndroidUtils.addStatusBarPadding21v(getActivity(), listView);
}
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);
listView.addHeaderView(headerView);
listAdapter = createAdapter();
@ -62,6 +58,9 @@ public class MapMultiSelectionMenuFragment extends Fragment implements MultiSele
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() {
@Override
public void onClick(View view) {

View file

@ -259,24 +259,16 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
private void updateViaView(final View parentView) {
String via = generateViaDescription();
View viaLayout = parentView.findViewById(R.id.ViaLayout);
View fromLayoutEmptyView = parentView.findViewById(R.id.from_layout_empty_view);
View toLayoutEmptyView = parentView.findViewById(R.id.to_layout_empty_view);
View dividerFromDropDownEmpty = parentView.findViewById(R.id.divider_from_drop_down_empty);
View viaLayoutDivider = parentView.findViewById(R.id.viaLayoutDivider);
ImageView swapDirectionView = (ImageView) parentView.findViewById(R.id.swap_direction_image_view);
if (via.length() == 0) {
viaLayout.setVisibility(View.GONE);
parentView.findViewById(R.id.viaLayoutDivider).setVisibility(View.GONE);
dividerFromDropDownEmpty.setVisibility(View.GONE);
fromLayoutEmptyView.setVisibility(View.VISIBLE);
toLayoutEmptyView.setVisibility(View.VISIBLE);
viaLayoutDivider.setVisibility(View.GONE);
swapDirectionView.setVisibility(View.VISIBLE);
} else {
fromLayoutEmptyView.setVisibility(View.GONE);
toLayoutEmptyView.setVisibility(View.GONE);
swapDirectionView.setVisibility(View.GONE);
dividerFromDropDownEmpty.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);
}
@ -294,7 +286,6 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
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));
AndroidUtils.setBackground(mapActivity, swapDirectionView, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
swapDirectionView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -638,7 +629,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} else {
infoIcon.setImageDrawable(ctx.getIconsCache().getIcon(R.drawable.ic_action_route_distance, R.color.route_info_unchecked_mode_icon_color));
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);
infoDistanceView.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);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerFromDropDown), nightMode,
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,
R.color.route_info_divider_light, R.color.route_info_divider_dark);
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.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.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.DistanceTitle), 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);
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() {
@Override
public void onClick(View view) {
@ -51,8 +49,8 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
IconsCache iconsCache = menu.getMapActivity().getMyApplication().getIconsCache();
final View iconLayout = convertView.findViewById(R.id.context_menu_icon_layout);
final ImageView iconView = (ImageView) convertView.findViewById(R.id.context_menu_icon_view);
Drawable icon = item.getLeftIcon();
int iconId = item.getLeftIconId();
Drawable icon = item.getRightIcon();
int iconId = item.getRightIconId();
if (icon != null) {
iconView.setImageDrawable(icon);
iconLayout.setVisibility(View.VISIBLE);
@ -66,7 +64,7 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
// Text line 1
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));
line1.setText(item.getTitleStr());
@ -80,9 +78,7 @@ public class MultiSelectionArrayAdapter extends ArrayAdapter<MapMultiSelectionMe
// Divider
View divider = convertView.findViewById(R.id.divider);
if (!menu.isLight()) {
divider.setBackgroundResource(R.color.dashboard_divider_dark);
}
divider.setBackgroundColor(ContextCompat.getColor(getContext(), menu.isLight() ? R.color.multi_selection_menu_divider_light : R.color.multi_selection_menu_divider_dark));
divider.setVisibility(position != getCount() - 1 ? View.VISIBLE : View.GONE);
}

View file

@ -56,7 +56,7 @@ public class MapillaryMenuController extends MenuController {
}
@Override
public Drawable getLeftIcon() {
public Drawable getRightIcon() {
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 ColorStateList dividerControlColorStateList = new ColorStateList(
new int[][]{
new int[]{android.R.attr.state_pressed},
new int[]{}
},
new int[] {
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)
}
);
private ColorStateList dividerControlColorStateList = AndroidUtils.createColorStateList(getContext(), false,
R.color.keyboard_item_divider_control_color_light, R.color.keyboard_item_divider_control_color_light_pressed,
0, 0);
private ColorStateList numberColorStateList = AndroidUtils.createColorStateList(getContext(), false,
R.color.keyboard_item_text_color_light, R.color.keyboard_item_text_color_light_pressed,
0, 0);
KeyboardAdapter(@NonNull Context context, @NonNull Object[] objects) {
super(context, 0, objects);

View file

@ -30,8 +30,8 @@ public class EditPOIMenuBuilder extends MenuBuilder {
if (osmPoint instanceof OsmNotesPoint) {
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_group, notes.getAuthor(), 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, null, notes.getAuthor(), 0, false, null, false, 0, false, null, false);
} else if (osmPoint instanceof OpenstreetmapPoint) {
OpenstreetmapPoint point = (OpenstreetmapPoint) osmPoint;
@ -56,7 +56,7 @@ public class EditPOIMenuBuilder extends MenuBuilder {
if (resId == 0) {
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;
}
}
@ -67,11 +67,11 @@ public class EditPOIMenuBuilder extends MenuBuilder {
continue;
}
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)
.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 net.osmand.data.PointDescription;
import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.osmedit.OsmPoint.Action;
import net.osmand.plus.osmedit.dialogs.SendPoiDialogFragment;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.util.Algorithms;
import java.util.Map;
public class EditPOIMenuController extends MenuController {
private OsmPoint osmPoint;
private OsmEditingPlugin plugin;
private String pointTypeStr;
private String category;
private String actionStr;
public EditPOIMenuController(final MapActivity mapActivity, PointDescription pointDescription, OsmPoint osmPoint) {
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.leftIconId = R.drawable.ic_action_delete_dark;
category = getCategory();
if (osmPoint.getGroup() == OsmPoint.Group.POI) {
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) {
pointTypeStr = getMapActivity().getString(R.string.osm_edit_modified_poi);
actionStr = getMapActivity().getString(R.string.osm_edit_modified_poi);
} 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) {
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) {
pointTypeStr = getMapActivity().getString(R.string.osm_edit_commented_note);
actionStr = getMapActivity().getString(R.string.osm_edit_commented_note);
} 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) */{
pointTypeStr = getMapActivity().getString(R.string.osm_edit_created_note);
actionStr = getMapActivity().getString(R.string.osm_edit_created_note);
}
} else {
pointTypeStr = "";
actionStr = "";
}
}
@Override
public String getTypeStr() {
return category;
}
@Override
protected void setObject(Object object) {
if (object instanceof OsmPoint) {
@ -112,21 +123,85 @@ public class EditPOIMenuController extends MenuController {
@Override
public boolean needTypeStr() {
return !Algorithms.isEmpty(pointTypeStr);
return !Algorithms.isEmpty(category);
}
@Override
public Drawable getLeftIcon() {
return getIcon(R.drawable.ic_action_gabout_dark, R.color.created_poi_icon_color);
public boolean displayDistanceDirection() {
return true;
}
@Override
public String getTypeStr() {
return pointTypeStr;
public String getAdditionalInfoStr() {
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
public boolean needStreetName() {
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
public Drawable getLeftIcon() {
public Drawable getRightIcon() {
if (bug.isOpened()) {
return getIcon(R.drawable.ic_action_gabout_dark, R.color.osm_bug_unresolved_icon_color);
} else {
@ -95,7 +95,7 @@ public class OsmBugMenuController extends MenuController {
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
super.addPlainMenuItems(typeStr, pointDescription, latLon);
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
public Drawable getLeftIcon() {
public Drawable getRightIcon() {
if (isLight()) {
return getIconOrig(R.drawable.widget_osmo_connected_location_day);
} else {

View file

@ -64,17 +64,17 @@ public class ParkingPositionMenuController extends MenuController {
}
@Override
public String getAdditionalTypeStr() {
public int getAdditionalInfoIconRes() {
return R.drawable.ic_action_opening_hour_16;
}
@Override
public String getAdditionalInfoStr() {
return parkingLeftDescription;
}
@Override
public boolean displayAdditionalTypeStrInHours() {
return true;
}
@Override
public int getTimeStrColor() {
public int getAdditionalInfoColor() {
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;
}
@Override
public boolean navigateInPedestrianMode() {
return true;
}
@Override
public boolean displayDistanceDirection() {
return true;
}
@Override
public Drawable getLeftIcon() {
public Drawable getRightIcon() {
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);
mInChangeMarkerPositionMode = true;
mMoveMarkerBottomSheetHelper.show(menu.getLeftIcon());
mMoveMarkerBottomSheetHelper.show(menu.getRightIcon());
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);

View file

@ -295,7 +295,6 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
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));
AndroidUtils.setBackground(mapActivity, cancelRouteButton, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
cancelRouteButton.setOnClickListener(new View.OnClickListener() {
@Override
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);
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() {
@Override
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);
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));
AndroidUtils.setBackground(mapActivity, options, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
options.setOnClickListener(new View.OnClickListener() {
@Override
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.v7.widget.PopupMenu;
import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.text.util.Linkify;
import android.util.TypedValue;
import android.view.Gravity;
@ -289,13 +290,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
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) {
showText(ctx, app, text, title);
}
@ -308,122 +302,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
ctx.getTheme().resolveAttribute(attr, typedvalueattr, true);
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) {
final Dialog dialog = new Dialog(ctx,
@ -471,50 +349,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
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
public PointDescription getObjectName(Object o) {
if (o instanceof Amenity) {

View file

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