This commit is contained in:
Vitaliy 2020-09-17 11:59:39 +03:00
parent a47c39a9ae
commit e2d8312771
3 changed files with 9 additions and 3 deletions

View file

@ -76,6 +76,8 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
sourceFileName = savedInstanceState.getString(SOURCE_FILE_NAME_KEY);
sourceFolderName = savedInstanceState.getString(SOURCE_FOLDER_NAME_KEY);
showSimplifiedButton = savedInstanceState.getBoolean(SHOW_SIMPLIFIED_BUTTON_KEY);
} else {
folderName = app.getAppPath(IndexConstants.GPX_INDEX_DIR).getName();
}
items.add(new TitleItem(getString(R.string.save_as_new_track)));
@ -290,7 +292,7 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends MenuBottomSheetDial
private File getFile(OsmandApplication app, String folderName, String fileName) {
File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
File source = dir;
if (folderName != null) {
if (folderName != null && !dir.getName().equals(folderName)) {
source = new File(dir, folderName);
}
source = new File(source, fileName + IndexConstants.GPX_FILE_EXT);

View file

@ -48,7 +48,8 @@ public class FolderListAdapter extends RecyclerView.Adapter<FolderListAdapter.Gr
private Collection<? extends String> getFolders() {
List<File> dirs = new ArrayList<>();
final File gpxDir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
File gpxDir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
dirs.add(gpxDir);
Algorithms.collectDirs(gpxDir, dirs);
List<String> dirItems = new ArrayList<>();
for (File dir : dirs) {

View file

@ -894,7 +894,10 @@ public class ChooseRouteFragment extends BaseOsmAndFragment implements ContextMe
public void onSaveAsNewTrack(String folderName, String fileName, boolean showOnMap, boolean simplifiedTrack) {
OsmandApplication app = getMyApplication();
if (app != null) {
File fileDir = new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), folderName == null ? "" : folderName);
File fileDir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
if (!fileDir.getName().equals(folderName)) {
fileDir = new File(fileDir, folderName);
}
File toSave = new File(fileDir, fileName + GPX_FILE_EXT);
new SaveDirectionsAsyncTask(app, showOnMap).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, toSave);
}