mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
Small updates and improvements to the Android client.
git-svn-id: https://zxing.googlecode.com/svn/trunk@577 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
d45123da9e
commit
db58d130a8
|
@ -21,6 +21,7 @@
|
|||
<string name="button_cancel">Cancel</string>
|
||||
<string name="button_dial">Dial</string>
|
||||
<string name="button_email">Email</string>
|
||||
<string name="button_lookup_book">Look up book</string>
|
||||
<string name="button_lookup_product">Look up product</string>
|
||||
<string name="button_ok">OK</string>
|
||||
<string name="button_open_browser">Open browser</string>
|
||||
|
|
|
@ -22,6 +22,7 @@ import android.content.DialogInterface;
|
|||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.AssetFileDescriptor;
|
||||
import android.content.res.Configuration;
|
||||
import android.media.MediaPlayer;
|
||||
import android.media.AudioManager;
|
||||
import android.media.MediaPlayer.OnCompletionListener;
|
||||
|
@ -169,6 +170,12 @@ public final class BarcodesCaptureActivity extends Activity implements SurfaceHo
|
|||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration config) {
|
||||
// Do nothing, this is to prevent the activity from being restarted when the keyboard opens.
|
||||
super.onConfigurationChanged(config);
|
||||
}
|
||||
|
||||
private final DialogInterface.OnClickListener mAboutListener = new DialogInterface.OnClickListener() {
|
||||
public void onClick(android.content.DialogInterface dialogInterface, int i) {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.zxing_url)));
|
||||
|
|
|
@ -35,6 +35,7 @@ import java.net.URI;
|
|||
public class QRCodeEncoder {
|
||||
|
||||
private static final String TAG = "QRCodeEncoder";
|
||||
private static final String CHART_SERVER_URL = "//chart.apis.google.com/chart?cht=qr&chs=";
|
||||
|
||||
private Activity mActivity;
|
||||
private String mContents;
|
||||
|
@ -151,12 +152,12 @@ public class QRCodeEncoder {
|
|||
}
|
||||
|
||||
public void run() {
|
||||
String url = "//chartserver.apis.google.com/chart?cht=qr&chs=";
|
||||
url += mPixelResolution + "x" + mPixelResolution + "&chl=" + mContents;
|
||||
String url = CHART_SERVER_URL + mPixelResolution + "x" + mPixelResolution + "&chl=" +
|
||||
mContents;
|
||||
try {
|
||||
URI uri = new URI("http", url, null);
|
||||
HttpGet get = new HttpGet(uri);
|
||||
AndroidHttpClient client = AndroidHttpClient.newInstance("Android-BarcodeScanner/0.1");
|
||||
AndroidHttpClient client = AndroidHttpClient.newInstance("Android-Barcodes/0.1");
|
||||
HttpResponse response = client.execute(get);
|
||||
HttpEntity entity = response.getEntity();
|
||||
Bitmap image = BitmapFactory.decodeStream(entity.getContent());
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.google.zxing.Result;
|
|||
import com.google.zxing.client.result.AddressBookParsedResult;
|
||||
import com.google.zxing.client.result.EmailAddressParsedResult;
|
||||
import com.google.zxing.client.result.GeoParsedResult;
|
||||
import com.google.zxing.client.result.ISBNParsedResult;
|
||||
import com.google.zxing.client.result.ParsedResult;
|
||||
import com.google.zxing.client.result.ParsedResultType;
|
||||
import com.google.zxing.client.result.ResultParser;
|
||||
|
@ -90,6 +91,8 @@ final class ResultHandler implements Button.OnClickListener {
|
|||
buttonText = R.string.button_dial;
|
||||
} else if (type.equals(ParsedResultType.GEO)) {
|
||||
buttonText = R.string.button_show_map;
|
||||
} else if (type.equals(ParsedResultType.ISBN)) {
|
||||
buttonText = R.string.button_lookup_book;
|
||||
} else {
|
||||
buttonText = 0;
|
||||
}
|
||||
|
@ -127,10 +130,12 @@ final class ResultHandler implements Button.OnClickListener {
|
|||
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(geoResult.getGeoURI()));
|
||||
} else if (type.equals(ParsedResultType.UPC)) {
|
||||
UPCParsedResult upcResult = (UPCParsedResult) result;
|
||||
// TODO: Add some UI to choose which product search to do
|
||||
//Uri uri = Uri.parse("http://www.upcdatabase.com/item.asp?upc=" + upcResult.getUPC());
|
||||
Uri uri = Uri.parse("http://www.google.com/products?q=" + upcResult.getUPC());
|
||||
intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
} else if (type.equals(ParsedResultType.ISBN)) {
|
||||
ISBNParsedResult isbnResult = (ISBNParsedResult) result;
|
||||
Uri uri = Uri.parse("http://www.google.com/products?q=" + isbnResult.getISBN());
|
||||
intent = new Intent(Intent.ACTION_VIEW, uri);
|
||||
} else if (type.equals(ParsedResultType.URI)) {
|
||||
URIParsedResult uriResult = (URIParsedResult) result;
|
||||
intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uriResult.getURI()));
|
||||
|
|
Loading…
Reference in a new issue