Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-01-08 19:07:46 +01:00
commit e3b4ceb3c6
25 changed files with 1480 additions and 410 deletions

View file

@ -52,13 +52,13 @@
android:layout_gravity="start" android:layout_gravity="start"
android:visibility="gone" > android:visibility="gone" >
<com.github.ksoichiro.android.observablescrollview.ObservableListView <net.osmand.plus.views.controls.DynamicListView
android:id="@+id/dash_list_view" android:id="@+id/dash_list_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/bg_color" android:background="?attr/bg_color"
android:fadeScrollbars="true" > android:fadeScrollbars="true" >
</com.github.ksoichiro.android.observablescrollview.ObservableListView> </net.osmand.plus.views.controls.DynamicListView>
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>

View file

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@+id/plan_route_info" <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/plan_route_info"
android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent" android:layout_width="match_parent"
android:clickable="true" android:layout_height="match_parent"
android:background="@color/color_transparent"> android:background="@color/color_transparent"
android:clickable="true">
<LinearLayout <LinearLayout
android:id="@+id/main_view" android:id="@+id/main_view"
@ -18,53 +19,47 @@
<LinearLayout <LinearLayout
android:id="@+id/ModesLayout" android:id="@+id/ModesLayout"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="@dimen/list_item_height" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<FrameLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content"> android:layout_height="@dimen/list_item_height"
android:orientation="horizontal">
<View
android:id="@+id/dividerModesLayout"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="bottom"
android:background="@color/dashboard_divider_dark"
android:focusable="false"/>
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:id="@+id/app_modes"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="left"
android:orientation="horizontal"/>
<LinearLayout <LinearLayout
android:id="@+id/app_modes" android:layout_width="wrap_content"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
android:layout_gravity="center_vertical" android:layout_marginLeft="@dimen/list_content_padding"
android:layout_weight="1" android:orientation="horizontal"
android:gravity="left" android:visibility="gone">
android:orientation="horizontal"/>
<LinearLayout <ImageView
android:layout_width="wrap_content" android:id="@+id/waypoints"
android:layout_height="wrap_content" android:layout_width="@dimen/list_item_height"
android:layout_gravity="center_horizontal" android:layout_height="@dimen/list_item_height"
android:layout_marginLeft="@dimen/list_content_padding" android:background="?attr/dashboard_button"
android:orientation="horizontal" android:scaleType="center"
android:visibility="gone"> android:src="@drawable/map_action_waypoints"/>
<ImageView
android:id="@+id/waypoints"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:background="?attr/dashboard_button"
android:scaleType="center"
android:src="@drawable/map_action_waypoints"/>
</LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </LinearLayout>
<View
android:id="@+id/dividerModesLayout"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dashboard_divider_dark"
android:focusable="false"/>
</LinearLayout> </LinearLayout>
<ScrollView <ScrollView
@ -252,8 +247,8 @@
android:id="@+id/Info" android:id="@+id/Info"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="@dimen/list_item_height"
android:background="?attr/dashboard_button" android:background="?attr/dashboard_button"
android:minHeight="@dimen/list_item_height"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
@ -269,9 +264,9 @@
android:id="@+id/InfoIcon" android:id="@+id/InfoIcon"
android:layout_width="@dimen/standard_icon_size" android:layout_width="@dimen/standard_icon_size"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/list_content_padding" android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding" android:layout_marginRight="@dimen/list_content_padding"
android:layout_gravity="center_vertical"
android:contentDescription="@string/info_button" android:contentDescription="@string/info_button"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_action_info_dark"/> android:src="@drawable/ic_action_info_dark"/>
@ -309,9 +304,9 @@
android:id="@+id/DurationIcon" android:id="@+id/DurationIcon"
android:layout_width="@dimen/standard_icon_size" android:layout_width="@dimen/standard_icon_size"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/list_content_padding" android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding" android:layout_marginRight="@dimen/list_content_padding"
android:layout_gravity="center_vertical"
android:contentDescription="@string/info_button" android:contentDescription="@string/info_button"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_action_time"/> android:src="@drawable/ic_action_time"/>
@ -350,8 +345,8 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical|left" android:layout_gravity="center_vertical|left"
android:layout_weight="1"
android:layout_margin="8dp" android:layout_margin="8dp"
android:layout_weight="1"
android:textSize="@dimen/default_desc_text_size"/> android:textSize="@dimen/default_desc_text_size"/>
<ImageView <ImageView

View file

@ -61,12 +61,12 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/bg_color" /> android:background="?attr/bg_color" />
<com.github.ksoichiro.android.observablescrollview.ObservableListView <net.osmand.plus.views.controls.DynamicListView
android:id="@+id/dash_list_view" android:id="@+id/dash_list_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:fadeScrollbars="true" > android:fadeScrollbars="true" >
</com.github.ksoichiro.android.observablescrollview.ObservableListView> </net.osmand.plus.views.controls.DynamicListView>
</FrameLayout> </FrameLayout>
<include layout="@layout/dashboard_toolbar"/> <include layout="@layout/dashboard_toolbar"/>

View file

@ -5,7 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:minHeight="40dp" android:minHeight="48dp"
android:layout_marginBottom="5dp"> android:layout_marginBottom="5dp">
<ImageView <ImageView
@ -24,15 +24,16 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:textSize="@dimen/default_list_text_size" /> android:textSize="@dimen/default_desc_text_size" />
<TextView <TextView
android:id="@+id/description" android:id="@+id/description"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="@dimen/default_list_text_size" android:textStyle="bold"
android:textColor="@color/sherpafy_selection" android:textSize="@dimen/default_desc_text_size"
android:textColor="@color/color_myloc_distance"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginRight="8dp" /> android:layout_marginRight="16dp" />
</LinearLayout> </LinearLayout>

View file

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:minHeight="50dp"
android:layout_marginBottom="5dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:text="@string/search_radius_proximity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="@dimen/default_desc_text_size" />
<TextView
android:id="@+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="@dimen/default_desc_text_size"
android:textColor="@color/color_myloc_distance"
android:layout_gravity="center_vertical"
android:layout_marginTop="2dp"
android:text="500 m"
android:layout_marginRight="16dp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/titleEx"
android:text="@string/shared_string_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textSize="@dimen/default_desc_text_size" />
<TextView
android:id="@+id/descriptionEx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="@dimen/default_desc_text_size"
android:textColor="@color/color_myloc_distance"
android:layout_gravity="center_vertical"
android:layout_marginTop="2dp"
android:text="Cinema"
android:layout_marginRight="16dp" />
</LinearLayout>
</LinearLayout>

View file

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout android:id="@+id/plan_route_info" <FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/plan_route_info"
android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent" android:layout_width="match_parent"
android:clickable="true" android:layout_height="match_parent"
android:background="@color/color_transparent"> android:background="@color/color_transparent"
android:clickable="true">
<LinearLayout <LinearLayout
android:id="@+id/main_view" android:id="@+id/main_view"
@ -18,53 +19,46 @@
<LinearLayout <LinearLayout
android:id="@+id/ModesLayout" android:id="@+id/ModesLayout"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="@dimen/list_item_height" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<FrameLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content"> android:layout_height="@dimen/list_item_height"
android:orientation="horizontal">
<View
android:id="@+id/dividerModesLayout"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_gravity="bottom"
android:background="@color/dashboard_divider_dark"
android:focusable="false"/>
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:id="@+id/app_modes"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="left"
android:orientation="horizontal"/>
<LinearLayout <LinearLayout
android:id="@+id/app_modes" android:layout_width="wrap_content"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="center_horizontal"
android:layout_gravity="center_vertical" android:layout_marginLeft="@dimen/list_content_padding"
android:layout_weight="1" android:orientation="horizontal"
android:gravity="left" android:visibility="gone">
android:orientation="horizontal"/>
<LinearLayout <ImageView
android:layout_width="wrap_content" android:id="@+id/waypoints"
android:layout_height="wrap_content" android:layout_width="@dimen/list_item_height"
android:layout_gravity="center_horizontal" android:layout_height="@dimen/list_item_height"
android:layout_marginLeft="@dimen/list_content_padding" android:background="?attr/dashboard_button"
android:orientation="horizontal" android:scaleType="center"
android:visibility="gone"> android:src="@drawable/map_action_waypoints"/>
<ImageView
android:id="@+id/waypoints"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:background="?attr/dashboard_button"
android:scaleType="center"
android:src="@drawable/map_action_waypoints"/>
</LinearLayout>
</LinearLayout> </LinearLayout>
</FrameLayout> </LinearLayout>
<View
android:id="@+id/dividerModesLayout"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/dashboard_divider_dark"
android:focusable="false"/>
</LinearLayout> </LinearLayout>
<ScrollView <ScrollView
@ -252,8 +246,8 @@
android:id="@+id/Info" android:id="@+id/Info"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="@dimen/list_item_height"
android:background="?attr/dashboard_button" android:background="?attr/dashboard_button"
android:minHeight="@dimen/list_item_height"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
@ -269,9 +263,9 @@
android:id="@+id/InfoIcon" android:id="@+id/InfoIcon"
android:layout_width="@dimen/standard_icon_size" android:layout_width="@dimen/standard_icon_size"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/list_content_padding" android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding" android:layout_marginRight="@dimen/list_content_padding"
android:layout_gravity="center_vertical"
android:contentDescription="@string/info_button" android:contentDescription="@string/info_button"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_action_info_dark"/> android:src="@drawable/ic_action_info_dark"/>
@ -309,9 +303,9 @@
android:id="@+id/DurationIcon" android:id="@+id/DurationIcon"
android:layout_width="@dimen/standard_icon_size" android:layout_width="@dimen/standard_icon_size"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/list_content_padding" android:layout_marginLeft="@dimen/list_content_padding"
android:layout_marginRight="@dimen/list_content_padding" android:layout_marginRight="@dimen/list_content_padding"
android:layout_gravity="center_vertical"
android:contentDescription="@string/info_button" android:contentDescription="@string/info_button"
android:scaleType="center" android:scaleType="center"
android:src="@drawable/ic_action_time"/> android:src="@drawable/ic_action_time"/>

View file

@ -1,13 +1,14 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:layout_marginRight="3dp" android:paddingRight="16dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:minHeight="40dp" android:minHeight="48dp"
android:orientation="horizontal"> android:orientation="horizontal">
<ProgressBar <ProgressBar
@ -17,16 +18,17 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"/> android:layout_marginLeft="4dp"/>
<TextView <net.osmand.plus.widgets.TextViewEx
android:id="@+id/header_text" android:id="@+id/header_text"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="8dp" android:layout_marginLeft="16dp"
android:layout_weight="1" android:layout_weight="1"
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true" android:singleLine="true"
android:textSize="@dimen/default_list_text_size_large"/> style="@style/DashboardSubHeader"
osmand:typeface="@string/font_roboto_medium"/>
<include layout="@layout/check_item_rel"/> <include layout="@layout/check_item_rel"/>

View file

@ -3,63 +3,103 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:background="@drawable/view_transparent_selection" android:background="@drawable/view_transparent_selection"
android:id="@+id/package_delivered_layout" android:id="@+id/package_delivered_layout"
android:minHeight="48dp" android:minHeight="50dp"
android:descendantFocusability="blocksDescendants"> android:descendantFocusability="blocksDescendants">
<ImageView <ImageView
android:id="@+id/waypoint_icon" android:id="@+id/waypoint_icon"
android:layout_marginLeft="8dp"
android:src="@drawable/ic_action_fav_dark" android:src="@drawable/ic_action_fav_dark"
android:layout_height="25dp" android:layout_height="25dp"
android:layout_width="25dp" android:layout_width="56dp"
android:layout_gravity="center_vertical" /> android:layout_gravity="center_vertical" />
<TextView <LinearLayout
android:id="@+id/waypoint_dist"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_gravity="center_vertical"
android:textColor="@color/wpt_distance_color"
android:maxLines="2"
android:textStyle="bold"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
android:id="@+id/waypoint_text"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:maxLines="2"
android:ellipsize="end"
android:layout_gravity="center_vertical"
android:layout_weight="1" android:layout_weight="1"
android:textSize="@dimen/default_list_text_size" /> android:gravity="center"
android:layout_gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/waypoint_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="2"
android:ellipsize="end"
android:layout_gravity="center_vertical"
android:textSize="@dimen/default_list_text_size" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:orientation="horizontal">
<TextView
android:id="@+id/waypoint_dist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:textColor="@color/color_myloc_distance"
android:maxLines="1"
android:textSize="@dimen/default_sub_text_size"/>
<TextView
android:id="@+id/waypoint_desc_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:layout_gravity="bottom"
android:layout_weight="1"
android:textColor="@color/secondary_text_dark"
android:textSize="@dimen/default_sub_text_size" />
</LinearLayout>
</LinearLayout>
<ImageButton <ImageButton
android:id="@+id/all_points" android:id="@+id/all_points"
android:layout_width="wrap_content" android:layout_width="48dp"
android:layout_height="wrap_content" android:layout_height="48dp"
android:contentDescription="@string/shared_string_more" android:contentDescription="@string/shared_string_more"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginRight="2dp"
android:visibility="gone" android:visibility="gone"
android:focusable="false" android:focusable="false"
android:scaleType="center"
style="@style/Widget.AppCompat.ActionButton" style="@style/Widget.AppCompat.ActionButton"
android:src="@drawable/ic_action_core_overflow_dark" /> android:src="@drawable/map_overflow_menu_white" />
<ImageButton <ImageButton
android:id="@+id/info_close" android:id="@+id/info_close"
android:layout_width="wrap_content" android:layout_width="48dp"
android:layout_height="wrap_content" android:layout_height="48dp"
android:contentDescription="@string/shared_string_close" android:contentDescription="@string/shared_string_close"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginRight="4dp" android:layout_marginRight="2dp"
style="@style/Widget.AppCompat.ActionButton" style="@style/Widget.AppCompat.ActionButton"
android:focusable="false" android:focusable="false"
android:src="@drawable/ic_action_gremove_dark" /> android:scaleType="center"
android:src="@drawable/ic_action_remove_dark" />
<ImageView
android:id="@+id/info_move"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:layout_marginRight="2dp"
android:focusable="false"
android:clickable="false"
android:scaleType="center"
android:src="@drawable/ic_flat_list_dark"
android:tag="DragIcon"
android:visibility="gone"/>
</LinearLayout> </LinearLayout>

View file

@ -9,6 +9,8 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="shared_string_type">Type</string>
<string name="starting_point">Starting point</string>
<string name="shared_string_not_selected">Not selected</string> <string name="shared_string_not_selected">Not selected</string>
<string name="rec_split">Recorder Split</string> <string name="rec_split">Recorder Split</string>
<string name="rec_split_title">Use Recorder Split</string> <string name="rec_split_title">Use Recorder Split</string>

View file

@ -83,8 +83,13 @@ public class CurrentPositionHelper {
} }
} }
}; };
if (!app.getRoutingHelper().startTaskInRouteThreadIfPossible(run) && result != null) { if (!app.getRoutingHelper().startTaskInRouteThreadIfPossible(run)) {
result.publish(null); if (result != null) {
result.publish(null);
}
if (geoCoding != null) {
geoCoding.publish(null);
}
} }
} }
} }

View file

@ -29,6 +29,7 @@ public class TargetPointsHelper {
private PointDescription pointDescription; private PointDescription pointDescription;
public int index; public int index;
public boolean intermediate; public boolean intermediate;
public boolean start;
public TargetPoint(LatLon point, PointDescription name) { public TargetPoint(LatLon point, PointDescription name) {
this.point = point; this.point = point;
@ -67,6 +68,14 @@ public class TargetPointsHelper {
return null; return null;
} }
public static TargetPoint createStartPoint(LatLon point, PointDescription name) {
if (point != null) {
TargetPoint target = new TargetPoint(point, name);
target.start = true;
return target;
}
return null;
}
public double getLatitude() { public double getLatitude() {
return point.getLatitude(); return point.getLatitude();
@ -97,7 +106,7 @@ public class TargetPointsHelper {
private void readFromSettings(OsmandSettings settings) { private void readFromSettings(OsmandSettings settings) {
pointToNavigate = TargetPoint.create(settings.getPointToNavigate(), settings.getPointNavigateDescription()); pointToNavigate = TargetPoint.create(settings.getPointToNavigate(), settings.getPointNavigateDescription());
pointToStart = TargetPoint.create(settings.getPointToStart(), settings.getStartPointDescription()); pointToStart = TargetPoint.createStartPoint(settings.getPointToStart(), settings.getStartPointDescription());
intermediatePoints.clear(); intermediatePoints.clear();
List<LatLon> ips = settings.getIntermediatePoints(); List<LatLon> ips = settings.getIntermediatePoints();
List<String> desc = settings.getIntermediatePointDescriptions(ips.size()); List<String> desc = settings.getIntermediatePointDescriptions(ips.size());
@ -285,7 +294,7 @@ public class TargetPointsHelper {
} }
public void reorderAllTargetPoints(List<TargetPoint> point, boolean updateRoute){ public void reorderAllTargetPoints(List<TargetPoint> point, boolean updateRoute) {
settings.clearPointToNavigate(); settings.clearPointToNavigate();
if (point.size() > 0) { if (point.size() > 0) {
List<TargetPoint> subList = point.subList(0, point.size() - 1); List<TargetPoint> subList = point.subList(0, point.size() - 1);

View file

@ -102,11 +102,11 @@ public class MapActivityActions implements DialogProvider {
TargetPointsHelper targets = getMyApplication().getTargetPointsHelper(); TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
targets.navigateToPoint(new LatLon(latitude, longitude), true, targets.getIntermediatePoints().size() + 1, targets.navigateToPoint(new LatLon(latitude, longitude), true, targets.getIntermediatePoints().size() + 1,
pd); pd);
openIntermediateEditPointsDialog(); openIntermediatePointsDialog();
} }
public void editWaypoints() { public void editWaypoints() {
openIntermediateEditPointsDialog(); openIntermediatePointsDialog();
} }
private Bundle enhance(Bundle aBundle, double latitude, double longitude, String name) { private Bundle enhance(Bundle aBundle, double latitude, double longitude, String name) {

View file

@ -96,7 +96,7 @@ public class DashWaypointsFragment extends DashLocationFragment {
View dv = getActivity().getLayoutInflater().inflate(R.layout.divider, null); View dv = getActivity().getLayoutInflater().inflate(R.layout.divider, null);
favorites.addView(dv); favorites.addView(dv);
View v = WaypointDialogHelper.updateWaypointItemView(false, null, getMyApplication(), View v = WaypointDialogHelper.updateWaypointItemView(false, null, getMyApplication(),
getActivity(), null, ps, null, !getMyApplication().getSettings().isLightContent()); getActivity(), null, ps, null, !getMyApplication().getSettings().isLightContent(), true);
favorites.addView(v); favorites.addView(v);
} }
@ -142,7 +142,21 @@ public class DashWaypointsFragment extends DashLocationFragment {
view.findViewById(R.id.group_image).setVisibility(View.GONE); view.findViewById(R.id.group_image).setVisibility(View.GONE);
boolean target = helper.getPointToNavigate() == point; boolean target = helper.getPointToNavigate() == point;
int id = target ? R.drawable.list_destination : R.drawable.list_intermediate; int id;
if (!target) {
if (getMyApplication().getSettings().isLightContent()) {
id = R.drawable.widget_intermediate_day;
} else {
id = R.drawable.widget_intermediate_night;
}
} else {
if (getMyApplication().getSettings().isLightContent()) {
id = R.drawable.widget_target_day;
} else {
id = R.drawable.widget_target_night;
}
}
((ImageView) view.findViewById(R.id.favourite_icon)).setImageDrawable(getMyApplication().getIconsCache() ((ImageView) view.findViewById(R.id.favourite_icon)).setImageDrawable(getMyApplication().getIconsCache()
.getIcon(id, 0)); .getIcon(id, 0));
DashLocationView dv = new DashLocationView(direction, label, new LatLon(point.getLatitude(), DashLocationView dv = new DashLocationView(direction, label, new LatLon(point.getLatitude(),

View file

@ -35,6 +35,7 @@ import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCal
import com.github.ksoichiro.android.observablescrollview.ScrollState; import com.github.ksoichiro.android.observablescrollview.ScrollState;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.ValueHolder;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
@ -44,7 +45,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.IntermediatePointsDialog; import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dashboard.tools.DashFragmentData; import net.osmand.plus.dashboard.tools.DashFragmentData;
import net.osmand.plus.dashboard.tools.DashboardSettingsDialogFragment; import net.osmand.plus.dashboard.tools.DashboardSettingsDialogFragment;
@ -57,8 +58,12 @@ import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu; import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu;
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu.LocalRoutingParameter; import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu.LocalRoutingParameter;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
import net.osmand.plus.views.DownloadedRegionsLayer; import net.osmand.plus.views.DownloadedRegionsLayer;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.controls.DynamicListView;
import net.osmand.plus.views.controls.DynamicListViewCallbacks;
import net.osmand.plus.views.controls.StableArrayAdapter;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
@ -72,7 +77,7 @@ import static android.util.TypedValue.COMPLEX_UNIT_DIP;
/** /**
*/ */
public class DashboardOnMap implements ObservableScrollViewCallbacks { public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicListViewCallbacks, IRouteInformationListener {
private static final org.apache.commons.logging.Log LOG = private static final org.apache.commons.logging.Log LOG =
PlatformUtil.getLog(DashboardOnMap.class); PlatformUtil.getLog(DashboardOnMap.class);
private static final String TAG = "DashboardOnMap"; private static final String TAG = "DashboardOnMap";
@ -182,6 +187,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
toolbar = ((Toolbar) dashboardView.findViewById(R.id.toolbar)); toolbar = ((Toolbar) dashboardView.findViewById(R.id.toolbar));
ObservableScrollView scrollView = ((ObservableScrollView) dashboardView.findViewById(R.id.main_scroll)); ObservableScrollView scrollView = ((ObservableScrollView) dashboardView.findViewById(R.id.main_scroll));
listView = (ListView) dashboardView.findViewById(R.id.dash_list_view); listView = (ListView) dashboardView.findViewById(R.id.dash_list_view);
listView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
((DynamicListView) listView).setDynamicListViewCallbacks(this);
gradientToolbar = mapActivity.getResources().getDrawable(R.drawable.gradient_toolbar).mutate(); gradientToolbar = mapActivity.getResources().getDrawable(R.drawable.gradient_toolbar).mutate();
if (AndroidUiHelper.isOrientationPortrait(mapActivity)) { if (AndroidUiHelper.isOrientationPortrait(mapActivity)) {
this.portrait = true; this.portrait = true;
@ -211,7 +218,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM)); FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM));
shadow.setScaleType(ScaleType.FIT_XY); shadow.setScaleType(ScaleType.FIT_XY);
shadowContainer.addView(shadow); shadowContainer.addView(shadow);
((FrameLayout)paddingView).addView(shadowContainer); ((FrameLayout) paddingView).addView(shadowContainer);
listView.addHeaderView(paddingView); listView.addHeaderView(paddingView);
listBackgroundView = mapActivity.findViewById(R.id.dash_list_background); listBackgroundView = mapActivity.findViewById(R.id.dash_list_background);
} }
@ -248,8 +255,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
TextView tv = (TextView) dashboardView.findViewById(R.id.toolbar_text); TextView tv = (TextView) dashboardView.findViewById(R.id.toolbar_text);
tv.setText(""); tv.setText("");
boolean waypointsVisible = visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT; boolean waypointsVisible = visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT;
boolean waypointsEdit = visibleType == DashboardType.WAYPOINTS_EDIT; if (waypointsVisible) {
if (waypointsVisible || waypointsEdit) {
tv.setText(R.string.waypoints); tv.setText(R.string.waypoints);
} else if (visibleType == DashboardType.CONFIGURE_MAP) { } else if (visibleType == DashboardType.CONFIGURE_MAP) {
tv.setText(R.string.configure_map); tv.setText(R.string.configure_map);
@ -283,25 +289,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}); });
if (waypointsVisible && getMyApplication().getWaypointHelper().getAllPoints().size() > 0) { if (waypointsVisible && getMyApplication().getWaypointHelper().getAllPoints().size() > 0) {
if (mapActivity.getMyApplication().getTargetPointsHelper().getIntermediatePoints().size() > 0) {
sort.setVisibility(View.VISIBLE);
sort.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hideDashboard();
IntermediatePointsDialog.openIntermediatePointsDialog(mapActivity, getMyApplication(), true);
}
});
}
edit.setVisibility(View.VISIBLE);
edit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setDashboardVisibility(true, DashboardType.WAYPOINTS_EDIT);
}
});
if (getMyApplication().getWaypointHelper().isRouteCalculated()) { if (getMyApplication().getWaypointHelper().isRouteCalculated()) {
flat.setVisibility(View.VISIBLE); flat.setVisibility(View.VISIBLE);
final boolean flatNow = visibleType == DashboardType.WAYPOINTS_FLAT; final boolean flatNow = visibleType == DashboardType.WAYPOINTS_FLAT;
@ -317,17 +304,17 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}); });
} }
} }
if (waypointsEdit) { // if (waypointsEdit) {
ok.setVisibility(View.VISIBLE); // ok.setVisibility(View.VISIBLE);
ok.setOnClickListener(new View.OnClickListener() { // ok.setOnClickListener(new View.OnClickListener() {
//
@Override // @Override
public void onClick(View v) { // public void onClick(View v) {
mapActivity.getMyApplication().getWaypointHelper().removeVisibleLocationPoint(deletedPoints); mapActivity.getMyApplication().getWaypointHelper().removeVisibleLocationPoint(deletedPoints);
hideDashboard(); // hideDashboard();
} // }
}); // });
} // }
if (visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.LIST_MENU) { if (visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.LIST_MENU) {
settingsButton.setVisibility(View.VISIBLE); settingsButton.setVisibility(View.VISIBLE);
settingsButton.setOnClickListener(new View.OnClickListener() { settingsButton.setOnClickListener(new View.OnClickListener() {
@ -552,7 +539,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
open(dashboardView.findViewById(R.id.animateContent), animation); open(dashboardView.findViewById(R.id.animateContent), animation);
updateLocation(true, true, false); updateLocation(true, true, false);
// addOrUpdateDashboardFragments(); // addOrUpdateDashboardFragments();
mapActivity.getRoutingHelper().addListener(this);
} else { } else {
mapActivity.getRoutingHelper().removeListener(this);
mapActivity.getMapViewTrackingUtilities().setDashboard(null); mapActivity.getMapViewTrackingUtilities().setDashboard(null);
hide(dashboardView.findViewById(R.id.animateContent), animation); hide(dashboardView.findViewById(R.id.animateContent), animation);
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE); mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.VISIBLE);
@ -607,10 +596,15 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
private void updateListAdapter() { private void updateListAdapter() {
ContextMenuAdapter cm = null; ContextMenuAdapter cm = null;
if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) { if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) {
ArrayAdapter<Object> listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(false, deletedPoints, mapActivity, running, StableArrayAdapter listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(true, deletedPoints, mapActivity, running,
DashboardType.WAYPOINTS_FLAT == visibleType, nightMode); DashboardType.WAYPOINTS_FLAT == visibleType, nightMode);
OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running, OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running,
listAdapter); listAdapter);
DynamicListView dynamicListView = (DynamicListView) listView;
dynamicListView.setItemsList(listAdapter.getObjects());
dynamicListView.setActiveItemsList(listAdapter.getActiveObjects());
updateListAdapter(listAdapter, listener); updateListAdapter(listAdapter, listener);
} else if (DashboardType.WAYPOINTS_EDIT == visibleType) { } else if (DashboardType.WAYPOINTS_EDIT == visibleType) {
deletedPoints.clear(); deletedPoints.clear();
@ -643,7 +637,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls(); boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
if (this.nightMode != nightMode) { if (this.nightMode != nightMode) {
this.nightMode = nightMode; this.nightMode = nightMode;
applyDayNightMode(); applyDayNightMode();
} }
final ArrayAdapter<?> listAdapter = cm.createListAdapter(mapActivity, !nightMode); final ArrayAdapter<?> listAdapter = cm.createListAdapter(mapActivity, !nightMode);
OnItemClickListener listener = getOptionsMenuOnClickListener(cm, listAdapter); OnItemClickListener listener = getOptionsMenuOnClickListener(cm, listAdapter);
@ -1087,4 +1081,54 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
return settings.registerBooleanPreference(SHOULD_SHOW + tag, true).makeGlobal().get(); return settings.registerBooleanPreference(SHOULD_SHOW + tag, true).makeGlobal().get();
} }
} }
@Override
public void onItemsSwapped(final List<Object> items) {
getMyApplication().runInUIThread(new Runnable() {
@Override
public void run() {
if (visibleType == DashboardType.WAYPOINTS) {
List<TargetPoint> allTargets = new ArrayList<>();
if (items != null) {
for (Object obj : items) {
if (obj instanceof LocationPointWrapper) {
LocationPointWrapper p = (LocationPointWrapper) obj;
if (p.getPoint() instanceof TargetPoint) {
TargetPoint t = (TargetPoint) p.getPoint();
if (!t.start) {
t.intermediate = true;
allTargets.add(t);
}
}
}
}
if (allTargets.size() > 0) {
allTargets.get(allTargets.size() - 1).intermediate = false;
}
}
getMyApplication().getTargetPointsHelper().reorderAllTargetPoints(allTargets, false);
newRouteIsCalculated(false, null);
getMyApplication().getTargetPointsHelper().updateRouteAndReferesh(true);
}
}
}, 50);
}
@Override
public void newRouteIsCalculated(boolean newRoute, ValueHolder<Boolean> showToast) {
if ((DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType)
&& listAdapter != null && listAdapter instanceof StableArrayAdapter) {
StableArrayAdapter stableAdapter = (StableArrayAdapter) listAdapter;
waypointDialogHelper.reloadListAdapter(stableAdapter);
if (listView instanceof DynamicListView) {
DynamicListView dynamicListView = (DynamicListView) listView;
dynamicListView.setItemsList(stableAdapter.getObjects());
dynamicListView.setActiveItemsList(stableAdapter.getActiveObjects());
}
}
}
@Override
public void routeWasCancelled() {
}
} }

