mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
Code cleanup: use trackFileFormat.getExtension
This commit is contained in:
@@ -33,8 +33,6 @@ import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.RadioGroup.OnCheckedChangeListener;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A DialogFragment to export a track.
|
||||
*
|
||||
@@ -172,9 +170,8 @@ public class ExportDialogFragment extends DialogFragment {
|
||||
* @param trackFileFormat the track file format
|
||||
*/
|
||||
private void setExternalStorageOption(RadioButton radioButton, TrackFileFormat trackFileFormat) {
|
||||
String format = trackFileFormat.name();
|
||||
radioButton.setText(getString(R.string.export_external_storage_option, format,
|
||||
FileUtils.getDisplayDirectory(format.toLowerCase(Locale.US))));
|
||||
radioButton.setText(getString(R.string.export_external_storage_option, trackFileFormat.name(),
|
||||
FileUtils.getDisplayDirectory(trackFileFormat.getExtension())));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,8 +28,6 @@ import android.content.DialogInterface.OnClickListener;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A DialogFragment to select a file type, gpx, kml, etc.
|
||||
*
|
||||
@@ -92,9 +90,9 @@ public class FileTypeDialogFragment extends DialogFragment {
|
||||
String[] choices = new String[size];
|
||||
TrackFileFormat[] trackFileFormats = TrackFileFormat.values();
|
||||
for (int i = 0; i < choices.length; i++) {
|
||||
String format = trackFileFormats[i].name();
|
||||
choices[i] = getString(
|
||||
optionId, format, FileUtils.getDisplayDirectory(format.toLowerCase(Locale.US)));
|
||||
TrackFileFormat trackFileFormat = trackFileFormats[i];
|
||||
choices[i] = getString(optionId, trackFileFormat.name(),
|
||||
FileUtils.getDisplayDirectory(trackFileFormat.getExtension()));
|
||||
}
|
||||
return new AlertDialog.Builder(getActivity()).setNegativeButton(R.string.generic_cancel, null)
|
||||
.setPositiveButton(R.string.generic_ok, new OnClickListener() {
|
||||
|
||||
@@ -87,8 +87,7 @@ public class ImportActivity extends Activity {
|
||||
return;
|
||||
}
|
||||
if (importAll) {
|
||||
path = FileUtils.buildExternalDirectoryPath(
|
||||
trackFileFormat == TrackFileFormat.KML ? "kml" : "gpx");
|
||||
path = FileUtils.buildExternalDirectoryPath(trackFileFormat.getExtension());
|
||||
if (!FileUtils.isDirectory(new File(path))) {
|
||||
Toast.makeText(this, getString(R.string.import_no_directory, path), Toast.LENGTH_LONG)
|
||||
.show();
|
||||
|
||||
@@ -81,7 +81,7 @@ public class SaveActivity extends Activity {
|
||||
}
|
||||
|
||||
directoryName = playTrack ? FileUtils.buildExternalDirectoryPath(
|
||||
trackFileFormat.getExtension(), "tmp")
|
||||
trackFileFormat.getExtension(), FileUtils.TEMP_DIR)
|
||||
: FileUtils.buildExternalDirectoryPath(trackFileFormat.getExtension());
|
||||
|
||||
File directory = new File(directoryName);
|
||||
|
||||
@@ -91,7 +91,7 @@ public class RemoveTempFilesService extends Service {
|
||||
}
|
||||
|
||||
private void cleanTempDirectory(String name) {
|
||||
cleanTempDirectory(new File(FileUtils.buildExternalDirectoryPath(name, "tmp")));
|
||||
cleanTempDirectory(new File(FileUtils.buildExternalDirectoryPath(name, FileUtils.TEMP_DIR)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,8 @@ public class FileUtils {
|
||||
|
||||
private FileUtils() {}
|
||||
|
||||
public static final String TEMP_DIR = "tmp";
|
||||
|
||||
/**
|
||||
* Name of the top-level directory inside the SD card where our files will be
|
||||
* read from/written to.
|
||||
|
||||
Reference in New Issue
Block a user