mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 02:35:20 +00:00
fix #4720
This commit is contained in:
parent
aee2d8e120
commit
e5e3ac0364
8 changed files with 18 additions and 103 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
from kivy.uix.widget import Widget
|
||||||
|
from kivy.properties import ObjectProperty
|
||||||
|
|
||||||
__all__ = ('NFCBase', 'NFCScanner')
|
__all__ = ('NFCBase', 'NFCScanner')
|
||||||
|
|
||||||
class NFCBase(Widget):
|
class NFCBase(Widget):
|
||||||
|
|
|
@ -117,8 +117,8 @@ class ScannerAndroid(NFCBase):
|
||||||
recTypes = []
|
recTypes = []
|
||||||
for record in ndefrecords:
|
for record in ndefrecords:
|
||||||
recTypes.append({
|
recTypes.append({
|
||||||
'type': ''.join(map(unichr, record.getType())),
|
'type': ''.join(map(chr, record.getType())),
|
||||||
'payload': ''.join(map(unichr, record.getPayload()))
|
'payload': ''.join(map(chr, record.getPayload()))
|
||||||
})
|
})
|
||||||
|
|
||||||
details['recTypes'] = recTypes
|
details['recTypes'] = recTypes
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
from . import NFCBase
|
from . import NFCBase
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
from kivy.logger import Logger
|
from kivy.logger import Logger
|
||||||
|
from kivy.app import App
|
||||||
|
|
||||||
class ScannerDummy(NFCBase):
|
class ScannerDummy(NFCBase):
|
||||||
'''This is the dummy interface that gets selected in case any other
|
'''This is the dummy interface that gets selected in case any other
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
class NFCTransactionDialog(AnimatedPopup):
|
from kivy.properties import ObjectProperty, OptionProperty
|
||||||
|
from kivy.factory import Factory
|
||||||
|
|
||||||
|
|
||||||
|
class NFCTransactionDialog(Factory.AnimatedPopup):
|
||||||
|
|
||||||
mode = OptionProperty('send', options=('send','receive'))
|
mode = OptionProperty('send', options=('send','receive'))
|
||||||
|
|
||||||
|
@ -19,14 +23,14 @@ class NFCTransactionDialog(AnimatedPopup):
|
||||||
sctr = self.ids.sctr
|
sctr = self.ids.sctr
|
||||||
if value:
|
if value:
|
||||||
def _cmp(*l):
|
def _cmp(*l):
|
||||||
anim = Animation(rotation=2, scale=1, opacity=1)
|
anim = Factory.Animation(rotation=2, scale=1, opacity=1)
|
||||||
anim.start(sctr)
|
anim.start(sctr)
|
||||||
anim.bind(on_complete=_start)
|
anim.bind(on_complete=_start)
|
||||||
|
|
||||||
def _start(*l):
|
def _start(*l):
|
||||||
anim = Animation(rotation=350, scale=2, opacity=0)
|
anim = Factory.Animation(rotation=350, scale=2, opacity=0)
|
||||||
anim.start(sctr)
|
anim.start(sctr)
|
||||||
anim.bind(on_complete=_cmp)
|
anim.bind(on_complete=_cmp)
|
||||||
_start()
|
_start()
|
||||||
return
|
return
|
||||||
Animation.cancel_all(sctr)
|
Factory.Animation.cancel_all(sctr)
|
||||||
|
|
|
@ -10,6 +10,7 @@ from kivy.factory import Factory
|
||||||
from kivy.properties import OptionProperty, NumericProperty, ObjectProperty
|
from kivy.properties import OptionProperty, NumericProperty, ObjectProperty
|
||||||
from kivy.clock import Clock
|
from kivy.clock import Clock
|
||||||
from kivy.lang import Builder
|
from kivy.lang import Builder
|
||||||
|
from kivy.logger import Logger
|
||||||
|
|
||||||
import gc
|
import gc
|
||||||
|
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
from functools import partial
|
|
||||||
|
|
||||||
from kivy.animation import Animation
|
|
||||||
from kivy.core.window import Window
|
|
||||||
from kivy.clock import Clock
|
|
||||||
from kivy.uix.bubble import Bubble, BubbleButton
|
|
||||||
from kivy.properties import ListProperty
|
|
||||||
from kivy.uix.widget import Widget
|
|
||||||
|
|
||||||
from ..i18n import _
|
|
||||||
|
|
||||||
class ContextMenuItem(Widget):
|
|
||||||
'''abstract class
|
|
||||||
'''
|
|
||||||
|
|
||||||
class ContextButton(ContextMenuItem, BubbleButton):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class ContextMenu(Bubble):
|
|
||||||
|
|
||||||
buttons = ListProperty([_('ok'), _('cancel')])
|
|
||||||
'''List of Buttons to be displayed at the bottom'''
|
|
||||||
|
|
||||||
__events__ = ('on_press', 'on_release')
|
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
|
||||||
self._old_buttons = self.buttons
|
|
||||||
super(ContextMenu, self).__init__(**kwargs)
|
|
||||||
self.on_buttons(self, self.buttons)
|
|
||||||
|
|
||||||
def on_touch_down(self, touch):
|
|
||||||
if not self.collide_point(*touch.pos):
|
|
||||||
self.hide()
|
|
||||||
return
|
|
||||||
return super(ContextMenu, self).on_touch_down(touch)
|
|
||||||
|
|
||||||
def on_buttons(self, _menu, value):
|
|
||||||
if 'menu_content' not in self.ids.keys():
|
|
||||||
return
|
|
||||||
if value == self._old_buttons:
|
|
||||||
return
|
|
||||||
blayout = self.ids.menu_content
|
|
||||||
blayout.clear_widgets()
|
|
||||||
for btn in value:
|
|
||||||
ib = ContextButton(text=btn)
|
|
||||||
ib.bind(on_press=partial(self.dispatch, 'on_press'))
|
|
||||||
ib.bind(on_release=partial(self.dispatch, 'on_release'))
|
|
||||||
blayout.add_widget(ib)
|
|
||||||
self._old_buttons = value
|
|
||||||
|
|
||||||
def on_press(self, instance):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def on_release(self, instance):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def show(self, pos, duration=0):
|
|
||||||
Window.add_widget(self)
|
|
||||||
# wait for the bubble to adjust it's size according to text then animate
|
|
||||||
Clock.schedule_once(lambda dt: self._show(pos, duration))
|
|
||||||
|
|
||||||
def _show(self, pos, duration):
|
|
||||||
def on_stop(*l):
|
|
||||||
if duration:
|
|
||||||
Clock.schedule_once(self.hide, duration + .5)
|
|
||||||
|
|
||||||
self.opacity = 0
|
|
||||||
arrow_pos = self.arrow_pos
|
|
||||||
if arrow_pos[0] in ('l', 'r'):
|
|
||||||
pos = pos[0], pos[1] - (self.height/2)
|
|
||||||
else:
|
|
||||||
pos = pos[0] - (self.width/2), pos[1]
|
|
||||||
|
|
||||||
self.limit_to = Window
|
|
||||||
|
|
||||||
anim = Animation(opacity=1, pos=pos, d=.32)
|
|
||||||
anim.bind(on_complete=on_stop)
|
|
||||||
anim.cancel_all(self)
|
|
||||||
anim.start(self)
|
|
||||||
|
|
||||||
|
|
||||||
def hide(self, *dt):
|
|
||||||
|
|
||||||
def on_stop(*l):
|
|
||||||
Window.remove_widget(self)
|
|
||||||
anim = Animation(opacity=0, d=.25)
|
|
||||||
anim.bind(on_complete=on_stop)
|
|
||||||
anim.cancel_all(self)
|
|
||||||
anim.start(self)
|
|
||||||
|
|
||||||
def add_widget(self, widget, index=0):
|
|
||||||
if not isinstance(widget, ContextMenuItem):
|
|
||||||
super(ContextMenu, self).add_widget(widget, index)
|
|
||||||
return
|
|
||||||
menu_content.add_widget(widget, index)
|
|
|
@ -370,8 +370,7 @@ def verify_cert_chain(chain):
|
||||||
hashBytes = bytearray(hashlib.sha512(data).digest())
|
hashBytes = bytearray(hashlib.sha512(data).digest())
|
||||||
verify = pubkey.verify(sig, x509.PREFIX_RSA_SHA512 + hashBytes)
|
verify = pubkey.verify(sig, x509.PREFIX_RSA_SHA512 + hashBytes)
|
||||||
else:
|
else:
|
||||||
raise Exception("Algorithm not supported")
|
raise Exception("Algorithm not supported: {}".format(algo))
|
||||||
util.print_error(self.error, algo.getComponentByName('algorithm'))
|
|
||||||
if not verify:
|
if not verify:
|
||||||
raise Exception("Certificate not Signed by Provided CA Certificate Chain")
|
raise Exception("Certificate not Signed by Provided CA Certificate Chain")
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
# A simple script that connects to a server and displays block headers
|
# A simple script that connects to a server and displays block headers
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
import sys
|
||||||
|
|
||||||
from .. import SimpleConfig, Network
|
from .. import SimpleConfig, Network
|
||||||
from electrum.util import print_msg, json_encode
|
from electrum.util import print_msg, json_encode
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue