mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 17:55:20 +00:00
kivy wizard: add space button
This commit is contained in:
parent
4d3ce06b6d
commit
83c68142e0
3 changed files with 18 additions and 8 deletions
|
@ -259,9 +259,10 @@ Builder.load_string('''
|
||||||
text: 'N'
|
text: 'N'
|
||||||
MButton:
|
MButton:
|
||||||
text: 'M'
|
text: 'M'
|
||||||
|
MButton:
|
||||||
|
text: ' '
|
||||||
MButton:
|
MButton:
|
||||||
text: '<'
|
text: '<'
|
||||||
size_hint: 2, None
|
|
||||||
|
|
||||||
GridLayout:
|
GridLayout:
|
||||||
rows: 1
|
rows: 1
|
||||||
|
@ -405,7 +406,7 @@ class RestoreSeedDialog(WizardDialog):
|
||||||
self.mnemonic = Mnemonic('en')
|
self.mnemonic = Mnemonic('en')
|
||||||
|
|
||||||
def on_text(self, dt):
|
def on_text(self, dt):
|
||||||
text = self.get_seed_text()
|
text = self.ids.text_input_seed.text
|
||||||
self.ids.next.disabled = not bool(self._test(text))
|
self.ids.next.disabled = not bool(self._test(text))
|
||||||
|
|
||||||
if not text:
|
if not text:
|
||||||
|
@ -415,20 +416,29 @@ class RestoreSeedDialog(WizardDialog):
|
||||||
else:
|
else:
|
||||||
last_word = text.split(' ')[-1]
|
last_word = text.split(' ')[-1]
|
||||||
|
|
||||||
|
enable_space = False
|
||||||
self.ids.suggestions.clear_widgets()
|
self.ids.suggestions.clear_widgets()
|
||||||
suggestions = [x for x in self.mnemonic.get_suggestions(last_word)]
|
suggestions = [x for x in self.mnemonic.get_suggestions(last_word)]
|
||||||
if suggestions and len(suggestions) < 10:
|
if suggestions and len(suggestions) < 10:
|
||||||
for w in suggestions:
|
for w in suggestions:
|
||||||
b = WordButton(text=w)
|
if w == last_word:
|
||||||
self.ids.suggestions.add_widget(b)
|
enable_space = True
|
||||||
|
else:
|
||||||
|
b = WordButton(text=w)
|
||||||
|
self.ids.suggestions.add_widget(b)
|
||||||
|
|
||||||
i = len(last_word)
|
i = len(last_word)
|
||||||
p = set([x[i] for x in suggestions])
|
p = set()
|
||||||
|
for x in suggestions:
|
||||||
|
if len(x)>i: p.add(x[i])
|
||||||
|
|
||||||
for line in [self.ids.line1, self.ids.line2, self.ids.line3]:
|
for line in [self.ids.line1, self.ids.line2, self.ids.line3]:
|
||||||
for c in line.children:
|
for c in line.children:
|
||||||
if isinstance(c, Button):
|
if isinstance(c, Button):
|
||||||
if c.text in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
|
if c.text in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
|
||||||
c.disabled = (c.text.lower() not in p) and p
|
c.disabled = (c.text.lower() not in p) and last_word
|
||||||
|
elif c.text == ' ':
|
||||||
|
c.disabled = not enable_space
|
||||||
|
|
||||||
def on_word(self, w):
|
def on_word(self, w):
|
||||||
text = self.get_seed_text()
|
text = self.get_seed_text()
|
||||||
|
|
|
@ -98,7 +98,7 @@ class InstallWizard(Widget):
|
||||||
else:
|
else:
|
||||||
self.run('add_seed', (text, None))
|
self.run('add_seed', (text, None))
|
||||||
# fixme: sync
|
# fixme: sync
|
||||||
msg = _('You may use the camera to scan your seed. Scan a master public key to create a watching-only wallet')
|
msg = _('You may use the camera to scan your seed. To create a watching-only wallet, scan your master public key.')
|
||||||
RestoreSeedDialog(test=Wallet.is_any, message=msg, on_release=on_seed).open()
|
RestoreSeedDialog(test=Wallet.is_any, message=msg, on_release=on_seed).open()
|
||||||
|
|
||||||
def add_seed(self, text, password):
|
def add_seed(self, text, password):
|
||||||
|
|
|
@ -134,7 +134,7 @@ class Mnemonic(object):
|
||||||
|
|
||||||
def get_suggestions(self, prefix):
|
def get_suggestions(self, prefix):
|
||||||
for w in self.wordlist:
|
for w in self.wordlist:
|
||||||
if w.startswith(prefix) and w!=prefix:
|
if w.startswith(prefix):
|
||||||
yield w
|
yield w
|
||||||
|
|
||||||
def mnemonic_decode(self, seed):
|
def mnemonic_decode(self, seed):
|
||||||
|
|
Loading…
Add table
Reference in a new issue