GPX info UI in progress
This commit is contained in:
parent
dd705b04a2
commit
73cbe9d033
23 changed files with 2147 additions and 225 deletions
|
@ -181,9 +181,14 @@
|
|||
android:layout_marginRight="@dimen/list_content_padding"
|
||||
android:visibility="gone">
|
||||
|
||||
<include android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
layout="@layout/check_item_rel"/>
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/toggle_item"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="4dp"
|
||||
android:paddingBottom="4dp"
|
||||
android:focusable="false"
|
||||
android:gravity="center_vertical"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
285
OsmAnd/res/layout/gpx_item_altitude.xml
Normal file
285
OsmAnd/res/layout/gpx_item_altitude.xml
Normal file
|
@ -0,0 +1,285 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.github.mikephil.charting.charts.LineChart
|
||||
android:id="@+id/chart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="150dp"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/average_range"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="13dp"
|
||||
android:paddingBottom="11dp">
|
||||
|
||||
<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_marginTop="5dp"
|
||||
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"
|
||||
tools: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:layout_marginTop="3dp"
|
||||
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_marginTop="5dp"
|
||||
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"
|
||||
tools: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:layout_marginTop="3dp"
|
||||
android:text="@string/altitude_range"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/list_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<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:id="@+id/ascent_descent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="13dp"
|
||||
android:paddingBottom="11dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ascent_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
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"
|
||||
tools: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:layout_marginTop="3dp"
|
||||
android:text="@string/altitude_ascent"
|
||||
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/descent_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
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"
|
||||
tools: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:layout_marginTop="3dp"
|
||||
android:text="@string/altitude_descent"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/details_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:gravity="center">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/details_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right|center_vertical"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:text="@string/rendering_category_details"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
303
OsmAnd/res/layout/gpx_item_general.xml
Normal file
303
OsmAnd/res/layout/gpx_item_general.xml
Normal file
|
@ -0,0 +1,303 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.github.mikephil.charting.charts.LineChart
|
||||
android:id="@+id/chart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="150dp"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/distance_time_span"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="13dp"
|
||||
android:paddingBottom="11dp">
|
||||
|
||||
<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_marginTop="5dp"
|
||||
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_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
tools:text="40 km"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/distance_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:layout_marginTop="3dp"
|
||||
android:text="@string/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/duration_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:src="@drawable/ic_action_time_start"/>
|
||||
|
||||
<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/duration_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
tools:text="3:32:44"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/duration_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:layout_marginTop="3dp"
|
||||
android:text="@string/shared_string_time_span"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/list_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<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:id="@+id/start_end_time"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="13dp"
|
||||
android:paddingBottom="11dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/start_time_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:src="@drawable/ic_action_time_start"/>
|
||||
|
||||
<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/start_time_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
tools:text="15:04:58"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/start_date_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
tools:text="Aug 8, 2016"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/start_time_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/shared_string_start_time"
|
||||
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/end_time_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:src="@drawable/ic_action_time_start"/>
|
||||
|
||||
<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/end_time_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
tools:text="20:58:00"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/end_date_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
tools:text="Aug 8, 2016"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/end_time_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/shared_string_end_time"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/details_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:gravity="center">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/details_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right|center_vertical"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:text="@string/rendering_category_details"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
144
OsmAnd/res/layout/gpx_item_list_header.xml
Normal file
144
OsmAnd/res/layout/gpx_item_list_header.xml
Normal file
|
@ -0,0 +1,144 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom">
|
||||
|
||||
<include layout="@layout/list_shadow_header"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="152dp"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/audio_video_notes"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:background="?attr/bg_color"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.8"
|
||||
android:minHeight="48dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:text="@string/shared_string_show_on_map"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/showOnMapToggle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="8dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:background="?attr/bg_color"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.6"
|
||||
android:minHeight="48dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:text="@string/gpx_split_interval"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/split_interval"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="10 km"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/split_interval_arrow"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_action_arrow_drop_down"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:minHeight="48dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:text="@string/shared_string_color"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/colorImage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="16dp"
|
||||
android:src="@drawable/ic_action_circle"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -64,11 +64,6 @@
|
|||
android:paddingLeft="@dimen/list_content_padding"
|
||||
android:paddingRight="@dimen/list_content_padding"/>
|
||||
|
||||
<com.github.mikephil.charting.charts.LineChart
|
||||
android:id="@+id/chart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="150dp"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
285
OsmAnd/res/layout/gpx_item_speed.xml
Normal file
285
OsmAnd/res/layout/gpx_item_speed.xml
Normal file
|
@ -0,0 +1,285 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.github.mikephil.charting.charts.LineChart
|
||||
android:id="@+id/chart"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="150dp"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/average_max"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="13dp"
|
||||
android:paddingBottom="11dp">
|
||||
|
||||
<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_marginTop="5dp"
|
||||
android:src="@drawable/ic_action_speed"/>
|
||||
|
||||
<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"
|
||||
tools:text="6.8 km/h"
|
||||
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:layout_marginTop="3dp"
|
||||
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/max_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:src="@drawable/ic_action_max_speed"/>
|
||||
|
||||
<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/max_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
tools:text="31.3 km/h"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/max_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:layout_marginTop="3dp"
|
||||
android:text="@string/shared_string_max"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/list_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<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:id="@+id/time_distance"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="13dp"
|
||||
android:paddingBottom="11dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/time_moving_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
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_moving_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
tools:text="174"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/time_moving_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:layout_marginTop="3dp"
|
||||
android:text="@string/shared_string_time_moving"
|
||||
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/distance_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
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_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
tools:text="42 km"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/distance_desc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:layout_marginTop="3dp"
|
||||
android:text="@string/distance"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/details_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:gravity="center">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/details_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right|center_vertical"
|
||||
android:textColor="?attr/color_dialog_buttons"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
osmand:textAllCapsCompat="true"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:text="@string/rendering_category_details"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
24
OsmAnd/res/layout/gpx_list_item_tab_content.xml
Normal file
24
OsmAnd/res/layout/gpx_list_item_tab_content.xml
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<include layout="@layout/list_item_divider"/>
|
||||
|
||||
<net.osmand.plus.views.controls.PagerSlidingTabStrip
|
||||
android:id="@+id/sliding_tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:background="?attr/bg_color"/>
|
||||
|
||||
|
||||
<net.osmand.plus.views.controls.WrapContentHeightViewPager
|
||||
android:id="@+id/pager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:paddingTop="8dp"/>
|
||||
|
||||
</LinearLayout>
|
21
OsmAnd/res/layout/gpx_tab.xml
Normal file
21
OsmAnd/res/layout/gpx_tab.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?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"
|
||||
android:gravity="center">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/tab_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/tab_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:singleLine="true" />
|
||||
|
||||
</LinearLayout>
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
@ -52,7 +53,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:text="40 m"
|
||||
tools:text="40 m"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
@ -95,7 +96,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:text="30m -53m"
|
||||
tools:text="30m - 53m"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
@ -188,7 +189,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:text="174"
|
||||
tools:text="174"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
@ -231,7 +232,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@null"
|
||||
android:text="164"
|
||||
tools:text="164"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
|
||||
<declare-styleable name="PagerSlidingTabStrip">
|
||||
<attr name="pstsTextColor" format="color"/>
|
||||
<attr name="pstsInactiveTextColor" format="color"/>
|
||||
<attr name="pstsIndicatorColor" format="color"/>
|
||||
<attr name="pstsUnderlineColor" format="color"/>
|
||||
<attr name="pstsDividerColor" format="color"/>
|
||||
|
|
|
@ -9,6 +9,12 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="shared_string_time_moving">Time moving</string>
|
||||
<string name="shared_string_time_span">Time span</string>
|
||||
<string name="shared_string_max">Max</string>
|
||||
<string name="shared_string_start_time">Start time</string>
|
||||
<string name="shared_string_end_time">End time</string>
|
||||
<string name="shared_string_color">Color</string>
|
||||
<string name="select_gpx_folder">Select GPX folder</string>
|
||||
<string name="file_can_not_be_moved">File can not be moved.</string>
|
||||
<string name="shared_string_move">Move</string>
|
||||
|
|
|
@ -88,6 +88,7 @@
|
|||
<item name="pstsUnderlineColor">@color/actionbar_light_color</item>
|
||||
<item name="pstsIndicatorColor">@color/color_white</item>
|
||||
<item name="pstsTextColor">@color/color_white</item>
|
||||
<item name="pstsInactiveTextColor">@color/icon_color</item>
|
||||
<item name="btn_flat_bg">@drawable/btn_flat</item>
|
||||
<item name="android:windowContentOverlay">@null</item>
|
||||
<item name="actionModeBackground">@color/actionbar_light_color</item>
|
||||
|
@ -252,6 +253,7 @@
|
|||
<item name="pstsUnderlineColor">@color/actionbar_dark_color</item>
|
||||
<item name="pstsIndicatorColor">@color/actionbar_light_color</item>
|
||||
<item name="pstsTextColor">@color/color_white</item>
|
||||
<item name="pstsInactiveTextColor">@color/dash_search_icon_dark</item>
|
||||
<item name="btn_flat_bg">@drawable/btn_flat_night</item>
|
||||
<item name="actionModeBackground">@color/actionbar_dark_color</item>
|
||||
<item name="actionBarStyle">@style/Widget.Styled.ActionBarDark</item>
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
||||
import static android.util.TypedValue.COMPLEX_UNIT_SP;
|
||||
|
||||
public class AndroidUtils {
|
||||
|
||||
|
@ -153,6 +154,15 @@ public class AndroidUtils {
|
|||
);
|
||||
}
|
||||
|
||||
public static int spToPx(Context ctx, float sp) {
|
||||
Resources r = ctx.getResources();
|
||||
return (int) TypedValue.applyDimension(
|
||||
COMPLEX_UNIT_SP,
|
||||
sp,
|
||||
r.getDisplayMetrics()
|
||||
);
|
||||
}
|
||||
|
||||
public static int getStatusBarHeight(Context ctx) {
|
||||
int result = 0;
|
||||
int resourceId = ctx.getResources().getIdentifier("status_bar_height", "dimen", "android");
|
||||
|
|
|
@ -18,7 +18,6 @@ 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.formatter.DefaultAxisValueFormatter;
|
||||
import com.github.mikephil.charting.formatter.IAxisValueFormatter;
|
||||
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||
import com.github.mikephil.charting.utils.Utils;
|
||||
|
@ -119,6 +118,9 @@ public class GPXUtilities {
|
|||
public static class Elevation {
|
||||
public double distance, elevation;
|
||||
}
|
||||
public static class Speed {
|
||||
public double distance, speed;
|
||||
}
|
||||
|
||||
public static class WptPt extends GPXExtensions implements LocationPoint {
|
||||
public double lat;
|
||||
|
@ -316,6 +318,7 @@ public class GPXUtilities {
|
|||
}
|
||||
|
||||
public List<Elevation> elevationData;
|
||||
public List<Speed> speedData;
|
||||
|
||||
public boolean isSpeedSpecified() {
|
||||
return avgSpeed > 0;
|
||||
|
@ -343,6 +346,7 @@ public class GPXUtilities {
|
|||
boolean climb = false;
|
||||
|
||||
elevationData = new ArrayList<>();
|
||||
speedData = new ArrayList<>();
|
||||
|
||||
for (SplitSegment s : splitSegments) {
|
||||
final int numberOfPoints = s.getNumberOfPoints();
|
||||
|
@ -383,10 +387,15 @@ public class GPXUtilities {
|
|||
}
|
||||
|
||||
float speed = (float) point.speed;
|
||||
Speed speed1 = new Speed();
|
||||
if (speed > 0) {
|
||||
totalSpeedSum += speed;
|
||||
maxSpeed = Math.max(speed, maxSpeed);
|
||||
speedCount++;
|
||||
|
||||
speed1.speed = speed;
|
||||
} else {
|
||||
speed1.speed = 0;
|
||||
}
|
||||
|
||||
// Trend channel approach for elevation gain/loss, Hardy 2015-09-22
|
||||
|
@ -476,7 +485,8 @@ public class GPXUtilities {
|
|||
|
||||
elevation1.distance = (j > 0) ? calculations[0] : 0;
|
||||
elevationData.add(elevation1);
|
||||
|
||||
speed1.distance = elevation1.distance;
|
||||
speedData.add(speed1);
|
||||
}
|
||||
}
|
||||
if (!isTimeSpecified()) {
|
||||
|
@ -1313,7 +1323,8 @@ public class GPXUtilities {
|
|||
|
||||
// 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);
|
||||
SelectedGPXFragment.MyMarkerView mv =
|
||||
new SelectedGPXFragment.MyMarkerView(mChart.getContext(), R.layout.chart_marker_view);
|
||||
mv.setChartView(mChart); // For bounds control
|
||||
mChart.setMarker(mv); // Set the marker to the chart
|
||||
mChart.setDrawMarkers(true);
|
||||
|
@ -1334,19 +1345,24 @@ public class GPXUtilities {
|
|||
yAxis.setLabelCount(yLabelsCount);
|
||||
yAxis.setTextColor(light ? mChart.getResources().getColor(R.color.secondary_text_light) : mChart.getResources().getColor(R.color.secondary_text_dark));
|
||||
|
||||
yAxis = mChart.getAxisRight();
|
||||
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);
|
||||
yAxis.setLabelCount(yLabelsCount);
|
||||
yAxis.setTextColor(light ? mChart.getResources().getColor(R.color.secondary_text_light) : mChart.getResources().getColor(R.color.secondary_text_dark));
|
||||
yAxis.setEnabled(false);
|
||||
|
||||
Legend legend = mChart.getLegend();
|
||||
legend.setEnabled(false);
|
||||
|
||||
mChart.getAxisRight().setEnabled(false);
|
||||
}
|
||||
|
||||
public static void setGPXChartData(OsmandApplication ctx, LineChart mChart, GPXTrackAnalysis analysis, int fillResourceId) {
|
||||
private static void getXAxisParams(OsmandApplication ctx, float meters, float[] koef, StringBuilder format, StringBuilder unit) {
|
||||
OsmandSettings settings = ctx.getSettings();
|
||||
OsmandSettings.MetricsConstants mc = settings.METRIC_SYSTEM.get();
|
||||
boolean useFeet = (mc == OsmandSettings.MetricsConstants.MILES_AND_FEET) || (mc == OsmandSettings.MetricsConstants.MILES_AND_YARDS);
|
||||
boolean light = settings.isLightContent();
|
||||
final float convEle = useFeet ? 3.28084f : 1.0f;
|
||||
final float meters = analysis.totalDistance;
|
||||
float divX;
|
||||
|
||||
String format1 = "{0,number,0.#} ";
|
||||
|
@ -1396,15 +1412,34 @@ public class GPXUtilities {
|
|||
}
|
||||
}
|
||||
|
||||
final String mainUnitX = ctx.getString(mainUnitStr);
|
||||
final String formatX = fmt;
|
||||
koef[0] = divX;
|
||||
format.append(fmt);
|
||||
unit.append(ctx.getString(mainUnitStr));
|
||||
}
|
||||
|
||||
public static LineDataSet createGPXElevationDataSet(OsmandApplication ctx, LineChart mChart, GPXTrackAnalysis analysis, boolean useRightAxis) {
|
||||
OsmandSettings settings = ctx.getSettings();
|
||||
OsmandSettings.MetricsConstants mc = settings.METRIC_SYSTEM.get();
|
||||
boolean useFeet = (mc == OsmandSettings.MetricsConstants.MILES_AND_FEET) || (mc == OsmandSettings.MetricsConstants.MILES_AND_YARDS);
|
||||
boolean light = settings.isLightContent();
|
||||
final float convEle = useFeet ? 3.28084f : 1.0f;
|
||||
final float meters = analysis.totalDistance;
|
||||
|
||||
float[] koef = new float[] { 1f };
|
||||
StringBuilder fmt = new StringBuilder();
|
||||
StringBuilder unitX = new StringBuilder();
|
||||
|
||||
getXAxisParams(ctx, meters, koef, fmt, unitX);
|
||||
float divX = koef[0];
|
||||
final String formatX = fmt.toString();
|
||||
final String mainUnitX = unitX.toString();
|
||||
|
||||
XAxis xAxis = mChart.getXAxis();
|
||||
xAxis.setValueFormatter(new IAxisValueFormatter() {
|
||||
|
||||
@Override
|
||||
public String getFormattedValue(float value, AxisBase axis) {
|
||||
if (formatX != null) {
|
||||
if (!Algorithms.isEmpty(formatX)) {
|
||||
return MessageFormat.format(formatX + mainUnitX, value);
|
||||
} else {
|
||||
return (int)value + " " + mainUnitX;
|
||||
|
@ -1413,7 +1448,19 @@ public class GPXUtilities {
|
|||
});
|
||||
|
||||
final String mainUnitY = useFeet ? ctx.getString(R.string.foot) : ctx.getString(R.string.m);
|
||||
YAxis yAxis = mChart.getAxisLeft();
|
||||
|
||||
YAxis yAxis;
|
||||
if (useRightAxis) {
|
||||
yAxis = mChart.getAxisRight();
|
||||
yAxis.setEnabled(true);
|
||||
((SelectedGPXFragment.MyMarkerView)mChart.getMarker()).setUnitsRight(mainUnitY);
|
||||
} else {
|
||||
yAxis = mChart.getAxisLeft();
|
||||
((SelectedGPXFragment.MyMarkerView)mChart.getMarker()).setUnitsLeft(mainUnitY);
|
||||
}
|
||||
if (analysis.minElevation >=0) {
|
||||
yAxis.setAxisMinimum(0f);
|
||||
}
|
||||
yAxis.setValueFormatter(new IAxisValueFormatter() {
|
||||
|
||||
@Override
|
||||
|
@ -1454,18 +1501,143 @@ public class GPXUtilities {
|
|||
|
||||
if (Utils.getSDKInt() >= 18) {
|
||||
// fill drawable only supported on api level 18 and above
|
||||
Drawable drawable = ContextCompat.getDrawable(mChart.getContext(), fillResourceId);
|
||||
Drawable drawable = ContextCompat.getDrawable(mChart.getContext(), R.drawable.line_chart_fade_blue);
|
||||
dataSet.setFillDrawable(drawable);
|
||||
} else {
|
||||
dataSet.setFillColor(ContextCompat.getColor(mChart.getContext(), fillResourceId));
|
||||
dataSet.setFillColor(ContextCompat.getColor(mChart.getContext(), R.color.transport_route_line));
|
||||
}
|
||||
ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
|
||||
dataSets.add(dataSet); // add the datasets
|
||||
if (useRightAxis) {
|
||||
dataSet.setAxisDependency(YAxis.AxisDependency.RIGHT);
|
||||
}
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
// create a data object with the datasets
|
||||
public static void setGPXElevationChartData(OsmandApplication ctx, LineChart mChart, GPXTrackAnalysis analysis, boolean useRightAxis) {
|
||||
LineDataSet dataSet = createGPXElevationDataSet(ctx, mChart, analysis, useRightAxis);
|
||||
ArrayList<ILineDataSet> dataSets = new ArrayList<>();
|
||||
dataSets.add(dataSet);
|
||||
LineData data = new LineData(dataSets);
|
||||
mChart.setData(data);
|
||||
}
|
||||
|
||||
// set data
|
||||
public static LineDataSet createGPXSpeedDataSet(OsmandApplication ctx, LineChart mChart, GPXTrackAnalysis analysis, boolean useRightAxis) {
|
||||
OsmandSettings settings = ctx.getSettings();
|
||||
boolean light = settings.isLightContent();
|
||||
final float meters = analysis.totalDistance;
|
||||
|
||||
float[] koef = new float[] { 1f };
|
||||
StringBuilder fmt = new StringBuilder();
|
||||
StringBuilder unitX = new StringBuilder();
|
||||
|
||||
getXAxisParams(ctx, meters, koef, fmt, unitX);
|
||||
float divX = koef[0];
|
||||
final String formatX = fmt.toString();
|
||||
final String mainUnitX = unitX.toString();
|
||||
|
||||
XAxis xAxis = mChart.getXAxis();
|
||||
xAxis.setValueFormatter(new IAxisValueFormatter() {
|
||||
|
||||
@Override
|
||||
public String getFormattedValue(float value, AxisBase axis) {
|
||||
if (!Algorithms.isEmpty(formatX)) {
|
||||
return MessageFormat.format(formatX + mainUnitX, value);
|
||||
} else {
|
||||
return (int)value + " " + mainUnitX;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
OsmandSettings.SpeedConstants sps = settings.SPEED_SYSTEM.get();
|
||||
float mulSpeed = Float.NaN;
|
||||
float divSpeed = Float.NaN;
|
||||
final String mainUnitY = sps.toShortString(ctx);
|
||||
if (sps == OsmandSettings.SpeedConstants.KILOMETERS_PER_HOUR) {
|
||||
mulSpeed = 3.6f;
|
||||
} else if (sps == OsmandSettings.SpeedConstants.MILES_PER_HOUR) {
|
||||
mulSpeed = 3.6f * METERS_IN_KILOMETER / METERS_IN_ONE_MILE;
|
||||
} else if (sps == OsmandSettings.SpeedConstants.NAUTICALMILES_PER_HOUR) {
|
||||
mulSpeed = 3.6f * METERS_IN_KILOMETER / METERS_IN_ONE_NAUTICALMILE;
|
||||
} else if (sps == OsmandSettings.SpeedConstants.MINUTES_PER_KILOMETER) {
|
||||
divSpeed = METERS_IN_KILOMETER / 60;
|
||||
} else if (sps == OsmandSettings.SpeedConstants.MINUTES_PER_MILE) {
|
||||
divSpeed = METERS_IN_ONE_MILE / 60;
|
||||
} else {
|
||||
mulSpeed = 1f;
|
||||
}
|
||||
|
||||
YAxis yAxis;
|
||||
if (useRightAxis) {
|
||||
yAxis = mChart.getAxisRight();
|
||||
yAxis.setEnabled(true);
|
||||
((SelectedGPXFragment.MyMarkerView)mChart.getMarker()).setUnitsRight(mainUnitY);
|
||||
} else {
|
||||
yAxis = mChart.getAxisLeft();
|
||||
((SelectedGPXFragment.MyMarkerView)mChart.getMarker()).setUnitsLeft(mainUnitY);
|
||||
}
|
||||
yAxis.setAxisMinimum(0f);
|
||||
yAxis.setValueFormatter(new IAxisValueFormatter() {
|
||||
|
||||
@Override
|
||||
public String getFormattedValue(float value, AxisBase axis) {
|
||||
return (int)value + " " + mainUnitY;
|
||||
}
|
||||
});
|
||||
|
||||
ArrayList<Entry> values = new ArrayList<>();
|
||||
List<Speed> speedData = analysis.speedData;
|
||||
float nextX = 0;
|
||||
float nextY;
|
||||
for (Speed s : speedData) {
|
||||
if (s.distance > 0) {
|
||||
nextX += (float) s.distance / divX;
|
||||
if (Float.isNaN(divSpeed)) {
|
||||
nextY = (float) (s.speed * mulSpeed);
|
||||
} else {
|
||||
nextY = (float) (divSpeed / s.speed);
|
||||
}
|
||||
if (nextY < 0) {
|
||||
nextY = 0;
|
||||
}
|
||||
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(light ? mChart.getResources().getColor(R.color.secondary_text_light) : mChart.getResources().getColor(R.color.secondary_text_dark));
|
||||
|
||||
if (Utils.getSDKInt() >= 18) {
|
||||
// fill drawable only supported on api level 18 and above
|
||||
Drawable drawable = ContextCompat.getDrawable(mChart.getContext(), R.drawable.line_chart_fade_red);
|
||||
dataSet.setFillDrawable(drawable);
|
||||
} else {
|
||||
dataSet.setFillColor(ContextCompat.getColor(mChart.getContext(), R.color.transport_end));
|
||||
}
|
||||
if (useRightAxis) {
|
||||
dataSet.setAxisDependency(YAxis.AxisDependency.RIGHT);
|
||||
}
|
||||
return dataSet;
|
||||
}
|
||||
|
||||
public static void setGPXSpeedChartData(OsmandApplication ctx, LineChart mChart, GPXTrackAnalysis analysis, boolean useRightAxis) {
|
||||
LineDataSet dataSet = createGPXSpeedDataSet(ctx, mChart, analysis, useRightAxis);
|
||||
ArrayList<ILineDataSet> dataSets = new ArrayList<>();
|
||||
dataSets.add(dataSet);
|
||||
LineData data = new LineData(dataSets);
|
||||
mChart.setData(data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import android.support.v7.widget.Toolbar;
|
|||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
|
@ -212,10 +213,16 @@ public class ShowRouteInfoDialogFragment extends DialogFragment {
|
|||
OsmandApplication app = getMyApplication();
|
||||
LineChart mChart = (LineChart) headerView.findViewById(R.id.chart);
|
||||
GPXUtilities.setupGPXChart(app, mChart, 4);
|
||||
mChart.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
listView.requestDisallowInterceptTouchEvent(true);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
GPXTrackAnalysis analysis = gpx.getAnalysis(0);
|
||||
GPXUtilities.setGPXChartData(app, mChart, analysis, Utils.getSDKInt() >= 18
|
||||
? R.drawable.line_chart_fade_blue : R.color.gpx_time_span_color);
|
||||
GPXUtilities.setGPXElevationChartData(app, mChart, analysis, false);
|
||||
|
||||
((TextView) headerView.findViewById(R.id.average_text))
|
||||
.setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app));
|
||||
|
|
|
@ -19,7 +19,6 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||
import net.osmand.plus.myplaces.SelectedGPXFragment;
|
||||
import net.osmand.plus.myplaces.TrackPointFragment;
|
||||
import net.osmand.plus.myplaces.TrackRoutePointFragment;
|
||||
import net.osmand.plus.myplaces.TrackSegmentFragment;
|
||||
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
||||
|
||||
|
@ -34,9 +33,6 @@ import android.util.Log;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TrackActivity extends TabActivity {
|
||||
|
||||
public static final String TRACK_FILE_NAME = "TRACK_FILE_NAME";
|
||||
|
@ -72,6 +68,7 @@ public class TrackActivity extends TabActivity {
|
|||
setContentView(R.layout.tab_content);
|
||||
|
||||
PagerSlidingTabStrip mSlidingTabLayout = (PagerSlidingTabStrip) findViewById(R.id.sliding_tabs);
|
||||
mSlidingTabLayout.setShouldExpand(true);
|
||||
|
||||
mViewPager = (ViewPager) findViewById(R.id.pager);
|
||||
|
||||
|
@ -101,16 +98,11 @@ public class TrackActivity extends TabActivity {
|
|||
}
|
||||
}
|
||||
((OsmandFragmentPagerAdapter) mViewPager.getAdapter()).addTab(
|
||||
getTabIndicator(R.string.track_segments, TrackSegmentFragment.class));
|
||||
if (isHavingWayPoints()){
|
||||
getTabIndicator(R.string.info_button, TrackSegmentFragment.class));
|
||||
if (isHavingWayPoints() || isHavingRoutePoints()) {
|
||||
((OsmandFragmentPagerAdapter) mViewPager.getAdapter()).addTab(
|
||||
getTabIndicator(R.string.announce_gpx_waypoints, TrackPointFragment.class));
|
||||
getTabIndicator(R.string.points, TrackPointFragment.class));
|
||||
}
|
||||
if (isHavingRoutePoints()){
|
||||
((OsmandFragmentPagerAdapter) mViewPager.getAdapter()).addTab(
|
||||
getTabIndicator(R.string.route_points, TrackRoutePointFragment.class));
|
||||
}
|
||||
|
||||
};
|
||||
}.execute((Void)null);
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ import java.text.DateFormat;
|
|||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
|
@ -204,8 +205,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
if (isRecording) {
|
||||
plugin.stopRecording();
|
||||
updateCurrentTrack();
|
||||
} else
|
||||
if (app.getLocationProvider().checkGPSEnabled(app)) {
|
||||
} else if (app.getLocationProvider().checkGPSEnabled(getActivity())) {
|
||||
plugin.startGPXMonitoring(getActivity());
|
||||
updateCurrentTrack();
|
||||
}
|
||||
|
@ -677,6 +677,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
for (GpxInfo v : values) {
|
||||
allGpxAdapter.addLocalIndexInfo(v);
|
||||
}
|
||||
allGpxAdapter.sort();
|
||||
allGpxAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
@ -687,6 +688,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
for (GpxInfo v : result) {
|
||||
allGpxAdapter.addLocalIndexInfo(v);
|
||||
}
|
||||
allGpxAdapter.sort();
|
||||
allGpxAdapter.refreshSelected();
|
||||
allGpxAdapter.notifyDataSetChanged();
|
||||
onPostExecute(result);
|
||||
|
@ -832,6 +834,10 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
data.get(category.get(found)).add(info);
|
||||
}
|
||||
|
||||
public void sort() {
|
||||
Collections.sort(category);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GpxInfo getChild(int groupPosition, int childPosition) {
|
||||
if (isSelectedGroup(groupPosition)) {
|
||||
|
@ -1333,6 +1339,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
for (GpxInfo i : ((List<GpxInfo>) results.values)) {
|
||||
allGpxAdapter.addLocalIndexInfo(i);
|
||||
}
|
||||
allGpxAdapter.sort();
|
||||
allGpxAdapter.refreshSelected();
|
||||
}
|
||||
allGpxAdapter.notifyDataSetChanged();
|
||||
|
|
|
@ -13,7 +13,6 @@ import android.support.annotation.NonNull;
|
|||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
@ -23,23 +22,20 @@ import android.view.ViewGroup;
|
|||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.components.MarkerView;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
import com.github.mikephil.charting.highlight.Highlight;
|
||||
import com.github.mikephil.charting.utils.MPPointF;
|
||||
import com.github.mikephil.charting.utils.Utils;
|
||||
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
|
@ -54,7 +50,6 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.TrackActivity;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.base.OsmAndListFragment;
|
||||
import net.osmand.plus.helpers.ColorDialogs;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -73,7 +68,7 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
|||
public static final String ARG_TO_FILTER_SHORT_TRACKS = "ARG_TO_FILTER_SHORT_TRACKS";
|
||||
public static final String ARG_TO_HIDE_CONFIG_BTN = "ARG_TO_HIDE_CONFIG_BTN";
|
||||
protected OsmandApplication app;
|
||||
protected SelectedGPXAdapter adapter;
|
||||
protected ArrayAdapter<GpxSelectionHelper.GpxDisplayItem> adapter;
|
||||
protected TrackActivity activity;
|
||||
private boolean updateEnable;
|
||||
|
||||
|
@ -87,6 +82,14 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
|||
app = (OsmandApplication) activity.getApplication();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
getListView().setBackgroundColor(getResources().getColor(
|
||||
getMyApplication().getSettings().isLightContent() ? R.color.ctx_menu_info_view_bg_light
|
||||
: R.color.ctx_menu_info_view_bg_dark));
|
||||
}
|
||||
|
||||
public TrackActivity getMyActivity() {
|
||||
return activity;
|
||||
}
|
||||
|
@ -121,7 +124,7 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
|||
super.onResume();
|
||||
updateContent();
|
||||
updateEnable = true;
|
||||
if(getGpx() != null && getGpx().showCurrentTrack && filterType() == GpxDisplayItemType.TRACK_POINTS) {
|
||||
if (getGpx() != null && getGpx().showCurrentTrack && hasFilterType(GpxDisplayItemType.TRACK_POINTS)) {
|
||||
startHandler();
|
||||
}
|
||||
}
|
||||
|
@ -133,13 +136,13 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
|||
}
|
||||
|
||||
|
||||
protected static List<GpxDisplayGroup> filterGroups(@NonNull GpxDisplayItemType type,
|
||||
protected static List<GpxDisplayGroup> filterGroups(GpxDisplayItemType[] types,
|
||||
@NonNull TrackActivity trackActivity,
|
||||
@Nullable Bundle args) {
|
||||
List<GpxDisplayGroup> result = trackActivity.getResult();
|
||||
List<GpxDisplayGroup> groups = new ArrayList<GpxSelectionHelper.GpxDisplayGroup>();
|
||||
for (GpxDisplayGroup group : result) {
|
||||
boolean add = group.getType() == type || type == null;
|
||||
boolean add = types == null || hasFilterType(types, group.getType());
|
||||
if (isArgumentTrue(args, ARG_TO_FILTER_SHORT_TRACKS)) {
|
||||
Iterator<GpxDisplayItem> item = group.getModifiableList().iterator();
|
||||
while (item.hasNext()) {
|
||||
|
@ -161,26 +164,44 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
|||
}
|
||||
|
||||
public void setContent() {
|
||||
adapter = new SelectedGPXAdapter(new ArrayList<GpxSelectionHelper.GpxDisplayItem>());
|
||||
adapter = createSelectedGPXAdapter();
|
||||
updateContent();
|
||||
setListAdapter(adapter);
|
||||
}
|
||||
|
||||
protected void updateContent() {
|
||||
adapter.clear();
|
||||
List<GpxSelectionHelper.GpxDisplayGroup> groups = filterGroups(filterType(), getMyActivity(), getArguments());
|
||||
List<GpxSelectionHelper.GpxDisplayGroup> groups = filterGroups(filterTypes(), getMyActivity(), getArguments());
|
||||
adapter.setNotifyOnChange(false);
|
||||
for(GpxDisplayItem i: flatten(groups)) {
|
||||
for (GpxDisplayItem i : flatten(groups)) {
|
||||
adapter.add(i);
|
||||
}
|
||||
adapter.setNotifyOnChange(true);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
protected GpxDisplayItemType filterType() {
|
||||
protected GpxDisplayItemType[] filterTypes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected boolean hasFilterType(GpxDisplayItemType filterType) {
|
||||
for (GpxDisplayItemType type : filterTypes()) {
|
||||
if (type == filterType) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static boolean hasFilterType(GpxDisplayItemType[] filterTypes, GpxDisplayItemType filterType) {
|
||||
for (GpxDisplayItemType type : filterTypes) {
|
||||
if (type == filterType) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected List<GpxDisplayItem> flatten(List<GpxDisplayGroup> groups) {
|
||||
ArrayList<GpxDisplayItem> list = new ArrayList<GpxDisplayItem>();
|
||||
for(GpxDisplayGroup g : groups) {
|
||||
|
@ -195,6 +216,9 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
|||
View view = getActivity().getLayoutInflater().inflate(R.layout.update_index, container, false);
|
||||
view.findViewById(R.id.header_layout).setVisibility(View.GONE);
|
||||
ListView listView = (ListView) view.findViewById(android.R.id.list);
|
||||
listView.setDivider(null);
|
||||
listView.setDividerHeight(0);
|
||||
listView.addFooterView(getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, null, false));
|
||||
TextView tv = new TextView(getActivity());
|
||||
tv.setText(R.string.none_selected_gpx);
|
||||
tv.setTextSize(24);
|
||||
|
@ -214,7 +238,7 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
|||
protected void saveAsFavorites(final GpxDisplayItemType gpxDisplayItemType) {
|
||||
AlertDialog.Builder b = new AlertDialog.Builder(getMyActivity());
|
||||
final EditText editText = new EditText(getMyActivity());
|
||||
final List<GpxDisplayGroup> gs = filterGroups(gpxDisplayItemType, getMyActivity(), getArguments());
|
||||
final List<GpxDisplayGroup> gs = filterGroups(new GpxDisplayItemType[] { gpxDisplayItemType }, getMyActivity(), getArguments());
|
||||
if (gs.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -239,7 +263,7 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
|||
|
||||
protected void saveAsMapMarkers(final GpxDisplayItemType gpxDisplayItemType) {
|
||||
AlertDialog.Builder b = new AlertDialog.Builder(getMyActivity());
|
||||
final List<GpxDisplayGroup> gs = filterGroups(gpxDisplayItemType, getMyActivity(), getArguments());
|
||||
final List<GpxDisplayGroup> gs = filterGroups(new GpxDisplayItemType[] { gpxDisplayItemType }, getMyActivity(), getArguments());
|
||||
if (gs.size() == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -309,7 +333,7 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
|||
}
|
||||
|
||||
protected void selectSplitDistance() {
|
||||
final List<GpxDisplayGroup> groups = filterGroups(GpxDisplayItemType.TRACK_SEGMENT,
|
||||
final List<GpxDisplayGroup> groups = filterGroups(new GpxDisplayItemType[] { GpxDisplayItemType.TRACK_SEGMENT },
|
||||
getMyActivity(), getArguments());
|
||||
|
||||
View view = getMyActivity().getLayoutInflater().inflate(R.layout.selected_track_edit, null);
|
||||
|
@ -447,78 +471,8 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
|||
|
||||
}
|
||||
|
||||
class SelectedGPXAdapter extends ArrayAdapter<GpxDisplayItem> {
|
||||
|
||||
|
||||
public SelectedGPXAdapter(List<GpxDisplayItem> items) {
|
||||
super(getActivity(), R.layout.gpx_item_list_item, items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View row = convertView;
|
||||
LineChart mChart = null;
|
||||
if (row == null) {
|
||||
LayoutInflater inflater = getMyActivity().getLayoutInflater();
|
||||
row = inflater.inflate(R.layout.gpx_item_list_item, parent, false);
|
||||
|
||||
mChart = (LineChart) row.findViewById(R.id.chart);
|
||||
GPXUtilities.setupGPXChart(app, mChart, 5);
|
||||
}
|
||||
GpxDisplayItem child = getItem(position);
|
||||
TextView label = (TextView) row.findViewById(R.id.name);
|
||||
TextView description = (TextView) row.findViewById(R.id.description);
|
||||
TextView additional = (TextView) row.findViewById(R.id.additional);
|
||||
ImageView icon = (ImageView) row.findViewById(R.id.icon);
|
||||
if (child.splitMetric >= 0 && child.splitName != null) {
|
||||
additional.setVisibility(View.VISIBLE);
|
||||
icon.setVisibility(View.INVISIBLE);
|
||||
additional.setText(child.splitName);
|
||||
} else {
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
additional.setVisibility(View.INVISIBLE);
|
||||
if (child.group.getType() == GpxDisplayItemType.TRACK_SEGMENT) {
|
||||
icon.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_polygom_dark));
|
||||
} else if (child.group.getType() == GpxDisplayItemType.TRACK_ROUTE_POINTS) {
|
||||
icon.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_markers_dark));
|
||||
} else {
|
||||
int groupColor = child.group.getColor();
|
||||
if (child.locationStart != null) {
|
||||
groupColor = child.locationStart.getColor(groupColor);
|
||||
}
|
||||
if (groupColor == 0) {
|
||||
groupColor = getMyActivity().getResources().getColor(R.color.gpx_track);
|
||||
}
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getMyActivity(), groupColor, false));
|
||||
}
|
||||
}
|
||||
row.setTag(child);
|
||||
|
||||
label.setText(Html.fromHtml(child.name.replace("\n", "<br/>")));
|
||||
boolean expand = true; //child.expanded || isArgumentTrue(ARG_TO_EXPAND_TRACK_INFO)
|
||||
if (expand && !Algorithms.isEmpty(child.description)) {
|
||||
String d = child.description;
|
||||
description.setText(Html.fromHtml(d));
|
||||
description.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
description.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (mChart != null) {
|
||||
if (child.analysis != null && child.analysis.elevationData != null && child.analysis.isElevationSpecified() && (child.analysis.totalDistance > 0)) {
|
||||
|
||||
GPXUtilities.setGPXChartData(app, mChart, child.analysis, Utils.getSDKInt() >= 18
|
||||
? R.drawable.line_chart_fade_orange : R.color.osmand_orange);
|
||||
|
||||
mChart.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mChart.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
public ArrayAdapter<GpxSelectionHelper.GpxDisplayItem> createSelectedGPXAdapter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -575,24 +529,36 @@ public class SelectedGPXFragment extends OsmAndListFragment {
|
|||
public static class MyMarkerView extends MarkerView {
|
||||
|
||||
private TextView tvContent;
|
||||
private String altSuffix;
|
||||
private String unitsLeft;
|
||||
private String unitsRight;
|
||||
|
||||
public MyMarkerView(Context context, int layoutResource, boolean useFeet) {
|
||||
public MyMarkerView(Context context, int layoutResource) {
|
||||
super(context, layoutResource);
|
||||
|
||||
tvContent = (TextView) findViewById(R.id.tvContent);
|
||||
if (!useFeet) {
|
||||
altSuffix = getContext().getString(R.string.m);
|
||||
} else {
|
||||
altSuffix = getContext().getString(R.string.foot);
|
||||
}
|
||||
}
|
||||
|
||||
public String getUnitsLeft() {
|
||||
return unitsLeft;
|
||||
}
|
||||
|
||||
public void setUnitsLeft(String unitsLeft) {
|
||||
this.unitsLeft = unitsLeft;
|
||||
}
|
||||
|
||||
public String getUnitsRight() {
|
||||
return unitsRight;
|
||||
}
|
||||
|
||||
public void setUnitsRight(String unitsRight) {
|
||||
this.unitsRight = unitsRight;
|
||||
}
|
||||
|
||||
// callbacks everytime the MarkerView is redrawn, can be used to update the
|
||||
// content (user-interface)
|
||||
@Override
|
||||
public void refreshContent(Entry e, Highlight highlight) {
|
||||
tvContent.setText(Integer.toString((int)e.getY()) + " " + altSuffix);
|
||||
tvContent.setText(Integer.toString((int)e.getY()) + " "
|
||||
+ (highlight.getAxis() == YAxis.AxisDependency.LEFT ? unitsLeft : unitsRight));
|
||||
super.refreshContent(e, highlight);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,46 +1,123 @@
|
|||
package net.osmand.plus.myplaces;
|
||||
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
||||
import net.osmand.plus.R;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Denis
|
||||
* on 04.03.2015.
|
||||
*/
|
||||
public class TrackPointFragment extends SelectedGPXFragment {
|
||||
|
||||
@Override
|
||||
protected GpxDisplayItemType filterType() {
|
||||
return GpxSelectionHelper.GpxDisplayItemType.TRACK_POINTS;
|
||||
protected GpxDisplayItemType[] filterTypes() {
|
||||
return new GpxDisplayItemType[] { GpxSelectionHelper.GpxDisplayItemType.TRACK_POINTS, GpxSelectionHelper.GpxDisplayItemType.TRACK_ROUTE_POINTS };
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
MenuItem item = menu.add(R.string.shared_string_add_to_favorites).setIcon(R.drawable.ic_action_fav_dark).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
MenuItem item = menu.add(R.string.shared_string_add_to_favorites)
|
||||
.setIcon(R.drawable.ic_action_fav_dark)
|
||||
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
saveAsFavorites(filterType());
|
||||
//saveAsFavorites(filterType());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
|
||||
if (app.getSettings().USE_MAP_MARKERS.get()) {
|
||||
item = menu.add(R.string.shared_string_add_to_map_markers).setIcon(R.drawable.ic_action_flag_dark)
|
||||
item = menu.add(R.string.shared_string_add_to_map_markers)
|
||||
.setIcon(R.drawable.ic_action_flag_dark)
|
||||
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
saveAsMapMarkers(GpxSelectionHelper.GpxDisplayItemType.TRACK_POINTS);
|
||||
//saveAsMapMarkers(GpxSelectionHelper.GpxDisplayItemType.TRACK_POINTS);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayAdapter<GpxDisplayItem> createSelectedGPXAdapter() {
|
||||
return new PointGPXAdapter(new ArrayList<GpxDisplayItem>());
|
||||
}
|
||||
|
||||
|
||||
class PointGPXAdapter extends ArrayAdapter<GpxDisplayItem> {
|
||||
|
||||
PointGPXAdapter(List<GpxDisplayItem> items) {
|
||||
super(getActivity(), R.layout.gpx_list_item_tab_content, items);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||
GpxDisplayItem child = adapter.getItem(position);
|
||||
|
||||
View row = convertView;
|
||||
if (row == null) {
|
||||
LayoutInflater inflater = getMyActivity().getLayoutInflater();
|
||||
row = inflater.inflate(R.layout.gpx_item_list_item, parent, false);
|
||||
}
|
||||
|
||||
TextView label = (TextView) row.findViewById(R.id.name);
|
||||
TextView description = (TextView) row.findViewById(R.id.description);
|
||||
TextView additional = (TextView) row.findViewById(R.id.additional);
|
||||
ImageView icon = (ImageView) row.findViewById(R.id.icon);
|
||||
if (child.splitMetric >= 0 && child.splitName != null) {
|
||||
additional.setVisibility(View.VISIBLE);
|
||||
icon.setVisibility(View.INVISIBLE);
|
||||
additional.setText(child.splitName);
|
||||
} else {
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
additional.setVisibility(View.INVISIBLE);
|
||||
if (child.group.getType() == GpxDisplayItemType.TRACK_ROUTE_POINTS) {
|
||||
icon.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_markers_dark));
|
||||
} else {
|
||||
int groupColor = child.group.getColor();
|
||||
if (child.locationStart != null) {
|
||||
groupColor = child.locationStart.getColor(groupColor);
|
||||
}
|
||||
if (groupColor == 0) {
|
||||
groupColor = getMyActivity().getResources().getColor(R.color.gpx_track);
|
||||
}
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(getMyActivity(), groupColor, false));
|
||||
}
|
||||
}
|
||||
row.setTag(child);
|
||||
|
||||
label.setText(Html.fromHtml(child.name.replace("\n", "<br/>")));
|
||||
boolean expand = true; //child.expanded || isArgumentTrue(ARG_TO_EXPAND_TRACK_INFO)
|
||||
if (expand && !Algorithms.isEmpty(child.description)) {
|
||||
String d = child.description;
|
||||
description.setText(Html.fromHtml(d));
|
||||
description.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
description.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
package net.osmand.plus.myplaces;
|
||||
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
||||
import net.osmand.plus.activities.TrackActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Denis on 05.03.2015.
|
||||
*/
|
||||
public class TrackRoutePointFragment extends SelectedGPXFragment {
|
||||
@Override
|
||||
protected GpxDisplayItemType filterType() {
|
||||
return GpxSelectionHelper.GpxDisplayItemType.TRACK_ROUTE_POINTS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
MenuItem item = menu.add(R.string.shared_string_add_to_favorites).setIcon(R.drawable.ic_action_fav_dark)
|
||||
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
saveAsFavorites(GpxSelectionHelper.GpxDisplayItemType.TRACK_ROUTE_POINTS);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
|
||||
if (app.getSettings().USE_MAP_MARKERS.get()) {
|
||||
item = menu.add(R.string.shared_string_add_to_map_markers).setIcon(R.drawable.ic_action_flag_dark)
|
||||
.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
saveAsMapMarkers(GpxSelectionHelper.GpxDisplayItemType.TRACK_ROUTE_POINTS);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +1,56 @@
|
|||
package net.osmand.plus.myplaces;
|
||||
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
||||
import net.osmand.plus.R;
|
||||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.util.SparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.github.mikephil.charting.charts.LineChart;
|
||||
import com.github.mikephil.charting.data.LineData;
|
||||
import com.github.mikephil.charting.data.LineDataSet;
|
||||
import com.github.mikephil.charting.interfaces.datasets.ILineDataSet;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXTrackAnalysis;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
||||
import net.osmand.plus.views.controls.PagerSlidingTabStrip.CustomTabProvider;
|
||||
import net.osmand.plus.views.controls.WrapContentHeightViewPager;
|
||||
import net.osmand.plus.views.controls.WrapContentHeightViewPager.ViewAtPositionInterface;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by Denis
|
||||
* on 04.03.2015.
|
||||
*/
|
||||
public class TrackSegmentFragment extends SelectedGPXFragment {
|
||||
|
||||
@Override
|
||||
protected GpxDisplayItemType filterType() {
|
||||
return GpxSelectionHelper.GpxDisplayItemType.TRACK_SEGMENT;
|
||||
protected GpxDisplayItemType[] filterTypes() {
|
||||
return new GpxDisplayItemType[] { GpxSelectionHelper.GpxDisplayItemType.TRACK_SEGMENT };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,4 +65,382 @@ public class TrackSegmentFragment extends SelectedGPXFragment {
|
|||
});
|
||||
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayAdapter<GpxDisplayItem> createSelectedGPXAdapter() {
|
||||
return new SegmentGPXAdapter(new ArrayList<GpxDisplayItem>());
|
||||
}
|
||||
|
||||
class SegmentGPXAdapter extends ArrayAdapter<GpxDisplayItem> {
|
||||
|
||||
private Map<GpxDisplayItem, GPXItemPagerAdapter> pagerAdaptersMap = new HashMap<>();
|
||||
|
||||
SegmentGPXAdapter(List<GpxDisplayItem> items) {
|
||||
super(getActivity(), R.layout.gpx_list_item_tab_content, items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
super.clear();
|
||||
pagerAdaptersMap.clear();
|
||||
}
|
||||
|
||||
private GPXItemPagerAdapter getPagerAdapter(PagerSlidingTabStrip tabs, GpxDisplayItem gpxItem) {
|
||||
GPXItemPagerAdapter adapter = pagerAdaptersMap.get(gpxItem);
|
||||
if (adapter == null) {
|
||||
adapter = new GPXItemPagerAdapter(tabs, gpxItem);
|
||||
pagerAdaptersMap.put(gpxItem, adapter);
|
||||
}
|
||||
return adapter;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
|
||||
View row = convertView;
|
||||
PagerSlidingTabStrip tabLayout = null;
|
||||
if (row == null) {
|
||||
LayoutInflater inflater = getMyActivity().getLayoutInflater();
|
||||
row = inflater.inflate(R.layout.gpx_list_item_tab_content, parent, false);
|
||||
|
||||
boolean light = app.getSettings().isLightContent();
|
||||
tabLayout = (PagerSlidingTabStrip) row.findViewById(R.id.sliding_tabs);
|
||||
tabLayout.setTabBackground(R.color.color_transparent);
|
||||
tabLayout.setIndicatorColorResource(light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark);
|
||||
tabLayout.setIndicatorBgColorResource(light ? R.color.dashboard_divider_light : R.color.dashboard_divider_dark);
|
||||
tabLayout.setIndicatorHeight(AndroidUtils.dpToPx(app, 1f));
|
||||
tabLayout.setTextColor(tabLayout.getIndicatorColor());
|
||||
tabLayout.setTextSize(AndroidUtils.spToPx(app, 12f));
|
||||
tabLayout.setShouldExpand(true);
|
||||
tabLayout.setTabSelectionType(PagerSlidingTabStrip.TabSelectionType.SOLID_COLOR);
|
||||
}
|
||||
|
||||
if (tabLayout != null) {
|
||||
final WrapContentHeightViewPager pager = (WrapContentHeightViewPager) row.findViewById(R.id.pager);
|
||||
pager.setAdapter(getPagerAdapter(tabLayout, getItem(position)));
|
||||
pager.setSwipeable(false);
|
||||
tabLayout.setViewPager(pager);
|
||||
}
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
||||
enum GPXTabItemType {
|
||||
GPX_TAB_ITEM_GENERAL,
|
||||
GPX_TAB_ITEM_ALTITUDE,
|
||||
GPX_TAB_ITEM_SPEED
|
||||
}
|
||||
|
||||
class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvider, ViewAtPositionInterface {
|
||||
|
||||
protected SparseArray<View> views = new SparseArray<>();
|
||||
private PagerSlidingTabStrip tabs;
|
||||
private GpxDisplayItem gpxItem;
|
||||
private GPXTabItemType[] tabTypes;
|
||||
private String[] titles;
|
||||
|
||||
GPXItemPagerAdapter(PagerSlidingTabStrip tabs, GpxDisplayItem gpxItem) {
|
||||
super();
|
||||
this.tabs = tabs;
|
||||
this.gpxItem = gpxItem;
|
||||
fetchTabTypes();
|
||||
}
|
||||
|
||||
private void fetchTabTypes() {
|
||||
|
||||
List<GPXTabItemType> tabTypeList = new ArrayList<>();
|
||||
tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_GENERAL);
|
||||
if (gpxItem != null && gpxItem.analysis != null) {
|
||||
if (gpxItem.analysis.elevationData != null) {
|
||||
tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_ALTITUDE);
|
||||
}
|
||||
if (gpxItem.analysis.isSpeedSpecified()) {
|
||||
tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_SPEED);
|
||||
}
|
||||
}
|
||||
tabTypes = tabTypeList.toArray(new GPXTabItemType[tabTypeList.size()]);
|
||||
|
||||
Context context = tabs.getContext();
|
||||
titles = new String[tabTypes.length];
|
||||
for (int i = 0; i < titles.length; i++) {
|
||||
switch (tabTypes[i]) {
|
||||
case GPX_TAB_ITEM_GENERAL:
|
||||
titles[i] = context.getString(R.string.general_settings);
|
||||
break;
|
||||
case GPX_TAB_ITEM_ALTITUDE:
|
||||
titles[i] = context.getString(R.string.altitude);
|
||||
break;
|
||||
case GPX_TAB_ITEM_SPEED:
|
||||
titles[i] = context.getString(R.string.map_widget_speed);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return tabTypes.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
return titles[position];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int position) {
|
||||
|
||||
GPXTabItemType tabType = tabTypes[position];
|
||||
View view = null;
|
||||
switch (tabType) {
|
||||
case GPX_TAB_ITEM_GENERAL:
|
||||
view = getActivity().getLayoutInflater().inflate(R.layout.gpx_item_general, container, false);
|
||||
break;
|
||||
case GPX_TAB_ITEM_ALTITUDE:
|
||||
view = getActivity().getLayoutInflater().inflate(R.layout.gpx_item_altitude, container, false);
|
||||
break;
|
||||
case GPX_TAB_ITEM_SPEED:
|
||||
view = getActivity().getLayoutInflater().inflate(R.layout.gpx_item_speed, container, false);
|
||||
break;
|
||||
}
|
||||
|
||||
if (view != null) {
|
||||
OsmandApplication app = (OsmandApplication) getActivity().getApplicationContext();
|
||||
if (gpxItem != null) {
|
||||
GPXTrackAnalysis analysis = gpxItem.analysis;
|
||||
LineChart chart = (LineChart) view.findViewById(R.id.chart);
|
||||
chart.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
getListView().requestDisallowInterceptTouchEvent(true);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
IconsCache ic = app.getIconsCache();
|
||||
switch (tabType) {
|
||||
case GPX_TAB_ITEM_GENERAL:
|
||||
if (analysis != null) {
|
||||
ArrayList<ILineDataSet> dataSets = new ArrayList<>();
|
||||
if (analysis.elevationData != null || analysis.isSpeedSpecified()) {
|
||||
GPXUtilities.setupGPXChart(app, chart, 4);
|
||||
if (analysis.isSpeedSpecified()) {
|
||||
LineDataSet dataSet = GPXUtilities.createGPXSpeedDataSet(app, chart, analysis, true);
|
||||
dataSets.add(dataSet);
|
||||
}
|
||||
if (analysis.elevationData != null) {
|
||||
LineDataSet dataSet = GPXUtilities.createGPXElevationDataSet(app, chart, analysis, false);
|
||||
dataSets.add(dataSet);
|
||||
}
|
||||
LineData data = new LineData(dataSets);
|
||||
chart.setData(data);
|
||||
chart.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
chart.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
((ImageView) view.findViewById(R.id.distance_icon))
|
||||
.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_polygom_dark));
|
||||
((ImageView) view.findViewById(R.id.duration_icon))
|
||||
.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_time_start));
|
||||
((ImageView) view.findViewById(R.id.start_time_icon))
|
||||
.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_time_start));
|
||||
((ImageView) view.findViewById(R.id.end_time_icon))
|
||||
.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_time_start));
|
||||
|
||||
((TextView) view.findViewById(R.id.distance_text))
|
||||
.setText(OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app));
|
||||
((TextView) view.findViewById(R.id.duration_text))
|
||||
.setText(Algorithms.formatDuration((int) (analysis.timeSpan / 1000), app.accessibilityEnabled()));
|
||||
|
||||
if (analysis.timeSpan > 0) {
|
||||
DateFormat tf = SimpleDateFormat.getTimeInstance(DateFormat.SHORT);
|
||||
DateFormat df = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM);
|
||||
|
||||
Date start = new Date(analysis.startTime);
|
||||
((TextView) view.findViewById(R.id.start_time_text)).setText(tf.format(start));
|
||||
((TextView) view.findViewById(R.id.start_date_text)).setText(df.format(start));
|
||||
Date end = new Date(analysis.endTime);
|
||||
((TextView) view.findViewById(R.id.end_time_text)).setText(tf.format(end));
|
||||
((TextView) view.findViewById(R.id.end_date_text)).setText(df.format(end));
|
||||
} else {
|
||||
view.findViewById(R.id.list_divider).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.start_end_time).setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
chart.setVisibility(View.GONE);
|
||||
view.findViewById(R.id.distance_time_span).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.list_divider).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.start_end_time).setVisibility(View.GONE);
|
||||
}
|
||||
view.findViewById(R.id.details_view).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//todo
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
case GPX_TAB_ITEM_ALTITUDE:
|
||||
if (analysis != null) {
|
||||
if (analysis.elevationData != null) {
|
||||
GPXUtilities.setupGPXChart(app, chart, 4);
|
||||
GPXUtilities.setGPXElevationChartData(app, chart, analysis, false);
|
||||
chart.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
chart.setVisibility(View.GONE);
|
||||
}
|
||||
((ImageView) view.findViewById(R.id.average_icon))
|
||||
.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_altitude_average));
|
||||
((ImageView) view.findViewById(R.id.range_icon))
|
||||
.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_altitude_average));
|
||||
((ImageView) view.findViewById(R.id.ascent_icon))
|
||||
.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_altitude_ascent));
|
||||
((ImageView) view.findViewById(R.id.descent_icon))
|
||||
.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_altitude_descent));
|
||||
|
||||
String min = OsmAndFormatter.getFormattedAlt(analysis.minElevation, app);
|
||||
String max = OsmAndFormatter.getFormattedAlt(analysis.maxElevation, app);
|
||||
String asc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationUp, app);
|
||||
String desc = OsmAndFormatter.getFormattedAlt(analysis.diffElevationDown, app);
|
||||
|
||||
((TextView) view.findViewById(R.id.average_text))
|
||||
.setText(OsmAndFormatter.getFormattedAlt(analysis.avgElevation, app));
|
||||
((TextView) view.findViewById(R.id.range_text)).setText(min + " - " + max);
|
||||
((TextView) view.findViewById(R.id.ascent_text)).setText(asc);
|
||||
((TextView) view.findViewById(R.id.descent_text)).setText(desc);
|
||||
|
||||
} else {
|
||||
chart.setVisibility(View.GONE);
|
||||
view.findViewById(R.id.average_range).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.list_divider).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.ascent_descent).setVisibility(View.GONE);
|
||||
}
|
||||
view.findViewById(R.id.details_view).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//todo
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
case GPX_TAB_ITEM_SPEED:
|
||||
if (analysis != null && analysis.isSpeedSpecified()) {
|
||||
GPXUtilities.setupGPXChart(app, chart, 4);
|
||||
GPXUtilities.setGPXSpeedChartData(app, chart, analysis, false);
|
||||
|
||||
((ImageView) view.findViewById(R.id.average_icon))
|
||||
.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_speed));
|
||||
((ImageView) view.findViewById(R.id.max_icon))
|
||||
.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_max_speed));
|
||||
((ImageView) view.findViewById(R.id.time_moving_icon))
|
||||
.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_time_span));
|
||||
((ImageView) view.findViewById(R.id.distance_icon))
|
||||
.setImageDrawable(ic.getThemedIcon(R.drawable.ic_action_polygom_dark));
|
||||
|
||||
String avg = OsmAndFormatter.getFormattedSpeed(analysis.avgSpeed, app);
|
||||
String max = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app);
|
||||
|
||||
((TextView) view.findViewById(R.id.average_text)).setText(avg);
|
||||
((TextView) view.findViewById(R.id.max_text)).setText(max);
|
||||
((TextView) view.findViewById(R.id.time_moving_text))
|
||||
.setText(Algorithms.formatDuration((int) (analysis.timeMoving / 1000), app.accessibilityEnabled()));
|
||||
((TextView) view.findViewById(R.id.distance_text))
|
||||
.setText(OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app));
|
||||
|
||||
} else {
|
||||
chart.setVisibility(View.GONE);
|
||||
view.findViewById(R.id.average_max).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.list_divider).setVisibility(View.GONE);
|
||||
view.findViewById(R.id.time_distance).setVisibility(View.GONE);
|
||||
}
|
||||
view.findViewById(R.id.details_view).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//todo
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
container.addView(view, 0);
|
||||
views.put(position, view);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyItem(ViewGroup collection, int position, Object view) {
|
||||
views.remove(position);
|
||||
collection.removeView((View) view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view == object;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getCustomTabView(ViewGroup parent, int position) {
|
||||
View tab = getActivity().getLayoutInflater().inflate(R.layout.gpx_tab, parent, false);
|
||||
tab.setTag(tabTypes[position].name());
|
||||
deselect(tab);
|
||||
return tab;
|
||||
}
|
||||
|
||||
private int getImageId(GPXTabItemType tabType) {
|
||||
int imageId;
|
||||
switch (tabType) {
|
||||
case GPX_TAB_ITEM_GENERAL:
|
||||
imageId = R.drawable.ic_action_polygom_dark;
|
||||
break;
|
||||
case GPX_TAB_ITEM_ALTITUDE:
|
||||
imageId = R.drawable.ic_action_altitude_average;
|
||||
break;
|
||||
case GPX_TAB_ITEM_SPEED:
|
||||
imageId = R.drawable.ic_action_speed;
|
||||
break;
|
||||
default:
|
||||
imageId = R.drawable.ic_action_folder_stroke;
|
||||
}
|
||||
return imageId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void select(View tab) {
|
||||
GPXTabItemType tabType = GPXTabItemType.valueOf((String)tab.getTag());
|
||||
ImageView img = (ImageView) tab.findViewById(R.id.tab_image);
|
||||
int imageId = getImageId(tabType);
|
||||
switch (tabs.getTabSelectionType()) {
|
||||
case ALPHA:
|
||||
ViewCompat.setAlpha(img, tabs.getTabTextSelectedAlpha());
|
||||
break;
|
||||
case SOLID_COLOR:
|
||||
img.setImageDrawable(app.getIconsCache().getPaintedIcon(imageId, tabs.getTextColor()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deselect(View tab) {
|
||||
GPXTabItemType tabType = GPXTabItemType.valueOf((String)tab.getTag());
|
||||
ImageView img = (ImageView) tab.findViewById(R.id.tab_image);
|
||||
int imageId = getImageId(tabType);
|
||||
switch (tabs.getTabSelectionType()) {
|
||||
case ALPHA:
|
||||
ViewCompat.setAlpha(img, tabs.getTabTextAlpha());
|
||||
break;
|
||||
case SOLID_COLOR:
|
||||
img.setImageDrawable(app.getIconsCache().getPaintedIcon(imageId, tabs.getTabInactiveTextColor()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getViewAtPosition(int position) {
|
||||
return views.get(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,6 @@ import android.graphics.Color;
|
|||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
@ -45,6 +43,7 @@ import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
|||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
|
||||
|
@ -56,8 +55,15 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
private static final float OPAQUE = 1.0f;
|
||||
private static final float HALF_TRANSP = 0.6f;
|
||||
|
||||
public enum TabSelectionType {
|
||||
ALPHA,
|
||||
SOLID_COLOR
|
||||
}
|
||||
|
||||
public interface CustomTabProvider {
|
||||
public View getCustomTabView(ViewGroup parent, int position);
|
||||
public void select(View tab);
|
||||
public void deselect(View tab);
|
||||
}
|
||||
|
||||
public interface OnTabReselectedListener {
|
||||
|
@ -116,6 +122,9 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
private int tabPadding = 12;
|
||||
private int tabTextSize = 14;
|
||||
private int tabTextColor = 0;
|
||||
|
||||
private TabSelectionType tabSelectionType = TabSelectionType.ALPHA;
|
||||
private int tabInactiveTextColor = 0;
|
||||
private float tabTextAlpha = HALF_TRANSP;
|
||||
private float tabTextSelectedAlpha = OPAQUE;
|
||||
|
||||
|
@ -181,6 +190,7 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
// get custom attrs
|
||||
a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);
|
||||
tabTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsTextColor, underlineColor);
|
||||
tabInactiveTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsInactiveTextColor, underlineColor);
|
||||
indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
|
||||
underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
|
||||
dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
|
||||
|
@ -283,8 +293,6 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
TextView textView = (TextView) tabView.findViewById(R.id.tab_title);
|
||||
if (textView != null) {
|
||||
if (title != null) textView.setText(title);
|
||||
float alpha = pager.getCurrentItem() == position ? tabTextSelectedAlpha : tabTextAlpha;
|
||||
ViewCompat.setAlpha(textView, alpha);
|
||||
}
|
||||
|
||||
tabView.setFocusable(true);
|
||||
|
@ -315,7 +323,24 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
if (tab_title != null) {
|
||||
tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
|
||||
tab_title.setTypeface(tabTypeface, pager.getCurrentItem() == i ? tabTypefaceSelectedStyle : tabTypefaceStyle);
|
||||
tab_title.setTextColor(tabTextColor);
|
||||
switch (tabSelectionType) {
|
||||
case ALPHA:
|
||||
float alpha = pager.getCurrentItem() == i ? tabTextSelectedAlpha : tabTextAlpha;
|
||||
ViewCompat.setAlpha(tab_title, alpha);
|
||||
tab_title.setTextColor(tabTextColor);
|
||||
break;
|
||||
case SOLID_COLOR:
|
||||
ViewCompat.setAlpha(tab_title, OPAQUE);
|
||||
tab_title.setTextColor(pager.getCurrentItem() == i ? tabTextColor : tabInactiveTextColor);
|
||||
break;
|
||||
}
|
||||
if (pager.getAdapter() instanceof CustomTabProvider) {
|
||||
if (pager.getCurrentItem() == i) {
|
||||
((CustomTabProvider) pager.getAdapter()).select(v);
|
||||
} else {
|
||||
((CustomTabProvider) pager.getAdapter()).deselect(v);
|
||||
}
|
||||
}
|
||||
|
||||
// setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
|
||||
// pre-ICS-build
|
||||
|
@ -518,7 +543,17 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
TextView title = (TextView) tab.findViewById(R.id.tab_title);
|
||||
if (title != null) {
|
||||
title.setTypeface(tabTypeface, tabTypefaceStyle);
|
||||
ViewCompat.setAlpha(title, tabTextAlpha);
|
||||
switch (tabSelectionType) {
|
||||
case ALPHA:
|
||||
ViewCompat.setAlpha(title, tabTextAlpha);
|
||||
break;
|
||||
case SOLID_COLOR:
|
||||
title.setTextColor(tabInactiveTextColor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pager.getAdapter() instanceof CustomTabProvider) {
|
||||
((CustomTabProvider) pager.getAdapter()).deselect(tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -528,7 +563,17 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
TextView title = (TextView) tab.findViewById(R.id.tab_title);
|
||||
if (title != null) {
|
||||
title.setTypeface(tabTypeface, tabTypefaceSelectedStyle);
|
||||
ViewCompat.setAlpha(title, tabTextSelectedAlpha);
|
||||
switch (tabSelectionType) {
|
||||
case ALPHA:
|
||||
ViewCompat.setAlpha(title, tabTextSelectedAlpha);
|
||||
break;
|
||||
case SOLID_COLOR:
|
||||
title.setTextColor(tabTextColor);
|
||||
break;
|
||||
}
|
||||
if (pager.getAdapter() instanceof CustomTabProvider) {
|
||||
((CustomTabProvider) pager.getAdapter()).select(tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -668,10 +713,26 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
return textAllCaps;
|
||||
}
|
||||
|
||||
public TabSelectionType getTabSelectionType() {
|
||||
return tabSelectionType;
|
||||
}
|
||||
|
||||
public int getTextColor() {
|
||||
return tabTextColor;
|
||||
}
|
||||
|
||||
public int getTabInactiveTextColor() {
|
||||
return tabInactiveTextColor;
|
||||
}
|
||||
|
||||
public float getTabTextAlpha() {
|
||||
return tabTextAlpha;
|
||||
}
|
||||
|
||||
public float getTabTextSelectedAlpha() {
|
||||
return tabTextSelectedAlpha;
|
||||
}
|
||||
|
||||
public int getTabBackground() {
|
||||
return tabBackgroundResId;
|
||||
}
|
||||
|
@ -690,6 +751,16 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
invalidate();
|
||||
}
|
||||
|
||||
public void setIndicatorBgColor(int indicatorBgColor) {
|
||||
this.indicatorBgColor = indicatorBgColor;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setIndicatorBgColorResource(int resId) {
|
||||
this.indicatorBgColor = getResources().getColor(resId);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setIndicatorHeight(int indicatorLineHeightPx) {
|
||||
this.indicatorHeight = indicatorLineHeightPx;
|
||||
invalidate();
|
||||
|
@ -751,10 +822,18 @@ public class PagerSlidingTabStrip extends HorizontalScrollView {
|
|||
updateTabStyles();
|
||||
}
|
||||
|
||||
public void setTabSelectionType(TabSelectionType tabSelectionType) {
|
||||
this.tabSelectionType = tabSelectionType;
|
||||
}
|
||||
|
||||
public void setTextColor(int textColor) {
|
||||
tabTextColor = textColor;
|
||||
}
|
||||
|
||||
public void setTabInactiveTextColor(int tabInactiveTextColor) {
|
||||
this.tabInactiveTextColor = tabInactiveTextColor;
|
||||
}
|
||||
|
||||
private ColorStateList getColorStateList(int textColor) {
|
||||
return new ColorStateList(new int[][]{new int[]{}}, new int[]{textColor});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,177 @@
|
|||
package net.osmand.plus.views.controls;
|
||||
|
||||
import android.content.Context;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
public class WrapContentHeightViewPager extends ViewPager {
|
||||
|
||||
private boolean swipeable = true;
|
||||
private int height = 0;
|
||||
private int decorHeight = 0;
|
||||
private int widthMeasuredSpec;
|
||||
|
||||
private boolean animateHeight;
|
||||
private int rightHeight;
|
||||
private int leftHeight;
|
||||
private int scrollingPosition = -1;
|
||||
|
||||
public interface ViewAtPositionInterface {
|
||||
|
||||
public View getViewAtPosition(int position);
|
||||
}
|
||||
|
||||
public WrapContentHeightViewPager(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public WrapContentHeightViewPager(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
addOnPageChangeListener(new OnPageChangeListener() {
|
||||
|
||||
int state;
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float offset, int positionOffsetPixels) {}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
if (state == SCROLL_STATE_IDLE) {
|
||||
height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
this.state = state;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAdapter(PagerAdapter adapter) {
|
||||
if (!(adapter instanceof ViewAtPositionInterface)) {
|
||||
throw new IllegalArgumentException("WrapContentHeightViewPager requires that PagerAdapter will implement ViewAtPositionInterface");
|
||||
}
|
||||
height = 0;
|
||||
super.setAdapter(adapter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to redraw the view size to wrap the content of the bigger child.
|
||||
*
|
||||
* @param widthMeasureSpec with measured
|
||||
* @param heightMeasureSpec height measured
|
||||
*/
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
|
||||
widthMeasuredSpec = widthMeasureSpec;
|
||||
int mode = MeasureSpec.getMode(heightMeasureSpec);
|
||||
|
||||
if (mode == MeasureSpec.UNSPECIFIED || mode == MeasureSpec.AT_MOST) {
|
||||
if (height == 0) {
|
||||
// measure vertical decor (i.e. PagerTitleStrip) based on ViewPager implementation
|
||||
decorHeight = 0;
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View child = getChildAt(i);
|
||||
LayoutParams lp = (LayoutParams) child.getLayoutParams();
|
||||
if (lp != null && lp.isDecor) {
|
||||
int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK;
|
||||
boolean consumeVertical = vgrav == Gravity.TOP || vgrav == Gravity.BOTTOM;
|
||||
if (consumeVertical) {
|
||||
decorHeight += child.getMeasuredHeight() ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make sure that we have an height (not sure if this is necessary because it seems that onPageScrolled is called right after
|
||||
int position = getCurrentItem();
|
||||
View child = getViewAtPosition(position);
|
||||
if (child != null) {
|
||||
height = measureViewHeight(child);
|
||||
}
|
||||
|
||||
}
|
||||
int totalHeight = height + decorHeight + getPaddingBottom() + getPaddingTop();
|
||||
heightMeasureSpec = MeasureSpec.makeMeasureSpec(totalHeight, MeasureSpec.EXACTLY);
|
||||
}
|
||||
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float offset, int positionOffsetPixels) {
|
||||
super.onPageScrolled(position, offset, positionOffsetPixels);
|
||||
// cache scrolled view heights
|
||||
if (scrollingPosition != position) {
|
||||
scrollingPosition = position;
|
||||
// scrolled position is always the left scrolled page
|
||||
View leftView = getViewAtPosition(position);
|
||||
View rightView = getViewAtPosition(position + 1);
|
||||
if (leftView != null && rightView != null) {
|
||||
leftHeight = measureViewHeight(leftView);
|
||||
rightHeight = measureViewHeight(rightView);
|
||||
animateHeight = true;
|
||||
} else {
|
||||
animateHeight = false;
|
||||
}
|
||||
}
|
||||
if (animateHeight) {
|
||||
int newHeight = (int) (leftHeight * (1 - offset) + rightHeight * (offset));
|
||||
if (height != newHeight) {
|
||||
height = newHeight;
|
||||
requestLayout();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int measureViewHeight(View view) {
|
||||
view.measure(getChildMeasureSpec(widthMeasuredSpec, getPaddingLeft() + getPaddingRight(), view.getLayoutParams().width), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
||||
return view.getMeasuredHeight();
|
||||
}
|
||||
|
||||
protected View getViewAtPosition(int position) {
|
||||
if (getAdapter() != null) {
|
||||
Object objectAtPosition = ((ViewAtPositionInterface) getAdapter()).getViewAtPosition(position);
|
||||
if (objectAtPosition != null) {
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View child = getChildAt(i);
|
||||
if (child != null && getAdapter().isViewFromObject(child, objectAtPosition)) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isSwipeable() {
|
||||
return swipeable;
|
||||
}
|
||||
|
||||
public void setSwipeable(boolean swipeable) {
|
||||
this.swipeable = swipeable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent event) {
|
||||
return swipeable && super.onInterceptTouchEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
return swipeable && super.onTouchEvent(event);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue