diff --git a/OsmAnd/res/values-large/sizes.xml b/OsmAnd/res/values-large/sizes.xml
index 30eddb8516..b1a4c09402 100644
--- a/OsmAnd/res/values-large/sizes.xml
+++ b/OsmAnd/res/values-large/sizes.xml
@@ -75,8 +75,8 @@
14sp
27sp
- 14sp
- 14sp
- 11sp
+ 15sp
+ 15sp
+ 12sp
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java
index c3539cd40f..de16d07f8d 100644
--- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java
+++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java
@@ -13,7 +13,7 @@ import java.util.List;
public class GPXDatabase {
private static final String DB_NAME = "gpx_database";
- private static final int DB_VERSION = 3;
+ private static final int DB_VERSION = 4;
private static final String GPX_TABLE_NAME = "gpxTable";
private static final String GPX_COL_NAME = "fileName";
private static final String GPX_COL_DIR = "fileDir";
@@ -40,6 +40,13 @@ public class GPXDatabase {
private static final String GPX_COL_COLOR = "color";
private static final String GPX_COL_FILE_LAST_MODIFIED_TIME = "fileLastModifiedTime";
+ private static final String GPX_COL_SPLIT_TYPE = "splitType";
+ private static final String GPX_COL_SPLIT_INTERVAL = "splitInterval";
+
+ public static final int GPX_SPLIT_TYPE_NO_SPLIT = -1;
+ public static final int GPX_SPLIT_TYPE_DISTANCE = 1;
+ public static final int GPX_SPLIT_TYPE_TIME = 2;
+
private static final String GPX_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " + GPX_TABLE_NAME + " (" +
GPX_COL_NAME + " TEXT, " +
GPX_COL_DIR + " TEXT, " +
@@ -63,7 +70,9 @@ public class GPXDatabase {
GPX_COL_POINTS + " int, " +
GPX_COL_WPT_POINTS + " int, " +
GPX_COL_COLOR + " TEXT, " +
- GPX_COL_FILE_LAST_MODIFIED_TIME + " long);";
+ GPX_COL_FILE_LAST_MODIFIED_TIME + " long, " +
+ GPX_COL_SPLIT_TYPE + " int, " +
+ GPX_COL_SPLIT_INTERVAL + " double);";
private static final String GPX_TABLE_SELECT = "SELECT " +
GPX_COL_NAME + ", " +
@@ -85,7 +94,9 @@ public class GPXDatabase {
GPX_COL_POINTS + ", " +
GPX_COL_WPT_POINTS + ", " +
GPX_COL_COLOR + ", " +
- GPX_COL_FILE_LAST_MODIFIED_TIME +
+ GPX_COL_FILE_LAST_MODIFIED_TIME + ", " +
+ GPX_COL_SPLIT_TYPE + ", " +
+ GPX_COL_SPLIT_INTERVAL +
" FROM " + GPX_TABLE_NAME;
private OsmandApplication context;
@@ -95,6 +106,8 @@ public class GPXDatabase {
private GPXTrackAnalysis analysis;
private int color;
private long fileLastModifiedTime;
+ private int splitType;
+ private double splitInterval;
public GpxDataItem(File file, GPXTrackAnalysis analysis) {
this.file = file;
@@ -121,6 +134,14 @@ public class GPXDatabase {
public long getFileLastModifiedTime() {
return fileLastModifiedTime;
}
+
+ public int getSplitType() {
+ return splitType;
+ }
+
+ public double getSplitInterval() {
+ return splitInterval;
+ }
}
public GPXDatabase(OsmandApplication app) {
@@ -161,6 +182,10 @@ public class GPXDatabase {
updateLastModifiedTime(item);
}
}
+ if (oldVersion < 4) {
+ db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SPLIT_TYPE + " int");
+ db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SPLIT_INTERVAL + " double");
+ }
}
private boolean updateLastModifiedTime(GpxDataItem item) {
@@ -223,6 +248,27 @@ public class GPXDatabase {
return false;
}
+ public boolean updateSplit(GpxDataItem item, int splitType, double splitInterval) {
+ SQLiteConnection db = openConnection(false);
+ if (db != null){
+ try {
+ String fileName = getFileName(item.file);
+ String fileDir = getFileDir(item.file);
+ db.execSQL("UPDATE " + GPX_TABLE_NAME + " SET " +
+ GPX_COL_SPLIT_TYPE + " = ?, " +
+ GPX_COL_SPLIT_INTERVAL + " = ? " +
+ " WHERE " + GPX_COL_NAME + " = ? AND " + GPX_COL_DIR + " = ?",
+ new Object[] { splitType, splitInterval, fileName, fileDir });
+ item.splitType = splitType;
+ item.splitInterval = splitInterval;
+ } finally {
+ db.close();
+ }
+ return true;
+ }
+ return false;
+ }
+
public boolean remove(File file) {
SQLiteConnection db = openConnection(false);
if (db != null){
@@ -278,16 +324,16 @@ public class GPXDatabase {
}
if (a != null) {
db.execSQL(
- "INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ "INSERT INTO " + GPX_TABLE_NAME + " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
new Object[]{ fileName, fileDir, a.totalDistance, a.totalTracks, a.startTime, a.endTime,
a.timeSpan, a.timeMoving, a.totalDistanceMoving, a.diffElevationUp, a.diffElevationDown,
a.avgElevation, a.minElevation, a.maxElevation, a.maxSpeed, a.avgSpeed, a.points, a.wptPoints,
- color, item.file.lastModified() });
+ color, item.file.lastModified(), item.splitType, item.splitInterval });
} else {
db.execSQL(
"INSERT INTO " + GPX_TABLE_NAME + "(" + GPX_COL_NAME + ", " + GPX_COL_DIR + ", " +
- GPX_COL_COLOR + ", " + GPX_COL_FILE_LAST_MODIFIED_TIME + ") VALUES (?, ?, ?, ?)",
- new Object[]{ fileName, fileDir, color, 0 });
+ GPX_COL_COLOR + ", " + GPX_COL_FILE_LAST_MODIFIED_TIME + ", " + GPX_COL_SPLIT_TYPE + ", " + GPX_COL_SPLIT_INTERVAL + ") VALUES (?, ?, ?, ?, ?, ?)",
+ new Object[]{ fileName, fileDir, color, 0, item.splitType, item.splitInterval });
}
}
@@ -350,6 +396,8 @@ public class GPXDatabase {
int wptPoints = (int)query.getInt(17);
String color = query.getString(18);
long fileLastModifiedTime = query.getLong(19);
+ int splitType = (int)query.getInt(20);
+ double splitInterval = query.getDouble(21);
GPXTrackAnalysis a = new GPXTrackAnalysis();
a.totalDistance = totalDistance;
@@ -383,6 +431,8 @@ public class GPXDatabase {
item.color = 0;
}
item.fileLastModifiedTime = fileLastModifiedTime;
+ item.splitType = splitType;
+ item.splitInterval = splitInterval;
return item;
}
diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
index 0054d1bcaf..5fcb91e40d 100644
--- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
+++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
@@ -12,6 +12,7 @@ import net.osmand.plus.GPXUtilities.Route;
import net.osmand.plus.GPXUtilities.Track;
import net.osmand.plus.GPXUtilities.TrkSegment;
import net.osmand.plus.GPXUtilities.WptPt;
+import net.osmand.plus.GPXDatabase.GpxDataItem;
import net.osmand.plus.OsmandSettings.MetricsConstants;
import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.helpers.GpxUiHelper;
@@ -82,6 +83,35 @@ public class GpxSelectionHelper {
return null;
}
+ public void processSplit() {
+ List items = app.getGpxDatabase().getItems();
+ for (GpxDataItem dataItem : items) {
+ if (dataItem.getSplitType() != 0) {
+ SelectedGpxFile selectedGpxFile = getSelectedFileByPath(dataItem.getFile().getAbsolutePath());
+ if (selectedGpxFile != null && selectedGpxFile.getGpxFile() != null) {
+ GPXFile gpxFile = selectedGpxFile.getGpxFile();
+ List groups = app.getSelectedGpxHelper().collectDisplayGroups(gpxFile);
+ if (dataItem.getSplitType() == GPXDatabase.GPX_SPLIT_TYPE_NO_SPLIT) {
+ for (GpxDisplayGroup model : groups) {
+ model.noSplit(app);
+ }
+ selectedGpxFile.setDisplayGroups(groups);
+ } else if (dataItem.getSplitType() == GPXDatabase.GPX_SPLIT_TYPE_DISTANCE) {
+ for (GpxDisplayGroup model : groups) {
+ model.splitByDistance(app, dataItem.getSplitInterval());
+ }
+ selectedGpxFile.setDisplayGroups(groups);
+ } else if (dataItem.getSplitType() == GPXDatabase.GPX_SPLIT_TYPE_TIME) {
+ for (GpxDisplayGroup model : groups) {
+ model.splitByTime(app, (int) dataItem.getSplitInterval());
+ }
+ selectedGpxFile.setDisplayGroups(groups);
+ }
+ }
+ }
+ }
+ }
+
private String getString(int resId, Object... formatArgs) {
return app.getString(resId, formatArgs);
}
@@ -391,6 +421,7 @@ public class GpxSelectionHelper {
selectedGPXFiles.add(savingTrackHelper.getCurrentTrack());
}
}
+ processSplit();
if (save) {
saveCurrentSelections();
}
diff --git a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java
index 125f9d29f1..231e4ef379 100644
--- a/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java
+++ b/OsmAnd/src/net/osmand/plus/myplaces/SplitSegmentFragment.java
@@ -1,11 +1,14 @@
package net.osmand.plus.myplaces;
import android.content.res.ColorStateList;
+import android.graphics.Paint;
+import android.graphics.Rect;
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.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -32,6 +35,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.TrackActivity;
import net.osmand.plus.base.OsmAndListFragment;
+import net.osmand.plus.helpers.FontCache;
import net.osmand.util.Algorithms;
import java.text.DateFormat;
@@ -59,6 +63,9 @@ public class SplitSegmentFragment extends OsmAndListFragment {
private TIntArrayList timeSplit = new TIntArrayList();
private int selectedSplitInterval;
private IconsCache ic;
+ private int minMaxSpeedLayoutWidth;
+ private Paint minMaxSpeedPaint;
+ private Rect minMaxSpeedTextBounds;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
@@ -67,6 +74,13 @@ public class SplitSegmentFragment extends OsmAndListFragment {
ic = app.getIconsCache();
}
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ updateContent();
+ updateHeader();
+ }
+
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
@@ -90,6 +104,13 @@ public class SplitSegmentFragment extends OsmAndListFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setHasOptionsMenu(true);
+
+ minMaxSpeedPaint = new Paint();
+ minMaxSpeedPaint.setTextSize(getResources().getDimension(R.dimen.default_split_segments_data));
+ minMaxSpeedPaint.setTypeface(FontCache.getFont(getContext(), "fonts/Roboto-Medium.ttf"));
+ minMaxSpeedPaint.setStyle(Paint.Style.FILL);
+ minMaxSpeedTextBounds = new Rect();
+
final View view = getActivity().getLayoutInflater().inflate(R.layout.split_segments_layout, container, false);
final ListView listView = (ListView) view.findViewById(android.R.id.list);
@@ -102,8 +123,6 @@ public class SplitSegmentFragment extends OsmAndListFragment {
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));
- updateContent();
- updateHeader();
setListAdapter(adapter);
@@ -119,7 +138,7 @@ public class SplitSegmentFragment extends OsmAndListFragment {
@Override
public void onScroll(AbsListView absListView, int i, int i1, int i2) {
- View c = absListView.getChildAt(1);
+ View c = absListView.getChildAt(0);
if (c != null) {
int currentYPos = -c.getTop() + absListView.getFirstVisiblePosition() * c.getHeight();
if (previousYPos == -1) {
@@ -194,8 +213,9 @@ public class SplitSegmentFragment extends OsmAndListFragment {
adapter.add(overviewSegments);
List splitSegments = getSplitSegments();
adapter.addAll(splitSegments);
- adapter.setNotifyOnChange(true);
adapter.notifyDataSetChanged();
+ getListView().setSelection(0);
+ headerView.setTranslationY(0);
updateHeader();
}
@@ -395,7 +415,9 @@ public class SplitSegmentFragment extends OsmAndListFragment {
}
overviewTextView.setTextColor(defaultTextColor);
overviewTextView.setText(app.getString(R.string.shared_string_overview));
- ((TextView) convertView.findViewById(R.id.fragment_count_text)).setText("");
+ if (currentGpxDisplayItem != null) {
+ ((TextView) convertView.findViewById(R.id.fragment_count_text)).setText(app.getString(R.string.shared_string_time_span) + ": " + Algorithms.formatDuration((int) (currentGpxDisplayItem.analysis.timeSpan / 1000), app.accessibilityEnabled()));
+ }
} else {
if (currentGpxDisplayItem != null && currentGpxDisplayItem.analysis != null) {
overviewTextView.setTextColor(app.getSettings().isLightContent() ? app.getResources().getColor(R.color.gpx_split_overview_light) : app.getResources().getColor(R.color.gpx_split_overview_dark));
@@ -555,7 +577,21 @@ 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);
+ String maxMinSpeed = maxSpeed.substring(0, maxSpeed.indexOf(" ")).concat("/").concat(minSpeed);
+
+ if (minMaxSpeedLayoutWidth == 0) {
+ DisplayMetrics metrics = new DisplayMetrics();
+ getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
+ int screenWidth = metrics.widthPixels;
+ int widthWithoutSidePadding = screenWidth - AndroidUtils.dpToPx(getActivity(), 32);
+ int singleLayoutWidth = widthWithoutSidePadding / 3;
+ int twoLayouts = 2 * (singleLayoutWidth + AndroidUtils.dpToPx(getActivity(), 3));
+ minMaxSpeedLayoutWidth = widthWithoutSidePadding - twoLayouts - AndroidUtils.dpToPx(getActivity(), 28);
+ }
+
+ minMaxSpeedPaint.getTextBounds(maxMinSpeed, 0, maxMinSpeed.length(), minMaxSpeedTextBounds);
+ int minMaxStringWidth = minMaxSpeedTextBounds.width();
+
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);
@@ -567,7 +603,7 @@ public class SplitSegmentFragment extends OsmAndListFragment {
.setVisibility(View.GONE);
((TextView) convertView.findViewById(R.id.max_min_speed_text))
.setText(app.getString(R.string.shared_string_max));
- } else if (max_min_speed.length() > 9) {
+ } else if (minMaxStringWidth > minMaxSpeedLayoutWidth) {
(convertView.findViewById(R.id.max_speed_value))
.setVisibility(View.VISIBLE);
(convertView.findViewById(R.id.min_speed_value))
@@ -584,7 +620,7 @@ public class SplitSegmentFragment extends OsmAndListFragment {
(convertView.findViewById(R.id.max_min_speed_value))
.setVisibility(View.VISIBLE);
((TextView) convertView.findViewById(R.id.max_min_speed_value))
- .setText(max_min_speed);
+ .setText(maxMinSpeed);
(convertView.findViewById(R.id.max_speed_value))
.setVisibility(View.GONE);
(convertView.findViewById(R.id.min_speed_value))
diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java
index a534ebf573..6efec111b1 100644
--- a/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java
+++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackSegmentFragment.java
@@ -57,6 +57,7 @@ import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect;
import net.osmand.data.RotatedTileBox;
import net.osmand.data.RotatedTileBox.RotatedTileBoxBuilder;
+import net.osmand.plus.GPXDatabase;
import net.osmand.plus.GPXDatabase.GpxDataItem;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GPXUtilities.GPXFile;
@@ -297,7 +298,7 @@ public class TrackSegmentFragment extends OsmAndListFragment {
final View colorView = headerView.findViewById(R.id.color_view);
final SwitchCompat vis = (SwitchCompat) headerView.findViewById(R.id.showOnMapToggle);
final ProgressBar progressBar = (ProgressBar) headerView.findViewById(R.id.mapLoadProgress);
- boolean selected = getGpx() != null &&
+ final boolean selected = getGpx() != null &&
((getGpx().showCurrentTrack && app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null) ||
(getGpx().path != null && app.getSelectedGpxHelper().getSelectedFileByPath(getGpx().path) != null));
vis.setChecked(selected);
@@ -311,6 +312,9 @@ public class TrackSegmentFragment extends OsmAndListFragment {
final List groups = getDisplayGroups();
if (groups.size() > 0) {
updateSplit(groups, vis.isChecked() ? sf : null);
+ if (getGpxDataItem() != null) {
+ updateSplitInDatabase();
+ }
}
updateSplitIntervalView(splitIntervalView);
updateColorView(colorView);
@@ -445,6 +449,9 @@ public class TrackSegmentFragment extends OsmAndListFragment {
final List groups = getDisplayGroups();
if (groups.size() > 0) {
updateSplit(groups, vis.isChecked() ? sf : null);
+ if (getGpxDataItem() != null) {
+ updateSplitInDatabase();
+ }
}
popup.dismiss();
updateSplitIntervalView(splitIntervalView);
@@ -465,11 +472,30 @@ public class TrackSegmentFragment extends OsmAndListFragment {
}
}
+ private void updateSplitInDatabase() {
+ int splitType = 0;
+ double splitInterval = 0;
+ if (selectedSplitInterval == 0) {
+ splitType = GPXDatabase.GPX_SPLIT_TYPE_NO_SPLIT;
+ splitInterval = 0;
+ } else if (distanceSplit.get(selectedSplitInterval) > 0) {
+ splitType = GPXDatabase.GPX_SPLIT_TYPE_DISTANCE;
+ splitInterval = distanceSplit.get(selectedSplitInterval);
+ } else if (timeSplit.get(selectedSplitInterval) > 0) {
+ splitType = GPXDatabase.GPX_SPLIT_TYPE_TIME;
+ splitInterval = timeSplit.get(selectedSplitInterval);
+ }
+ app.getGpxDatabase().updateSplit(getGpxDataItem(), splitType, splitInterval);
+ }
+
public void updateSplitView() {
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), ((SwitchCompat)headerView.findViewById(R.id.showOnMapToggle)).isChecked(), false);
final List groups = getDisplayGroups();
if (groups.size() > 0) {
updateSplit(groups, ((SwitchCompat)headerView.findViewById(R.id.showOnMapToggle)).isChecked() ? sf : null);
+ if (getGpxDataItem() != null) {
+ updateSplitInDatabase();
+ }
}
updateSplitIntervalView(headerView.findViewById(R.id.split_interval_view));
}