View file

@ -74,7 +74,7 @@ public class AvoidSpecificRoads {
ImageButton remove = (ImageButton) v.findViewById(R.id.info_close); ImageButton remove = (ImageButton) v.findViewById(R.id.info_close);
remove.setVisibility(View.VISIBLE); remove.setVisibility(View.VISIBLE);
remove.setImageDrawable(app.getIconsCache().getContentIcon( remove.setImageDrawable(app.getIconsCache().getContentIcon(
R.drawable.ic_action_gremove_dark)); R.drawable.ic_action_remove_dark));
remove.setOnClickListener(new View.OnClickListener() { remove.setOnClickListener(new View.OnClickListener() {
@Override @Override

View file

@ -4,8 +4,6 @@ import android.app.Activity;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnDismissListener; import android.content.DialogInterface.OnDismissListener;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
@ -19,18 +17,20 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.LocationPoint; import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.IntermediatePointsDialog;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.controls.StableArrayAdapter;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
@ -62,39 +62,74 @@ public class WaypointDialogHelper {
public static void updatePointInfoView(final OsmandApplication app, final Activity activity, public static void updatePointInfoView(final OsmandApplication app, final Activity activity,
View localView, final LocationPointWrapper ps, View localView, final LocationPointWrapper ps,
final boolean mapCenter, final boolean nightMode) { final boolean mapCenter, final boolean nightMode,
final boolean edit) {
WaypointHelper wh = app.getWaypointHelper(); WaypointHelper wh = app.getWaypointHelper();
final LocationPoint point = ps.getPoint(); final LocationPoint point = ps.getPoint();
TextView text = (TextView) localView.findViewById(R.id.waypoint_text); TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
AndroidUtils.setTextPrimaryColor(activity, text, nightMode); AndroidUtils.setTextPrimaryColor(activity, text, nightMode);
TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow); TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow);
localView.setOnClickListener(new View.OnClickListener() { if (!edit) {
@Override localView.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) { @Override
showOnMap(app, activity, point, mapCenter); public void onClick(View view) {
} showOnMap(app, activity, point, mapCenter);
}); }
TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist); });
((ImageView) localView.findViewById(R.id.waypoint_icon)).setImageDrawable(ps.getDrawable(activity, app));
int dist = -1;
if (!wh.isRouteCalculated()) {
if (activity instanceof MapActivity) {
dist = (int) MapUtils.getDistance(((MapActivity) activity).getMapView().getLatitude(), ((MapActivity) activity)
.getMapView().getLongitude(), point.getLatitude(), point.getLongitude());
}
} else {
dist = wh.getRouteDistance(ps);
} }
TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist);
((ImageView) localView.findViewById(R.id.waypoint_icon)).setImageDrawable(ps.getDrawable(activity, app, nightMode));
int dist = -1;
boolean startPoint = ps.type == WaypointHelper.TARGETS && ((TargetPoint) ps.point).start;
if (!startPoint) {
if (!wh.isRouteCalculated()) {
if (activity instanceof MapActivity) {
dist = (int) MapUtils.getDistance(((MapActivity) activity).getMapView().getLatitude(), ((MapActivity) activity)
.getMapView().getLongitude(), point.getLatitude(), point.getLongitude());
}
} else {
dist = wh.getRouteDistance(ps);
}
}
String pointDescription = "";
TextView descText = (TextView) localView.findViewById(R.id.waypoint_desc_text);
if (descText != null) {
AndroidUtils.setTextSecondaryColor(activity, descText, nightMode);
switch (ps.type) {
case WaypointHelper.TARGETS:
TargetPoint targetPoint = (TargetPoint) ps.point;
if (targetPoint.start) {
pointDescription = activity.getResources().getString(R.string.starting_point);
} else {
pointDescription = targetPoint.getPointDescription(activity).getTypeName();
}
break;
case WaypointHelper.FAVORITES:
FavouritePoint favPoint = (FavouritePoint) ps.point;
pointDescription = favPoint.getCategory();
break;
}
}
if (dist > 0) { if (dist > 0) {
String dd = OsmAndFormatter.getFormattedDistance(dist, app); String dd = OsmAndFormatter.getFormattedDistance(dist, app);
if (ps.deviationDistance > 0) { if (ps.deviationDistance > 0) {
dd += "\n+" + OsmAndFormatter.getFormattedDistance(ps.deviationDistance, app); dd += " +" + OsmAndFormatter.getFormattedDistance(ps.deviationDistance, app);
} }
textDist.setText(dd); textDist.setText(dd);
if (!Algorithms.isEmpty(pointDescription)) {
pointDescription = "" + pointDescription;
}
} else { } else {
textDist.setText(""); textDist.setText("");
} }
if (descText != null) {
descText.setText(pointDescription);
}
String descr; String descr;
PointDescription pd = point.getPointDescription(app); PointDescription pd = point.getPointDescription(app);
if (Algorithms.isEmpty(pd.getName())) { if (Algorithms.isEmpty(pd.getName())) {
@ -113,18 +148,33 @@ public class WaypointDialogHelper {
// 0); // 0);
} }
private List<Object> getActivePoints(List<Object> points) {
List<Object> activePoints = new ArrayList<>();
for (Object p : points) {
if (p instanceof LocationPointWrapper) {
LocationPointWrapper w = (LocationPointWrapper) p;
if (w.type == WaypointHelper.TARGETS && !((TargetPoint) w.point).start) {
activePoints.add(p);
}
}
}
return activePoints;
}
public ArrayAdapter<Object> getWaypointsDrawerAdapter( public StableArrayAdapter getWaypointsDrawerAdapter(
final boolean edit, final List<LocationPointWrapper> deletedPoints, final boolean edit, final List<LocationPointWrapper> deletedPoints,
final MapActivity ctx, final int[] running, final boolean flat, final boolean nightMode) { final MapActivity ctx, final int[] running, final boolean flat, final boolean nightMode) {
final List<Object> points; final List<Object> points;
if (flat) { if (flat) {
points = new ArrayList<Object>(waypointHelper.getAllPoints()); points = new ArrayList<Object>(waypointHelper.getAllPoints());
} else { } else {
points = getPoints(); points = getPoints();
} }
return new ArrayAdapter<Object>(ctx, List<Object> activePoints = getActivePoints(points);
R.layout.waypoint_reached, R.id.title, points) {
return new StableArrayAdapter(ctx,
R.layout.waypoint_reached, R.id.title, points, activePoints) {
@Override @Override
public View getView(final int position, View convertView, ViewGroup parent) { public View getView(final int position, View convertView, ViewGroup parent) {
@ -139,56 +189,76 @@ public class WaypointDialogHelper {
final int type = ((RadiusItem) obj).type; final int type = ((RadiusItem) obj).type;
v = createItemForRadiusProximity(ctx, type, running, position, thisAdapter, nightMode); v = createItemForRadiusProximity(ctx, type, running, position, thisAdapter, nightMode);
//Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_light)); //Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_light));
if (nightMode) { AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
v.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_dark));
} else {
v.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_light));
}
} else if (labelView) { } else if (labelView) {
v = createItemForCategory(ctx, (Integer) obj, running, position, thisAdapter, nightMode); v = createItemForCategory(ctx, (Integer) obj, running, position, thisAdapter, nightMode);
if (nightMode) { AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
v.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_dark));
} else {
v.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_light));
}
} else if (topDividerView) { } else if (topDividerView) {
v = ctx.getLayoutInflater().inflate(R.layout.card_top_divider, null); v = ctx.getLayoutInflater().inflate(R.layout.card_top_divider, null);
} else if (bottomDividerView) { } else if (bottomDividerView) {
v = ctx.getLayoutInflater().inflate(R.layout.card_bottom_divider, null); v = ctx.getLayoutInflater().inflate(R.layout.card_bottom_divider, null);
} else if (obj instanceof LocationPointWrapper) { } else if (obj instanceof LocationPointWrapper) {
LocationPointWrapper point = (LocationPointWrapper) obj; LocationPointWrapper point = (LocationPointWrapper) obj;
v = updateWaypointItemView(edit, deletedPoints, app, ctx, v, point, this, nightMode); v = updateWaypointItemView(edit, deletedPoints, app, ctx, v, point, this,
if (nightMode) { nightMode, flat);
v.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_dark)); AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
} else {
v.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_light));
}
} }
return v; return v;
} }
}; };
} }
public static View updateWaypointItemView(final boolean edit, final List<LocationPointWrapper> deletedPoints, public static View updateWaypointItemView(final boolean edit, final List<LocationPointWrapper> deletedPoints,
final OsmandApplication app, final Activity ctx, View v, final LocationPointWrapper point, final OsmandApplication app, final Activity ctx, View v,
final ArrayAdapter adapter, final boolean nightMode) { final LocationPointWrapper point,
final ArrayAdapter adapter, final boolean nightMode,
final boolean flat) {
if (v == null || v.findViewById(R.id.info_close) == null) { if (v == null || v.findViewById(R.id.info_close) == null) {
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null); v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
} }
updatePointInfoView(app, ctx, v, point, true, nightMode); updatePointInfoView(app, ctx, v, point, true, nightMode, edit);
View more = v.findViewById(R.id.all_points);
View move = v.findViewById(R.id.info_move);
View remove = v.findViewById(R.id.info_close); View remove = v.findViewById(R.id.info_close);
if (!edit) { if (!edit) {
remove.setVisibility(View.GONE); remove.setVisibility(View.GONE);
move.setVisibility(View.GONE);
more.setVisibility(View.GONE);
} else if (point.type == WaypointHelper.TARGETS && !flat) {
if (((TargetPoint) point.point).start) {
remove.setVisibility(View.GONE);
move.setVisibility(View.GONE);
more.setVisibility(View.VISIBLE);
((ImageButton) more).setImageDrawable(app.getIconsCache().getContentIcon(
R.drawable.map_overflow_menu_white, !nightMode));
more.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//hideDashboard();
IntermediatePointsDialog.openIntermediatePointsDialog(ctx, app, true);
}
});
} else {
remove.setVisibility(View.GONE);
move.setVisibility(View.VISIBLE);
more.setVisibility(View.GONE);
((ImageView) move).setImageDrawable(app.getIconsCache().getContentIcon(
R.drawable.ic_flat_list_dark, !nightMode));
}
} else { } else {
remove.setVisibility(View.VISIBLE); remove.setVisibility(View.VISIBLE);
move.setVisibility(View.GONE);
more.setVisibility(View.GONE);
((ImageButton) remove).setImageDrawable(app.getIconsCache().getContentIcon( ((ImageButton) remove).setImageDrawable(app.getIconsCache().getContentIcon(
R.drawable.ic_action_gremove_dark, !nightMode)); R.drawable.ic_action_remove_dark, !nightMode));
remove.setOnClickListener(new View.OnClickListener() { remove.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
ArrayList<LocationPointWrapper> arr = new ArrayList<>();
arr.add(point);
app.getWaypointHelper().removeVisibleLocationPoint(arr);
deletedPoints.add(point); deletedPoints.add(point);
if (adapter != null) { if (adapter != null) {
adapter.remove(point); adapter.remove(point);
@ -204,11 +274,38 @@ public class WaypointDialogHelper {
protected View createItemForRadiusProximity(final FragmentActivity ctx, final int type, final int[] running, protected View createItemForRadiusProximity(final FragmentActivity ctx, final int type, final int[] running,
final int position, final ArrayAdapter<Object> thisAdapter, boolean nightMode) { final int position, final ArrayAdapter<Object> thisAdapter, boolean nightMode) {
View v; View v;
IconsCache iconsCache = app.getIconsCache(); if (type == WaypointHelper.POI) {
v = ctx.getLayoutInflater().inflate(R.layout.drawer_list_radius, null); v = ctx.getLayoutInflater().inflate(R.layout.drawer_list_radius_ex, null);
AndroidUtils.setTextPrimaryColor(mapActivity, (TextView) v.findViewById(R.id.titleEx), nightMode);
String descEx = waypointHelper.getPoiFilter() == null ? ctx.getString(R.string.poi) : waypointHelper
.getPoiFilter().getName();
((TextView) v.findViewById(R.id.title)).setText(ctx.getString(R.string.search_radius_proximity) + ":");
((TextView) v.findViewById(R.id.titleEx)).setText(ctx.getString(R.string.shared_string_type) + ":");
final TextView radiusEx = (TextView) v.findViewById(R.id.descriptionEx);
radiusEx.setText(descEx);
radiusEx.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
running[0] = position;
thisAdapter.notifyDataSetInvalidated();
MapActivity map = (MapActivity) ctx;
final PoiUIFilter[] selected = new PoiUIFilter[1];
AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected);
dlg.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
enableType(running, thisAdapter, type, true);
}
});
}
});
} else {
v = ctx.getLayoutInflater().inflate(R.layout.drawer_list_radius, null);
((TextView) v.findViewById(R.id.title)).setText(ctx.getString(R.string.search_radius_proximity));
}
AndroidUtils.setTextPrimaryColor(mapActivity, (TextView) v.findViewById(R.id.title), nightMode); AndroidUtils.setTextPrimaryColor(mapActivity, (TextView) v.findViewById(R.id.title), nightMode);
final TextView radius = (TextView) v.findViewById(R.id.description); final TextView radius = (TextView) v.findViewById(R.id.description);
((ImageView) v.findViewById(R.id.waypoint_icon)).setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_poi_radius_dark, !nightMode));
radius.setText(OsmAndFormatter.getFormattedDistance(waypointHelper.getSearchDeviationRadius(type), app)); radius.setText(OsmAndFormatter.getFormattedDistance(waypointHelper.getSearchDeviationRadius(type), app));
radius.setOnClickListener(new View.OnClickListener() { radius.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -249,26 +346,6 @@ public class WaypointDialogHelper {
TextView tv = (TextView) v.findViewById(R.id.header_text); TextView tv = (TextView) v.findViewById(R.id.header_text);
AndroidUtils.setTextPrimaryColor(mapActivity, tv, nightMode); AndroidUtils.setTextPrimaryColor(mapActivity, tv, nightMode);
tv.setText(getHeader(type, checked, ctx)); tv.setText(getHeader(type, checked, ctx));
v.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (type == WaypointHelper.POI && btn.isChecked()) {
running[0] = position;
thisAdapter.notifyDataSetInvalidated();
MapActivity map = (MapActivity) ctx;
final PoiUIFilter[] selected = new PoiUIFilter[1];
AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected);
dlg.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
if (selected != null) {
enableType(running, thisAdapter, type, true);
}
}
});
}
}
});
return v; return v;
} }
@ -305,11 +382,7 @@ public class WaypointDialogHelper {
protected void onPostExecute(Void result) { protected void onPostExecute(Void result) {
running[0] = -1; running[0] = -1;
listAdapter.clear(); reloadListAdapter(listAdapter);
for (Object point : getPoints()) {
listAdapter.add(point);
}
listAdapter.notifyDataSetChanged();
} }
}.execute((Void) null); }.execute((Void) null);
} }
@ -372,15 +445,23 @@ public class WaypointDialogHelper {
protected void onPostExecute(Void result) { protected void onPostExecute(Void result) {
running[0] = -1; running[0] = -1;
listAdapter.clear(); reloadListAdapter(listAdapter);
for (Object point : getPoints()) {
listAdapter.add(point);
}
listAdapter.notifyDataSetChanged();
} }
}.execute((Void) null); }.execute((Void) null);
} }
public void reloadListAdapter(ArrayAdapter<Object> listAdapter) {
listAdapter.clear();
List<Object> points = getPoints();
for (Object point : points) {
listAdapter.add(point);
}
if (listAdapter instanceof StableArrayAdapter) {
((StableArrayAdapter) listAdapter).updateObjects(points, getActivePoints(points));
}
listAdapter.notifyDataSetChanged();
}
protected String getHeader(int type, boolean checked, Activity ctx) { protected String getHeader(int type, boolean checked, Activity ctx) {
String str = ctx.getString(R.string.waypoints); String str = ctx.getString(R.string.waypoints);
switch (type) { switch (type) {
@ -397,8 +478,7 @@ public class WaypointDialogHelper {
str = ctx.getString(R.string.waypoints); str = ctx.getString(R.string.waypoints);
break; break;
case WaypointHelper.POI: case WaypointHelper.POI:
str = waypointHelper.getPoiFilter() == null || !checked ? ctx.getString(R.string.poi) : waypointHelper str = ctx.getString(R.string.poi);
.getPoiFilter().getName();
break; break;
} }
return str; return str;
@ -416,7 +496,33 @@ public class WaypointDialogHelper {
points.add(true); points.add(true);
} }
points.add(i); points.add(i);
if ((i == WaypointHelper.POI || i == WaypointHelper.FAVORITES || i == WaypointHelper.WAYPOINTS) if (i == WaypointHelper.TARGETS && rc) {
TargetPoint start = app.getTargetPointsHelper().getPointToStart();
if (start == null) {
LatLon latLon;
Location loc = app.getLocationProvider().getLastKnownLocation();
if (loc != null) {
latLon = new LatLon(loc.getLatitude(), loc.getLongitude());
} else {
latLon = new LatLon(mapActivity.getMapView().getLatitude(),
mapActivity.getMapView().getLongitude());
}
start = TargetPoint.createStartPoint(latLon,
new PointDescription(PointDescription.POINT_TYPE_MY_LOCATION,
mapActivity.getString(R.string.shared_string_my_location)));
} else {
String oname = start.getOnlyName().length() > 0 ? start.getOnlyName()
: (mapActivity.getString(R.string.route_descr_map_location)
+ " " + mapActivity.getString(R.string.route_descr_lat_lon, start.getLatitude(), start.getLongitude()));
start = TargetPoint.createStartPoint(new LatLon(start.getLatitude(), start.getLongitude()),
new PointDescription(PointDescription.POINT_TYPE_LOCATION,
oname));
}
points.add(new LocationPointWrapper(null, WaypointHelper.TARGETS, start, 0f, 0));
} else if ((i == WaypointHelper.POI || i == WaypointHelper.FAVORITES || i == WaypointHelper.WAYPOINTS)
&& rc) { && rc) {
if (waypointHelper.isTypeEnabled(i)) { if (waypointHelper.isTypeEnabled(i)) {
points.add(new RadiusItem(i)); points.add(new RadiusItem(i));
@ -435,6 +541,11 @@ public class WaypointDialogHelper {
if (!(a instanceof MapActivity)) { if (!(a instanceof MapActivity)) {
return; return;
} }
app.getSettings().setMapLocationToShow(locationPoint.getLatitude(), locationPoint.getLongitude(),
15, locationPoint.getPointDescription(a), false, locationPoint);
MapActivity.launchMapActivityMoveToTop(a);
/*
MapActivity ctx = (MapActivity) a; MapActivity ctx = (MapActivity) a;
AnimateDraggingMapThread thread = ctx.getMapView().getAnimatedDraggingThread(); AnimateDraggingMapThread thread = ctx.getMapView().getAnimatedDraggingThread();
int fZoom = ctx.getMapView().getZoom() < 15 ? 15 : ctx.getMapView().getZoom(); int fZoom = ctx.getMapView().getZoom() < 15 ? 15 : ctx.getMapView().getZoom();
@ -467,15 +578,9 @@ public class WaypointDialogHelper {
new LatLon(locationPoint.getLatitude(), locationPoint.getLongitude()), new LatLon(locationPoint.getLatitude(), locationPoint.getLongitude()),
locationPoint.getPointDescription(ctx), locationPoint.getPointDescription(ctx),
locationPoint); locationPoint);
/*
ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint);
ctx.getMapLayers()
.getContextMenuLayer()
.setLocation(new LatLon(locationPoint.getLatitude(), locationPoint.getLongitude()),
PointDescription.getSimpleName(locationPoint, ctx));
*/
} }
} }
*/
} }
} }

