Added support for a title when searching for an address, for example a business name...
authordswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 23 Oct 2008 18:34:35 +0000 (18:34 +0000)
committerdswitkin <dswitkin@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 23 Oct 2008 18:34:35 +0000 (18:34 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@635 59b500cc-1b3d-0410-9834-0bbf25fbcc57

android/res/values/strings.xml
android/src/com/google/zxing/client/android/result/AddressBookResultHandler.java
android/src/com/google/zxing/client/android/result/ResultHandler.java

index 2723535..b574512 100755 (executable)
@@ -64,7 +64,7 @@
   <string name="msg_sbc_failed">Sorry, the search encountered a problem.</string>
   <string name="msg_sbc_no_page_returned">No page returned</string>
   <string name="msg_sbc_page">Page</string>
-  <string name="msg_sbc_snippet_unavailable">Snippets not available</string>
+  <string name="msg_sbc_snippet_unavailable">Snippet not available</string>
   <string name="msg_sbc_unknown_page">Unknown page</string>
   <string name="msg_searching_book">Searching book\u2026</string>
   <string name="msg_share_barcode">Here\'s the contents of a barcode I scanned</string>
index 64a0709..e583318 100644 (file)
@@ -100,7 +100,9 @@ public class AddressBookResultHandler extends ResultHandler {
             addressResult.getTitle());
         break;
       case 1:
-        searchMap(addressResult.getAddress());
+        String[] names = addressResult.getNames();
+        String title = names != null ? names[0] : null;
+        searchMap(addressResult.getAddress(), title);
         break;
       case 2:
         dialPhone(addressResult.getPhoneNumbers()[0]);
index 0f8c503..bc28521 100644 (file)
@@ -207,8 +207,18 @@ public abstract class ResultHandler {
     launchIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(geoURI)));
   }
 
-  public void searchMap(String address) {
-    launchIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + Uri.encode(address))));
+  /**
+   * Do a geo search using the address as the query.
+   *
+   * @param address The address to find
+   * @param title An optional title, e.g. the name of the business at this address
+   */
+  public void searchMap(String address, String title) {
+    String query = address;
+    if (title != null && title.length() > 0) {
+      query = query + " (" + title + ")";
+    }
+    launchIntent(new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + Uri.encode(query))));
   }
 
   public void getDirections(float latitude, float longitude) {
@@ -255,6 +265,8 @@ public abstract class ResultHandler {
     }
   }
 
+  // TODO: The current Contacts Intent API can only accept one value for each field, so we pick the
+  // first element in the array for names, phone numbers, and emails. It would be great to fix this.
   private static void putExtra(Intent intent, String key, String[] value) {
     if (value != null && value.length > 0) {
       putExtra(intent, key, value[0]);