Merge pull request #10925 from osmandapp/multisegment-gpx

Review
This commit is contained in:
Vitaliy 2021-02-18 13:50:28 +02:00 committed by GitHub
commit 1dd956ba38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 13 deletions

View file

@ -49,7 +49,7 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter<TrackViewHol
@Override
public void onBindViewHolder(@NonNull final TrackViewHolder holder, int position) {
holder.icon.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_split_interval));
holder.iconSegment.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_split_interval));
TrkSegment segment = segments.get(position);
@ -59,8 +59,10 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter<TrackViewHol
double distance = getDistance(segment);
long time = getSegmentTime(segment);
if (time != 1) {
holder.timeIcon.setVisibility(View.VISIBLE);
holder.time.setText(OsmAndFormatter.getFormattedDurationShort((int) (time / 1000)));
} else {
holder.timeIcon.setVisibility(View.GONE);
holder.time.setText("");
}
holder.distance.setText(OsmAndFormatter.getFormattedDistance((float) distance, app));
@ -118,14 +120,16 @@ public class TrackSelectSegmentAdapter extends RecyclerView.Adapter<TrackViewHol
static class TrackViewHolder extends RecyclerView.ViewHolder {
ImageView icon;
ImageView iconSegment;
ImageView timeIcon;
TextView name;
TextView distance;
TextView time;
TrackViewHolder(View itemView) {
super(itemView);
icon = itemView.findViewById(R.id.icon);
iconSegment = itemView.findViewById(R.id.icon);
timeIcon = itemView.findViewById(R.id.time_icon);
name = itemView.findViewById(R.id.name);
distance = itemView.findViewById(R.id.distance);
time = itemView.findViewById(R.id.time_interval);

View file

@ -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);

View file

@ -3,6 +3,7 @@ package net.osmand.plus.routepreparationmenu.cards;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -15,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;
@ -83,19 +85,21 @@ public class TrackEditCard extends BaseCard {
if (gpxFile.getNonEmptySegmentsCount() > 1 && routeParams != null && routeParams.getSelectedSegment() != -1) {
TextView distanceView = view.findViewById(R.id.distance);
TextView timeView = view.findViewById(R.id.time);
TextView pointsView = view.findViewById(R.id.points_count);
ImageView timeIcon = view.findViewById(R.id.time_icon);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.points_icon), false);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.points_count), false);
List<GPXUtilities.TrkSegment> 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 {
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));
pointsView.setText(String.valueOf(point));
}
ImageButton editButton = view.findViewById(R.id.show_on_map);

View file

@ -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);

View file

@ -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;
@ -81,6 +82,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 +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);
time.setText(analysis.isTimeSpecified() ? Algorithms.formatDuration((int) (analysis.timeSpan / 1000), app.accessibilityEnabled()) : "");
boolean timeSpecified = analysis.isTimeSpecified();
if (timeSpecified) {
time.setText(Algorithms.formatDuration((int) (analysis.timeSpan / 1000),
app.accessibilityEnabled()));
}
AndroidUiHelper.updateVisibility(time, timeSpecified);
AndroidUiHelper.updateVisibility(timeIcon, timeSpecified);
RecyclerView recyclerView = itemView.findViewById(R.id.gpx_segment_list);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));