View file

@ -19,6 +19,8 @@ import net.osmand.data.Amenity.AmenityRoutePoint;
import net.osmand.data.LocationPoint; import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.osm.PoiType; import net.osmand.osm.PoiType;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings.MetricsConstants; import net.osmand.plus.OsmandSettings.MetricsConstants;
@ -33,6 +35,7 @@ import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
import net.osmand.plus.routing.RouteCalculationResult; import net.osmand.plus.routing.RouteCalculationResult;
import net.osmand.plus.routing.VoiceRouter; import net.osmand.plus.routing.VoiceRouter;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import android.content.Context; import android.content.Context;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -71,17 +74,16 @@ public class WaypointHelper {
private long announcedAlarmTime; private long announcedAlarmTime;
public WaypointHelper(OsmandApplication application) { public WaypointHelper(OsmandApplication application) {
app = application; app = application;
} }
public List<LocationPointWrapper> getWaypoints(int type) { public List<LocationPointWrapper> getWaypoints(int type) {
if(type == TARGETS) { if (type == TARGETS) {
return getTargets(new ArrayList<WaypointHelper.LocationPointWrapper>()); return getTargets(new ArrayList<WaypointHelper.LocationPointWrapper>());
} }
if(type >= locationPoints.size()) { if (type >= locationPoints.size()) {
return Collections.emptyList(); return Collections.emptyList();
} }
return locationPoints.get(type); return locationPoints.get(type);
@ -98,7 +100,7 @@ public class WaypointHelper {
} }
public void removeVisibleLocationPoint(LocationPointWrapper lp) { public void removeVisibleLocationPoint(LocationPointWrapper lp) {
if(lp.type < locationPoints.size()) { if (lp.type < locationPoints.size()) {
locationPoints.get(lp.type).remove(lp); locationPoints.get(lp.type).remove(lp);
} }
} }
@ -108,11 +110,11 @@ public class WaypointHelper {
boolean[] checkedIntermediates = null; boolean[] checkedIntermediates = null;
for (LocationPointWrapper lp : points) { for (LocationPointWrapper lp : points) {
if (lp.type == TARGETS) { if (lp.type == TARGETS) {
if(checkedIntermediates == null) { if (checkedIntermediates == null) {
checkedIntermediates = new boolean[ps.size()]; checkedIntermediates = new boolean[ps.size()];
Arrays.fill(checkedIntermediates, true); Arrays.fill(checkedIntermediates, true);
} }
if(((TargetPoint) lp.point).intermediate) { if (((TargetPoint) lp.point).intermediate) {
checkedIntermediates[((TargetPoint) lp.point).index] = false; checkedIntermediates[((TargetPoint) lp.point).index] = false;
} else { } else {
checkedIntermediates[ps.size() - 1] = false; checkedIntermediates[ps.size() - 1] = false;
@ -121,33 +123,33 @@ public class WaypointHelper {
locationPoints.get(lp.type).remove(lp); locationPoints.get(lp.type).remove(lp);
} }
} }
if(checkedIntermediates != null) { if (checkedIntermediates != null) {
IntermediatePointsDialog.commitPointsRemoval(app, checkedIntermediates); IntermediatePointsDialog.commitPointsRemoval(app, checkedIntermediates);
} }
} }
public LocationPointWrapper getMostImportantLocationPoint(List<LocationPointWrapper> list ) { public LocationPointWrapper getMostImportantLocationPoint(List<LocationPointWrapper> list) {
//Location lastProjection = app.getRoutingHelper().getLastProjection(); //Location lastProjection = app.getRoutingHelper().getLastProjection();
if(list != null) { if (list != null) {
list.clear(); list.clear();
} }
LocationPointWrapper found = null; LocationPointWrapper found = null;
for (int type = 0; type < locationPoints.size(); type++) { for (int type = 0; type < locationPoints.size(); type++) {
if(type == ALARMS || type == TARGETS) { if (type == ALARMS || type == TARGETS) {
continue; continue;
} }
int kIterator = pointsProgress.get(type); int kIterator = pointsProgress.get(type);
List<LocationPointWrapper> lp = locationPoints.get(type); List<LocationPointWrapper> lp = locationPoints.get(type);
while(kIterator < lp.size()) { while (kIterator < lp.size()) {
LocationPointWrapper lwp = lp.get(kIterator); LocationPointWrapper lwp = lp.get(kIterator);
if(lp.get(kIterator).routeIndex < route.getCurrentRoute()) { if (lp.get(kIterator).routeIndex < route.getCurrentRoute()) {
// skip // skip
} else { } else {
if(route.getDistanceToPoint(lwp.routeIndex) <= LONG_ANNOUNCE_RADIUS ) { if (route.getDistanceToPoint(lwp.routeIndex) <= LONG_ANNOUNCE_RADIUS) {
if(found == null || found.routeIndex < lwp.routeIndex) { if (found == null || found.routeIndex < lwp.routeIndex) {
found = lwp; found = lwp;
if(list != null) { if (list != null) {
list.add(lwp); list.add(lwp);
} }
} }
@ -200,26 +202,26 @@ public class WaypointHelper {
public void enableWaypointType(int type, boolean enable) { public void enableWaypointType(int type, boolean enable) {
//An item will be displayed in the Waypoint list if either "Show..." or "Announce..." is selected for it in the Navigation settings //An item will be displayed in the Waypoint list if either "Show..." or "Announce..." is selected for it in the Navigation settings
//Keep both "Show..." and "Announce..." Nav settings in sync when user changes what to display in the Waypoint list, as follows: //Keep both "Show..." and "Announce..." Nav settings in sync when user changes what to display in the Waypoint list, as follows:
if(type == ALARMS) { if (type == ALARMS) {
app.getSettings().SHOW_TRAFFIC_WARNINGS.set(enable); app.getSettings().SHOW_TRAFFIC_WARNINGS.set(enable);
app.getSettings().SPEAK_TRAFFIC_WARNINGS.set(enable); app.getSettings().SPEAK_TRAFFIC_WARNINGS.set(enable);
app.getSettings().SHOW_PEDESTRIAN.set(enable); app.getSettings().SHOW_PEDESTRIAN.set(enable);
app.getSettings().SPEAK_PEDESTRIAN.set(enable); app.getSettings().SPEAK_PEDESTRIAN.set(enable);
//But do not implicitly change speed_cam settings here because of legal restrictions in some countries, so Nav settings must prevail //But do not implicitly change speed_cam settings here because of legal restrictions in some countries, so Nav settings must prevail
} else if(type == POI) { } else if (type == POI) {
app.getSettings().SHOW_NEARBY_POI.set(enable); app.getSettings().SHOW_NEARBY_POI.set(enable);
app.getSettings().ANNOUNCE_NEARBY_POI.set(enable); app.getSettings().ANNOUNCE_NEARBY_POI.set(enable);
} else if(type == FAVORITES) { } else if (type == FAVORITES) {
app.getSettings().SHOW_NEARBY_FAVORITES.set(enable); app.getSettings().SHOW_NEARBY_FAVORITES.set(enable);
app.getSettings().ANNOUNCE_NEARBY_FAVORITES.set(enable); app.getSettings().ANNOUNCE_NEARBY_FAVORITES.set(enable);
} else if(type == WAYPOINTS) { } else if (type == WAYPOINTS) {
app.getSettings().SHOW_WPT.set(enable); app.getSettings().SHOW_WPT.set(enable);
app.getSettings().ANNOUNCE_WPT.set(enable); app.getSettings().ANNOUNCE_WPT.set(enable);
} }
recalculatePoints(route, type, locationPoints); recalculatePoints(route, type, locationPoints);
} }
public void recalculatePoints(int type){ public void recalculatePoints(int type) {
recalculatePoints(route, type, locationPoints); recalculatePoints(route, type, locationPoints);
} }
@ -230,14 +232,14 @@ public class WaypointHelper {
public boolean isTypeVisible(int waypointType) { public boolean isTypeVisible(int waypointType) {
boolean vis = app.getAppCustomization().isWaypointGroupVisible(waypointType, route); boolean vis = app.getAppCustomization().isWaypointGroupVisible(waypointType, route);
if(!vis) { if (!vis) {
return false; return false;
} }
return vis; return vis;
} }
public boolean isTypeEnabled(int type) { public boolean isTypeEnabled(int type) {
if(type == ALARMS) { if (type == ALARMS) {
return showAlarms() || announceAlarms(); return showAlarms() || announceAlarms();
} else if (type == POI) { } else if (type == POI) {
//no SHOW item in nav settings, hence only query ANNOUNCE here (makes inital Waypoint dialogue consistent with nav settings) //no SHOW item in nav settings, hence only query ANNOUNCE here (makes inital Waypoint dialogue consistent with nav settings)
@ -256,9 +258,9 @@ public class WaypointHelper {
} }
public AlarmInfo calculateMostImportantAlarm(RouteDataObject ro, Location loc, public AlarmInfo calculateMostImportantAlarm(RouteDataObject ro, Location loc,
MetricsConstants mc, boolean showCameras) { MetricsConstants mc, boolean showCameras) {
boolean direction = true; boolean direction = true;
if(loc.hasBearing()) { if (loc.hasBearing()) {
double diff = MapUtils.alignAngleDifference(ro.directionRoute(0, true) - double diff = MapUtils.alignAngleDifference(ro.directionRoute(0, true) -
loc.getBearing() / (2 * Math.PI)); loc.getBearing() / (2 * Math.PI));
direction = Math.abs(diff) < Math.PI; direction = Math.abs(diff) < Math.PI;
@ -279,8 +281,8 @@ public class WaypointHelper {
AlarmInfo info = AlarmInfo.createAlarmInfo(typeRule, 0, loc); AlarmInfo info = AlarmInfo.createAlarmInfo(typeRule, 0, loc);
if (info != null) { if (info != null) {
if (info.getType() != AlarmInfoType.SPEED_CAMERA || showCameras) { if (info.getType() != AlarmInfoType.SPEED_CAMERA || showCameras) {
long ms = System.currentTimeMillis() ; long ms = System.currentTimeMillis();
if(ms - announcedAlarmTime > 50 * 1000) { if (ms - announcedAlarmTime > 50 * 1000) {
announcedAlarmTime = ms; announcedAlarmTime = ms;
getVoiceRouter().announceAlarm(info.getType()); getVoiceRouter().announceAlarm(info.getType());
} }
@ -319,15 +321,15 @@ public class WaypointHelper {
List<LocationPointWrapper> approachPoints = new ArrayList<LocationPointWrapper>(); List<LocationPointWrapper> approachPoints = new ArrayList<LocationPointWrapper>();
List<LocationPointWrapper> announcePoints = new ArrayList<LocationPointWrapper>(); List<LocationPointWrapper> announcePoints = new ArrayList<LocationPointWrapper>();
List<LocationPointWrapper> lp = locationPoints.get(type); List<LocationPointWrapper> lp = locationPoints.get(type);
if(lp != null) { if (lp != null) {
int kIterator = pointsProgress.get(type); int kIterator = pointsProgress.get(type);
while(kIterator < lp.size() && lp.get(kIterator).routeIndex < currentRoute) { while (kIterator < lp.size() && lp.get(kIterator).routeIndex < currentRoute) {
kIterator++; kIterator++;
} }
pointsProgress.set(type, kIterator); pointsProgress.set(type, kIterator);
while(kIterator < lp.size()) { while (kIterator < lp.size()) {
LocationPointWrapper lwp = lp.get(kIterator); LocationPointWrapper lwp = lp.get(kIterator);
if(route.getDistanceToPoint(lwp.routeIndex) > LONG_ANNOUNCE_RADIUS * 2){ if (route.getDistanceToPoint(lwp.routeIndex) > LONG_ANNOUNCE_RADIUS * 2) {
break; break;
} }
LocationPoint point = lwp.point; LocationPoint point = lwp.point;
@ -350,7 +352,7 @@ public class WaypointHelper {
kIterator++; kIterator++;
} }
if (!announcePoints.isEmpty()) { if (!announcePoints.isEmpty()) {
if(announcePoints.size() > ANNOUNCE_POI_LIMIT) { if (announcePoints.size() > ANNOUNCE_POI_LIMIT) {
announcePoints = announcePoints.subList(0, ANNOUNCE_POI_LIMIT); announcePoints = announcePoints.subList(0, ANNOUNCE_POI_LIMIT);
} }
if (type == WAYPOINTS) { if (type == WAYPOINTS) {
@ -364,7 +366,7 @@ public class WaypointHelper {
} }
} }
if (!approachPoints.isEmpty()) { if (!approachPoints.isEmpty()) {
if(approachPoints.size() > APPROACH_POI_LIMIT) { if (approachPoints.size() > APPROACH_POI_LIMIT) {
approachPoints = approachPoints.subList(0, APPROACH_POI_LIMIT); approachPoints = approachPoints.subList(0, APPROACH_POI_LIMIT);
} }
if (type == WAYPOINTS) { if (type == WAYPOINTS) {
@ -373,10 +375,10 @@ public class WaypointHelper {
getVoiceRouter().approachPoi(lastKnownLocation, approachPoints); getVoiceRouter().approachPoi(lastKnownLocation, approachPoints);
} else if (type == ALARMS) { } else if (type == ALARMS) {
EnumSet<AlarmInfoType> ait = EnumSet.noneOf(AlarmInfoType.class); EnumSet<AlarmInfoType> ait = EnumSet.noneOf(AlarmInfoType.class);
for(LocationPointWrapper pw : approachPoints) { for (LocationPointWrapper pw : approachPoints) {
ait.add(((AlarmInfo) pw.point).getType()); ait.add(((AlarmInfo) pw.point).getType());
} }
for(AlarmInfoType t : ait) { for (AlarmInfoType t : ait) {
app.getRoutingHelper().getVoiceRouter().announceAlarm(t); app.getRoutingHelper().getVoiceRouter().announceAlarm(t);
} }
} else if (type == FAVORITES) { } else if (type == FAVORITES) {
@ -418,8 +420,8 @@ public class WaypointHelper {
for (int k = 0; k < wts.size(); k++) { for (int k = 0; k < wts.size(); k++) {
final int index = wts.size() - k - 1; final int index = wts.size() - k - 1;
TargetPoint tp = wts.get(index); TargetPoint tp = wts.get(index);
int routeIndex ; int routeIndex;
if(route == null) { if (route == null) {
routeIndex = k == 0 ? Integer.MAX_VALUE : index; routeIndex = k == 0 ? Integer.MAX_VALUE : index;
} else { } else {
routeIndex = k == 0 ? route.getImmutableAllLocations().size() - 1 : route.getIndexOfIntermediate(k - 1); routeIndex = k == 0 ? route.getImmutableAllLocations().size() - 1 : route.getIndexOfIntermediate(k - 1);
@ -459,7 +461,7 @@ public class WaypointHelper {
sortList(array); sortList(array);
} }
} }
if((type == ALARMS || all)) { if ((type == ALARMS || all)) {
final List<LocationPointWrapper> array = clearAndGetArray(locationPoints, ALARMS); final List<LocationPointWrapper> array = clearAndGetArray(locationPoints, ALARMS);
calculateAlarms(route, array); calculateAlarms(route, array);
sortList(array); sortList(array);
@ -473,9 +475,9 @@ public class WaypointHelper {
sortList(array); sortList(array);
} }
} }
if((type == POI || all)) { if ((type == POI || all)) {
final List<LocationPointWrapper> array = clearAndGetArray(locationPoints, POI); final List<LocationPointWrapper> array = clearAndGetArray(locationPoints, POI);
if(showPOI()) { if (showPOI()) {
calculatePoi(route, array); calculatePoi(route, array);
sortList(array); sortList(array);
} }
@ -486,13 +488,13 @@ public class WaypointHelper {
private float dist(LocationPoint l, List<Location> locations, int[] ind) { private float dist(LocationPoint l, List<Location> locations, int[] ind) {
float dist = Float.POSITIVE_INFINITY; float dist = Float.POSITIVE_INFINITY;
// Special iterations because points stored by pairs! // Special iterations because points stored by pairs!
for (int i = 1; i < locations.size(); i ++) { for (int i = 1; i < locations.size(); i++) {
final double ld = MapUtils.getOrthogonalDistance( final double ld = MapUtils.getOrthogonalDistance(
l.getLatitude(), l.getLongitude(), l.getLatitude(), l.getLongitude(),
locations.get(i - 1).getLatitude(), locations.get(i - 1).getLongitude(), locations.get(i - 1).getLatitude(), locations.get(i - 1).getLongitude(),
locations.get(i).getLatitude(), locations.get(i).getLongitude()); locations.get(i).getLatitude(), locations.get(i).getLongitude());
if(ld < dist){ if (ld < dist) {
if(ind != null) { if (ind != null) {
ind[0] = i; ind[0] = i;
} }
dist = (float) ld; dist = (float) ld;
@ -517,7 +519,7 @@ public class WaypointHelper {
public int compare(LocationPointWrapper olhs, LocationPointWrapper orhs) { public int compare(LocationPointWrapper olhs, LocationPointWrapper orhs) {
int lhs = olhs.routeIndex; int lhs = olhs.routeIndex;
int rhs = orhs.routeIndex; int rhs = orhs.routeIndex;
if(lhs == rhs) { if (lhs == rhs) {
return Float.compare(olhs.deviationDistance, orhs.deviationDistance); return Float.compare(olhs.deviationDistance, orhs.deviationDistance);
} }
return lhs < rhs ? -1 : 1; return lhs < rhs ? -1 : 1;
@ -545,17 +547,16 @@ public class WaypointHelper {
} }
private void calculateAlarms(RouteCalculationResult route, List<LocationPointWrapper> array) { private void calculateAlarms(RouteCalculationResult route, List<LocationPointWrapper> array) {
for(AlarmInfo i : route.getAlarmInfo()) { for (AlarmInfo i : route.getAlarmInfo()) {
if(i.getType() == AlarmInfoType.SPEED_CAMERA) { if (i.getType() == AlarmInfoType.SPEED_CAMERA) {
if(app.getSettings().SHOW_CAMERAS.get() || app.getSettings().SPEAK_SPEED_CAMERA.get()){ if (app.getSettings().SHOW_CAMERAS.get() || app.getSettings().SPEAK_SPEED_CAMERA.get()) {
LocationPointWrapper lw = new LocationPointWrapper(route, ALARMS, i, 0, i.getLocationIndex()); LocationPointWrapper lw = new LocationPointWrapper(route, ALARMS, i, 0, i.getLocationIndex());
lw.setAnnounce(app.getSettings().SPEAK_SPEED_CAMERA.get()); lw.setAnnounce(app.getSettings().SPEAK_SPEED_CAMERA.get());
array.add(lw); array.add(lw);
} }
} else { } else {
if(app.getSettings().SHOW_TRAFFIC_WARNINGS.get() || app.getSettings().SPEAK_TRAFFIC_WARNINGS.get()){ if (app.getSettings().SHOW_TRAFFIC_WARNINGS.get() || app.getSettings().SPEAK_TRAFFIC_WARNINGS.get()) {
LocationPointWrapper lw = new LocationPointWrapper(route, ALARMS, i, 0, i.getLocationIndex()); LocationPointWrapper lw = new LocationPointWrapper(route, ALARMS, i, 0, i.getLocationIndex());
lw.setAnnounce(app.getSettings().SPEAK_TRAFFIC_WARNINGS.get()); lw.setAnnounce(app.getSettings().SPEAK_TRAFFIC_WARNINGS.get());
array.add(lw); array.add(lw);
@ -568,8 +569,8 @@ public class WaypointHelper {
private List<LocationPointWrapper> clearAndGetArray(List<List<LocationPointWrapper>> array, private List<LocationPointWrapper> clearAndGetArray(List<List<LocationPointWrapper>> array,
int ind) { int ind) {
while(array.size() <= ind) { while (array.size() <= ind) {
array.add(new ArrayList<WaypointHelper.LocationPointWrapper>()); array.add(new ArrayList<WaypointHelper.LocationPointWrapper>());
} }
array.get(ind).clear(); array.get(ind).clear();
@ -578,13 +579,13 @@ public class WaypointHelper {
private void findLocationPoints(RouteCalculationResult rt, int type, List<LocationPointWrapper> locationPoints, private void findLocationPoints(RouteCalculationResult rt, int type, List<LocationPointWrapper> locationPoints,
List<? extends LocationPoint> points, boolean announce) { List<? extends LocationPoint> points, boolean announce) {
List<Location> immutableAllLocations = rt.getImmutableAllLocations(); List<Location> immutableAllLocations = rt.getImmutableAllLocations();
int[] ind = new int[1]; int[] ind = new int[1];
for(LocationPoint p : points) { for (LocationPoint p : points) {
float dist = dist(p, immutableAllLocations, ind); float dist = dist(p, immutableAllLocations, ind);
int rad = getSearchDeviationRadius(type); int rad = getSearchDeviationRadius(type);
if(dist <= rad) { if (dist <= rad) {
LocationPointWrapper lpw = new LocationPointWrapper(rt, type, p, dist, ind[0]); LocationPointWrapper lpw = new LocationPointWrapper(rt, type, p, dist, ind[0]);
lpw.setAnnounce(announce); lpw.setAnnounce(announce);
locationPoints.add(lpw); locationPoints.add(lpw);
@ -597,6 +598,7 @@ public class WaypointHelper {
public PoiUIFilter getPoiFilter() { public PoiUIFilter getPoiFilter() {
return app.getPoiFilters().getFilterById(app.getSettings().SELECTED_POI_FILTER_FOR_MAP.get()); return app.getPoiFilters().getFilterById(app.getSettings().SELECTED_POI_FILTER_FOR_MAP.get());
} }
public boolean showPOI() { public boolean showPOI() {
return app.getSettings().SHOW_NEARBY_POI.get(); return app.getSettings().SHOW_NEARBY_POI.get();
} }
@ -662,10 +664,8 @@ public class WaypointHelper {
} }
public Drawable getDrawable(Context uiCtx, OsmandApplication app, boolean nightMode) {
if (type == POI) {
public Drawable getDrawable(Context uiCtx, OsmandApplication app) {
if(type == POI) {
Amenity amenity = ((AmenityLocationPoint) point).a; Amenity amenity = ((AmenityLocationPoint) point).a;
PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType()); PoiType st = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
if (st != null) { if (st != null) {
@ -678,36 +678,53 @@ public class WaypointHelper {
} }
} }
return null; return null;
} else if(type == TARGETS) {
int i = !((TargetPoint)point).intermediate? R.drawable.list_destination : } else if (type == TARGETS) {
R.drawable.list_intermediate; IconsCache iconsCache = app.getIconsCache();
return uiCtx.getResources().getDrawable(i); if (((TargetPoint) point).start) {
} else if(type == FAVORITES || type == WAYPOINTS) { ApplicationMode appMode = app.getSettings().getApplicationMode();
return uiCtx.getResources().getDrawable(appMode.getResourceLocationDay());
} else if (((TargetPoint) point).intermediate) {
if (!nightMode) {
return iconsCache.getIcon(R.drawable.widget_intermediate_day, 0, 0f);
} else {
return iconsCache.getIcon(R.drawable.widget_intermediate_night, 0, 0f);
}
} else {
if (!nightMode) {
return iconsCache.getIcon(R.drawable.widget_target_day, 0, 0f);
} else {
return iconsCache.getIcon(R.drawable.widget_target_night, 0, 0f);
}
}
} else if (type == FAVORITES || type == WAYPOINTS) {
return FavoriteImageDrawable.getOrCreate(uiCtx, point.getColor(), false); return FavoriteImageDrawable.getOrCreate(uiCtx, point.getColor(), false);
} else if(type == ALARMS) {
} else if (type == ALARMS) {
//assign alarm list icons manually for now //assign alarm list icons manually for now
if(((AlarmInfo) point).getType().toString() == "SPEED_CAMERA") { if (((AlarmInfo) point).getType().toString().equals("SPEED_CAMERA")) {
return uiCtx.getResources().getDrawable(R.drawable.mx_highway_speed_camera); return uiCtx.getResources().getDrawable(R.drawable.mx_highway_speed_camera);
} else if(((AlarmInfo) point).getType().toString() == "BORDER_CONTROL") { } else if (((AlarmInfo) point).getType().toString().equals("BORDER_CONTROL")) {
return uiCtx.getResources().getDrawable(R.drawable.mx_barrier_border_control); return uiCtx.getResources().getDrawable(R.drawable.mx_barrier_border_control);
} else if(((AlarmInfo) point).getType().toString() == "RAILWAY") { } else if (((AlarmInfo) point).getType().toString().equals("RAILWAY")) {
if(app.getSettings().DRIVING_REGION.get().americanSigns){ if (app.getSettings().DRIVING_REGION.get().americanSigns) {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways_us); return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways_us);
} else { } else {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways); return uiCtx.getResources().getDrawable(R.drawable.list_warnings_railways);
} }
} else if(((AlarmInfo) point).getType().toString() == "TRAFFIC_CALMING") { } else if (((AlarmInfo) point).getType().toString().equals("TRAFFIC_CALMING")) {
if(app.getSettings().DRIVING_REGION.get().americanSigns){ if (app.getSettings().DRIVING_REGION.get().americanSigns) {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_traffic_calming_us); return uiCtx.getResources().getDrawable(R.drawable.list_warnings_traffic_calming_us);
} else { } else {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_traffic_calming); return uiCtx.getResources().getDrawable(R.drawable.list_warnings_traffic_calming);
} }
} else if(((AlarmInfo) point).getType().toString() == "TOLL_BOOTH") { } else if (((AlarmInfo) point).getType().toString().equals("TOLL_BOOTH")) {
return uiCtx.getResources().getDrawable(R.drawable.mx_toll_booth); return uiCtx.getResources().getDrawable(R.drawable.mx_toll_booth);
} else if(((AlarmInfo) point).getType().toString() == "STOP") { } else if (((AlarmInfo) point).getType().toString().equals("STOP")) {
return uiCtx.getResources().getDrawable(R.drawable.list_stop); return uiCtx.getResources().getDrawable(R.drawable.list_stop);
} else if(((AlarmInfo) point).getType().toString() == "PEDESTRIAN") { } else if (((AlarmInfo) point).getType().toString().equals("PEDESTRIAN")) {
if(app.getSettings().DRIVING_REGION.get().americanSigns){ if (app.getSettings().DRIVING_REGION.get().americanSigns) {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian_us); return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian_us);
} else { } else {
return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian); return uiCtx.getResources().getDrawable(R.drawable.list_warnings_pedestrian);
@ -715,6 +732,7 @@ public class WaypointHelper {
} else { } else {
return null; return null;
} }
} else { } else {
return null; return null;
} }
@ -724,6 +742,7 @@ public class WaypointHelper {
public int hashCode() { public int hashCode() {
return ((point == null) ? 0 : point.hashCode()); return ((point == null) ? 0 : point.hashCode());
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) if (this == obj)
@ -743,12 +762,12 @@ public class WaypointHelper {
} }
public int getSearchDeviationRadius(int type){ public int getSearchDeviationRadius(int type) {
return type == POI ? poiSearchDeviationRadius : searchDeviationRadius; return type == POI ? poiSearchDeviationRadius : searchDeviationRadius;
} }
public void setSearchDeviationRadius(int type, int radius){ public void setSearchDeviationRadius(int type, int radius) {
if(type == POI) { if (type == POI) {
this.poiSearchDeviationRadius = radius; this.poiSearchDeviationRadius = radius;
} else { } else {
this.searchDeviationRadius = radius; this.searchDeviationRadius = radius;

View file

@ -143,13 +143,12 @@ public abstract class MenuTitleController {
protected void acquireStreetName() { protected void acquireStreetName() {
if (searchingAddress) { if (searchingAddress) {
cancelSearch = true; cancelSearch = true;
searchingAddress = false;
getMapActivity().getMyApplication().runInUIThread(new Runnable() { getMapActivity().getMyApplication().runInUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
acquireStreetName(); acquireStreetName();
} }
}, 50); }, 100);
return; return;
} }

View file

@ -65,6 +65,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
private boolean selectFromMapForTarget; private boolean selectFromMapForTarget;
private boolean showMenu = false; private boolean showMenu = false;
private boolean visible;
private MapActivity mapActivity; private MapActivity mapActivity;
private MapControlsLayer mapControlsLayer; private MapControlsLayer mapControlsLayer;
public static final String TARGET_SELECT = "TARGET_SELECT"; public static final String TARGET_SELECT = "TARGET_SELECT";
@ -375,7 +376,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} }
public boolean isVisible() { public boolean isVisible() {
return findMenuFragment() != null; return visible;
} }
public WeakReference<MapRouteInfoMenuFragment> findMenuFragment() { public WeakReference<MapRouteInfoMenuFragment> findMenuFragment() {
@ -602,29 +603,34 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} }
public void onDismiss() { public void onDismiss() {
visible = false;
mapActivity.getMapView().setMapPositionX(0); mapActivity.getMapView().setMapPositionX(0);
mapActivity.getMapView().refreshMap(); mapActivity.getMapView().refreshMap();
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin), false); AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin), false);
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), true); AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), true);
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_left_widgets_panel), true);
if (switched) { if (switched) {
mapControlsLayer.switchToRouteFollowingLayout(); mapControlsLayer.switchToRouteFollowingLayout();
} }
} }
public void show() { public void show() {
visible = true;
switched = mapControlsLayer.switchToRoutePlanningLayout(); switched = mapControlsLayer.switchToRoutePlanningLayout();
boolean refreshMap = !switched;
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity); boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
if (!portrait) { if (!portrait) {
mapActivity.getMapView().setMapPositionX(1); mapActivity.getMapView().setMapPositionX(1);
mapActivity.getMapView().refreshMap(); refreshMap = true;
}
if (refreshMap) {
mapActivity.refreshMap();
} }
MapRouteInfoMenuFragment.showInstance(mapActivity); MapRouteInfoMenuFragment.showInstance(mapActivity);
if (!AndroidUiHelper.isXLargeDevice(mapActivity)) { if (!AndroidUiHelper.isXLargeDevice(mapActivity)) {
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), false); AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_right_widgets_panel), false);
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_left_widgets_panel), false);
} }
if (!portrait) { if (!portrait) {
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin), true); AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin), true);
@ -635,6 +641,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment(); WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) { if (fragmentRef != null) {
fragmentRef.get().dismiss(); fragmentRef.get().dismiss();
} else {
visible = false;
} }
} }
@ -677,7 +685,8 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
label.setText(row.text); label.setText(row.text);
Drawable icon = mapActivity.getMyApplication().getIconsCache().getContentIcon(row.iconId); Drawable icon = mapActivity.getMyApplication().getIconsCache().getContentIcon(row.iconId);
label.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null); label.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
label.setCompoundDrawablePadding(dpToPx(12f)); label.setCompoundDrawablePadding(dpToPx(16f));
label.setPadding(dpToPx((16f)), 0, 0, 0);
return label; return label;
} }

View file

@ -609,6 +609,7 @@ public class RoutingHelper {
voiceRouter.newRouteIsCalculated(newRoute); voiceRouter.newRouteIsCalculated(newRoute);
} }
} }
app.getWaypointHelper().setNewRoute(res);
app.runInUIThread(new Runnable() { app.runInUIThread(new Runnable() {
@Override @Override
@ -616,10 +617,10 @@ public class RoutingHelper {
ValueHolder<Boolean> showToast = new ValueHolder<Boolean>(); ValueHolder<Boolean> showToast = new ValueHolder<Boolean>();
showToast.value = true; showToast.value = true;
Iterator<WeakReference<IRouteInformationListener>> it = listeners.iterator(); Iterator<WeakReference<IRouteInformationListener>> it = listeners.iterator();
while(it.hasNext()) { while (it.hasNext()) {
WeakReference<IRouteInformationListener> ref = it.next(); WeakReference<IRouteInformationListener> ref = it.next();
IRouteInformationListener l = ref.get(); IRouteInformationListener l = ref.get();
if(l == null) { if (l == null) {
it.remove(); it.remove();
} else { } else {
l.newRouteIsCalculated(newRoute, showToast); l.newRouteIsCalculated(newRoute, showToast);
@ -635,9 +636,6 @@ public class RoutingHelper {
} }
} }
}); });
app.getWaypointHelper().setNewRoute(res);
} }
public int getLeftDistance(){ public int getLeftDistance(){

View file

@ -492,7 +492,7 @@ public class MapControlsLayer extends OsmandMapLayer {
((System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS) && routeFollowingMode); ((System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS) && routeFollowingMode);
updateMyLocation(rh, dialogOpened); updateMyLocation(rh, dialogOpened);
boolean showButtons = (showRouteCalculationControls || !routeFollowingMode); boolean showButtons = (showRouteCalculationControls || !routeFollowingMode);
routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions); //routePlanningBtn.setIconResId(routeFollowingMode ? R.drawable.ic_action_gabout_dark : R.drawable.map_directions);
if (routePlanningMode || routeFollowingMode) { if (routePlanningMode || routeFollowingMode) {
routePlanningBtn.setIconResId(R.drawable.map_start_navigation); routePlanningBtn.setIconResId(R.drawable.map_start_navigation);
routePlanningBtn.setIconColorId(R.color.color_myloc_distance); routePlanningBtn.setIconColorId(R.color.color_myloc_distance);
@ -534,7 +534,7 @@ public class MapControlsLayer extends OsmandMapLayer {
updateCompass(isNight); updateCompass(isNight);
for (MapHudButton mc : controls) { for (MapHudButton mc : controls) {
mc.update(mapActivity.getMyApplication(), nightMode != null && nightMode.isNightMode()); mc.update(mapActivity.getMyApplication(), isNight);
} }
} }

View file

@ -0,0 +1,689 @@
package net.osmand.plus.views.controls;
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.AbsListView;
import android.widget.HeaderViewListAdapter;
import android.widget.ListAdapter;
import com.github.ksoichiro.android.observablescrollview.ObservableListView;
import java.util.List;
public class DynamicListView extends ObservableListView {
public final String TAG_DRAG_ICON = "DragIcon";
protected final int SMOOTH_SCROLL_AMOUNT_AT_EDGE = 15;
protected final int MOVE_DURATION = 150;
protected List<Object> mItemsList;
protected List<Object> mActiveItemsList;
private DynamicListViewCallbacks dCallbacks;
private int mLastEventY = -1;
protected int mDownY = -1;
protected int mDownX = -1;
private int mTotalOffset = 0;
private boolean mCellIsMobile = false;
private boolean mIsMobileScrolling = false;
private int mSmoothScrollAmountAtEdge = 0;
private boolean itemsSwapped = false;
protected final int INVALID_ID = -1;
private long mAboveItemId = INVALID_ID;
private long mMobileItemId = INVALID_ID;
private long mBelowItemId = INVALID_ID;
private BitmapDrawable mHoverCell;
private Rect mHoverCellCurrentBounds;
private Rect mHoverCellOriginalBounds;
protected final int INVALID_POINTER_ID = -1;
private int mActivePointerId = INVALID_POINTER_ID;
private boolean mIsWaitingForScrollFinish = false;
private int mScrollState = OnScrollListener.SCROLL_STATE_IDLE;
public DynamicListView(Context context) {
super(context);
init(context);
}
public DynamicListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context);
}
public DynamicListView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public void init(Context context) {
setOnScrollListener(mScrollListener);
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
mSmoothScrollAmountAtEdge = (int) (SMOOTH_SCROLL_AMOUNT_AT_EDGE / metrics.density);
}
public void setDynamicListViewCallbacks(DynamicListViewCallbacks callbacks) {
dCallbacks = callbacks;
}
/**
* Creates the hover cell with the appropriate bitmap and of appropriate
* size. The hover cell's BitmapDrawable is drawn on top of the bitmap every
* single time an invalidate call is made.
*/
private BitmapDrawable getAndAddHoverView(View v) {
int w = v.getWidth();
int h = v.getHeight();
int top = v.getTop();
int left = v.getLeft();
Bitmap b = getBitmapFromView(v);
BitmapDrawable drawable = new BitmapDrawable(getResources(), b);
mHoverCellOriginalBounds = new Rect(left, top, left + w, top + h);
mHoverCellCurrentBounds = new Rect(mHoverCellOriginalBounds);
drawable.setBounds(mHoverCellCurrentBounds);
return drawable;
}
/**
* Returns a bitmap showing a screenshot of the view passed in.
*/
private Bitmap getBitmapFromView(View v) {
Bitmap bitmap = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
v.draw(canvas);
Bitmap bitmapOut = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvasOut = new Canvas(bitmapOut);
canvasOut.drawColor(Color.TRANSPARENT);
Paint p = new Paint();
p.setAlpha(200);
canvasOut.drawBitmap(bitmap, 0, 0, p);
return bitmapOut;
}
public StableArrayAdapter getStableAdapter() {
ListAdapter listAdapter = getAdapter();
if (listAdapter instanceof HeaderViewListAdapter) {
listAdapter = ((HeaderViewListAdapter) listAdapter).getWrappedAdapter();
}
if (listAdapter instanceof StableArrayAdapter) {
return (StableArrayAdapter) listAdapter;
}
return null;
}
/**
* Stores a reference to the views above and below the item currently
* corresponding to the hover cell. It is important to note that if this
* item is either at the top or bottom of the list, mAboveItemId or mBelowItemId
* may be invalid.
*/
private void updateNeighborViewsForID(long itemID) {
ListAdapter adapter = getAdapter();
int position = getPositionForID(itemID);
int pos = position;
mAboveItemId = INVALID_ID;
while (mAboveItemId == INVALID_ID && pos > 0) {
pos--;
mAboveItemId = adapter.getItemId(pos);
if (mAboveItemId != INVALID_ID) {
Object obj = adapter.getItem(pos);
if (mActiveItemsList == null || !mActiveItemsList.contains(obj)) {
mAboveItemId = INVALID_ID;
}
}
}
pos = position;
mBelowItemId = INVALID_ID;
while (mBelowItemId == INVALID_ID && pos < mItemsList.size()) {
pos++;
mBelowItemId = adapter.getItemId(pos);
if (mBelowItemId != INVALID_ID) {
Object obj = adapter.getItem(pos);
if (mActiveItemsList == null || !mActiveItemsList.contains(obj)) {
mBelowItemId = INVALID_ID;
}
}
}
}
/**
* Retrieves the view in the list corresponding to itemID
*/
public View getViewForID(long itemID) {
if (itemID != INVALID_ID) {
int firstVisiblePosition = getFirstVisiblePosition();
ListAdapter adapter = getAdapter();
for (int i = 0; i < getChildCount(); i++) {
View v = getChildAt(i);
int position = firstVisiblePosition + i;
long id = adapter.getItemId(position);
if (id == itemID) {
return v;
}
}
}
return null;
}
public void setAllVisible() {
for (int i = 0; i < getChildCount(); i++) {
View v = getChildAt(i);
if (v != null && v.getVisibility() != VISIBLE) {
v.setVisibility(VISIBLE);
}
}
}
/**
* Retrieves the position in the list corresponding to itemID
*/
public int getPositionForID(long itemID) {
View v = getViewForID(itemID);
if (v == null) {
return -1;
} else {
return getPositionForView(v);
}
}
/**
* dispatchDraw gets invoked when all the child views are about to be drawn.
* By overriding this method, the hover cell (BitmapDrawable) can be drawn
* over the listview's items whenever the listview is redrawn.
*/
@Override
protected void dispatchDraw(@NonNull Canvas canvas) {
super.dispatchDraw(canvas);
if (mHoverCell != null) {
mHoverCell.draw(canvas);
}
}
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_DOWN:
if (!mCellIsMobile && mHoverCell == null) {
mDownX = (int) event.getX();
mDownY = (int) event.getY();
mActivePointerId = event.getPointerId(0);
// Find the view that the user pressed their finger down on.
View v = findViewAtPositionWithTag(getRootView(), (int) event.getRawX(), (int) event.getRawY(), TAG_DRAG_ICON);
// If the view contains a tag set to "DragIcon", it means that the user wants to
// reorder the list item.
if ((v != null) && (v.getTag() != null) && (v.getTag().equals(TAG_DRAG_ICON))) {
mTotalOffset = 0;
int position = pointToPosition(mDownX, mDownY);
if (position != INVALID_POSITION) {
Object item = getAdapter().getItem(position);
if (mActiveItemsList == null || mActiveItemsList.contains(item)) {
int itemNum = position - getFirstVisiblePosition();
itemsSwapped = false;
View selectedView = getChildAt(itemNum);
mMobileItemId = getAdapter().getItemId(position);
mHoverCell = getAndAddHoverView(selectedView);
selectedView.setVisibility(INVISIBLE);
mCellIsMobile = true;
updateNeighborViewsForID(mMobileItemId);
}
}
}
}
break;
case MotionEvent.ACTION_MOVE:
if (mActivePointerId == INVALID_POINTER_ID) {
break;
}
int pointerIndex = event.findPointerIndex(mActivePointerId);
mLastEventY = (int) event.getY(pointerIndex);
int deltaY = mLastEventY - mDownY;
if (mCellIsMobile && mHoverCell != null) {
mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left,
mHoverCellOriginalBounds.top + deltaY + mTotalOffset);
mHoverCell.setBounds(mHoverCellCurrentBounds);
invalidate();
handleCellSwitch();
mIsMobileScrolling = false;
handleMobileCellScroll();
return false;
}
break;
case MotionEvent.ACTION_UP:
touchEventsEnded();
break;
case MotionEvent.ACTION_CANCEL:
touchEventsCancelled();
break;
case MotionEvent.ACTION_POINTER_UP:
/* If a multitouch event took place and the original touch dictating
* the movement of the hover cell has ended, then the dragging event
* ends and the hover cell is animated to its corresponding position
* in the listview. */
pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_INDEX_MASK) >>
MotionEvent.ACTION_POINTER_INDEX_SHIFT;
final int pointerId = event.getPointerId(pointerIndex);
if (pointerId == mActivePointerId) {
touchEventsEnded();
}
break;
default:
break;
}
return super.onTouchEvent(event);
}
/**
* This method determines whether the hover cell has been shifted far enough
* to invoke a cell swap. If so, then the respective cell swap candidate is
* determined and the data set is changed. Upon posting a notification of the
* data set change, a layout is invoked to place the cells in the right place.
* Using a ViewTreeObserver and a corresponding OnPreDrawListener, we can
* offset the cell being swapped to where it previously was and then animate it to
* its new position.
*/
private void handleCellSwitch() {
final int deltaY = mLastEventY - mDownY;
final int deltaYTotal = mHoverCellOriginalBounds.top + mTotalOffset + deltaY;
View belowView = getViewForID(mBelowItemId);
View mobileView = getViewForID(mMobileItemId);
View aboveView = getViewForID(mAboveItemId);
boolean isBelow = (belowView != null) && (deltaYTotal > belowView.getTop());
boolean isAbove = (aboveView != null) && (deltaYTotal < aboveView.getTop());
if (isBelow || isAbove) {
final long switchItemID = isBelow ? mBelowItemId : mAboveItemId;
View switchView = isBelow ? belowView : aboveView;
final int originalItem = getPositionForView(mobileView) - getHeaderViewsCount();
final int switchItem = getPositionForView(switchView) - getHeaderViewsCount();
swapElements(originalItem, switchItem);
getStableAdapter().notifyDataSetChanged();
mDownY = mLastEventY;
final int switchViewStartTop = switchView.getTop();
if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.KITKAT) {
mobileView.setVisibility(View.VISIBLE);
switchView.setVisibility(View.INVISIBLE);
}
updateNeighborViewsForID(mMobileItemId);
final ViewTreeObserver observer = getViewTreeObserver();
observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
public boolean onPreDraw() {
observer.removeOnPreDrawListener(this);
View switchView = getViewForID(switchItemID);
mTotalOffset += deltaY;
int switchViewNewTop = switchView.getTop();
int delta = switchViewStartTop - switchViewNewTop;
switchView.setTranslationY(delta);
ObjectAnimator animator = ObjectAnimator.ofFloat(switchView,
View.TRANSLATION_Y, 0);
animator.setDuration(MOVE_DURATION);
animator.start();
return true;
}
});
}
}
private void swapElements(int indexOne, int indexTwo) {
Object obj1 = mItemsList.get(indexOne);
Object obj2 = mItemsList.get(indexTwo);
mItemsList.set(indexOne, obj2);
mItemsList.set(indexTwo, obj1);
int index1 = mActiveItemsList.indexOf(obj1);
int index2 = mActiveItemsList.indexOf(obj2);
if (index1 != -1 && index2 != -1) {
mActiveItemsList.set(index1, obj2);
mActiveItemsList.set(index2, obj1);
itemsSwapped = true;
}
}
/**
* Resets all the appropriate fields to a default state while also animating
* the hover cell back to its correct location.
*/
private void touchEventsEnded() {
final View mobileView = getViewForID(mMobileItemId);
if (mCellIsMobile || mIsWaitingForScrollFinish) {
mCellIsMobile = false;
mIsWaitingForScrollFinish = false;
mIsMobileScrolling = false;
mActivePointerId = INVALID_POINTER_ID;
// If the autoscroller has not completed scrolling, we need to wait for it to
// finish in order to determine the final location of where the hover cell
// should be animated to.
if (mScrollState != OnScrollListener.SCROLL_STATE_IDLE) {
mIsWaitingForScrollFinish = true;
return;
}
mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mobileView.getTop());
ObjectAnimator hoverViewAnimator = ObjectAnimator.ofObject(mHoverCell, "bounds",
sBoundEvaluator, mHoverCellCurrentBounds);
hoverViewAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
invalidate();
}
});
hoverViewAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
setEnabled(false);
}
@Override
public void onAnimationEnd(Animator animation) {
mAboveItemId = INVALID_ID;
mMobileItemId = INVALID_ID;
mBelowItemId = INVALID_ID;
setAllVisible();
mHoverCell = null;
setEnabled(true);
invalidate();
processSwapped();
}
});
hoverViewAnimator.start();
} else {
touchEventsCancelled();
}
}
/**
* Resets all the appropriate fields to a default state.
*/
private void touchEventsCancelled() {
if (mCellIsMobile) {
mAboveItemId = INVALID_ID;
mMobileItemId = INVALID_ID;
mBelowItemId = INVALID_ID;
setAllVisible();
mHoverCell = null;
invalidate();
processSwapped();
}
mCellIsMobile = false;
mIsMobileScrolling = false;
mActivePointerId = INVALID_POINTER_ID;
}
private void processSwapped() {
if (itemsSwapped) {
itemsSwapped = false;
if (dCallbacks != null) {
dCallbacks.onItemsSwapped(mActiveItemsList);
}
}
}
/**
* This TypeEvaluator is used to animate the BitmapDrawable back to its
* final location when the user lifts his finger by modifying the
* BitmapDrawable's bounds.
*/
private final static TypeEvaluator<Rect> sBoundEvaluator = new TypeEvaluator<Rect>() {
public Rect evaluate(float fraction, Rect startValue, Rect endValue) {
return new Rect(interpolate(startValue.left, endValue.left, fraction),
interpolate(startValue.top, endValue.top, fraction),
interpolate(startValue.right, endValue.right, fraction),
interpolate(startValue.bottom, endValue.bottom, fraction));
}
public int interpolate(int start, int end, float fraction) {
return (int) (start + fraction * (end - start));
}
};
/**
* Determines whether this listview is in a scrolling state invoked
* by the fact that the hover cell is out of the bounds of the listview;
*/
private void handleMobileCellScroll() {
mIsMobileScrolling = handleMobileCellScroll(mHoverCellCurrentBounds);
}
/**
* This method is in charge of determining if the hover cell is above
* or below the bounds of the listview. If so, the listview does an appropriate
* upward or downward smooth scroll so as to reveal new items.
*/
public boolean handleMobileCellScroll(Rect r) {
int offset = computeVerticalScrollOffset();
int height = getHeight();
int extent = computeVerticalScrollExtent();
int range = computeVerticalScrollRange();
int hoverViewTop = r.top;
int hoverHeight = r.height();
if (hoverViewTop <= 0 && offset > 0) {
smoothScrollBy(-mSmoothScrollAmountAtEdge, 0);
return true;
}
if (hoverViewTop + hoverHeight >= height && (offset + extent) < range) {
smoothScrollBy(mSmoothScrollAmountAtEdge, 0);
return true;
}
return false;
}
public void setItemsList(List<Object> itemsList) {
mItemsList = itemsList;
}
/*
* Define items which can be moved
* mActiveItemsList == null means all items are movable
*/
public void setActiveItemsList(List<Object> mActiveItemsList) {
this.mActiveItemsList = mActiveItemsList;
}
/**
* This scroll listener is added to the listview in order to handle cell swapping
* when the cell is either at the top or bottom edge of the listview. If the hover
* cell is at either edge of the listview, the listview will begin scrolling. As
* scrolling takes place, the listview continuously checks if new cells became visible
* and determines whether they are potential candidates for a cell swap.
*/
private AbsListView.OnScrollListener mScrollListener = new AbsListView.OnScrollListener() {
private int mPreviousFirstVisibleItem = -1;
private int mPreviousVisibleItemCount = -1;
private int mCurrentFirstVisibleItem;
private int mCurrentVisibleItemCount;
private int mCurrentScrollState;
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
int totalItemCount) {
mCurrentFirstVisibleItem = firstVisibleItem;
mCurrentVisibleItemCount = visibleItemCount;
mPreviousFirstVisibleItem = (mPreviousFirstVisibleItem == -1) ? mCurrentFirstVisibleItem
: mPreviousFirstVisibleItem;
mPreviousVisibleItemCount = (mPreviousVisibleItemCount == -1) ? mCurrentVisibleItemCount
: mPreviousVisibleItemCount;
checkAndHandleFirstVisibleCellChange();
checkAndHandleLastVisibleCellChange();
mPreviousFirstVisibleItem = mCurrentFirstVisibleItem;
mPreviousVisibleItemCount = mCurrentVisibleItemCount;
}
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
mCurrentScrollState = scrollState;
mScrollState = scrollState;
isScrollCompleted();
}
/**
* This method is in charge of invoking 1 of 2 actions. Firstly, if the listview
* is in a state of scrolling invoked by the hover cell being outside the bounds
* of the listview, then this scrolling event is continued. Secondly, if the hover
* cell has already been released, this invokes the animation for the hover cell
* to return to its correct position after the listview has entered an idle scroll
* state.
*/
private void isScrollCompleted() {
if (mCurrentVisibleItemCount > 0 && mCurrentScrollState == SCROLL_STATE_IDLE) {
if (mCellIsMobile && mIsMobileScrolling) {
handleMobileCellScroll();
} else if (mIsWaitingForScrollFinish) {
touchEventsEnded();
}
}
}
/**
* Determines if the listview scrolled up enough to reveal a new cell at the
* top of the list. If so, then the appropriate parameters are updated.
*/
public void checkAndHandleFirstVisibleCellChange() {
if (mCurrentFirstVisibleItem != mPreviousFirstVisibleItem) {
if (mCellIsMobile && mMobileItemId != INVALID_ID) {
updateNeighborViewsForID(mMobileItemId);
handleCellSwitch();
}
}
}
/**
* Determines if the listview scrolled down enough to reveal a new cell at the
* bottom of the list. If so, then the appropriate parameters are updated.
*/
public void checkAndHandleLastVisibleCellChange() {
int currentLastVisibleItem = mCurrentFirstVisibleItem + mCurrentVisibleItemCount;
int previousLastVisibleItem = mPreviousFirstVisibleItem + mPreviousVisibleItemCount;
if (currentLastVisibleItem != previousLastVisibleItem) {
if (mCellIsMobile && mMobileItemId != INVALID_ID) {
updateNeighborViewsForID(mMobileItemId);
handleCellSwitch();
}
}
}
};
/**
* Returns the most inner view that contains the xy coordinate.
*
* @param v This method gets called recursively. The initial call should be the root view.
* @param x The X location to be tested.
* @param y The Y location to be tested.
* @return Returns the most inner view that contains the XY coordinate or null if no view could be found.
*/
private View findViewAtPositionWithTag(View v, int x, int y, String tag) {
View vXY = null;
if (v instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) v;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View c = viewGroup.getChildAt(i);
int loc[] = new int[2];
c.getLocationOnScreen(loc);
if ((x >= loc[0] && (x <= (loc[0] + c.getWidth()))) && (y >= loc[1] && (y <= (loc[1] + c.getHeight())))) {
vXY = c;
View viewAtPosition = findViewAtPositionWithTag(c, x, y, tag);
if ((viewAtPosition != null) && (viewAtPosition.getTag() != null) && viewAtPosition.getTag().equals(tag)) {
vXY = viewAtPosition;
break;
}
}
}
}
return vXY;
}
}

View file

@ -0,0 +1,9 @@
package net.osmand.plus.views.controls;
import java.util.List;
public interface DynamicListViewCallbacks {
void onItemsSwapped(final List<Object> items);
}

View file

@ -0,0 +1,66 @@
package net.osmand.plus.views.controls;
import android.content.Context;
import android.support.annotation.NonNull;
import android.widget.ArrayAdapter;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
public class StableArrayAdapter extends ArrayAdapter<Object> {
final int INVALID_ID = -1;
List<Object> objects;
List<Object> activeObjects;
HashMap<Object, Integer> mIdMap = new HashMap<>();
public StableArrayAdapter(Context context, int textViewResourceId, int titleId,
List<Object> objects, List<Object> activeObjects) {
super(context, textViewResourceId, titleId, objects);
updateObjects(objects, activeObjects);
}
public List<Object> getObjects() {
return objects;
}
public List<Object> getActiveObjects() {
return activeObjects;
}
public void updateObjects(List<Object> objects, List<Object> activeObjects) {
this.objects = objects;
this.activeObjects = activeObjects;
HashMap<Object, Integer> idMap = new HashMap<>();
for (int i = 0; i < objects.size(); ++i) {
idMap.put(objects.get(i), i);
}
mIdMap = idMap;
}
@Override
public Object getItem(int position) {
return objects.get(position);
}
@Override
public long getItemId(int position) {
if (position < 0 || position >= mIdMap.size()) {
return INVALID_ID;
}
Object item = getItem(position);
if (mIdMap.containsKey(item)) {
return mIdMap.get(item);
} else {
return INVALID_ID;
}
}
@Override
public boolean hasStableIds() {
return true;
}
}

View file

@ -321,7 +321,7 @@ public class MapInfoWidgetsFactory {
boolean updated = updateVisibility(waypointInfoBar, true); boolean updated = updateVisibility(waypointInfoBar, true);
// pass top bar to make it clickable // pass top bar to make it clickable
WaypointDialogHelper.updatePointInfoView(map.getMyApplication(), map, topBar, WaypointDialogHelper.updatePointInfoView(map.getMyApplication(), map, topBar,
pnt, true, !map.getMyApplication().getSettings().isLightContent()); pnt, true, !map.getMyApplication().getSettings().isLightContent(), false);
if (updated || changed) { if (updated || changed) {
ImageView all = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_more); ImageView all = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_more);
ImageView remove = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_close); ImageView remove = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_close);