forked from upstream-mirrors/OpenTracks
Support cases when there is no files to import or export.
This commit is contained in:
@@ -637,6 +637,16 @@ limitations under the License.
|
||||
%2$s the directory. E.g., '/MyTracks/kml'.">
|
||||
Exported %1$d of %2$s to %3$s.
|
||||
</string>
|
||||
<string name="export_external_storage_no_track"
|
||||
translation_description="When exporting tracks to the external storage, the messsage in the
|
||||
result dialog when there is no tracks to export.">
|
||||
There is no tracks to export.
|
||||
</string>
|
||||
<string name="export_external_storage_no_track_title"
|
||||
translation_description="When exporting tracks to the external storage, the title in the result
|
||||
dialog when there is no tracks to export.">
|
||||
Export tracks
|
||||
</string>
|
||||
<string name="export_external_storage_option"
|
||||
translation_description="When exporting a track to the external storage, the option to export as
|
||||
a certain file format.
|
||||
@@ -929,6 +939,19 @@ limitations under the License.
|
||||
%1$s: the directory. E.g., '/MyTracks/kml'.">
|
||||
%1$s does not exist.
|
||||
</string>
|
||||
<string name="import_no_file"
|
||||
translation_description="When importing from the external storage, the message in the result
|
||||
dialog when there is no files to import.
|
||||
|
||||
%1$s: the directory. E.g., '/MyTracks/kml'.">
|
||||
There were no files to import. Connect your device to your computer and place the files to
|
||||
import in %1$s.
|
||||
</string>
|
||||
<string name="import_no_file_title"
|
||||
translation_description="When importing from the external storage, the title in the result
|
||||
dialog when there is no files to import.">
|
||||
Import files
|
||||
</string>
|
||||
<string name="import_progress_message"
|
||||
translation_description="When importing from the external storage, the progress message.
|
||||
|
||||
|
||||
@@ -147,20 +147,28 @@ public class ImportActivity extends Activity {
|
||||
}, directoryDisplayName);
|
||||
return progressDialog;
|
||||
case DIALOG_RESULT_ID:
|
||||
final boolean success;
|
||||
int iconId;
|
||||
int titleId;
|
||||
String message;
|
||||
String totalFiles = getResources()
|
||||
.getQuantityString(R.plurals.files, totalCount, totalCount);
|
||||
if (successCount == totalCount && totalCount > 0) {
|
||||
success = true;
|
||||
message = getString(R.string.import_success, totalFiles, directoryDisplayName);
|
||||
if (successCount == totalCount) {
|
||||
iconId = android.R.drawable.ic_dialog_info;
|
||||
if (totalCount == 0) {
|
||||
titleId = R.string.import_no_file_title;
|
||||
message = getString(R.string.import_no_file, directoryDisplayName);
|
||||
} else {
|
||||
titleId = R.string.generic_success_title;
|
||||
message = getString(R.string.import_success, totalFiles, directoryDisplayName);
|
||||
}
|
||||
} else {
|
||||
success = false;
|
||||
message = getString(R.string.import_error, successCount, totalFiles, directoryDisplayName);
|
||||
iconId = android.R.drawable.ic_dialog_alert;
|
||||
titleId = R.string.generic_error_title;
|
||||
message = getString(
|
||||
R.string.import_error, successCount, totalFiles, directoryDisplayName);
|
||||
}
|
||||
return new AlertDialog.Builder(this).setCancelable(true).setIcon(
|
||||
success ? android.R.drawable.ic_dialog_info : android.R.drawable.ic_dialog_alert)
|
||||
.setMessage(message).setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
return new AlertDialog.Builder(this).setCancelable(true).setIcon(iconId).setMessage(message)
|
||||
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
dialog.dismiss();
|
||||
@@ -169,7 +177,7 @@ public class ImportActivity extends Activity {
|
||||
}).setPositiveButton(R.string.generic_ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (success && !importAll && trackId != -1L) {
|
||||
if (successCount == totalCount && !importAll && trackId != -1L) {
|
||||
Intent intent = IntentUtils.newIntent(
|
||||
ImportActivity.this, TrackDetailActivity.class)
|
||||
.putExtra(TrackDetailActivity.EXTRA_TRACK_ID, trackId);
|
||||
@@ -180,8 +188,7 @@ public class ImportActivity extends Activity {
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
}
|
||||
}).setTitle(success ? R.string.generic_success_title : R.string.generic_error_title)
|
||||
.create();
|
||||
}).setTitle(titleId).create();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -126,21 +126,30 @@ public class SaveActivity extends Activity {
|
||||
}, directoryDisplayName);
|
||||
return progressDialog;
|
||||
case DIALOG_RESULT_ID:
|
||||
boolean success;
|
||||
int iconId;
|
||||
int titleId;
|
||||
String message;
|
||||
String totalTracks = getResources()
|
||||
.getQuantityString(R.plurals.tracks, totalCount, totalCount);
|
||||
if (successCount == totalCount && totalCount > 0) {
|
||||
success = true;
|
||||
message = getString(R.string.export_external_storage_success, totalTracks, directoryDisplayName);
|
||||
if (successCount == totalCount) {
|
||||
iconId = android.R.drawable.ic_dialog_info;
|
||||
if (totalCount == 0) {
|
||||
titleId = R.string.export_external_storage_no_track_title;
|
||||
message = getString(R.string.export_external_storage_no_track);
|
||||
} else {
|
||||
titleId = R.string.generic_success_title;
|
||||
message = getString(
|
||||
R.string.export_external_storage_success, totalTracks, directoryDisplayName);
|
||||
}
|
||||
} else {
|
||||
success = false;
|
||||
message = getString(
|
||||
R.string.export_external_storage_error, successCount, totalTracks, directoryDisplayName);
|
||||
iconId = android.R.drawable.ic_dialog_alert;
|
||||
titleId = R.string.generic_error_title;
|
||||
message = getString(R.string.export_external_storage_error, successCount, totalTracks,
|
||||
directoryDisplayName);
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this).setCancelable(true).setIcon(
|
||||
success ? android.R.drawable.ic_dialog_info : android.R.drawable.ic_dialog_alert)
|
||||
.setMessage(message).setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this).setCancelable(true)
|
||||
.setIcon(iconId).setMessage(message)
|
||||
.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
dialog.dismiss();
|
||||
@@ -152,8 +161,8 @@ public class SaveActivity extends Activity {
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
}
|
||||
}).setTitle(success ? R.string.generic_success_title : R.string.generic_error_title);
|
||||
if (!playTrack && trackIds.length == 1 && trackIds[0] != -1L && success
|
||||
}).setTitle(titleId);
|
||||
if (!playTrack && trackIds.length == 1 && trackIds[0] != -1L && successCount == totalCount
|
||||
&& savedPath != null) {
|
||||
builder.setNegativeButton(
|
||||
R.string.share_track_share_file, new DialogInterface.OnClickListener() {
|
||||
@@ -167,7 +176,6 @@ public class SaveActivity extends Activity {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return builder.create();
|
||||
default:
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user