forked from upstream-mirrors/OpenTracks
For import/export, include the external storage location.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package com.google.android.apps.mytracks.fragments;
|
||||
|
||||
import com.google.android.apps.mytracks.io.file.TrackFileFormat;
|
||||
import com.google.android.apps.mytracks.util.FileUtils;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
@@ -32,6 +33,8 @@ import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.RadioGroup.OnCheckedChangeListener;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* A DialogFragment to export a track.
|
||||
*
|
||||
@@ -169,7 +172,9 @@ public class ExportDialogFragment extends DialogFragment {
|
||||
* @param trackFileFormat the track file format
|
||||
*/
|
||||
private void setExternalStorageOption(RadioButton radioButton, TrackFileFormat trackFileFormat) {
|
||||
radioButton.setText(getString(R.string.export_external_storage_option, trackFileFormat.name()));
|
||||
String format = trackFileFormat.name();
|
||||
radioButton.setText(getString(R.string.export_external_storage_option, format,
|
||||
FileUtils.getDisplayDirectory(format.toLowerCase(Locale.US))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.google.android.apps.mytracks.fragments;
|
||||
|
||||
import com.google.android.apps.mytracks.io.file.TrackFileFormat;
|
||||
import com.google.android.apps.mytracks.util.FileUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.Activity;
|
||||
@@ -27,6 +28,8 @@ 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.
|
||||
*
|
||||
@@ -82,14 +85,16 @@ public class FileTypeDialogFragment extends DialogFragment {
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
String fileTypes[] = getResources().getStringArray(R.array.file_types);
|
||||
int size = getArguments().getInt(KEY_SIZE);
|
||||
int optionId = getArguments().getInt(KEY_OPTION_ID);
|
||||
final int titleId = getArguments().getInt(KEY_TITLE_ID);
|
||||
final int menuId = getArguments().getInt(KEY_MENU_ID);
|
||||
String[] choices = new String[size];
|
||||
TrackFileFormat[] trackFileFormats = TrackFileFormat.values();
|
||||
for (int i = 0; i < choices.length; i++) {
|
||||
choices[i] = getString(optionId, fileTypes[i]);
|
||||
String format = trackFileFormats[i].name();
|
||||
choices[i] = getString(
|
||||
optionId, format, FileUtils.getDisplayDirectory(format.toLowerCase(Locale.US)));
|
||||
}
|
||||
return new AlertDialog.Builder(getActivity()).setNegativeButton(R.string.generic_cancel, null)
|
||||
.setPositiveButton(R.string.generic_ok, new OnClickListener() {
|
||||
|
||||
@@ -84,6 +84,20 @@ public class FileUtils {
|
||||
return dir.mkdirs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display directory.
|
||||
* @param components the components
|
||||
*/
|
||||
public static String getDisplayDirectory(String... components) {
|
||||
StringBuilder dirNameBuilder = new StringBuilder();
|
||||
dirNameBuilder.append(File.separatorChar);
|
||||
dirNameBuilder.append(SDCARD_TOP_DIR);
|
||||
for (String component : components) {
|
||||
dirNameBuilder.append(File.separatorChar);
|
||||
dirNameBuilder.append(component);
|
||||
}
|
||||
return dirNameBuilder.toString();
|
||||
}
|
||||
/**
|
||||
* Builds a path inside the My Tracks directory in the SD card.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user