Compare commits

...

38 commits
master ... r2.9

Author SHA1 Message Date
Alexander Sytnyk
9bb7b295d9 Handle the interruption of the permission request 2018-02-08 12:50:35 +02:00
Alexander Sytnyk
291509580c Fix IllegalStateException 2018-02-07 12:52:25 +02:00
xmd5a
d06eca5e4e Change phrase name (charging) 2018-02-06 20:28:36 +03:00
Alexander Sytnyk
df1bed0f4b Fix ConcurrentModificationException 2018-02-06 16:55:40 +02:00
Alexander Sytnyk
10ae4afd90 Swap icons for warnings list 2018-02-06 16:26:43 +02:00
Alexander Sytnyk
ce59706582 Fix #3773 2018-02-06 16:26:32 +02:00
Alexander Sytnyk
6a7b30e33d Fix displaying of tunnel length 2018-02-06 16:26:02 +02:00
Alexey Kulish
6482818892 Fix POI additionals in context menu 2018-02-06 14:57:57 +03:00
Alexey Kulish
3c7afb3139 Fix 'show all' button for POI additionals in context menu 2018-02-06 12:08:30 +03:00
Alexey Kulish
b0443dd424 Improved displaying of POI additionals in context menu 2018-02-06 11:06:34 +03:00
Alexander Sytnyk
ba10ca0ecc Fix distance formatting for tunnel alarm info 2018-02-05 18:51:42 +02:00
Alexander Sytnyk
fd26d9d58d Translate renderer name in menu item description 2018-02-05 18:46:06 +02:00
Alexander Sytnyk
f027adf0eb Fix #4977 2018-02-05 18:46:00 +02:00
Alexander Sytnyk
953cfec17b Revert changes 2018-02-05 18:45:53 +02:00
Alexander Sytnyk
2d80f3e4d9 Add "Make as Start Point" item to add waypoints menu 2018-02-05 16:36:17 +02:00
Alexey Kulish
6ec8a82bba Fix #4986 2018-02-05 14:16:40 +03:00
Alexander Sytnyk
ccf4740989 Increase add waypoint menu item height 2018-02-05 12:17:22 +02:00
Victor Shcherb
0588eb7cd4 Fix issue #3844 2018-02-03 18:54:32 +01:00
Alexey Kulish
e1748a0c2e Fix handling context menu swipes 2018-02-03 19:13:38 +03:00
Alexander Sytnyk
4f776f3268 Redesign "add waypoint" menu; remove some legacy code 2018-02-03 15:52:22 +03:00
Alexey Kulish
cd757e3516 Fix #4628 2018-02-03 14:45:41 +03:00
Alexey Kulish
3de5811add Fix #4746 2018-02-03 13:57:35 +03:00
Alexey Kulish
c9ab275284 Added fling to context menu 2018-02-03 10:35:05 +03:00
Alexander Sytnyk
cd7628ae3d Fix concurrent modification exception 2018-02-02 14:31:05 +02:00
Alexey Kulish
c8c2f03989 Fix opening hours UI 2018-02-02 14:47:39 +03:00
Alexander Sytnyk
6fbfbf1b65 Fix NPE that occurs while search amenities 2018-02-02 12:35:08 +02:00
Alexander Sytnyk
95d1c7370e Fix NPE that occurs when swapping start and finish points 2018-02-02 12:07:35 +02:00
Alexey Kulish
19e2e90276 Fix context menu UI issues 2018-02-02 12:11:32 +03:00
Alexey Kulish
09e4e6bba8 Fix context menu 2018-02-02 12:11:12 +03:00
Alexey Kulish
f14a84dc19 Fix context menu landscape layout 2018-02-02 12:10:49 +03:00
Alexey Kulish
cb2ede54bc Added toolbar to context menu 2018-02-02 12:10:20 +03:00
Alexander Sytnyk
e4298a796c Add small UI fixes 2018-02-01 18:30:16 +02:00
Alexander Sytnyk
2e479f0563 Add functionality to zoom setting 2018-02-01 18:30:08 +02:00
Alexander Sytnyk
8ae1c4f910 Add items to osm notes menu; add functionality for show/hide closed notes and notes in general 2018-02-01 18:30:00 +02:00
Alexander Sytnyk
9dbe9c1c7e Osm notes menu in progress 2018-02-01 18:29:51 +02:00
PaulStets
93dbe540b5 Correct distance format 2018-02-01 16:28:40 +02:00
PaulStets
a4ab825925 Small refactoring and cleaning 2018-02-01 16:28:29 +02:00
PaulStets
be45cb0706 Added the tunnel warnings 2018-02-01 16:28:12 +02:00
58 changed files with 1802 additions and 558 deletions

View file

@ -30,6 +30,7 @@ public class Amenity extends MapObject {
public static final String OPENING_HOURS = "opening_hours";
public static final String CONTENT = "content";
public static final String CUISINE = "cuisine";
public static final String DISH = "dish";
public static final String OSM_DELETE_VALUE = "delete";
public static final String OSM_DELETE_TAG = "osmand_change";

View file

@ -41,7 +41,7 @@ public class MapPoiTypes {
private boolean init;
Map<String, PoiType> poiTypesByTag = new LinkedHashMap<String, PoiType>();
Map<String, String> deprecatedTags = new LinkedHashMap<String, String>();
Map<String, String> poiAdditionalCategoryIcons = new LinkedHashMap<String, String>();
Map<String, String> poiAdditionalCategoryIconNames = new LinkedHashMap<String, String>();
List<PoiType> textPoiAdditionals = new ArrayList<PoiType>();
@ -92,8 +92,8 @@ public class MapPoiTypes {
return otherMapCategory;
}
public String getPoiAdditionalCategoryIcon(String category) {
return poiAdditionalCategoryIcons.get(category);
public String getPoiAdditionalCategoryIconName(String category) {
return poiAdditionalCategoryIconNames.get(category);
}
public List<PoiType> getTextPoiAdditionals() {
@ -379,7 +379,7 @@ public class MapPoiTypes {
lastPoiAdditionalCategory = parser.getAttributeValue("", "name");
String icon = parser.getAttributeValue("", "icon");
if (!Algorithms.isEmpty(icon)) {
poiAdditionalCategoryIcons.put(lastPoiAdditionalCategory, icon);
poiAdditionalCategoryIconNames.put(lastPoiAdditionalCategory, icon);
}
}
@ -814,6 +814,12 @@ public class MapPoiTypes {
if (!otag.equals(tag) && !otag.equals("name")) {
PoiType pat = poiTypesByTag.get(otag + "/" + e.getValue());
if (pat == null) {
for(String splValue : e.getValue().split(";")) {
PoiType ps = poiTypesByTag.get(otag + "/" + splValue.trim());
if(ps != null) {
a.setAdditionalInfo(ps.getKeyName(), splValue.trim());
}
}
pat = poiTypesByTag.get(otag);
}
if (pat != null && pat.isAdditional()) {

View file

@ -358,6 +358,7 @@ public abstract class MapRenderingTypes {
protected static class TagValuePattern {
protected String tag;
protected String value;
protected String tagPrefix;
protected int substrSt = 0;
protected int substrEnd = 0;
protected TagValuePattern(String t, String v) {

View file

@ -1016,7 +1016,7 @@ public class OpeningHoursParser {
if (b.charAt(b.length() - 1) != ' ') {
b.append(" ");
}
b.append("(").append(comment).append(")");
b.append("- ").append(comment);
} else {
b.append(comment);
}
@ -1136,7 +1136,7 @@ public class OpeningHoursParser {
}
String res = sb.toString();
if (res.length() > 0 && !Algorithms.isEmpty(comment)) {
res += " (" + comment + ")";
res += " - " + comment;
}
return res;
}

View file

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

View file

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

View file

@ -43,6 +43,17 @@
android:textSize="@dimen/map_alarm_text_size"
android:textStyle="bold"
tools:text="60"/>
<TextView
android:id="@+id/map_alarm_warning_text_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginBottom="@dimen/map_alarm_bottom_text_margin"
android:textSize="@dimen/map_alarm_bottom_text_size"
android:textStyle="bold"
tools:text="1.2 km"
tools:textColor="@color/color_black"/>
</FrameLayout>
<TextView

View file

@ -1,53 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@+id/share_fragment_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="350dp"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<LinearLayout
android:id="@+id/main_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:background="?attr/left_menu_view_bg"
android:clickable="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="48dp">
<TextView
android:id="@+id/header_caption"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_weight="1"
android:text="@string/share_menu_location"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<ListView
android:id="@+id/list"
android:divider="@null"
android:dividerHeight="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</LinearLayout>
</LinearLayout>
</FrameLayout>

View file

@ -0,0 +1,309 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:background="?attr/bg_color">
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/bottom_sheet_content_padding_small">
<net.osmand.plus.widgets.TextViewEx
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_title_height"
android:gravity="center_vertical"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding"
android:text="@string/new_destination_point_dialog"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/>
<LinearLayout
android:id="@+id/replace_dest_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
android:src="@drawable/list_destination"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/replace_destination_point"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<TextView
android:id="@+id/current_dest_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:textColor="@color/searchbar_text_hint_light"
android:textSize="@dimen/default_desc_text_size"
tools:text="Current: Some street 46"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/replace_start_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
android:src="@drawable/list_startpoint"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/make_as_start_point"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<TextView
android:id="@+id/current_start_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:textColor="@color/searchbar_text_hint_light"
android:textSize="@dimen/default_desc_text_size"
tools:text="Current: My location"/>
</LinearLayout>
</LinearLayout>
<View
android:id="@+id/current_dest_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="@dimen/bottom_sheet_content_padding_small"
android:layout_marginLeft="@dimen/bottom_sheet_divider_margin_start"
android:layout_marginStart="@dimen/bottom_sheet_divider_margin_start"
android:layout_marginTop="@dimen/bottom_sheet_content_padding_small"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:id="@+id/subsequent_dest_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding">
<ImageView
android:id="@+id/subsequent_dest_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:foreground="@drawable/ic_action_route_subsequent_destination"
tools:src="@drawable/ic_action_route_subsequent_destination_point"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/keep_and_add_destination_point"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:text="@string/subsequent_dest_description"
android:textColor="@color/searchbar_text_hint_light"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/first_intermediate_dest_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding">
<ImageView
android:id="@+id/first_interm_dest_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:foreground="@drawable/ic_action_route_first_intermediate"
tools:src="@drawable/ic_action_route_first_intermediate_point"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/add_as_first_destination_point"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:text="@string/first_intermediate_dest_description"
android:textColor="@color/searchbar_text_hint_light"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/last_intermediate_dest_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
android:paddingEnd="@dimen/content_padding"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:paddingStart="@dimen/content_padding">
<ImageView
android:id="@+id/last_interm_dest_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/bottom_sheet_icon_margin"
android:layout_marginRight="@dimen/bottom_sheet_icon_margin"
tools:foreground="@drawable/ic_action_route_last_intermediate"
tools:src="@drawable/ic_action_route_last_intermediate_point"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:text="@string/add_as_last_destination_point"
android:textAppearance="@style/TextAppearance.ListItemTitle"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:text="@string/last_intermediate_dest_description"
android:textColor="@color/searchbar_text_hint_light"
android:textSize="@dimen/default_desc_text_size"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<View
android:id="@+id/cancel_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout
android:id="@+id/cancel_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/shared_string_cancel"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout>

View file

@ -91,7 +91,7 @@
android:layout_height= "wrap_content"
android:layout_marginBottom="@dimen/context_menu_direction_margin"
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
android:gravity="center_vertical"
android:gravity="top"
android:orientation="horizontal"
android:paddingTop="3dp"
android:paddingBottom="3dp"
@ -108,6 +108,15 @@
osmand:typeface="@string/font_roboto_medium"
tools:text="Museum"/>
<ImageView
android:id="@+id/additional_info_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:paddingTop="1dp"
android:paddingRight="@dimen/context_menu_padding_margin_small"
tools:src="@drawable/ic_action_opening_hour_16"/>
<TextView
android:id="@+id/additional_info_text_view"
android:layout_width="wrap_content"
@ -600,6 +609,86 @@
</net.osmand.plus.mapcontextmenu.InterceptorLinearLayout>
<FrameLayout
android:id="@+id/context_menu_top_button_container"
android:layout_width="wrap_content"
android:layout_height="@dimen/dashboard_map_toolbar"
android:layout_marginLeft="4dp"
android:layout_marginStart="4dp"
android:alpha="0">
<LinearLayout
android:layout_width="@dimen/list_item_height"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:background="@drawable/btn_circle_trans_flat"/>
</LinearLayout>
<ImageView
android:id="@+id/context_menu_top_back"
android:layout_width="@dimen/list_item_height"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/shared_string_collapse"
android:scaleType="center"
android:src="@drawable/ic_arrow_back"
tools:visibility="visible"/>
</FrameLayout>
<android.support.design.widget.AppBarLayout
android:id="@+id/context_menu_toolbar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alpha="0">
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/context_menu_toolbar"
android:layout_width="fill_parent"
android:layout_height="@dimen/dashboard_map_toolbar"
android:background="@color/actionbar_light_color"
app:contentInsetLeft="4dp"
app:contentInsetStart="4dp">
<ImageView
android:id="@+id/context_menu_toolbar_back"
android:layout_width="@dimen/list_item_height"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/shared_string_collapse"
android:scaleType="center"
android:src="@drawable/ic_arrow_back"
tools:visibility="visible"/>
<TextView
android:id="@+id/context_menu_toolbar_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:scaleType="center"
android:textColor="@color/abc_primary_text_material_dark"
android:textSize="@dimen/abc_text_size_large_material"
android:ellipsize="end"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
tools:text="Toolbar"
tools:visibility="visible"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="@+id/context_menu_fab_container"
android:layout_width="match_parent"

View file

@ -63,6 +63,17 @@
android:textSize="@dimen/map_alarm_text_size"
android:textStyle="bold"
tools:text="60"/>
<TextView
android:id="@+id/map_alarm_warning_text_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:layout_marginBottom="@dimen/map_alarm_bottom_text_margin"
android:textSize="@dimen/map_alarm_bottom_text_size"
android:textStyle="bold"
tools:text="1.2 km"
tools:textColor="@color/color_black"/>
</FrameLayout>
<TextView

View file

@ -1,53 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@+id/share_fragment_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:orientation="vertical">
<LinearLayout
android:id="@+id/main_view"
android:id="@+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="?attr/bottom_menu_view_bg"
android:clickable="true"
android:orientation="vertical">
<LinearLayout
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title_text_view"
android:layout_width="match_parent"
android:layout_height="48dp">
android:layout_height="@dimen/bottom_sheet_title_height"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"
android:paddingLeft="@dimen/content_padding"
android:paddingRight="@dimen/content_padding"
android:text="@string/share_menu_location"
android:textAppearance="@style/TextAppearance.ListItemTitle"
osmand:typeface="@string/font_roboto_medium"/>
<TextView
android:id="@+id/header_caption"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_weight="1"
android:text="@string/share_menu_location"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_list_text_size"/>
</LinearLayout>
<LinearLayout
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<ListView
android:id="@+id/list"
android:divider="@null"
android:dividerHeight="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</LinearLayout>
android:divider="@null"
android:dividerHeight="0dp"/>
</LinearLayout>
</FrameLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<FrameLayout
android:id="@+id/cancel_row"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_cancel_button_height"
android:background="?attr/selectableItemBackground">
<TextView
android:id="@+id/cancel_row_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/shared_string_cancel"
android:textAllCaps="true"
android:textColor="?attr/color_dialog_buttons"
android:textSize="@dimen/default_desc_text_size"
android:textStyle="bold"/>
</FrameLayout>
</LinearLayout>

View file

@ -22,8 +22,10 @@
<dimen name="map_button_shadow_margin">6dp</dimen>
<dimen name="map_button_shadow_width">84dp</dimen>
<dimen name="map_alarm_size">116dp</dimen>
<dimen name="map_alarm_bottom_text_margin">12dp</dimen>
<dimen name="map_alarm_text_size">35sp</dimen>
<dimen name="map_alarm_bottom_text_size">22sp</dimen>
<dimen name="map_alarm_bottom_margin">140dp</dimen>
<dimen name="map_alarm_bottom_margin_land">81dp</dimen>

View file

@ -155,7 +155,7 @@
<string name="poi_vehicle_inspection">Пункт техосмотра</string>
<string name="poi_car_wash">Автомойка</string>
<string name="poi_fuel">Автомобильная заправка</string>
<string name="poi_charging_station">Зарядная станция</string>
<string name="poi_electricity_combined_charging">Зарядная станция</string>
<string name="poi_vehicle_ramp">Ремонтная эстакада/яма</string>
<string name="poi_compressed_air">Подкачка шин</string>
<string name="poi_parking">Парковка</string>

View file

@ -331,7 +331,7 @@
<string name="poi_fuel_electricity">Electricity</string>
<string name="poi_aeroway_fuel">Aircraft fuel station</string>
<string name="poi_waterway_fuel">Gas station for boats</string>
<string name="poi_charging_station">Charging station</string>
<string name="poi_electricity_combined_charging">Charging station</string>
<string name="poi_vehicle_ramp">Vehicle ramp</string>
<string name="poi_compressed_air">Compressed air</string>
<string name="poi_parking">Parking</string>

View file

@ -76,6 +76,7 @@
<dimen name="map_ruler_width">120dp</dimen>
<dimen name="map_ruler_bottom_margin">9dp</dimen>
<dimen name="map_alarm_size">78dp</dimen>
<dimen name="map_alarm_bottom_text_margin">8dp</dimen>
<dimen name="map_alarm_bottom_margin">87dp</dimen>
@ -108,6 +109,7 @@
<dimen name="map_widget_text_size_small">15sp</dimen>
<dimen name="map_button_text_size">18sp</dimen>
<dimen name="map_alarm_text_size">25sp</dimen>
<dimen name="map_alarm_bottom_text_size">16sp</dimen>
<dimen name="map_widget_text_bottom_margin">1sp</dimen>
<dimen name="map_widget_text_small_bottom_margin">3sp</dimen>
<dimen name="map_widget_icon_margin">2dp</dimen>

View file

@ -9,6 +9,13 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="make_as_start_point">Make as Start Point</string>
<string name="shared_string_current">Current</string>
<string name="last_intermediate_dest_description">Adds the last stop along the route</string>
<string name="first_intermediate_dest_description">Adds the first stop on the route</string>
<string name="subsequent_dest_description">Move destination up, and create destination</string>
<string name="show_closed_notes">Show closed notes</string>
<string name="switch_osm_notes_visibility_desc">Show/Hide OSM Notes on the map.</string>
<string name="gpx_file_desc">GPX - suitable for export to JOSM or other OSM editors.</string>
<string name="osc_file_desc">OSC - suitable for export to OpenStreetMap.</string>
<string name="gpx_file">GPX file</string>
@ -1710,7 +1717,7 @@
<string name="poi_filter_for_tourists">For tourists</string>
<string name="poi_filter_fuel">Fuel</string>
<string name="show_warnings_title">Show alerts…</string>
<string name="show_warnings_descr">Configure traffic warnings (speed limits, forced stops, speed bumps), speed camera warnings, and lane information.</string>
<string name="show_warnings_descr">Configure traffic warnings (speed limits, forced stops, speed bumps, tunnels), speed camera warnings, and lane information.</string>
<string name="use_compass_navigation_descr">Use the compass when no heading is detected otherwise.</string>
<string name="use_compass_navigation">Use compass</string>
<string name="avoid_motorway">Avoid motorways</string>
@ -2867,4 +2874,6 @@
<string name="nautical_renderer">Nautical</string>
<string name="copy_location_name">Copy Point/POI name</string>
<string name="toast_empty_name_error">Location has no name</string>
<string name="tunnel_warning">Tunnel ahead</string>
<string name="show_tunnels">Tunnels</string>
</resources>

View file

@ -365,7 +365,8 @@ public class GpxSelectionHelper {
}
public SelectedGpxFile getSelectedFileByPath(String path) {
for (SelectedGpxFile s : selectedGPXFiles) {
List<SelectedGpxFile> newList = new ArrayList<>(selectedGPXFiles);
for (SelectedGpxFile s : newList) {
if (s.getGpxFile().path.equals(path)) {
return s;
}

View file

@ -36,7 +36,7 @@ public class LockableScrollView extends ScrollView {
return super.onTouchEvent(ev);
}
// only continue to handle the touch event if scrolling enabled
return mScrollable;
return false;
default:
return super.onTouchEvent(ev);
}

View file

@ -118,6 +118,15 @@ public class OsmAndFormatter {
return fixed2.format(((float) meters) / mainUnitInMeters) + " " + ctx.getString(mainUnitStr);
}
}
public static String getFormattedAlarmInfoDistance(OsmandApplication app, float meters) {
boolean kmAndMeters = app.getSettings().METRIC_SYSTEM.get() == MetricsConstants.KILOMETERS_AND_METERS;
int mainUnitStr = kmAndMeters ? R.string.km : R.string.mile;
float mainUnitInMeters = kmAndMeters ? METERS_IN_KILOMETER : METERS_IN_ONE_MILE;
DecimalFormat df = new DecimalFormat("#.#");
return df.format(meters / mainUnitInMeters) + " " + app.getString(mainUnitStr);
}
public static String getFormattedDistance(float meters, OsmandApplication ctx) {
return getFormattedDistance(meters, ctx, true);

View file

@ -1070,6 +1070,12 @@ public class OsmandSettings {
SHOW_PEDESTRIAN.setModeDefaultValue(ApplicationMode.CAR, true);
}
public final CommonPreference<Boolean> SHOW_TUNNELS = new BooleanPreference("show_tunnels", false).makeProfile().cache();
{
SHOW_TUNNELS.setModeDefaultValue(ApplicationMode.CAR, true);
}
public final OsmandPreference<Boolean> SHOW_CAMERAS = new BooleanPreference("show_cameras", false).makeProfile().cache();
public final CommonPreference<Boolean> SHOW_LANES = new BooleanPreference("show_lanes", false).makeProfile().cache();
@ -1155,6 +1161,8 @@ public class OsmandSettings {
// this value string is synchronized with settings_pref.xml preference name
public final OsmandPreference<Boolean> SHOW_OSM_BUGS = new BooleanPreference("show_osm_bugs", false).makeGlobal();
public final CommonPreference<Boolean> SHOW_CLOSED_OSM_BUGS = new BooleanPreference("show_closed_osm_bugs", false).makeGlobal();
public final CommonPreference<Integer> SHOW_OSM_BUGS_MIN_ZOOM = new IntPreference("show_osm_bugs_min_zoom", 8).makeGlobal();
public final CommonPreference<String> MAP_INFO_CONTROLS = new StringPreference("map_info_controls", "").makeProfile();
{

View file

@ -1660,41 +1660,43 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull final int[] grantResults) {
OsmandPlugin.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (grantResults.length > 0) {
OsmandPlugin.onRequestPermissionsResult(requestCode, permissions, grantResults);
MapControlsLayer mcl = mapView.getLayerByClass(MapControlsLayer.class);
if (mcl != null) {
mcl.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
MapControlsLayer mcl = mapView.getLayerByClass(MapControlsLayer.class);
if (mcl != null) {
mcl.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
if (requestCode == DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE
&& grantResults.length > 0 && permissions.length > 0
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
permissionAsked = true;
permissionGranted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
} else if (requestCode == FirstUsageWizardFragment.FIRST_USAGE_REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION
&& grantResults.length > 0 && permissions.length > 0
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
if (requestCode == DownloadActivity.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE
&& grantResults.length > 0 && permissions.length > 0
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
permissionAsked = true;
permissionGranted = grantResults[0] == PackageManager.PERMISSION_GRANTED;
} else if (requestCode == FirstUsageWizardFragment.FIRST_USAGE_REQUEST_WRITE_EXTERNAL_STORAGE_PERMISSION
&& grantResults.length > 0 && permissions.length > 0
&& Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[0])) {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
FirstUsageWizardFragment wizardFragment = getFirstUsageWizardFragment();
if (wizardFragment != null) {
wizardFragment.processStoragePermission(grantResults[0] == PackageManager.PERMISSION_GRANTED);
new Timer().schedule(new TimerTask() {
@Override
public void run() {
FirstUsageWizardFragment wizardFragment = getFirstUsageWizardFragment();
if (wizardFragment != null) {
wizardFragment.processStoragePermission(grantResults[0] == PackageManager.PERMISSION_GRANTED);
}
}
}
}, 1);
} else if (requestCode == FirstUsageWizardFragment.FIRST_USAGE_LOCATION_PERMISSION) {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
FirstUsageWizardFragment wizardFragment = getFirstUsageWizardFragment();
if (wizardFragment != null) {
wizardFragment.processLocationPermission(grantResults[0] == PackageManager.PERMISSION_GRANTED);
}, 1);
} else if (requestCode == FirstUsageWizardFragment.FIRST_USAGE_LOCATION_PERMISSION) {
new Timer().schedule(new TimerTask() {
@Override
public void run() {
FirstUsageWizardFragment wizardFragment = getFirstUsageWizardFragment();
if (wizardFragment != null) {
wizardFragment.processLocationPermission(grantResults[0] == PackageManager.PERMISSION_GRANTED);
}
}
}
}, 1);
}, 1);
}
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);

View file

@ -630,8 +630,8 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
return true;
} else if (preference == showAlarms) {
showBooleanSettings(new String[] { getString(R.string.show_traffic_warnings), getString(R.string.show_pedestrian_warnings),
getString(R.string.show_cameras), getString(R.string.show_lanes) }, new OsmandPreference[] { settings.SHOW_TRAFFIC_WARNINGS,
settings.SHOW_PEDESTRIAN, settings.SHOW_CAMERAS, settings.SHOW_LANES }, preference.getTitle());
getString(R.string.show_cameras), getString(R.string.show_lanes), getString(R.string.show_tunnels) }, new OsmandPreference[] { settings.SHOW_TRAFFIC_WARNINGS,
settings.SHOW_PEDESTRIAN, settings.SHOW_CAMERAS, settings.SHOW_LANES, settings.SHOW_TUNNELS }, preference.getTitle());
return true;
} else if (preference == speakAlarms) {
AlertDialog dlg = showBooleanSettings(new String[] { getString(R.string.speak_street_names),

View file

@ -90,7 +90,6 @@ public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity
private static final Log log = PlatformUtil.getLog(SearchByNameAbstractActivity.class);
private static final int NAVIGATE_TO = 3;
private static final int ADD_WAYPOINT = 4;
private static final int SHOW_ON_MAP = 5;
private static final int ADD_TO_FAVORITE = 6;
@ -571,9 +570,6 @@ public abstract class SearchByNameAbstractActivity<T> extends OsmandListActivity
} else if (mode == NAVIGATE_TO) {
DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), searchPoint.getLatitude(),
searchPoint.getLongitude(), ai.getHistoryName());
} else if (mode == ADD_WAYPOINT) {
DirectionsDialogs.addWaypointDialogAndLaunchMap(getActivity(), searchPoint.getLatitude(),
searchPoint.getLongitude(), ai.getHistoryName());
} else if (mode == SHOW_ON_MAP) {
showOnMap(searchPoint, ai);
}

View file

@ -80,14 +80,12 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
}
if (AndroidUiHelper.isOrientationPortrait(activity)) {
AndroidUtils.setBackground(activity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
mainView.setBackgroundResource(getPortraitBgResId());
} else {
if (screenHeight - statusBarHeight - mainView.getHeight() >= getResources().getDimension(R.dimen.bottom_sheet_content_padding_small)) {
AndroidUtils.setBackground(activity, mainView, nightMode,
R.drawable.bg_bottom_sheet_topsides_landscape_light, R.drawable.bg_bottom_sheet_topsides_landscape_dark);
mainView.setBackgroundResource(getLandscapeTopsidesBgResId());
} else {
AndroidUtils.setBackground(activity, mainView, nightMode,
R.drawable.bg_bottom_sheet_sides_landscape_light, R.drawable.bg_bottom_sheet_sides_landscape_dark);
mainView.setBackgroundResource(getLandscapeSidesBgResId());
}
}
@ -101,6 +99,21 @@ public abstract class MenuBottomSheetDialogFragment extends BottomSheetDialogFra
});
}
@DrawableRes
protected int getPortraitBgResId() {
return nightMode ? R.drawable.bg_bottom_menu_dark : R.drawable.bg_bottom_menu_light;
}
@DrawableRes
protected int getLandscapeTopsidesBgResId() {
return nightMode ? R.drawable.bg_bottom_sheet_topsides_landscape_dark : R.drawable.bg_bottom_sheet_topsides_landscape_light;
}
@DrawableRes
protected int getLandscapeSidesBgResId() {
return nightMode ? R.drawable.bg_bottom_sheet_sides_landscape_dark : R.drawable.bg_bottom_sheet_sides_landscape_light;
}
protected boolean isNightMode() {
if (usedOnMap) {
return getMyApplication().getDaynightHelper().isNightModeForMapControls();

View file

@ -76,6 +76,7 @@ import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu;
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu.LocalRoutingParameter;
import net.osmand.plus.mapillary.MapillaryFiltersFragment;
import net.osmand.plus.mapillary.MapillaryPlugin.MapillaryFirstDialogFragment;
import net.osmand.plus.osmedit.OsmNotesMenu;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
@ -189,7 +190,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
UNDERLAY_MAP,
MAPILLARY,
CONTOUR_LINES,
HILLSHADE
HILLSHADE,
OSM_NOTES
}
private Map<DashboardActionButtonType, DashboardActionButton> actionButtons = new HashMap<>();
@ -428,6 +430,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
tv.setText(R.string.srtm_plugin_name);
} else if (visibleType == DashboardType.HILLSHADE) {
tv.setText(R.string.layer_hillshade);
} else if (visibleType == DashboardType.OSM_NOTES) {
tv.setText(R.string.osm_notes);
}
ImageView edit = (ImageView) dashboardView.findViewById(R.id.toolbar_edit);
edit.setVisibility(View.GONE);
@ -822,7 +826,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
&& visibleType != DashboardType.CONFIGURE_SCREEN
&& visibleType != DashboardType.CONFIGURE_MAP
&& visibleType != DashboardType.CONTOUR_LINES
&& visibleType != DashboardType.HILLSHADE) {
&& visibleType != DashboardType.HILLSHADE
&& visibleType != DashboardType.OSM_NOTES) {
listView.setDivider(dividerDrawable);
listView.setDividerHeight(dpToPx(1f));
} else {
@ -879,6 +884,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
cm = ContourLinesMenu.createListAdapter(mapActivity);
} else if (visibleType == DashboardType.HILLSHADE) {
cm = HillshadeMenu.createListAdapter(mapActivity);
} else if (visibleType == DashboardType.OSM_NOTES) {
cm = OsmNotesMenu.createListAdapter(mapActivity);
}
if (cm != null) {
updateListAdapter(cm);

View file

@ -0,0 +1,171 @@
package net.osmand.plus.dialogs;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
public class AddWaypointBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
public static final String TAG = "AddWaypointBottomSheetDialogFragment";
public static final String LAT_KEY = "latitude";
public static final String LON_KEY = "longitude";
public static final String POINT_DESCRIPTION_KEY = "point_description";
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Bundle args = getArguments();
final LatLon latLon = new LatLon(args.getDouble(LAT_KEY), args.getDouble(LON_KEY));
final PointDescription name = PointDescription.deserializeFromString(args.getString(POINT_DESCRIPTION_KEY), latLon);
final TargetPointsHelper targetPointsHelper = getMyApplication().getTargetPointsHelper();
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
R.layout.fragment_add_waypoint_bottom_sheet_dialog, container);
((TextView) mainView.findViewById(R.id.current_dest_text_view))
.setText(getCurrentPointName(targetPointsHelper.getPointToNavigate(), false));
((TextView) mainView.findViewById(R.id.current_start_text_view))
.setText(getCurrentPointName(targetPointsHelper.getPointToStart(), true));
((ImageView) mainView.findViewById(R.id.subsequent_dest_icon)).setImageDrawable(getSubsequentDestIcon());
((ImageView) mainView.findViewById(R.id.first_interm_dest_icon)).setImageDrawable(getFirstIntermDestIcon());
((ImageView) mainView.findViewById(R.id.last_interm_dest_icon)).setImageDrawable(getLastIntermDistIcon());
View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
int id = v.getId();
if (id == R.id.replace_dest_row) {
targetPointsHelper.navigateToPoint(latLon, true, -1, name);
} else if (id == R.id.replace_start_row) {
TargetPoint start = targetPointsHelper.getPointToStart();
if (start != null) {
targetPointsHelper.navigateToPoint(new LatLon(start.getLatitude(), start.getLongitude()),
false, 0, start.getOriginalPointDescription());
}
targetPointsHelper.setStartPoint(latLon, true, name);
} else if (id == R.id.subsequent_dest_row) {
targetPointsHelper.navigateToPoint(latLon, true,
targetPointsHelper.getIntermediatePoints().size() + 1, name);
} else if (id == R.id.first_intermediate_dest_row) {
targetPointsHelper.navigateToPoint(latLon, true, 0, name);
} else if (id == R.id.last_intermediate_dest_row) {
targetPointsHelper.navigateToPoint(latLon, true, targetPointsHelper.getIntermediatePoints().size(), name);
}
dismiss();
}
};
mainView.findViewById(R.id.replace_dest_row).setOnClickListener(onClickListener);
mainView.findViewById(R.id.replace_start_row).setOnClickListener(onClickListener);
mainView.findViewById(R.id.subsequent_dest_row).setOnClickListener(onClickListener);
mainView.findViewById(R.id.first_intermediate_dest_row).setOnClickListener(onClickListener);
mainView.findViewById(R.id.last_intermediate_dest_row).setOnClickListener(onClickListener);
mainView.findViewById(R.id.cancel_row).setOnClickListener(onClickListener);
if (nightMode) {
int dividerColor = ContextCompat.getColor(getContext(), R.color.route_info_bottom_view_bg_dark);
mainView.findViewById(R.id.current_dest_divider).setBackgroundColor(dividerColor);
mainView.findViewById(R.id.cancel_divider).setBackgroundColor(dividerColor);
}
setupHeightAndBackground(mainView, R.id.scroll_view);
return mainView;
}
@Override
public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog);
closeContextMenu();
}
@Override
protected Drawable getActiveIcon(@DrawableRes int id) {
return getIcon(id, nightMode ? R.color.ctx_menu_direction_color_dark : R.color.map_widget_blue);
}
@Override
protected int getPortraitBgResId() {
return nightMode ? R.drawable.bg_additional_menu_dark : R.drawable.bg_bottom_menu_light;
}
@Override
protected int getLandscapeTopsidesBgResId() {
return nightMode ? R.drawable.bg_additional_menu_topsides_dark : R.drawable.bg_bottom_sheet_topsides_landscape_light;
}
@Override
protected int getLandscapeSidesBgResId() {
return nightMode ? R.drawable.bg_additional_menu_sides_dark : R.drawable.bg_bottom_sheet_sides_landscape_light;
}
private Drawable getBackgroundIcon(@DrawableRes int resId) {
return getIcon(resId, R.color.searchbar_text_hint_light);
}
private LayerDrawable getLayerDrawable(@DrawableRes int bgIdRes, @DrawableRes int icIdRes) {
return new LayerDrawable(new Drawable[]{getBackgroundIcon(bgIdRes), getActiveIcon(icIdRes)});
}
private LayerDrawable getSubsequentDestIcon() {
return getLayerDrawable(R.drawable.ic_action_route_subsequent_destination,
R.drawable.ic_action_route_subsequent_destination_point);
}
private LayerDrawable getFirstIntermDestIcon() {
return getLayerDrawable(R.drawable.ic_action_route_first_intermediate,
R.drawable.ic_action_route_first_intermediate_point);
}
private LayerDrawable getLastIntermDistIcon() {
return getLayerDrawable(R.drawable.ic_action_route_last_intermediate,
R.drawable.ic_action_route_last_intermediate_point);
}
private String getCurrentPointName(@Nullable TargetPoint point, boolean start) {
Context ctx = getContext();
StringBuilder builder = new StringBuilder(ctx.getString(R.string.shared_string_current));
builder.append(": ");
if (point != null) {
if (point.getOnlyName().length() > 0) {
builder.append(point.getOnlyName());
} else {
builder.append(ctx.getString(R.string.route_descr_map_location));
builder.append(" ");
builder.append(ctx.getString(R.string.route_descr_lat_lon, point.getLatitude(), point.getLongitude()));
}
} else if (start) {
builder.append(ctx.getString(R.string.shared_string_my_location));
}
return builder.toString();
}
private void closeContextMenu() {
Activity activity = getActivity();
if (activity instanceof MapActivity) {
((MapActivity) activity).getContextMenu().close();
}
}
}

