forked from upstream-mirrors/OpenTracks
For import/export, include the external storage location.
This commit is contained in:
@@ -92,12 +92,6 @@ limitations under the License.
|
||||
<item>15</item>
|
||||
<item>-1</item>
|
||||
</string-array>
|
||||
<string-array name="file_types">
|
||||
<item>KML</item>
|
||||
<item>GPX</item>
|
||||
<item>CSV</item>
|
||||
<item>TCX</item>
|
||||
</string-array>
|
||||
<string-array name="frequency_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
|
||||
@@ -616,8 +616,9 @@ limitations under the License.
|
||||
translation_description="When exporting all tracks to the external storage, the option to export
|
||||
as a certain file format.
|
||||
|
||||
%1$s: file format. 'KML', 'GPX', 'CSV', or 'TCX'.">
|
||||
Export all as %1$s
|
||||
%1$s: the file format. E.g., 'KML'.
|
||||
%2$s: the directory. E.g., '/MyTracks/kml'.">
|
||||
All as %1$s to %2$s
|
||||
</string>
|
||||
<string name="export_all_title"
|
||||
translation_description="The dialog title to export all tracks to the external storage.">
|
||||
@@ -640,8 +641,9 @@ limitations under the License.
|
||||
translation_description="When exporting a track to the external storage, the option to export as
|
||||
a certain file format.
|
||||
|
||||
%1$s: file format. 'KML', 'GPX', 'CSV', or 'TCX'.">
|
||||
as %1$s file
|
||||
%1$s: the file format. E.g., 'KML'.
|
||||
%2$s: the directory. E.g., '/MyTracks/kml'.">
|
||||
as %1$s to %2$s
|
||||
</string>
|
||||
<string name="export_external_storage_progress_message"
|
||||
translation_description="When exporting tracks to the external storage, the progress message.
|
||||
@@ -934,14 +936,15 @@ limitations under the License.
|
||||
Importing from %1$s…
|
||||
</string>
|
||||
<string name="import_selection_option"
|
||||
translation_description="When importing from external storage, the option to import all the
|
||||
translation_description="When importing all from external storage, the option to import all the
|
||||
files of a certain file format.
|
||||
|
||||
%1$s: file format. 'KML', 'GPX', 'CSV', or 'TCX'.">
|
||||
Import all %1$s
|
||||
%1$s: the file format. E.g., 'KML'.
|
||||
%2$s: the directory. E.g., '/MyTracks/kml'.">
|
||||
All %1$s from %2$s
|
||||
</string>
|
||||
<string name="import_selection_title"
|
||||
translation_description="The dialog title to import from external storage.">
|
||||
translation_description="The dialog title to import all from external storage.">
|
||||
Import from external storage
|
||||
</string>
|
||||
<string name="import_success"
|
||||
|
||||
@@ -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