electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 67145e053b5c71a5379411bbd2c83394329b5d65
parent dff138852ddd2f714040da9dd42c9ec4ec77e9ac
Author: ThomasV <thomasv@electrum.org>
Date:   Sat, 19 Mar 2016 17:00:37 +0100

scan qrcodes with zxing embedded

Diffstat:
Mgui/kivy/main_window.py | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)

diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py @@ -330,6 +330,26 @@ class ElectrumWindow(App): except: self.show_error(_('Could not start Barcode Scanner.') + ' ' + _('Please install the Barcode Scanner app from ZXing')) + def scan_qr_zxing(self, on_complete): + # uses zxing embedded lib + if platform != 'android': + return + from jnius import autoclass + from android import activity + PythonActivity = autoclass('org.renpy.android.PythonActivity') + IntentIntegrator = autoclass('com.google.zxing.integration.android.IntentIntegrator') + integrator = IntentIntegrator(PythonActivity.mActivity) + def on_qr_result(requestCode, resultCode, intent): + if requestCode == 0: + if resultCode == -1: # RESULT_OK: + contents = intent.getStringExtra("SCAN_RESULT") + if intent.getStringExtra("SCAN_RESULT_FORMAT") == 'QR_CODE': + on_complete(contents) + else: + self.show_error("wrong format " + intent.getStringExtra("SCAN_RESULT_FORMAT")) + activity.bind(on_activity_result=on_qr_result) + integrator.initiateScan() + def build(self): return Builder.load_file('gui/kivy/main.kv')