Merge branch 'split_interval_screen' of ssh://github.com/osmandapp/Osmand into split_interval_screen

This commit is contained in:
PavelRatushny 2017-07-06 23:52:31 +03:00
commit 631a82149e
7 changed files with 229 additions and 110 deletions

View file

@ -38,7 +38,7 @@
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"
android:textSize="@dimen/default_split_segments_overview"
tools:text="Overview"/>
<TextView
@ -50,7 +50,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
android:textSize="@dimen/default_split_segments_overview"/>
</LinearLayout>
@ -94,7 +94,7 @@
tools:text="40 km"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:textSize="@dimen/default_split_segments_data"/>
<TextView
android:id="@+id/distance_or_time_span_text"
@ -104,7 +104,7 @@
android:layout_marginTop="3dp"
tools:text="@string/distance"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
android:textSize="@dimen/default_split_segments_sub"/>
</LinearLayout>
@ -137,7 +137,7 @@
tools:text="15:24:58"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:textSize="@dimen/default_split_segments_data"/>
<TextView
android:id="@+id/start_date_value"
@ -147,7 +147,7 @@
android:layout_marginTop="3dp"
tools:text="Aud 8, 2016"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
android:textSize="@dimen/default_split_segments_sub"/>
</LinearLayout>
@ -179,7 +179,7 @@
tools:text="15:34:58"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:textSize="@dimen/default_split_segments_data"/>
<TextView
android:id="@+id/end_date_value"
@ -189,7 +189,7 @@
android:layout_marginTop="3dp"
tools:text="Aug 8, 2016"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
android:textSize="@dimen/default_split_segments_sub"/>
</LinearLayout>
@ -239,7 +239,7 @@
tools:text="25 000 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:textSize="@dimen/default_split_segments_data"/>
<TextView
android:layout_width="match_parent"
@ -248,7 +248,7 @@
android:layout_marginTop="3dp"
android:text="@string/average"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
android:textSize="@dimen/default_split_segments_sub"/>
</LinearLayout>
@ -281,7 +281,7 @@
tools:text="1/2335 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:textSize="@dimen/default_split_segments_data"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/min_altitude_value"
@ -291,7 +291,7 @@
tools:text="1 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:textSize="@dimen/default_split_segments_data"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/max_altitude_value"
@ -301,7 +301,7 @@
tools:text="2335 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:textSize="@dimen/default_split_segments_data"/>
<TextView
android:id="@+id/textView4"
@ -311,7 +311,7 @@
android:background="@null"
android:text="@string/range"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size" />
android:textSize="@dimen/default_split_segments_sub" />
</LinearLayout>
@ -343,7 +343,7 @@
tools:text="6280/6285 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:textSize="@dimen/default_split_segments_data"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/ascent_value"
@ -353,7 +353,7 @@
tools:text="6280 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:textSize="@dimen/default_split_segments_data"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/descent_value"
@ -363,7 +363,7 @@
tools:text="6285 m"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:textSize="@dimen/default_split_segments_data"/>
<TextView
android:layout_width="match_parent"
@ -372,7 +372,7 @@
android:layout_marginTop="3dp"
android:text="@string/ascent_descent"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
android:textSize="@dimen/default_split_segments_sub"/>
</LinearLayout>
@ -422,7 +422,7 @@
tools:text="3:20:12"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:textSize="@dimen/default_split_segments_data"/>
<TextView
android:layout_width="match_parent"
@ -431,7 +431,7 @@
android:layout_marginTop="3dp"
android:text="@string/moving_time"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
android:textSize="@dimen/default_split_segments_sub"/>
</LinearLayout>
@ -464,7 +464,7 @@
tools:text="11.1 km/h"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:textSize="@dimen/default_split_segments_data"/>
<TextView
android:layout_width="match_parent"
@ -473,7 +473,7 @@
android:layout_marginTop="3dp"
android:text="@string/average"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
android:textSize="@dimen/default_split_segments_sub"/>
</LinearLayout>
@ -505,7 +505,7 @@
tools:text="93/2 kmg/h"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:textSize="@dimen/default_split_segments_data"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/max_speed_value"
@ -515,7 +515,7 @@
tools:text="93 kmg/h"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:textSize="@dimen/default_split_segments_data"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/min_speed_value"
@ -525,7 +525,7 @@
tools:text="2 kmg/h"
android:textColor="?android:attr/textColorPrimary"
osmand:typeface="@string/font_roboto_medium"
android:textSize="@dimen/default_desc_text_size"/>
android:textSize="@dimen/default_split_segments_data"/>
<TextView
android:id="@+id/max_min_speed_text"
@ -535,7 +535,7 @@
android:layout_marginTop="3dp"
android:text="@string/max_min"
android:textColor="?android:attr/textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
android:textSize="@dimen/default_split_segments_sub"/>
</LinearLayout>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_width="match_parent"
android:layout_height="48dp"/>
</LinearLayout>

View file

@ -1,61 +0,0 @@
<?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:id="@+id/header_split_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
tools:src="@drawable/ic_action_split_interval"
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

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"/>
<LinearLayout
android:id="@+id/header_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
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:id="@+id/header_split_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
tools:src="@drawable/ic_action_split_interval"
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>
<include layout="@layout/card_bottom_divider"/>
</LinearLayout>
</FrameLayout>

View file

@ -74,5 +74,9 @@
<dimen name="default_desc_text_size">16sp</dimen>
<dimen name="default_sub_text_size">14sp</dimen>
<dimen name="welcome_header_text_size">27sp</dimen>
<dimen name="default_split_segments_overview">14sp</dimen>
<dimen name="default_split_segments_data">14sp</dimen>
<dimen name="default_split_segments_sub">11sp</dimen>
</resources>

View file

@ -134,5 +134,9 @@
<dimen name="default_sub_text_size">12sp</dimen>
<dimen name="welcome_header_text_size">23sp</dimen>
<dimen name="default_split_segments_overview">12sp</dimen>
<dimen name="default_split_segments_data">12sp</dimen>
<dimen name="default_split_segments_sub">9sp</dimen>
<dimen name="dialog_header_text_size">20sp</dimen>
</resources>

View file

@ -1,19 +1,22 @@
package net.osmand.plus.myplaces;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.res.ColorStateList;
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.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
@ -82,22 +85,96 @@ public class SplitSegmentFragment extends OsmAndListFragment {
@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);
final View view = getActivity().getLayoutInflater().inflate(R.layout.split_segments_layout, container, false);
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);
((ImageView) headerView.findViewById(R.id.header_split_image)).setImageDrawable(ic.getIcon(R.drawable.ic_action_split_interval, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0));
headerView = view.findViewById(R.id.header_layout);
((ImageView) headerView.findViewById(R.id.header_split_image)).setImageDrawable(ic.getIcon(R.drawable.ic_action_split_interval, app.getSettings().isLightContent() ? R.color.icon_color : 0));
listView.addHeaderView(headerView);
listView.addHeaderView(getActivity().getLayoutInflater().inflate(R.layout.gpx_split_segments_empty_header, null, false));
listView.addFooterView(getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, null, false));
updateHeader();
updateContent();
setListAdapter(adapter);
listView.setOnScrollListener(new AbsListView.OnScrollListener() {
int initialYPos;
boolean changed;
int visibility = View.VISIBLE;
@Override
public void onScrollStateChanged(AbsListView absListView, int i) {
initialYPos = -1;
changed = false;
}
@Override
public void onScroll(AbsListView absListView, int i, int i1, int i2) {
View c = absListView.getChildAt(0);
if (c != null) {
int currentYPos = -c.getTop() + absListView.getFirstVisiblePosition() * c.getHeight();
if (initialYPos == -1) {
initialYPos = currentYPos;
}
if (currentYPos < headerView.getHeight() && visibility == View.GONE) {
changed = false;
initialYPos = currentYPos;
}
if (currentYPos < initialYPos && !changed && visibility == View.GONE) {
if (currentYPos < headerView.getHeight()) {
headerView.setTranslationY(currentYPos - headerView.getHeight());
} else {
headerView.animate().translationY(0);
visibility = View.VISIBLE;
changed = true;
}
} else if (currentYPos > initialYPos && !changed && visibility == View.VISIBLE) {
if (currentYPos < headerView.getHeight()) {
headerView.setTranslationY(-currentYPos);
} else {
headerView.animate().translationY(-headerView.getHeight());
visibility = View.GONE;
changed = true;
}
}
Log.d("onScroll", "currentYpos: " + currentYPos);
Log.d("onScroll", "visibility: " + visibility);
Log.d("onScroll", "headerView.getHeight(): " + headerView.getHeight());
Log.d("onScroll", "headerView.getTranslationY(): " + headerView.getTranslationY());
// if (headerView.getHeight() != 0) {
// if (visibility == View.VISIBLE) {
// if (currentYPos < headerView.getHeight()) {
// headerView.setTranslationY(-currentYPos);
// } else if (!changed) {
// headerView.animate().translationY(-headerView.getHeight());
// visibility = View.GONE;
// changed = true;
// }
// }
//
// if (visibility == View.GONE) {
// if (currentYPos < headerView.getHeight()) {
// headerView.setTranslationY(currentYPos - headerView.getHeight());
// } else if (!changed) {
// headerView.animate().translationY(0);
// visibility = View.VISIBLE;
// changed = true;
// }
// }
// }
}
}
});
return view;
}
@ -145,12 +222,6 @@ public class SplitSegmentFragment extends OsmAndListFragment {
}
}
@Override
public void onResume() {
super.onResume();
updateContent();
}
public void updateContent() {
adapter.clear();
adapter.setNotifyOnChange(false);
@ -346,6 +417,7 @@ public class SplitSegmentFragment extends OsmAndListFragment {
if (convertView == null) {
convertView = getMyActivity().getLayoutInflater().inflate(R.layout.gpx_split_segment_fragment, parent, false);
}
convertView.setOnClickListener(null);
TextView overviewTextView = (TextView) convertView.findViewById(R.id.overview_text);
ImageView overviewImageView = (ImageView) convertView.findViewById(R.id.overview_image);
if (position == 0) {
@ -378,12 +450,6 @@ public class SplitSegmentFragment extends OsmAndListFragment {
}
}
ImageView distanceOrTimeSpanImageView = ((ImageView) convertView.findViewById(R.id.distance_or_timespan_image));
if (position == 0) {
distanceOrTimeSpanImageView.setImageDrawable(ic.getIcon(R.drawable.ic_action_track_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0));
} else {
distanceOrTimeSpanImageView.setImageDrawable(ic.getIcon(R.drawable.ic_action_time_span_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0));
}
((ImageView) convertView.findViewById(R.id.start_time_image))
.setImageDrawable(ic.getIcon(R.drawable.ic_action_time_start_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0));
((ImageView) convertView.findViewById(R.id.end_time_image))
@ -404,18 +470,27 @@ public class SplitSegmentFragment extends OsmAndListFragment {
if (currentGpxDisplayItem != null) {
GPXTrackAnalysis analysis = currentGpxDisplayItem.analysis;
if (analysis != null) {
ImageView distanceOrTimeSpanImageView = ((ImageView) convertView.findViewById(R.id.distance_or_timespan_image));
TextView distanceOrTimeSpanValue = (TextView) convertView.findViewById(R.id.distance_or_time_span_value);
TextView distanceOrTimeSpanText = (TextView) convertView.findViewById(R.id.distance_or_time_span_text);
if (position == 0) {
distanceOrTimeSpanImageView.setImageDrawable(ic.getIcon(R.drawable.ic_action_track_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0));
distanceOrTimeSpanValue.setText(OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app));
distanceOrTimeSpanText.setText(app.getString(R.string.distance));
} else {
if (analysis.timeSpan > 0) {
distanceOrTimeSpanValue.setText(OsmAndFormatter.getFormattedDuration((int) (analysis.timeSpan / 1000), app));
} else {
distanceOrTimeSpanValue.setText("-");
if (currentGpxDisplayItem.group.isSplitDistance()) {
distanceOrTimeSpanImageView.setImageDrawable(ic.getIcon(R.drawable.ic_action_time_span_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0));
if (analysis.timeSpan > 0) {
distanceOrTimeSpanValue.setText(Algorithms.formatDuration((int) (analysis.timeSpan / 1000), app.accessibilityEnabled()));
} else {
distanceOrTimeSpanValue.setText("-");
}
distanceOrTimeSpanText.setText(app.getString(R.string.shared_string_time_span));
} else if (currentGpxDisplayItem.group.isSplitTime()) {
distanceOrTimeSpanImageView.setImageDrawable(ic.getIcon(R.drawable.ic_action_track_16, app.getSettings().isLightContent() ? R.color.gpx_split_segment_icon_color : 0));
distanceOrTimeSpanValue.setText(OsmAndFormatter.getFormattedDistance(analysis.totalDistance, app));
distanceOrTimeSpanText.setText(app.getString(R.string.distance));
}
distanceOrTimeSpanText.setText(app.getString(R.string.shared_string_time_span));
}
TextView startTimeValue = (TextView) convertView.findViewById(R.id.start_time_value);