Test adding split segments fragments

This commit is contained in:
PavelRatushny 2017-06-30 19:01:01 +03:00
parent 1f0c286c4e
commit 012657b027
5 changed files with 854 additions and 399 deletions

View file

@ -4,467 +4,476 @@
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/overview_image"
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_time_start"
android:layout_marginBottom="12dp"
android:layout_marginTop="12dp"
android:layout_marginRight="12dp"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/overview_text"
android:background="@null"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"
tools:text="Overview"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/fragment_count_text"
android:background="@null"
android:layout_gravity="center_vertical"
android:gravity="right"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"
tools:text="1 of 4"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="28dp"
android:background="?attr/dashboard_divider"/>
android:layout_height="wrap_content">
<include layout="@layout/list_item_divider"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
android:background="?attr/bg_color"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<LinearLayout
android:layout_marginRight="3dp"
android:layout_width="107dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/distance_or_timespan_image"
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_polygom_dark"
android:layout_marginRight="12dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/distance_or_time_span_value"
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_or_time_span_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
tools:text="@string/distance"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginRight="3dp"
android:layout_width="107dp"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/overview_image"
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_time_start"
android:layout_marginBottom="12dp"
android:layout_marginTop="12dp"
android:layout_marginRight="12dp"/>
<LinearLayout
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/overview_text"
android:background="@null"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"
tools:text="Overview"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/start_time_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="15:24:58"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/fragment_count_text"
android:background="@null"
android:layout_gravity="center_vertical"
android:gravity="right"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"
tools:text="1 of 4"/>
<TextView
android:layout_width="match_parent"
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="28dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<LinearLayout
android:layout_marginRight="3dp"
android:layout_width="107dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/distance_or_timespan_image"
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_polygom_dark"
android:layout_marginRight="12dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
android:text="@string/shared_string_start_time"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/distance_or_time_span_value"
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_or_time_span_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
tools:text="@string/distance"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginRight="3dp"
android:layout_width="107dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_time_start"
android:layout_marginRight="12dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/start_time_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="15:24:58"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
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="107dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_time_end"
android:layout_marginRight="12dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/end_time_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="15:34:58"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
android:text="@string/shared_string_end_time"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="107dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="28dp"
android:background="?attr/dashboard_divider"/>
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_time_end"
android:layout_marginRight="12dp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_marginRight="3dp"
android:layout_width="107dp"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="horizontal">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/end_time_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="15:34:58"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_altitude_average"
android:layout_marginRight="12dp"/>
<TextView
android:layout_width="match_parent"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
android:text="@string/shared_string_end_time"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/average_altitude_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="25 000 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
tools:text="Average"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginRight="3dp"
android:layout_width="107dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_altitude_average"
android:layout_marginRight="12dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/min_altitude_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="1 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/max_altitude_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="2335 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
android:text="Range"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="107dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_altitude_average"
android:layout_marginRight="12dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/ascent_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="6280 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/descent_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="6285 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
android:text="Ascent/Descent"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="28dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="28dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:layout_marginRight="3dp"
android:layout_width="107dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_altitude_average"
android:layout_marginRight="12dp"/>
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_marginRight="3dp"
android:layout_width="107dp"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="horizontal">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/average_altitude_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="25 000 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_time_span"
android:layout_marginRight="12dp"/>
<TextView
android:layout_width="match_parent"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
tools:text="Average"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/moving_time_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="3:20:12"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
tools:text="Moving time"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginRight="3dp"
android:layout_width="107dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_altitude_average"
android:layout_marginRight="12dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_marginRight="3dp"
android:layout_width="107dp"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="horizontal">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/min_altitude_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="1 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_speed"
android:layout_marginRight="12dp"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/max_altitude_value"
android:layout_width="match_parent"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
tools:text="2335 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
android:text="Range"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/average_speed_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="11.1 km/h"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
android:text="Average"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="107dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_altitude_average"
android:layout_marginRight="12dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="107dp"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="horizontal">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/ascent_value"
android:layout_width="match_parent"
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_speed"
android:layout_marginRight="12dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
tools:text="6280 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/descent_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="6285 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/max_min_speed_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="93 kmg/h"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
android:text="Ascent/Descent"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
android:text="Max/Min"
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:layout_marginLeft="28dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<LinearLayout
android:layout_marginRight="3dp"
android:layout_width="107dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_time_span"
android:layout_marginRight="12dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/moving_time_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="3:20:12"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
tools:text="Moving time"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_marginRight="3dp"
android:layout_width="107dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_speed"
android:layout_marginRight="12dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/average_speed_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="11.1 km/h"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
android:text="Average"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="107dp"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/ic_action_speed"
android:layout_marginRight="12dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/max_min_speed_value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
tools:text="93 kmg/h"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:layout_marginTop="3dp"
android:text="Max/Min"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
</LinearLayout>
</LinearLayout>

View file

@ -0,0 +1,60 @@
<?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="horizontal"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="?attr/bg_color"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_action_time_start"
android:layout_marginBottom="12dp"
android:layout_marginTop="12dp"
android:layout_marginRight="16dp"/>
<LinearLayout
android:id="@+id/split_interval_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/split_interval_title"
android:background="@null"
android:layout_gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"
android:text="Split interval:"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/split_interval_text"
android:background="@null"
android:layout_gravity="center_vertical"
android:gravity="right"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"
tools:text="10 km"/>
<ImageView
android:id="@+id/split_interval_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_action_arrow_drop_down"/>
</LinearLayout>
</LinearLayout>

View file

@ -3,7 +3,8 @@
android:layout_width="fill_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
android:orientation="vertical"
android:id="@+id/track_activity_layout">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"

View file

@ -0,0 +1,381 @@
package net.osmand.plus.myplaces;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.ListPopupWindow;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.base.OsmAndListFragment;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import gnu.trove.list.array.TIntArrayList;
import static net.osmand.plus.myplaces.TrackSegmentFragment.ARG_TO_FILTER_SHORT_TRACKS;
public class SplitSegmentFragment extends OsmAndListFragment{
private OsmandApplication app;
private SplitSegmentsAdapter adapter;
private View headerView;
private GpxDisplayItemType[] filterTypes = { GpxDisplayItemType.TRACK_SEGMENT };
private List<String> options = new ArrayList<>();
private List<Double> distanceSplit = new ArrayList<>();
private TIntArrayList timeSplit = new TIntArrayList();
private int selectedSplitInterval;
private boolean updateEnable;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.app = getMyApplication();
}
@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));
}
@Override
public ArrayAdapter<?> getAdapter() {
return adapter;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setHasOptionsMenu(true);
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);
adapter = new SplitSegmentsAdapter(new ArrayList<GpxDisplayItem>());
headerView = getActivity().getLayoutInflater().inflate(R.layout.gpx_split_segments_header, null, false);
listView.addHeaderView(headerView);
listView.addFooterView(getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, null, false));
updateHeader();
setListAdapter(adapter);
return view;
}
private void updateHeader() {
final View splitIntervalView = headerView.findViewById(R.id.split_interval_view);
if (getGpx() != null && !getGpx().showCurrentTrack && adapter.getCount() > 0) {
prepareSplitIntervalAdapterData();
setupSplitIntervalView(splitIntervalView);
updateSplitIntervalView(splitIntervalView);
splitIntervalView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final ListPopupWindow popup = new ListPopupWindow(getActivity());
popup.setAnchorView(splitIntervalView);
popup.setContentWidth(AndroidUtils.dpToPx(app, 200f));
popup.setModal(true);
popup.setDropDownGravity(Gravity.RIGHT | Gravity.TOP);
popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
popup.setAdapter(new ArrayAdapter<>(getMyActivity(),
R.layout.popup_list_text_item, options));
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectedSplitInterval = position;
GpxSelectionHelper.SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), true, false);
final List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups.size() > 0) {
updateSplit(groups, sf);
}
popup.dismiss();
updateSplitIntervalView(splitIntervalView);
}
});
popup.show();
}
});
splitIntervalView.setVisibility(View.VISIBLE);
} else {
splitIntervalView.setVisibility(View.GONE);
}
}
@Override
public void onResume() {
super.onResume();
updateContent();
updateEnable = true;
}
@Override
public void onPause() {
super.onPause();
updateEnable = false;
}
public void updateContent() {
adapter.clear();
GPXUtilities.GPXFile gpxFile = getGpx();
List<GpxDisplayGroup> displayGroups = getDisplayGroups();
List<GpxDisplayGroup> groups = getOriginalGroups();
adapter.setNotifyOnChange(false);
for (GpxDisplayItem i : flatten(groups)) {
adapter.add(i);
}
adapter.setNotifyOnChange(true);
adapter.notifyDataSetChanged();
updateHeader();
}
protected List<GpxDisplayItem> flatten(List<GpxDisplayGroup> groups) {
ArrayList<GpxDisplayItem> list = new ArrayList<>();
for(GpxDisplayGroup g : groups) {
list.addAll(g.getModifiableList());
}
return list;
}
private List<GpxDisplayGroup> getOriginalGroups() {
return filterGroups(false);
}
private void updateSplit(List<GpxDisplayGroup> groups, GpxSelectionHelper.SelectedGpxFile sf) {
new SplitTrackAsyncTask(sf, groups).execute((Void) null);
}
private void setupSplitIntervalView(View view) {
final TextView title = (TextView) view.findViewById(R.id.split_interval_title);
final TextView text = (TextView) view.findViewById(R.id.split_interval_text);
final ImageView img = (ImageView) view.findViewById(R.id.split_interval_arrow);
int colorId;
final List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups.size() > 0) {
colorId = app.getSettings().isLightContent() ?
R.color.primary_text_light : R.color.primary_text_dark;
} else {
colorId = app.getSettings().isLightContent() ?
R.color.secondary_text_light : R.color.secondary_text_dark;
}
int color = app.getResources().getColor(colorId);
title.setTextColor(color);
text.setTextColor(color);
img.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_arrow_drop_down, colorId));
}
private void updateSplitIntervalView(View view) {
final TextView text = (TextView) view.findViewById(R.id.split_interval_text);
if (selectedSplitInterval == 0) {
text.setText(getString(R.string.shared_string_none));
} else {
text.setText(options.get(selectedSplitInterval));
}
}
private GPXUtilities.GPXFile getGpx() {
return getMyActivity().getGpx();
}
public TrackActivity getMyActivity() {
return (TrackActivity) getActivity();
}
private void prepareSplitIntervalAdapterData() {
final List<GpxDisplayGroup> groups = getDisplayGroups();
options.add(app.getString(R.string.shared_string_none));
distanceSplit.add(-1d);
timeSplit.add(-1);
addOptionSplit(30, true, groups); // 50 feet, 20 yards, 20
// m
addOptionSplit(60, true, groups); // 100 feet, 50 yards,
// 50 m
addOptionSplit(150, true, groups); // 200 feet, 100 yards,
// 100 m
addOptionSplit(300, true, groups); // 500 feet, 200 yards,
// 200 m
addOptionSplit(600, true, groups); // 1000 feet, 500 yards,
// 500 m
addOptionSplit(1500, true, groups); // 2000 feet, 1000 yards, 1 km
addOptionSplit(3000, true, groups); // 1 mi, 2 km
addOptionSplit(6000, true, groups); // 2 mi, 5 km
addOptionSplit(15000, true, groups); // 5 mi, 10 km
addOptionSplit(15, false, groups);
addOptionSplit(30, false, groups);
addOptionSplit(60, false, groups);
addOptionSplit(120, false, groups);
addOptionSplit(150, false, groups);
addOptionSplit(300, false, groups);
addOptionSplit(600, false, groups);
addOptionSplit(900, false, groups);
addOptionSplit(1800, false, groups);
addOptionSplit(3600, false, groups);
}
private List<GpxDisplayGroup> getDisplayGroups() {
return filterGroups(true);
}
private void addOptionSplit(int value, boolean distance, List<GpxDisplayGroup> model) {
if (distance) {
double dvalue = OsmAndFormatter.calculateRoundedDist(value, app);
options.add(OsmAndFormatter.getFormattedDistance((float) dvalue, app));
distanceSplit.add(dvalue);
timeSplit.add(-1);
if (Math.abs(model.get(0).getSplitDistance() - dvalue) < 1) {
selectedSplitInterval = distanceSplit.size() - 1;
}
} else {
if (value < 60) {
options.add(value + " " + app.getString(R.string.int_seconds));
} else if (value % 60 == 0) {
options.add((value / 60) + " " + app.getString(R.string.int_min));
} else {
options.add((value / 60f) + " " + app.getString(R.string.int_min));
}
distanceSplit.add(-1d);
timeSplit.add(value);
if (model.get(0).getSplitTime() == value) {
selectedSplitInterval = distanceSplit.size() - 1;
}
}
}
private List<GpxDisplayGroup> filterGroups(boolean useDisplayGroups) {
List<GpxDisplayGroup> result = getMyActivity().getGpxFile(useDisplayGroups);
List<GpxDisplayGroup> groups = new ArrayList<>();
for (GpxDisplayGroup group : result) {
boolean add = hasFilterType(group.getType());
if (isArgumentTrue(ARG_TO_FILTER_SHORT_TRACKS)) {
Iterator<GpxDisplayItem> item = group.getModifiableList().iterator();
while (item.hasNext()) {
GpxDisplayItem it2 = item.next();
if (it2.analysis != null && it2.analysis.totalDistance < 100) {
item.remove();
}
}
if (group.getModifiableList().isEmpty()) {
add = false;
}
}
if (add) {
groups.add(group);
}
}
return groups;
}
private List<GpxDisplayItem> getSplitSegments(boolean useDisplayGroups) {
List<GpxDisplayGroup> result = getMyActivity().getGpxFile(useDisplayGroups);
List<GpxDisplayItem> splitSegments = new ArrayList<>();
for (GpxDisplayGroup group : result) {
splitSegments.addAll(group.getModifiableList());
}
return splitSegments;
}
private boolean isArgumentTrue(@NonNull String arg) {
return getArguments() != null && getArguments().getBoolean(arg);
}
protected boolean hasFilterType(GpxDisplayItemType filterType) {
for (GpxDisplayItemType type : filterTypes) {
if (type == filterType) {
return true;
}
}
return false;
}
private class SplitSegmentsAdapter extends ArrayAdapter<GpxDisplayItem> {
public SplitSegmentsAdapter(List<GpxDisplayItem> items) {
super(getActivity(), 0, items);
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
GpxDisplayItem currentGpxDisplayItem = getItem(position);
if (convertView == null) {
convertView = getMyActivity().getLayoutInflater().inflate(R.layout.gpx_split_segment_fragment, parent, false);
}
return convertView;
}
}
private class SplitTrackAsyncTask extends AsyncTask<Void, Void, Void> {
@Nullable
private final GpxSelectionHelper.SelectedGpxFile mSelectedGpxFile;
@NonNull private final TrackActivity mActivity;
private final List<GpxDisplayGroup> groups;
SplitTrackAsyncTask(@Nullable GpxSelectionHelper.SelectedGpxFile selectedGpxFile, List<GpxDisplayGroup> groups) {
mSelectedGpxFile = selectedGpxFile;
mActivity = getMyActivity();
this.groups = groups;
}
protected void onPostExecute(Void result) {
if (mSelectedGpxFile != null) {
mSelectedGpxFile.setDisplayGroups(getDisplayGroups());
}
if (!mActivity.isFinishing()) {
mActivity.setProgressBarIndeterminateVisibility(false);
}
}
protected void onPreExecute() {
mActivity.setProgressBarIndeterminateVisibility(true);
}
@Override
protected Void doInBackground(Void... params) {
for (GpxDisplayGroup model : groups) {
OsmandApplication application = mActivity.getMyApplication();
if (selectedSplitInterval == 0) {
model.noSplit(application);
} else if (distanceSplit.get(selectedSplitInterval) > 0) {
model.splitByDistance(application, distanceSplit.get(selectedSplitInterval));
} else if (timeSplit.get(selectedSplitInterval) > 0) {
model.splitByTime(application, timeSplit.get(selectedSplitInterval));
}
}
return null;
}
}
}

View file

@ -1449,7 +1449,11 @@ public class TrackSegmentFragment extends OsmAndListFragment {
}
void openSplitIntervalScreen() {
getFragmentManager()
.beginTransaction()
.replace(R.id.track_activity_layout, new SplitSegmentFragment())
.addToBackStack(null)
.commit();
}
private class SplitTrackAsyncTask extends AsyncTask<Void, Void, Void> {