summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-11-19 14:13:31 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-11-19 14:13:31 -0800
commiteb114de5037bba89333bd7d57d305ae989727096 (patch)
tree26f0248ca197c11361627eb213d84be587ce28f0 /core
parent98fdda09256072ae4f45a08ee40178b3ef643c9f (diff)
parent639b0f032bd933286a89812544460680a6a01ae4 (diff)
downloadframeworks_base-eb114de5037bba89333bd7d57d305ae989727096.zip
frameworks_base-eb114de5037bba89333bd7d57d305ae989727096.tar.gz
frameworks_base-eb114de5037bba89333bd7d57d305ae989727096.tar.bz2
Merge change I639b0f03 into eclair-mr2
* changes: Make vCard exporter append neighborhood to locality field instead of extended address, per China convention.
Diffstat (limited to 'core')
-rw-r--r--core/java/android/pim/vcard/VCardBuilder.java38
1 files changed, 30 insertions, 8 deletions
diff --git a/core/java/android/pim/vcard/VCardBuilder.java b/core/java/android/pim/vcard/VCardBuilder.java
index 408d0ce..3980940 100644
--- a/core/java/android/pim/vcard/VCardBuilder.java
+++ b/core/java/android/pim/vcard/VCardBuilder.java
@@ -839,14 +839,14 @@ public class VCardBuilder {
// ; PO Box, Extended Address, Street, Locality, Region, Postal
// ; Code, Country Name
final String rawPoBox = contentValues.getAsString(StructuredPostal.POBOX);
- final String rawExtendedAddress = contentValues.getAsString(StructuredPostal.NEIGHBORHOOD);
+ final String rawNeighborhood = contentValues.getAsString(StructuredPostal.NEIGHBORHOOD);
final String rawStreet = contentValues.getAsString(StructuredPostal.STREET);
final String rawLocality = contentValues.getAsString(StructuredPostal.CITY);
final String rawRegion = contentValues.getAsString(StructuredPostal.REGION);
final String rawPostalCode = contentValues.getAsString(StructuredPostal.POSTCODE);
final String rawCountry = contentValues.getAsString(StructuredPostal.COUNTRY);
final String[] rawAddressArray = new String[]{
- rawPoBox, rawExtendedAddress, rawStreet, rawLocality,
+ rawPoBox, rawNeighborhood, rawStreet, rawLocality,
rawRegion, rawPostalCode, rawCountry};
if (!VCardUtils.areAllEmpty(rawAddressArray)) {
final boolean reallyUseQuotedPrintable =
@@ -855,33 +855,55 @@ public class VCardBuilder {
final boolean appendCharset =
!VCardUtils.containsOnlyPrintableAscii(rawAddressArray);
final String encodedPoBox;
- final String encodedExtendedAddress;
final String encodedStreet;
final String encodedLocality;
final String encodedRegion;
final String encodedPostalCode;
final String encodedCountry;
+ final String encodedNeighborhood;
+
+ final String rawLocality2;
+ // This looks inefficient since we encode rawLocality and rawNeighborhood twice,
+ // but this is intentional.
+ //
+ // QP encoding may add line feeds when needed and the result of
+ // - encodeQuotedPrintable(rawLocality + " " + rawNeighborhood)
+ // may be different from
+ // - encodedLocality + " " + encodedNeighborhood.
+ //
+ // We use safer way.
+ if (TextUtils.isEmpty(rawLocality)) {
+ if (TextUtils.isEmpty(rawNeighborhood)) {
+ rawLocality2 = "";
+ } else {
+ rawLocality2 = rawNeighborhood;
+ }
+ } else {
+ if (TextUtils.isEmpty(rawNeighborhood)) {
+ rawLocality2 = rawLocality;
+ } else {
+ rawLocality2 = rawLocality + " " + rawNeighborhood;
+ }
+ }
if (reallyUseQuotedPrintable) {
encodedPoBox = encodeQuotedPrintable(rawPoBox);
- encodedExtendedAddress = encodeQuotedPrintable(rawExtendedAddress);
encodedStreet = encodeQuotedPrintable(rawStreet);
- encodedLocality = encodeQuotedPrintable(rawLocality);
+ encodedLocality = encodeQuotedPrintable(rawLocality2);
encodedRegion = encodeQuotedPrintable(rawRegion);
encodedPostalCode = encodeQuotedPrintable(rawPostalCode);
encodedCountry = encodeQuotedPrintable(rawCountry);
} else {
encodedPoBox = escapeCharacters(rawPoBox);
- encodedExtendedAddress = escapeCharacters(rawExtendedAddress);
encodedStreet = escapeCharacters(rawStreet);
- encodedLocality = escapeCharacters(rawLocality);
+ encodedLocality = escapeCharacters(rawLocality2);
encodedRegion = escapeCharacters(rawRegion);
encodedPostalCode = escapeCharacters(rawPostalCode);
encodedCountry = escapeCharacters(rawCountry);
+ encodedNeighborhood = escapeCharacters(rawNeighborhood);
}
final StringBuffer addressBuffer = new StringBuffer();
addressBuffer.append(encodedPoBox);
addressBuffer.append(VCARD_ITEM_SEPARATOR);
- addressBuffer.append(encodedExtendedAddress);
addressBuffer.append(VCARD_ITEM_SEPARATOR);
addressBuffer.append(encodedStreet);
addressBuffer.append(VCARD_ITEM_SEPARATOR);