mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
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
This commit is contained in:
parent
6e680f000a
commit
8090bb441a
|
@ -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. -->
|
versionName is 2.31, 2.4, or 3.0. -->
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.google.zxing.client.android"
|
package="com.google.zxing.client.android"
|
||||||
android:versionName="3.11 alpha 1"
|
android:versionName="3.2 beta 1"
|
||||||
android:versionCode="43">
|
android:versionCode="44">
|
||||||
<!-- We require Cupcake (Android 1.5) or later, but are really targeting Donut. -->
|
<!-- We require Cupcake (Android 1.5) or later, but are really targeting Donut. -->
|
||||||
<uses-sdk android:minSdkVersion="3"
|
<uses-sdk android:minSdkVersion="3"
|
||||||
android:targetSdkVersion="4"/>
|
android:targetSdkVersion="4"/>
|
||||||
|
|
|
@ -3,17 +3,15 @@
|
||||||
<body>
|
<body>
|
||||||
<link rel="StyleSheet" href="style.css" type="text/css">
|
<link rel="StyleSheet" href="style.css" type="text/css">
|
||||||
<h3><center>What's new in this version</center></h3>
|
<h3><center>What's new in this version</center></h3>
|
||||||
<p>New in version 3.11:</p>
|
<p>New in version 3.2:</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Allowed devices without autofocus to see Barcode Scanner in the Market.</li>
|
<li>Allowed devices without autofocus to see Barcode Scanner in the Market.</li>
|
||||||
<li>Minor translation and bug fixes.</li>
|
<li>New Finnish, Dutch, and Czech translations.</li>
|
||||||
</ul>
|
<li>Added a Google Shopper button when scanning products.</li>
|
||||||
<p>New in version 3.1:</p>
|
<li>Fixed a possible crash on unsupported hardware.</li>
|
||||||
<ul>
|
<li>Better layouts on QVGA devices like the HTC Tattoo.</li>
|
||||||
<li>Added a real-time visualization of the image processing as it's looking for barcodes.</li>
|
<li>Added the ability to email your scan history.</li>
|
||||||
<li>Made QR Code reading in shadows or other difficult lighting dramatically better.</li>
|
<li>New high res icon and minor bug fixes.</li>
|
||||||
<li>Added sharing of any installed app by generating a QR Code that links to Market.</li>
|
|
||||||
<li>Many other minor improvements and bug fixes.</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
BIN
android/res/drawable/shopper_icon.png
Normal file
BIN
android/res/drawable/shopper_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
|
@ -29,11 +29,12 @@
|
||||||
<string name="button_done">Done</string>
|
<string name="button_done">Done</string>
|
||||||
<string name="button_email">Send email</string>
|
<string name="button_email">Send email</string>
|
||||||
<string name="button_get_directions">Get directions</string>
|
<string name="button_get_directions">Get directions</string>
|
||||||
|
<string name="button_google_shopper">Google Shopper</string>
|
||||||
<string name="button_mms">Send MMS</string>
|
<string name="button_mms">Send MMS</string>
|
||||||
<string name="button_ok">OK</string>
|
<string name="button_ok">OK</string>
|
||||||
<string name="button_open_browser">Open browser</string>
|
<string name="button_open_browser">Open browser</string>
|
||||||
<string name="button_product_search">Product Search</string>
|
<string name="button_product_search">Product Search</string>
|
||||||
<string name="button_search_book_contents">Search book contents</string>
|
<string name="button_search_book_contents">Search contents</string>
|
||||||
<string name="button_read_book">Browse book</string>
|
<string name="button_read_book">Browse book</string>
|
||||||
<string name="button_share_app">Application</string>
|
<string name="button_share_app">Application</string>
|
||||||
<string name="button_share_bookmark">Bookmark</string>
|
<string name="button_share_bookmark">Bookmark</string>
|
||||||
|
@ -65,6 +66,8 @@
|
||||||
<string name="msg_encode_barcode_failed">Could not generate the requested barcode.</string>
|
<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_encode_contents_failed">Could not encode a barcode from the data provided.</string>
|
||||||
<string name="msg_encode_in_progress">Generating a barcode\u2026</string>
|
<string name="msg_encode_in_progress">Generating a barcode\u2026</string>
|
||||||
|
<string name="msg_google_shopper_missing">Google Shopper is not installed</string>
|
||||||
|
<string name="msg_install_google_shopper">Google Shopper is a new Android app with prices, reviews, and more. Would you like to install it from Market?</string>
|
||||||
<string name="msg_intent_failed">Sorry, the requested application could not be launched. The barcode contents may be invalid.</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_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>
|
<string name="msg_not_our_results">You are leaving this application. The search results you will see are not related to this application.</string>
|
||||||
|
@ -100,10 +103,10 @@
|
||||||
<string name="result_uri">Found URL</string>
|
<string name="result_uri">Found URL</string>
|
||||||
<string name="history_title">History</string>
|
<string name="history_title">History</string>
|
||||||
<string name="history_clear_text">Clear history</string>
|
<string name="history_clear_text">Clear history</string>
|
||||||
<string name="history_send">Send history</string>
|
<string name="history_send">Send history</string>
|
||||||
<string name="history_email_title">Barcode Scanner history</string>
|
<string name="history_email_title">Barcode Scanner history</string>
|
||||||
<string name="sbc_name">Google Book Search</string>
|
<string name="sbc_name">Google Book Search</string>
|
||||||
<string name="share_name">Share via barcode</string>
|
<string name="share_name">Share via barcode</string>
|
||||||
<string name="title_about">Barcode Scanner v</string>
|
<string name="title_about">Barcode Scanner v</string>
|
||||||
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
<string name="zxing_url">http://code.google.com/p/zxing</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -16,15 +16,16 @@
|
||||||
|
|
||||||
package com.google.zxing.client.android.result;
|
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.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.preference.PreferenceManager;
|
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.
|
* 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_product_search,
|
||||||
R.string.button_book_search,
|
R.string.button_book_search,
|
||||||
R.string.button_search_book_contents,
|
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) {
|
public ISBNResultHandler(Activity activity, ParsedResult result) {
|
||||||
super(activity, result);
|
super(activity, result);
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||||
customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH, null);
|
customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH, null);
|
||||||
|
if (customProductSearch != null && customProductSearch.length() == 0) {
|
||||||
|
customProductSearch = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getButtonCount() {
|
public int getButtonCount() {
|
||||||
return customProductSearch != null && customProductSearch.length() > 0 ? buttons.length : buttons
|
// Always show four buttons - Shopper and Custom Search are mutually exclusive.
|
||||||
.length - 1;
|
return buttons.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getButtonText(int index) {
|
public int getButtonText(int index) {
|
||||||
|
if (index == buttons.length - 1 && customProductSearch != null) {
|
||||||
|
return R.string.button_custom_product_search;
|
||||||
|
}
|
||||||
return buttons[index];
|
return buttons[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,8 +81,12 @@ public final class ISBNResultHandler extends ResultHandler {
|
||||||
searchBookContents(isbnResult.getISBN());
|
searchBookContents(isbnResult.getISBN());
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
String url = customProductSearch.replace("%s", isbnResult.getISBN());
|
if (customProductSearch != null) {
|
||||||
openURL(url);
|
String url = customProductSearch.replace("%s", isbnResult.getISBN());
|
||||||
|
openURL(url);
|
||||||
|
} else {
|
||||||
|
openGoogleShopper(isbnResult.getISBN());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,15 +16,16 @@
|
||||||
|
|
||||||
package com.google.zxing.client.android.result;
|
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.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.preference.PreferenceManager;
|
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.
|
* Handles generic products which are not books.
|
||||||
|
@ -35,15 +36,19 @@ public final class ProductResultHandler extends ResultHandler {
|
||||||
private static final int[] buttons = {
|
private static final int[] buttons = {
|
||||||
R.string.button_product_search,
|
R.string.button_product_search,
|
||||||
R.string.button_web_search,
|
R.string.button_web_search,
|
||||||
|
R.string.button_google_shopper,
|
||||||
R.string.button_custom_product_search,
|
R.string.button_custom_product_search,
|
||||||
};
|
};
|
||||||
|
|
||||||
private final String customProductSearch;
|
private String customProductSearch;
|
||||||
|
|
||||||
public ProductResultHandler(Activity activity, ParsedResult result) {
|
public ProductResultHandler(Activity activity, ParsedResult result) {
|
||||||
super(activity, result);
|
super(activity, result);
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
|
||||||
customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH, null);
|
customProductSearch = prefs.getString(PreferencesActivity.KEY_CUSTOM_PRODUCT_SEARCH, null);
|
||||||
|
if (customProductSearch != null && customProductSearch.length() == 0) {
|
||||||
|
customProductSearch = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,6 +74,9 @@ public final class ProductResultHandler extends ResultHandler {
|
||||||
webSearch(productResult.getNormalizedProductID());
|
webSearch(productResult.getNormalizedProductID());
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
openGoogleShopper(productResult.getNormalizedProductID());
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
String url = customProductSearch.replace("%s", productResult.getNormalizedProductID());
|
String url = customProductSearch.replace("%s", productResult.getNormalizedProductID());
|
||||||
openURL(url);
|
openURL(url);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -16,14 +16,6 @@
|
||||||
|
|
||||||
package com.google.zxing.client.android.result;
|
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.Contents;
|
||||||
import com.google.zxing.client.android.Intents;
|
import com.google.zxing.client.android.Intents;
|
||||||
import com.google.zxing.client.android.LocaleManager;
|
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.ParsedResult;
|
||||||
import com.google.zxing.client.result.ParsedResultType;
|
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.DateFormat;
|
||||||
import java.text.ParsePosition;
|
import java.text.ParsePosition;
|
||||||
import java.text.SimpleDateFormat;
|
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_FORMAT = new SimpleDateFormat("yyyyMMdd");
|
||||||
private static final DateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
|
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;
|
public static final int MAX_BUTTON_COUNT = 4;
|
||||||
|
|
||||||
private final ParsedResult result;
|
private final ParsedResult result;
|
||||||
private final Activity activity;
|
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) {
|
ResultHandler(Activity activity, ParsedResult result) {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
|
@ -298,14 +317,34 @@ public abstract class ResultHandler {
|
||||||
launchIntent(intent);
|
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) {
|
void launchIntent(Intent intent) {
|
||||||
if (intent != null) {
|
if (intent != null) {
|
||||||
try {
|
try {
|
||||||
activity.startActivity(intent);
|
activity.startActivity(intent);
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||||
builder.setTitle(activity.getString(R.string.app_name));
|
builder.setTitle(R.string.app_name);
|
||||||
builder.setMessage(activity.getString(R.string.msg_intent_failed));
|
builder.setMessage(R.string.msg_intent_failed);
|
||||||
builder.setPositiveButton(R.string.button_ok, null);
|
builder.setPositiveButton(R.string.button_ok, null);
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue