Added support for supplying a postal address when encoding a QR Code.
authordswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 6 Nov 2008 16:13:16 +0000 (16:13 +0000)
committerdswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 6 Nov 2008 16:13:16 +0000 (16:13 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@670 59b500cc-1b3d-0410-9834-0bbf25fbcc57

android/src/com/google/zxing/client/android/Contents.java
android/src/com/google/zxing/client/android/QRCodeEncoder.java
androidtest/src/com/google/zxing/client/androidtest/ZXingTestActivity.java

index 87ffcd3..ccd0a80 100755 (executable)
@@ -65,6 +65,7 @@ public final class Contents {
      * bundle.putString(Contacts.Intents.Insert.NAME, "Jenny");
      * bundle.putString(Contacts.Intents.Insert.PHONE, "8675309");
      * bundle.putString(Contacts.Intents.Insert.EMAIL, "jenny@the80s.com");
+     * bundle.putString(Contacts.Intents.Insert.POSTAL, "123 Fake St. San Francisco, CA 94102");
      * intent.putExtra(Intents.Encode.DATA, bundle);
      */
     public static final String CONTACT = "CONTACT_TYPE";
index 1fc2982..953b08d 100755 (executable)
@@ -108,16 +108,21 @@ public class QRCodeEncoder {
       Bundle bundle = intent.getBundleExtra(Intents.Encode.DATA);
       if (bundle != null) {
         String name = bundle.getString(Contacts.Intents.Insert.NAME);
-        if (name != null && !name.equals("")) {
+        if (name != null && name.length() > 0) {
           mContents = "MECARD:N:" + name + ";";
           mDisplayContents = name;
+          String address = bundle.getString(Contacts.Intents.Insert.POSTAL);
+          if (address != null && address.length() > 0) {
+            mContents += "ADR:" + address + ";";
+            mDisplayContents += "\n" + address;
+          }
           String phone = bundle.getString(Contacts.Intents.Insert.PHONE);
-          if (phone != null && !phone.equals("")) {
+          if (phone != null && phone.length() > 0) {
             mContents += "TEL:" + phone + ";";
             mDisplayContents += "\n" + phone;
           }
           String email = bundle.getString(Contacts.Intents.Insert.EMAIL);
-          if (email != null && !email.equals("")) {
+          if (email != null && email.length() > 0) {
             mContents += "EMAIL:" + email + ";";
             mDisplayContents += "\n" + email;
           }
index a989a5a..c4fc782 100755 (executable)
@@ -163,6 +163,7 @@ public class ZXingTestActivity extends Activity {
       bundle.putString(Contacts.Intents.Insert.NAME, "Jenny");
       bundle.putString(Contacts.Intents.Insert.PHONE, "8675309");
       bundle.putString(Contacts.Intents.Insert.EMAIL, "jenny@the80s.com");
+      bundle.putString(Contacts.Intents.Insert.POSTAL, "123 Fake St. San Francisco, CA 94102");
       encodeBarcode("CONTACT_TYPE", bundle);
     }
   };