import com.google.zxing.BarcodeFormat;
import com.google.zxing.Result;
import com.google.zxing.ResultPoint;
+import com.google.zxing.client.android.camera.CameraManager;
import com.google.zxing.client.android.history.HistoryManager;
import com.google.zxing.client.android.result.ResultButtonListener;
import com.google.zxing.client.android.result.ResultHandler;
PRODUCT_FORMATS.add(BarcodeFormat.UPC_E);
PRODUCT_FORMATS.add(BarcodeFormat.EAN_13);
PRODUCT_FORMATS.add(BarcodeFormat.EAN_8);
- //PRODUCT_FORMATS.add(BarcodeFormat.RSS14);
+ PRODUCT_FORMATS.add(BarcodeFormat.RSS14);
ONE_D_FORMATS = new Vector<BarcodeFormat>(PRODUCT_FORMATS.size() + 3);
ONE_D_FORMATS.addAll(PRODUCT_FORMATS);
ONE_D_FORMATS.add(BarcodeFormat.CODE_39);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
playBeep = prefs.getBoolean(PreferencesActivity.KEY_PLAY_BEEP, true);
+ if (playBeep) {
+ // See if sound settings overrides this
+ AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
+ if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
+ playBeep = false;
+ }
+ }
vibrate = prefs.getBoolean(PreferencesActivity.KEY_VIBRATE, false);
copyToClipboard = prefs.getBoolean(PreferencesActivity.KEY_COPY_TO_CLIPBOARD, true);
initBeepSound();
}
private static Vector<BarcodeFormat> parseDecodeFormats(Intent intent) {
- return parseDecodeFormats(
- Arrays.asList(COMMA_PATTERN.split(intent.getStringExtra(Intents.Scan.SCAN_FORMATS))),
- intent.getStringExtra(Intents.Scan.MODE));
+ List<String> scanFormats = null;
+ String scanFormatsString = intent.getStringExtra(Intents.Scan.SCAN_FORMATS);
+ if (scanFormatsString != null) {
+ scanFormats = Arrays.asList(COMMA_PATTERN.split(scanFormatsString));
+ }
+ return parseDecodeFormats(scanFormats, intent.getStringExtra(Intents.Scan.MODE));
}
-
+
private static Vector<BarcodeFormat> parseDecodeFormats(Uri inputUri) {
List<String> formats = inputUri.getQueryParameters(Intents.Scan.SCAN_FORMATS);
- if (formats.size() == 1){
+ if (formats != null && formats.size() == 1 && formats.get(0) != null){
formats = Arrays.asList(COMMA_PATTERN.split(formats.get(0)));
}
return parseDecodeFormats(formats, inputUri.getQueryParameter(Intents.Scan.MODE));
}
-
+
private static Vector<BarcodeFormat> parseDecodeFormats(List<String> scanFormats,
String decodeMode) {
if (scanFormats != null) {
resultHandler.getDisplayContents().toString() + "&source=zxing";
handler.sendMessageDelayed(message, INTENT_RESULT_DURATION);
} else if (source == Source.ZXING_LINK) {
- // Replace each occurrence of RETURN_CODE_PLACEHOLDER in the returnUrlTemplate
- // with the scanned code. This allows both queries and REST-style URLs to work.
+ // Replace each occurrence of RETURN_CODE_PLACEHOLDER in the returnUrlTemplate
+ // with the scanned code. This allows both queries and REST-style URLs to work.
Message message = Message.obtain(handler, R.id.launch_product_query);
message.obj = returnUrlTemplate.replace(RETURN_CODE_PLACEHOLDER, resultHandler.getDisplayContents().toString());
handler.sendMessageDelayed(message, INTENT_RESULT_DURATION);
} catch (RuntimeException e) {
// Barcode Scanner has seen crashes in the wild of this variety:
// java.?lang.?RuntimeException: Fail to connect to camera service
- Log.e(TAG, e.toString());
+ Log.w(TAG, "Unexpected error initializating camera", e);
displayFrameworkBugMessageAndExit();
return;
}