Merge branch 'r3.5'
This commit is contained in:
commit
8bb7fb7144
13 changed files with 72 additions and 43 deletions
|
@ -1238,7 +1238,7 @@ public class OsmandAidlApi {
|
|||
@Override
|
||||
protected void onPostExecute(GPXFile gpx) {
|
||||
if (gpx.error == null) {
|
||||
selectedGpx.setGpxFile(gpx);
|
||||
selectedGpx.setGpxFile(gpx, app);
|
||||
refreshMap();
|
||||
}
|
||||
}
|
||||
|
@ -1417,7 +1417,7 @@ public class OsmandAidlApi {
|
|||
}
|
||||
long modifiedTime = gpxFile.modifiedTime;
|
||||
long fileSize = new File(gpxFile.path).length();
|
||||
files.add(new ASelectedGpxFile(path, modifiedTime, fileSize, createGpxFileDetails(selectedGpxFile.getTrackAnalysis())));
|
||||
files.add(new ASelectedGpxFile(path, modifiedTime, fileSize, createGpxFileDetails(selectedGpxFile.getTrackAnalysis(app))));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -1435,7 +1435,7 @@ public class OsmandAidlApi {
|
|||
}
|
||||
long modifiedTime = gpxFile.modifiedTime;
|
||||
long fileSize = new File(gpxFile.path).length();
|
||||
files.add(new net.osmand.aidlapi.gpx.ASelectedGpxFile(path, modifiedTime, fileSize, createGpxFileDetailsV2(selectedGpxFile.getTrackAnalysis())));
|
||||
files.add(new net.osmand.aidlapi.gpx.ASelectedGpxFile(path, modifiedTime, fileSize, createGpxFileDetailsV2(selectedGpxFile.getTrackAnalysis(app))));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -151,10 +151,13 @@ public class GpxSelectionHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void processSplit() {
|
||||
public static boolean processSplit(OsmandApplication app) {
|
||||
if (app == null || app.isApplicationInitializing()) {
|
||||
return false;
|
||||
}
|
||||
List<GpxDataItem> items = app.getGpxDbHelper().getSplitItems();
|
||||
for (GpxDataItem dataItem : items) {
|
||||
SelectedGpxFile selectedGpxFile = getSelectedFileByPath(dataItem.getFile().getAbsolutePath());
|
||||
SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByPath(dataItem.getFile().getAbsolutePath());
|
||||
if (selectedGpxFile != null && selectedGpxFile.getGpxFile() != null) {
|
||||
GPXFile gpxFile = selectedGpxFile.getGpxFile();
|
||||
List<GpxDisplayGroup> groups = app.getSelectedGpxHelper().collectDisplayGroups(gpxFile);
|
||||
|
@ -162,20 +165,21 @@ public class GpxSelectionHelper {
|
|||
for (GpxDisplayGroup model : groups) {
|
||||
model.noSplit(app);
|
||||
}
|
||||
selectedGpxFile.setDisplayGroups(groups);
|
||||
selectedGpxFile.setDisplayGroups(groups, app);
|
||||
} else if (dataItem.getSplitType() == GPXDatabase.GPX_SPLIT_TYPE_DISTANCE) {
|
||||
for (GpxDisplayGroup model : groups) {
|
||||
model.splitByDistance(app, dataItem.getSplitInterval());
|
||||
}
|
||||
selectedGpxFile.setDisplayGroups(groups);
|
||||
selectedGpxFile.setDisplayGroups(groups, app);
|
||||
} else if (dataItem.getSplitType() == GPXDatabase.GPX_SPLIT_TYPE_TIME) {
|
||||
for (GpxDisplayGroup model : groups) {
|
||||
model.splitByTime(app, (int) dataItem.getSplitInterval());
|
||||
}
|
||||
selectedGpxFile.setDisplayGroups(groups);
|
||||
selectedGpxFile.setDisplayGroups(groups, app);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getString(int resId, Object... formatArgs) {
|
||||
|
@ -508,6 +512,7 @@ public class GpxSelectionHelper {
|
|||
} else {
|
||||
selectGpxFile(gpx, true, false, true, selectedByUser, false);
|
||||
}
|
||||
gpx.addGeneralTrack();
|
||||
} else if (obj.has(CURRENT_TRACK)) {
|
||||
SelectedGpxFile file = savingTrackHelper.getCurrentTrack();
|
||||
file.selectedByUser = selectedByUser;
|
||||
|
@ -516,7 +521,6 @@ public class GpxSelectionHelper {
|
|||
selectedGPXFiles = newSelectedGPXFiles;
|
||||
}
|
||||
}
|
||||
processSplit();
|
||||
if (save) {
|
||||
saveCurrentSelections();
|
||||
}
|
||||
|
@ -589,7 +593,7 @@ public class GpxSelectionHelper {
|
|||
if (dataItem != null && dataItem.getColor() != 0) {
|
||||
gpx.setColor(dataItem.getColor());
|
||||
}
|
||||
sf.setGpxFile(gpx);
|
||||
sf.setGpxFile(gpx, app);
|
||||
sf.notShowNavigationDialog = notShowNavigationDialog;
|
||||
sf.selectedByUser = selectedByUser;
|
||||
}
|
||||
|
@ -606,6 +610,9 @@ public class GpxSelectionHelper {
|
|||
if (syncGroup) {
|
||||
syncGpxWithMarkers(gpx);
|
||||
}
|
||||
if (sf != null) {
|
||||
sf.splitProcessed = false;
|
||||
}
|
||||
return sf;
|
||||
}
|
||||
|
||||
|
@ -667,36 +674,38 @@ public class GpxSelectionHelper {
|
|||
private int color;
|
||||
private GPXTrackAnalysis trackAnalysis;
|
||||
private long modifiedTime = -1;
|
||||
private boolean splitProcessed = false;
|
||||
private List<TrkSegment> processedPointsToDisplay = new ArrayList<>();
|
||||
private boolean routePoints;
|
||||
|
||||
private List<GpxDisplayGroup> displayGroups;
|
||||
|
||||
public void setGpxFile(GPXFile gpxFile) {
|
||||
public void setGpxFile(GPXFile gpxFile, OsmandApplication app) {
|
||||
this.gpxFile = gpxFile;
|
||||
if (gpxFile.tracks.size() > 0) {
|
||||
this.color = gpxFile.tracks.get(0).getColor(0);
|
||||
}
|
||||
processPoints();
|
||||
processPoints(app);
|
||||
}
|
||||
|
||||
public GPXTrackAnalysis getTrackAnalysis() {
|
||||
public GPXTrackAnalysis getTrackAnalysis(OsmandApplication app) {
|
||||
if (modifiedTime != gpxFile.modifiedTime) {
|
||||
update();
|
||||
update(app);
|
||||
}
|
||||
return trackAnalysis;
|
||||
}
|
||||
|
||||
private void update() {
|
||||
private void update(OsmandApplication app) {
|
||||
modifiedTime = gpxFile.modifiedTime;
|
||||
trackAnalysis = gpxFile.getAnalysis(
|
||||
Algorithms.isEmpty(gpxFile.path) ? System.currentTimeMillis() :
|
||||
new File(gpxFile.path).lastModified());
|
||||
displayGroups = null;
|
||||
splitProcessed = GpxSelectionHelper.processSplit(app);
|
||||
}
|
||||
|
||||
public void processPoints() {
|
||||
update();
|
||||
public void processPoints(OsmandApplication app) {
|
||||
update(app);
|
||||
this.processedPointsToDisplay = gpxFile.proccessPoints();
|
||||
if (this.processedPointsToDisplay.isEmpty()) {
|
||||
this.processedPointsToDisplay = gpxFile.processRoutePoints();
|
||||
|
@ -737,16 +746,16 @@ public class GpxSelectionHelper {
|
|||
return color;
|
||||
}
|
||||
|
||||
public List<GpxDisplayGroup> getDisplayGroups() {
|
||||
if (modifiedTime != gpxFile.modifiedTime) {
|
||||
update();
|
||||
public List<GpxDisplayGroup> getDisplayGroups(OsmandApplication app) {
|
||||
if (modifiedTime != gpxFile.modifiedTime || !splitProcessed) {
|
||||
update(app);
|
||||
}
|
||||
return displayGroups;
|
||||
}
|
||||
|
||||
public void setDisplayGroups(List<GpxDisplayGroup> displayGroups) {
|
||||
public void setDisplayGroups(List<GpxDisplayGroup> displayGroups, OsmandApplication app) {
|
||||
if (modifiedTime != gpxFile.modifiedTime) {
|
||||
update();
|
||||
update(app);
|
||||
}
|
||||
this.displayGroups = displayGroups;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
this.currentTrack.setShowCurrentTrack(true);
|
||||
GPXFile gx = new GPXFile(Version.getFullVersion(ctx));
|
||||
gx.showCurrentTrack = true;
|
||||
this.currentTrack.setGpxFile(gx);
|
||||
this.currentTrack.setGpxFile(gx, ctx);
|
||||
prepareCurrentTrackForRecording();
|
||||
|
||||
updateScript = "INSERT INTO " + TRACK_NAME + " (" + TRACK_COL_LAT + ", " + TRACK_COL_LON + ", "
|
||||
|
@ -482,7 +482,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
lt.points.add(pt);
|
||||
}
|
||||
if (segmentAdded) {
|
||||
currentTrack.processPoints();
|
||||
currentTrack.processPoints(ctx);
|
||||
}
|
||||
currentTrack.getModifiableGpxFile().modifiedTime = time;
|
||||
}
|
||||
|
@ -629,7 +629,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
|
|||
ctx.getSelectedGpxHelper().addPoints(entry.getValue().getPoints(), currentTrack.getModifiableGpxFile());
|
||||
currentTrack.getModifiableGpxFile().tracks.addAll(entry.getValue().tracks);
|
||||
}
|
||||
currentTrack.processPoints();
|
||||
currentTrack.processPoints(ctx);
|
||||
prepareCurrentTrackForRecording();
|
||||
GPXTrackAnalysis analysis = currentTrack.getModifiableGpxFile().getAnalysis(System.currentTimeMillis());
|
||||
distance = analysis.totalDistance;
|
||||
|
|
|
@ -39,6 +39,7 @@ import net.osmand.plus.OsmandSettings.AutoZoomMap;
|
|||
import net.osmand.plus.OsmandSettings.OsmandPreference;
|
||||
import net.osmand.plus.OsmandSettings.SpeedConstants;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
|
@ -774,11 +775,10 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
max = Math.round(router.getMaxSpeed() * ratio[0] * 1.5f);
|
||||
}
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
boolean lightMode = app.getSettings().isLightContent();
|
||||
int themeRes = lightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
|
||||
View seekbarView = LayoutInflater.from(new ContextThemeWrapper(activity, themeRes))
|
||||
.inflate(R.layout.default_speed_dialog, null, false);
|
||||
boolean nightMode = !app.getSettings().isLightContentForMode(mode);
|
||||
Context themedContext = UiUtilities.getThemedContext(activity, nightMode);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(themedContext);
|
||||
View seekbarView = LayoutInflater.from(themedContext).inflate(R.layout.default_speed_dialog, null, false);
|
||||
builder.setView(seekbarView);
|
||||
builder.setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -189,8 +189,8 @@ public class TrackActivity extends TabActivity {
|
|||
}
|
||||
if (file != null) {
|
||||
SelectedGpxFile sf = selectedGpxHelper.getSelectedFileByPath(gpxFile.path);
|
||||
if (sf != null && file != null && sf.getDisplayGroups() != null) {
|
||||
displayGroups = sf.getDisplayGroups();
|
||||
if (sf != null && file != null && sf.getDisplayGroups(app) != null) {
|
||||
displayGroups = sf.getDisplayGroups(app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ public class TrackActivity extends TabActivity {
|
|||
} else {
|
||||
final SelectedGpxFile selectedGpx = helper.getSelectedFileByPath(result.path);
|
||||
if (selectedGpx != null && result.error == null) {
|
||||
selectedGpx.setGpxFile(result);
|
||||
selectedGpx.setGpxFile(result, app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -796,7 +796,7 @@ public class GpxUiHelper {
|
|||
|
||||
GPXTrackAnalysis analysis = null;
|
||||
if (currentlyRecordingTrack) {
|
||||
analysis = app.getSavingTrackHelper().getCurrentTrack().getTrackAnalysis();
|
||||
analysis = app.getSavingTrackHelper().getCurrentTrack().getTrackAnalysis(app);
|
||||
} else if (dataItem != null) {
|
||||
analysis = dataItem.getAnalysis();
|
||||
}
|
||||
|
@ -1025,6 +1025,8 @@ public class GpxUiHelper {
|
|||
GPXFile res = GPXUtilities.loadGPXFile(f);
|
||||
if (res.error != null && !Algorithms.isEmpty(res.error.getMessage())) {
|
||||
w += res.error.getMessage() + "\n";
|
||||
} else {
|
||||
res.addGeneralTrack();
|
||||
}
|
||||
result[k++] = res;
|
||||
}
|
||||
|
|
|
@ -1349,7 +1349,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
|||
SelectedGpxFile sf = activity.getMyApplication().getSelectedGpxHelper().selectGpxFile(gpx, true, false);
|
||||
if (sf != null) {
|
||||
if (actionType == NewGpxData.ActionType.ADD_SEGMENT || actionType == NewGpxData.ActionType.EDIT_SEGMENT) {
|
||||
sf.processPoints();
|
||||
sf.processPoints(getMyApplication());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1867,9 +1867,9 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
|||
SelectedGpxFile sgpx = getSelectedGpxFile(gpxInfo, app);
|
||||
GPXTrackAnalysis analysis = null;
|
||||
if (sgpx != null) {
|
||||
analysis = sgpx.getTrackAnalysis();
|
||||
analysis = sgpx.getTrackAnalysis(app);
|
||||
} else if (gpxInfo.currentlyRecordingTrack) {
|
||||
analysis = app.getSavingTrackHelper().getCurrentTrack().getTrackAnalysis();
|
||||
analysis = app.getSavingTrackHelper().getCurrentTrack().getTrackAnalysis(app);
|
||||
} else if (gpxInfo.file != null) {
|
||||
GpxDataItemCallback analyserCallback = null;
|
||||
if (callback != null) {
|
||||
|
|
|
@ -695,7 +695,7 @@ public class SplitSegmentDialogFragment extends DialogFragment {
|
|||
progressBar.setVisibility(View.GONE);
|
||||
if (mSelectedGpxFile != null) {
|
||||
List<GpxDisplayGroup> groups = getDisplayGroups();
|
||||
mSelectedGpxFile.setDisplayGroups(groups);
|
||||
mSelectedGpxFile.setDisplayGroups(groups, app);
|
||||
}
|
||||
updateContent();
|
||||
}
|
||||
|
|
|
@ -720,12 +720,30 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
|
||||
private void updateSplitIntervalView(View view) {
|
||||
final TextView text = (TextView) view.findViewById(R.id.split_interval_text);
|
||||
selectedSplitInterval = getSelectedSplitInterval();
|
||||
if (selectedSplitInterval == 0) {
|
||||
text.setText(app.getString(R.string.shared_string_none));
|
||||
} else {
|
||||
text.setText(options.get(selectedSplitInterval));
|
||||
}
|
||||
}
|
||||
|
||||
private int getSelectedSplitInterval() {
|
||||
if (getGpxDataItem() == null) {
|
||||
return 0;
|
||||
}
|
||||
int splitType = getGpxDataItem().getSplitType();
|
||||
double splitInterval = getGpxDataItem().getSplitInterval();
|
||||
int position = 0;
|
||||
|
||||
if (splitType == GPXDatabase.GPX_SPLIT_TYPE_DISTANCE) {
|
||||
position = distanceSplit.indexOf(splitInterval);
|
||||
} else if (splitType == GPXDatabase.GPX_SPLIT_TYPE_TIME) {
|
||||
position = timeSplit.indexOf((int) splitInterval);
|
||||
}
|
||||
|
||||
return position > 0 ? position : 0;
|
||||
}
|
||||
|
||||
private void updateColorView(View colorView) {
|
||||
final ImageView colorImageView = (ImageView) colorView.findViewById(R.id.colorImage);
|
||||
|
@ -1008,7 +1026,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
}
|
||||
if (selectedGpx != null) {
|
||||
List<GpxDisplayGroup> groups = fragment.getDisplayGroups();
|
||||
selectedGpx.setDisplayGroups(groups);
|
||||
selectedGpx.setDisplayGroups(groups, app);
|
||||
}
|
||||
/*
|
||||
if (fragment.isVisible()) {
|
||||
|
|
|
@ -206,7 +206,7 @@ public class TrackBitmapDrawer {
|
|||
sf = app.getSavingTrackHelper().getCurrentTrack();
|
||||
} else {
|
||||
sf = new GpxSelectionHelper.SelectedGpxFile();
|
||||
sf.setGpxFile(gpxFile);
|
||||
sf.setGpxFile(gpxFile, app);
|
||||
}
|
||||
Bitmap bmp = mapBitmap.copy(mapBitmap.getConfig(), true);
|
||||
Canvas canvas = new Canvas(bmp);
|
||||
|
|
|
@ -1294,8 +1294,8 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
|
|||
if (selectedGpx != null) {
|
||||
List<GpxDisplayGroup> groups = fragment.getDisplayGroups();
|
||||
if (groups != null) {
|
||||
selectedGpx.setDisplayGroups(groups);
|
||||
selectedGpx.processPoints();
|
||||
selectedGpx.setDisplayGroups(groups, app);
|
||||
selectedGpx.processPoints(app);
|
||||
}
|
||||
}
|
||||
fragment.updateContent();
|
||||
|
|
|
@ -289,7 +289,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
if (tileBox.getZoom() >= startZoom) {
|
||||
// request to load
|
||||
for (SelectedGpxFile g : selectedGPXFiles) {
|
||||
List<GpxDisplayGroup> groups = g.getDisplayGroups();
|
||||
List<GpxDisplayGroup> groups = g.getDisplayGroups(view.getApplication());
|
||||
if (groups != null && !groups.isEmpty()) {
|
||||
int color = g.getGpxFile().getColor(0);
|
||||
if (color == 0) {
|
||||
|
|
Loading…
Reference in a new issue