Implemement Ui for Inbox Load feature with create new address based on random number

This commit is contained in:
surbhi 2018-08-04 14:00:12 +05:30
parent 0bc1dfdc8b
commit b1f7489b09
No known key found for this signature in database
GPG Key ID: 88928762974D3618
36 changed files with 146 additions and 59 deletions

View File

@ -1,59 +1,41 @@
#:import la kivy.adapters.listadapter
#:import factory kivy.factory
#:import mpybit bitmessagekivy.mpybit
#:import ListItemButton kivy.uix.listview.ListItemButton
<Navigator>: <Navigator>:
id: nav_drawer id: nav_drawer
NavigationDrawerIconButton: NavigationDrawerIconButton:
Button: Spinner:
pos_hint:{"x":0,"y":.3}
id: btn id: btn
background_color: app.theme_cls.primary_dark background_color: app.theme_cls.primary_dark
text: 'BM-2cSvewtJw8o8eqcFzmLeXHza4BVsRsirKk' text: '<address>'
on_release: dropdown.open(self) values: app.showmeaddresses()
pos_hint: {'x': 0, 'y': 0.3}
size_hint_y: None
height: '48dp'
DropDown:
id: dropdown
on_parent: self.dismiss()
on_select: btn.text = '{}'.format(args[1])
Button:
background_color:app.theme_cls.primary_dark
text: 'BM-2cSvewtJw8o8eqcFzmLeXHza4BVsRsirKk'
size_hint_y: None
height: '48dp'
on_release: dropdown.select('BM-2cSvewtJw8o8eqcFzmLeXHza4BVsRsirKk')
on_release: app.root.ids.scr_mngr.current = 'dialog'
Button:
background_color:app.theme_cls.primary_dark
text: 'BM-2cSvewtJw8o8eqcFzmLeXHza4BVsRsirKk'
size_hint_y: None
height: '48dp'
on_release: dropdown.select('BM-2cSvewtJw8o8eqcFzmLeXHza4BVsRsirKk')
on_release: app.root.ids.scr_mngr.current = 'button'
NavigationDrawerIconButton: NavigationDrawerIconButton:
icon: 'email' icon: 'email-open'
text: "inbox" text: "inbox"
on_release: app.root.ids.scr_mngr.current = 'inbox' on_release: app.root.ids.scr_mngr.current = 'inbox'
NavigationDrawerIconButton: NavigationDrawerIconButton:
icon: 'email' icon: 'mail-send'
text: "sent" text: "sent"
on_release: app.root.ids.scr_mngr.current = 'sent' on_release: app.root.ids.scr_mngr.current = 'sent'
NavigationDrawerIconButton: NavigationDrawerIconButton:
icon: 'email' icon: 'dropbox'
text: "trash" text: "trash"
on_release: app.root.ids.scr_mngr.current = 'trash' on_release: app.root.ids.scr_mngr.current = 'trash'
NavigationDrawerIconButton: NavigationDrawerIconButton:
icon: 'email' icon: 'email'
text: "dialog" text: "drafts"
on_release: app.root.ids.scr_mngr.current = 'dialog' on_release: app.root.ids.scr_mngr.current = 'dialog'
NavigationDrawerIconButton: NavigationDrawerIconButton:
icon: 'email' icon: 'markunread-mailbox'
text: "test" text: "test"
on_release: app.root.ids.scr_mngr.current = 'test' on_release: app.root.ids.scr_mngr.current = 'test'
NavigationDrawerIconButton: NavigationDrawerIconButton:
text: "new identity" text: "new identity"
icon:'notifications-add' icon:'accounts-add'
on_release: app.root.ids.scr_mngr.current = 'newidentity' on_release: app.root.ids.scr_mngr.current = 'newidentity'
BoxLayout: BoxLayout:
@ -67,8 +49,8 @@ BoxLayout:
text:"EXIT" text:"EXIT"
color: 0,0,0,1 color: 0,0,0,1
background_color: (0,0,0,0) background_color: (0,0,0,0)
size_hint_y: 0.1 size_hint_y: 0.4
size_hint_x: 0.1 size_hint_x: 0.5
pos_hint: {'x': 0.8, 'y':0.4} pos_hint: {'x': 0.8, 'y':0.4}
on_press: app.say_exit() on_press: app.say_exit()
@ -89,10 +71,14 @@ BoxLayout:
id:sc6 id:sc6
NewIdentity: NewIdentity:
id:sc7 id:sc7
Page:
id:sc8
AddressSuccessful:
id:sc9
Button: Button:
height:100 height:100
size_hint_y: 0.1 size_hint_y: 0.2
size_hint_x: 0.1 size_hint_x: 0.1
pos_hint: {'x': 0.85, 'y': 0.5} pos_hint: {'x': 0.85, 'y': 0.5}
background_color: (0,0,0,0) background_color: (0,0,0,0)
@ -102,8 +88,30 @@ BoxLayout:
y: self.parent.y y: self.parent.y
x: self.parent.x + self.parent.width - 50 x: self.parent.x + self.parent.width - 50
size: 70, 70 size: 70, 70
<ListItemButton>:
height: dp(25)
size_hint: (1,.1)
selected_color: 0,0,0,0
deselected_color: 0,0,0,0
color: 0, 0,0, 1
<Inbox>: <Inbox>:
name: 'inbox' name: 'inbox'
ScrollView:
GridLayout:
id: box_share
cols: 1
size_hint_y: None
spacing: 10
padding: 10
height: self.minimum_height
canvas:
Color:
rgb: 30,144,255
Rectangle:
pos: self.pos
size: self.size
<Sent>: <Sent>:
name: 'sent' name: 'sent'
@ -141,7 +149,7 @@ BoxLayout:
pos: 10,10 pos: 10,10
id: spinner_id id: spinner_id
text: '<select>' text: '<select>'
values: root.showmeaddresses() values: app.showmeaddresses()
BoxLayout: BoxLayout:
size_hint_y: None size_hint_y: None
@ -208,7 +216,12 @@ BoxLayout:
pos:self.center_x-8, self.center_y-8 pos:self.center_x-8, self.center_y-8
size:[16,16] size:[16,16]
group: "money" group: "money"
id:chk
text:"use a random number generator to make an address"
on_active:
root.checked = self.text
active:root.is_active active:root.is_active
Label: Label:
text: "use a random number generator to make an address" text: "use a random number generator to make an address"
color: 0,0,0,1 color: 0,0,0,1
@ -221,9 +234,13 @@ BoxLayout:
pos:self.center_x-8, self.center_y-8 pos:self.center_x-8, self.center_y-8
size:[16,16] size:[16,16]
group: "money" group: "money"
id:chk
text:"use a pseudo number generator to make an address"
on_active:
root.checked = self.text
active:not root.is_active active:not root.is_active
Label: Label:
text: "use a random number generator to make an address" text: "use a pseudo number generator to make an address"
color: 0,0,0,1 color: 0,0,0,1
Label: Label:
color: 0,0,0,1 color: 0,0,0,1
@ -254,3 +271,16 @@ BoxLayout:
size_hint_x: 0.3 size_hint_x: 0.3
height: '32dp' height: '32dp'
pos_hint: {'x': .5, 'y': 0.1} pos_hint: {'x': .5, 'y': 0.1}
on_press: root.generateaddress()
<Page>:
name: 'page'
Label:
text: 'I am on description of my email yooooo'
color: 0,0,0,1
<AddressSuccessful>:
name: 'add_sucess'
Label:
text: 'Successfully created a new bit address'
color: 0,0,0,1

