summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Attwell <brianattwell@google.com>2014-10-17 22:30:45 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-10-17 22:30:45 +0000
commitaabbf8985c575b958eedb1bffa3f6be804739aeb (patch)
treea2d934d0605fbcc9e644ae4615aee434be5dfd0c /src
parentbe5e6429cfc1100e9a3d8a36e52414e13929ad99 (diff)
parented95f6c490fb9549a88918ddf421cfb70694c52d (diff)
downloadandroid_packages_apps_ContactsCommon-aabbf8985c575b958eedb1bffa3f6be804739aeb.tar.gz
android_packages_apps_ContactsCommon-aabbf8985c575b958eedb1bffa3f6be804739aeb.tar.bz2
android_packages_apps_ContactsCommon-aabbf8985c575b958eedb1bffa3f6be804739aeb.zip
Merge "Improve appearance of export file path" into lmp-mr1-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/contacts/common/vcard/ExportVCardActivity.java16
-rw-r--r--src/com/android/contacts/common/vcard/VCardService.java9
2 files changed, 20 insertions, 5 deletions
diff --git a/src/com/android/contacts/common/vcard/ExportVCardActivity.java b/src/com/android/contacts/common/vcard/ExportVCardActivity.java
index 3d6f6022..008beb68 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;
@@ -111,6 +113,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;
@@ -208,13 +211,22 @@ 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() {
+ 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)
@@ -258,7 +270,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/VCardService.java b/src/com/android/contacts/common/vcard/VCardService.java
index e2adbbde..0a50becc 100644
--- a/src/com/android/contacts/common/vcard/VCardService.java
+++ b/src/com/android/contacts/common/vcard/VCardService.java
@@ -37,6 +37,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;
@@ -472,7 +473,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
@@ -495,7 +497,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,
@@ -507,7 +509,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)