Merge pull request #4103 from osmandapp/split_interval_screen
Split screen improvements and saving to database
This commit is contained in:
commit
d7251843cd
5 changed files with 162 additions and 19 deletions
|
@ -75,8 +75,8 @@
|
||||||
<dimen name="default_sub_text_size">14sp</dimen>
|
<dimen name="default_sub_text_size">14sp</dimen>
|
||||||
<dimen name="welcome_header_text_size">27sp</dimen>
|
<dimen name="welcome_header_text_size">27sp</dimen>
|
||||||
|
|
||||||
<dimen name="default_split_segments_overview">14sp</dimen>
|
<dimen name="default_split_segments_overview">15sp</dimen>
|
||||||
<dimen name="default_split_segments_data">14sp</dimen>
|
<dimen name="default_split_segments_data">15sp</dimen>
|
||||||
<dimen name="default_split_segments_sub">11sp</dimen>
|
<dimen name="default_split_segments_sub">12sp</dimen>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||||
public class GPXDatabase {
|
public class GPXDatabase {
|
||||||
|
|
||||||
private static final String DB_NAME = "gpx_database";
|
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_TABLE_NAME = "gpxTable";
|
||||||
private static final String GPX_COL_NAME = "fileName";
|
private static final String GPX_COL_NAME = "fileName";
|
||||||
private static final String GPX_COL_DIR = "fileDir";
|
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_COLOR = "color";
|
||||||
private static final String GPX_COL_FILE_LAST_MODIFIED_TIME = "fileLastModifiedTime";
|
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 + " (" +
|
private static final String GPX_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " + GPX_TABLE_NAME + " (" +
|
||||||
GPX_COL_NAME + " TEXT, " +
|
GPX_COL_NAME + " TEXT, " +
|
||||||
GPX_COL_DIR + " TEXT, " +
|
GPX_COL_DIR + " TEXT, " +
|
||||||
|
@ -63,7 +70,9 @@ public class GPXDatabase {
|
||||||
GPX_COL_POINTS + " int, " +
|
GPX_COL_POINTS + " int, " +
|
||||||
GPX_COL_WPT_POINTS + " int, " +
|
GPX_COL_WPT_POINTS + " int, " +
|
||||||
GPX_COL_COLOR + " TEXT, " +
|
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 " +
|
private static final String GPX_TABLE_SELECT = "SELECT " +
|
||||||
GPX_COL_NAME + ", " +
|
GPX_COL_NAME + ", " +
|
||||||
|
@ -85,7 +94,9 @@ public class GPXDatabase {
|
||||||
GPX_COL_POINTS + ", " +
|
GPX_COL_POINTS + ", " +
|
||||||
GPX_COL_WPT_POINTS + ", " +
|
GPX_COL_WPT_POINTS + ", " +
|
||||||
GPX_COL_COLOR + ", " +
|
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;
|
" FROM " + GPX_TABLE_NAME;
|
||||||
|
|
||||||
private OsmandApplication context;
|
private OsmandApplication context;
|
||||||
|
@ -95,6 +106,8 @@ public class GPXDatabase {
|
||||||
private GPXTrackAnalysis analysis;
|
private GPXTrackAnalysis analysis;
|
||||||
private int color;
|
private int color;
|
||||||
private long fileLastModifiedTime;
|
private long fileLastModifiedTime;
|
||||||
|
private int splitType;
|
||||||
|
private double splitInterval;
|
||||||
|
|
||||||
public GpxDataItem(File file, GPXTrackAnalysis analysis) {
|
public GpxDataItem(File file, GPXTrackAnalysis analysis) {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
|
@ -121,6 +134,14 @@ public class GPXDatabase {
|
||||||
public long getFileLastModifiedTime() {
|
public long getFileLastModifiedTime() {
|
||||||
return fileLastModifiedTime;
|
return fileLastModifiedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getSplitType() {
|
||||||
|
return splitType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getSplitInterval() {
|
||||||
|
return splitInterval;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GPXDatabase(OsmandApplication app) {
|
public GPXDatabase(OsmandApplication app) {
|
||||||
|
@ -161,6 +182,10 @@ public class GPXDatabase {
|
||||||
updateLastModifiedTime(item);
|
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) {
|
private boolean updateLastModifiedTime(GpxDataItem item) {
|
||||||
|
@ -223,6 +248,27 @@ public class GPXDatabase {
|
||||||
return false;
|
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) {
|
public boolean remove(File file) {
|
||||||
SQLiteConnection db = openConnection(false);
|
SQLiteConnection db = openConnection(false);
|
||||||
if (db != null){
|
if (db != null){
|
||||||
|
@ -278,16 +324,16 @@ public class GPXDatabase {
|
||||||
}
|
}
|
||||||
if (a != null) {
|
if (a != null) {
|
||||||
db.execSQL(
|
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,
|
new Object[]{ fileName, fileDir, a.totalDistance, a.totalTracks, a.startTime, a.endTime,
|
||||||
a.timeSpan, a.timeMoving, a.totalDistanceMoving, a.diffElevationUp, a.diffElevationDown,
|
a.timeSpan, a.timeMoving, a.totalDistanceMoving, a.diffElevationUp, a.diffElevationDown,
|
||||||
a.avgElevation, a.minElevation, a.maxElevation, a.maxSpeed, a.avgSpeed, a.points, a.wptPoints,
|
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 {
|
} else {
|
||||||
db.execSQL(
|
db.execSQL(
|
||||||
"INSERT INTO " + GPX_TABLE_NAME + "(" + GPX_COL_NAME + ", " + GPX_COL_DIR + ", " +
|
"INSERT INTO " + GPX_TABLE_NAME + "(" + GPX_COL_NAME + ", " + GPX_COL_DIR + ", " +
|
||||||
GPX_COL_COLOR + ", " + GPX_COL_FILE_LAST_MODIFIED_TIME + ") VALUES (?, ?, ?, ?)",
|
GPX_COL_COLOR + ", " + GPX_COL_FILE_LAST_MODIFIED_TIME + ", " + GPX_COL_SPLIT_TYPE + ", " + GPX_COL_SPLIT_INTERVAL + ") VALUES (?, ?, ?, ?, ?, ?)",
|
||||||
new Object[]{ fileName, fileDir, color, 0 });
|
new Object[]{ fileName, fileDir, color, 0, item.splitType, item.splitInterval });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,6 +396,8 @@ public class GPXDatabase {
|
||||||
int wptPoints = (int)query.getInt(17);
|
int wptPoints = (int)query.getInt(17);
|
||||||
String color = query.getString(18);
|
String color = query.getString(18);
|
||||||
long fileLastModifiedTime = query.getLong(19);
|
long fileLastModifiedTime = query.getLong(19);
|
||||||
|
int splitType = (int)query.getInt(20);
|
||||||
|
double splitInterval = query.getDouble(21);
|
||||||
|
|
||||||
GPXTrackAnalysis a = new GPXTrackAnalysis();
|
GPXTrackAnalysis a = new GPXTrackAnalysis();
|
||||||
a.totalDistance = totalDistance;
|
a.totalDistance = totalDistance;
|
||||||
|
@ -383,6 +431,8 @@ public class GPXDatabase {
|
||||||
item.color = 0;
|
item.color = 0;
|
||||||
}
|
}
|
||||||
item.fileLastModifiedTime = fileLastModifiedTime;
|
item.fileLastModifiedTime = fileLastModifiedTime;
|
||||||
|
item.splitType = splitType;
|
||||||
|
item.splitInterval = splitInterval;
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import net.osmand.plus.GPXUtilities.Route;
|
||||||
import net.osmand.plus.GPXUtilities.Track;
|
import net.osmand.plus.GPXUtilities.Track;
|
||||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
import net.osmand.plus.OsmandSettings.MetricsConstants;
|
||||||
import net.osmand.plus.activities.SavingTrackHelper;
|
import net.osmand.plus.activities.SavingTrackHelper;
|
||||||
import net.osmand.plus.helpers.GpxUiHelper;
|
import net.osmand.plus.helpers.GpxUiHelper;
|
||||||
|
@ -82,6 +83,35 @@ public class GpxSelectionHelper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void processSplit() {
|
||||||
|
List<GpxDataItem> 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<GpxDisplayGroup> 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) {
|
private String getString(int resId, Object... formatArgs) {
|
||||||
return app.getString(resId, formatArgs);
|
return app.getString(resId, formatArgs);
|
||||||
}
|
}
|
||||||
|
@ -391,6 +421,7 @@ public class GpxSelectionHelper {
|
||||||
selectedGPXFiles.add(savingTrackHelper.getCurrentTrack());
|
selectedGPXFiles.add(savingTrackHelper.getCurrentTrack());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
processSplit();
|
||||||
if (save) {
|
if (save) {
|
||||||
saveCurrentSelections();
|
saveCurrentSelections();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
package net.osmand.plus.myplaces;
|
package net.osmand.plus.myplaces;
|
||||||
|
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.Rect;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.widget.ListPopupWindow;
|
import android.support.v7.widget.ListPopupWindow;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
|
@ -32,6 +35,7 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.TrackActivity;
|
import net.osmand.plus.activities.TrackActivity;
|
||||||
import net.osmand.plus.base.OsmAndListFragment;
|
import net.osmand.plus.base.OsmAndListFragment;
|
||||||
|
import net.osmand.plus.helpers.FontCache;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
@ -59,6 +63,9 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
private TIntArrayList timeSplit = new TIntArrayList();
|
private TIntArrayList timeSplit = new TIntArrayList();
|
||||||
private int selectedSplitInterval;
|
private int selectedSplitInterval;
|
||||||
private IconsCache ic;
|
private IconsCache ic;
|
||||||
|
private int minMaxSpeedLayoutWidth;
|
||||||
|
private Paint minMaxSpeedPaint;
|
||||||
|
private Rect minMaxSpeedTextBounds;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
@ -67,6 +74,13 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
ic = app.getIconsCache();
|
ic = app.getIconsCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||||
|
super.onViewCreated(view, savedInstanceState);
|
||||||
|
updateContent();
|
||||||
|
updateHeader();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
@ -90,6 +104,13 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
setHasOptionsMenu(true);
|
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 View view = getActivity().getLayoutInflater().inflate(R.layout.split_segments_layout, container, false);
|
||||||
|
|
||||||
final ListView listView = (ListView) view.findViewById(android.R.id.list);
|
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.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));
|
listView.addFooterView(getActivity().getLayoutInflater().inflate(R.layout.list_shadow_footer, null, false));
|
||||||
updateContent();
|
|
||||||
updateHeader();
|
|
||||||
|
|
||||||
setListAdapter(adapter);
|
setListAdapter(adapter);
|
||||||
|
|
||||||
|
@ -119,7 +138,7 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScroll(AbsListView absListView, int i, int i1, int i2) {
|
public void onScroll(AbsListView absListView, int i, int i1, int i2) {
|
||||||
View c = absListView.getChildAt(1);
|
View c = absListView.getChildAt(0);
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
int currentYPos = -c.getTop() + absListView.getFirstVisiblePosition() * c.getHeight();
|
int currentYPos = -c.getTop() + absListView.getFirstVisiblePosition() * c.getHeight();
|
||||||
if (previousYPos == -1) {
|
if (previousYPos == -1) {
|
||||||
|
@ -194,8 +213,9 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
adapter.add(overviewSegments);
|
adapter.add(overviewSegments);
|
||||||
List<GpxDisplayItem> splitSegments = getSplitSegments();
|
List<GpxDisplayItem> splitSegments = getSplitSegments();
|
||||||
adapter.addAll(splitSegments);
|
adapter.addAll(splitSegments);
|
||||||
adapter.setNotifyOnChange(true);
|
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
|
getListView().setSelection(0);
|
||||||
|
headerView.setTranslationY(0);
|
||||||
updateHeader();
|
updateHeader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +415,9 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
overviewTextView.setTextColor(defaultTextColor);
|
overviewTextView.setTextColor(defaultTextColor);
|
||||||
overviewTextView.setText(app.getString(R.string.shared_string_overview));
|
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 {
|
} else {
|
||||||
if (currentGpxDisplayItem != null && currentGpxDisplayItem.analysis != null) {
|
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));
|
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 maxSpeed = OsmAndFormatter.getFormattedSpeed(analysis.maxSpeed, app);
|
||||||
String minSpeed = OsmAndFormatter.getFormattedSpeed(analysis.minSpeed, 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")) {
|
if (minSpeed.substring(0, minSpeed.indexOf(" ")).equals("0") || minSpeed.substring(0, minSpeed.indexOf(" ")).equals("0.0")) {
|
||||||
(convertView.findViewById(R.id.max_speed_value))
|
(convertView.findViewById(R.id.max_speed_value))
|
||||||
.setVisibility(View.VISIBLE);
|
.setVisibility(View.VISIBLE);
|
||||||
|
@ -567,7 +603,7 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
.setVisibility(View.GONE);
|
.setVisibility(View.GONE);
|
||||||
((TextView) convertView.findViewById(R.id.max_min_speed_text))
|
((TextView) convertView.findViewById(R.id.max_min_speed_text))
|
||||||
.setText(app.getString(R.string.shared_string_max));
|
.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))
|
(convertView.findViewById(R.id.max_speed_value))
|
||||||
.setVisibility(View.VISIBLE);
|
.setVisibility(View.VISIBLE);
|
||||||
(convertView.findViewById(R.id.min_speed_value))
|
(convertView.findViewById(R.id.min_speed_value))
|
||||||
|
@ -584,7 +620,7 @@ public class SplitSegmentFragment extends OsmAndListFragment {
|
||||||
(convertView.findViewById(R.id.max_min_speed_value))
|
(convertView.findViewById(R.id.max_min_speed_value))
|
||||||
.setVisibility(View.VISIBLE);
|
.setVisibility(View.VISIBLE);
|
||||||
((TextView) convertView.findViewById(R.id.max_min_speed_value))
|
((TextView) convertView.findViewById(R.id.max_min_speed_value))
|
||||||
.setText(max_min_speed);
|
.setText(maxMinSpeed);
|
||||||
(convertView.findViewById(R.id.max_speed_value))
|
(convertView.findViewById(R.id.max_speed_value))
|
||||||
.setVisibility(View.GONE);
|
.setVisibility(View.GONE);
|
||||||
(convertView.findViewById(R.id.min_speed_value))
|
(convertView.findViewById(R.id.min_speed_value))
|
||||||
|
|
|
@ -57,6 +57,7 @@ import net.osmand.data.PointDescription;
|
||||||
import net.osmand.data.QuadRect;
|
import net.osmand.data.QuadRect;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.data.RotatedTileBox.RotatedTileBoxBuilder;
|
import net.osmand.data.RotatedTileBox.RotatedTileBoxBuilder;
|
||||||
|
import net.osmand.plus.GPXDatabase;
|
||||||
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
import net.osmand.plus.GPXDatabase.GpxDataItem;
|
||||||
import net.osmand.plus.GPXUtilities;
|
import net.osmand.plus.GPXUtilities;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
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 View colorView = headerView.findViewById(R.id.color_view);
|
||||||
final SwitchCompat vis = (SwitchCompat) headerView.findViewById(R.id.showOnMapToggle);
|
final SwitchCompat vis = (SwitchCompat) headerView.findViewById(R.id.showOnMapToggle);
|
||||||
final ProgressBar progressBar = (ProgressBar) headerView.findViewById(R.id.mapLoadProgress);
|
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().showCurrentTrack && app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null) ||
|
||||||
(getGpx().path != null && app.getSelectedGpxHelper().getSelectedFileByPath(getGpx().path) != null));
|
(getGpx().path != null && app.getSelectedGpxHelper().getSelectedFileByPath(getGpx().path) != null));
|
||||||
vis.setChecked(selected);
|
vis.setChecked(selected);
|
||||||
|
@ -311,6 +312,9 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
final List<GpxDisplayGroup> groups = getDisplayGroups();
|
final List<GpxDisplayGroup> groups = getDisplayGroups();
|
||||||
if (groups.size() > 0) {
|
if (groups.size() > 0) {
|
||||||
updateSplit(groups, vis.isChecked() ? sf : null);
|
updateSplit(groups, vis.isChecked() ? sf : null);
|
||||||
|
if (getGpxDataItem() != null) {
|
||||||
|
updateSplitInDatabase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateSplitIntervalView(splitIntervalView);
|
updateSplitIntervalView(splitIntervalView);
|
||||||
updateColorView(colorView);
|
updateColorView(colorView);
|
||||||
|
@ -445,6 +449,9 @@ public class TrackSegmentFragment extends OsmAndListFragment {
|
||||||
final List<GpxDisplayGroup> groups = getDisplayGroups();
|
final List<GpxDisplayGroup> groups = getDisplayGroups();
|
||||||
if (groups.size() > 0) {
|
if (groups.size() > 0) {
|
||||||
updateSplit(groups, vis.isChecked() ? sf : null);
|
updateSplit(groups, vis.isChecked() ? sf : null);
|
||||||
|
if (getGpxDataItem() != null) {
|
||||||
|
updateSplitInDatabase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
popup.dismiss();
|
popup.dismiss();
|
||||||
updateSplitIntervalView(splitIntervalView);
|
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() {
|
public void updateSplitView() {
|
||||||
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), ((SwitchCompat)headerView.findViewById(R.id.showOnMapToggle)).isChecked(), false);
|
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), ((SwitchCompat)headerView.findViewById(R.id.showOnMapToggle)).isChecked(), false);
|
||||||
final List<GpxDisplayGroup> groups = getDisplayGroups();
|
final List<GpxDisplayGroup> groups = getDisplayGroups();
|
||||||
if (groups.size() > 0) {
|
if (groups.size() > 0) {
|
||||||
updateSplit(groups, ((SwitchCompat)headerView.findViewById(R.id.showOnMapToggle)).isChecked() ? sf : null);
|
updateSplit(groups, ((SwitchCompat)headerView.findViewById(R.id.showOnMapToggle)).isChecked() ? sf : null);
|
||||||
|
if (getGpxDataItem() != null) {
|
||||||
|
updateSplitInDatabase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateSplitIntervalView(headerView.findViewById(R.id.split_interval_view));
|
updateSplitIntervalView(headerView.findViewById(R.id.split_interval_view));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue