forked from upstream-mirrors/OpenTracks
Fixed import/export message to show Storage Access Framework selected path.
This commit is contained in:
@@ -31,7 +31,6 @@ import java.util.Locale;
|
|||||||
|
|
||||||
import de.dennisguse.opentracks.R;
|
import de.dennisguse.opentracks.R;
|
||||||
import de.dennisguse.opentracks.io.file.TrackFileFormat;
|
import de.dennisguse.opentracks.io.file.TrackFileFormat;
|
||||||
import de.dennisguse.opentracks.util.FileUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DialogFragment to select a file type, gpx, kml, etc.
|
* A DialogFragment to select a file type, gpx, kml, etc.
|
||||||
@@ -73,7 +72,7 @@ public class FileTypeDialogFragment extends DialogFragment {
|
|||||||
for (int i = 0; i < choices.length; i++) {
|
for (int i = 0; i < choices.length; i++) {
|
||||||
TrackFileFormat trackFileFormat = trackFileFormats[i];
|
TrackFileFormat trackFileFormat = trackFileFormats[i];
|
||||||
String trackFileFormatUpperCase = trackFileFormat.getExtension().toUpperCase(Locale.US); //ASCII upper case
|
String trackFileFormatUpperCase = trackFileFormat.getExtension().toUpperCase(Locale.US); //ASCII upper case
|
||||||
choices[i] = getString(optionId, trackFileFormatUpperCase, FileUtils.getPathDisplayName(trackFileFormat.getExtension()));
|
choices[i] = getString(optionId, trackFileFormatUpperCase);
|
||||||
}
|
}
|
||||||
return new AlertDialog.Builder(getActivity())
|
return new AlertDialog.Builder(getActivity())
|
||||||
.setNegativeButton(R.string.generic_cancel, new OnClickListener() {
|
.setNegativeButton(R.string.generic_cancel, new OnClickListener() {
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class ExportActivity extends FragmentActivity implements FileTypeDialogFr
|
|||||||
exportDirectory = pickedDirectory.createDirectory(FileUtils.EXPORT_DIR);
|
exportDirectory = pickedDirectory.createDirectory(FileUtils.EXPORT_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
directoryDisplayName = FileUtils.getPathDisplayName(trackFileFormat.getExtension());
|
directoryDisplayName = FileUtils.getPath(exportDirectory);
|
||||||
exportAsyncTask = new ExportAsyncTask(this, trackFileFormat, exportDirectory);
|
exportAsyncTask = new ExportAsyncTask(this, trackFileFormat, exportDirectory);
|
||||||
exportAsyncTask.execute();
|
exportAsyncTask.execute();
|
||||||
}
|
}
|
||||||
@@ -132,8 +132,7 @@ public class ExportActivity extends FragmentActivity implements FileTypeDialogFr
|
|||||||
} else {
|
} else {
|
||||||
iconId = R.drawable.ic_dialog_error_24dp;
|
iconId = R.drawable.ic_dialog_error_24dp;
|
||||||
titleId = R.string.generic_error_title;
|
titleId = R.string.generic_error_title;
|
||||||
message = getString(R.string.export_external_storage_error, processedTrackCount, totalTracks,
|
message = getString(R.string.export_external_storage_error, processedTrackCount, totalTracks, directoryDisplayName);
|
||||||
directoryDisplayName);
|
|
||||||
}
|
}
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this).setCancelable(true)
|
AlertDialog.Builder builder = new AlertDialog.Builder(this).setCancelable(true)
|
||||||
.setIcon(iconId).setMessage(message)
|
.setIcon(iconId).setMessage(message)
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class ImportActivity extends FragmentActivity implements FileTypeDialogFr
|
|||||||
public void onFileTypeDone(TrackFileFormat trackFileFormat) {
|
public void onFileTypeDone(TrackFileFormat trackFileFormat) {
|
||||||
DocumentFile pickedDirectory = DocumentFile.fromTreeUri(this, directoryUri);
|
DocumentFile pickedDirectory = DocumentFile.fromTreeUri(this, directoryUri);
|
||||||
|
|
||||||
directoryDisplayName = FileUtils.getPathDisplayName(trackFileFormat.getExtension());
|
directoryDisplayName = FileUtils.getPath(pickedDirectory);
|
||||||
|
|
||||||
importAsyncTask = new ImportAsyncTask(this, trackFileFormat, pickedDirectory);
|
importAsyncTask = new ImportAsyncTask(this, trackFileFormat, pickedDirectory);
|
||||||
importAsyncTask.execute();
|
importAsyncTask.execute();
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import android.content.Intent;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
|
||||||
|
import androidx.documentfile.provider.DocumentFile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import de.dennisguse.opentracks.BuildConfig;
|
import de.dennisguse.opentracks.BuildConfig;
|
||||||
@@ -57,20 +59,15 @@ public class FileUtils {
|
|||||||
return photoDirectory;
|
return photoDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the display name for a path on the external storage.
|
public static String getPath(DocumentFile file) {
|
||||||
*
|
if (file == null) {
|
||||||
* @param components the components
|
return "";
|
||||||
*/
|
|
||||||
public static String getPathDisplayName(String... components) {
|
|
||||||
StringBuilder dirNameBuilder = new StringBuilder();
|
|
||||||
dirNameBuilder.append(File.separatorChar);
|
|
||||||
dirNameBuilder.append(EXPORT_DIR);
|
|
||||||
for (String component : components) {
|
|
||||||
dirNameBuilder.append(File.separatorChar);
|
|
||||||
dirNameBuilder.append(component);
|
|
||||||
}
|
}
|
||||||
return dirNameBuilder.toString();
|
if (file.getParentFile() == null) {
|
||||||
|
return file.getName();
|
||||||
|
}
|
||||||
|
return getPath(file.getParentFile()) + File.pathSeparatorChar + file.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user