import android.app.Activity;
import android.content.Context;
+import android.content.Intent;
import android.graphics.PixelFormat;
import android.os.Bundle;
import android.os.Handler;
Context context = getApplication();
ParsedReaderResult readerResult = parseReaderResult(rawResult);
- Handler handler = new ResultHandler(this, readerResult);
- if (canBeHandled(readerResult.getType())) {
+ ResultHandler handler = new ResultHandler(this, readerResult);
+ if (handler.getIntent() != null) {
// Can be handled by some external app; ask if the user wants to
// proceed first though
Message yesMessage = handler.obtainMessage(R.string.button_yes);
}
private static ParsedReaderResult parseReaderResult(Result rawResult) {
- String rawText = rawResult.getText();
- ParsedReaderResult readerResult = ParsedReaderResult.parseReaderResult(rawText);
+ ParsedReaderResult readerResult = ParsedReaderResult.parseReaderResult(rawResult);
if (readerResult.getType().equals(ParsedReaderResultType.TEXT)) {
- ParsedReaderResult androidResult = AndroidIntentParsedResult.parse(rawText);
+ String rawText = rawResult.getText();
+ AndroidIntentParsedResult androidResult = AndroidIntentParsedResult.parse(rawText);
if (androidResult != null) {
- readerResult = androidResult;
+ Intent intent = androidResult.getIntent();
+ if (!Intent.VIEW_ACTION.equals(intent.getAction())) {
+ // For now, don't take anything that just parses as a View action. A lot
+ // of things are accepted as a View action by default.
+ readerResult = androidResult;
+ }
}
}
return readerResult;
}
- private static boolean canBeHandled(ParsedReaderResultType type) {
- return !type.equals(ParsedReaderResultType.TEXT);
- }
-
private static int getDialogTitleID(ParsedReaderResultType type) {
if (type.equals(ParsedReaderResultType.ADDRESSBOOK)) {
return R.string.title_add_contact;
return R.string.title_compose_email;
} else if (type.equals(ParsedReaderResultType.UPC)) {
return R.string.title_lookup_barcode;
+ } else if (type.equals(ParsedReaderResultType.TEL)) {
+ return R.string.title_dial;
} else {
return R.string.title_barcode_detected;
}