diff options
| author | dswitkin@google.com <dswitkin@google.com@59b500cc-1b3d-0410-9834-0bbf25fbcc57> | 2010-07-22 03:15:23 +0400 |
|---|---|---|
| committer | dswitkin@google.com <dswitkin@google.com@59b500cc-1b3d-0410-9834-0bbf25fbcc57> | 2010-07-22 03:15:23 +0400 |
| commit | 99b5974f44ed47bfded6b46ff989c1ecf8a09153 (patch) | |
| tree | 6c5c37dd8e3fdbe9b2b300c01aa28ed7fcd67869 | |
| parent | e8eaf3f8e65eb05e023a1f9a41b590aac6214c6e (diff) | |
| download | zxing-android-embedded-99b5974f44ed47bfded6b46ff989c1ecf8a09153.tar.xz | |
Added a Google Shopper icon to the result buton for products and ISBNs.
git-svn-id: http://zxing.googlecode.com/svn/trunk/android@1492 59b500cc-1b3d-0410-9834-0bbf25fbcc57
| -rwxr-xr-x | AndroidManifest.xml | 4 | ||||
| -rw-r--r-- | res/drawable-hdpi/shopper_icon.png | bin | 0 -> 6196 bytes | |||
| -rw-r--r-- | res/drawable/shopper_icon.png | bin | 4987 -> 2394 bytes | |||
| -rwxr-xr-x | res/layout-ldpi/capture.xml | 10 | ||||
| -rwxr-xr-x | res/layout/capture.xml | 9 | ||||
| -rwxr-xr-x | res/values/strings.xml | 4 | ||||
| -rw-r--r-- | src/com/google/zxing/client/android/result/ISBNResultHandler.java | 21 | ||||
| -rw-r--r-- | src/com/google/zxing/client/android/result/ProductResultHandler.java | 13 | ||||
| -rw-r--r-- | src/com/google/zxing/client/android/result/ResultHandler.java | 15 |
9 files changed, 55 insertions, 21 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index e746bb0c..c0f943dc 100755 --- a/AndroidManifest.xml +++ b/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. --> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.google.zxing.client.android" - android:versionName="3.4" - android:versionCode="58" + android:versionName="3.41 beta 1" + android:versionCode="59" android:installLocation="auto"> <!-- We require Cupcake (Android 1.5) or later, but are really targeting Donut. --> <uses-sdk android:minSdkVersion="3" diff --git a/res/drawable-hdpi/shopper_icon.png b/res/drawable-hdpi/shopper_icon.png Binary files differnew file mode 100644 index 00000000..09735588 --- /dev/null +++ b/res/drawable-hdpi/shopper_icon.png diff --git a/res/drawable/shopper_icon.png b/res/drawable/shopper_icon.png Binary files differindex 600b4280..be69c14b 100644 --- a/res/drawable/shopper_icon.png +++ b/res/drawable/shopper_icon.png diff --git a/res/layout-ldpi/capture.xml b/res/layout-ldpi/capture.xml index 821de2e3..c8dcb3fd 100755 --- a/res/layout-ldpi/capture.xml +++ b/res/layout-ldpi/capture.xml @@ -197,6 +197,16 @@ android:textSize="14sp" android:visibility="gone"/> + <Button android:id="@+id/shopper_button" + android:layout_width="0sp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:textSize="14sp" + android:drawableLeft="@drawable/shopper_icon" + android:drawablePadding="4dip" + android:text="@string/button_google_shopper" + android:visibility="gone"/> + </LinearLayout> </LinearLayout> diff --git a/res/layout/capture.xml b/res/layout/capture.xml index f79813a1..f8c60f9a 100755 --- a/res/layout/capture.xml +++ b/res/layout/capture.xml @@ -197,6 +197,15 @@ android:textSize="14sp" android:visibility="gone"/> + <Button android:id="@+id/shopper_button" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:textSize="14sp" + android:drawableLeft="@drawable/shopper_icon" + android:drawablePadding="4dip" + android:text="@string/button_google_shopper" + android:visibility="gone"/> + </LinearLayout> </LinearLayout> diff --git a/res/values/strings.xml b/res/values/strings.xml index 47f2b9ae..62014f22 100755 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -75,7 +75,7 @@ <string name="msg_encode_barcode_failed">Could not generate the requested barcode.</string> <string name="msg_encode_contents_failed">Could not encode a barcode from the data provided.</string> <string name="msg_google_shopper_missing">Google Shopper is not installed</string> - <string name="msg_install_google_shopper">Google Shopper combines barcode scanning with prices, reviews and more without opening the browser. Would you like to try it?</string> + <string name="msg_install_google_shopper">Google Shopper combines barcode scanning with online and local prices, reviews and more without opening the browser. Would you like to try it?</string> <string name="msg_intent_failed">Sorry, the requested application could not be launched. The barcode contents may be invalid.</string> <string name="msg_loading_apps">Loading list of applications\u2026</string> <string name="msg_not_our_results">You are leaving this application. The search results you will see are not related to this application.</string> @@ -126,7 +126,7 @@ <string name="wifi_modifying_network">Modifying Network</string> <string name="wifi_ssid_missing">Network name missing</string> <string name="wifi_type_incorrect">Network type incorrect</string> - <string name="wifi_connect_failed">Network connection failed</string> + <string name="wifi_connect_failed">Network connection failed</string> <string name="wifi_ssid_label">Network Name</string> <string name="wifi_type_label">Type</string> <string name="zxing_url">http://code.google.com/p/zxing</string> diff --git a/src/com/google/zxing/client/android/result/ISBNResultHandler.java b/src/com/google/zxing/client/android/result/ISBNResultHandler.java index c492a1ce..f5a3f5fa 100644 --- a/src/com/google/zxing/client/android/result/ISBNResultHandler.java +++ b/src/com/google/zxing/client/android/result/ISBNResultHandler.java @@ -24,6 +24,7 @@ import com.google.zxing.client.result.ParsedResult; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; +import android.view.View; /** * Handles books encoded by their ISBN values. @@ -35,24 +36,26 @@ 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_google_shopper + R.string.button_custom_product_search }; public ISBNResultHandler(Activity activity, ParsedResult result, Result rawResult) { super(activity, result, rawResult); + showGoogleShopperButton(new View.OnClickListener() { + public void onClick(View view) { + ISBNParsedResult isbnResult = (ISBNParsedResult) getResult(); + openGoogleShopper(isbnResult.getISBN()); + } + }); } @Override public int getButtonCount() { - // Always show four buttons - Shopper and Custom Search are mutually exclusive. - return buttons.length; + return hasCustomProductSearch() ? buttons.length : buttons.length - 1; } @Override public int getButtonText(int index) { - if (index == buttons.length - 1 && hasCustomProductSearch()) { - return R.string.button_custom_product_search; - } return buttons[index]; } @@ -72,11 +75,7 @@ public final class ISBNResultHandler extends ResultHandler { searchBookContents(isbnResult.getISBN()); break; case 3: - if (hasCustomProductSearch()) { - openURL(fillInCustomSearchURL(isbnResult.getISBN())); - } else { - openGoogleShopper(isbnResult.getISBN()); - } + openURL(fillInCustomSearchURL(isbnResult.getISBN())); break; } } diff --git a/src/com/google/zxing/client/android/result/ProductResultHandler.java b/src/com/google/zxing/client/android/result/ProductResultHandler.java index 21369778..5cde7791 100644 --- a/src/com/google/zxing/client/android/result/ProductResultHandler.java +++ b/src/com/google/zxing/client/android/result/ProductResultHandler.java @@ -24,6 +24,7 @@ import com.google.zxing.client.result.ProductParsedResult; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; +import android.view.View; /** * Handles generic products which are not books. @@ -34,12 +35,17 @@ 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, + R.string.button_custom_product_search }; public ProductResultHandler(Activity activity, ParsedResult result, Result rawResult) { super(activity, result, rawResult); + showGoogleShopperButton(new View.OnClickListener() { + public void onClick(View view) { + ProductParsedResult productResult = (ProductParsedResult) getResult(); + openGoogleShopper(productResult.getNormalizedProductID()); + } + }); } @Override @@ -65,9 +71,6 @@ public final class ProductResultHandler extends ResultHandler { webSearch(productResult.getNormalizedProductID()); break; case 2: - openGoogleShopper(productResult.getNormalizedProductID()); - break; - case 3: openURL(fillInCustomSearchURL(productResult.getNormalizedProductID())); break; } diff --git a/src/com/google/zxing/client/android/result/ResultHandler.java b/src/com/google/zxing/client/android/result/ResultHandler.java index db9e2352..3020dc55 100644 --- a/src/com/google/zxing/client/android/result/ResultHandler.java +++ b/src/com/google/zxing/client/android/result/ResultHandler.java @@ -39,6 +39,8 @@ import android.content.pm.PackageManager; import android.net.Uri; import android.preference.PreferenceManager; import android.provider.Contacts; +import android.view.View; +import android.widget.Button; import java.text.DateFormat; import java.text.ParsePosition; @@ -126,6 +128,17 @@ public abstract class ResultHandler { public abstract void handleButtonPress(int index); /** + * The Google Shopper button is special and is not handled by the abstract button methods above. + * + * @param listener The on click listener to install for this button. + */ + protected void showGoogleShopperButton(View.OnClickListener listener) { + Button shopperButton = (Button) activity.findViewById(R.id.shopper_button); + shopperButton.setVisibility(View.VISIBLE); + shopperButton.setOnClickListener(listener); + } + + /** * Create a possibly styled string for the contents of the current barcode. * * @return The text to be displayed. @@ -161,7 +174,7 @@ public abstract class ResultHandler { * @param location a text description of the event location * @param description a text description of the event itself */ - final void addCalendarEvent(String summary, + final void addCalendarEvent(String summary, String start, String end, String location, |