View File

@ -1,5 +1,6 @@
import os import os
import queues import queues
import random
import shutdown import shutdown
import time import time
@ -7,10 +8,14 @@ from kivy.app import App
from kivy.lang import Builder from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout from kivy.uix.boxlayout import BoxLayout
from kivy.properties import BooleanProperty from kivy.properties import BooleanProperty
from kivy.uix.button import Button
from kivy.clock import Clock from kivy.clock import Clock
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.image import Image
from kivy.uix.label import Label from kivy.uix.label import Label
from kivy.uix.listview import ListItemButton
from navigationdrawer import NavigationDrawer from navigationdrawer import NavigationDrawer
from kivy.properties import ObjectProperty, StringProperty from kivy.properties import ObjectProperty, StringProperty, ListProperty, NumericProperty
from kivy.uix.screenmanager import Screen from kivy.uix.screenmanager import Screen
from kivy.uix.textinput import TextInput from kivy.uix.textinput import TextInput
from kivymd.theming import ThemeManager from kivymd.theming import ThemeManager
@ -21,6 +26,7 @@ from helper_ackPayload import genAckPayload
from addresses import decodeAddress, addBMIfNotPresent from addresses import decodeAddress, addBMIfNotPresent
from helper_sql import sqlExecute from helper_sql import sqlExecute
statusIconColor = 'red' statusIconColor = 'red'
avatarlist = os.listdir("images/ngletteravatar")
class NavigateApp(App, TextInput): class NavigateApp(App, TextInput):
@ -38,23 +44,65 @@ class NavigateApp(App, TextInput):
App.get_running_app().stop() App.get_running_app().stop()
shutdown.doCleanShutdown() shutdown.doCleanShutdown()
def showmeaddresses(self):
return BMConfigParser().addresses()
class Navigator(NavigationDrawer): class Navigator(NavigationDrawer):
image_source = StringProperty('images/me.jpg') image_source = StringProperty('images/qidenticon_two.png')
title = StringProperty('Navigation') title = StringProperty('Navigation')
class Inbox(Screen): class Inbox(Screen):
def __init__(self, **kwargs):
super(Inbox, self).__init__(**kwargs) def __init__(self, *args, **kwargs):
val_y = .1 super(Inbox, self).__init__(*args, **kwargs)
val_z = 0 Clock.schedule_once(self.init_ui, 0)
my_box1 = BoxLayout(orientation='vertical')
for i in range(1, 5): def init_ui(self, dt=0):
my_box1.add_widget(Label(text="I am in inbox", size_hint=(.3, .1), pos_hint={ self.orientation = "vertical"
'x': val_z, 'top': val_y}, color=(0, 0, 0, 1), background_color=(0, 0, 0, 0))) self.create_button(self.ids.box_share)
val_y += .1
self.add_widget(my_box1) def create_button(self, box_share):
top_logo_share = 1.01
top_button_share = 1.1
top_label_share = 1.4
for i in range(50):
top_logo_share -= .4
top_button_share -= .4
top_label_share -= .4
logo_share = \
Image(source='images/ngletteravatar/{}'.format(self.list_random(avatarlist)),
pos_hint={"center_x": .05, "top": top_logo_share},
size_hint_y=None, height=25)
button_share = \
Button(pos_hint={"x": 0, "top": top_button_share},
size_hint_y=None, height=40, text='email_{}'.format(i), background_color=NavigateApp.theme_cls.primary_dark)
button_share.bind(on_press=self.change_screen)
label_share = \
Label(text=str(i), pos_hint={"x": 0, "top": top_label_share},
size_hint_y=None)
fl = FloatLayout(size_hint_y=None, height=25)
fl.add_widget(button_share)
fl.add_widget(logo_share)
fl.add_widget(label_share)
box_share.add_widget(fl)
def list_random(self, ran):
random.shuffle(ran)
return ran[0]
def change_screen(self, instance):
self.manager.current = 'page'
print('I am {}'.format(instance.text))
class Page(Screen):
pass
class AddressSuccessful(Screen):
pass
class Sent(Screen): class Sent(Screen):
@ -91,19 +139,15 @@ class Test(Screen):
pass pass
class Create(Screen, Widget): class Create(Screen):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(Create, self).__init__(*args, **kwargs) super(Create, self).__init__(*args, **kwargs)
Clock.schedule_once(self.init_ui, 0) Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0): def init_ui(self, dt=0):
# self.ids['recipent'].bind(text=self.on_text)
pass pass
def showmeaddresses(self):
return BMConfigParser().addresses()
def send(self): def send(self):
# toAddress = self.ids.recipent.text # toAddress = self.ids.recipent.text
fromAddress = self.ids.spinner_id.text fromAddress = self.ids.spinner_id.text
@ -167,7 +211,20 @@ class Create(Screen, Widget):
class NewIdentity(Screen): class NewIdentity(Screen):
is_active = BooleanProperty(False) is_active = BooleanProperty(False)
checked = StringProperty("")
def generateaddress(self):
if self.checked == 'use a random number generator to make an address':
queues.apiAddressGeneratorReturnQueue.queue.clear()
streamNumberForAddress = 1
label = self.ids.label.text
eighteenByteRipe = False
nonceTrialsPerByte = 1000
payloadLengthExtraBytes = 1000
queues.addressGeneratorQueue.put((
'createRandomAddress', 4, streamNumberForAddress, label, 1, "", eighteenByteRipe, nonceTrialsPerByte, payloadLengthExtraBytes)
)
self.manager.current = 'add_sucess'
if __name__ == '__main__': if __name__ == '__main__':
NavigateApp().run() NavigateApp().run()

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 656 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 938 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 806 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 972 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B