From 5081ffd41dc407aeed27d6ad2753fc6542d28d2e Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Wed, 17 Feb 2021 17:15:06 +0200 Subject: [PATCH 1/5] Review After changing segments using "Select another track" without closing RP, the last point of the previously selected segment will be added as a destination point. @androiddevkotlin Don't show route points quantity, on the second line we show only waypoints quantity @androiddevkotlin --- .../osmand/plus/helpers/TrackSelectSegmentAdapter.java | 10 ++++++---- .../plus/routepreparationmenu/FollowTrackFragment.java | 2 +- .../plus/routepreparationmenu/cards/TrackEditCard.java | 10 ++++++++-- .../src/net/osmand/plus/track/TrackMenuFragment.java | 2 +- .../plus/track/TrackSelectSegmentBottomSheet.java | 9 ++++++++- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/TrackSelectSegmentAdapter.java b/OsmAnd/src/net/osmand/plus/helpers/TrackSelectSegmentAdapter.java index 498f638081..e9b1a67ce3 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/TrackSelectSegmentAdapter.java +++ b/OsmAnd/src/net/osmand/plus/helpers/TrackSelectSegmentAdapter.java @@ -28,6 +28,7 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter segments; private OnItemClickListener onItemClickListener; + private ImageView timeIcon; public TrackSelectSegmentAdapter(Context ctx, List segments) { app = (OsmandApplication) ctx.getApplicationContext(); @@ -42,14 +43,14 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter 1 && routeParams != null && routeParams.getSelectedSegment() != -1) { TextView distanceView = view.findViewById(R.id.distance); TextView timeView = view.findViewById(R.id.time); + ImageView timeIcon = view.findViewById(R.id.time_icon); TextView pointsView = view.findViewById(R.id.points_count); + ImageView pointsIcon = view.findViewById(R.id.points_icon); + pointsView.setVisibility(View.GONE); + pointsIcon.setVisibility(View.GONE); List segments = gpxFile.getNonEmptyTrkSegments(false); GPXUtilities.TrkSegment segment = segments.get(routeParams.getSelectedSegment()); - int point = segment.points.size(); double distance = TrackSelectSegmentAdapter.getDistance(segment); long time = TrackSelectSegmentAdapter.getSegmentTime(segment); if (time != 1) { timeView.setText(OsmAndFormatter.getFormattedDurationShort((int) (time / 1000))); } else { + timeIcon.setVisibility(View.GONE); timeView.setText(""); } distanceView.setText(OsmAndFormatter.getFormattedDistance((float) distance, app)); - pointsView.setText(String.valueOf(point)); } ImageButton editButton = view.findViewById(R.id.show_on_map); diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index e0a7290b33..fb72c0a9c8 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -1090,10 +1090,10 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card @Override public void onSegmentSelect(GPXFile gpxFile, int selectedSegment) { + app.getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment); MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { startNavigationForGPX(gpxFile, mapActivity.getMapActions()); - app.getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment); RouteProvider.GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute(); if (paramsBuilder != null) { paramsBuilder.setSelectedSegment(selectedSegment); diff --git a/OsmAnd/src/net/osmand/plus/track/TrackSelectSegmentBottomSheet.java b/OsmAnd/src/net/osmand/plus/track/TrackSelectSegmentBottomSheet.java index b49c2eb898..cc60c4f057 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackSelectSegmentBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackSelectSegmentBottomSheet.java @@ -81,6 +81,7 @@ public class TrackSelectSegmentBottomSheet extends MenuBottomSheetDialogFragment TextView distance = gpxTrackContainer.findViewById(R.id.distance); TextView pointsCount = gpxTrackContainer.findViewById(R.id.points_count); TextView time = gpxTrackContainer.findViewById(R.id.time); + ImageView timeIcon = gpxTrackContainer.findViewById(R.id.time_icon); LinearLayout container = gpxTrackContainer.findViewById(R.id.container); LinearLayout containerNameAndReadSection = gpxTrackContainer.findViewById(R.id.name_and_read_section_container); container.setPadding(sidePadding, 0, 0, 0); @@ -93,7 +94,13 @@ public class TrackSelectSegmentBottomSheet extends MenuBottomSheetDialogFragment pointsCount.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); pointsCount.setText(String.valueOf(analysis.wptPoints)); time.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); - time.setText(analysis.isTimeSpecified() ? Algorithms.formatDuration((int) (analysis.timeSpan / 1000), app.accessibilityEnabled()) : ""); + if (analysis.isTimeSpecified()) { + time.setText(Algorithms.formatDuration((int) (analysis.timeSpan / 1000), + app.accessibilityEnabled())); + } else { + time.setText(""); + timeIcon.setVisibility(View.GONE); + } RecyclerView recyclerView = itemView.findViewById(R.id.gpx_segment_list); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); From 7d8886f757ed7e288974bbef62101c0129a628b4 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Wed, 17 Feb 2021 23:00:23 +0200 Subject: [PATCH 2/5] Fix of possible bugs --- .../osmand/plus/helpers/TrackSelectSegmentAdapter.java | 8 +++++--- .../plus/routepreparationmenu/FollowTrackFragment.java | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/helpers/TrackSelectSegmentAdapter.java b/OsmAnd/src/net/osmand/plus/helpers/TrackSelectSegmentAdapter.java index e9b1a67ce3..802e6d1441 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/TrackSelectSegmentAdapter.java +++ b/OsmAnd/src/net/osmand/plus/helpers/TrackSelectSegmentAdapter.java @@ -28,7 +28,6 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter segments; private OnItemClickListener onItemClickListener; - private ImageView timeIcon; public TrackSelectSegmentAdapter(Context ctx, List segments) { app = (OsmandApplication) ctx.getApplicationContext(); @@ -43,7 +42,7 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter Date: Thu, 18 Feb 2021 13:37:09 +0200 Subject: [PATCH 3/5] updateVisibility refactor --- .../cards/TrackEditCard.java | 20 +++++++++---------- .../track/TrackSelectSegmentBottomSheet.java | 9 +++++---- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java index cc10e542ba..646e2da386 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java @@ -1,7 +1,6 @@ package net.osmand.plus.routepreparationmenu.cards; import android.graphics.drawable.ColorDrawable; -import android.opengl.Visibility; import android.view.View; import android.widget.ImageButton; import android.widget.ImageView; @@ -17,6 +16,7 @@ import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; import net.osmand.plus.helpers.TrackSelectSegmentAdapter; @@ -24,7 +24,6 @@ import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; import net.osmand.util.Algorithms; import java.io.File; -import java.util.ArrayList; import java.util.List; public class TrackEditCard extends BaseCard { @@ -87,20 +86,19 @@ public class TrackEditCard extends BaseCard { TextView distanceView = view.findViewById(R.id.distance); TextView timeView = view.findViewById(R.id.time); ImageView timeIcon = view.findViewById(R.id.time_icon); - TextView pointsView = view.findViewById(R.id.points_count); - ImageView pointsIcon = view.findViewById(R.id.points_icon); - pointsView.setVisibility(View.GONE); - pointsIcon.setVisibility(View.GONE); + AndroidUiHelper.updateVisibility(view.findViewById(R.id.points_icon), false); + AndroidUiHelper.updateVisibility(view.findViewById(R.id.points_count), false); List segments = gpxFile.getNonEmptyTrkSegments(false); GPXUtilities.TrkSegment segment = segments.get(routeParams.getSelectedSegment()); double distance = TrackSelectSegmentAdapter.getDistance(segment); long time = TrackSelectSegmentAdapter.getSegmentTime(segment); - if (time != 1) { - timeView.setText(OsmAndFormatter.getFormattedDurationShort((int) (time / 1000))); - } else { - timeIcon.setVisibility(View.GONE); - timeView.setText(""); + boolean timeAvailable = time != 1; + if (timeAvailable) { + timeView.setText(Algorithms.formatDuration((int) (time / 1000), + app.accessibilityEnabled())); } + AndroidUiHelper.updateVisibility(timeView, timeAvailable); + AndroidUiHelper.updateVisibility(timeIcon, timeAvailable); distanceView.setText(OsmAndFormatter.getFormattedDistance((float) distance, app)); } diff --git a/OsmAnd/src/net/osmand/plus/track/TrackSelectSegmentBottomSheet.java b/OsmAnd/src/net/osmand/plus/track/TrackSelectSegmentBottomSheet.java index cc60c4f057..28bde3ffed 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackSelectSegmentBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackSelectSegmentBottomSheet.java @@ -30,6 +30,7 @@ import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; +import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.FontCache; import net.osmand.plus.helpers.TrackSelectSegmentAdapter; import net.osmand.plus.helpers.TrackSelectSegmentAdapter.OnItemClickListener; @@ -94,13 +95,13 @@ public class TrackSelectSegmentBottomSheet extends MenuBottomSheetDialogFragment pointsCount.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); pointsCount.setText(String.valueOf(analysis.wptPoints)); time.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); - if (analysis.isTimeSpecified()) { + boolean timeAvailable = analysis.timeSpan != 1; + if (timeAvailable) { time.setText(Algorithms.formatDuration((int) (analysis.timeSpan / 1000), app.accessibilityEnabled())); - } else { - time.setText(""); - timeIcon.setVisibility(View.GONE); } + AndroidUiHelper.updateVisibility(time, timeAvailable); + AndroidUiHelper.updateVisibility(timeIcon, timeAvailable); RecyclerView recyclerView = itemView.findViewById(R.id.gpx_segment_list); recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); From d40214cec7648d4e1d5ee34ba59769c3c461b6e6 Mon Sep 17 00:00:00 2001 From: androiddevkotlin <64539346+androiddevkotlin@users.noreply.github.com> Date: Thu, 18 Feb 2021 13:43:25 +0200 Subject: [PATCH 4/5] Fix conflicts --- .../osmand/plus/routepreparationmenu/FollowTrackFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index 067c09025e..93b26b82a4 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -719,11 +719,11 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca @Override public void onSegmentSelect(GPXFile gpxFile, int selectedSegment) { + app.getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment); selectTrackToFollow(gpxFile); GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute(); if (paramsBuilder != null) { paramsBuilder.setSelectedSegment(selectedSegment); - app.getSettings().GPX_ROUTE_SEGMENT.set(selectedSegment); app.getRoutingHelper().onSettingsChanged(true); } updateSelectionMode(false); From 8a84bdc81acd9df8d7313d6196350d8ea9aee34e Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Thu, 18 Feb 2021 13:49:40 +0200 Subject: [PATCH 5/5] Small fix --- .../osmand/plus/track/TrackSelectSegmentBottomSheet.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/track/TrackSelectSegmentBottomSheet.java b/OsmAnd/src/net/osmand/plus/track/TrackSelectSegmentBottomSheet.java index 28bde3ffed..6ea60cbed2 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackSelectSegmentBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackSelectSegmentBottomSheet.java @@ -95,13 +95,13 @@ public class TrackSelectSegmentBottomSheet extends MenuBottomSheetDialogFragment pointsCount.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); pointsCount.setText(String.valueOf(analysis.wptPoints)); time.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14); - boolean timeAvailable = analysis.timeSpan != 1; - if (timeAvailable) { + boolean timeSpecified = analysis.isTimeSpecified(); + if (timeSpecified) { time.setText(Algorithms.formatDuration((int) (analysis.timeSpan / 1000), app.accessibilityEnabled())); } - AndroidUiHelper.updateVisibility(time, timeAvailable); - AndroidUiHelper.updateVisibility(timeIcon, timeAvailable); + AndroidUiHelper.updateVisibility(time, timeSpecified); + AndroidUiHelper.updateVisibility(timeIcon, timeSpecified); RecyclerView recyclerView = itemView.findViewById(R.id.gpx_segment_list); recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));