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