From 8090bb441ac8c55a5df39bca64965b2349f8b54a Mon Sep 17 00:00:00 2001 From: dswitkin Date: Mon, 22 Feb 2010 15:55:25 +0000 Subject: [PATCH] Added a Google Shopper button when scanning products, and bumped the version to 3.2 beta 1. git-svn-id: https://zxing.googlecode.com/svn/trunk@1216 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- android/AndroidManifest.xml | 4 +- android/assets/html/whatsnew.html | 16 +++-- android/res/drawable/shopper_icon.png | Bin 0 -> 4987 bytes android/res/values/strings.xml | 9 ++- .../android/result/ISBNResultHandler.java | 31 ++++++--- .../android/result/ProductResultHandler.java | 18 ++++-- .../client/android/result/ResultHandler.java | 59 +++++++++++++++--- 7 files changed, 98 insertions(+), 39 deletions(-) create mode 100644 android/res/drawable/shopper_icon.png diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 16207ce20..074cb92dd 100755 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -20,8 +20,8 @@ version to be published. The next versionCode will be 7, regardless of whether t versionName is 2.31, 2.4, or 3.0. --> + android:versionName="3.2 beta 1" + android:versionCode="44"> diff --git a/android/assets/html/whatsnew.html b/android/assets/html/whatsnew.html index aa777c195..52bf3bdde 100644 --- a/android/assets/html/whatsnew.html +++ b/android/assets/html/whatsnew.html @@ -3,17 +3,15 @@

What's new in this version

-

New in version 3.11:

+

New in version 3.2:

  • Allowed devices without autofocus to see Barcode Scanner in the Market.
  • -
  • Minor translation and bug fixes.
  • -
-

New in version 3.1:

-
    -
  • Added a real-time visualization of the image processing as it's looking for barcodes.
  • -
  • Made QR Code reading in shadows or other difficult lighting dramatically better.
  • -
  • Added sharing of any installed app by generating a QR Code that links to Market.
  • -
  • Many other minor improvements and bug fixes.
  • +
  • New Finnish, Dutch, and Czech translations.
  • +
  • Added a Google Shopper button when scanning products.
  • +
  • Fixed a possible crash on unsupported hardware.
  • +
  • Better layouts on QVGA devices like the HTC Tattoo.
  • +
  • Added the ability to email your scan history.
  • +
  • New high res icon and minor bug fixes.
diff --git a/android/res/drawable/shopper_icon.png b/android/res/drawable/shopper_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..600b4280345bfafcc56e5614ec9f247124bd105d GIT binary patch literal 4987 zcmV->6NK!EP)Px|HAzH4RCwCeTy2bkqu^ zue-i??fsa;k9TIyIWu#u{s3FK(rWL=`_4Oa=A1LnbIzF|i2iz zi~Zj+fF%G6{%^_uh2M=ZQo%F;^Z^(IFbrVC{~z?-mRK->TC`tO&u zpqd4(Spi@rfHeTd|LBp{C&u2}*tuf7+SETpqo}AsL;!Pr2NOU5gX<=VKn#G`PXz&B z5bApv^)>YyR-z7VQvDTkeV4zKz+jd+ty}d^Ad2tn{xFE^r-A@t29v*InU|NkXkVIf zQ)efZ_Wk6E&WiwM0Gt7E0l+1%O`$aaK;?xq1Yk9Q8*Y81b>F%V_kXH?q%jsdOjLK& zcQ4*v_eKpybvVo$g+V3%)fctANwi$G3E!@KsNcl}?Gn)mg6giE%h2IMCz>rfat#f~cpCC#Lt zYUK+vUUrad2JP=PU-A{b0Eamxuh{@*f4R8#l?N|80bmNitT(}>hW9B0UUN3?dS>O9 zSKre25dy`VYsm-A0Eo$(0;##Nclh~+bb-|S&=%EgDP^Xp(DidDw9V>CtTh6$9}F>w zx?Qs3XX$DEu8P+Tu5I3U{cZglr@njXAb`u>c`pZtJPhFaTmNq4bL&4i@JZ-_vTe+$ zc@O|AMKOXRB`O&4nPG5&M&_GF14sQj{(q{uNVG|Nv_^k5IJCa%ocz(kF938a4+4i*ZR_7bUi#z+ za8#QNdta`#$;s?f{I4`Zn0l$ zwK;{g$JMTZmDa{dXFZ0>d>-4@ztbyDUqH))E7mkNGm9gxTdV37C0hbWaE9?!9s;mc zoM?vR2SflfMK1)lzJ^)A1bRG!)RM*?3u#{%oqt@hD!_4sUqI!tnsO8VwPH;TAebjV0F+AngwuD6pqJaELbUm zP)ACZEEDe714?C3j-tCFg%j><)0+9lWVX@`7l*s_% zs-$M$KZKlMksyrP*>l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apJFNw zj8qCoCp5zr2vh55JfCc*;1ZH1SNWOYeCKckizzGsg zXi9upxOUh=P})@_MdyeEhTr_cPR11%_Rue`1kIOX(xw7JLw)T-h)gk3Q0uybl^=xO zjtvveq%=h4v5_v&B2E7^0*5ZKu~92{Rjwme8+W#ATO}_90qBlc*t@ z8l+3mo)o6g0Vf^TQ>7(l8>ROjL^4<}a8hO$quQ+EQAB2MnRsF3_4Ulg?TXO!4o1Br zi2agDFsHF+&Yxe0 zLRjq?%L9RS3FUHNE3HgTc0%QYrvjYHLXZU^NUDlr8KJbiJipY2KgXl#B{hHP!op<# zU~?=J2nr;Xt^cXjp|WK`%r*>U22vULV1}iNEA_09nKU-}7A^_I06|5)!y-h5T}U2U zbk8qL!JoWPp*~@tGkdi2s!r2V0@c%McJ2JwyiZh`)vjX|ZeVYYoK=63)BrFdEs5I< z%$9WxaJ#j9+uN!Y7$_SnUJs857h3<8>a^|{wyT%2D%n;!rm9oDg2 zju=MbIqXQdn#(u67(to%j1msCkR%orVncA2$C2K)uImV5d-5zPUlybu&C5S;p}TZ$ z-*a!g2w)Dt<;t7bMF2C$4xRartn*H0!0w}0{zvVy$#()#GV2ugPQ(dNVN%jU15Dry zYQF}lI2CKbI2(`)d+ez&8RSUq)2Q2;K6K`J)W_vqgg@LQn(XmIXO3OJZERC(<=_^x z7lJ$kM-`W83as2)6REuv(dBq8p~3FRp|+D9x1nDyxl;h+Je&ko3fM@|kW;be0O**KIwy~UK)1fq&`KS{D%Crw0B5*JEV^@fq1tt}G3i9`ZH>IpnPcIpnQbh^oC4UO`Gr zu!p?Od52s)Done Send email Get directions + Google Shopper Send MMS OK Open browser Product Search - Search book contents + Search contents Browse book Application Bookmark @@ -65,6 +66,8 @@ Could not generate the requested barcode. Could not encode a barcode from the data provided. Generating a barcode\u2026 + Google Shopper is not installed + Google Shopper is a new Android app with prices, reviews, and more. Would you like to install it from Market? Sorry, the requested application could not be launched. The barcode contents may be invalid. Loading list of applications\u2026 You are leaving this application. The search results you will see are not related to this application. @@ -100,10 +103,10 @@ Found URL History Clear history - Send history + Send history Barcode Scanner history Google Book Search Share via barcode Barcode Scanner v http://code.google.com/p/zxing - \ No newline at end of file + diff --git a/android/src/com/google/zxing/client/android/result/ISBNResultHandler.java b/android/src/com/google/zxing/client/android/result/ISBNResultHandler.java index bd80a2607..11f309202 100644 --- a/android/src/com/google/zxing/client/android/result/ISBNResultHandler.java +++ b/android/src/com/google/zxing/client/android/result/ISBNResultHandler.java @@ -16,15 +16,16 @@ package com.google.zxing.client.android.result; +import com.google.zxing.client.android.PreferencesActivity; +import com.google.zxing.client.android.R; +import com.google.zxing.client.result.ISBNParsedResult; +import com.google.zxing.client.result.ParsedResult; + import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.SharedPreferences; import android.preference.PreferenceManager; -import com.google.zxing.client.android.PreferencesActivity; -import com.google.zxing.client.android.R; -import com.google.zxing.client.result.ISBNParsedResult; -import com.google.zxing.client.result.ParsedResult; /** * Handles books encoded by their ISBN values. @@ -36,25 +37,31 @@ public final class ISBNResultHandler extends ResultHandler { R.string.button_product_search, R.string.button_book_search, R.string.button_search_book_contents, - R.string.button_custom_product_search, + R.string.button_google_shopper }; - private final String customProductSearch; + private String customProductSearch; public ISBNResultHandler(Activity activity, ParsedResult result) { super(activity, result); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH, null); + if (customProductSearch != null && customProductSearch.length() == 0) { + customProductSearch = null; + } } @Override public int getButtonCount() { - return customProductSearch != null && customProductSearch.length() > 0 ? buttons.length : buttons - .length - 1; + // Always show four buttons - Shopper and Custom Search are mutually exclusive. + return buttons.length; } @Override public int getButtonText(int index) { + if (index == buttons.length - 1 && customProductSearch != null) { + return R.string.button_custom_product_search; + } return buttons[index]; } @@ -74,8 +81,12 @@ public final class ISBNResultHandler extends ResultHandler { searchBookContents(isbnResult.getISBN()); break; case 3: - String url = customProductSearch.replace("%s", isbnResult.getISBN()); - openURL(url); + if (customProductSearch != null) { + String url = customProductSearch.replace("%s", isbnResult.getISBN()); + openURL(url); + } else { + openGoogleShopper(isbnResult.getISBN()); + } break; } } diff --git a/android/src/com/google/zxing/client/android/result/ProductResultHandler.java b/android/src/com/google/zxing/client/android/result/ProductResultHandler.java index 1c58da640..916d8d973 100644 --- a/android/src/com/google/zxing/client/android/result/ProductResultHandler.java +++ b/android/src/com/google/zxing/client/android/result/ProductResultHandler.java @@ -16,15 +16,16 @@ package com.google.zxing.client.android.result; +import com.google.zxing.client.android.PreferencesActivity; +import com.google.zxing.client.android.R; +import com.google.zxing.client.result.ParsedResult; +import com.google.zxing.client.result.ProductParsedResult; + import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.SharedPreferences; import android.preference.PreferenceManager; -import com.google.zxing.client.android.PreferencesActivity; -import com.google.zxing.client.android.R; -import com.google.zxing.client.result.ParsedResult; -import com.google.zxing.client.result.ProductParsedResult; /** * Handles generic products which are not books. @@ -35,15 +36,19 @@ public final class ProductResultHandler extends ResultHandler { private static final int[] buttons = { R.string.button_product_search, R.string.button_web_search, + R.string.button_google_shopper, R.string.button_custom_product_search, }; - private final String customProductSearch; + private String customProductSearch; public ProductResultHandler(Activity activity, ParsedResult result) { super(activity, result); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH, null); + if (customProductSearch != null && customProductSearch.length() == 0) { + customProductSearch = null; + } } @Override @@ -69,6 +74,9 @@ public final class ProductResultHandler extends ResultHandler { webSearch(productResult.getNormalizedProductID()); break; case 2: + openGoogleShopper(productResult.getNormalizedProductID()); + break; + case 3: String url = customProductSearch.replace("%s", productResult.getNormalizedProductID()); openURL(url); break; diff --git a/android/src/com/google/zxing/client/android/result/ResultHandler.java b/android/src/com/google/zxing/client/android/result/ResultHandler.java index 13bae1551..42b6b7a14 100644 --- a/android/src/com/google/zxing/client/android/result/ResultHandler.java +++ b/android/src/com/google/zxing/client/android/result/ResultHandler.java @@ -16,14 +16,6 @@ package com.google.zxing.client.android.result; -import android.app.Activity; -import android.app.AlertDialog; -import android.content.ActivityNotFoundException; -import android.content.Intent; -import android.content.SharedPreferences; -import android.net.Uri; -import android.preference.PreferenceManager; -import android.provider.Contacts; import com.google.zxing.client.android.Contents; import com.google.zxing.client.android.Intents; import com.google.zxing.client.android.LocaleManager; @@ -33,6 +25,18 @@ import com.google.zxing.client.android.book.SearchBookContentsActivity; import com.google.zxing.client.result.ParsedResult; import com.google.zxing.client.result.ParsedResultType; +import android.app.Activity; +import android.app.AlertDialog; +import android.app.SearchManager; +import android.content.ActivityNotFoundException; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.SharedPreferences; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.preference.PreferenceManager; +import android.provider.Contacts; + import java.text.DateFormat; import java.text.ParsePosition; import java.text.SimpleDateFormat; @@ -54,11 +58,26 @@ public abstract class ResultHandler { private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMdd"); private static final DateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HHmmss"); + private static final String GOOGLE_SHOPPER_PACKAGE = "com.google.android.apps.shopper"; + private static final String GOOGLE_SHOPPER_ACTIVITY = GOOGLE_SHOPPER_PACKAGE + + ".results.SearchResultsActivity"; + private static final String MARKET_URI_PREFIX = "market://search?q=pname:"; + private static final String MARKET_REFERRER_SUFFIX = + "&referrer=utm_source%3Dbarcodescanner%26utm_medium%3Dapps%26utm_campaign%3Dscan"; + public static final int MAX_BUTTON_COUNT = 4; private final ParsedResult result; private final Activity activity; + private final DialogInterface.OnClickListener shopperMarketListener = + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialogInterface, int which) { + launchIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(MARKET_URI_PREFIX + + GOOGLE_SHOPPER_PACKAGE + MARKET_REFERRER_SUFFIX))); + } + }; + ResultHandler(Activity activity, ParsedResult result) { this.result = result; this.activity = activity; @@ -298,14 +317,34 @@ public abstract class ResultHandler { launchIntent(intent); } + final void openGoogleShopper(String query) { + try { + activity.getPackageManager().getPackageInfo(GOOGLE_SHOPPER_PACKAGE, 0); + // If we didn't throw, Shopper is installed, so launch it. + Intent intent = new Intent(Intent.ACTION_SEARCH); + intent.setClassName(GOOGLE_SHOPPER_PACKAGE, GOOGLE_SHOPPER_ACTIVITY); + intent.putExtra(SearchManager.QUERY, query); + activity.startActivity(intent); + } catch (PackageManager.NameNotFoundException e) { + // Otherwise offer to install it from Market. + AlertDialog.Builder builder = new AlertDialog.Builder(activity); + builder.setTitle(R.string.msg_google_shopper_missing); + builder.setMessage(R.string.msg_install_google_shopper); + builder.setIcon(R.drawable.shopper_icon); + builder.setPositiveButton(R.string.button_ok, shopperMarketListener); + builder.setNegativeButton(R.string.button_cancel, null); + builder.show(); + } + } + void launchIntent(Intent intent) { if (intent != null) { try { activity.startActivity(intent); } catch (ActivityNotFoundException e) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); - builder.setTitle(activity.getString(R.string.app_name)); - builder.setMessage(activity.getString(R.string.msg_intent_failed)); + builder.setTitle(R.string.app_name); + builder.setMessage(R.string.msg_intent_failed); builder.setPositiveButton(R.string.button_ok, null); builder.show(); }