From fd86d10067cabf8d92a7ae1f0d987e39ba63a7a8 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Wed, 5 Jul 2017 10:44:38 +0300 Subject: [PATCH 1/3] Disable click on split segment --- OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java index 2526055e01..34b1dc8a41 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java @@ -346,6 +346,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) { From 70fc627f2d4e5606e23d56fdb5ea561623082798 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 6 Jul 2017 11:20:50 +0300 Subject: [PATCH 2/3] Fix size and displaying timespan or distance --- .../res/layout/gpx_split_segment_fragment.xml | 52 +++++++++---------- OsmAnd/res/values-large/sizes.xml | 4 ++ OsmAnd/res/values/sizes.xml | 4 ++ .../plus/myplaces/SplitSegmentFragment.java | 27 +++++----- 4 files changed, 49 insertions(+), 38 deletions(-) diff --git a/OsmAnd/res/layout/gpx_split_segment_fragment.xml b/OsmAnd/res/layout/gpx_split_segment_fragment.xml index 387a4ab4a8..b1e4cda7da 100644 --- a/OsmAnd/res/layout/gpx_split_segment_fragment.xml +++ b/OsmAnd/res/layout/gpx_split_segment_fragment.xml @@ -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"/> + android:textSize="@dimen/default_split_segments_overview"/> @@ -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"/> + android:textSize="@dimen/default_split_segments_sub"/> @@ -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"/> + android:textSize="@dimen/default_split_segments_sub"/> @@ -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"/> + android:textSize="@dimen/default_split_segments_sub"/> @@ -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"/> + android:textSize="@dimen/default_split_segments_sub"/> @@ -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"/> + android:textSize="@dimen/default_split_segments_data"/> + android:textSize="@dimen/default_split_segments_data"/> + android:textSize="@dimen/default_split_segments_sub" /> @@ -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"/> + android:textSize="@dimen/default_split_segments_data"/> + android:textSize="@dimen/default_split_segments_data"/> + android:textSize="@dimen/default_split_segments_sub"/> @@ -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"/> + android:textSize="@dimen/default_split_segments_sub"/> @@ -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"/> + android:textSize="@dimen/default_split_segments_sub"/> @@ -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"/> + android:textSize="@dimen/default_split_segments_data"/> + android:textSize="@dimen/default_split_segments_data"/> + android:textSize="@dimen/default_split_segments_sub"/> diff --git a/OsmAnd/res/values-large/sizes.xml b/OsmAnd/res/values-large/sizes.xml index 7716dffd2e..30eddb8516 100644 --- a/OsmAnd/res/values-large/sizes.xml +++ b/OsmAnd/res/values-large/sizes.xml @@ -74,5 +74,9 @@ 16sp 14sp 27sp + + 14sp + 14sp + 11sp \ No newline at end of file diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 500b0e4f8b..d56e2e75b2 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -134,5 +134,9 @@ 12sp 23sp + 12sp + 12sp + 9sp + 20sp \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java index 34b1dc8a41..f1d50693ad 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java @@ -91,7 +91,7 @@ public class SplitSegmentFragment extends OsmAndListFragment { adapter = new SplitSegmentsAdapter(new ArrayList()); 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)); + ((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.addFooterView(getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, null, false)); @@ -379,12 +379,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)) @@ -405,18 +399,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); From 6ea6b95928b00b7eaa9ecc53f2e4dadab5eafe85 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Thu, 6 Jul 2017 19:03:03 +0300 Subject: [PATCH 3/3] Test adding scroll --- .../gpx_split_segments_empty_header.xml | 11 +++ .../res/layout/gpx_split_segments_header.xml | 61 ------------ OsmAnd/res/layout/split_segments_layout.xml | 86 +++++++++++++++++ .../plus/myplaces/SplitSegmentFragment.java | 93 ++++++++++++++++--- 4 files changed, 179 insertions(+), 72 deletions(-) create mode 100644 OsmAnd/res/layout/gpx_split_segments_empty_header.xml delete mode 100644 OsmAnd/res/layout/gpx_split_segments_header.xml create mode 100644 OsmAnd/res/layout/split_segments_layout.xml diff --git a/OsmAnd/res/layout/gpx_split_segments_empty_header.xml b/OsmAnd/res/layout/gpx_split_segments_empty_header.xml new file mode 100644 index 0000000000..94ff6a29e0 --- /dev/null +++ b/OsmAnd/res/layout/gpx_split_segments_empty_header.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/gpx_split_segments_header.xml b/OsmAnd/res/layout/gpx_split_segments_header.xml deleted file mode 100644 index 541877ace4..0000000000 --- a/OsmAnd/res/layout/gpx_split_segments_header.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OsmAnd/res/layout/split_segments_layout.xml b/OsmAnd/res/layout/split_segments_layout.xml new file mode 100644 index 0000000000..20fdb8abfe --- /dev/null +++ b/OsmAnd/res/layout/split_segments_layout.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java index f1d50693ad..06d6999da3 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java @@ -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()); - headerView = getActivity().getLayoutInflater().inflate(R.layout.gpx_split_segments_header, null, false); + 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);