some fixes
This commit is contained in:
parent
7048f8c52d
commit
07280935c0
5 changed files with 70 additions and 81 deletions
|
@ -329,7 +329,7 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
graphsAdapter = new GPXItemPagerAdapter(app, nightMode, this, true, true);
|
graphsAdapter = new GPXItemPagerAdapter(app, null, null, nightMode, this, true);
|
||||||
graphsAdapter.setChartHMargin(getResources().getDimensionPixelSize(R.dimen.content_padding));
|
graphsAdapter.setChartHMargin(getResources().getDimensionPixelSize(R.dimen.content_padding));
|
||||||
|
|
||||||
pager.setAdapter(graphsAdapter);
|
pager.setAdapter(graphsAdapter);
|
||||||
|
@ -607,23 +607,11 @@ public class TripRecordingBottomSheet extends MenuBottomSheetDialogFragment impl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TrackDisplayHelper getDisplayHelper() {
|
|
||||||
TrackDisplayHelper displayHelper = new TrackDisplayHelper(app);
|
|
||||||
GPXFile gpxFile = getGPXFile();
|
|
||||||
if (!selectedGpxFile.isShowCurrentTrack()) {
|
|
||||||
File file = new File(gpxFile.path);
|
|
||||||
displayHelper.setFile(file);
|
|
||||||
displayHelper.setGpxDataItem(app.getGpxDbHelper().getItem(file));
|
|
||||||
}
|
|
||||||
displayHelper.setGpx(gpxFile);
|
|
||||||
return displayHelper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPointSelected(TrkSegment segment, double lat, double lon) {
|
public void onPointSelected(TrkSegment segment, double lat, double lon) {
|
||||||
if (trackChartPoints == null) {
|
if (trackChartPoints == null) {
|
||||||
trackChartPoints = new TrackChartPoints();
|
trackChartPoints = new TrackChartPoints();
|
||||||
trackChartPoints.setGpx(getDisplayHelper().getGpx());
|
trackChartPoints.setGpx(getGPXFile());
|
||||||
}
|
}
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
|
|
|
@ -112,10 +112,15 @@ public class TripRecordingClearDataBottomSheet extends MenuBottomSheetDialogFrag
|
||||||
@Override
|
@Override
|
||||||
public void dismissTarget() {
|
public void dismissTarget() {
|
||||||
Fragment target = getTargetFragment();
|
Fragment target = getTargetFragment();
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putBoolean(ACTION_CLEAR_DATA, true);
|
|
||||||
target.setArguments(args);
|
|
||||||
if (target instanceof TripRecordingOptionsBottomSheet) {
|
if (target instanceof TripRecordingOptionsBottomSheet) {
|
||||||
|
Bundle args = target.getArguments();
|
||||||
|
if (args != null) {
|
||||||
|
args.putBoolean(ACTION_CLEAR_DATA, true);
|
||||||
|
} else {
|
||||||
|
args = new Bundle();
|
||||||
|
args.putBoolean(ACTION_CLEAR_DATA, true);
|
||||||
|
target.setArguments(args);
|
||||||
|
}
|
||||||
((TripRecordingOptionsBottomSheet) target).dismiss();
|
((TripRecordingOptionsBottomSheet) target).dismiss();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,10 +68,15 @@ public class TripRecordingDiscardBottomSheet extends MenuBottomSheetDialogFragme
|
||||||
dismiss();
|
dismiss();
|
||||||
|
|
||||||
Fragment target = getTargetFragment();
|
Fragment target = getTargetFragment();
|
||||||
if (target != null) {
|
if (target instanceof TripRecordingOptionsBottomSheet) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = target.getArguments();
|
||||||
args.putBoolean(ACTION_STOP_AND_DISMISS, true);
|
if (args != null) {
|
||||||
target.setArguments(args);
|
args.putBoolean(ACTION_STOP_AND_DISMISS, true);
|
||||||
|
} else {
|
||||||
|
args = new Bundle();
|
||||||
|
args.putBoolean(ACTION_STOP_AND_DISMISS, true);
|
||||||
|
target.setArguments(args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dismissTarget();
|
dismissTarget();
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,9 +259,14 @@ public class TripRecordingOptionsBottomSheet extends MenuBottomSheetDialogFragme
|
||||||
if (mapActivity != null && plugin != null) {
|
if (mapActivity != null && plugin != null) {
|
||||||
stopUpdatingTimeTrackSaved();
|
stopUpdatingTimeTrackSaved();
|
||||||
plugin.saveCurrentTrack(null, mapActivity, false, true);
|
plugin.saveCurrentTrack(null, mapActivity, false, true);
|
||||||
Bundle args = new Bundle();
|
Bundle args = getArguments();
|
||||||
args.putBoolean(ACTION_STOP_AND_DISMISS, true);
|
if (args != null) {
|
||||||
setArguments(args);
|
args.putBoolean(ACTION_STOP_AND_DISMISS, true);
|
||||||
|
} else {
|
||||||
|
args = new Bundle();
|
||||||
|
args.putBoolean(ACTION_STOP_AND_DISMISS, true);
|
||||||
|
setArguments(args);
|
||||||
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
dismissTarget();
|
dismissTarget();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.widget.SwitchCompat;
|
import androidx.appcompat.widget.SwitchCompat;
|
||||||
import androidx.viewpager.widget.PagerAdapter;
|
import androidx.viewpager.widget.PagerAdapter;
|
||||||
|
|
||||||
|
@ -89,50 +90,19 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
private boolean chartClicked;
|
private boolean chartClicked;
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
private boolean onlyGraphs;
|
private boolean onlyGraphs;
|
||||||
private boolean recordingTrack = false;
|
|
||||||
private int chartHMargin = 0;
|
private int chartHMargin = 0;
|
||||||
|
|
||||||
public void setChartHMargin(int chartHMargin) {
|
public void setChartHMargin(int chartHMargin) {
|
||||||
this.chartHMargin = chartHMargin;
|
this.chartHMargin = chartHMargin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SelectedGpxFile getCurrentTrack() {
|
private boolean isShowCurrentTrack() {
|
||||||
return app.getSavingTrackHelper().getCurrentTrack();
|
return displayHelper.getGpx() != null && displayHelper.getGpx().showCurrentTrack;
|
||||||
}
|
|
||||||
|
|
||||||
private GPXFile getGpxFile() {
|
|
||||||
return recordingTrack ? getCurrentTrack().getGpxFile() : displayHelper.getGpx();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GPXItemPagerAdapter(@NonNull OsmandApplication app,
|
public GPXItemPagerAdapter(@NonNull OsmandApplication app,
|
||||||
boolean nightMode,
|
@Nullable GpxDisplayItem gpxItem,
|
||||||
@NonNull SegmentActionsListener actionsListener,
|
@Nullable TrackDisplayHelper displayHelper,
|
||||||
boolean onlyGraphs,
|
|
||||||
boolean recordingTrack) {
|
|
||||||
super();
|
|
||||||
this.app = app;
|
|
||||||
this.nightMode = nightMode;
|
|
||||||
this.actionsListener = actionsListener;
|
|
||||||
this.onlyGraphs = onlyGraphs;
|
|
||||||
this.recordingTrack = recordingTrack;
|
|
||||||
iconsCache = app.getUIUtilities();
|
|
||||||
|
|
||||||
displayHelper = new TrackDisplayHelper(app);
|
|
||||||
GPXFile gpxFile = getGpxFile();
|
|
||||||
if (!getCurrentTrack().isShowCurrentTrack()) {
|
|
||||||
File file = new File(gpxFile.path);
|
|
||||||
displayHelper.setFile(file);
|
|
||||||
displayHelper.setGpxDataItem(app.getGpxDbHelper().getItem(file));
|
|
||||||
}
|
|
||||||
displayHelper.setGpx(gpxFile);
|
|
||||||
|
|
||||||
updateAnalysis();
|
|
||||||
fetchTabTypes();
|
|
||||||
}
|
|
||||||
|
|
||||||
public GPXItemPagerAdapter(@NonNull OsmandApplication app,
|
|
||||||
@NonNull GpxDisplayItem gpxItem,
|
|
||||||
@NonNull TrackDisplayHelper displayHelper,
|
|
||||||
boolean nightMode,
|
boolean nightMode,
|
||||||
@NonNull SegmentActionsListener actionsListener,
|
@NonNull SegmentActionsListener actionsListener,
|
||||||
boolean onlyGraphs) {
|
boolean onlyGraphs) {
|
||||||
|
@ -140,22 +110,36 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.gpxItem = gpxItem;
|
this.gpxItem = gpxItem;
|
||||||
this.nightMode = nightMode;
|
this.nightMode = nightMode;
|
||||||
this.displayHelper = displayHelper;
|
|
||||||
this.actionsListener = actionsListener;
|
this.actionsListener = actionsListener;
|
||||||
this.onlyGraphs = onlyGraphs;
|
this.onlyGraphs = onlyGraphs;
|
||||||
iconsCache = app.getUIUtilities();
|
iconsCache = app.getUIUtilities();
|
||||||
|
|
||||||
|
if (displayHelper == null) {
|
||||||
|
this.displayHelper = new TrackDisplayHelper(app);
|
||||||
|
SelectedGpxFile currentTrack = app.getSavingTrackHelper().getCurrentTrack();
|
||||||
|
GPXFile gpxFile = currentTrack.getGpxFile();
|
||||||
|
if (currentTrack.isShowCurrentTrack()) {
|
||||||
|
File file = new File(gpxFile.path);
|
||||||
|
this.displayHelper.setFile(file);
|
||||||
|
this.displayHelper.setGpxDataItem(app.getGpxDbHelper().getItem(file));
|
||||||
|
}
|
||||||
|
this.displayHelper.setGpx(gpxFile);
|
||||||
|
} else {
|
||||||
|
this.displayHelper = displayHelper;
|
||||||
|
}
|
||||||
|
|
||||||
updateAnalysis();
|
updateAnalysis();
|
||||||
fetchTabTypes();
|
fetchTabTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAnalysis() {
|
private void updateAnalysis() {
|
||||||
analysis = null;
|
analysis = null;
|
||||||
if (recordingTrack) {
|
if (isShowCurrentTrack()) {
|
||||||
GPXFile currentGpx = getCurrentTrack().getGpxFile();
|
GPXFile gpxFile = displayHelper.getGpx();
|
||||||
if (!currentGpx.isEmpty()) {
|
if (gpxFile != null && !gpxFile.isEmpty()) {
|
||||||
analysis = currentGpx.getAnalysis(0);
|
analysis = gpxFile.getAnalysis(0);
|
||||||
|
gpxItem = GpxUiHelper.makeGpxDisplayItem(app, gpxFile);
|
||||||
}
|
}
|
||||||
gpxItem = GpxUiHelper.makeGpxDisplayItem(app, currentGpx);
|
|
||||||
} else {
|
} else {
|
||||||
if (gpxItem != null) {
|
if (gpxItem != null) {
|
||||||
analysis = gpxItem.analysis;
|
analysis = gpxItem.analysis;
|
||||||
|
@ -165,7 +149,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
|
|
||||||
private void fetchTabTypes() {
|
private void fetchTabTypes() {
|
||||||
List<GPXTabItemType> tabTypeList = new ArrayList<>();
|
List<GPXTabItemType> tabTypeList = new ArrayList<>();
|
||||||
if (recordingTrack) {
|
if (isShowCurrentTrack()) {
|
||||||
if (analysis != null && (analysis.hasElevationData || analysis.hasSpeedData)) {
|
if (analysis != null && (analysis.hasElevationData || analysis.hasSpeedData)) {
|
||||||
tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_GENERAL);
|
tabTypeList.add(GPXTabItemType.GPX_TAB_ITEM_GENERAL);
|
||||||
}
|
}
|
||||||
|
@ -187,17 +171,17 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
LineGraphType firstType, LineGraphType secondType) {
|
LineGraphType firstType, LineGraphType secondType) {
|
||||||
List<ILineDataSet> dataSets = dataSetsMap.get(tabType);
|
List<ILineDataSet> dataSets = dataSetsMap.get(tabType);
|
||||||
boolean withoutGaps = true;
|
boolean withoutGaps = true;
|
||||||
if (recordingTrack) {
|
if (isShowCurrentTrack()) {
|
||||||
GPXFile currentGpx = getGpxFile();
|
GPXFile gpxFile = displayHelper.getGpx();
|
||||||
withoutGaps = !getCurrentTrack().isJoinSegments()
|
withoutGaps = !app.getSavingTrackHelper().getCurrentTrack().isJoinSegments() && gpxFile != null
|
||||||
&& (Algorithms.isEmpty(currentGpx.tracks) || currentGpx.tracks.get(0).generalTrack);
|
&& (Algorithms.isEmpty(gpxFile.tracks) || gpxFile.tracks.get(0).generalTrack);
|
||||||
} else if (gpxItem != null) {
|
} else if (gpxItem != null) {
|
||||||
GpxDataItem gpxDataItem = displayHelper.getGpxDataItem();
|
GpxDataItem gpxDataItem = displayHelper.getGpxDataItem();
|
||||||
withoutGaps = gpxItem.isGeneralTrack() && gpxDataItem != null && !gpxDataItem.isJoinSegments();
|
withoutGaps = gpxItem.isGeneralTrack() && gpxDataItem != null && !gpxDataItem.isJoinSegments();
|
||||||
}
|
}
|
||||||
if (chart != null && analysis != null) {
|
if (chart != null && analysis != null) {
|
||||||
dataSets = GpxUiHelper.getDataSets(chart, app, analysis, firstType, secondType, withoutGaps);
|
dataSets = GpxUiHelper.getDataSets(chart, app, analysis, firstType, secondType, withoutGaps);
|
||||||
if (dataSets != null) {
|
if (!Algorithms.isEmpty(dataSets)) {
|
||||||
dataSetsMap.remove(tabType);
|
dataSetsMap.remove(tabType);
|
||||||
}
|
}
|
||||||
dataSetsMap.put(tabType, dataSets);
|
dataSetsMap.put(tabType, dataSets);
|
||||||
|
@ -212,7 +196,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
if (ds != null && ds.size() > 0) {
|
if (ds != null && ds.size() > 0) {
|
||||||
for (GPXUtilities.Track t : gpxItem.group.getGpx().tracks) {
|
for (GPXUtilities.Track t : gpxItem.group.getGpx().tracks) {
|
||||||
for (TrkSegment s : t.segments) {
|
for (TrkSegment s : t.segments) {
|
||||||
if (s.points.size() > 0 && s.points.get(0).equals(gpxItem.analysis.locationStart)) {
|
if (s.points.size() > 0 && s.points.get(0).equals(analysis.locationStart)) {
|
||||||
segment = s;
|
segment = s;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -236,7 +220,7 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
if (gpxItem.chartAxisType == GPXDataSetAxisType.TIME) {
|
if (gpxItem.chartAxisType == GPXDataSetAxisType.TIME) {
|
||||||
float time = pos * 1000;
|
float time = pos * 1000;
|
||||||
for (WptPt p : segment.points) {
|
for (WptPt p : segment.points) {
|
||||||
if (p.time - gpxItem.analysis.startTime >= time) {
|
if (p.time - analysis.startTime >= time) {
|
||||||
wpt = p;
|
wpt = p;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -739,20 +723,21 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
void updateJoinGapsInfo(View view, int position) {
|
void updateJoinGapsInfo(View view, int position) {
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
GPXTabItemType tabType = tabTypes[position];
|
GPXTabItemType tabType = tabTypes[position];
|
||||||
boolean visible = gpxItem.isGeneralTrack() && analysis != null && tabType.equals(GPXTabItemType.GPX_TAB_ITEM_GENERAL);
|
boolean generalTrack = gpxItem.isGeneralTrack();
|
||||||
AndroidUiHelper.updateVisibility(view.findViewById(R.id.gpx_join_gaps_container), visible);
|
|
||||||
boolean joinSegments = displayHelper.isJoinSegments();
|
boolean joinSegments = displayHelper.isJoinSegments();
|
||||||
|
boolean visible = generalTrack && analysis != null && tabType.equals(GPXTabItemType.GPX_TAB_ITEM_GENERAL);
|
||||||
|
AndroidUiHelper.updateVisibility(view.findViewById(R.id.gpx_join_gaps_container), visible);
|
||||||
((SwitchCompat) view.findViewById(R.id.gpx_join_gaps_switch)).setChecked(joinSegments);
|
((SwitchCompat) view.findViewById(R.id.gpx_join_gaps_switch)).setChecked(joinSegments);
|
||||||
if (analysis != null) {
|
if (analysis != null) {
|
||||||
if (tabType.equals(GPXTabItemType.GPX_TAB_ITEM_GENERAL)) {
|
if (tabType.equals(GPXTabItemType.GPX_TAB_ITEM_GENERAL)) {
|
||||||
float totalDistance = !joinSegments && gpxItem.isGeneralTrack() ? analysis.totalDistanceWithoutGaps : analysis.totalDistance;
|
float totalDistance = !joinSegments && generalTrack ? analysis.totalDistanceWithoutGaps : analysis.totalDistance;
|
||||||
float timeSpan = !joinSegments && gpxItem.isGeneralTrack() ? analysis.timeSpanWithoutGaps : analysis.timeSpan;
|
float timeSpan = !joinSegments && generalTrack ? analysis.timeSpanWithoutGaps : analysis.timeSpan;
|
||||||
|
|
||||||
((TextView) view.findViewById(R.id.distance_text)).setText(OsmAndFormatter.getFormattedDistance(totalDistance, app));
|
((TextView) view.findViewById(R.id.distance_text)).setText(OsmAndFormatter.getFormattedDistance(totalDistance, app));
|
||||||
((TextView) view.findViewById(R.id.duration_text)).setText(Algorithms.formatDuration((int) (timeSpan / 1000), app.accessibilityEnabled()));
|
((TextView) view.findViewById(R.id.duration_text)).setText(Algorithms.formatDuration((int) (timeSpan / 1000), app.accessibilityEnabled()));
|
||||||
} else if (tabType.equals(GPX_TAB_ITEM_SPEED)) {
|
} else if (tabType.equals(GPX_TAB_ITEM_SPEED)) {
|
||||||
long timeMoving = !joinSegments && gpxItem.isGeneralTrack() ? analysis.timeMovingWithoutGaps : analysis.timeMoving;
|
long timeMoving = !joinSegments && generalTrack ? analysis.timeMovingWithoutGaps : analysis.timeMoving;
|
||||||
float totalDistanceMoving = !joinSegments && gpxItem.isGeneralTrack() ? analysis.totalDistanceMovingWithoutGaps : analysis.totalDistanceMoving;
|
float totalDistanceMoving = !joinSegments && generalTrack ? analysis.totalDistanceMovingWithoutGaps : analysis.totalDistanceMoving;
|
||||||
|
|
||||||
((TextView) view.findViewById(R.id.time_moving_text)).setText(Algorithms.formatDuration((int) (timeMoving / 1000), app.accessibilityEnabled()));
|
((TextView) view.findViewById(R.id.time_moving_text)).setText(Algorithms.formatDuration((int) (timeMoving / 1000), app.accessibilityEnabled()));
|
||||||
((TextView) view.findViewById(R.id.distance_text)).setText(OsmAndFormatter.getFormattedDistance(totalDistanceMoving, app));
|
((TextView) view.findViewById(R.id.distance_text)).setText(OsmAndFormatter.getFormattedDistance(totalDistanceMoving, app));
|
||||||
|
@ -777,10 +762,11 @@ public class GPXItemPagerAdapter extends PagerAdapter implements CustomTabProvid
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTabsVisible() {
|
public boolean isTabsVisible() {
|
||||||
if (getCount() > 0 && views.size() > 0) {
|
GPXFile gpxFile = displayHelper.getGpx();
|
||||||
|
if (gpxFile != null && getCount() > 0 && views.size() > 0) {
|
||||||
for (int i = 0; i < getCount(); i++) {
|
for (int i = 0; i < getCount(); i++) {
|
||||||
LineChart lc = getViewAtPosition(i).findViewById(R.id.chart);
|
LineChart lc = getViewAtPosition(i).findViewById(R.id.chart);
|
||||||
if (!lc.isEmpty() && !getGpxFile().isEmpty()) {
|
if (!lc.isEmpty() && !gpxFile.isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue