1
0
mirror of https://codeberg.org/vanous/huafetcher synced 2024-11-15 14:33:06 +01:00

Solution for accounts with 2+ devices

Signed-off-by: Ivan Lebedev <lisgml@gmail.com>
This commit is contained in:
Ivan Lebedev 2022-05-19 20:35:07 +03:00
parent 1905801d2d
commit 69d195a9d1
No known key found for this signature in database
GPG Key ID: CFCF525BA4CD4E2C

31
main.py

@ -67,6 +67,17 @@ Builder.load_string('''
Rectangle:
size: self.size
pos: self.pos
<MyDDKeyButton>:
bcolor: .7, .7, .7, 1
background_color: .1, 0, .5, 0
text_size: self.width, None
canvas.before:
Color:
rgba: root.bcolor
Rectangle:
size: self.size
pos: self.pos
''')
class MyLabel(Label):
@ -81,6 +92,9 @@ class MyButton(Button):
class MyInput(TextInput):
pass
class MyDDKeyButton(Button):
pass
class Main(App):
def build(self):
@ -199,7 +213,10 @@ class Main(App):
rows_layout.add_widget(self.paste_token_input_layout)
result_value_label=MyButton(text='Found key')
self.result_value_value=TextInput()
self.result_value_value = MyDDKeyButton(text="No keys yet")
self.ddown=DropDown()
self.result_value_value.bind(on_release=self.ddown.open)
self.ddown.bind(on_select=lambda instance, x: setattr(self.result_value_value, 'text', x))
copy_key_button=MyButton(text='Copy', size_hint=(.3, 1))
@ -283,7 +300,7 @@ class Main(App):
def on_press_button_gettoken(self, instance):
debug_print('You pressed the button login!')
self.result_value_value.text=''
self.result_value_value.text='No keys yet'
self.paste_token_input.text=''
self.fetch_agps_button.disabled=True
self.fetch_key_button.disabled=True
@ -339,7 +356,7 @@ class Main(App):
self.instructions_label.text=f"{e}"
if not res:
self.instructions_label.text="amazfit login failed"
self.result_value_value.text=''
self.result_value_value.text='No keys yet'
self.paste_token_input.text=''
self.result_value_layout.disabled=True
self.paste_token_input_layout.disabled=True
@ -363,16 +380,20 @@ class Main(App):
device_keys = self.huamidevice.get_wearable_auth_keys()
self.result_value_layout.disabled=False
self.result_value_value.text=""
self.result_value_value.text="No keys yet"
key=""
for device_key in device_keys:
debug_print(f"{device_key} {device_keys[device_key]}")
key_button = MyDDKeyButton(text=f"{device_keys[device_key]}", size_hint_y=None, height=44)
key_button.bind(on_release=lambda btn: self.ddown.select(btn.text))
key=f"{device_keys[device_key]}"
self.ddown.add_widget(key_button)
if key=="":
self.instructions_label.text="No keys on the server"
else:
self.instructions_label.text="Got the key, use the Copy button"
self.instructions_label.text="Got the keys, select one and use the Copy button"
self.result_value_value.text=f"{key}"
#Clock.schedule_once(partial(self.doit), 1)