Merge "Use same TAG in vCard"
diff --git a/java/com/android/vcard/VCardBuilder.java b/java/com/android/vcard/VCardBuilder.java
index 42567bd..ae778c5 100644
--- a/java/com/android/vcard/VCardBuilder.java
+++ b/java/com/android/vcard/VCardBuilder.java
@@ -36,7 +36,6 @@
import android.util.Log;
import java.io.UnsupportedEncodingException;
-import java.nio.charset.UnsupportedCharsetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -66,7 +65,7 @@
* return builder.toString();</pre>
*/
public class VCardBuilder {
- private static final String LOG_TAG = "VCardBuilder";
+ private static final String LOG_TAG = VCardConstants.LOG_TAG;
// If you add the other element, please check all the columns are able to be
// converted to String.
@@ -837,7 +836,7 @@
}
// PAGER number needs unformatted "phone number".
- // TODO: It would be better to have this logic as optional.
+ // TODO: It would be better to have this logic as optional.
final int type = (typeAsObject != null ? typeAsObject : DEFAULT_PHONE_TYPE);
if (type == Phone.TYPE_PAGER ||
VCardConfig.refrainPhoneNumberFormatting(mVCardType)) {
@@ -1732,7 +1731,7 @@
}
/**
- * @param encodedValue Must be encoded by BASE64
+ * @param encodedValue Must be encoded by BASE64
* @param photoType
*/
public void appendPhotoLine(final String encodedValue, final String photoType) {
@@ -1907,7 +1906,7 @@
}
/**
- * Appends one line with a given property name and value.
+ * Appends one line with a given property name and value.
*/
public void appendLine(final String propertyName, final String rawValue) {
appendLine(propertyName, rawValue, false, false);
diff --git a/java/com/android/vcard/VCardConfig.java b/java/com/android/vcard/VCardConfig.java
index c43d672..5cc796b 100644
--- a/java/com/android/vcard/VCardConfig.java
+++ b/java/com/android/vcard/VCardConfig.java
@@ -28,7 +28,7 @@
* but in VCardUtils.
*/
public class VCardConfig {
- private static final String LOG_TAG = "VCardConfig";
+ private static final String LOG_TAG = VCardConstants.LOG_TAG;
/* package */ static final int LOG_LEVEL_NONE = 0;
/* package */ static final int LOG_LEVEL_PERFORMANCE_MEASUREMENT = 0x1;
@@ -98,13 +98,13 @@
* </p>
*/
private static final int FLAG_USE_ANDROID_PROPERTY = 0x80000000;
-
+
/**
* <p>
* The flag indicating the vCard composer will add some "X-" properties seen in the
* vCard data emitted by the other softwares/devices when the formal vCard specification
* does not have appropriate field(s) for that data.
- * </p>
+ * </p>
* <p>
* One example is X-PHONETIC-FIRST-NAME/X-PHONETIC-MIDDLE-NAME/X-PHONETIC-LAST-NAME, which are
* for phonetic name (how the name is pronounced), seen in the vCard emitted by some other
@@ -299,7 +299,7 @@
(VERSION_21 | NAME_ORDER_DEFAULT | FLAG_USE_DEFACT_PROPERTY | FLAG_USE_ANDROID_PROPERTY);
/* package */ static String VCARD_TYPE_V21_GENERIC_STR = "v21_generic";
-
+
/**
* <p>
* General vCard format with the version 3.0. Uses UTF-8 for the charset.
@@ -332,7 +332,7 @@
(VERSION_21 | NAME_ORDER_EUROPE | FLAG_USE_DEFACT_PROPERTY | FLAG_USE_ANDROID_PROPERTY);
/* package */ static final String VCARD_TYPE_V21_EUROPE_STR = "v21_europe";
-
+
/**
* <p>
* General vCard format with the version 3.0 with some Europe convension. Uses UTF-8.
@@ -343,7 +343,7 @@
*/
public static final int VCARD_TYPE_V30_EUROPE =
(VERSION_30 | NAME_ORDER_EUROPE | FLAG_USE_DEFACT_PROPERTY | FLAG_USE_ANDROID_PROPERTY);
-
+
/* package */ static final String VCARD_TYPE_V30_EUROPE_STR = "v30_europe";
/**
@@ -407,7 +407,7 @@
private static final Map<String, Integer> sVCardTypeMap;
private static final Set<Integer> sJapaneseMobileTypeSet;
-
+
static {
sVCardTypeMap = new HashMap<String, Integer>();
sVCardTypeMap.put(VCARD_TYPE_V21_GENERIC_STR, VCARD_TYPE_V21_GENERIC);
diff --git a/java/com/android/vcard/VCardConstants.java b/java/com/android/vcard/VCardConstants.java
index ea13a7c..20fabed 100644
--- a/java/com/android/vcard/VCardConstants.java
+++ b/java/com/android/vcard/VCardConstants.java
@@ -19,6 +19,7 @@
* Constants used in both exporter and importer code.
*/
public class VCardConstants {
+ /* package */ static final String LOG_TAG = "vCard";
public static final String VERSION_V21 = "2.1";
public static final String VERSION_V30 = "3.0";
public static final String VERSION_V40 = "4.0";
@@ -66,7 +67,7 @@
public static final String PROPERTY_X_SIP = "X-SIP";
// Available in vCard 3.0. Shoud not use when composing vCard 2.1 file.
-
+
// De-fact property values expressing phonetic names.
public static final String PROPERTY_X_PHONETIC_FIRST_NAME = "X-PHONETIC-FIRST-NAME";
public static final String PROPERTY_X_PHONETIC_MIDDLE_NAME = "X-PHONETIC-MIDDLE-NAME";
diff --git a/java/com/android/vcard/VCardEntry.java b/java/com/android/vcard/VCardEntry.java
index 32391e3..afe1bfa 100644
--- a/java/com/android/vcard/VCardEntry.java
+++ b/java/com/android/vcard/VCardEntry.java
@@ -19,12 +19,8 @@
import android.accounts.Account;
import android.content.ContentProviderOperation;
-import android.content.ContentProviderResult;
import android.content.ContentResolver;
-import android.content.OperationApplicationException;
import android.net.Uri;
-import android.os.RemoteException;
-import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Event;
import android.provider.ContactsContract.CommonDataKinds.GroupMembership;
@@ -59,7 +55,7 @@
* This class bridges between data structure of Contact app and VCard data.
*/
public class VCardEntry {
- private static final String LOG_TAG = "VCardEntry";
+ private static final String LOG_TAG = VCardConstants.LOG_TAG;
private final static int DEFAULT_ORGANIZATION_TYPE = Organization.TYPE_WORK;
@@ -539,7 +535,7 @@
}
/**
- * Should be called via {@link #handleOrgValue(int, List, Map, boolean) or
+ * Should be called via {@link #handleOrgValue(int, List, Map, boolean)} or
* {@link #handleTitleValue(String)}.
*/
private void addNewOrganization(int type, final String companyName,
@@ -1031,7 +1027,8 @@
Collection<String> typeCollection = paramMap.get(VCardConstants.PARAM_TYPE);
final int type = Phone.TYPE_OTHER;
final boolean isPrimary;
- if (typeCollection != null && typeCollection.contains(VCardConstants.PARAM_TYPE_PREF)) {
+ if (typeCollection != null &&
+ typeCollection.contains(VCardConstants.PARAM_TYPE_PREF)) {
isPrimary = true;
} else {
isPrimary = false;
diff --git a/java/com/android/vcard/VCardEntryCommitter.java b/java/com/android/vcard/VCardEntryCommitter.java
index d589ef2..7f8e885 100644
--- a/java/com/android/vcard/VCardEntryCommitter.java
+++ b/java/com/android/vcard/VCardEntryCommitter.java
@@ -38,13 +38,13 @@
* </P>
*/
public class VCardEntryCommitter implements VCardEntryHandler {
- public static String LOG_TAG = "VCardEntryComitter";
+ public static String LOG_TAG = VCardConstants.LOG_TAG;
private final ContentResolver mContentResolver;
private long mTimeToCommit;
private int mCounter;
private ArrayList<ContentProviderOperation> mOperationList;
- private ArrayList<Uri> mCreatedUris = new ArrayList<Uri>();
+ private final ArrayList<Uri> mCreatedUris = new ArrayList<Uri>();
public VCardEntryCommitter(ContentResolver resolver) {
mContentResolver = resolver;
diff --git a/java/com/android/vcard/VCardEntryConstructor.java b/java/com/android/vcard/VCardEntryConstructor.java
index 3326ac1..8d3610b 100644
--- a/java/com/android/vcard/VCardEntryConstructor.java
+++ b/java/com/android/vcard/VCardEntryConstructor.java
@@ -42,12 +42,12 @@
* </p>
*/
public class VCardEntryConstructor implements VCardInterpreter {
- private static String LOG_TAG = "VCardEntryConstructor";
+ private static String LOG_TAG = VCardConstants.LOG_TAG;
private VCardEntry.Property mCurrentProperty = new VCardEntry.Property();
private VCardEntry mCurrentVCardEntry;
private String mParamType;
-
+
// The charset using which {@link VCardInterpreter} parses the text.
// Each String is first decoded into binary stream with this charset, and encoded back
// to "target charset", which may be explicitly specified by the vCard with "CHARSET"
@@ -57,7 +57,7 @@
private final boolean mStrictLineBreaking;
private final int mVCardType;
private final Account mAccount;
-
+
// For measuring performance.
private long mTimePushIntoContentResolver;
@@ -144,7 +144,7 @@
public void endProperty() {
mCurrentVCardEntry.addProperty(mCurrentProperty);
}
-
+
@Override
public void propertyName(String name) {
mCurrentProperty.setPropertyName(name);
@@ -196,7 +196,7 @@
Log.w(LOG_TAG, "Unknown encoding. Fall back to default.");
}
- // Just translate the charset of a given String from inputCharset to a system one.
+ // Just translate the charset of a given String from inputCharset to a system one.
return VCardUtils.convertStringCharset(value, sourceCharset, targetCharset);
}
@@ -231,7 +231,7 @@
* @hide
*/
public void showPerformanceInfo() {
- Log.d(LOG_TAG, "time for insert ContactStruct to database: " +
+ Log.d(LOG_TAG, "time for insert ContactStruct to database: " +
mTimePushIntoContentResolver + " ms");
}
}
diff --git a/java/com/android/vcard/VCardParserImpl_V21.java b/java/com/android/vcard/VCardParserImpl_V21.java
index 12f64d8..9e08a19 100644
--- a/java/com/android/vcard/VCardParserImpl_V21.java
+++ b/java/com/android/vcard/VCardParserImpl_V21.java
@@ -42,7 +42,7 @@
* @hide
*/
/* package */ class VCardParserImpl_V21 {
- private static final String LOG_TAG = "VCardParserImpl_V21";
+ private static final String LOG_TAG = VCardConstants.LOG_TAG;
private static final class EmptyInterpreter implements VCardInterpreter {
@Override
@@ -485,7 +485,8 @@
} else {
throw new VCardException("Unknown BEGIN type: " + propertyValue);
}
- } else if (propertyName.equals("VERSION") && !propertyValue.equals(getVersionString())) {
+ } else if (propertyName.equals("VERSION") &&
+ !propertyValue.equals(getVersionString())) {
throw new VCardVersionException("Incompatible version: " + propertyValue + " != "
+ getVersionString());
}
diff --git a/java/com/android/vcard/VCardParserImpl_V30.java b/java/com/android/vcard/VCardParserImpl_V30.java
index 648ce7e..8936fc4 100644
--- a/java/com/android/vcard/VCardParserImpl_V30.java
+++ b/java/com/android/vcard/VCardParserImpl_V30.java
@@ -36,7 +36,7 @@
* @hide
*/
/* package */ class VCardParserImpl_V30 extends VCardParserImpl_V21 {
- private static final String LOG_TAG = "VCardParserImpl_V30";
+ private static final String LOG_TAG = VCardConstants.LOG_TAG;
private String mPreviousLine;
private boolean mEmittedAgentWarning = false;
diff --git a/java/com/android/vcard/VCardParserImpl_V40.java b/java/com/android/vcard/VCardParserImpl_V40.java
index 3a49444..34478d2 100644
--- a/java/com/android/vcard/VCardParserImpl_V40.java
+++ b/java/com/android/vcard/VCardParserImpl_V40.java
@@ -23,12 +23,12 @@
* Basic implementation parsing vCard 4.0.
* </p>
* <p>
- * vCard 4.0 is not published yet. Also this implementation is premature.
+ * vCard 4.0 is not published yet. Also this implementation is premature.
* </p>
* @hide
*/
/* package */ class VCardParserImpl_V40 extends VCardParserImpl_V30 {
- // private static final String LOG_TAG = "VCardParserImpl_V40";
+ // private static final String LOG_TAG = VCardConstants.LOG_TAG;
public VCardParserImpl_V40() {
super();
diff --git a/java/com/android/vcard/VCardSourceDetector.java b/java/com/android/vcard/VCardSourceDetector.java
index 9566a4b..28d8a7a 100644
--- a/java/com/android/vcard/VCardSourceDetector.java
+++ b/java/com/android/vcard/VCardSourceDetector.java
@@ -40,7 +40,7 @@
* </p>
*/
public class VCardSourceDetector implements VCardInterpreter {
- private static final String LOG_TAG = "VCardSourceDetector";
+ private static final String LOG_TAG = VCardConstants.LOG_TAG;
private static Set<String> APPLE_SIGNS = new HashSet<String>(Arrays.asList(
"X-PHONETIC-FIRST-NAME", "X-PHONETIC-MIDDLE-NAME", "X-PHONETIC-LAST-NAME",
diff --git a/java/com/android/vcard/VCardUtils.java b/java/com/android/vcard/VCardUtils.java
index 5385cbf..6c6142d 100644
--- a/java/com/android/vcard/VCardUtils.java
+++ b/java/com/android/vcard/VCardUtils.java
@@ -44,7 +44,7 @@
* Utilities for VCard handling codes.
*/
public class VCardUtils {
- private static final String LOG_TAG = "VCardUtils";
+ private static final String LOG_TAG = VCardConstants.LOG_TAG;
/**
* See org.apache.commons.codec.DecoderException
@@ -121,7 +121,7 @@
// Note that not all types are included in this map/set, since, for example, TYPE_HOME_FAX is
// converted to two parameter Strings. These only contain some minor fields valid in both
- // vCard and current (as of 2009-08-07) Contacts structure.
+ // vCard and current (as of 2009-08-07) Contacts structure.
private static final Map<Integer, String> sKnownPhoneTypesMap_ItoS;
private static final Set<String> sPhoneTypesUnknownToContactsSet;
private static final Map<String, Integer> sKnownPhoneTypeMap_StoI;
@@ -138,11 +138,11 @@
sKnownPhoneTypeMap_StoI.put(VCardConstants.PARAM_TYPE_PAGER, Phone.TYPE_PAGER);
sKnownPhoneTypesMap_ItoS.put(Phone.TYPE_ISDN, VCardConstants.PARAM_TYPE_ISDN);
sKnownPhoneTypeMap_StoI.put(VCardConstants.PARAM_TYPE_ISDN, Phone.TYPE_ISDN);
-
+
sKnownPhoneTypeMap_StoI.put(VCardConstants.PARAM_TYPE_HOME, Phone.TYPE_HOME);
sKnownPhoneTypeMap_StoI.put(VCardConstants.PARAM_TYPE_WORK, Phone.TYPE_WORK);
sKnownPhoneTypeMap_StoI.put(VCardConstants.PARAM_TYPE_CELL, Phone.TYPE_MOBILE);
-
+
sKnownPhoneTypeMap_StoI.put(VCardConstants.PARAM_PHONE_EXTRA_TYPE_OTHER, Phone.TYPE_OTHER);
sKnownPhoneTypeMap_StoI.put(VCardConstants.PARAM_PHONE_EXTRA_TYPE_CALLBACK,
Phone.TYPE_CALLBACK);
@@ -187,7 +187,7 @@
/**
* Returns Interger when the given types can be parsed as known type. Returns String object
- * when not, which should be set to label.
+ * when not, which should be set to label.
*/
public static Object getPhoneTypeFromStrings(Collection<String> types,
String number) {
@@ -198,7 +198,7 @@
String label = null;
boolean isFax = false;
boolean hasPref = false;
-
+
if (types != null) {
for (final String typeStringOrg : types) {
if (typeStringOrg == null) {
@@ -519,7 +519,7 @@
* This is useful since vCard 3.0 often requires the ("X-") properties and groups
* should contain only alphabets, digits, and hyphen.
* </p>
- * <p>
+ * <p>
* Note: It is already known some devices (wrongly) outputs properties with characters
* which should not be in the field. One example is "X-GOOGLE TALK". We accept
* such kind of input but must never output it unless the target is very specific
@@ -812,7 +812,7 @@
byte[] rawBytes = null;
try {
- rawBytes = rawString.getBytes(sourceCharset);
+ rawBytes = rawString.getBytes(sourceCharset);
} catch (UnsupportedEncodingException e) {
Log.w(LOG_TAG, "Failed to decode: " + sourceCharset);
rawBytes = rawString.getBytes();