View file

@ -42,15 +42,12 @@ import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers;
import net.osmand.plus.activities.PluginActivity;
import net.osmand.plus.activities.SettingsActivity;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
import net.osmand.plus.poi.PoiFiltersHelper;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.plus.srtmplugin.SRTMPlugin;
import net.osmand.plus.views.GPXLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.RouteLayer;
import net.osmand.plus.views.corenative.NativeCoreContext;
import net.osmand.render.RenderingRule;
import net.osmand.render.RenderingRuleProperty;
@ -62,7 +59,6 @@ import org.apache.commons.logging.Log;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@ -503,29 +499,33 @@ public class ConfigureMapMenu {
AlertDialog.Builder bld = new AlertDialog.Builder(activity);
bld.setTitle(R.string.renderers);
final OsmandApplication app = activity.getMyApplication();
Collection<String> rendererNames = app.getRendererRegistry().getRendererNames();
final String[] items = rendererNames.toArray(new String[rendererNames.size()]);
final ArrayList<String> items = new ArrayList<>(app.getRendererRegistry().getRendererNames());
boolean nauticalPluginDisabled = OsmandPlugin.getEnabledPlugin(NauticalMapsPlugin.class) == null;
final List<String> visibleNamesList = new ArrayList<>();
int selected = -1;
final String selectedName = app.getRendererRegistry().getCurrentSelectedRenderer().getName();
int i = 0;
for (String item : items) {
Iterator<String> iterator = items.iterator();
while (iterator.hasNext()) {
String item = iterator.next();
if (nauticalPluginDisabled && item.equals(RendererRegistry.NAUTICAL_RENDER)) {
continue;
iterator.remove();
} else {
if (item.equals(selectedName)) {
selected = i;
}
String translation = RendererRegistry.getTranslatedRendererName(activity, item);
visibleNamesList.add(translation != null ? translation
: item.replace('_', ' ').replace('-', ' '));
i++;
}
if (item.equals(selectedName)) {
selected = i;
}
visibleNamesList.add(item.replace('_', ' ').replace('-', ' '));
i++;
}
bld.setSingleChoiceItems(visibleNamesList.toArray(new String[visibleNamesList.size()]), selected, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String renderer = visibleNamesList.get(which);
String renderer = items.get(which);
RenderingRulesStorage loaded = app.getRendererRegistry().getRenderer(renderer);
if (loaded != null) {
OsmandMapTileView view = activity.getMapView();
@ -1135,7 +1135,8 @@ public class ConfigureMapMenu {
if (storage == null) {
return "";
}
return storage.getName();
String translation = RendererRegistry.getTranslatedRendererName(activity, storage.getName());
return translation == null ? storage.getName() : translation;
}
protected String getDayNightDescr(final MapActivity activity) {

View file

@ -2,7 +2,9 @@ package net.osmand.plus.dialogs;
import android.app.Activity;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.PopupMenu;
import net.osmand.data.LatLon;
@ -45,38 +47,17 @@ public class DirectionsDialogs {
MapActivity.launchMapActivityMoveToTop(act);
}
}
public static void addWaypointDialogAndLaunchMap(final Activity act, final double lat, final double lon, final PointDescription name) {
final OsmandApplication ctx = (OsmandApplication) act.getApplication();
final TargetPointsHelper targetPointsHelper = ctx.getTargetPointsHelper();
public static void addWaypointDialogAndLaunchMap(final AppCompatActivity act, final double lat, final double lon, final PointDescription name) {
final TargetPointsHelper targetPointsHelper = ((OsmandApplication) act.getApplication()).getTargetPointsHelper();
if (targetPointsHelper.getPointToNavigate() != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(act);
builder.setTitle(R.string.new_destination_point_dialog);
builder.setItems(
new String[] { act.getString(R.string.replace_destination_point),
act.getString(R.string.keep_and_add_destination_point),
act.getString(R.string.add_as_first_destination_point), act.getString(R.string.add_as_last_destination_point) },
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, -1, name);
closeContextMenu(act);
} else if (which == 1) {
targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true,
targetPointsHelper.getIntermediatePoints().size() + 1, name);
closeContextMenu(act);
} else if (which == 2) {
targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, 0, name);
closeContextMenu(act);
} else {
targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, targetPointsHelper.getIntermediatePoints().size(), name);
closeContextMenu(act);
}
MapActivity.launchMapActivityMoveToTop(act);
}
});
builder.show();
Bundle args = new Bundle();
args.putDouble(AddWaypointBottomSheetDialogFragment.LAT_KEY, lat);
args.putDouble(AddWaypointBottomSheetDialogFragment.LON_KEY, lon);
args.putString(AddWaypointBottomSheetDialogFragment.POINT_DESCRIPTION_KEY, PointDescription.serializeToString(name));
AddWaypointBottomSheetDialogFragment fragment = new AddWaypointBottomSheetDialogFragment();
fragment.setArguments(args);
fragment.show(act.getSupportFragmentManager(), AddWaypointBottomSheetDialogFragment.TAG);
} else {
targetPointsHelper.navigateToPoint(new LatLon(lat, lon), true, -1, name);
closeContextMenu(act);

View file

@ -268,6 +268,8 @@ public class DataStoragePlaceDialogFragment extends BottomSheetDialogFragment {
Bundle args = new Bundle();
args.putBoolean(STORAGE_READOLNY_KEY, storageReadOnly);
f.setArguments(args);
f.show(fragmentManager, DataStoragePlaceDialogFragment.TAG);
fragmentManager.beginTransaction()
.add(f, DataStoragePlaceDialogFragment.TAG)
.commitAllowingStateLoss();
}
}

View file

@ -178,6 +178,7 @@ public class WaypointHelper {
}
AlarmInfo mostImportant = speedAlarm;
int value = speedAlarm != null ? speedAlarm.updateDistanceAndGetPriority(0, 0) : Integer.MAX_VALUE;
float speed = lastProjection != null && lastProjection.hasSpeed() ? lastProjection.getSpeed() : 0;
if (ALARMS < pointsProgress.size()) {
int kIterator = pointsProgress.get(ALARMS);
List<LocationPointWrapper> lp = locationPoints.get(ALARMS);
@ -191,7 +192,6 @@ public class WaypointHelper {
break;
}
AlarmInfo inf = (AlarmInfo) lwp.point;
float speed = lastProjection != null && lastProjection.hasSpeed() ? lastProjection.getSpeed() : 0;
float time = speed > 0 ? d / speed : Integer.MAX_VALUE;
int vl = inf.updateDistanceAndGetPriority(time, d);
if (vl < value && (showCameras || inf.getType() != AlarmInfoType.SPEED_CAMERA)) {
@ -704,32 +704,39 @@ public class WaypointHelper {
} else if (type == ALARMS) {
//assign alarm list icons manually for now
if (((AlarmInfo) point).getType().toString().equals("SPEED_CAMERA")) {
String typeString = ((AlarmInfo) point).getType().toString();
if (typeString.equals("SPEED_CAMERA")) {
return uiCtx.getResources().getDrawable(R.drawable.mx_highway_speed_camera);
} else if (((AlarmInfo) point).getType().toString().equals("BORDER_CONTROL")) {
} else if (typeString.equals("BORDER_CONTROL")) {
return uiCtx.getResources().getDrawable(R.drawable.mx_barrier_border_control);
} else if (((AlarmInfo) point).getType().toString().equals("RAILWAY")) {
} else if (typeString.equals("RAILWAY")) {
if (app.getSettings().DRIVING_REGION.get().americanSigns) {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways_us);
} else {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways);
}
} else if (((AlarmInfo) point).getType().toString().equals("TRAFFIC_CALMING")) {
} else if (typeString.equals("TRAFFIC_CALMING")) {
if (app.getSettings().DRIVING_REGION.get().americanSigns) {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_traffic_calming_us);
} else {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_traffic_calming);
}
} else if (((AlarmInfo) point).getType().toString().equals("TOLL_BOOTH")) {
} else if (typeString.equals("TOLL_BOOTH")) {
return uiCtx.getResources().getDrawable(R.drawable.mx_toll_booth);
} else if (((AlarmInfo) point).getType().toString().equals("STOP")) {
} else if (typeString.equals("STOP")) {
return uiCtx.getResources().getDrawable(R.drawable.list_stop);
} else if (((AlarmInfo) point).getType().toString().equals("PEDESTRIAN")) {
} else if (typeString.equals("PEDESTRIAN")) {
if (app.getSettings().DRIVING_REGION.get().americanSigns) {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian_us);
} else {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian);
}
} else if (typeString.equals("TUNNEL")) {
if (app.getSettings().DRIVING_REGION.get().americanSigns) {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_tunnel_us);
} else {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_tunnel);
}
} else {
return null;
}

View file

@ -665,6 +665,11 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
}
}
public boolean hasActiveToolbar() {
TopToolbarController toolbarController = mapActivity.getTopToolbarController(TopToolbarControllerType.CONTEXT_MENU);
return toolbarController != null && toolbarController instanceof ContextMenuToolbarController;
}
public void closeActiveToolbar() {
TopToolbarController toolbarController = mapActivity.getTopToolbarController(TopToolbarControllerType.CONTEXT_MENU);
if (toolbarController != null && toolbarController instanceof ContextMenuToolbarController) {
@ -1069,7 +1074,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
if (menuController != null) {
return menuController.getHalfScreenMaxHeightKoef();
} else {
return 0f;
return .75f;
}
}
@ -1177,7 +1182,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
public int getAdditionalInfoColor() {
if (menuController != null) {
return menuController.getAdditionalInfoColor();
return menuController.getAdditionalInfoColorId();
}
return 0;
}

View file

@ -20,6 +20,7 @@ import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.View.OnLayoutChangeListener;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewTreeObserver;
@ -29,6 +30,7 @@ import android.widget.GridView;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.OverScroller;
import android.widget.ProgressBar;
import android.widget.TextView;
@ -66,16 +68,23 @@ import static net.osmand.plus.mapcontextmenu.MenuBuilder.SHADOW_HEIGHT_TOP_DP;
public class MapContextMenuFragment extends BaseOsmAndFragment implements DownloadEvents {
public static final String TAG = "MapContextMenuFragment";
public static final float FAB_PADDING_TOP_DP = 4f;
public static final float ZOOM_PADDING_TOP_DP = 4f;
public static final float MARKER_PADDING_DP = 20f;
public static final float MARKER_PADDING_X_DP = 50f;
public static final float SKIP_HALF_SCREEN_STATE_KOEF = .21f;
public static final int ZOOM_IN_STANDARD = 17;
public static final int CURRENT_Y_UNDEFINED = Integer.MAX_VALUE;
private View view;
private InterceptorLinearLayout mainView;
private View toolbarContainer;
private View toolbarView;
private View toolbarBackButton;
private TextView toolbarTextView;
private View topButtonContainer;
private LockableScrollView menuScrollView;
private View zoomButtonsView;
private ImageButton zoomInButtonView;
private ImageButton zoomOutButtonView;
@ -87,6 +96,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private int menuTopShadowAllHeight;
private int menuTitleHeight;
private int menuBottomViewHeight;
private int menuButtonsHeight;
private int menuFullHeight;
private int menuFullHeightMax;
private int menuTopViewHeightExcludingTitle;
@ -99,6 +109,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private int markerPaddingPx;
private int markerPaddingXPx;
private int topScreenPosY;
private int bottomToolbarPosY;
private int minHalfY;
private int shadowHeight;
private int zoomPaddingTop;
private OsmandMapTileView map;
private LatLon mapCenter;
@ -113,8 +127,6 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private boolean wasDrawerDisabled;
private boolean zoomIn;
private float skipScreenStateLimit;
private int screenOrientation;
private boolean created;
@ -124,18 +136,46 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
processScreenHeight(container);
menu = getMapActivity().getContextMenu();
markerPaddingPx = dpToPx(MARKER_PADDING_DP);
markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP);
topScreenPosY = addStatusBarHeightIfNeeded(-dpToPx(SHADOW_HEIGHT_TOP_DP));
shadowHeight = dpToPx(SHADOW_HEIGHT_TOP_DP);
topScreenPosY = addStatusBarHeightIfNeeded(-shadowHeight);
bottomToolbarPosY = addStatusBarHeightIfNeeded(getResources().getDimensionPixelSize(R.dimen.dashboard_map_toolbar));
minHalfY = viewHeight - (int) (viewHeight * menu.getHalfScreenMaxHeightKoef());
zoomPaddingTop = dpToPx(ZOOM_PADDING_TOP_DP);
menu = getMapActivity().getContextMenu();
view = inflater.inflate(R.layout.map_context_menu_fragment, container, false);
if (!menu.isActive()) {
return view;
}
AndroidUtils.addStatusBarPadding21v(getMapActivity(), view);
nightMode = menu.isNightMode();
mainView = view.findViewById(R.id.context_menu_main);
toolbarContainer = view.findViewById(R.id.context_menu_toolbar_container);
toolbarView = view.findViewById(R.id.context_menu_toolbar);
toolbarBackButton = view.findViewById(R.id.context_menu_toolbar_back);
toolbarTextView = (TextView) view.findViewById(R.id.context_menu_toolbar_text);
updateVisibility(toolbarContainer, 0);
toolbarBackButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openMenuHeaderOnly();
}
});
topButtonContainer = view.findViewById(R.id.context_menu_top_button_container);
view.findViewById(R.id.context_menu_top_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openMenuHeaderOnly();
}
});
updateVisibility(topButtonContainer, 0);
map = getMapActivity().getMapView();
RotatedTileBox box = map.getCurrentRotatedTileBox().copy();
customMapCenter = menu.getMapCenter() != null;
@ -252,30 +292,41 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private float dy;
private float dyMain;
private float mDownY;
private VelocityTracker velocity;
private int minimumVelocity;
private int maximumVelocity;
private VelocityTracker velocityTracker;
private OverScroller scroller;
private boolean slidingUp;
private boolean slidingDown;
private float velocityY;
private float maxVelocityY;
private boolean hasMoved;
{
scroller = new OverScroller(getContext());
final ViewConfiguration configuration = ViewConfiguration.get(getContext());
minimumVelocity = configuration.getScaledMinimumFlingVelocity();
maximumVelocity = configuration.getScaledMaximumFlingVelocity();
}
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getY() <= menuTopViewHeight) {
if (!hasMoved && event.getY() <= menuTopViewHeight) {
if (singleTapDetector.onTouchEvent(event)) {
moving = false;
if (hasMoved) {
applyPosY(getViewY(), false, false, 0, 0, 0);
}
openMenuHalfScreen();
recycleVelocityTracker();
return true;
}
}
if (menu.isLandscapeLayout()) {
if (swipeDetector.onTouchEvent(event)) {
menu.close();
recycleVelocityTracker();
return true;
}
}
@ -286,10 +337,9 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
mDownY = event.getRawY();
dy = event.getY();
dyMain = getViewY();
velocity = VelocityTracker.obtain();
velocityY = 0;
maxVelocityY = 0;
velocity.addMovement(event);
initOrResetVelocityTracker();
velocityTracker.addMovement(event);
break;
case MotionEvent.ACTION_MOVE:
@ -300,8 +350,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
hasMoved = true;
float y = event.getY();
float newY = getViewY() + (y - dy);
if (menu.isLandscapeLayout() && newY > 0) {
newY = 0;
if (menu.isLandscapeLayout() && newY > topScreenPosY) {
newY = topScreenPosY;
}
setViewY((int) newY, false, false);
@ -311,39 +361,82 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
mainView.setLayoutParams(lp);
mainView.requestLayout();
if (velocity != null) {
velocity.addMovement(event);
velocity.computeCurrentVelocity(1000);
velocityY = Math.abs(velocity.getYVelocity());
if (velocityY > maxVelocityY) {
maxVelocityY = velocityY;
}
}
float newEventY = newY - (dyMain - dy);
MotionEvent ev = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), event.getAction(),
event.getX(), newEventY, event.getMetaState());
initVelocityTrackerIfNotExists();
velocityTracker.addMovement(ev);
updateToolbar();
updateTopButton();
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
if (moving) {
moving = false;
hasMoved = false;
int currentY = getViewY();
slidingUp = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) < -50;
slidingDown = Math.abs(maxVelocityY) > 500 && (currentY - dyMain) > 50;
final VelocityTracker velocityTracker = this.velocityTracker;
velocityTracker.computeCurrentVelocity(1000, maximumVelocity);
int initialVelocity = (int) velocityTracker.getYVelocity();
if (velocity != null) {
velocity.recycle();
if ((Math.abs(initialVelocity) > minimumVelocity)) {
scroller.abortAnimation();
scroller.fling(0, currentY, 0, initialVelocity, 0, 0,
Math.min(viewHeight - menuFullHeightMax, getFullScreenTopPosY()),
screenHeight,
0, 0);
currentY = scroller.getFinalY();
scroller.abortAnimation();
slidingUp = initialVelocity < -2000;
slidingDown = initialVelocity > 2000;
} else {
slidingUp = false;
slidingDown = false;
}
boolean skipScreenState = Math.abs(currentY - dyMain) > skipScreenStateLimit;
changeMenuState(currentY, skipScreenState, slidingUp, slidingDown);
changeMenuState(currentY, slidingUp, slidingDown);
}
recycleVelocityTracker();
break;
case MotionEvent.ACTION_CANCEL:
moving = false;
hasMoved = false;
recycleVelocityTracker();
break;
}
return true;
}
private void initOrResetVelocityTracker() {
if (velocityTracker == null) {
velocityTracker = VelocityTracker.obtain();
} else {
velocityTracker.clear();
}
}
private void initVelocityTrackerIfNotExists() {
if (velocityTracker == null) {
velocityTracker = VelocityTracker.obtain();
velocityTracker.clear();
}
}
private void recycleVelocityTracker() {
if (velocityTracker != null) {
velocityTracker.recycle();
velocityTracker = null;
}
}
};
View topShadowAllView = view.findViewById(R.id.context_menu_top_shadow_all);
@ -541,6 +634,65 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
return view;
}
private float getToolbarAlpha(int y) {
float a = 0;
if (menu != null && !menu.isLandscapeLayout()) {
if (y < bottomToolbarPosY) {
a = 1f - (y - topScreenPosY) * (1f / (bottomToolbarPosY - topScreenPosY));
}
if (a < 0) {
a = 0;
} else if (a > 1) {
a = 1;
}
}
return a;
}
private void updateToolbar() {
float a = getToolbarAlpha(getViewY());
updateVisibility(toolbarContainer, a);
}
private float getTopButtonAlpha(int y) {
float a = 0;
if (menu != null && !menu.isLandscapeLayout() && !menu.hasActiveToolbar()) {
int headerTopY = getHeaderOnlyTopY();
if (y < headerTopY) {
a = 1f - (y - minHalfY) * (1f / (headerTopY - minHalfY));
}
if (a < 0) {
a = 0;
} else if (a > 1) {
a = 1;
}
}
return a;
}
private void updateTopButton() {
float a = getTopButtonAlpha(getViewY());
updateVisibility(topButtonContainer, a);
}
private void updateVisibility(View v, float alpha) {
boolean visible = alpha > 0;
v.setAlpha(alpha);
if (visible && v.getVisibility() != View.VISIBLE) {
v.setVisibility(View.VISIBLE);
} else if (!visible && v.getVisibility() == View.VISIBLE) {
v.setVisibility(View.INVISIBLE);
}
}
private void updateVisibility(View v, boolean visible) {
if (visible && v.getVisibility() != View.VISIBLE) {
v.setVisibility(View.VISIBLE);
} else if (!visible && v.getVisibility() == View.VISIBLE) {
v.setVisibility(View.INVISIBLE);
}
}
private void toggleDetailsHideButton() {
int menuState = menu.getCurrentMenuState();
final boolean showShowHideButton = menuState == MenuState.HALF_SCREEN || (!menu.isLandscapeLayout() && menuState == MenuState.FULL_SCREEN);
@ -582,61 +734,92 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
}
private void processScreenHeight(ViewParent parent) {
View container = (View)parent;
View container = (View) parent;
screenHeight = container.getHeight() + AndroidUtils.getStatusBarHeight(getActivity());
skipScreenStateLimit = screenHeight * SKIP_HALF_SCREEN_STATE_KOEF;
viewHeight = screenHeight - AndroidUtils.getStatusBarHeight(getMapActivity());
}
public void openMenuFullScreen() {
changeMenuState(getViewY(), true, true, false);
changeMenuState(getMenuStatePosY(MenuState.FULL_SCREEN), false, false);
}
public void openMenuHeaderOnly() {
changeMenuState(getViewY(), true, false, true);
}
public void openMenuHalfScreen() {
int oldMenuState = menu.getCurrentMenuState();
if (oldMenuState == MenuState.HEADER_ONLY) {
changeMenuState(getViewY(), false, true, false);
} else if (oldMenuState == MenuState.FULL_SCREEN && !menu.isLandscapeLayout()) {
changeMenuState(getViewY(), false, false, true);
if (!menu.isLandscapeLayout()) {
changeMenuState(getMenuStatePosY(MenuState.HEADER_ONLY), false, false);
}
}
private void changeMenuState(int currentY, boolean skipScreenState,
boolean slidingUp, boolean slidingDown) {
public void openMenuHalfScreen() {
if (!menu.isLandscapeLayout()) {
changeMenuState(getMenuStatePosY(MenuState.HALF_SCREEN), false, false);
}
}
private void changeMenuState(int currentY, boolean slidingUp, boolean slidingDown) {
boolean needCloseMenu = false;
int oldMenuState = menu.getCurrentMenuState();
int currentMenuState = menu.getCurrentMenuState();
if (!menu.isLandscapeLayout()) {
if (slidingDown && !skipScreenState && oldMenuState == MenuState.FULL_SCREEN && currentY < topScreenPosY) {
int headerDist = Math.abs(currentY - getMenuStatePosY(MenuState.HEADER_ONLY));
int halfDist = Math.abs(currentY - getMenuStatePosY(MenuState.HALF_SCREEN));
int fullDist = Math.abs(currentY - getMenuStatePosY(MenuState.FULL_SCREEN));
int newState;
if (headerDist < halfDist && headerDist < fullDist) {
newState = MenuState.HEADER_ONLY;
} else if (halfDist < headerDist && halfDist < fullDist) {
newState = MenuState.HALF_SCREEN;
} else {
newState = MenuState.FULL_SCREEN;
}
if (slidingDown && currentMenuState == MenuState.FULL_SCREEN && getViewY() < getFullScreenTopPosY()) {
slidingDown = false;
newState = MenuState.FULL_SCREEN;
}
if (menuBottomViewHeight > 0 && slidingUp) {
menu.slideUp();
if (skipScreenState) {
menu.slideUp();
while (menu.getCurrentMenuState() != newState) {
if (!menu.slideUp()) {
break;
}
}
} else if (slidingDown) {
needCloseMenu = !menu.slideDown();
if (!needCloseMenu && skipScreenState) {
menu.slideDown();
if (currentMenuState == MenuState.HEADER_ONLY) {
needCloseMenu = true;
} else {
while (menu.getCurrentMenuState() != newState) {
if (!menu.slideDown()) {
needCloseMenu = true;
break;
}
}
}
} else {
if (currentMenuState < newState) {
while (menu.getCurrentMenuState() != newState) {
if (!menu.slideUp()) {
break;
}
}
} else {
while (menu.getCurrentMenuState() != newState) {
if (!menu.slideDown()) {
break;
}
}
}
}
}
int newMenuState = menu.getCurrentMenuState();
boolean needMapAdjust = oldMenuState != newMenuState && newMenuState != MenuState.FULL_SCREEN;
boolean needMapAdjust = currentMenuState != newMenuState && newMenuState != MenuState.FULL_SCREEN;
if (newMenuState != oldMenuState) {
if (newMenuState != currentMenuState) {
restoreCustomMapRatio();
menu.updateControlsVisibility(true);
doBeforeMenuStateChange(oldMenuState, newMenuState);
doBeforeMenuStateChange(currentMenuState, newMenuState);
toggleDetailsHideButton();
}
applyPosY(currentY, needCloseMenu, needMapAdjust, oldMenuState, newMenuState, 0);
applyPosY(currentY, needCloseMenu, needMapAdjust, currentMenuState, newMenuState, 0);
}
private void restoreCustomMapRatio() {
@ -676,12 +859,42 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private void applyPosY(final int currentY, final boolean needCloseMenu, boolean needMapAdjust,
final int previousMenuState, final int newMenuState, int dZoom) {
final int posY = getPosY(currentY, needCloseMenu);
if (currentY != posY || dZoom != 0) {
if (posY < currentY) {
final int posY = getPosY(currentY, needCloseMenu, previousMenuState);
if (getViewY() != posY || dZoom != 0) {
if (posY < getViewY()) {
updateMainViewLayout(posY);
}
final float topButtonAlpha = getTopButtonAlpha(posY);
if (topButtonAlpha > 0) {
updateVisibility(topButtonContainer, true);
}
topButtonContainer.animate().alpha(topButtonAlpha)
.setDuration(200)
.setInterpolator(new DecelerateInterpolator())
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
updateVisibility(topButtonContainer, topButtonAlpha);
}
})
.start();
final float toolbarAlpha = getToolbarAlpha(posY);
if (toolbarAlpha > 0) {
updateVisibility(toolbarContainer, true);
}
toolbarContainer.animate().alpha(toolbarAlpha)
.setDuration(200)
.setInterpolator(new DecelerateInterpolator())
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
updateVisibility(toolbarContainer, toolbarAlpha);
}
})
.start();
mainView.animate().y(posY)
.setDuration(200)
.setInterpolator(new DecelerateInterpolator())
@ -739,7 +952,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
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);
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);
@ -1083,6 +1296,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
menuTopShadowAllHeight = newMenuTopShadowAllHeight;
menuTitleHeight = menuTopShadowAllHeight + dy;
menuBottomViewHeight = view.findViewById(R.id.context_menu_bottom_view).getHeight();
menuButtonsHeight = view.findViewById(R.id.context_menu_bottom_buttons).getHeight() + view.findViewById(R.id.buttons_bottom_border).getHeight() + view.findViewById(R.id.context_menu_buttons).getHeight();
menuFullHeightMax = menuTitleHeight + menuBottomViewHeight;
@ -1163,6 +1377,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
// Text line 1
TextView line1 = (TextView) view.findViewById(R.id.context_menu_line1);
line1.setText(menu.getTitleStr());
toolbarTextView.setText(menu.getTitleStr());
// Text line 2
LinearLayout line2layout = (LinearLayout) view.findViewById(R.id.context_menu_line2_layout);
@ -1206,8 +1421,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
line3.setCompoundDrawablePadding(dpToPx(5f));
}
ImageView additionalInfoImageView = (ImageView) view.findViewById(R.id.additional_info_image_view);
TextView additionalInfoTextView = (TextView) view.findViewById(R.id.additional_info_text_view);
CharSequence additionalInfoStr = menu.getAdditionalInfo();
boolean showAdditionalImage = false;
if (!TextUtils.isEmpty(additionalInfoStr)) {
int colorId = menu.getAdditionalInfoColor();
int additionalInfoIconRes = menu.getAdditionalInfoIconRes();
@ -1215,8 +1432,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
additionalInfoTextView.setTextColor(ContextCompat.getColor(getContext(), colorId));
if (additionalInfoIconRes != 0) {
Drawable additionalIcon = getIcon(additionalInfoIconRes, colorId);
additionalInfoTextView.setCompoundDrawablesWithIntrinsicBounds(additionalIcon, null, null, null);
additionalInfoTextView.setCompoundDrawablePadding(dpToPx(8));
additionalInfoImageView.setImageDrawable(additionalIcon);
showAdditionalImage = true;
}
}
additionalInfoTextView.setText(additionalInfoStr);
@ -1224,6 +1441,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} else {
additionalInfoTextView.setVisibility(View.GONE);
}
additionalInfoImageView.setVisibility(showAdditionalImage ? View.VISIBLE : View.GONE);
}
updateCompassVisibility();
}
@ -1267,23 +1485,48 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
}
}
private int getHeaderOnlyTopY() {
return viewHeight - menuTitleHeight;
}
private int getFullScreenTopPosY() {
return -menuTitleHeight + menuButtonsHeight + bottomToolbarPosY;
}
private int getMenuStatePosY(int menuState) {
if (menu.isLandscapeLayout()) {
return topScreenPosY;
}
switch (menuState) {
case MenuState.HEADER_ONLY:
return getHeaderOnlyTopY();
case MenuState.HALF_SCREEN:
return minHalfY;
case MenuState.FULL_SCREEN:
return getFullScreenTopPosY();
default:
return 0;
}
}
private int getPosY() {
return getPosY(CURRENT_Y_UNDEFINED, false);
}
private int getPosY(final int currentY, boolean needCloseMenu) {
return getPosY(currentY, needCloseMenu, 0);
}
private int getPosY(final int currentY, boolean needCloseMenu, int previousState) {
if (needCloseMenu) {
return screenHeight;
}
int destinationState;
int minHalfY;
if (menu.isExtended()) {
destinationState = menu.getCurrentMenuState();
minHalfY = viewHeight - (int) (viewHeight * menu.getHalfScreenMaxHeightKoef());
} else {
destinationState = MenuState.HEADER_ONLY;
minHalfY = viewHeight - (int) (viewHeight * .75f);
}
updateZoomButtonsVisibility(destinationState);
@ -1291,19 +1534,19 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
int posY = 0;
switch (destinationState) {
case MenuState.HEADER_ONLY:
posY = viewHeight - menuTitleHeight;
posY = getMenuStatePosY(MenuState.HEADER_ONLY);
break;
case MenuState.HALF_SCREEN:
posY = minHalfY;
posY = getMenuStatePosY(MenuState.HALF_SCREEN);
break;
case MenuState.FULL_SCREEN:
if (currentY != CURRENT_Y_UNDEFINED) {
int maxPosY = viewHeight - menuFullHeightMax;
int minPosY = topScreenPosY;
int minPosY = getMenuStatePosY(MenuState.FULL_SCREEN);
if (maxPosY > minPosY) {
maxPosY = minPosY;
}
if (currentY > minPosY) {
if (currentY > minPosY || previousState != MenuState.FULL_SCREEN) {
posY = minPosY;
} else if (currentY < maxPosY) {
posY = maxPosY;
@ -1311,7 +1554,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
posY = currentY;
}
} else {
posY = topScreenPosY;
posY = getMenuStatePosY(MenuState.FULL_SCREEN);
}
break;
default:
@ -1362,7 +1605,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
int zoom = getZoom() + dZoom;
LatLon latlon = getAdjustedMarkerLocation(y, menu.getLatLon(), center, zoom);
if (map.getLatitude() == latlon.getLatitude() && map.getLongitude() == latlon.getLongitude() && dZoom == 0) {
if (map.hasCustomMapRatio()
|| (map.getLatitude() == latlon.getLatitude() && map.getLongitude() == latlon.getLongitude() && dZoom == 0)) {
return;
}
@ -1440,11 +1684,11 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
}
private int getZoomButtonsY(int y) {
return y - zoomButtonsHeight;
return y - zoomButtonsHeight - shadowHeight - zoomPaddingTop;
}
private void doLayoutMenu() {
final int posY = getPosY(getViewY(), false);
final int posY = getPosY(getViewY(), false, menu.getCurrentMenuState());
setViewY(posY, true, !initLayout || !centered);
updateMainViewLayout(posY);
}

View file

@ -873,93 +873,6 @@ public class MenuBuilder {
return new CollapsableView(textView, this, collapsed);
}
protected CollapsableView getCollapsableFavouritesView(final Context context, boolean collapsed, @NonNull final FavoriteGroup group, FavouritePoint selectedPoint) {
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
List<FavouritePoint> points = group.points;
for (int i = 0; i < points.size() && i < 10; i++) {
final FavouritePoint point = points.get(i);
boolean selected = selectedPoint != null && selectedPoint.equals(point);
TextViewEx button = buildButtonInCollapsableView(context, selected, false);
String name = point.getName();
button.setText(name);
if (!selected) {
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LatLon latLon = new LatLon(point.getLatitude(), point.getLongitude());
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName());
mapActivity.getContextMenu().show(latLon, pointDescription, point);
}
});
}
view.addView(button);
}
if (points.size() > 10) {
TextViewEx button = buildButtonInCollapsableView(context, false, true);
button.setText(context.getString(R.string.shared_string_show_all));
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
OsmAndAppCustomization appCustomization = app.getAppCustomization();
final Intent intent = new Intent(context, appCustomization.getFavoritesActivity());
intent.putExtra(FavoritesActivity.OPEN_FAVOURITES_TAB, true);
intent.putExtra(FavoritesActivity.GROUP_NAME_TO_SHOW, group.name);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
context.startActivity(intent);
}
});
view.addView(button);
}
return new CollapsableView(view, this, collapsed);
}
protected CollapsableView getCollapsableWaypointsView(final Context context, boolean collapsed, @NonNull final GPXFile gpxFile, WptPt selectedPoint) {
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
List<WptPt> points = gpxFile.getPoints();
for (int i = 0; i < points.size() && i < 10; i++) {
final WptPt point = points.get(i);
boolean selected = selectedPoint != null && selectedPoint.equals(point);
TextViewEx button = buildButtonInCollapsableView(context, selected, false);
button.setText(point.name);
if (!selected) {
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LatLon latLon = new LatLon(point.getLatitude(), point.getLongitude());
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, point.name);
mapActivity.getContextMenu().show(latLon, pointDescription, point);
}
});
}
view.addView(button);
}
if (points.size() > 10) {
TextViewEx button = buildButtonInCollapsableView(context, false, true);
button.setText(context.getString(R.string.shared_string_show_all));
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
OsmAndAppCustomization appCustomization = app.getAppCustomization();
final Intent intent = new Intent(context, appCustomization.getTrackActivity());
intent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxFile.path);
intent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
context.startActivity(intent);
}
});
view.addView(button);
}
return new CollapsableView(view, this, collapsed);
}
protected CollapsableView getCollapsableWikiView(Context context, boolean collapsed) {
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
@ -995,9 +908,14 @@ public class MenuBuilder {
}
protected TextViewEx buildButtonInCollapsableView(Context context, boolean selected, boolean showAll) {
return buildButtonInCollapsableView(context, selected, showAll, true);
}
protected TextViewEx buildButtonInCollapsableView(Context context, boolean selected, boolean showAll, boolean singleLine) {
TextViewEx button = new TextViewEx(new ContextThemeWrapper(context, light ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme));
LinearLayout.LayoutParams llWikiButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, dpToPx(36f));
LinearLayout.LayoutParams llWikiButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llWikiButtonParams.setMargins(0, 0, 0, dpToPx(8f));
//button.setMinimumHeight(dpToPx(36f));
button.setLayoutParams(llWikiButtonParams);
button.setTypeface(FontCache.getRobotoRegular(context));
int bg;
@ -1011,7 +929,7 @@ public class MenuBuilder {
button.setBackgroundResource(bg);
button.setTextSize(14);
int paddingSides = dpToPx(10f);
button.setPadding(paddingSides, 0, paddingSides, 0);
button.setPadding(paddingSides, paddingSides, paddingSides, paddingSides);
if (!selected) {
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,
@ -1021,7 +939,7 @@ public class MenuBuilder {
button.setTextColor(ContextCompat.getColor(context, light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));
}
button.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
button.setSingleLine(true);
button.setSingleLine(singleLine);
button.setEllipsize(TextUtils.TruncateAt.END);
return button;

View file

@ -4,6 +4,7 @@ import android.graphics.drawable.Drawable;
import android.graphics.drawable.StateListDrawable;
import android.os.AsyncTask;
import android.os.Build;
import android.support.annotation.ColorRes;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@ -130,38 +131,13 @@ public abstract class MenuController extends BaseMenuController implements Colla
this.builder.setLight(isLight());
}
public void onCreated() {
/*
toolbarController = new ContextMenuToolbarController(this);
toolbarController.setTitle(getNameStr());
toolbarController.setOnBackButtonClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mapContextMenu != null) {
mapContextMenu.backToolbarAction(MenuController.this);
}
}
});
toolbarController.setOnTitleClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
}
});
toolbarController.setOnCloseButtonClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mapContextMenu != null) {
mapContextMenu.close();
}
}
});
*/
protected void onCreated() {
}
@Override
public void onCollapseExpand(boolean collapsed) {
if (mapContextMenu != null) {
mapContextMenu.updateMenuUI();
mapContextMenu.updateLayout();
}
}
@ -478,9 +454,17 @@ public abstract class MenuController extends BaseMenuController implements Colla
return "";
}
public int getAdditionalInfoColor() {
@ColorRes
public int getAdditionalInfoColorId() {
if (openingHoursInfo != null) {
return 0;
boolean open = false;
for (OpeningHours.Info info : openingHoursInfo) {
if (info.isOpened() || info.isOpened24_7()) {
open = true;
break;
}
}
return open ? R.color.ctx_menu_amenity_opened_text_color : R.color.ctx_menu_amenity_closed_text_color;
} else if (indexItem != null) {
return R.color.icon_color;
}
@ -516,6 +500,7 @@ public abstract class MenuController extends BaseMenuController implements Colla
return "";
}
@DrawableRes
public int getAdditionalInfoIconRes() {
if (openingHoursInfo != null) {
return R.drawable.ic_action_opening_hour_16;

View file

@ -1,18 +1,18 @@
package net.osmand.plus.mapcontextmenu.builders;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper;
import android.text.Html;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.URLSpan;
import android.text.util.Linkify;
import android.view.Gravity;
import android.view.View;
@ -36,11 +36,13 @@ 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.poi.PoiUIFilter;
import net.osmand.plus.views.POIMapLayer;
import net.osmand.plus.widgets.TextViewEx;
import net.osmand.util.Algorithms;
import net.osmand.util.OpeningHoursParser;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
@ -66,26 +68,21 @@ public class AmenityMenuBuilder extends MenuBuilder {
private void buildRow(View view, int iconId, String text, String textPrefix,
boolean collapsable, final CollapsableView collapsableView,
int textColor, boolean isWiki, boolean isText, boolean needLinks,
boolean isPhoneNumber, boolean isUrl, boolean matchWidthDivider) {
boolean isPhoneNumber, boolean isUrl, boolean matchWidthDivider, int textLinesLimit) {
buildRow(view, iconId == 0 ? null : getRowIcon(iconId), text, textPrefix, collapsable, collapsableView, textColor,
isWiki, isText, needLinks, isPhoneNumber, isUrl, matchWidthDivider);
isWiki, isText, needLinks, isPhoneNumber, isUrl, matchWidthDivider, textLinesLimit);
}
protected void buildRow(final View view, Drawable icon, final String text, final String textPrefix,
boolean collapsable, final CollapsableView collapsableView,
int textColor, boolean isWiki, boolean isText, boolean needLinks,
boolean isPhoneNumber, boolean isUrl, boolean matchWidthDivider) {
boolean isPhoneNumber, boolean isUrl, boolean matchWidthDivider, int textLinesLimit) {
if (!isFirstRow()) {
buildRowDivider(view);
}
final String txt;
if (!Algorithms.isEmpty(textPrefix)) {
txt = textPrefix + ": " + text;
} else {
txt = text;
}
final String txt = text;
LinearLayout baseView = new LinearLayout(view.getContext());
baseView.setOrientation(LinearLayout.VERTICAL);
@ -100,7 +97,8 @@ public class AmenityMenuBuilder extends MenuBuilder {
ll.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
copyToClipboard(txt, view.getContext());
String textToCopy = !Algorithms.isEmpty(textPrefix) ? textPrefix + ": " + txt : txt;
copyToClipboard(textToCopy, view.getContext());
return true;
}
});
@ -130,31 +128,35 @@ public class AmenityMenuBuilder extends MenuBuilder {
llText.setOrientation(LinearLayout.VERTICAL);
ll.addView(llText);
TextView textPrefixView = null;
if (!Algorithms.isEmpty(textPrefix)) {
textPrefixView = new TextView(view.getContext());
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llTextParams.setMargins(icon == null ? dpToPx(16f) : 0, dpToPx(8f), 0, 0);
textPrefixView.setLayoutParams(llTextParams);
textPrefixView.setTextSize(12);
textPrefixView.setTextColor(app.getResources().getColor(R.color.ctx_menu_buttons_text_color));
textPrefixView.setEllipsize(TextUtils.TruncateAt.END);
textPrefixView.setMinLines(1);
textPrefixView.setMaxLines(1);
textPrefixView.setText(textPrefix);
}
TextView textView = new TextView(view.getContext());
LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
llTextParams.setMargins(icon == null ? dpToPx(16f) : 0, collapsable ? dpToPx(13f) : dpToPx(8f), 0, collapsable ? dpToPx(13f) : dpToPx(8f));
llTextParams.setMargins(icon == null ? dpToPx(16f) : 0,
textPrefixView == null ? (collapsable ? dpToPx(13f) : dpToPx(8f)) : dpToPx(2f), 0, collapsable && textPrefixView == null ? dpToPx(13f) : dpToPx(8f));
textView.setLayoutParams(llTextParams);
textView.setTextSize(16);
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_text_color_light : R.color.ctx_menu_bottom_view_text_color_dark));
int linkTextColor = ContextCompat.getColor(view.getContext(), light ? R.color.ctx_menu_bottom_view_url_color_light : R.color.ctx_menu_bottom_view_url_color_dark);
boolean textDefined = false;
if (isPhoneNumber || isUrl) {
if (!Algorithms.isEmpty(textPrefix)) {
SpannableString spannableString = new SpannableString(txt);
spannableString.setSpan(new URLSpan(txt), textPrefix.length() + 2, txt.length(), 0);
textView.setText(spannableString);
textView.setLinkTextColor(linkTextColor);
textDefined = true;
} else {
textView.setTextColor(linkTextColor);
}
textView.setTextColor(linkTextColor);
needLinks = false;
}
if (!textDefined) {
textView.setText(txt);
}
textView.setText(txt);
if (needLinks) {
Linkify.addLinks(textView, Linkify.ALL);
textView.setLinksClickable(true);
@ -162,7 +164,10 @@ public class AmenityMenuBuilder extends MenuBuilder {
AndroidUtils.removeLinkUnderline(textView);
}
textView.setEllipsize(TextUtils.TruncateAt.END);
if (isWiki) {
if (textLinesLimit > 0) {
textView.setMinLines(1);
textView.setMaxLines(textLinesLimit);
} else if (isWiki) {
textView.setMinLines(1);
textView.setMaxLines(15);
} else if (isText) {
@ -178,13 +183,16 @@ public class AmenityMenuBuilder extends MenuBuilder {
llTextViewParams.setMargins(0, 0, dpToPx(10f), 0);
llTextViewParams.gravity = Gravity.CENTER_VERTICAL;
llText.setLayoutParams(llTextViewParams);
if (textPrefixView != null) {
llText.addView(textPrefixView);
}
llText.addView(textView);
final ImageView iconViewCollapse = new ImageView(view.getContext());
if (collapsable && collapsableView != null) {
// Icon
LinearLayout llIconCollapse = new LinearLayout(view.getContext());
llIconCollapse.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(40f), dpToPx(48f)));
llIconCollapse.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(40f), ViewGroup.LayoutParams.MATCH_PARENT));
llIconCollapse.setOrientation(LinearLayout.HORIZONTAL);
llIconCollapse.setGravity(Gravity.CENTER_VERTICAL);
ll.addView(llIconCollapse);
@ -316,6 +324,9 @@ public class AmenityMenuBuilder extends MenuBuilder {
List<AmenityInfoRow> infoRows = new LinkedList<>();
List<AmenityInfoRow> descriptions = new LinkedList<>();
Map<String, List<PoiType>> poiAdditionalCategories = new HashMap<>();
AmenityInfoRow cuisineRow = null;
for (Map.Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) {
int iconId = 0;
Drawable icon = null;
@ -336,6 +347,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
boolean needLinks = !"population".equals(key);
boolean isPhoneNumber = false;
boolean isUrl = false;
boolean isCuisine = false;
int poiTypeOrder = 0;
String poiTypeKeyName = "";
@ -353,6 +365,19 @@ public class AmenityMenuBuilder extends MenuBuilder {
poiTypeKeyName = pType.getKeyName();
}
if (pType != null && !pType.isText()) {
String categoryName = pType.getPoiAdditionalCategory();
if (!Algorithms.isEmpty(categoryName)) {
List<PoiType> poiAdditionalCategoryTypes = poiAdditionalCategories.get(categoryName);
if (poiAdditionalCategoryTypes == null) {
poiAdditionalCategoryTypes = new ArrayList<>();
poiAdditionalCategories.put(categoryName, poiAdditionalCategoryTypes);
}
poiAdditionalCategoryTypes.add(pType);
continue;
}
}
if (amenity.getType().isWiki()) {
if (!hasWiki) {
String lng = amenity.getContentLanguage("content", preferredLang, "en");
@ -399,16 +424,18 @@ public class AmenityMenuBuilder extends MenuBuilder {
iconId = R.drawable.ic_world_globe_dark;
isUrl = true;
} else if (Amenity.CUISINE.equals(key)) {
isCuisine = true;
iconId = R.drawable.ic_action_cuisine;
StringBuilder sb = new StringBuilder();
for (String c : e.getValue().split(";")) {
if (sb.length() > 0) {
sb.append(", ");
sb.append(poiTypes.getPoiTranslation("cuisine_" + c).toLowerCase());
} else {
sb.append(app.getString(R.string.poi_cuisine)).append(": ");
sb.append(poiTypes.getPoiTranslation("cuisine_" + c));
}
sb.append(poiTypes.getPoiTranslation("cuisine_" + c).toLowerCase());
}
textPrefix = app.getString(R.string.poi_cuisine);
vl = sb.toString();
} else if (key.contains(Amenity.ROUTE)) {
continue;
@ -425,11 +452,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
icon = getRowIcon(view.getContext(), ((PoiType) pType.getParentType()).getOsmTag() + "_" + pType.getOsmTag().replace(':', '_') + "_" + pType.getOsmValue());
}
if (!pType.isText()) {
if (!Algorithms.isEmpty(pType.getPoiAdditionalCategory())) {
vl = pType.getPoiAdditionalCategoryTranslation() + ": " + pType.getTranslation();
} else {
vl = pType.getTranslation();
}
vl = pType.getTranslation();
} else {
isText = true;
isDescription = iconId == R.drawable.ic_action_note_dark;
@ -456,15 +479,69 @@ public class AmenityMenuBuilder extends MenuBuilder {
}
boolean matchWidthDivider = !isDescription && isWiki;
AmenityInfoRow row;
if (isDescription) {
descriptions.add(new AmenityInfoRow(key, R.drawable.ic_action_note_dark, textPrefix,
vl, collapsable, collapsableView, 0, false, true, true, 0, "", false, false, matchWidthDivider));
row = new AmenityInfoRow(key, R.drawable.ic_action_note_dark, textPrefix,
vl, collapsable, collapsableView, 0, false, true,
true, 0, "", false, false, matchWidthDivider, 0);
} else if (icon != null) {
infoRows.add(new AmenityInfoRow(key, icon, textPrefix, vl, collapsable, collapsableView,
textColor, isWiki, isText, needLinks, poiTypeOrder, poiTypeKeyName, isPhoneNumber, isUrl, matchWidthDivider));
row = new AmenityInfoRow(key, icon, textPrefix, vl, collapsable, collapsableView,
textColor, isWiki, isText, needLinks, poiTypeOrder, poiTypeKeyName,
isPhoneNumber, isUrl, matchWidthDivider, 0);
} else {
infoRows.add(new AmenityInfoRow(key, iconId, textPrefix, vl, collapsable, collapsableView,
textColor, isWiki, isText, needLinks, poiTypeOrder, poiTypeKeyName, isPhoneNumber, isUrl, matchWidthDivider));
row = new AmenityInfoRow(key, iconId, textPrefix, vl, collapsable, collapsableView,
textColor, isWiki, isText, needLinks, poiTypeOrder, poiTypeKeyName,
isPhoneNumber, isUrl, matchWidthDivider, 0);
}
if (isDescription) {
descriptions.add(row);
} else {
if (!isCuisine) {
infoRows.add(row);
} else {
cuisineRow = row;
}
}
}
if (cuisineRow != null) {
boolean hasCuisineOrDish = poiAdditionalCategories.get(Amenity.CUISINE) != null
|| poiAdditionalCategories.get(Amenity.DISH) != null;
if (!hasCuisineOrDish) {
infoRows.add(cuisineRow);
}
}
for (Map.Entry<String, List<PoiType>> e : poiAdditionalCategories.entrySet()) {
String categoryName = e.getKey();
List<PoiType> categoryTypes = e.getValue();
if (categoryTypes.size() > 0) {
Drawable icon;
PoiType pType = categoryTypes.get(0);
String poiAdditionalCategoryName = pType.getPoiAdditionalCategory();
String poiAddidionalIconName = poiTypes.getPoiAdditionalCategoryIconName(poiAdditionalCategoryName);
icon = getRowIcon(view.getContext(), poiAddidionalIconName);
if (icon == null) {
icon = getRowIcon(view.getContext(), poiAdditionalCategoryName);
}
if (icon == null) {
icon = getRowIcon(view.getContext(), pType.getIconKeyName());
}
if (icon == null) {
icon = getRowIcon(R.drawable.ic_action_note_dark);
}
StringBuilder sb = new StringBuilder();
for (PoiType pt : categoryTypes) {
if (sb.length() > 0) {
sb.append("");
}
sb.append(pt.getTranslation());
}
boolean cuisineOrDish = categoryName.equals(Amenity.CUISINE) || categoryName.equals(Amenity.DISH);
CollapsableView collapsableView = getPoiAdditionalCollapsableView(view.getContext(), true, categoryTypes, cuisineOrDish ? cuisineRow : null);
infoRows.add(new AmenityInfoRow(poiAdditionalCategoryName, icon, pType.getPoiAdditionalCategoryTranslation(), sb.toString(), true, collapsableView,
0, false, false, false, pType.getOrder(), pType.getKeyName(), false, false, false, 1));
}
}
@ -507,7 +584,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
AmenityInfoRow wikiInfo = new AmenityInfoRow(
"nearest_wiki", R.drawable.ic_action_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")", true,
getCollapsableWikiView(view.getContext(), true),
0, false, false, false, 1000, null, false, false, false);
0, false, false, false, 1000, null, false, false, false, 0);
buildAmenityRow(view, wikiInfo);
}
@ -534,17 +611,19 @@ public class AmenityMenuBuilder extends MenuBuilder {
public void buildAmenityRow(View view, AmenityInfoRow info) {
if (info.icon != null) {
buildRow(view, info.icon, info.text, info.textPrefix, info.collapsable, info.collapsableView,
info.textColor, info.isWiki, info.isText, info.needLinks, info.isPhoneNumber, info.isUrl, info.matchWidthDivider);
info.textColor, info.isWiki, info.isText, info.needLinks, info.isPhoneNumber,
info.isUrl, info.matchWidthDivider, info.textLinesLimit);
} else {
buildRow(view, info.iconId, info.text, info.textPrefix, info.collapsable, info.collapsableView,
info.textColor, info.isWiki, info.isText, info.needLinks, info.isPhoneNumber, info.isUrl, info.matchWidthDivider);
info.textColor, info.isWiki, info.isText, info.needLinks, info.isPhoneNumber,
info.isUrl, info.matchWidthDivider, info.textLinesLimit);
}
}
@Override
protected Map<String, String> getAdditionalCardParams() {
Map<String, String> params = new HashMap<>();
Map<String, String> additionalInfo = amenity.getAdditionalInfo();
Map<String, String> additionalInfo = amenity.getAdditionalInfo();
String imageValue = additionalInfo.get("image");
String mapillaryValue = additionalInfo.get("mapillary");
if (!Algorithms.isEmpty(imageValue)) {
@ -556,6 +635,68 @@ public class AmenityMenuBuilder extends MenuBuilder {
return params;
}
private CollapsableView getPoiAdditionalCollapsableView(
final Context context, boolean collapsed,
@NonNull final List<PoiType> categoryTypes, AmenityInfoRow textCuisineRow) {
final List<TextViewEx> buttons = new ArrayList<>();
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
for (final PoiType pt : categoryTypes) {
TextViewEx button = buildButtonInCollapsableView(context, false, false);
String name = pt.getTranslation();
button.setText(name);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (amenity.getType() != null) {
PoiUIFilter filter = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + amenity.getType().getKeyName());
if (filter != null) {
filter.clearFilter();
filter.setTypeToAccept(amenity.getType(), true);
filter.updateTypesToAccept(pt);
filter.setFilterByName(pt.getKeyName().replace('_', ':').toLowerCase());
getMapActivity().showQuickSearch(filter);
}
}
}
});
buttons.add(button);
if (buttons.size() > 3 && categoryTypes.size() > 4) {
button.setVisibility(View.GONE);
}
view.addView(button);
}
if (textCuisineRow != null) {
TextViewEx button = buildButtonInCollapsableView(context, true, false, false);
String name = textCuisineRow.textPrefix + ": " + textCuisineRow.text.toLowerCase();
button.setText(name);
view.addView(button);
}
if (categoryTypes.size() > 4) {
final TextViewEx button = buildButtonInCollapsableView(context, false, true);
button.setText(context.getString(R.string.shared_string_show_all));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
for (TextViewEx b : buttons) {
if (b.getVisibility() != View.VISIBLE) {
b.setVisibility(View.VISIBLE);
}
}
button.setVisibility(View.GONE);
}
});
view.addView(button);
}
return new CollapsableView(view, this, collapsed);
}
private static class AmenityInfoRow {
private String key;
private Drawable icon;
@ -573,11 +714,13 @@ public class AmenityMenuBuilder extends MenuBuilder {
private int order;
private String name;
private boolean matchWidthDivider;
private int textLinesLimit;
public AmenityInfoRow(String key, Drawable icon, String textPrefix, String text,
boolean collapsable, CollapsableView collapsableView,
int textColor, boolean isWiki, boolean isText, boolean needLinks,
int order, String name, boolean isPhoneNumber, boolean isUrl, boolean matchWidthDivider) {
int order, String name, boolean isPhoneNumber, boolean isUrl,
boolean matchWidthDivider, int textLinesLimit) {
this.key = key;
this.icon = icon;
this.textPrefix = textPrefix;
@ -593,12 +736,14 @@ public class AmenityMenuBuilder extends MenuBuilder {
this.isPhoneNumber = isPhoneNumber;
this.isUrl = isUrl;
this.matchWidthDivider = matchWidthDivider;
this.textLinesLimit = textLinesLimit;
}
public AmenityInfoRow(String key, int iconId, String textPrefix, String text,
boolean collapsable, CollapsableView collapsableView,
int textColor, boolean isWiki, boolean isText, boolean needLinks,
int order, String name, boolean isPhoneNumber, boolean isUrl, boolean matchWidthDivider) {
int order, String name, boolean isPhoneNumber, boolean isUrl,
boolean matchWidthDivider, int textLinesLimit) {
this.key = key;
this.iconId = iconId;
this.textPrefix = textPrefix;
@ -614,6 +759,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
this.isPhoneNumber = isPhoneNumber;
this.isUrl = isUrl;
this.matchWidthDivider = matchWidthDivider;
this.textLinesLimit = textLinesLimit;
}
}
}

View file

@ -1,19 +1,28 @@
package net.osmand.plus.mapcontextmenu.builders;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.LinearLayout;
import net.osmand.ResultMatcher;
import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.Amenity;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect;
import net.osmand.data.TransportStop;
import net.osmand.osm.PoiCategory;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.widgets.TextViewEx;
import net.osmand.util.MapUtils;
import java.util.List;
@ -127,4 +136,48 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
}
return null;
}
private CollapsableView getCollapsableFavouritesView(final Context context, boolean collapsed, @NonNull final FavoriteGroup group, FavouritePoint selectedPoint) {
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
List<FavouritePoint> points = group.points;
for (int i = 0; i < points.size() && i < 10; i++) {
final FavouritePoint point = points.get(i);
boolean selected = selectedPoint != null && selectedPoint.equals(point);
TextViewEx button = buildButtonInCollapsableView(context, selected, false);
String name = point.getName();
button.setText(name);
if (!selected) {
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LatLon latLon = new LatLon(point.getLatitude(), point.getLongitude());
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName());
mapActivity.getContextMenu().show(latLon, pointDescription, point);
}
});
}
view.addView(button);
}
if (points.size() > 10) {
TextViewEx button = buildButtonInCollapsableView(context, false, true);
button.setText(context.getString(R.string.shared_string_show_all));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
OsmAndAppCustomization appCustomization = app.getAppCustomization();
final Intent intent = new Intent(context, appCustomization.getFavoritesActivity());
intent.putExtra(FavoritesActivity.OPEN_FAVOURITES_TAB, true);
intent.putExtra(FavoritesActivity.GROUP_NAME_TO_SHOW, group.name);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
context.startActivity(intent);
}
});
view.addView(button);
}
return new CollapsableView(view, this, collapsed);
}
}

