electrum

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

commit 584cc5d31f447de1f7675e658718d665e940a3b4
parent 37caf97ee9401b731bd87ed844fde3ec6e751eeb
Author: ThomasV <thomasv@electrum.org>
Date:   Tue,  8 Sep 2015 16:19:02 +0200

use zxing to scan qr codes

Diffstat:
Mgui/kivy/main_window.py | 22++++++++++++++++++++--
Mgui/kivy/uix/screens.py | 6+-----
2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/gui/kivy/main_window.py b/gui/kivy/main_window.py @@ -1,6 +1,8 @@ -import sys +import sys import datetime +from android import activity + from electrum import WalletStorage, Wallet from electrum.i18n import _, set_language from electrum.contacts import Contacts @@ -206,7 +208,7 @@ class ElectrumWindow(App): def set_url(self, instance, url): self.gui_object.set_url(url) - def scan_qr(self, on_complete): + def old_scan_qr(self, on_complete): dlg = Cache.get('electrum_widgets', 'QrScannerDialog') if not dlg: dlg = Factory.QrScannerDialog() @@ -214,6 +216,22 @@ class ElectrumWindow(App): dlg.bind(on_complete=on_complete) dlg.open() + def scan_qr(self, on_complete): + from jnius import autoclass + PythonActivity = autoclass('org.renpy.android.PythonActivity') + Intent = autoclass('android.content.Intent') + intent = Intent("com.google.zxing.client.android.SCAN") + intent.putExtra("SCAN_MODE", "QR_CODE_MODE") + 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': + uri = App.get_running_app().decode_uri(contents) + on_complete(uri) + activity.bind(on_activity_result=on_qr_result) + PythonActivity.mActivity.startActivityForResult(intent, 0) + def build(self): global Builder if not Builder: diff --git a/gui/kivy/uix/screens.py b/gui/kivy/uix/screens.py @@ -101,14 +101,10 @@ class MainScreen(Factory.Screen): class ScreenSend(CScreen): - def set_qr_data(self, dialog, uri): + def set_qr_data(self, uri): self.ids.payto_e.text = uri.get('address', '') self.ids.message_e.text = uri.get('message', '') self.ids.amount_e.text = uri.get('amount', '') - #label = uri.get('label') - #if label: - # TODO: update label, add to contacts - class ScreenReceive(CScreen): pass