diff options
Diffstat (limited to 'src/com/android/contacts/common/vcard')
5 files changed, 41 insertions, 24 deletions
diff --git a/src/com/android/contacts/common/vcard/ExportVCardActivity.java b/src/com/android/contacts/common/vcard/ExportVCardActivity.java index 625412e8..029561d0 100644 --- a/src/com/android/contacts/common/vcard/ExportVCardActivity.java +++ b/src/com/android/contacts/common/vcard/ExportVCardActivity.java @@ -30,6 +30,8 @@ import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.Messenger; +import android.text.BidiFormatter; +import android.text.TextDirectionHeuristics; import android.text.TextUtils; import android.util.Log; @@ -113,6 +115,7 @@ public class ExportVCardActivity extends Activity implements ServiceConnection, private VCardService mService; private final Messenger mIncomingMessenger = new Messenger(new IncomingHandler()); + private static final BidiFormatter mBidiFormatter = BidiFormatter.getInstance(); // Used temporarily when asking users to confirm the file name private String mTargetFileName; @@ -268,13 +271,25 @@ public class ExportVCardActivity extends Activity implements ServiceConnection, } } + /** + * Returns the name of the target path with additional formatting characters to improve its + * appearance in bidirectional text. + */ + private String getTargetFileForDisplay() { + if (mTargetFileName == null) { + return null; + } + return mBidiFormatter.unicodeWrap(mTargetFileName, TextDirectionHeuristics.LTR); + } + @Override protected Dialog onCreateDialog(int id, Bundle bundle) { switch (id) { case R.id.dialog_export_confirmation: { return new AlertDialog.Builder(this) .setTitle(R.string.confirm_export_title) - .setMessage(getString(R.string.confirm_export_message, mTargetFileName)) + .setMessage(getString(R.string.confirm_export_message, + getTargetFileForDisplay())) .setPositiveButton(android.R.string.ok, new ExportConfirmationListener(mTargetFileName)) .setNegativeButton(android.R.string.cancel, this) @@ -318,7 +333,7 @@ public class ExportVCardActivity extends Activity implements ServiceConnection, ((AlertDialog)dialog).setMessage(mErrorReason); } else if (id == R.id.dialog_export_confirmation) { ((AlertDialog)dialog).setMessage( - getString(R.string.confirm_export_message, mTargetFileName)); + getString(R.string.confirm_export_message, getTargetFileForDisplay())); } else { super.onPrepareDialog(id, dialog, args); } diff --git a/src/com/android/contacts/common/vcard/ImportProcessor.java b/src/com/android/contacts/common/vcard/ImportProcessor.java index 37128755..219ec144 100644 --- a/src/com/android/contacts/common/vcard/ImportProcessor.java +++ b/src/com/android/contacts/common/vcard/ImportProcessor.java @@ -194,14 +194,14 @@ public class ImportProcessor extends ProcessorBase implements VCardEntryHandler Log.i(LOG_TAG, "Successfully finished importing one vCard file: " + uri); List<Uri> uris = committer.getCreatedUris(); if (mListener != null) { - if (uris != null && uris.size() > 0) { - // TODO: construct intent showing a list of imported contact list. + if (uris != null && uris.size() == 1) { mListener.onImportFinished(mImportRequest, mJobId, uris.get(0)); } else { - // Not critical, but suspicious. - Log.w(LOG_TAG, - "Created Uris is null or 0 length " + - "though the creation itself is successful."); + if (uris == null || uris.size() == 0) { + // Not critical, but suspicious. + Log.w(LOG_TAG, "Created Uris is null or 0 length " + + "though the creation itself is successful."); + } mListener.onImportFinished(mImportRequest, mJobId, null); } } diff --git a/src/com/android/contacts/common/vcard/ImportVCardActivity.java b/src/com/android/contacts/common/vcard/ImportVCardActivity.java index 24f24dd1..d36dcaf3 100644 --- a/src/com/android/contacts/common/vcard/ImportVCardActivity.java +++ b/src/com/android/contacts/common/vcard/ImportVCardActivity.java @@ -110,8 +110,6 @@ public class ImportVCardActivity extends Activity { final static String CACHED_URIS = "cached_uris"; - private AccountSelectionUtil.AccountSelectedListener mAccountSelectionListener; - private AccountWithDataSet mAccount; private ProgressDialog mProgressDialogForScanVCard; @@ -946,14 +944,6 @@ public class ImportVCardActivity extends Activity { @Override protected Dialog onCreateDialog(int resId, Bundle bundle) { switch (resId) { - case R.string.import_from_sdcard: { - if (mAccountSelectionListener == null) { - throw new NullPointerException( - "mAccountSelectionListener must not be null."); - } - return AccountSelectionUtil.getSelectAccountDialog(this, resId, - mAccountSelectionListener, mCancelListener); - } case R.id.dialog_searching_vcard: { if (mProgressDialogForScanVCard == null) { String message = getString(R.string.searching_vcard_message); diff --git a/src/com/android/contacts/common/vcard/NotificationImportExportListener.java b/src/com/android/contacts/common/vcard/NotificationImportExportListener.java index 7117f9f5..63420026 100644 --- a/src/com/android/contacts/common/vcard/NotificationImportExportListener.java +++ b/src/com/android/contacts/common/vcard/NotificationImportExportListener.java @@ -26,12 +26,15 @@ import android.content.Intent; import android.net.Uri; import android.os.Handler; import android.os.Message; +import android.provider.ContactsContract; import android.provider.ContactsContract.RawContacts; import android.widget.Toast; import com.android.contacts.common.R; import com.android.vcard.VCardEntry; +import java.text.NumberFormat; + public class NotificationImportExportListener implements VCardImportExportListener, Handler.Callback { /** The tag used by vCard-related notifications. */ @@ -123,7 +126,8 @@ public class NotificationImportExportListener implements VCardImportExportListen RawContacts.CONTENT_URI, rawContactId)); intent = new Intent(Intent.ACTION_VIEW, contactUri); } else { - intent = null; + intent = new Intent(Intent.ACTION_VIEW); + intent.setType(ContactsContract.Contacts.CONTENT_TYPE); } final Notification notification = NotificationImportExportListener.constructFinishNotification(mContext, @@ -218,13 +222,15 @@ public class NotificationImportExportListener implements VCardImportExportListen .setProgress(totalCount, currentCount, totalCount == - 1) .setTicker(tickerText) .setContentTitle(description) + .setColor(context.getResources().getColor(R.color.dialtacts_theme_color)) .setSmallIcon(type == VCardService.TYPE_IMPORT ? android.R.drawable.stat_sys_download : android.R.drawable.stat_sys_upload) .setContentIntent(PendingIntent.getActivity(context, 0, intent, 0)); if (totalCount > 0) { - builder.setContentText(context.getString(R.string.percentage, - String.valueOf(currentCount * 100 / totalCount))); + String percentage = + NumberFormat.getPercentInstance().format((double) currentCount / totalCount); + builder.setContentText(percentage); } return builder.getNotification(); } @@ -240,6 +246,7 @@ public class NotificationImportExportListener implements VCardImportExportListen return new Notification.Builder(context) .setAutoCancel(true) .setSmallIcon(android.R.drawable.stat_notify_error) + .setColor(context.getResources().getColor(R.color.dialtacts_theme_color)) .setContentTitle(description) .setContentText(description) .setContentIntent(PendingIntent.getActivity(context, 0, new Intent(), 0)) @@ -260,6 +267,7 @@ public class NotificationImportExportListener implements VCardImportExportListen .setSmallIcon(type == VCardService.TYPE_IMPORT ? android.R.drawable.stat_sys_download_done : android.R.drawable.stat_sys_upload_done) + .setColor(context.getResources().getColor(R.color.dialtacts_theme_color)) .setContentTitle(title) .setContentText(description) .setContentIntent(PendingIntent.getActivity(context, 0, @@ -277,6 +285,7 @@ public class NotificationImportExportListener implements VCardImportExportListen Context context, String reason) { return new Notification.Builder(context) .setAutoCancel(true) + .setColor(context.getResources().getColor(R.color.dialtacts_theme_color)) .setSmallIcon(android.R.drawable.stat_notify_error) .setContentTitle(context.getString(R.string.vcard_import_failed)) .setContentText(reason) diff --git a/src/com/android/contacts/common/vcard/VCardService.java b/src/com/android/contacts/common/vcard/VCardService.java index f11598a1..7b90eddb 100644 --- a/src/com/android/contacts/common/vcard/VCardService.java +++ b/src/com/android/contacts/common/vcard/VCardService.java @@ -38,6 +38,7 @@ import java.io.File; import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -496,7 +497,8 @@ public class VCardService extends Service { * This method increments "index" part from 1 to maximum, and checks whether any file name * following naming rule is available. If there's no file named /mnt/sdcard/00001.vcf, the * name will be returned to a caller. If there are 00001.vcf 00002.vcf, 00003.vcf is - * returned. + * returned. We format these numbers in the US locale to ensure we they appear as + * english numerals. * * There may not be any appropriate file name. If there are 99999 vCard files in the * storage, for example, there's no appropriate name, so this method returns @@ -519,7 +521,7 @@ public class VCardService extends Service { if (!ALLOW_LONG_FILE_NAME) { final String possibleBody = - String.format(bodyFormat, mFileNamePrefix, 1, mFileNameSuffix); + String.format(Locale.US, bodyFormat, mFileNamePrefix, 1, mFileNameSuffix); if (possibleBody.length() > 8 || mFileNameExtension.length() > 3) { Log.e(LOG_TAG, "This code does not allow any long file name."); mErrorReason = getString(R.string.fail_reason_too_long_filename, @@ -531,7 +533,8 @@ public class VCardService extends Service { for (int i = mFileIndexMinimum; i <= mFileIndexMaximum; i++) { boolean numberIsAvailable = true; - final String body = String.format(bodyFormat, mFileNamePrefix, i, mFileNameSuffix); + final String body + = String.format(Locale.US, bodyFormat, mFileNamePrefix, i, mFileNameSuffix); // Make sure that none of the extensions of mExtensionsToConsider matches. If this // number is free, we'll go ahead with mFileNameExtension (which is included in // mExtensionsToConsider) |