|
29 | 29 | import android.widget.Toast; |
30 | 30 | import com.google.bitcoin.core.InsufficientMoneyException; |
31 | 31 | import com.google.bitcoin.core.VerificationException; |
| 32 | +import com.google.zxing.integration.android.IntentIntegrator; |
| 33 | +import com.google.zxing.integration.android.IntentIntegratorSupportV4; |
| 34 | +import com.google.zxing.integration.android.IntentResult; |
32 | 35 | import org.litecoin.LitecoinWallet; |
33 | 36 | import org.slf4j.Logger; |
34 | 37 | import org.slf4j.LoggerFactory; |
@@ -642,33 +645,34 @@ private void restoreInstanceState(final Bundle savedInstanceState) |
642 | 645 | @Override |
643 | 646 | public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) |
644 | 647 | { |
645 | | - if (requestCode == REQUEST_CODE_SCAN) |
| 648 | + IntentResult scanResult = IntentIntegratorSupportV4.parseActivityResult(requestCode, resultCode, intent); |
| 649 | + |
| 650 | + if (scanResult != null) |
646 | 651 | { |
647 | | - if (resultCode == Activity.RESULT_OK) |
648 | | - { |
649 | | - final String input = intent.getStringExtra(ScanActivity.INTENT_EXTRA_RESULT); |
| 652 | + final String input = scanResult.getContents(); |
| 653 | + if(input == null) return; |
| 654 | + Log.d("Litecoin", "SCAN RESULT:" + input); |
650 | 655 |
|
651 | | - new StringInputParser(input) |
652 | | - { |
653 | | - @Override |
654 | | - protected void bitcoinRequest(final Address address, final String addressLabel, final BigInteger amount, final String bluetoothMac) |
655 | | - { |
656 | | - SendCoinsActivity.start(activity, address != null ? address.toString() : null, addressLabel, amount, bluetoothMac); |
657 | | - } |
| 656 | + new StringInputParser(input) |
| 657 | + { |
| 658 | + @Override |
| 659 | + protected void bitcoinRequest(final Address address, final String addressLabel, final BigInteger amount, final String bluetoothMac) |
| 660 | + { |
| 661 | + SendCoinsActivity.start(activity, address != null ? address.toString() : null, addressLabel, amount, bluetoothMac); |
| 662 | + } |
658 | 663 |
|
659 | | - @Override |
660 | | - protected void directTransaction(final Transaction transaction) |
661 | | - { |
662 | | - cannotClassify(input); |
663 | | - } |
| 664 | + @Override |
| 665 | + protected void directTransaction(final Transaction transaction) |
| 666 | + { |
| 667 | + cannotClassify(input); |
| 668 | + } |
664 | 669 |
|
665 | | - @Override |
666 | | - protected void error(final int messageResId, final Object... messageArgs) |
667 | | - { |
668 | | - dialog(activity, null, R.string.button_scan, messageResId, messageArgs); |
669 | | - } |
670 | | - }.parse(); |
671 | | - } |
| 670 | + @Override |
| 671 | + protected void error(final int messageResId, final Object... messageArgs) |
| 672 | + { |
| 673 | + dialog(activity, null, R.string.button_scan, messageResId, messageArgs); |
| 674 | + } |
| 675 | + }.parse(); |
672 | 676 | } |
673 | 677 | else if (requestCode == REQUEST_CODE_ENABLE_BLUETOOTH) |
674 | 678 | { |
@@ -960,7 +964,8 @@ protected void onFailure() |
960 | 964 |
|
961 | 965 | private void handleScan() |
962 | 966 | { |
963 | | - startActivityForResult(new Intent(activity, ScanActivity.class), REQUEST_CODE_SCAN); |
| 967 | + IntentIntegratorSupportV4 integrator = new IntentIntegratorSupportV4(this); |
| 968 | + integrator.initiateScan(); |
964 | 969 | } |
965 | 970 |
|
966 | 971 | private void handleEmpty() |
|
0 commit comments