View file

@ -1,20 +1,28 @@
package net.osmand.plus.mapcontextmenu.builders;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.LinearLayout;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapillary.MapillaryPlugin;
import net.osmand.plus.views.POIMapLayer;
import net.osmand.plus.widgets.TextViewEx;
import net.osmand.util.Algorithms;
import java.io.File;
@ -121,4 +129,47 @@ public class WptPtMenuBuilder extends MenuBuilder {
}
return visit;
}
private CollapsableView getCollapsableWaypointsView(final Context context, boolean collapsed, @NonNull final GPXUtilities.GPXFile gpxFile, WptPt selectedPoint) {
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
List<WptPt> points = gpxFile.getPoints();
for (int i = 0; i < points.size() && i < 10; i++) {
final WptPt point = points.get(i);
boolean selected = selectedPoint != null && selectedPoint.equals(point);
TextViewEx button = buildButtonInCollapsableView(context, selected, false);
button.setText(point.name);
if (!selected) {
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
LatLon latLon = new LatLon(point.getLatitude(), point.getLongitude());
PointDescription pointDescription = new PointDescription(PointDescription.POINT_TYPE_WPT, point.name);
mapActivity.getContextMenu().show(latLon, pointDescription, point);
}
});
}
view.addView(button);
}
if (points.size() > 10) {
TextViewEx button = buildButtonInCollapsableView(context, false, true);
button.setText(context.getString(R.string.shared_string_show_all));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
OsmAndAppCustomization appCustomization = app.getAppCustomization();
final Intent intent = new Intent(context, appCustomization.getTrackActivity());
intent.putExtra(TrackActivity.TRACK_FILE_NAME, gpxFile.path);
intent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
context.startActivity(intent);
}
});
view.addView(button);
}
return new CollapsableView(view, this, collapsed);
}
}

View file

@ -191,7 +191,7 @@ public class MapDataMenuController extends MenuController {
}
@Override
public int getAdditionalInfoColor() {
public int getAdditionalInfoColorId() {
return R.color.icon_color;
}

View file

@ -306,7 +306,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
}
}
if (startPoint != null) {
if (startPoint != null && endPoint != null) {
targetPointsHelper.navigateToPoint(startPoint.point, false, -1, startPoint.getPointDescription(mapActivity));
targetPointsHelper.setStartPoint(endPoint.point, false, endPoint.getPointDescription(mapActivity));
targetPointsHelper.updateRouteAndRefresh(true);

View file

@ -3,7 +3,7 @@ package net.osmand.plus.mapcontextmenu.other;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -17,13 +17,14 @@ import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.mapcontextmenu.other.ShareMenu.ShareItem;
import net.osmand.plus.widgets.TextViewEx;
import java.util.List;
public class ShareMenuFragment extends BaseOsmAndFragment implements OnItemClickListener {
public class ShareMenuFragment extends MenuBottomSheetDialogFragment implements OnItemClickListener {
public static final String TAG = "ShareMenuFragment";
private ArrayAdapter<ShareItem> listAdapter;
@ -40,56 +41,41 @@ public class ShareMenuFragment extends BaseOsmAndFragment implements OnItemClick
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.share_menu_fragment, container, false);
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes),
R.layout.share_menu_fragment, container);
View mainView = view.findViewById(R.id.main_view);
if (menu.isLandscapeLayout()) {
AndroidUtils.addStatusBarPadding21v(getContext(), view);
AndroidUtils.setBackground(view.getContext(), mainView, !menu.isLight(),
R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
} else {
AndroidUtils.setBackground(view.getContext(), mainView, !menu.isLight(),
R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
if (nightMode) {
((TextViewEx) view.findViewById(R.id.title_text_view)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
}
TextView headerCaption = (TextView) view.findViewById(R.id.header_caption);
AndroidUtils.setTextSecondaryColor(view.getContext(), headerCaption, !menu.isLight());
ListView listView = (ListView) view.findViewById(R.id.list);
listAdapter = createAdapter();
listView.setAdapter(listAdapter);
listView.setOnItemClickListener(this);
view.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
setupHeightAndBackground(view, R.id.scroll_view);
return view;
}
@Override
public void onStart() {
super.onStart();
menu.getMapActivity().getContextMenu().setBaseFragmentVisibility(false);
}
@Override
public void onStop() {
super.onStop();
menu.getMapActivity().getContextMenu().setBaseFragmentVisibility(true);
}
@Override
public void onSaveInstanceState(Bundle outState) {
menu.saveMenu(outState);
}
public static void showInstance(ShareMenu menu) {
int slideInAnim = menu.getSlideInAnimation();
int slideOutAnim = menu.getSlideOutAnimation();
ShareMenuFragment fragment = new ShareMenuFragment();
fragment.menu = menu;
menu.getMapActivity().getSupportFragmentManager().beginTransaction()
.setCustomAnimations(slideInAnim, slideOutAnim, slideInAnim, slideOutAnim)
.add(R.id.fragmentContainer, fragment, TAG)
.addToBackStack(TAG).commit();
fragment.setUsedOnMap(true);
fragment.show(menu.getMapActivity().getSupportFragmentManager(), ShareMenuFragment.TAG);
}
private ArrayAdapter<ShareItem> createAdapter() {
@ -103,13 +89,13 @@ public class ShareMenuFragment extends BaseOsmAndFragment implements OnItemClick
if (v == null) {
v = menu.getMapActivity().getLayoutInflater().inflate(R.layout.share_list_item, null);
}
AndroidUtils.setBackground(v.getContext(), v, !menu.isLight(), R.drawable.expandable_list_item_background_light, R.drawable.expandable_list_item_background_dark);
AndroidUtils.setBackground(v.getContext(), v, nightMode, R.drawable.expandable_list_item_background_light, R.drawable.expandable_list_item_background_dark);
final ShareItem item = getItem(position);
ImageView icon = (ImageView) v.findViewById(R.id.icon);
icon.setImageDrawable(menu.getMapActivity().getMyApplication()
.getIconsCache().getIcon(item.getIconResourceId(), menu.isLight()));
.getIconsCache().getIcon(item.getIconResourceId(), !nightMode));
TextView name = (TextView) v.findViewById(R.id.name);
AndroidUtils.setTextPrimaryColor(v.getContext(), name, !menu.isLight());
AndroidUtils.setTextPrimaryColor(v.getContext(), name, nightMode);
name.setText(getContext().getText(item.getTitleResourceId()));
return v;
}
@ -118,15 +104,12 @@ public class ShareMenuFragment extends BaseOsmAndFragment implements OnItemClick
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
dismiss();
menu.share(listAdapter.getItem(position));
disableTransitionAnimation();
dismissMenu();
}
public void dismissMenu() {
menu.getMapActivity().getSupportFragmentManager().popBackStackImmediate(TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE);
if (menu.getMapActivity().getContextMenu().isVisible()) {
menu.getMapActivity().getContextMenu().close();
}
dismiss();
menu.getMapActivity().getContextMenu().close();
}
}

View file

@ -136,7 +136,7 @@ public class EditPOIMenuController extends MenuController {
}
@Override
public int getAdditionalInfoColor() {
public int getAdditionalInfoColorId() {
if (osmPoint.getAction() == Action.DELETE) {
return R.color.color_osm_edit_delete;
} else if (osmPoint.getAction() == Action.MODIFY || osmPoint.getAction() == Action.REOPEN) {

View file

@ -50,7 +50,6 @@ import java.util.List;
public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider {
private static final Log log = PlatformUtil.getLog(OsmBugsLayer.class);
private final static int startZoom = 8;
private final OsmEditingPlugin plugin;
private OsmandMapTileView view;
@ -65,6 +64,8 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
private OsmBugsLocalUtil local;
private MapLayerData<List<OpenStreetNote>> data;
private int startZoom;
public OsmBugsLayer(MapActivity activity, OsmEditingPlugin plugin) {
this.activity = activity;
this.plugin = plugin;
@ -116,6 +117,7 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
startZoom = activity.getMyApplication().getSettings().SHOW_OSM_BUGS_MIN_ZOOM.get();
if (tileBox.getZoom() >= startZoom) {
// request to load
data.queryNewData(tileBox);
@ -127,7 +129,11 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
List<OpenStreetNote> fullObjects = new ArrayList<>();
List<LatLon> fullObjectsLatLon = new ArrayList<>();
List<LatLon> smallObjectsLatLon = new ArrayList<>();
boolean showClosed = activity.getMyApplication().getSettings().SHOW_CLOSED_OSM_BUGS.get();
for (OpenStreetNote o : objects) {
if (!o.isOpened() && !showClosed) {
continue;
}
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
@ -146,6 +152,9 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
}
}
for (OpenStreetNote o : fullObjects) {
if (!o.isOpened() && !showClosed) {
continue;
}
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
Bitmap b;
@ -200,9 +209,13 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
final int rad = getRadiusBug(tb);
int radius = rad * 3 / 2;
int small = rad * 3 / 4;
boolean showClosed = activity.getMyApplication().getSettings().SHOW_CLOSED_OSM_BUGS.get();
try {
for (int i = 0; i < objects.size(); i++) {
OpenStreetNote n = objects.get(i);
if (!n.isOpened() && !showClosed) {
continue;
}
int x = (int) tb.getPixXFromLatLon(n.getLatitude(), n.getLongitude());
int y = (int) tb.getPixYFromLatLon(n.getLatitude(), n.getLongitude());
if (Math.abs(x - ex) <= radius && Math.abs(y - ey) <= radius) {

View file

@ -15,6 +15,7 @@ import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.data.Amenity;
import net.osmand.osm.PoiType;
@ -30,6 +31,7 @@ import net.osmand.plus.activities.EnumAdapter;
import net.osmand.plus.activities.EnumAdapter.IEnumWithResource;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.TabActivity;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.myplaces.AvailableGPXFragment;
import net.osmand.plus.myplaces.AvailableGPXFragment.GpxInfo;
@ -258,11 +260,23 @@ public class OsmEditingPlugin extends OsmandPlugin {
@Override
public void registerLayerContextMenuActions(OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) {
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_osm_bugs, mapActivity)
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(R.string.layer_osm_bugs, mapActivity)
.setSelected(settings.SHOW_OSM_BUGS.get())
.setIcon(R.drawable.ic_action_bug_dark)
.setColor(settings.SHOW_OSM_BUGS.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
.setListener(new ContextMenuAdapter.ItemClickListener() {
.setSecondaryIcon(R.drawable.ic_action_additional_option)
.setListener(new ContextMenuAdapter.OnRowItemClick() {
@Override
public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> adapter, View view, int itemId, int position) {
if (itemId == R.string.layer_osm_bugs) {
mapActivity.getDashboard().setDashboardVisibility(true,
DashboardType.OSM_NOTES, AndroidUtils.getCenterViewCoordinates(view));
return false;
}
return true;
}
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
@ -279,7 +293,6 @@ public class OsmEditingPlugin extends OsmandPlugin {
})
.setPosition(16)
.createItem());
}
@Override

View file

@ -0,0 +1,135 @@
package net.osmand.plus.osmedit;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.widget.ArrayAdapter;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import java.util.Arrays;
public class OsmNotesMenu {
private static Integer[] zoomIntValues = {8, 9, 10, 11, 12, 13, 14, 15, 16};
public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity) {
ContextMenuAdapter adapter = new ContextMenuAdapter();
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
createLayersItems(adapter, mapActivity);
return adapter;
}
private static void createLayersItems(final ContextMenuAdapter adapter, final MapActivity mapActivity) {
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
final OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
if (plugin == null) {
return;
}
final int osmNotesStringId = R.string.layer_osm_bugs;
final int showZoomLevelStringId = R.string.show_from_zoom_level;
final int showClosedNotesStringId = R.string.show_closed_notes;
final OsmandPreference<Boolean> showOsmBugsPref = settings.SHOW_OSM_BUGS;
final CommonPreference<Boolean> showClosedOsmBugsPref = settings.SHOW_CLOSED_OSM_BUGS;
final CommonPreference<Integer> showOsmBugsZoomPref = settings.SHOW_OSM_BUGS_MIN_ZOOM;
final String[] zoomStrings = getZoomStrings(mapActivity);
ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {
@Override
public boolean onContextMenuClick(final ArrayAdapter<ContextMenuItem> adapter, int itemId,
final int position, boolean isChecked, int[] viewCoordinates) {
if (itemId == osmNotesStringId) {
showOsmBugsPref.set(isChecked);
plugin.updateLayers(mapActivity.getMapView(), mapActivity);
mapActivity.refreshMap();
mapActivity.getDashboard().refreshContent(true);
} else if (itemId == showZoomLevelStringId) {
int checked = Arrays.asList(zoomIntValues).indexOf(showOsmBugsZoomPref.get());
new AlertDialog.Builder(mapActivity)
.setTitle(R.string.show_from_zoom_level)
.setSingleChoiceItems(zoomStrings, checked, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
showOsmBugsZoomPref.set(zoomIntValues[which]);
ContextMenuItem item = adapter.getItem(position);
if (item != null) {
item.setDescription(zoomStrings[which]);
adapter.notifyDataSetChanged();
}
mapActivity.refreshMap();
dialog.dismiss();
}
})
.setNegativeButton(R.string.shared_string_dismiss, null)
.show();
} else if (itemId == showClosedNotesStringId) {
showClosedOsmBugsPref.set(isChecked);
mapActivity.refreshMap();
}
return false;
}
};
boolean showOsmBugs = showOsmBugsPref.get();
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
int toggleIconColorId;
if (showOsmBugs) {
toggleIconColorId = nightMode ? R.color.color_dialog_buttons_dark : R.color.color_dialog_buttons_light;
} else {
toggleIconColorId = nightMode ? 0 : R.color.icon_color;
}
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(osmNotesStringId, mapActivity)
.setDescription(mapActivity.getString(R.string.switch_osm_notes_visibility_desc))
.setIcon(R.drawable.ic_action_bug_dark)
.setColor(toggleIconColorId)
.setListener(l)
.setSelected(showOsmBugs)
.createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(showZoomLevelStringId, mapActivity)
.setDescription(zoomStrings[Arrays.asList(zoomIntValues).indexOf(showOsmBugsZoomPref.get())])
.setLayout(R.layout.list_item_single_line_descrition_narrow)
.setIcon(R.drawable.ic_action_map_magnifier)
.setListener(l)
.setClickable(showOsmBugs)
.createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(showClosedNotesStringId, mapActivity)
.setIcon(R.drawable.ic_action_note_dark)
.setListener(l)
.setSelected(showClosedOsmBugsPref.get())
.setClickable(showOsmBugs)
.hideDivider(true)
.createItem());
adapter.addItem(new ContextMenuItem.ItemBuilder()
.setLayout(R.layout.card_bottom_divider)
.setClickable(false)
.createItem());
}
private static String[] getZoomStrings(Context context) {
String[] res = new String[zoomIntValues.length];
for (int i = 0; i < zoomIntValues.length; i++) {
String strVal = String.valueOf(zoomIntValues[i]);
res[i] = i == 0 ? context.getString(R.string.rendering_value_default_name) + " (" + strVal + ")" : strVal;
}
return res;
}
}

View file

@ -73,7 +73,7 @@ public class ParkingPositionMenuController extends MenuController {
}
@Override
public int getAdditionalInfoColor() {
public int getAdditionalInfoColorId() {
return plugin.getParkingType() ? R.color.ctx_menu_amenity_closed_text_color : R.color.icon_color;
}

View file

@ -20,8 +20,8 @@ import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.render.RenderingRulesStorage;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class MapStyleAction extends SwitchableAction<String> {
@ -120,17 +120,19 @@ public class MapStyleAction extends SwitchableAction<String> {
final OsmandApplication app = activity.getMyApplication();
final List<String> visibleNamesList = new ArrayList<>();
final Collection<String> rendererNames = app.getRendererRegistry().getRendererNames();
final String[] items = rendererNames.toArray(new String[rendererNames.size()]);
final ArrayList<String> items = new ArrayList<>(app.getRendererRegistry().getRendererNames());
final boolean nauticalPluginDisabled = OsmandPlugin.getEnabledPlugin(NauticalMapsPlugin.class) == null;
for (String item : items) {
Iterator<String> iterator = items.iterator();
while (iterator.hasNext()) {
String item = iterator.next();
if (nauticalPluginDisabled && item.equals(RendererRegistry.NAUTICAL_RENDER)) {
continue;
iterator.remove();
} else {
String translation = RendererRegistry.getTranslatedRendererName(activity, item);
visibleNamesList.add(translation != null ? translation
: item.replace('_', ' ').replace('-', ' '));
}
visibleNamesList.add(item.replace('_', ' ').replace('-', ' '));
}
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(activity, R.layout.dialog_text_item);
@ -140,7 +142,7 @@ public class MapStyleAction extends SwitchableAction<String> {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
String renderer = visibleNamesList.get(i);
String renderer = items.get(i);
RenderingRulesStorage loaded = app.getRendererRegistry().getRenderer(renderer);
if (loaded != null) {

View file

@ -1,15 +1,8 @@
package net.osmand.plus.render;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
@ -25,6 +18,17 @@ import org.apache.commons.logging.Log;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
public class RendererRegistry {
@ -32,12 +36,11 @@ public class RendererRegistry {
public final static String DEFAULT_RENDER = "OsmAnd"; //$NON-NLS-1$
public final static String DEFAULT_RENDER_FILE_PATH = "default.render.xml";
public final static String TOURING_VIEW = "Touring view (contrast and details)"; //$NON-NLS-1$
public final static String WINTER_SKI_RENDER = "Winter and ski"; //$NON-NLS-1$
public final static String NAUTICAL_RENDER = "Nautical"; //$NON-NLS-1$
public final static String TOPO_RENDER = "Topo"; //$NON-NLS-1$
public final static String MAPNIK_RENDER = "Mapnik"; //$NON-NLS-1$
// Translatable renders
public static String TOURING_VIEW;
public static String WINTER_SKI_RENDER;
public static String NAUTICAL_RENDER;
private RenderingRulesStorage defaultRender = null;
private RenderingRulesStorage currentSelectedRender = null;
@ -57,9 +60,6 @@ public class RendererRegistry {
public RendererRegistry(OsmandApplication app){
this.app = app;
WINTER_SKI_RENDER = app.getResources().getString(R.string.winter_and_ski_renderer);
TOURING_VIEW = app.getResources().getString(R.string.touring_view_renderer);
NAUTICAL_RENDER = app.getResources().getString(R.string.nautical_renderer);
internalRenderers.put(DEFAULT_RENDER, DEFAULT_RENDER_FILE_PATH);
internalRenderers.put(TOURING_VIEW, "Touring-view_(more-contrast-and-details)" +".render.xml");
internalRenderers.put(TOPO_RENDER, "topo" + ".render.xml");
@ -247,6 +247,19 @@ public class RendererRegistry {
return names;
}
@Nullable
public static String getTranslatedRendererName(@NonNull Context ctx, @NonNull String key) {
switch (key) {
case TOURING_VIEW:
return ctx.getString(R.string.touring_view_renderer);
case WINTER_SKI_RENDER:
return ctx.getString(R.string.winter_and_ski_renderer);
case NAUTICAL_RENDER:
return ctx.getString(R.string.nautical_renderer);
}
return null;
}
public RenderingRulesStorage getCurrentSelectedRenderer() {
if(currentSelectedRender == null){
return defaultRender();

View file

@ -88,7 +88,8 @@ public class IncrementalChangesManager {
if (!regionUpdateFiles.dayUpdates.isEmpty()) {
ArrayList<String> list = new ArrayList<String>(regionUpdateFiles.dayUpdates.keySet());
for (String month : list) {
Iterator<RegionUpdate> it = regionUpdateFiles.dayUpdates.get(month).iterator();
List<RegionUpdate> newList = new ArrayList<>(regionUpdateFiles.dayUpdates.get(month));
Iterator<RegionUpdate> it = newList.iterator();
RegionUpdate monthRu = regionUpdateFiles.monthUpdates.get(month);
while (it.hasNext()) {
RegionUpdate ru = it.next();
@ -100,6 +101,7 @@ public class IncrementalChangesManager {
log.info("Delete overlapping day update " + ru.file.getName());
}
}
regionUpdateFiles.dayUpdates.put(month, newList);
}
}
}

View file

@ -716,18 +716,18 @@ public class ResourceManager {
int left31 = MapUtils.get31TileNumberX(leftLongitude);
int bottom31 = MapUtils.get31TileNumberY(bottomLatitude);
int right31 = MapUtils.get31TileNumberX(rightLongitude);
List<String> fileNames = new ArrayList<String>(amenityRepositories.keySet());
List<String> fileNames = new ArrayList<>(amenityRepositories.keySet());
Collections.sort(fileNames, Algorithms.getStringVersionComparator());
for (String name : fileNames) {
AmenityIndexRepository index = amenityRepositories.get(name);
if (matcher != null && matcher.isCancelled()) {
searchAmenitiesInProgress = false;
break;
}
if (index.checkContainsInt(top31, left31, bottom31, right31)) {
AmenityIndexRepository index = amenityRepositories.get(name);
if (index != null && index.checkContainsInt(top31, left31, bottom31, right31)) {
List<Amenity> r = index.searchAmenities(top31,
left31, bottom31, right31, zoom, filter, matcher);
if(r != null) {
if (r != null) {
amenities.addAll(r);
}
}

View file

@ -18,7 +18,8 @@ public class AlarmInfo implements LocationPoint {
STOP(7, R.string.traffic_warning_stop),
PEDESTRIAN(8, R.string.traffic_warning_pedestrian),
HAZARD(9, R.string.traffic_warning_hazard),
MAXIMUM(10, R.string.traffic_warning);
MAXIMUM(10, R.string.traffic_warning),
TUNNEL(8, R.string.tunnel_warning);
private int priority;
private int string;
@ -41,6 +42,7 @@ public class AlarmInfo implements LocationPoint {
private AlarmInfoType type;
protected final int locationIndex;
private int intValue;
private float floatValue;
private double latitude;
private double longitude;
@ -53,6 +55,14 @@ public class AlarmInfo implements LocationPoint {
public AlarmInfoType getType() {
return type;
}
public float getFloatValue() {
return floatValue;
}
public void setFloatValue(float floatValue) {
this.floatValue = floatValue;
}
@Override
public double getLatitude() {

View file

@ -1,8 +1,6 @@
package net.osmand.plus.routing;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import android.content.Context;
import net.osmand.Location;
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
@ -12,12 +10,14 @@ import net.osmand.data.LocationPoint;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
import net.osmand.router.RouteSegmentResult;
import net.osmand.router.TurnType;
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils;
import android.content.Context;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static net.osmand.binary.RouteDataObject.HEIGHT_UNDEFINED;
@ -221,12 +221,26 @@ public class RouteCalculationResult {
float prevDirectionDistance = 0;
double lastHeight = HEIGHT_UNDEFINED;
List<RouteSegmentResult> segmentsToPopulate = new ArrayList<RouteSegmentResult>();
AlarmInfo tunnelAlarm = null;
for (int routeInd = 0; routeInd < list.size(); routeInd++) {
RouteSegmentResult s = list.get(routeInd);
float[] vls = s.getObject().calculateHeightArray();
boolean plus = s.getStartPointIndex() < s.getEndPointIndex();
int i = s.getStartPointIndex();
int prevLocationSize = locations.size();
if (s.getObject().tunnel()) {
if (tunnelAlarm == null) {
LatLon latLon = s.getPoint(i);
tunnelAlarm = new AlarmInfo(AlarmInfoType.TUNNEL, prevLocationSize);
tunnelAlarm.setLatLon(latLon.getLatitude(), latLon.getLongitude());
tunnelAlarm.setFloatValue(s.getDistance());
alarms.add(tunnelAlarm);
} else {
tunnelAlarm.setFloatValue(tunnelAlarm.getFloatValue() + s.getDistance());
}
} else {
tunnelAlarm = null;
}
while (true) {
Location n = new Location(""); //$NON-NLS-1$
LatLon point = s.getPoint(i);

View file

@ -1134,7 +1134,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
QuickSearchDialogFragment.this, filter.getFilterId());
}
}));
categoriesSearchFragment.updateListAdapter(rows, false);
if (categoriesSearchFragment != null) {
categoriesSearchFragment.updateListAdapter(rows, false);
}
}
LOG.info("--- categories loaded");
} catch (IOException e) {
@ -1815,6 +1817,21 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
sr.objectType = ObjectType.POI_TYPE;
searchUICore.selectSearchResult(sr);
bundle.putBoolean(QUICK_SEARCH_PHRASE_DEFINED_KEY, true);
} else if (object instanceof PoiUIFilter) {
PoiUIFilter filter = (PoiUIFilter) object;
objectLocalizedName = filter.getName();
SearchUICore searchUICore = mapActivity.getMyApplication().getSearchUICore().getCore();
SearchPhrase phrase = searchUICore.resetPhrase();
SearchResult sr = new SearchResult(phrase);
sr.localeName = objectLocalizedName;
sr.object = filter;
sr.priority = SEARCH_AMENITY_TYPE_PRIORITY;
sr.priorityDistance = 0;
sr.objectType = ObjectType.POI_TYPE;
searchUICore.selectSearchResult(sr);
bundle.putBoolean(QUICK_SEARCH_PHRASE_DEFINED_KEY, true);
}
searchQuery = objectLocalizedName.trim() + " ";

View file

@ -6,7 +6,6 @@ import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatButton;
import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.SwitchCompat;
import android.support.v7.widget.Toolbar;
@ -558,7 +557,7 @@ public class QuickSearchPoiFilterFragment extends DialogFragment {
boolean showAll = showAllCategories.contains(category);
items.add(new PoiFilterListItem(PoiFilterListItemType.DIVIDER, 0, null, -1, false, false, false, null, null));
String categoryIconStr = poiTypes.getPoiAdditionalCategoryIcon(category);
String categoryIconStr = poiTypes.getPoiAdditionalCategoryIconName(category);
int categoryIconId = 0;
if (!Algorithms.isEmpty(categoryIconStr)) {
categoryIconId = RenderingIcons.getBigIconResourceId(categoryIconStr);

View file

@ -604,6 +604,9 @@ public class ContextMenuLayer extends OsmandMapLayer {
if (entry.getKey().startsWith("name:") && !entry.getValue().equals("")) {
names.add(entry.getValue());
}
if (entry.getKey().equals("name") && !entry.getValue().equals("")) {
names.add(entry.getValue());
}
}
LatLon searchLatLon = objectLatLon;
if (searchLatLon == null) {

View file

@ -806,12 +806,12 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode();
boolean routeDialogOpened = MapRouteInfoMenu.isVisible();
boolean trackDialogOpened = TrackDetailsMenu.isVisible();
boolean contextMenuOpened = mapActivity.getContextMenu().shouldShowTopControls();
boolean contextMenuOpened = !mapActivity.getContextMenu().shouldShowTopControls();
boolean showRouteCalculationControls = routePlanningMode ||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
updateMyLocation(rh, routeDialogOpened || trackDialogOpened || !contextMenuOpened);
updateMyLocation(rh, routeDialogOpened || trackDialogOpened || contextMenuOpened);
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode)
&& !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && contextMenuOpened;
&& !isInMovingMarkerMode() && !isInGpxDetailsMode() && !isInMeasurementToolMode() && !isInPlanRouteMode() && !contextMenuOpened;
//routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions);
if (rh.isFollowingMode()) {
routePlanningBtn.setIconResId(R.drawable.map_start_navigation);
@ -826,18 +826,20 @@ public class MapControlsLayer extends OsmandMapLayer {
routePlanningBtn.updateVisibility(showButtons);
menuControl.updateVisibility(showButtons);
mapZoomIn.updateVisibility(!routeDialogOpened && contextMenuOpened);
mapZoomOut.updateVisibility(!routeDialogOpened && contextMenuOpened);
compassHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && shouldShowCompass()
&& !isInMeasurementToolMode() && !isInPlanRouteMode() && contextMenuOpened);
mapZoomIn.updateVisibility(!routeDialogOpened && !contextMenuOpened);
mapZoomOut.updateVisibility(!routeDialogOpened && !contextMenuOpened);
boolean forceHideCompass = routeDialogOpened || trackDialogOpened
|| isInMeasurementToolMode() || isInPlanRouteMode() || contextMenuOpened;
compassHud.forceHideCompass = forceHideCompass;
compassHud.updateVisibility(!forceHideCompass && shouldShowCompass());
if (layersHud.setIconResId(settings.getApplicationMode().getMapIconId())) {
layersHud.update(app, isNight);
}
layersHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode()
&& contextMenuOpened);
&& !contextMenuOpened);
quickSearchHud.updateVisibility(!routeDialogOpened && !trackDialogOpened && !isInMeasurementToolMode() && !isInPlanRouteMode()
&& contextMenuOpened);
&& !contextMenuOpened);
if (!routePlanningMode && !routeFollowingMode) {
if (mapView.isZooming()) {
@ -854,7 +856,9 @@ public class MapControlsLayer extends OsmandMapLayer {
}
mapRouteInfoMenu.setVisible(showRouteCalculationControls);
updateCompass(isNight);
if (!forceHideCompass) {
updateCompass(isNight);
}
for (MapHudButton mc : controls) {
mc.update(mapActivity.getMyApplication(), isNight);
@ -1027,6 +1031,7 @@ public class MapControlsLayer extends OsmandMapLayer {
boolean f = true;
boolean compass;
boolean compassOutside;
boolean forceHideCompass;
ViewPropertyAnimatorCompat hideAnimator;
public MapHudButton setRoundTransparent() {
@ -1088,9 +1093,10 @@ public class MapControlsLayer extends OsmandMapLayer {
iv.setVisibility(View.VISIBLE);
iv.invalidate();
} else if (hideAnimator == null) {
if (compass) {
if (compass && !forceHideCompass) {
hideDelayed(5000);
} else {
forceHideCompass = false;
iv.setVisibility(View.GONE);
iv.invalidate();
}

View file

@ -130,7 +130,6 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
private float mapRatioX;
private float mapRatioY;
private LatLon originalRatioCenterLatLon;
private boolean showMapPosition = true;
@ -496,16 +495,20 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
public void setCustomMapRatio(float ratioX, float ratioY) {
this.mapRatioX = ratioX;
this.mapRatioY = ratioY;
originalRatioCenterLatLon = currentViewport.getCenterLatLon();
}
public void restoreMapRatio() {
RotatedTileBox box = currentViewport.copy();
float rx = (float)box.getCenterPixelX() / box.getPixWidth();
float ry = (float)box.getCenterPixelY() / box.getPixHeight();
if (mapPosition == OsmandSettings.BOTTOM_CONSTANT) {
ry -= 0.35;
}
box.setCenterLocation(rx, ry);
LatLon screenCenter = box.getLatLonFromPixel(box.getPixWidth() / 2, box.getPixHeight() / 2);
mapRatioX = 0;
mapRatioY = 0;
if (originalRatioCenterLatLon != null) {
setLatLon(originalRatioCenterLatLon.getLatitude(), originalRatioCenterLatLon.getLongitude());
originalRatioCenterLatLon = null;
}
setLatLon(screenCenter.getLatitude(), screenCenter.getLongitude());
}
public boolean hasCustomMapRatio() {

View file

@ -16,6 +16,7 @@ import android.graphics.drawable.Drawable;
import android.hardware.GeomagneticField;
import android.os.BatteryManager;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.text.format.DateFormat;
import android.view.View;
import android.view.ViewGroup;
@ -55,6 +56,7 @@ import net.osmand.router.RouteResultPreparation;
import net.osmand.router.TurnType;
import net.osmand.util.Algorithms;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@ -1191,6 +1193,7 @@ public class RouteInfoWidgetsFactory {
private View layout;
private ImageView icon;
private TextView text;
private TextView bottomText;
private OsmandSettings settings;
private RoutingHelper rh;
private MapViewTrackingUtilities trackingUtilities;
@ -1198,11 +1201,13 @@ public class RouteInfoWidgetsFactory {
private WaypointHelper wh;
private int imgId;
private String textString;
private String bottomTextString;
public AlarmWidget(final OsmandApplication app, MapActivity ma) {
layout = ma.findViewById(R.id.map_alarm_warning);
icon = (ImageView) ma.findViewById(R.id.map_alarm_warning_icon);
text = (TextView) ma.findViewById(R.id.map_alarm_warning_text);
bottomText = (TextView) ma.findViewById(R.id.map_alarm_warning_text_bottom);
settings = app.getSettings();
rh = ma.getRoutingHelper();
trackingUtilities = ma.getMapViewTrackingUtilities();
@ -1214,6 +1219,7 @@ public class RouteInfoWidgetsFactory {
boolean trafficWarnings = settings.SHOW_TRAFFIC_WARNINGS.get();
boolean cams = settings.SHOW_CAMERAS.get();
boolean peds = settings.SHOW_PEDESTRIAN.get();
boolean tunnels = settings.SHOW_TUNNELS.get();
boolean visible = false;
if ((rh.isFollowingMode() || trackingUtilities.isMapLinkedToLocation())
&& (trafficWarnings || cams)) {
@ -1232,6 +1238,7 @@ public class RouteInfoWidgetsFactory {
if(alarm != null) {
int locimgId = R.drawable.warnings_limit;
String text = "";
String bottomText = "";
if(alarm.getType() == AlarmInfoType.SPEED_LIMIT) {
if(settings.DRIVING_REGION.get().americanSigns){
locimgId = R.drawable.warnings_speed_limit_us;
@ -1271,8 +1278,16 @@ public class RouteInfoWidgetsFactory {
} else {
locimgId = R.drawable.warnings_pedestrian;
}
} else if(alarm.getType() == AlarmInfoType.TUNNEL) {
if(settings.DRIVING_REGION.get().americanSigns){
locimgId = R.drawable.warnings_tunnel_us;
} else {
locimgId = R.drawable.warnings_tunnel;
}
bottomText = OsmAndFormatter.getFormattedAlarmInfoDistance(settings.getContext(), alarm.getFloatValue());
} else {
text = null;
bottomText = null;
}
visible = (text != null && text.length() > 0) || (locimgId != 0);
if (visible) {
@ -1280,6 +1295,8 @@ public class RouteInfoWidgetsFactory {
visible = cams;
} else if (alarm.getType() == AlarmInfoType.PEDESTRIAN) {
visible = peds;
} else if (alarm.getType() == AlarmInfoType.TUNNEL) {
visible = tunnels;
} else {
visible = trafficWarnings;
}
@ -1292,7 +1309,13 @@ public class RouteInfoWidgetsFactory {
if (!Algorithms.objectEquals(text, this.textString)) {
textString = text;
this.text.setText(this.textString);
}
}
if (!Algorithms.objectEquals(bottomText, this.bottomTextString)) {
bottomTextString = bottomText;
this.bottomText.setText(this.bottomTextString);
this.bottomText.setTextColor(ContextCompat.getColor(layout.getContext(),
settings.DRIVING_REGION.get().americanSigns ? R.color.color_black : R.color.color_white));
}
}
}
}