From fa9c3154e0199f2a427ad2963437f9a02af07ecb Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Sat, 8 Jul 2017 09:38:58 +0300 Subject: [PATCH 1/3] Fix time and displaying range string --- OsmAnd/res/layout/gpx_split_segment_fragment.xml | 2 +- OsmAnd/src/net/osmand/plus/GPXUtilities.java | 8 ++------ .../net/osmand/plus/myplaces/SplitSegmentFragment.java | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/OsmAnd/res/layout/gpx_split_segment_fragment.xml b/OsmAnd/res/layout/gpx_split_segment_fragment.xml index 788f97561c..4741ce93ef 100644 --- a/OsmAnd/res/layout/gpx_split_segment_fragment.xml +++ b/OsmAnd/res/layout/gpx_split_segment_fragment.xml @@ -309,7 +309,7 @@ android:layout_height="wrap_content" android:layout_marginTop="3dp" android:background="@null" - android:text="@string/range" + android:text="@string/range_min_max" android:textColor="?android:attr/textColorSecondary" android:textSize="@dimen/default_split_segments_sub" /> diff --git a/OsmAnd/src/net/osmand/plus/GPXUtilities.java b/OsmAnd/src/net/osmand/plus/GPXUtilities.java index ec73ad3bdd..e0553c7f50 100644 --- a/OsmAnd/src/net/osmand/plus/GPXUtilities.java +++ b/OsmAnd/src/net/osmand/plus/GPXUtilities.java @@ -275,7 +275,7 @@ public class GPXUtilities { public double minElevation = 99999; public double maxElevation = -100; - public float minSpeed = 0; + public float minSpeed = Float.MAX_VALUE; public float maxSpeed = 0; public float avgSpeed; @@ -521,11 +521,7 @@ public class GPXUtilities { if (speed > 0) { totalSpeedSum += speed; - if (minSpeed == 0) { - minSpeed = speed; - } else { - minSpeed = Math.min(speed, minSpeed); - } + minSpeed = Math.min(speed, minSpeed); maxSpeed = Math.max(speed, maxSpeed); speedCount++; } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java index b0d52a599f..67314082a6 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java @@ -544,7 +544,7 @@ public class SplitSegmentFragment extends OsmAndListFragment { String maxSpeed = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app); String minSpeed = OsmAndFormatter.getFormattedSpeed(analysis.minSpeed, app); - String max_min_speed = maxSpeed.substring(0, maxSpeed.indexOf(" ")).concat("/").concat(minSpeed.substring(0, minSpeed.indexOf(" "))); + String max_min_speed = maxSpeed.substring(0, maxSpeed.indexOf(" ")).concat("/").concat(minSpeed); if (minSpeed.substring(0, minSpeed.indexOf(" ")).equals("0") || minSpeed.substring(0, minSpeed.indexOf(" ")).equals("0.0")) { (convertView.findViewById(R.id.max_speed_value)) .setVisibility(View.VISIBLE); From 7624cd36eced33d55dc43970e9ec4b6b5f5a9d7f Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Mon, 10 Jul 2017 10:42:31 +0300 Subject: [PATCH 2/3] Test displaying last segment --- OsmAnd/src/net/osmand/plus/GPXUtilities.java | 1 + .../src/net/osmand/plus/activities/TrackActivity.java | 10 ++++++++++ .../net/osmand/plus/myplaces/TrackSegmentFragment.java | 1 + 3 files changed, 12 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/GPXUtilities.java b/OsmAnd/src/net/osmand/plus/GPXUtilities.java index e0553c7f50..ad8931db29 100644 --- a/OsmAnd/src/net/osmand/plus/GPXUtilities.java +++ b/OsmAnd/src/net/osmand/plus/GPXUtilities.java @@ -521,6 +521,7 @@ public class GPXUtilities { if (speed > 0) { totalSpeedSum += speed; +// android.util.Log.d(GPXUtilities.class.getSimpleName(), "metricEnd: " + s.metricEnd + " speed: " + speed); minSpeed = Math.min(speed, minSpeed); maxSpeed = Math.max(speed, maxSpeed); speedCount++; diff --git a/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java b/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java index 86cbbc353e..6cd2b107a5 100644 --- a/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java @@ -48,6 +48,10 @@ public class TrackActivity extends TabActivity { private List originalGroups = new ArrayList<>(); private boolean stopped = false; + public PagerSlidingTabStrip getSlidingTabLayout() { + return slidingTabLayout; + } + @Override public void onCreate(Bundle icicle) { ((OsmandApplication) getApplication()).applyTheme(this); @@ -234,6 +238,9 @@ public class TrackActivity extends TabActivity { ((TrackSegmentFragment) frag).updateSplitView(); } } + if (isHavingWayPoints() || isHavingRoutePoints()) { + getSlidingTabLayout().setVisibility(View.VISIBLE); + } getSupportFragmentManager().popBackStack(); return true; } @@ -264,6 +271,9 @@ public class TrackActivity extends TabActivity { ((TrackSegmentFragment) frag).updateSplitView(); } } + if (isHavingWayPoints() || isHavingRoutePoints()) { + getSlidingTabLayout().setVisibility(View.VISIBLE); + } getSupportFragmentManager().popBackStack(); return; } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java index 0ddbe9373f..e3f8fdb18d 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java @@ -1472,6 +1472,7 @@ public class TrackSegmentFragment extends OsmAndListFragment { } void openSplitIntervalScreen() { + getMyActivity().getSlidingTabLayout().setVisibility(View.GONE); getMyActivity().getSupportFragmentManager() .beginTransaction() .replace(R.id.track_activity_layout, new SplitSegmentFragment()) From 3e42d5001a9b23413dfe2008d1791ca78f384226 Mon Sep 17 00:00:00 2001 From: PavelRatushny Date: Mon, 10 Jul 2017 14:27:44 +0300 Subject: [PATCH 3/3] Fix time --- OsmAnd/src/net/osmand/plus/GPXUtilities.java | 3 +-- OsmAnd/src/net/osmand/plus/activities/TrackActivity.java | 4 ++-- OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/GPXUtilities.java b/OsmAnd/src/net/osmand/plus/GPXUtilities.java index 3020411c30..be8990d1a3 100644 --- a/OsmAnd/src/net/osmand/plus/GPXUtilities.java +++ b/OsmAnd/src/net/osmand/plus/GPXUtilities.java @@ -519,10 +519,9 @@ public class GPXUtilities { hasElevationData = true; } + minSpeed = Math.min(speed, minSpeed); if (speed > 0) { totalSpeedSum += speed; -// android.util.Log.d(GPXUtilities.class.getSimpleName(), "metricEnd: " + s.metricEnd + " speed: " + speed); - minSpeed = Math.min(speed, minSpeed); maxSpeed = Math.max(speed, maxSpeed); speedCount++; } diff --git a/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java b/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java index 6cd2b107a5..b0286a90e6 100644 --- a/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/TrackActivity.java @@ -238,10 +238,10 @@ public class TrackActivity extends TabActivity { ((TrackSegmentFragment) frag).updateSplitView(); } } + getSupportFragmentManager().popBackStack(); if (isHavingWayPoints() || isHavingRoutePoints()) { getSlidingTabLayout().setVisibility(View.VISIBLE); } - getSupportFragmentManager().popBackStack(); return true; } } @@ -271,10 +271,10 @@ public class TrackActivity extends TabActivity { ((TrackSegmentFragment) frag).updateSplitView(); } } + getSupportFragmentManager().popBackStack(); if (isHavingWayPoints() || isHavingRoutePoints()) { getSlidingTabLayout().setVisibility(View.VISIBLE); } - getSupportFragmentManager().popBackStack(); return; } } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java index e3f8fdb18d..bf4587fc83 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java @@ -1472,12 +1472,12 @@ public class TrackSegmentFragment extends OsmAndListFragment { } void openSplitIntervalScreen() { - getMyActivity().getSlidingTabLayout().setVisibility(View.GONE); getMyActivity().getSupportFragmentManager() .beginTransaction() .replace(R.id.track_activity_layout, new SplitSegmentFragment()) .addToBackStack(SplitSegmentFragment.TAG) .commit(); + getMyActivity().getSlidingTabLayout().setVisibility(View.GONE); } private class SplitTrackAsyncTask extends AsyncTask {