[SCM] Multi-format 1D/2D barcode image processing library branch, upstream, updated. 24d4480bc48cf9eabf7b2bd2f528248b0e458809
srowen
srowen at 59b500cc-1b3d-0410-9834-0bbf25fbcc57
Wed Aug 4 01:30:56 UTC 2010
The following commit has been merged in the upstream branch:
commit 53318db0aa32fc64659dac58ffea58265a8b3251
Author: srowen <srowen at 59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Date: Sat Apr 10 15:30:22 2010 +0000
Noticed we should just use BarcodeFormat constants in the client for simplicity
git-svn-id: http://zxing.googlecode.com/svn/trunk@1295 59b500cc-1b3d-0410-9834-0bbf25fbcc57
diff --git a/android/src/com/google/zxing/client/android/Contents.java b/android/src/com/google/zxing/client/android/Contents.java
index ddcb6b0..3080ecd 100755
--- a/android/src/com/google/zxing/client/android/Contents.java
+++ b/android/src/com/google/zxing/client/android/Contents.java
@@ -28,21 +28,6 @@ public final class Contents {
private Contents() {
}
- /**
- * All the formats we know about.
- */
- public static final class Format {
- public static final String UPC_A = "UPC_A";
- public static final String UPC_E = "UPC_E";
- public static final String EAN_8 = "EAN_8";
- public static final String EAN_13 = "EAN_13";
- public static final String CODE_39 = "CODE_39";
- public static final String CODE_128 = "CODE_128";
- public static final String QR_CODE = "QR_CODE";
- private Format() {
- }
- }
-
public static final class Type {
/**
* Plain text. Use Intent.putExtra(DATA, string). This can be used for URLs too, but string
diff --git a/android/src/com/google/zxing/client/android/encode/QRCodeEncoder.java b/android/src/com/google/zxing/client/android/encode/QRCodeEncoder.java
index 0a7a395..41f3c5b 100755
--- a/android/src/com/google/zxing/client/android/encode/QRCodeEncoder.java
+++ b/android/src/com/google/zxing/client/android/encode/QRCodeEncoder.java
@@ -106,9 +106,15 @@ final class QRCodeEncoder {
// but we use platform specific code like PhoneNumberUtils, so it can't.
private boolean encodeContentsFromZXingIntent(Intent intent) {
// Default to QR_CODE if no format given.
- String format = intent.getStringExtra(Intents.Encode.FORMAT);
- if (format == null || format.length() == 0 ||
- format.equals(Contents.Format.QR_CODE)) {
+ String formatString = intent.getStringExtra(Intents.Encode.FORMAT);
+ try {
+ format = BarcodeFormat.valueOf(formatString);
+ } catch (IllegalArgumentException iae) {
+ // Ignore it then
+ format = null;
+ formatString = null;
+ }
+ if (format == null || BarcodeFormat.QR_CODE.equals(format)) {
String type = intent.getStringExtra(Intents.Encode.TYPE);
if (type == null || type.length() == 0) {
return false;
@@ -121,19 +127,6 @@ final class QRCodeEncoder {
contents = data;
displayContents = data;
title = activity.getString(R.string.contents_text);
- if (format.equals(Contents.Format.CODE_128)) {
- this.format = BarcodeFormat.CODE_128;
- } else if (format.equals(Contents.Format.CODE_39)) {
- this.format = BarcodeFormat.CODE_39;
- } else if (format.equals(Contents.Format.EAN_8)) {
- this.format = BarcodeFormat.EAN_8;
- } else if (format.equals(Contents.Format.EAN_13)) {
- this.format = BarcodeFormat.EAN_13;
- } else if (format.equals(Contents.Format.UPC_A)) {
- this.format = BarcodeFormat.UPC_A;
- } else if (format.equals(Contents.Format.UPC_E)) {
- this.format = BarcodeFormat.UPC_E;
- }
}
}
return contents != null && contents.length() > 0;
diff --git a/android/src/com/google/zxing/client/android/share/ShareActivity.java b/android/src/com/google/zxing/client/android/share/ShareActivity.java
index 084f84c..5dd33b1 100755
--- a/android/src/com/google/zxing/client/android/share/ShareActivity.java
+++ b/android/src/com/google/zxing/client/android/share/ShareActivity.java
@@ -28,6 +28,7 @@ import android.provider.BaseColumns;
import android.text.ClipboardManager;
import android.view.View;
import android.widget.Button;
+import com.google.zxing.BarcodeFormat;
import com.google.zxing.client.android.Intents;
import com.google.zxing.client.android.Contents;
import com.google.zxing.client.android.R;
@@ -98,7 +99,7 @@ public final class ShareActivity extends Activity {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
intent.putExtra(Intents.Encode.DATA, clipboard.getText().toString());
- intent.putExtra(Intents.Encode.FORMAT, Contents.Format.QR_CODE);
+ intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
startActivity(intent);
}
}
@@ -151,7 +152,7 @@ public final class ShareActivity extends Activity {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.TEXT);
intent.putExtra(Intents.Encode.DATA, text);
- intent.putExtra(Intents.Encode.FORMAT, Contents.Format.QR_CODE);
+ intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
startActivity(intent);
}
@@ -220,7 +221,7 @@ public final class ShareActivity extends Activity {
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intents.Encode.TYPE, Contents.Type.CONTACT);
intent.putExtra(Intents.Encode.DATA, bundle);
- intent.putExtra(Intents.Encode.FORMAT, Contents.Format.QR_CODE);
+ intent.putExtra(Intents.Encode.FORMAT, BarcodeFormat.QR_CODE.toString());
startActivity(intent);
}
diff --git a/core/src/com/google/zxing/BarcodeFormat.java b/core/src/com/google/zxing/BarcodeFormat.java
index 9820c09..360baf7 100644
--- a/core/src/com/google/zxing/BarcodeFormat.java
+++ b/core/src/com/google/zxing/BarcodeFormat.java
@@ -78,6 +78,9 @@ public final class BarcodeFormat {
}
public static BarcodeFormat valueOf(String name) {
+ if (name == null || name.length() == 0) {
+ throw new IllegalArgumentException();
+ }
BarcodeFormat format = (BarcodeFormat) VALUES.get(name);
if (format == null) {
throw new IllegalArgumentException();
--
Multi-format 1D/2D barcode image processing library
More information about the Pkg-google-commits
mailing list