Merge "Showing toast on the UI thread."
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 15e2ddf..95dad37 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -815,6 +815,10 @@
The argument is file name the user imported.
[CHAR LIMIT=40] -->
<string name="vcard_import_will_start_message"><xliff:g id="filename" example="import.vcf">%s</xliff:g> will be imported shortly.</string>
+ <!-- The message shown when vCard import request is accepted. The system may start that work soon, or do it later when there are already other import/export requests.
+ "The file" is what a user selected for importing.
+ [CHAR LIMIT=40] -->
+ <string name="vcard_import_will_start_message_with_default_name">The file will be imported shortly.</string>
<!-- The message shown when a given vCard import request is rejected by the system. [CHAR LIMIT=NONE] -->
<string name="vcard_import_request_rejected_message">vCard import request is rejected. Please try later.</string>
<!-- The message shown when vCard export request is accepted. The system may start that work soon, or do it later
@@ -824,7 +828,9 @@
<string name="vcard_export_will_start_message"><xliff:g id="filename" example="import.vcf">%s</xliff:g> will be exported shortly.</string>
<!-- The message shown when a given vCard export request is rejected by the system. [CHAR LIMIT=NONE] -->
<string name="vcard_export_request_rejected_message">vCard export request is rejected. Please try later.</string>
-
+ <!-- Used when file name is unknown in vCard processing. It typically happens
+ when the file is given outside the Contacts app. [CHAR LIMIT=30] -->
+ <string name="vcard_unknown_filename">contact</string>
<!-- The percentage, used for expressing the progress of vCard import/export. -->
<string name="percentage">%s%%</string>
diff --git a/src/com/android/contacts/vcard/VCardService.java b/src/com/android/contacts/vcard/VCardService.java
index 7639c18..efa93d4 100644
--- a/src/com/android/contacts/vcard/VCardService.java
+++ b/src/com/android/contacts/vcard/VCardService.java
@@ -188,9 +188,18 @@
request.uri, request.originalUri));
}
if (tryExecute(new ImportProcessor(this, request, mCurrentJobId))) {
- final String displayName = request.originalUri.getLastPathSegment();
- final String message = getString(R.string.vcard_import_will_start_message,
- displayName);
+ final String displayName;
+ final String message;
+ final String lastPathSegment = request.originalUri.getLastPathSegment();
+ if ("file".equals(request.originalUri.getScheme()) &&
+ lastPathSegment != null) {
+ displayName = lastPathSegment;
+ message = getString(R.string.vcard_import_will_start_message, displayName);
+ } else {
+ displayName = getString(R.string.vcard_unknown_filename);
+ message = getString(R.string.vcard_import_will_start_message_with_default_name);
+ }
+
// TODO: Ideally we should detect the current status of import/export and show
// "started" when we can import right now and show "will start" when we cannot.
Toast.makeText(this, message, Toast.LENGTH_LONG).show();