Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ac89c33e3f
17 changed files with 1247 additions and 578 deletions
|
@ -179,7 +179,6 @@
|
||||||
<activity android:name="net.osmand.access.SettingsAccessibilityActivity" android:configChanges="keyboardHidden|orientation" />
|
<activity android:name="net.osmand.access.SettingsAccessibilityActivity" android:configChanges="keyboardHidden|orientation" />
|
||||||
|
|
||||||
<activity android:name="net.osmand.plus.activities.search.SearchActivity" android:label="@string/search_activity" />
|
<activity android:name="net.osmand.plus.activities.search.SearchActivity" android:label="@string/search_activity" />
|
||||||
<activity android:name="net.osmand.plus.activities.ShowRouteInfoActivity" android:label="@string/show_route" />
|
|
||||||
<activity android:name="net.osmand.plus.activities.FavoritesListActivity" android:label="@string/favourites_list_activity" />
|
<activity android:name="net.osmand.plus.activities.FavoritesListActivity" android:label="@string/favourites_list_activity" />
|
||||||
<activity android:name=".myplaces.FavoritesActivity" android:windowSoftInputMode="adjustPan" />
|
<activity android:name=".myplaces.FavoritesActivity" android:windowSoftInputMode="adjustPan" />
|
||||||
<activity android:name="net.osmand.plus.activities.TrackActivity"/>
|
<activity android:name="net.osmand.plus.activities.TrackActivity"/>
|
||||||
|
|
|
@ -129,6 +129,12 @@ android {
|
||||||
dimension "version"
|
dimension "version"
|
||||||
applicationId "net.osmand.plus"
|
applicationId "net.osmand.plus"
|
||||||
}
|
}
|
||||||
|
fulldev {
|
||||||
|
dimension "version"
|
||||||
|
applicationId "net.osmand.plus"
|
||||||
|
resConfig "en"
|
||||||
|
//resConfigs "xxhdpi", "nodpi"
|
||||||
|
}
|
||||||
|
|
||||||
// CoreVersion
|
// CoreVersion
|
||||||
legacy {
|
legacy {
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
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_weight="1"/>
|
android:layout_weight="1"
|
||||||
|
android:text="Route details"/>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/start_navigation"
|
android:id="@+id/start_navigation"
|
||||||
|
|
265
OsmAnd/res/layout/route_info_header.xml
Normal file
265
OsmAnd/res/layout/route_info_header.xml
Normal file
|
@ -0,0 +1,265 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="?attr/bg_color"
|
||||||
|
android:paddingTop="8dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/route_altitude"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"/>
|
||||||
|
|
||||||
|
<com.github.mikephil.charting.charts.LineChart
|
||||||
|
android:id="@+id/chart"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="100dp"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:background="?attr/bg_color"
|
||||||
|
android:paddingBottom="4dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="16dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/average_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:src="@drawable/ic_action_altitude_average"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginLeft="18dp">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/average_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:text="40 m"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/average_desc"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:text="@string/average_altitude"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_sub_text_size"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="16dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/range_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:src="@drawable/ic_action_altitude_average"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginLeft="18dp">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/range_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:text="30m -53m"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/range_desc"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:text="@string/altitude_range"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_sub_text_size"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:background="?attr/bg_color"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="8dp">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/dashboard_divider"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="16dp">
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/dashboard_divider"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:background="?attr/bg_color"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="16dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/descent_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:src="@drawable/ic_action_altitude_descent"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginLeft="18dp">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/descent_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:text="164"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/descent_desc"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:text="@string/altitude_descent"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_sub_text_size"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="16dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/ascent_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:src="@drawable/ic_action_altitude_ascent"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginLeft="18dp">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/ascent_text"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:text="174"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/ascent_desc"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:text="@string/altitude_ascent"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_sub_text_size"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<include layout="@layout/list_item_divider"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
237
OsmAnd/res/layout/route_info_layout.xml
Normal file
237
OsmAnd/res/layout/route_info_layout.xml
Normal file
|
@ -0,0 +1,237 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:app="http://schemas.android.com/tools"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<android.support.design.widget.AppBarLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<android.support.v7.widget.Toolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/bg_color"
|
||||||
|
android:minHeight="@dimen/dashboard_map_toolbar"
|
||||||
|
android:theme="?attr/toolbar_theme"
|
||||||
|
app:contentInsetLeft="54dp"
|
||||||
|
app:contentInsetStart="54dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="14dp"
|
||||||
|
android:layout_marginTop="14dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:lines="1"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="@string/show_route"
|
||||||
|
android:textColor="?attr/searchbar_text"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
android:textSize="@dimen/default_list_text_size_large"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/print_route"
|
||||||
|
style="@style/Widget.AppCompat.ActionButton"
|
||||||
|
android:layout_width="44dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:contentDescription="@string/print_route"
|
||||||
|
android:src="@drawable/ic_action_gprint_dark"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/save_as_gpx"
|
||||||
|
style="@style/Widget.AppCompat.ActionButton"
|
||||||
|
android:layout_width="44dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:contentDescription="@string/shared_string_save_as_gpx"
|
||||||
|
android:src="@drawable/ic_action_gsave_dark"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/share_as_gpx"
|
||||||
|
style="@style/Widget.AppCompat.ActionButton"
|
||||||
|
android:layout_width="44dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:contentDescription="@string/share_route_as_gpx"
|
||||||
|
android:src="@drawable/ic_action_gshare_dark"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</android.support.v7.widget.Toolbar>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:background="?attr/bg_color"
|
||||||
|
android:paddingTop="4dp"
|
||||||
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="16dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/distance_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:src="@drawable/ic_action_polygom_dark"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginLeft="18dp">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/distance"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:text="26 km"
|
||||||
|
android:textColor="?attr/routeParameterTitleColor"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
android:textSize="@dimen/default_list_text_size"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/distance_desc"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:text="@string/total_distance"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_sub_text_size"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="16dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/time_icon"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:src="@drawable/ic_action_time_span"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_marginLeft="18dp">
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/time"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:text="20 min"
|
||||||
|
android:textColor="?attr/routeParameterTitleColor"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
android:textSize="@dimen/default_list_text_size"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/time_desc"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:text="@string/shared_string_time"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textSize="@dimen/default_sub_text_size"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:background="@color/map_widget_blue">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/go_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:clickable="true"
|
||||||
|
android:background="?android:attr/selectableItemBackground"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:src="@drawable/ic_action_start_navigation"/>
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:text="@string/shared_string_go"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
osmand:textAllCapsCompat="true"
|
||||||
|
android:textColor="@color/color_white"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</android.support.design.widget.AppBarLayout>
|
||||||
|
|
||||||
|
<FrameLayout android:id="@+id/listContainer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ListView android:id="@android:id/list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:drawSelectorOnTop="true"
|
||||||
|
android:divider="@null"
|
||||||
|
android:dividerHeight="0dp"/>
|
||||||
|
<TextView android:id="@+id/internalEmpty"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -2,13 +2,22 @@
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/bg_color"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="@dimen/list_item_height"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:minWidth="50dp"
|
android:minWidth="42dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="@dimen/list_content_padding"
|
android:layout_marginLeft="@dimen/list_content_padding"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -17,8 +26,9 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:textColor="@color/color_distance"
|
android:textColor="@color/color_distance"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_sub_text_size"
|
||||||
tools:text="@string/app_version"/>
|
android:textStyle="bold"
|
||||||
|
tools:text="631 m"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/cumulative_time"
|
android:id="@+id/cumulative_time"
|
||||||
|
@ -26,8 +36,9 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:textColor="@color/color_distance"
|
android:textColor="@color/color_distance"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_sub_text_size"
|
||||||
tools:text="@string/app_version"/>
|
android:textStyle="bold"
|
||||||
|
tools:text="0:50"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
@ -35,12 +46,14 @@
|
||||||
android:layout_marginLeft="@dimen/list_header_padding"
|
android:layout_marginLeft="@dimen/list_header_padding"
|
||||||
android:layout_marginRight="@dimen/list_header_padding"
|
android:layout_marginRight="@dimen/list_header_padding"
|
||||||
android:layout_width="32dp"
|
android:layout_width="32dp"
|
||||||
android:layout_height="32dp"/>
|
android:layout_height="32dp"
|
||||||
|
android:layout_gravity="center_vertical"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:minWidth="50dp"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:minWidth="42dp"
|
||||||
android:layout_marginRight="@dimen/list_header_padding"
|
android:layout_marginRight="@dimen/list_header_padding"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
@ -50,7 +63,8 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:textColor="@color/color_distance"
|
android:textColor="@color/color_distance"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_sub_text_size"
|
||||||
|
android:textStyle="bold"
|
||||||
tools:text="@string/app_version"/>
|
tools:text="@string/app_version"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -58,20 +72,31 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_sub_text_size"
|
||||||
android:textColor="@color/color_distance"
|
android:textColor="@color/color_distance"
|
||||||
|
android:textStyle="bold"
|
||||||
tools:text="@string/app_version"/>
|
tools:text="@string/app_version"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/description"
|
android:id="@+id/description"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="5dp"
|
android:layout_marginRight="5dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:textSize="@dimen/default_list_text_size"
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
tools:text="@string/lorem_ipsum"
|
tools:text="Head Dmytrivska Street"
|
||||||
android:text=""/>
|
android:text=""/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?attr/dashboard_divider"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
|
@ -4,6 +4,7 @@
|
||||||
<attr name="maxVisibleWidth" format="dimension"/>
|
<attr name="maxVisibleWidth" format="dimension"/>
|
||||||
</declare-styleable>
|
</declare-styleable>
|
||||||
<declare-styleable name="OsmAndTheme">
|
<declare-styleable name="OsmAndTheme">
|
||||||
|
<attr name="routeParameterTitleColor" format="color"/>
|
||||||
<!-- list colors -->
|
<!-- list colors -->
|
||||||
<attr name="ctx_menu_info_divider" format="color"/>
|
<attr name="ctx_menu_info_divider" format="color"/>
|
||||||
<attr name="searchbar_text" format="color"/>
|
<attr name="searchbar_text" format="color"/>
|
||||||
|
|
|
@ -9,6 +9,13 @@
|
||||||
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="route_altitude">Route altitude</string>
|
||||||
|
<string name="altitude_descent">Descent</string>
|
||||||
|
<string name="altitude_ascent">Ascent</string>
|
||||||
|
<string name="altitude_range">Altitude range</string>
|
||||||
|
<string name="average_altitude">Average</string>
|
||||||
|
<string name="shared_string_time">Time</string>
|
||||||
|
<string name="total_distance">Total distance</string>
|
||||||
<string name="routing_attr_height_relief_smoothness_factor_name">Relief smoothness factor</string>
|
<string name="routing_attr_height_relief_smoothness_factor_name">Relief smoothness factor</string>
|
||||||
<string name="routing_attr_height_relief_smoothness_factor_description">More plains or more hills</string>
|
<string name="routing_attr_height_relief_smoothness_factor_description">More plains or more hills</string>
|
||||||
<string name="routing_attr_height_obstacles_name">Use elevation data</string>
|
<string name="routing_attr_height_obstacles_name">Use elevation data</string>
|
||||||
|
|
|
@ -76,6 +76,7 @@
|
||||||
|
|
||||||
<!-- Osmand themes styles -->
|
<!-- Osmand themes styles -->
|
||||||
<style name="OsmandLightTheme" parent="Theme.AppCompat.Light">
|
<style name="OsmandLightTheme" parent="Theme.AppCompat.Light">
|
||||||
|
<item name="routeParameterTitleColor">@color/color_myloc_distance</item>
|
||||||
<item name="ctx_menu_info_divider">@color/ctx_menu_info_divider_light</item>
|
<item name="ctx_menu_info_divider">@color/ctx_menu_info_divider_light</item>
|
||||||
<item name="searchbar_text">@color/searchbar_text_light</item>
|
<item name="searchbar_text">@color/searchbar_text_light</item>
|
||||||
<item name="searchbar_text_hint">@color/searchbar_text_hint_light</item>
|
<item name="searchbar_text_hint">@color/searchbar_text_hint_light</item>
|
||||||
|
@ -239,6 +240,7 @@
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="OsmandDarkTheme" parent="Theme.AppCompat">
|
<style name="OsmandDarkTheme" parent="Theme.AppCompat">
|
||||||
|
<item name="routeParameterTitleColor">@color/osmand_orange</item>
|
||||||
<item name="ctx_menu_info_divider">@color/ctx_menu_info_divider_dark</item>
|
<item name="ctx_menu_info_divider">@color/ctx_menu_info_divider_dark</item>
|
||||||
<item name="searchbar_text">@color/searchbar_text_dark</item>
|
<item name="searchbar_text">@color/searchbar_text_dark</item>
|
||||||
<item name="searchbar_text_hint">@color/searchbar_text_hint_dark</item>
|
<item name="searchbar_text_hint">@color/searchbar_text_hint_dark</item>
|
||||||
|
|
|
@ -5,13 +5,27 @@ import android.content.Context;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.annotation.ColorInt;
|
import android.support.annotation.ColorInt;
|
||||||
|
import android.support.v4.app.ActivityCompat;
|
||||||
|
import android.support.v4.content.ContextCompat;
|
||||||
|
|
||||||
|
import com.github.mikephil.charting.charts.LineChart;
|
||||||
|
import com.github.mikephil.charting.components.Legend;
|
||||||
|
import com.github.mikephil.charting.components.XAxis;
|
||||||
|
import com.github.mikephil.charting.components.YAxis;
|
||||||
|
import com.github.mikephil.charting.data.Entry;
|
||||||
|
import com.github.mikephil.charting.data.LineData;
|
||||||
|
import com.github.mikephil.charting.data.LineDataSet;
|
||||||
|
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||||
|
import com.github.mikephil.charting.utils.Utils;
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
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.data.RotatedTileBox;
|
||||||
|
import net.osmand.plus.myplaces.SelectedGPXFragment;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.plus.views.Renderable;
|
import net.osmand.plus.views.Renderable;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -48,6 +62,8 @@ import java.util.Map;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import static com.github.mikephil.charting.components.XAxis.XAxisPosition.BOTTOM;
|
||||||
|
|
||||||
public class GPXUtilities {
|
public class GPXUtilities {
|
||||||
public final static Log log = PlatformUtil.getLog(GPXUtilities.class);
|
public final static Log log = PlatformUtil.getLog(GPXUtilities.class);
|
||||||
|
|
||||||
|
@ -1264,4 +1280,109 @@ public class GPXUtilities {
|
||||||
to.warning = from.warning;
|
to.warning = from.warning;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setupGPXChart(LineChart mChart, boolean useFeet) {
|
||||||
|
//mChart.setHardwareAccelerationEnabled(true);
|
||||||
|
mChart.setTouchEnabled(true);
|
||||||
|
mChart.setDragEnabled(true);
|
||||||
|
mChart.setScaleEnabled(true);
|
||||||
|
mChart.setPinchZoom(true);
|
||||||
|
mChart.setScaleYEnabled(false);
|
||||||
|
mChart.setAutoScaleMinMaxEnabled(true);
|
||||||
|
mChart.setDrawBorders(false);
|
||||||
|
mChart.getDescription().setEnabled(false);
|
||||||
|
mChart.setMaxVisibleValueCount(10);
|
||||||
|
mChart.setMinOffset(0f);
|
||||||
|
|
||||||
|
mChart.setExtraTopOffset(24f);
|
||||||
|
mChart.setExtraBottomOffset(16f);
|
||||||
|
|
||||||
|
// create a custom MarkerView (extend MarkerView) and specify the layout
|
||||||
|
// to use for it
|
||||||
|
SelectedGPXFragment.MyMarkerView mv = new SelectedGPXFragment.MyMarkerView(mChart.getContext(), R.layout.chart_marker_view, useFeet);
|
||||||
|
mv.setChartView(mChart); // For bounds control
|
||||||
|
mChart.setMarker(mv); // Set the marker to the chart
|
||||||
|
mChart.setDrawMarkers(true);
|
||||||
|
|
||||||
|
XAxis xAxis = mChart.getXAxis();
|
||||||
|
xAxis.setDrawAxisLine(false);
|
||||||
|
xAxis.setDrawGridLines(false);
|
||||||
|
xAxis.setDrawAxisLine(false);
|
||||||
|
xAxis.setPosition(BOTTOM);
|
||||||
|
|
||||||
|
YAxis yAxis = mChart.getAxisLeft();
|
||||||
|
yAxis.enableGridDashedLine(10f, 5f, 0f);
|
||||||
|
yAxis.setGridColor(ActivityCompat.getColor(mChart.getContext(), R.color.divider_color));
|
||||||
|
yAxis.setDrawAxisLine(false);
|
||||||
|
yAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
|
||||||
|
yAxis.setXOffset(16f);
|
||||||
|
yAxis.setYOffset(-6f);
|
||||||
|
|
||||||
|
Legend legend = mChart.getLegend();
|
||||||
|
legend.setEnabled(false);
|
||||||
|
|
||||||
|
mChart.getAxisRight().setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setGPXChartData(LineChart mChart, GPXTrackAnalysis analysis, int fillResourceId, boolean useFeet) {
|
||||||
|
final float convEle = useFeet ? 3.28084f : 1.0f;
|
||||||
|
final float divX = analysis.totalDistance > 1000 ? 1000f : 1f;
|
||||||
|
|
||||||
|
ArrayList<Entry> values = new ArrayList<>();
|
||||||
|
List<Elevation> elevationData = analysis.elevationData;
|
||||||
|
float nextX = 0;
|
||||||
|
float nextY;
|
||||||
|
for (Elevation e : elevationData) {
|
||||||
|
if (e.distance > 0) {
|
||||||
|
nextX += (float) e.distance / divX;
|
||||||
|
nextY = (float) (e.elevation * convEle);
|
||||||
|
values.add(new Entry(nextX, nextY));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LineDataSet dataSet = new LineDataSet(values, "");
|
||||||
|
|
||||||
|
dataSet.setColor(Color.BLACK);
|
||||||
|
dataSet.setDrawValues(false);
|
||||||
|
dataSet.setLineWidth(0f);
|
||||||
|
dataSet.setValueTextSize(9f);
|
||||||
|
dataSet.setDrawFilled(true);
|
||||||
|
dataSet.setFormLineWidth(1f);
|
||||||
|
dataSet.setFormSize(15.f);
|
||||||
|
|
||||||
|
dataSet.setDrawCircles(false);
|
||||||
|
dataSet.setDrawCircleHole(false);
|
||||||
|
|
||||||
|
dataSet.setHighlightEnabled(true);
|
||||||
|
dataSet.setDrawVerticalHighlightIndicator(true);
|
||||||
|
dataSet.setDrawHorizontalHighlightIndicator(false);
|
||||||
|
dataSet.setHighLightColor(Color.BLACK);
|
||||||
|
|
||||||
|
if (Utils.getSDKInt() >= 18) {
|
||||||
|
// fill drawable only supported on api level 18 and above
|
||||||
|
Drawable drawable = ContextCompat.getDrawable(mChart.getContext(), fillResourceId);
|
||||||
|
dataSet.setFillDrawable(drawable);
|
||||||
|
} else {
|
||||||
|
dataSet.setFillColor(ContextCompat.getColor(mChart.getContext(), fillResourceId));
|
||||||
|
}
|
||||||
|
ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
|
||||||
|
dataSets.add(dataSet); // add the datasets
|
||||||
|
|
||||||
|
// create a data object with the datasets
|
||||||
|
LineData data = new LineData(dataSets);
|
||||||
|
|
||||||
|
// set data
|
||||||
|
mChart.setData(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TrkSegment buildTrkSegment(float[] heightArray) {
|
||||||
|
TrkSegment segment = new TrkSegment();
|
||||||
|
if (heightArray.length > 0) {
|
||||||
|
for (int i = 0; i < heightArray.length / 2; i++) {
|
||||||
|
WptPt p = new WptPt(0, 0, 0, heightArray[i * 2 + 1], 0, 0);
|
||||||
|
segment.points.add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return segment;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,6 @@ import net.osmand.Location;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.StateChangedListener;
|
import net.osmand.StateChangedListener;
|
||||||
import net.osmand.ValueHolder;
|
import net.osmand.ValueHolder;
|
||||||
import net.osmand.access.AccessibilityPlugin;
|
|
||||||
import net.osmand.access.MapAccessibilityActions;
|
import net.osmand.access.MapAccessibilityActions;
|
||||||
import net.osmand.core.android.AtlasMapRendererView;
|
import net.osmand.core.android.AtlasMapRendererView;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
@ -89,9 +88,6 @@ import net.osmand.plus.mapcontextmenu.MapContextMenuFragment;
|
||||||
import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu;
|
import net.osmand.plus.mapcontextmenu.other.DestinationReachedMenu;
|
||||||
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
|
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
|
||||||
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenuFragment;
|
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenuFragment;
|
||||||
import net.osmand.plus.quickaction.QuickAction;
|
|
||||||
import net.osmand.plus.quickaction.QuickActionFactory;
|
|
||||||
import net.osmand.plus.quickaction.QuickActionsWidget;
|
|
||||||
import net.osmand.plus.render.RendererRegistry;
|
import net.osmand.plus.render.RendererRegistry;
|
||||||
import net.osmand.plus.resources.ResourceManager;
|
import net.osmand.plus.resources.ResourceManager;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
|
@ -573,9 +569,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (intent.getStringExtra(ShowRouteInfoActivity.START_NAVIGATION) != null) {
|
|
||||||
mapLayers.getMapControlsLayer().startNavigation();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mapView.refreshMap(true);
|
mapView.refreshMap(true);
|
||||||
if (atlasMapRendererView != null) {
|
if (atlasMapRendererView != null) {
|
||||||
|
|
|
@ -18,7 +18,6 @@ import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
@ -172,13 +171,6 @@ public class MapActivityActions implements DialogProvider {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void aboutRoute() {
|
|
||||||
Intent intent = new Intent(mapActivity, ShowRouteInfoActivity.class);
|
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
mapActivity.startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Location getLastKnownLocation() {
|
protected Location getLastKnownLocation() {
|
||||||
return getMyApplication().getLocationProvider().getLastKnownLocation();
|
return getMyApplication().getLocationProvider().getLastKnownLocation();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,390 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.osmand.plus.activities;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import net.osmand.Location;
|
|
||||||
import net.osmand.data.PointDescription;
|
|
||||||
import net.osmand.plus.GPXUtilities;
|
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.OsmandSettings;
|
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
|
|
||||||
import net.osmand.plus.routing.RouteDirectionInfo;
|
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
|
||||||
import net.osmand.plus.views.TurnPathHelper;
|
|
||||||
import net.osmand.util.Algorithms;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.content.FileProvider;
|
|
||||||
import android.support.v4.view.MenuItemCompat;
|
|
||||||
import android.text.Html;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class ShowRouteInfoActivity extends OsmandListActivity {
|
|
||||||
|
|
||||||
|
|
||||||
private static final int SAVE = 0;
|
|
||||||
private static final int SHARE = 1;
|
|
||||||
private static final int PRINT = 2;
|
|
||||||
private RoutingHelper helper;
|
|
||||||
private TextView header;
|
|
||||||
private DisplayMetrics dm;
|
|
||||||
|
|
||||||
public static final String START_NAVIGATION = "START_NAVIGATION";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle icicle) {
|
|
||||||
super.onCreate(icicle);
|
|
||||||
setContentView(R.layout.default_list_view);
|
|
||||||
ListView lv = (ListView) findViewById(android.R.id.list);
|
|
||||||
View headerView = getLayoutInflater().inflate(R.layout.route_details_header, null);
|
|
||||||
header = (TextView) headerView.findViewById(R.id.header);
|
|
||||||
helper = ((OsmandApplication)getApplication()).getRoutingHelper();
|
|
||||||
((ImageView)
|
|
||||||
headerView.findViewById(R.id.start_navigation)).setImageDrawable(
|
|
||||||
getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_start_navigation, R.color.color_myloc_distance));
|
|
||||||
headerView.findViewById(R.id.start_navigation).setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
Intent i = new Intent(ShowRouteInfoActivity.this, MapActivity.class);
|
|
||||||
i.putExtra(START_NAVIGATION, START_NAVIGATION);
|
|
||||||
startActivity(i);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
lv.addHeaderView(headerView);
|
|
||||||
dm = new DisplayMetrics();
|
|
||||||
getWindowManager().getDefaultDisplay().getMetrics(dm);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
if (item.getItemId() == SAVE) {
|
|
||||||
MapActivityActions.createSaveDirections(ShowRouteInfoActivity.this, helper).show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (item.getItemId() == SHARE) {
|
|
||||||
final GPXFile gpx = helper.generateGPXFileWithRoute();
|
|
||||||
final Uri fileUri = Uri.fromFile(new File(gpx.path));
|
|
||||||
File dir = new File(ShowRouteInfoActivity.this.getCacheDir(), "share");
|
|
||||||
if (!dir.exists()) {
|
|
||||||
dir.mkdir();
|
|
||||||
}
|
|
||||||
File dst = new File(dir, "route.gpx");
|
|
||||||
try {
|
|
||||||
FileWriter fw = new FileWriter(dst);
|
|
||||||
GPXUtilities.writeGpx(fw, gpx, getMyApplication());
|
|
||||||
fw.close();
|
|
||||||
final Intent sendIntent = new Intent();
|
|
||||||
sendIntent.setAction(Intent.ACTION_SEND);
|
|
||||||
sendIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(generateHtml(((RouteInfoAdapter)getListAdapter()),
|
|
||||||
helper.getGeneralRouteInformation()).toString()));
|
|
||||||
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_route_subject));
|
|
||||||
sendIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
|
|
||||||
sendIntent.putExtra(
|
|
||||||
Intent.EXTRA_STREAM,
|
|
||||||
FileProvider.getUriForFile(ShowRouteInfoActivity.this,
|
|
||||||
ShowRouteInfoActivity.this.getPackageName() + ".fileprovider", dst));
|
|
||||||
sendIntent.setType("text/plain");
|
|
||||||
startActivity(sendIntent);
|
|
||||||
} catch (IOException e) {
|
|
||||||
// Toast.makeText(getActivity(), "Error sharing favorites: " + e.getMessage(),
|
|
||||||
// Toast.LENGTH_LONG).show();
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (item.getItemId() == PRINT) {
|
|
||||||
print();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.onOptionsItemSelected(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
header.setText(helper.getGeneralRouteInformation());
|
|
||||||
float f = Math.min(dm.widthPixels/(dm.density*160),dm.heightPixels/(dm.density*160));
|
|
||||||
if (f >= 3) {
|
|
||||||
// large screen
|
|
||||||
header.setTextSize(dm.scaledDensity * 23);
|
|
||||||
}
|
|
||||||
setListAdapter(new RouteInfoAdapter(helper.getRouteDirections()));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
createMenuItem(menu, PRINT, R.string.print_route,
|
|
||||||
R.drawable.ic_action_gprint_dark,
|
|
||||||
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
|
||||||
createMenuItem(menu, SAVE, R.string.shared_string_save_as_gpx,
|
|
||||||
R.drawable.ic_action_gsave_dark,
|
|
||||||
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
|
||||||
createMenuItem(menu, SHARE, R.string.share_route_as_gpx,
|
|
||||||
R.drawable.ic_action_gshare_dark,
|
|
||||||
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
if(position < 1){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
RouteDirectionInfo item = ((RouteInfoAdapter)getListAdapter()).getItem(position - 1);
|
|
||||||
Location loc = helper.getLocationFromRouteDirection(item);
|
|
||||||
if(loc != null){
|
|
||||||
MapRouteInfoMenu.directionInfo = position - 1;
|
|
||||||
OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
|
|
||||||
settings.setMapLocationToShow(loc.getLatitude(),loc.getLongitude(),
|
|
||||||
Math.max(13, settings.getLastKnownMapZoom()),
|
|
||||||
new PointDescription(PointDescription.POINT_TYPE_MARKER, item.getDescriptionRoutePart() + " " + getTimeDescription(item)),
|
|
||||||
false, null);
|
|
||||||
MapActivity.launchMapActivityMoveToTop(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class RouteInfoAdapter extends ArrayAdapter<RouteDirectionInfo> {
|
|
||||||
public class CumulativeInfo {
|
|
||||||
public int distance;
|
|
||||||
public int time;
|
|
||||||
|
|
||||||
public CumulativeInfo() {
|
|
||||||
distance = 0;
|
|
||||||
time = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final int lastItemIndex;
|
|
||||||
|
|
||||||
RouteInfoAdapter(List<RouteDirectionInfo> list) {
|
|
||||||
super(ShowRouteInfoActivity.this, R.layout.route_info_list_item, list);
|
|
||||||
lastItemIndex = list.size() - 1;
|
|
||||||
this.setNotifyOnChange(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
|
||||||
View row = convertView;
|
|
||||||
if (row == null) {
|
|
||||||
LayoutInflater inflater = getLayoutInflater();
|
|
||||||
row = inflater.inflate(R.layout.route_info_list_item, parent, false);
|
|
||||||
}
|
|
||||||
RouteDirectionInfo model = (RouteDirectionInfo) getItem(position);
|
|
||||||
TextView label = (TextView) row.findViewById(R.id.description);
|
|
||||||
TextView distanceLabel = (TextView) row.findViewById(R.id.distance);
|
|
||||||
TextView timeLabel = (TextView) row.findViewById(R.id.time);
|
|
||||||
TextView cumulativeDistanceLabel = (TextView) row.findViewById(R.id.cumulative_distance);
|
|
||||||
TextView cumulativeTimeLabel = (TextView) row.findViewById(R.id.cumulative_time);
|
|
||||||
ImageView icon = (ImageView) row.findViewById(R.id.direction);
|
|
||||||
|
|
||||||
TurnPathHelper.RouteDrawable drawable = new TurnPathHelper.RouteDrawable(getResources(), true);
|
|
||||||
drawable.setRouteType(model.getTurnType());
|
|
||||||
icon.setImageDrawable(drawable);
|
|
||||||
|
|
||||||
label.setText(String.valueOf(position + 1) + ". " + model.getDescriptionRoutePart());
|
|
||||||
if (model.distance > 0) {
|
|
||||||
distanceLabel.setText(OsmAndFormatter.getFormattedDistance(
|
|
||||||
model.distance, getMyApplication()));
|
|
||||||
timeLabel.setText(getTimeDescription(model));
|
|
||||||
row.setContentDescription(label.getText() + " " + timeLabel.getText()); //$NON-NLS-1$
|
|
||||||
} else {
|
|
||||||
if (label.getText().equals(String.valueOf(position + 1) + ". ")) {
|
|
||||||
label.setText(String.valueOf(position + 1) + ". " + getString((position != lastItemIndex) ? R.string.arrived_at_intermediate_point : R.string.arrived_at_destination));
|
|
||||||
}
|
|
||||||
distanceLabel.setText(""); //$NON-NLS-1$
|
|
||||||
timeLabel.setText(""); //$NON-NLS-1$
|
|
||||||
row.setContentDescription(""); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
CumulativeInfo cumulativeInfo = getRouteDirectionCumulativeInfo(position);
|
|
||||||
cumulativeDistanceLabel.setText(OsmAndFormatter.getFormattedDistance(
|
|
||||||
cumulativeInfo.distance, getMyApplication()));
|
|
||||||
cumulativeTimeLabel.setText(Algorithms.formatDuration(cumulativeInfo.time, getMyApplication().accessibilityEnabled()));
|
|
||||||
return row;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CumulativeInfo getRouteDirectionCumulativeInfo(int position) {
|
|
||||||
CumulativeInfo cumulativeInfo = new CumulativeInfo();
|
|
||||||
for (int i = 0; i < position; i++) {
|
|
||||||
RouteDirectionInfo routeDirectionInfo = (RouteDirectionInfo) getItem(i);
|
|
||||||
cumulativeInfo.time += routeDirectionInfo.getExpectedTime();
|
|
||||||
cumulativeInfo.distance += routeDirectionInfo.distance;
|
|
||||||
}
|
|
||||||
return cumulativeInfo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getTimeDescription(RouteDirectionInfo model) {
|
|
||||||
final int timeInSeconds = model.getExpectedTime();
|
|
||||||
return Algorithms.formatDuration(timeInSeconds, getMyApplication().accessibilityEnabled());
|
|
||||||
}
|
|
||||||
|
|
||||||
void print() {
|
|
||||||
File file = generateRouteInfoHtml((RouteInfoAdapter)getListAdapter(),
|
|
||||||
helper.getGeneralRouteInformation());
|
|
||||||
if (file.exists()) {
|
|
||||||
Uri uri = Uri.fromFile(file);
|
|
||||||
Intent browserIntent;
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // use Android Print Framework
|
|
||||||
browserIntent = new Intent(this, PrintDialogActivity.class)
|
|
||||||
.setDataAndType(uri, "text/html");
|
|
||||||
} else { // just open html document
|
|
||||||
browserIntent = new Intent(Intent.ACTION_VIEW).setDataAndType(
|
|
||||||
uri, "text/html");
|
|
||||||
}
|
|
||||||
startActivity(browserIntent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private File generateRouteInfoHtml(RouteInfoAdapter routeInfo, String title) {
|
|
||||||
File file = null;
|
|
||||||
if (routeInfo == null) {
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String FILE_NAME = "route_info.html";
|
|
||||||
StringBuilder html = generateHtmlPrint(routeInfo, title);
|
|
||||||
FileOutputStream fos = null;
|
|
||||||
try {
|
|
||||||
file = ((OsmandApplication) getApplication()).getAppPath(FILE_NAME);
|
|
||||||
fos = new FileOutputStream(file);
|
|
||||||
fos.write(html.toString().getBytes("UTF-8"));
|
|
||||||
fos.flush();
|
|
||||||
} catch (IOException e) {
|
|
||||||
file = null;
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
|
||||||
if (fos != null) {
|
|
||||||
try {
|
|
||||||
fos.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
file = null;
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return file;
|
|
||||||
}
|
|
||||||
|
|
||||||
private StringBuilder generateHtml(RouteInfoAdapter routeInfo, String title) {
|
|
||||||
StringBuilder html = new StringBuilder();
|
|
||||||
if (!TextUtils.isEmpty(title)) {
|
|
||||||
html.append("<h1>");
|
|
||||||
html.append(title);
|
|
||||||
html.append("</h1>");
|
|
||||||
}
|
|
||||||
final String NBSP = " ";
|
|
||||||
final String BR = "<br>";
|
|
||||||
for (int i = 0; i < routeInfo.getCount(); i++) {
|
|
||||||
RouteDirectionInfo routeDirectionInfo = (RouteDirectionInfo) routeInfo.getItem(i);
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(OsmAndFormatter.getFormattedDistance(routeDirectionInfo.distance, getMyApplication()));
|
|
||||||
sb.append(", ").append(NBSP);
|
|
||||||
sb.append(getTimeDescription(routeDirectionInfo));
|
|
||||||
String distance = sb.toString().replaceAll("\\s", NBSP);
|
|
||||||
String description = routeDirectionInfo.getDescriptionRoutePart();
|
|
||||||
html.append(BR);
|
|
||||||
html.append("<p>" + String.valueOf(i + 1) + ". " + NBSP + description + NBSP + "(" + distance + ")</p>");
|
|
||||||
}
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
|
|
||||||
private StringBuilder generateHtmlPrint(RouteInfoAdapter routeInfo, String title) {
|
|
||||||
StringBuilder html = new StringBuilder();
|
|
||||||
html.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
|
|
||||||
html.append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">");
|
|
||||||
html.append("<head>");
|
|
||||||
html.append("<title>Route info</title>");
|
|
||||||
html.append("<meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />");
|
|
||||||
html.append("<style>");
|
|
||||||
html.append("table, th, td {");
|
|
||||||
html.append("border: 1px solid black;");
|
|
||||||
html.append("border-collapse: collapse;}");
|
|
||||||
html.append("th, td {");
|
|
||||||
html.append("padding: 5px;}");
|
|
||||||
html.append("</style>");
|
|
||||||
html.append("</head>");
|
|
||||||
html.append("<body>");
|
|
||||||
|
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(title)) {
|
|
||||||
html.append("<h1>");
|
|
||||||
html.append(title);
|
|
||||||
html.append("</h1>");
|
|
||||||
}
|
|
||||||
html.append("<table style=\"width:100%\">");
|
|
||||||
final String NBSP = " ";
|
|
||||||
final String BR = "<br>";
|
|
||||||
for (int i = 0; i < routeInfo.getCount(); i++) {
|
|
||||||
RouteDirectionInfo routeDirectionInfo = (RouteDirectionInfo) routeInfo.getItem(i);
|
|
||||||
html.append("<tr>");
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(OsmAndFormatter.getFormattedDistance(routeDirectionInfo.distance, getMyApplication()));
|
|
||||||
sb.append(", ");
|
|
||||||
sb.append(getTimeDescription(routeDirectionInfo));
|
|
||||||
String distance = sb.toString().replaceAll("\\s", NBSP);
|
|
||||||
html.append("<td>");
|
|
||||||
html.append(distance);
|
|
||||||
html.append("</td>");
|
|
||||||
String description = routeDirectionInfo.getDescriptionRoutePart();
|
|
||||||
html.append("<td>");
|
|
||||||
html.append(String.valueOf(i + 1) + ". " + description);
|
|
||||||
html.append("</td>");
|
|
||||||
RouteInfoAdapter.CumulativeInfo cumulativeInfo = routeInfo.getRouteDirectionCumulativeInfo(i);
|
|
||||||
html.append("<td>");
|
|
||||||
sb = new StringBuilder();
|
|
||||||
sb.append(OsmAndFormatter.getFormattedDistance(cumulativeInfo.distance, getMyApplication()));
|
|
||||||
sb.append(" - ");
|
|
||||||
sb.append(OsmAndFormatter.getFormattedDistance(cumulativeInfo.distance + routeDirectionInfo.distance,
|
|
||||||
getMyApplication()));
|
|
||||||
sb.append(BR);
|
|
||||||
sb.append(Algorithms.formatDuration(cumulativeInfo.time, getMyApplication().accessibilityEnabled()));
|
|
||||||
sb.append(" - ");
|
|
||||||
sb.append(Algorithms.formatDuration(cumulativeInfo.time + routeDirectionInfo.getExpectedTime(),
|
|
||||||
getMyApplication().accessibilityEnabled()));
|
|
||||||
String cumulativeTimeAndDistance = sb.toString().replaceAll("\\s", NBSP);
|
|
||||||
html.append(cumulativeTimeAndDistance);
|
|
||||||
html.append("</td>");
|
|
||||||
html.append("</tr>");
|
|
||||||
}
|
|
||||||
html.append("</table>");
|
|
||||||
html.append("</body>");
|
|
||||||
html.append("</html>");
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,506 @@
|
||||||
|
package net.osmand.plus.activities;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.PorterDuffColorFilter;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.content.FileProvider;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
|
import android.text.Html;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.github.mikephil.charting.charts.LineChart;
|
||||||
|
import com.github.mikephil.charting.utils.Utils;
|
||||||
|
|
||||||
|
import net.osmand.Location;
|
||||||
|
import net.osmand.data.PointDescription;
|
||||||
|
import net.osmand.plus.GPXUtilities;
|
||||||
|
import net.osmand.plus.GPXUtilities.Elevation;
|
||||||
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
|
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||||
|
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||||
|
import net.osmand.plus.IconsCache;
|
||||||
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.OsmandSettings;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
|
||||||
|
import net.osmand.plus.routing.RouteDirectionInfo;
|
||||||
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
|
import net.osmand.plus.views.TurnPathHelper;
|
||||||
|
import net.osmand.router.RouteSegmentResult;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ShowRouteInfoDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
|
public static final String TAG = "ShowRouteInfoDialogFragment";
|
||||||
|
|
||||||
|
private RoutingHelper helper;
|
||||||
|
private View view;
|
||||||
|
private ListView listView;
|
||||||
|
private RouteInfoAdapter adapter;
|
||||||
|
|
||||||
|
public ShowRouteInfoDialogFragment() {
|
||||||
|
}
|
||||||
|
|
||||||
|
private OsmandApplication getMyApplication() {
|
||||||
|
return (OsmandApplication) getActivity().getApplication();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
boolean isLightTheme = getMyApplication().getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
|
||||||
|
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
||||||
|
setStyle(STYLE_NO_FRAME, themeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
final OsmandApplication app = getMyApplication();
|
||||||
|
helper = app.getRoutingHelper();
|
||||||
|
|
||||||
|
view = inflater.inflate(R.layout.route_info_layout, container, false);
|
||||||
|
|
||||||
|
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
|
||||||
|
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getThemedIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha));
|
||||||
|
toolbar.setNavigationContentDescription(R.string.shared_string_close);
|
||||||
|
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
((ImageView) view.findViewById(R.id.distance_icon))
|
||||||
|
.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_polygom_dark));
|
||||||
|
((ImageView) view.findViewById(R.id.time_icon))
|
||||||
|
.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_time_span));
|
||||||
|
|
||||||
|
buildMenuButtons();
|
||||||
|
|
||||||
|
listView = (ListView) view.findViewById(android.R.id.list);
|
||||||
|
listView.setBackgroundColor(getResources().getColor(
|
||||||
|
app.getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light
|
||||||
|
: R.color.ctx_menu_info_view_bg_dark));
|
||||||
|
|
||||||
|
View topShadowView = inflater.inflate(R.layout.list_shadow_header, listView, false);
|
||||||
|
listView.addHeaderView(topShadowView, null, false);
|
||||||
|
View bottomShadowView = inflater.inflate(R.layout.list_shadow_footer, listView, false);
|
||||||
|
listView.addFooterView(bottomShadowView, null, false);
|
||||||
|
|
||||||
|
adapter = new RouteInfoAdapter(helper.getRouteDirections());
|
||||||
|
listView.setAdapter(adapter);
|
||||||
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
if (position < 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
RouteDirectionInfo item = adapter.getItem(position - 2);
|
||||||
|
Location loc = helper.getLocationFromRouteDirection(item);
|
||||||
|
if(loc != null){
|
||||||
|
MapRouteInfoMenu.directionInfo = position - 2;
|
||||||
|
OsmandSettings settings = getMyApplication().getSettings();
|
||||||
|
settings.setMapLocationToShow(loc.getLatitude(),loc.getLongitude(),
|
||||||
|
Math.max(13, settings.getLastKnownMapZoom()),
|
||||||
|
new PointDescription(PointDescription.POINT_TYPE_MARKER, item.getDescriptionRoutePart() + " " + getTimeDescription(item)),
|
||||||
|
false, null);
|
||||||
|
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
int dist = helper.getLeftDistance();
|
||||||
|
int time = helper.getLeftTime();
|
||||||
|
int hours = time / (60 * 60);
|
||||||
|
int minutes = (time / 60) % 60;
|
||||||
|
((TextView)view.findViewById(R.id.distance)).setText(OsmAndFormatter.getFormattedDistance(dist, app));
|
||||||
|
StringBuilder timeStr = new StringBuilder();
|
||||||
|
if (hours > 0) {
|
||||||
|
timeStr.append(hours).append(" ").append(getString(R.string.osmand_parking_hour)).append(" ");
|
||||||
|
}
|
||||||
|
if (minutes > 0) {
|
||||||
|
timeStr.append(minutes).append(" ").append(getString(R.string.osmand_parking_minute));
|
||||||
|
}
|
||||||
|
((TextView)view.findViewById(R.id.time)).setText(timeStr);
|
||||||
|
|
||||||
|
view.findViewById(R.id.go_button).setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
MapActivity activity = (MapActivity)getActivity();
|
||||||
|
if (activity != null) {
|
||||||
|
activity.getMapLayers().getMapControlsLayer().startNavigation();
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
View headerView = inflater.inflate(R.layout.route_info_header, null);
|
||||||
|
if (buildHeader(headerView)) {
|
||||||
|
listView.addHeaderView(headerView);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean buildHeader(View headerView) {
|
||||||
|
OsmandApplication app = getMyApplication();
|
||||||
|
OsmandSettings.MetricsConstants mc = app.getSettings().METRIC_SYSTEM.get();
|
||||||
|
final boolean useFeet = (mc == OsmandSettings.MetricsConstants.MILES_AND_FEET) || (mc == OsmandSettings.MetricsConstants.MILES_AND_YARDS);
|
||||||
|
LineChart mChart = (LineChart) headerView.findViewById(R.id.chart);
|
||||||
|
GPXUtilities.setupGPXChart(mChart, useFeet);
|
||||||
|
List<RouteSegmentResult> route = helper.getRoute().getOriginalRoute();
|
||||||
|
List<float[]> heightList = new ArrayList<>();
|
||||||
|
int count = 0;
|
||||||
|
for (RouteSegmentResult s : route) {
|
||||||
|
float[] arr = s.getHeightValues();
|
||||||
|
if (arr.length > 0) {
|
||||||
|
heightList.add(arr);
|
||||||
|
count += arr.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
float[] heightArray = new float[count];
|
||||||
|
int i = 0;
|
||||||
|
for (float[] arr : heightList) {
|
||||||
|
System.arraycopy(arr, 0, heightArray, i, arr.length);
|
||||||
|
i += arr.length;
|
||||||
|
}
|
||||||
|
TrkSegment seg = GPXUtilities.buildTrkSegment(heightArray);
|
||||||
|
GPXTrackAnalysis analysis = GPXTrackAnalysis.segment(0, seg);
|
||||||
|
i = 0;
|
||||||
|
for (Elevation e : analysis.elevationData) {
|
||||||
|
e.distance = heightArray[i * 2];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
analysis.totalDistance = helper.getLeftDistance();
|
||||||
|
GPXUtilities.setGPXChartData(mChart, analysis, Utils.getSDKInt() >= 18
|
||||||
|
? R.drawable.line_chart_fade_orange : R.color.osmand_orange, useFeet);
|
||||||
|
|
||||||
|
((TextView) headerView.findViewById(R.id.average_text))
|
||||||
|
.setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app));
|
||||||
|
|
||||||
|
String min = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app);
|
||||||
|
String max = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app);
|
||||||
|
((TextView) headerView.findViewById(R.id.range_text))
|
||||||
|
.setText(min + " " + max);
|
||||||
|
|
||||||
|
String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app);
|
||||||
|
String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app);
|
||||||
|
((TextView) headerView.findViewById(R.id.descent_text)).setText(desc);
|
||||||
|
((TextView) headerView.findViewById(R.id.ascent_text)).setText(asc);
|
||||||
|
|
||||||
|
((ImageView) headerView.findViewById(R.id.average_icon))
|
||||||
|
.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_altitude_average));
|
||||||
|
((ImageView) headerView.findViewById(R.id.range_icon))
|
||||||
|
.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_altitude_average));
|
||||||
|
((ImageView) headerView.findViewById(R.id.descent_icon))
|
||||||
|
.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_altitude_descent));
|
||||||
|
((ImageView) headerView.findViewById(R.id.ascent_icon))
|
||||||
|
.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_altitude_ascent));
|
||||||
|
|
||||||
|
return count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildMenuButtons() {
|
||||||
|
IconsCache iconsCache = getMyApplication().getIconsCache();
|
||||||
|
ImageButton printRoute = (ImageButton) view.findViewById(R.id.print_route);
|
||||||
|
printRoute.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_gprint_dark));
|
||||||
|
printRoute.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
print();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ImageButton saveRoute = (ImageButton) view.findViewById(R.id.save_as_gpx);
|
||||||
|
saveRoute.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_gsave_dark));
|
||||||
|
saveRoute.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
MapActivityActions.createSaveDirections(getActivity(), helper).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ImageButton shareRoute = (ImageButton) view.findViewById(R.id.share_as_gpx);
|
||||||
|
shareRoute.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_gshare_dark));
|
||||||
|
shareRoute.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
final GPXFile gpx = helper.generateGPXFileWithRoute();
|
||||||
|
final Uri fileUri = Uri.fromFile(new File(gpx.path));
|
||||||
|
File dir = new File(getActivity().getCacheDir(), "share");
|
||||||
|
if (!dir.exists()) {
|
||||||
|
dir.mkdir();
|
||||||
|
}
|
||||||
|
File dst = new File(dir, "route.gpx");
|
||||||
|
try {
|
||||||
|
FileWriter fw = new FileWriter(dst);
|
||||||
|
GPXUtilities.writeGpx(fw, gpx, getMyApplication());
|
||||||
|
fw.close();
|
||||||
|
final Intent sendIntent = new Intent();
|
||||||
|
sendIntent.setAction(Intent.ACTION_SEND);
|
||||||
|
sendIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(generateHtml(adapter,
|
||||||
|
helper.getGeneralRouteInformation()).toString()));
|
||||||
|
sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_route_subject));
|
||||||
|
sendIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
|
||||||
|
sendIntent.putExtra(
|
||||||
|
Intent.EXTRA_STREAM,
|
||||||
|
FileProvider.getUriForFile(getActivity(),
|
||||||
|
getActivity().getPackageName() + ".fileprovider", dst));
|
||||||
|
sendIntent.setType("text/plain");
|
||||||
|
startActivity(sendIntent);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Toast.makeText(getActivity(), "Error sharing favorites: " + e.getMessage(),
|
||||||
|
// Toast.LENGTH_LONG).show();
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showDialog(FragmentManager fragmentManager) {
|
||||||
|
ShowRouteInfoDialogFragment fragment = new ShowRouteInfoDialogFragment();
|
||||||
|
fragment.show(fragmentManager, TAG);
|
||||||
|
}
|
||||||
|
|
||||||
|
class RouteInfoAdapter extends ArrayAdapter<RouteDirectionInfo> {
|
||||||
|
public class CumulativeInfo {
|
||||||
|
public int distance;
|
||||||
|
public int time;
|
||||||
|
|
||||||
|
public CumulativeInfo() {
|
||||||
|
distance = 0;
|
||||||
|
time = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int lastItemIndex;
|
||||||
|
private boolean light;
|
||||||
|
|
||||||
|
RouteInfoAdapter(List<RouteDirectionInfo> list) {
|
||||||
|
super(getActivity(), R.layout.route_info_list_item, list);
|
||||||
|
lastItemIndex = list.size() - 1;
|
||||||
|
this.setNotifyOnChange(false);
|
||||||
|
light = getMyApplication().getSettings().isLightContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
|
View row = convertView;
|
||||||
|
if (row == null) {
|
||||||
|
LayoutInflater inflater =
|
||||||
|
(LayoutInflater) getMyApplication().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
row = inflater.inflate(R.layout.route_info_list_item, parent, false);
|
||||||
|
}
|
||||||
|
RouteDirectionInfo model = getItem(position);
|
||||||
|
TextView label = (TextView) row.findViewById(R.id.description);
|
||||||
|
TextView distanceLabel = (TextView) row.findViewById(R.id.distance);
|
||||||
|
TextView timeLabel = (TextView) row.findViewById(R.id.time);
|
||||||
|
TextView cumulativeDistanceLabel = (TextView) row.findViewById(R.id.cumulative_distance);
|
||||||
|
TextView cumulativeTimeLabel = (TextView) row.findViewById(R.id.cumulative_time);
|
||||||
|
ImageView icon = (ImageView) row.findViewById(R.id.direction);
|
||||||
|
row.findViewById(R.id.divider).setVisibility(position == getCount() - 1 ? View.INVISIBLE : View.VISIBLE);
|
||||||
|
|
||||||
|
TurnPathHelper.RouteDrawable drawable = new TurnPathHelper.RouteDrawable(getResources(), true);
|
||||||
|
drawable.setColorFilter(new PorterDuffColorFilter(light ? getResources().getColor(R.color.icon_color) : Color.WHITE, PorterDuff.Mode.SRC_ATOP));
|
||||||
|
drawable.setRouteType(model.getTurnType());
|
||||||
|
icon.setImageDrawable(drawable);
|
||||||
|
|
||||||
|
label.setText(String.valueOf(position + 1) + ". " + model.getDescriptionRoutePart());
|
||||||
|
if (model.distance > 0) {
|
||||||
|
distanceLabel.setText(OsmAndFormatter.getFormattedDistance(
|
||||||
|
model.distance, getMyApplication()));
|
||||||
|
timeLabel.setText(getTimeDescription(model));
|
||||||
|
row.setContentDescription(label.getText() + " " + timeLabel.getText()); //$NON-NLS-1$
|
||||||
|
} else {
|
||||||
|
if (label.getText().equals(String.valueOf(position + 1) + ". ")) {
|
||||||
|
label.setText(String.valueOf(position + 1) + ". " + getString((position != lastItemIndex) ? R.string.arrived_at_intermediate_point : R.string.arrived_at_destination));
|
||||||
|
}
|
||||||
|
distanceLabel.setText(""); //$NON-NLS-1$
|
||||||
|
timeLabel.setText(""); //$NON-NLS-1$
|
||||||
|
row.setContentDescription(""); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
CumulativeInfo cumulativeInfo = getRouteDirectionCumulativeInfo(position);
|
||||||
|
cumulativeDistanceLabel.setText(OsmAndFormatter.getFormattedDistance(
|
||||||
|
cumulativeInfo.distance, getMyApplication()));
|
||||||
|
cumulativeTimeLabel.setText(Algorithms.formatDuration(cumulativeInfo.time, getMyApplication().accessibilityEnabled()));
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CumulativeInfo getRouteDirectionCumulativeInfo(int position) {
|
||||||
|
CumulativeInfo cumulativeInfo = new CumulativeInfo();
|
||||||
|
for (int i = 0; i < position; i++) {
|
||||||
|
RouteDirectionInfo routeDirectionInfo = (RouteDirectionInfo) getItem(i);
|
||||||
|
cumulativeInfo.time += routeDirectionInfo.getExpectedTime();
|
||||||
|
cumulativeInfo.distance += routeDirectionInfo.distance;
|
||||||
|
}
|
||||||
|
return cumulativeInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getTimeDescription(RouteDirectionInfo model) {
|
||||||
|
final int timeInSeconds = model.getExpectedTime();
|
||||||
|
return Algorithms.formatDuration(timeInSeconds, getMyApplication().accessibilityEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
|
void print() {
|
||||||
|
File file = generateRouteInfoHtml(adapter, helper.getGeneralRouteInformation());
|
||||||
|
if (file.exists()) {
|
||||||
|
Uri uri = Uri.fromFile(file);
|
||||||
|
Intent browserIntent;
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // use Android Print Framework
|
||||||
|
browserIntent = new Intent(getActivity(), PrintDialogActivity.class)
|
||||||
|
.setDataAndType(uri, "text/html");
|
||||||
|
} else { // just open html document
|
||||||
|
browserIntent = new Intent(Intent.ACTION_VIEW).setDataAndType(
|
||||||
|
uri, "text/html");
|
||||||
|
}
|
||||||
|
startActivity(browserIntent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private File generateRouteInfoHtml(RouteInfoAdapter routeInfo, String title) {
|
||||||
|
File file = null;
|
||||||
|
if (routeInfo == null) {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String fileName = "route_info.html";
|
||||||
|
StringBuilder html = generateHtmlPrint(routeInfo, title);
|
||||||
|
FileOutputStream fos = null;
|
||||||
|
try {
|
||||||
|
file = getMyApplication().getAppPath(fileName);
|
||||||
|
fos = new FileOutputStream(file);
|
||||||
|
fos.write(html.toString().getBytes("UTF-8"));
|
||||||
|
fos.flush();
|
||||||
|
} catch (IOException e) {
|
||||||
|
file = null;
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
if (fos != null) {
|
||||||
|
try {
|
||||||
|
fos.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
file = null;
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
private StringBuilder generateHtml(RouteInfoAdapter routeInfo, String title) {
|
||||||
|
StringBuilder html = new StringBuilder();
|
||||||
|
if (!TextUtils.isEmpty(title)) {
|
||||||
|
html.append("<h1>");
|
||||||
|
html.append(title);
|
||||||
|
html.append("</h1>");
|
||||||
|
}
|
||||||
|
final String NBSP = " ";
|
||||||
|
final String BR = "<br>";
|
||||||
|
for (int i = 0; i < routeInfo.getCount(); i++) {
|
||||||
|
RouteDirectionInfo routeDirectionInfo = (RouteDirectionInfo) routeInfo.getItem(i);
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(OsmAndFormatter.getFormattedDistance(routeDirectionInfo.distance, getMyApplication()));
|
||||||
|
sb.append(", ").append(NBSP);
|
||||||
|
sb.append(getTimeDescription(routeDirectionInfo));
|
||||||
|
String distance = sb.toString().replaceAll("\\s", NBSP);
|
||||||
|
String description = routeDirectionInfo.getDescriptionRoutePart();
|
||||||
|
html.append(BR);
|
||||||
|
html.append("<p>" + String.valueOf(i + 1) + ". " + NBSP + description + NBSP + "(" + distance + ")</p>");
|
||||||
|
}
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
private StringBuilder generateHtmlPrint(RouteInfoAdapter routeInfo, String title) {
|
||||||
|
StringBuilder html = new StringBuilder();
|
||||||
|
html.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
|
||||||
|
html.append("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">");
|
||||||
|
html.append("<head>");
|
||||||
|
html.append("<title>Route info</title>");
|
||||||
|
html.append("<meta http-equiv=\"Content-type\" content=\"text/html; charset=utf-8\" />");
|
||||||
|
html.append("<style>");
|
||||||
|
html.append("table, th, td {");
|
||||||
|
html.append("border: 1px solid black;");
|
||||||
|
html.append("border-collapse: collapse;}");
|
||||||
|
html.append("th, td {");
|
||||||
|
html.append("padding: 5px;}");
|
||||||
|
html.append("</style>");
|
||||||
|
html.append("</head>");
|
||||||
|
html.append("<body>");
|
||||||
|
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(title)) {
|
||||||
|
html.append("<h1>");
|
||||||
|
html.append(title);
|
||||||
|
html.append("</h1>");
|
||||||
|
}
|
||||||
|
html.append("<table style=\"width:100%\">");
|
||||||
|
final String NBSP = " ";
|
||||||
|
final String BR = "<br>";
|
||||||
|
for (int i = 0; i < routeInfo.getCount(); i++) {
|
||||||
|
RouteDirectionInfo routeDirectionInfo = (RouteDirectionInfo) routeInfo.getItem(i);
|
||||||
|
html.append("<tr>");
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(OsmAndFormatter.getFormattedDistance(routeDirectionInfo.distance, getMyApplication()));
|
||||||
|
sb.append(", ");
|
||||||
|
sb.append(getTimeDescription(routeDirectionInfo));
|
||||||
|
String distance = sb.toString().replaceAll("\\s", NBSP);
|
||||||
|
html.append("<td>");
|
||||||
|
html.append(distance);
|
||||||
|
html.append("</td>");
|
||||||
|
String description = routeDirectionInfo.getDescriptionRoutePart();
|
||||||
|
html.append("<td>");
|
||||||
|
html.append(String.valueOf(i + 1) + ". " + description);
|
||||||
|
html.append("</td>");
|
||||||
|
RouteInfoAdapter.CumulativeInfo cumulativeInfo = routeInfo.getRouteDirectionCumulativeInfo(i);
|
||||||
|
html.append("<td>");
|
||||||
|
sb = new StringBuilder();
|
||||||
|
sb.append(OsmAndFormatter.getFormattedDistance(cumulativeInfo.distance, getMyApplication()));
|
||||||
|
sb.append(" - ");
|
||||||
|
sb.append(OsmAndFormatter.getFormattedDistance(cumulativeInfo.distance + routeDirectionInfo.distance,
|
||||||
|
getMyApplication()));
|
||||||
|
sb.append(BR);
|
||||||
|
sb.append(Algorithms.formatDuration(cumulativeInfo.time, getMyApplication().accessibilityEnabled()));
|
||||||
|
sb.append(" - ");
|
||||||
|
sb.append(Algorithms.formatDuration(cumulativeInfo.time + routeDirectionInfo.getExpectedTime(),
|
||||||
|
getMyApplication().accessibilityEnabled()));
|
||||||
|
String cumulativeTimeAndDistance = sb.toString().replaceAll("\\s", NBSP);
|
||||||
|
html.append(cumulativeTimeAndDistance);
|
||||||
|
html.append("</td>");
|
||||||
|
html.append("</tr>");
|
||||||
|
}
|
||||||
|
html.append("</table>");
|
||||||
|
html.append("</body>");
|
||||||
|
html.append("</html>");
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.ShowRouteInfoActivity;
|
import net.osmand.plus.activities.ShowRouteInfoDialogFragment;
|
||||||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
|
|
||||||
|
@ -40,7 +40,9 @@ public class DashNavigationFragment extends DashBaseFragment {
|
||||||
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
|
(view.findViewById(R.id.show_all)).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
Intent intent = new Intent(view.getContext(), ShowRouteInfoActivity.class);
|
|
||||||
|
ShowRouteInfoDialogFragment.showDialog(getActivity().getSupportFragmentManager());
|
||||||
|
Intent intent = new Intent(view.getContext(), ShowRouteInfoDialogFragment.class);
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
view.getContext().startActivity(intent);
|
view.getContext().startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.Location;
|
|
||||||
import net.osmand.ValueHolder;
|
import net.osmand.ValueHolder;
|
||||||
import net.osmand.data.FavouritePoint;
|
import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
|
@ -34,14 +33,13 @@ import net.osmand.plus.MapMarkersHelper;
|
||||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||||
import net.osmand.plus.OsmAndFormatter;
|
import net.osmand.plus.OsmAndFormatter;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
|
||||||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.TargetPointsHelper;
|
import net.osmand.plus.TargetPointsHelper;
|
||||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||||
import net.osmand.plus.activities.FavoritesListFragment.FavouritesAdapter;
|
import net.osmand.plus.activities.FavoritesListFragment.FavouritesAdapter;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.ShowRouteInfoActivity;
|
import net.osmand.plus.activities.ShowRouteInfoDialogFragment;
|
||||||
import net.osmand.plus.activities.actions.AppModeDialog;
|
import net.osmand.plus.activities.actions.AppModeDialog;
|
||||||
import net.osmand.plus.activities.search.SearchAddressActivity;
|
import net.osmand.plus.activities.search.SearchAddressActivity;
|
||||||
import net.osmand.plus.dialogs.FavoriteDialogs;
|
import net.osmand.plus.dialogs.FavoriteDialogs;
|
||||||
|
@ -581,9 +579,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
||||||
info.setOnClickListener(new View.OnClickListener() {
|
info.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent intent = new Intent(mapView.getContext(), ShowRouteInfoActivity.class);
|
ShowRouteInfoDialogFragment.showDialog(mapActivity.getSupportFragmentManager());
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
mapView.getContext().startActivity(intent);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.app.ActivityCompat;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
@ -33,10 +32,7 @@ import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.github.mikephil.charting.charts.LineChart;
|
import com.github.mikephil.charting.charts.LineChart;
|
||||||
import com.github.mikephil.charting.components.Legend;
|
|
||||||
import com.github.mikephil.charting.components.MarkerView;
|
import com.github.mikephil.charting.components.MarkerView;
|
||||||
import com.github.mikephil.charting.components.XAxis;
|
|
||||||
import com.github.mikephil.charting.components.YAxis;
|
|
||||||
import com.github.mikephil.charting.data.Entry;
|
import com.github.mikephil.charting.data.Entry;
|
||||||
import com.github.mikephil.charting.data.LineData;
|
import com.github.mikephil.charting.data.LineData;
|
||||||
import com.github.mikephil.charting.data.LineDataSet;
|
import com.github.mikephil.charting.data.LineDataSet;
|
||||||
|
@ -49,6 +45,7 @@ import net.osmand.data.FavouritePoint;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.plus.FavouritesDbHelper;
|
import net.osmand.plus.FavouritesDbHelper;
|
||||||
|
import net.osmand.plus.GPXUtilities;
|
||||||
import net.osmand.plus.GPXUtilities.Elevation;
|
import net.osmand.plus.GPXUtilities.Elevation;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
|
@ -78,8 +75,6 @@ import java.util.List;
|
||||||
|
|
||||||
import gnu.trove.list.array.TIntArrayList;
|
import gnu.trove.list.array.TIntArrayList;
|
||||||
|
|
||||||
import static com.github.mikephil.charting.components.XAxis.XAxisPosition.BOTTOM;
|
|
||||||
|
|
||||||
|
|
||||||
public class SelectedGPXFragment extends OsmAndListFragment {
|
public class SelectedGPXFragment extends OsmAndListFragment {
|
||||||
public static final String ARG_TO_EXPAND_TRACK_INFO = "ARG_TO_EXPAND_TRACK_INFO";
|
public static final String ARG_TO_EXPAND_TRACK_INFO = "ARG_TO_EXPAND_TRACK_INFO";
|
||||||
|
@ -478,46 +473,7 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
||||||
row = inflater.inflate(R.layout.gpx_item_list_item, parent, false);
|
row = inflater.inflate(R.layout.gpx_item_list_item, parent, false);
|
||||||
|
|
||||||
mChart = (LineChart) row.findViewById(R.id.chart);
|
mChart = (LineChart) row.findViewById(R.id.chart);
|
||||||
//mChart.setHardwareAccelerationEnabled(true);
|
GPXUtilities.setupGPXChart(mChart, useFeet);
|
||||||
mChart.setTouchEnabled(true);
|
|
||||||
mChart.setDragEnabled(true);
|
|
||||||
mChart.setScaleEnabled(true);
|
|
||||||
mChart.setPinchZoom(true);
|
|
||||||
mChart.setScaleYEnabled(false);
|
|
||||||
mChart.setAutoScaleMinMaxEnabled(true);
|
|
||||||
mChart.setDrawBorders(false);
|
|
||||||
mChart.getDescription().setEnabled(false);
|
|
||||||
mChart.setMaxVisibleValueCount(10);
|
|
||||||
mChart.setMinOffset(0f);
|
|
||||||
|
|
||||||
mChart.setExtraTopOffset(24f);
|
|
||||||
mChart.setExtraBottomOffset(16f);
|
|
||||||
|
|
||||||
// create a custom MarkerView (extend MarkerView) and specify the layout
|
|
||||||
// to use for it
|
|
||||||
MyMarkerView mv = new MyMarkerView(getActivity(), R.layout.chart_marker_view, useFeet);
|
|
||||||
mv.setChartView(mChart); // For bounds control
|
|
||||||
mChart.setMarker(mv); // Set the marker to the chart
|
|
||||||
mChart.setDrawMarkers(true);
|
|
||||||
|
|
||||||
XAxis xAxis = mChart.getXAxis();
|
|
||||||
xAxis.setDrawAxisLine(false);
|
|
||||||
xAxis.setDrawGridLines(false);
|
|
||||||
xAxis.setDrawAxisLine(false);
|
|
||||||
xAxis.setPosition(BOTTOM);
|
|
||||||
|
|
||||||
YAxis yAxis = mChart.getAxisLeft();
|
|
||||||
yAxis.enableGridDashedLine(10f, 5f, 0f);
|
|
||||||
yAxis.setGridColor(ActivityCompat.getColor(getActivity(), R.color.divider_color));
|
|
||||||
yAxis.setDrawAxisLine(false);
|
|
||||||
yAxis.setPosition(YAxis.YAxisLabelPosition.INSIDE_CHART);
|
|
||||||
yAxis.setXOffset(16f);
|
|
||||||
yAxis.setYOffset(-6f);
|
|
||||||
|
|
||||||
Legend legend = mChart.getLegend();
|
|
||||||
legend.setEnabled(false);
|
|
||||||
|
|
||||||
mChart.getAxisRight().setEnabled(false);
|
|
||||||
}
|
}
|
||||||
GpxDisplayItem child = getItem(position);
|
GpxDisplayItem child = getItem(position);
|
||||||
TextView label = (TextView) row.findViewById(R.id.name);
|
TextView label = (TextView) row.findViewById(R.id.name);
|
||||||
|
@ -561,58 +517,8 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
||||||
if (mChart != null) {
|
if (mChart != null) {
|
||||||
if (child.analysis != null && child.analysis.elevationData != null && child.analysis.isElevationSpecified() && (child.analysis.totalDistance > 0)) {
|
if (child.analysis != null && child.analysis.elevationData != null && child.analysis.isElevationSpecified() && (child.analysis.totalDistance > 0)) {
|
||||||
|
|
||||||
if (child.analysis.minElevation >= 0) {
|
GPXUtilities.setGPXChartData(mChart, child.analysis, Utils.getSDKInt() >= 18
|
||||||
//mChart.getAxisLeft().setAxisMinimum(0f);
|
? R.drawable.line_chart_fade_orange : R.color.osmand_orange, useFeet);
|
||||||
}
|
|
||||||
|
|
||||||
final float convEle = useFeet ? 3.28084f : 1.0f;
|
|
||||||
final float divX = child.analysis.totalDistance > 1000 ? 1000f : 1f;
|
|
||||||
|
|
||||||
ArrayList<Entry> values = new ArrayList<>();
|
|
||||||
List<Elevation> elevationData = child.analysis.elevationData;
|
|
||||||
float nextX = 0;
|
|
||||||
float nextY;
|
|
||||||
for (Elevation e : elevationData) {
|
|
||||||
if (e.distance > 0) {
|
|
||||||
nextX += (float) e.distance / divX;
|
|
||||||
nextY = (float) (e.elevation * convEle);
|
|
||||||
values.add(new Entry(nextX, nextY));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LineDataSet dataSet = new LineDataSet(values, "");
|
|
||||||
|
|
||||||
dataSet.setColor(Color.BLACK);
|
|
||||||
dataSet.setDrawValues(false);
|
|
||||||
dataSet.setLineWidth(0f);
|
|
||||||
dataSet.setValueTextSize(9f);
|
|
||||||
dataSet.setDrawFilled(true);
|
|
||||||
dataSet.setFormLineWidth(1f);
|
|
||||||
dataSet.setFormSize(15.f);
|
|
||||||
|
|
||||||
dataSet.setDrawCircles(false);
|
|
||||||
dataSet.setDrawCircleHole(false);
|
|
||||||
|
|
||||||
dataSet.setHighlightEnabled(true);
|
|
||||||
dataSet.setDrawVerticalHighlightIndicator(true);
|
|
||||||
dataSet.setDrawHorizontalHighlightIndicator(false);
|
|
||||||
dataSet.setHighLightColor(Color.BLACK);
|
|
||||||
|
|
||||||
if (Utils.getSDKInt() >= 18) {
|
|
||||||
// fill drawable only supported on api level 18 and above
|
|
||||||
Drawable drawable = ContextCompat.getDrawable(getActivity(), R.drawable.line_chart_fade_orange);
|
|
||||||
dataSet.setFillDrawable(drawable);
|
|
||||||
} else {
|
|
||||||
dataSet.setFillColor(ContextCompat.getColor(getActivity(), R.color.osmand_orange));
|
|
||||||
}
|
|
||||||
ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
|
|
||||||
dataSets.add(dataSet); // add the datasets
|
|
||||||
|
|
||||||
// create a data object with the datasets
|
|
||||||
LineData data = new LineData(dataSets);
|
|
||||||
|
|
||||||
// set data
|
|
||||||
mChart.setData(data);
|
|
||||||
|
|
||||||
mChart.setVisibility(View.VISIBLE);
|
mChart.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue