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.io.file.TrackFileFormat;
|
||||
import de.dennisguse.opentracks.util.FileUtils;
|
||||
|
||||
/**
|
||||
* 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++) {
|
||||
TrackFileFormat trackFileFormat = trackFileFormats[i];
|
||||
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())
|
||||
.setNegativeButton(R.string.generic_cancel, new OnClickListener() {
|
||||
|
||||
@@ -93,7 +93,7 @@ public class ExportActivity extends FragmentActivity implements FileTypeDialogFr
|
||||
exportDirectory = pickedDirectory.createDirectory(FileUtils.EXPORT_DIR);
|
||||
}
|
||||
|
||||
directoryDisplayName = FileUtils.getPathDisplayName(trackFileFormat.getExtension());
|
||||
directoryDisplayName = FileUtils.getPath(exportDirectory);
|
||||
exportAsyncTask = new ExportAsyncTask(this, trackFileFormat, exportDirectory);
|
||||
exportAsyncTask.execute();
|
||||
}
|
||||
@@ -132,8 +132,7 @@ public class ExportActivity extends FragmentActivity implements FileTypeDialogFr
|
||||
} else {
|
||||
iconId = R.drawable.ic_dialog_error_24dp;
|
||||
titleId = R.string.generic_error_title;
|
||||
message = getString(R.string.export_external_storage_error, processedTrackCount, totalTracks,
|
||||
directoryDisplayName);
|
||||
message = getString(R.string.export_external_storage_error, processedTrackCount, totalTracks, directoryDisplayName);
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this).setCancelable(true)
|
||||
.setIcon(iconId).setMessage(message)
|
||||
|
||||
@@ -91,7 +91,7 @@ public class ImportActivity extends FragmentActivity implements FileTypeDialogFr
|
||||
public void onFileTypeDone(TrackFileFormat trackFileFormat) {
|
||||
DocumentFile pickedDirectory = DocumentFile.fromTreeUri(this, directoryUri);
|
||||
|
||||
directoryDisplayName = FileUtils.getPathDisplayName(trackFileFormat.getExtension());
|
||||
directoryDisplayName = FileUtils.getPath(pickedDirectory);
|
||||
|
||||
importAsyncTask = new ImportAsyncTask(this, trackFileFormat, pickedDirectory);
|
||||
importAsyncTask.execute();
|
||||
|
||||
@@ -20,6 +20,8 @@ import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Environment;
|
||||
|
||||
import androidx.documentfile.provider.DocumentFile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import de.dennisguse.opentracks.BuildConfig;
|
||||
@@ -57,20 +59,15 @@ public class FileUtils {
|
||||
return photoDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display name for a path on the external storage.
|
||||
*
|
||||
* @param components the components
|
||||
*/
|
||||
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);
|
||||
|
||||
public static String getPath(DocumentFile file) {
|
||||
if (file == null) {
|
||||
return "";
|
||||
}
|
||||
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