|
|
@ -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') |
|
|
|
|
|
|
|