+ // Put up our own UI for how to handle the decoded contents.
+ private void handleDecodeInternally(Result rawResult, Bitmap barcode) {
+ statusView.setVisibility(View.GONE);
+ viewfinderView.setVisibility(View.GONE);
+ resultView.setVisibility(View.VISIBLE);
+
+ ImageView barcodeImageView = (ImageView) findViewById(R.id.barcode_image_view);
+ if (barcode == null) {
+ barcodeImageView.setImageResource(R.drawable.zxing_icon);
+ } else {
+ barcodeImageView.setImageBitmap(barcode);
+ }
+ barcodeImageView.setVisibility(View.VISIBLE);
+
+ TextView formatTextView = (TextView) findViewById(R.id.format_text_view);
+ formatTextView.setVisibility(View.VISIBLE);
+ formatTextView.setText(getString(R.string.msg_default_format) + ": " +
+ rawResult.getBarcodeFormat().toString());
+
+ ResultHandler resultHandler = ResultHandlerFactory.makeResultHandler(this, rawResult);
+ TextView typeTextView = (TextView) findViewById(R.id.type_text_view);
+ typeTextView.setVisibility(View.VISIBLE);
+ typeTextView.setText(getString(R.string.msg_default_type) + ": " +
+ resultHandler.getType().toString());
+
+ DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
+ String formattedTime = formatter.format(new Date(rawResult.getTimestamp()));
+ TextView timeTextView = (TextView) findViewById(R.id.time_text_view);
+ timeTextView.setVisibility(View.VISIBLE);
+ timeTextView.setText(getString(R.string.msg_default_time) + ": " + formattedTime);
+
+ TextView contentsTextView = (TextView) findViewById(R.id.contents_text_view);
+ CharSequence title = getString(resultHandler.getDisplayTitle());
+ SpannableStringBuilder styled = new SpannableStringBuilder(title + "\n\n");
+ styled.setSpan(new UnderlineSpan(), 0, title.length(), 0);
+ CharSequence displayContents = resultHandler.getDisplayContents();
+ styled.append(displayContents);
+ contentsTextView.setText(styled);
+
+ int buttonCount = resultHandler.getButtonCount();
+ ViewGroup buttonView = (ViewGroup) findViewById(R.id.result_button_view);
+ buttonView.requestFocus();
+ for (int x = 0; x < ResultHandler.MAX_BUTTON_COUNT; x++) {
+ TextView button = (TextView) buttonView.getChildAt(x);
+ if (x < buttonCount) {
+ button.setVisibility(View.VISIBLE);
+ button.setText(resultHandler.getButtonText(x));
+ button.setOnClickListener(new ResultButtonListener(resultHandler, x));
+ } else {
+ button.setVisibility(View.GONE);
+ }
+ }
+
+ if (copyToClipboard) {
+ ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
+ clipboard.setText(displayContents);
+ }
+ }
+
+ // Briefly show the contents of the barcode, then handle the result outside Barcode Scanner.
+ private void handleDecodeExternally(Result rawResult, Bitmap barcode) {
+ viewfinderView.drawResultBitmap(barcode);