Merge pull request #26 from jaicis/py3porting

Solved ssl issue and added UI validation
This commit is contained in:
surbhi 2020-05-13 21:46:25 +05:30 committed by GitHub
commit bb0c694826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 827 additions and 352 deletions

View File

@ -0,0 +1,58 @@
<ChatList>:
name: 'chlist'
canvas.before:
Color:
rgba: 1,1,1,1
Rectangle:
pos: self.pos
size: self.size
MDTabs:
id: chat_panel
tab_display_mode:'text'
Tab:
text: "Chats"
BoxLayout:
id: chat_box
orientation: 'vertical'
ScrollView:
id: scroll_y
do_scroll_x: False
MDList:
id: ml
MDLabel:
font_style: 'Caption'
theme_text_color: 'Primary'
text: 'No Chat'
halign: 'center'
size_hint_y: None
bold: True
valign: 'top'
# OneLineAvatarListItem:
# text: "Single-line item with avatar"
# divider: None
# _no_ripple_effect: True
# ImageLeftWidget:
# source: './images/text_images/A.png'
# OneLineAvatarListItem:
# text: "Single-line item with avatar"
# divider: None
# _no_ripple_effect: True
# ImageLeftWidget:
# source: './images/text_images/B.png'
# OneLineAvatarListItem:
# text: "Single-line item with avatar"
# divider: None
# _no_ripple_effect: True
# ImageLeftWidget:
# source: './images/text_images/A.png'
Tab:
text: "Contacts"
BoxLayout:
id: contact_box
orientation: 'vertical'
ScrollView:
id: scroll_y
do_scroll_x: False
MDList:
id: ml

View File

@ -0,0 +1,45 @@
#:import C kivy.utils.get_color_from_hex
<ChatRoom>:
name: 'chroom'
BoxLayout:
orientation: 'vertical'
canvas.before:
Color:
rgba: 1,1,1,1
Rectangle:
pos: self.pos
size: self.size
ScrollView:
Label:
id: chat_logs
text: ''
color: C('#101010')
text_size: (self.width, None)
halign: 'left'
valign: 'top'
padding: (0, 0) # fixed in Kivy 1.8.1
size_hint: (1, None)
height: self.texture_size[1]
markup: True
font_size: sp(20)
BoxLayout:
height: 50
orientation: 'horizontal'
padding: 0
size_hint: (1, None)
TextInput:
id: message
size_hint: (1, 1)
multiline: False
font_size: sp(20)
on_text_validate: root.send_msg()
MDRaisedButton:
text: "Send"
elevation_normal: 2
opposite_colors: True
size_hint: (0.3, 1)
pos_hint: {"center_x": .5}
on_press: root.send_msg()

View File

@ -1,10 +1,11 @@
<DropDownWidget>: <DropDownWidget>:
ScrollView: ScrollView:
id: id_scroll
BoxLayout: BoxLayout:
orientation: 'vertical' orientation: 'vertical'
size_hint_y: None size_hint_y: None
height: self.minimum_height + 2 * self.parent.height/4 height: self.minimum_height + 2 * self.parent.height/4
padding: dp(32) padding: dp(20)
spacing: 15 spacing: 15
BoxLayout: BoxLayout:
orientation: 'vertical' orientation: 'vertical'
@ -13,7 +14,7 @@
hint_text: 'type or select sender address' hint_text: 'type or select sender address'
size_hint_y: None size_hint_y: None
height: 100 height: 100
font_size: '15sp' font_size: dp(15)
multiline: False multiline: False
required: True required: True
helper_text_mode: "on_error" helper_text_mode: "on_error"

View File

@ -29,4 +29,9 @@
MDList: MDList:
id: ml id: ml
Loader: Loader:
ComposerButton: ComposerButton:
<TimeTagRightSampleWidget>:
size_hint:(None, None)
font_style: 'Caption'
halign: 'center'

View File

@ -5,7 +5,7 @@
BoxLayout: BoxLayout:
orientation: 'vertical' orientation: 'vertical'
size_hint_y: None size_hint_y: None
height: dp(400) + self.minimum_height height: dp(450) + self.minimum_height
padding: dp(10) padding: dp(10)
BoxLayout: BoxLayout:
MDLabel: MDLabel:
@ -21,6 +21,9 @@
text: root.log_text2 text: root.log_text2
halign: 'left' halign: 'left'
color:app.theme_cls.primary_dark color:app.theme_cls.primary_dark
Widget:
size_hint: (None, None)
height: dp(10)
MDCheckbox: MDCheckbox:
id: grp_chkbox_1 id: grp_chkbox_1
group: 'test' group: 'test'
@ -55,7 +58,8 @@
BoxLayout: BoxLayout:
AnchorLayout: AnchorLayout:
MDRaisedButton: MDRaisedButton:
height: dp(40) size_hint: (.2, None)
# height: dp(40)
on_press: app.root.ids.scr_mngr.current = 'random' on_press: app.root.ids.scr_mngr.current = 'random'
on_press: app.root.ids.sc7.reset_address_label() on_press: app.root.ids.sc7.reset_address_label()
MDLabel: MDLabel:
@ -68,44 +72,49 @@
<Random>: <Random>:
name: 'random' name: 'random'
ScrollView: ScrollView:
BoxLayout: id: add_random_bx
orientation: 'vertical'
size_hint_y: None
height: self.minimum_height
padding: dp(20)
spacing: 100
MDLabel:
font_style: 'Subtitle2'
theme_text_color: 'Primary'
text: "Random Addresses"
halign: 'center'
color:app.theme_cls.primary_dark
MDLabel: <RandomBoxlayout>:
font_style: 'Subtitle2' orientation: 'vertical'
theme_text_color: 'Primary' size_hint_y: None
text: "Here you may generate as many addresses as you like, Indeed creating and abandoning addresses is encouraged" height: self.minimum_height
halign: 'center' padding: dp(20)
color:app.theme_cls.primary_dark spacing: 100
MDTextField: MDLabel:
id: label font_style: 'Subtitle2'
multiline: False theme_text_color: 'Primary'
hint_text: "Label" text: "Random Addresses"
required: True halign: 'center'
helper_text_mode: "on_error" color:app.theme_cls.primary_dark
on_text: root.add_validation(self)
canvas.before: MDLabel:
Color: font_style: 'Subtitle2'
rgba: (0,0,0,1) theme_text_color: 'Primary'
BoxLayout: text: "Here you may generate as many addresses as you like, Indeed creating and abandoning addresses is encouraged"
AnchorLayout: halign: 'left'
MDRaisedButton: color:app.theme_cls.primary_dark
height: dp(40)
on_release: root.generateaddress(app) MDTextField:
opposite_colors: True id: label
MDLabel: multiline: False
font_style: 'H6' hint_text: "Label"
text: 'next' required: True
font_size: '13sp' helper_text_mode: "on_error"
color: (1,1,1,1) on_text: app.root.ids.sc7.add_validation(self)
halign: 'center' canvas.before:
Color:
rgba: (0,0,0,1)
BoxLayout:
AnchorLayout:
MDRaisedButton:
size_hint: (.2, None)
# height: dp(40)
on_release: app.root.ids.sc7.generateaddress(app)
opposite_colors: True
MDLabel:
font_style: 'H6'
text: 'next'
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'

View File

@ -7,7 +7,7 @@
orientation: 'vertical' orientation: 'vertical'
# height: dp(bod.height) + self.minimum_height # height: dp(bod.height) + self.minimum_height
height: self.minimum_height height: self.minimum_height
padding: dp(20) padding: dp(10)
# MDLabel: # MDLabel:
# size_hint_y: None # size_hint_y: None
# id: subj # id: subj
@ -32,17 +32,21 @@
divider: None divider: None
on_press: root.detailedPopup() on_press: root.detailedPopup()
BadgeText: BadgeText:
size_hint:(None, None)
size:[120, 140] if app.app_platform == 'android' else [64, 80]
text: root.time_tag text: root.time_tag
halign:'right' halign:'center'
font_style:'Caption' font_style:'Caption'
pos_hint: {'center_y': .8} pos_hint: {'center_y': .8}
_txt_right_pad: dp(70)
font_size: '11sp'
MDChip: MDChip:
size_hint: (None, None) size_hint: (.16 if app.app_platform == 'android' else .07 , None)
label: root.page_type label: root.page_type
icon: '' icon: ''
pos_hint: {'center_x': .94, 'center_y': .3} pos_hint: {'center_x': .91 if app.app_platform == 'android' else .95, 'center_y': .3}
radius: 8 radius: 8
height: 18 height: self.parent.height/4
AvatarSampleWidget: AvatarSampleWidget:
source: root.avatarImg source: root.avatarImg
MDLabel: MDLabel:

View File

@ -19,12 +19,18 @@
size_hint_y: None size_hint_y: None
height: dp(58) height: dp(58)
MDRaisedButton: MDRaisedButton:
size_hint: .5, 0 size_hint: .6, 0
height: dp(40) height: dp(40)
text: root.text_variable_1 # text: root.text_variable_1
elevation_normal: 2 elevation_normal: 2
opposite_colors: True opposite_colors: True
pos_hint: {'center_x': .5} pos_hint: {'center_x': .5}
MDLabel:
font_style: 'H6'
text: root.text_variable_1
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
Tab: Tab:
text: 'Processes' text: 'Processes'
ScrollView: ScrollView:
@ -40,12 +46,18 @@
size_hint_y: None size_hint_y: None
height: dp(58) height: dp(58)
MDRaisedButton: MDRaisedButton:
size_hint: .5, 0 size_hint: .6, 0
height: dp(40) height: dp(40)
text: root.text_variable_2 # text: root.text_variable_2
elevation_normal: 2 elevation_normal: 2
opposite_colors: True opposite_colors: True
pos_hint: {'center_x': .5} pos_hint: {'center_x': .5}
MDLabel:
font_style: 'H6'
text: root.text_variable_2
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
OneLineListItem: OneLineListItem:
text: "Brodcast" text: "Brodcast"
BoxLayout: BoxLayout:
@ -53,12 +65,18 @@
size_hint_y: None size_hint_y: None
height: dp(58) height: dp(58)
MDRaisedButton: MDRaisedButton:
size_hint: .5, 0 size_hint: .6, 0
height: dp(40) height: dp(40)
text: root.text_variable_3 # text: root.text_variable_3
elevation_normal: 2 elevation_normal: 2
opposite_colors: True opposite_colors: True
pos_hint: {'center_x': .5} pos_hint: {'center_x': .5}
MDLabel:
font_style: 'H6'
text: root.text_variable_3
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
OneLineListItem: OneLineListItem:
text: "publickeys" text: "publickeys"
BoxLayout: BoxLayout:
@ -66,12 +84,18 @@
size_hint_y: None size_hint_y: None
height: dp(58) height: dp(58)
MDRaisedButton: MDRaisedButton:
size_hint: .5, 0 size_hint: .6, 0
height: dp(40) height: dp(40)
text: root.text_variable_4 # text: root.text_variable_4
elevation_normal: 2 elevation_normal: 2
opposite_colors: True opposite_colors: True
pos_hint: {'center_x': .5} pos_hint: {'center_x': .5}
MDLabel:
font_style: 'H6'
text: root.text_variable_4
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
OneLineListItem: OneLineListItem:
text: "objects" text: "objects"
BoxLayout: BoxLayout:
@ -79,9 +103,15 @@
size_hint_y: None size_hint_y: None
height: dp(58) height: dp(58)
MDRaisedButton: MDRaisedButton:
size_hint: .5, 0 size_hint: .6, 0
height: dp(40) height: dp(40)
text: root.text_variable_5 # text: root.text_variable_5
elevation_normal: 2 elevation_normal: 2
opposite_colors: True opposite_colors: True
pos_hint: {'center_x': .5} pos_hint: {'center_x': .5}
MDLabel:
font_style: 'H6'
text: root.text_variable_5
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'

View File

@ -45,7 +45,7 @@
Rectangle: Rectangle:
pos: self.pos pos: self.pos
size: self.size size: self.size
size: dp(app.window_size[0] - 2*self.parent.parent.padding[0]) - 10 , 1 size: app.window_size[0] - 2*self.parent.parent.padding[0] - dp(10) , 1
height: dp(40) height: dp(40)
on_press: root.get_free_credits(self) on_press: root.get_free_credits(self)
MDLabel: MDLabel:
@ -91,7 +91,7 @@
Rectangle: Rectangle:
pos: self.pos pos: self.pos
size: self.size size: self.size
size: dp(app.window_size[0] - 2*self.parent.parent.padding[0]) - 10 , 1 size: app.window_size[0] - 2*self.parent.parent.padding[0] - dp(10) , 1
height: dp(40) height: dp(40)
on_press: root.create_hidden_payment_address(self) on_press: root.create_hidden_payment_address(self)
MDLabel: MDLabel:
@ -137,7 +137,7 @@
Rectangle: Rectangle:
pos: self.pos pos: self.pos
size: self.size size: self.size
size: dp(app.window_size[0] - 2*self.parent.parent.padding[0]) - 10 , 1 size: app.window_size[0] - 2*self.parent.parent.padding[0] - dp(10) , 1
height: dp(40) height: dp(40)
on_press: root.create_hidden_payment_address(self) on_press: root.create_hidden_payment_address(self)
MDLabel: MDLabel:

View File

@ -102,7 +102,7 @@
BoxLayout: BoxLayout:
size_hint_y: None size_hint_y: None
orientation: 'vertical' orientation: 'vertical'
spacing:dp(20) spacing:dp(15)
MDLabel: MDLabel:
font_style: 'Subtitle2' font_style: 'Subtitle2'
theme_text_color: 'Primary' theme_text_color: 'Primary'
@ -128,6 +128,9 @@
text: "Address" text: "Address"
font_size: '17sp' font_size: '17sp'
halign: 'left' halign: 'left'
Widget:
size_hint_y: None
height: dp(1)
BoxLayout: BoxLayout:
orientation: 'horizontal' orientation: 'horizontal'
MDLabel: MDLabel:
@ -338,6 +341,19 @@
id: myadd_popup_box id: myadd_popup_box
size_hint_y: None size_hint_y: None
orientation: 'vertical' orientation: 'vertical'
spacing:dp(8 if app.app_platform == 'android' else 3)
BoxLayout:
orientation: 'vertical'
MDLabel:
id: from_add_label
font_style: 'Subtitle2'
theme_text_color: 'Primary'
text: "From :"
font_size: '15sp'
halign: 'left'
Widget:
size_hint_y: None
height: dp(1 if app.app_platform == 'android' else 0)
BoxLayout: BoxLayout:
size_hint_y: None size_hint_y: None
height: 50 height: 50
@ -346,13 +362,23 @@
id: sd_label id: sd_label
font_style: 'Body2' font_style: 'Body2'
theme_text_color: 'Primary' theme_text_color: 'Primary'
text: "From : [b]" + root.from_addr + "[/b]" text: "[b]" + root.from_addr + "[/b]"
font_size: '15sp' font_size: '15sp'
halign: 'left' halign: 'left'
markup: True markup: True
IconRightSampleWidget: IconRightSampleWidget:
icon: 'content-copy' icon: 'content-copy'
on_press: app.copy_composer_text(root.from_addr) on_press: app.copy_composer_text(root.from_addr)
Widget:
id: space_1
size_hint_y: None
height: dp(2 if app.app_platform == 'android' else 0)
BoxLayout:
id: to_addtitle
Widget:
id:space_2
size_hint_y: None
height: dp(1 if app.app_platform == 'android' else 0)
BoxLayout: BoxLayout:
id: to_addId id: to_addId
BoxLayout: BoxLayout:
@ -370,7 +396,8 @@
orientation: 'vertical' orientation: 'vertical'
MDRaisedButton: MDRaisedButton:
on_press: root.dismiss() on_press: root.dismiss()
pos_hint: {'x': 0.85, 'y': 0} size_hint: .2, 0
pos_hint: {'x': 0.8, 'y': 0}
MDLabel: MDLabel:
font_style: 'H6' font_style: 'H6'
text: 'Cancel' text: 'Cancel'
@ -383,9 +410,19 @@
MDLabel: MDLabel:
font_style: 'Body2' font_style: 'Body2'
theme_text_color: 'Primary' theme_text_color: 'Primary'
text: "To : " + root.to_addr text: root.to_addr
font_size: '15sp' font_size: '15sp'
halign: 'left' halign: 'left'
IconRightSampleWidget: IconRightSampleWidget:
icon: 'content-copy' icon: 'content-copy'
on_press: app.copy_composer_text(root.to_addr) on_press: app.copy_composer_text(root.to_addr)
<ToAddressTitle>:
orientation: 'vertical'
MDLabel:
id: to_add_label
font_style: 'Subtitle2'
theme_text_color: 'Primary'
text: "To :"
font_size: '15sp'
halign: 'left'

View File

@ -11,10 +11,12 @@
BoxLayout: BoxLayout:
size_hint_y: None size_hint_y: None
orientation: 'vertical' orientation: 'vertical'
height: dp(400) + self.minimum_height height: dp(250) + self.minimum_height
padding: 10 padding: 10
BoxLayout: BoxLayout:
size_hint_y: None
orientation: 'horizontal' orientation: 'horizontal'
height: self.minimum_height
MDCheckbox: MDCheckbox:
id: chkbox id: chkbox
size_hint: None, None size_hint: None, None
@ -29,23 +31,6 @@
halign: 'left' halign: 'left'
pos_hint: {'center_x': 0, 'center_y': 0.6} pos_hint: {'center_x': 0, 'center_y': 0.6}
disabled: True disabled: True
BoxLayout:
orientation: 'vertical'
padding: [0, 10, 0, 0]
spacing: 10
MDLabel:
font_style: 'Body1'
theme_text_color: 'Primary'
text: "Interface Language"
halign: 'right'
bold: True
MDDropDownItem:
id: dropdown_item
text: 'italiano'
dropdown_max_height: 150
dropdown_bg: [1, 1, 1, 1]
pos_hint: {'center_x': 0.8, 'center_y': 0}
items: [f"{i}" for i in ['System Setting','U.S. English','italiano','Esperanto','dansk','Deutsch','Pirate English','francais','Nederlands','norsk bokmal','polski','portugues europeu']]
BoxLayout: BoxLayout:
size_hint_y: None size_hint_y: None
orientation: 'vertical' orientation: 'vertical'
@ -105,51 +90,53 @@
halign: 'left' halign: 'left'
pos_hint: {'x': 0, 'y': .5} pos_hint: {'x': 0, 'y': .5}
BoxLayout: BoxLayout:
orientation: 'horizontal' size_hint_y: None
MDCheckbox: orientation: 'vertical'
id: chkbox height: dp(100) + self.minimum_height
size_hint: None, None BoxLayout:
size: dp(48), dp(50) orientation: 'horizontal'
# active: True MDCheckbox:
halign: 'center' id: chkbox
MDLabel: size_hint: None, None
font_style: 'Body1' size: dp(48), dp(50)
theme_text_color: 'Primary' # active: True
text: "Hide connection notifications" halign: 'center'
halign: 'left' MDLabel:
pos_hint: {'x': 0, 'y': 0.1} font_style: 'Body1'
theme_text_color: 'Primary'
text: "Hide connection notifications"
halign: 'left'
pos_hint: {'x': 0, 'y': 0.2}
BoxLayout:
orientation: 'horizontal'
MDCheckbox:
id: chkbox
size_hint: None, None
size: dp(48), dp(50)
active: True
halign: 'center'
MDLabel:
font_style: 'Body1'
theme_text_color: 'Primary'
text: "Show notification when message received"
halign: 'left'
pos_hint: {'x': 0, 'y': 0.2}
BoxLayout:
orientation: 'horizontal'
MDCheckbox:
id: chkbox
size_hint: None, None
size: dp(48), dp(50)
# active: True
halign: 'center'
MDLabel:
font_style: 'Body1'
theme_text_color: 'Primary'
text: "Run in Portable Mode"
halign: 'left'
pos_hint: {'x': 0, 'y': 0.2}
BoxLayout: BoxLayout:
orientation: 'horizontal' orientation: 'vertical'
MDCheckbox:
id: chkbox
size_hint: None, None
size: dp(48), dp(50)
active: True
halign: 'center'
MDLabel:
font_style: 'Body1'
theme_text_color: 'Primary'
text: "Show notification when message received"
halign: 'left'
pos_hint: {'x': 0, 'y': 0.1}
BoxLayout:
orientation: 'horizontal'
MDCheckbox:
id: chkbox
size_hint: None, None
size: dp(48), dp(50)
# active: True
halign: 'center'
MDLabel:
font_style: 'Body1'
theme_text_color: 'Primary'
text: "Run in Portable Mode"
halign: 'left'
pos_hint: {'x': 0, 'y': 0.1}
BoxLayout:
# id: box_height
orientation: 'horizontal'
padding: 10
MDLabel: MDLabel:
font_style: 'Body1' font_style: 'Body1'
theme_text_color: 'Primary' theme_text_color: 'Primary'
@ -157,74 +144,84 @@
# text: 'huiiiii' # text: 'huiiiii'
halign: 'left' halign: 'left'
BoxLayout: BoxLayout:
orientation: 'horizontal' size_hint_y: None
MDCheckbox: orientation: 'vertical'
id: chkbox height: dp(100) + self.minimum_height
size_hint: None, None BoxLayout:
size: dp(48), dp(50) orientation: 'horizontal'
halign: 'center' MDCheckbox:
MDLabel: id: chkbox
font_style: 'Body1' size_hint: None, None
theme_text_color: 'Primary' size: dp(48), dp(50)
text: "Willingly include unencrypted destination address when sending to a mobile device" halign: 'center'
halign: 'left' MDLabel:
pos_hint: {'x': 0, 'y': 0.1} font_style: 'Body1'
BoxLayout: theme_text_color: 'Primary'
orientation: 'horizontal' text: "Willingly include unencrypted destination address when sending to a mobile device"
MDCheckbox: halign: 'left'
id: chkbox pos_hint: {'x': 0, 'y': 0.2}
size_hint: None, None BoxLayout:
size: dp(48), dp(50) orientation: 'horizontal'
active: True MDCheckbox:
halign: 'center' id: chkbox
MDLabel: size_hint: None, None
font_style: 'Body1' size: dp(48), dp(50)
theme_text_color: 'Primary' active: True
text: "Use identicons" halign: 'center'
halign: 'left' MDLabel:
pos_hint: {'x': 0, 'y': 0.1} font_style: 'Body1'
BoxLayout: theme_text_color: 'Primary'
orientation: 'horizontal' text: "Use identicons"
MDCheckbox: halign: 'left'
id: chkbox pos_hint: {'x': 0, 'y': 0.2}
size_hint: None, None BoxLayout:
size: dp(48), dp(50) orientation: 'horizontal'
halign: 'center' MDCheckbox:
MDLabel: id: chkbox
font_style: 'Body1' size_hint: None, None
theme_text_color: 'Primary' size: dp(48), dp(50)
text: "Reply below Quote" halign: 'center'
halign: 'left' MDLabel:
pos_hint: {'x': 0, 'y': 0.1} font_style: 'Body1'
theme_text_color: 'Primary'
text: "Reply below Quote"
halign: 'left'
pos_hint: {'x': 0, 'y': 0.2}
Widget: Widget:
size_hint_y: None size_hint_y: None
height: 10 height: 10
# BoxLayout: BoxLayout:
# orientation: 'vertical' size_hint_y: None
# spacing: 10 orientation: 'vertical'
# padding: 10 # padding: [0, 10, 0, 0]
spacing: 10
# MDLabel: padding: [20, 0, 0, 0]
# font_style: 'Body1' height: dp(20) + self.minimum_height
# theme_text_color: 'Primary' MDLabel:
# text: "Interface Language" font_style: 'Body1'
# halign: 'left' theme_text_color: 'Primary'
# bold: True text: "Interface Language"
# MDDropDownItem: # halign: 'right'
# id: dropdown_item bold: True
# # on_select MDDropDownItem:
# text: 'italiano' id: dropdown_item
# dropdown_max_height: 150 text: 'italiano'
# pos_hint: {'center_x': 0.1, 'center_y': 0} dropdown_max_height: 150
# items: [f"{i}" for i in ['System Setting','U.S. English','italiano','Esperanto','dansk','Deutsch','Pirate English','francais','Nederlands','norsk bokmal','polski','portugues europeu']] dropdown_bg: [1, 1, 1, 1]
# pos_hint: {'center_x': 0.5, 'center_y': 0}
items: [f"{i}" for i in ['System Setting','U.S. English','italiano','Esperanto','dansk','Deutsch','Pirate English','francais','Nederlands','norsk bokmal','polski','portugues europeu']]
BoxLayout: BoxLayout:
spacing:5 spacing:5
orientation: 'horizontal' orientation: 'horizontal'
pos_hint: {'x':.76} # pos_hint: {'x':.76}
MDRaisedButton: BoxLayout:
text: 'Reset' orientation: 'horizontal'
MDRaisedButton: # padding: [0, 10, 0, 0]
text: 'Ok' spacing: 10
MDRaisedButton:
text: 'Reset'
MDRaisedButton:
text: 'Ok'
Tab: Tab:
text: 'Network Settings' text: 'Network Settings'
ScrollView: ScrollView:
@ -232,7 +229,7 @@
BoxLayout: BoxLayout:
size_hint_y: None size_hint_y: None
orientation: 'vertical' orientation: 'vertical'
height: dp(550) + self.minimum_height height: dp(500) + self.minimum_height
padding: 10 padding: 10
BoxLayout: BoxLayout:
id: box_height id: box_height
@ -275,7 +272,7 @@
theme_text_color: 'Primary' theme_text_color: 'Primary'
text: "UPnP" text: "UPnP"
halign: 'left' halign: 'left'
pos_hint: {'x': 0, 'y': 0.1} pos_hint: {'x': 0, 'y': 0}
BoxLayout: BoxLayout:
orientation: 'vertical' orientation: 'vertical'
MDLabel: MDLabel:
@ -301,9 +298,11 @@
pos_hint: {'x': 0.9, 'y': 0} pos_hint: {'x': 0.9, 'y': 0}
items: [f"{i}" for i in ['System Setting','U.S. English']] items: [f"{i}" for i in ['System Setting','U.S. English']]
BoxLayout: BoxLayout:
orientation: 'horizontal' size_hint_y: None
orientation: 'vertical'
padding: [30, 0, 0, 0] padding: [30, 0, 0, 0]
spacing: 10 spacing: 10
height: dp(100) + self.minimum_height
BoxLayout: BoxLayout:
orientation: 'horizontal' orientation: 'horizontal'
MDLabel: MDLabel:
@ -337,10 +336,6 @@
hint_text: '9050' hint_text: '9050'
pos_hint: {'center_y': .5, 'center_x': .5} pos_hint: {'center_y': .5, 'center_x': .5}
input_filter: "int" input_filter: "int"
BoxLayout:
orientation: 'horizontal'
padding: [30, 0, 0, 0]
spacing: 10
BoxLayout: BoxLayout:
orientation: 'horizontal' orientation: 'horizontal'
MDLabel: MDLabel:
@ -377,7 +372,7 @@
theme_text_color: 'Primary' theme_text_color: 'Primary'
text: "Authentication" text: "Authentication"
halign: 'left' halign: 'left'
pos_hint: {'x': 0, 'y': 0.1} pos_hint: {'x': 0, 'y': 0}
BoxLayout: BoxLayout:
orientation: 'horizontal' orientation: 'horizontal'
padding: [30, 0, 0, 0] padding: [30, 0, 0, 0]
@ -392,7 +387,7 @@
theme_text_color: 'Primary' theme_text_color: 'Primary'
text: "Listen for incoming connections when using proxy" text: "Listen for incoming connections when using proxy"
halign: 'left' halign: 'left'
pos_hint: {'x': 0, 'y': 0.1} pos_hint: {'x': 0, 'y': 0}
BoxLayout: BoxLayout:
orientation: 'horizontal' orientation: 'horizontal'
padding: [30, 0, 0, 0] padding: [30, 0, 0, 0]
@ -407,7 +402,7 @@
theme_text_color: 'Primary' theme_text_color: 'Primary'
text: "Only connect to onion services(*.onion)" text: "Only connect to onion services(*.onion)"
halign: 'left' halign: 'left'
pos_hint: {'x': 0, 'y': 0.1} pos_hint: {'x': 0, 'y': 0}
BoxLayout: BoxLayout:
orientation: 'vertical' orientation: 'vertical'
MDLabel: MDLabel:
@ -417,8 +412,10 @@
halign: 'left' halign: 'left'
bold: True bold: True
BoxLayout: BoxLayout:
size_hint_y: None
orientation: 'horizontal' orientation: 'horizontal'
padding: [30, 0, 0, 0] padding: [30, 0, 0, 0]
height: dp(30) + self.minimum_height
MDLabel: MDLabel:
font_style: 'Body1' font_style: 'Body1'
theme_text_color: 'Primary' theme_text_color: 'Primary'
@ -426,13 +423,15 @@
halign: 'left' halign: 'left'
MDTextFieldRect: MDTextFieldRect:
size_hint: None, None size_hint: None, None
size: dp(app.window_size[0]/2), dp(30) size: app.window_size[0]/2, dp(30)
hint_text: '0' hint_text: '0'
pos_hint: {'center_y': .5, 'center_x': .5} pos_hint: {'center_y': .5, 'center_x': .5}
input_filter: "int" input_filter: "int"
BoxLayout: BoxLayout:
size_hint_y: None
orientation: 'horizontal' orientation: 'horizontal'
padding: [30, 0, 0, 0] padding: [30, 0, 0, 0]
height: dp(30) + self.minimum_height
MDLabel: MDLabel:
font_style: 'Body1' font_style: 'Body1'
theme_text_color: 'Primary' theme_text_color: 'Primary'
@ -440,13 +439,15 @@
halign: 'left' halign: 'left'
MDTextFieldRect: MDTextFieldRect:
size_hint: None, None size_hint: None, None
size: dp(app.window_size[0]/2), dp(30) size: app.window_size[0]/2, dp(30)
hint_text: '0' hint_text: '0'
pos_hint: {'center_y': .5, 'center_x': .5} pos_hint: {'center_y': .5, 'center_x': .5}
input_filter: "int" input_filter: "int"
BoxLayout: BoxLayout:
size_hint_y: None
orientation: 'horizontal' orientation: 'horizontal'
padding: [30, 0, 0, 0] padding: [30, 0, 0, 0]
height: dp(30) + self.minimum_height
MDLabel: MDLabel:
font_style: 'Body1' font_style: 'Body1'
theme_text_color: 'Primary' theme_text_color: 'Primary'
@ -454,14 +455,14 @@
halign: 'left' halign: 'left'
MDTextFieldRect: MDTextFieldRect:
size_hint: None, None size_hint: None, None
size: dp(app.window_size[0]/2), dp(30) size: app.window_size[0]/2, dp(30)
hint_text: '8' hint_text: '8'
pos_hint: {'center_y': .5, 'center_x': .5} pos_hint: {'center_y': .5, 'center_x': .5}
input_filter: "int" input_filter: "int"
BoxLayout: BoxLayout:
spacing:5 spacing:5
orientation: 'horizontal' orientation: 'horizontal'
pos_hint: {'x':.76} # pos_hint: {'x':.76}
MDRaisedButton: MDRaisedButton:
text: 'Reset' text: 'Reset'
MDRaisedButton: MDRaisedButton:
@ -473,28 +474,34 @@
BoxLayout: BoxLayout:
size_hint_y: None size_hint_y: None
orientation: 'vertical' orientation: 'vertical'
height: dp(200) + self.minimum_height height: dp(210 if app.app_platform == 'android' else 100)+ self.minimum_height
padding: 20 padding: 20
spacing: 10 # spacing: 10
BoxLayout: BoxLayout:
id: box_height # size_hint_y: None
id: box1_height
orientation: 'vertical' orientation: 'vertical'
# height: dp(100) + self.minimum_height
MDLabel: MDLabel:
font_style: 'Body1' font_style: 'Body1'
theme_text_color: 'Primary' theme_text_color: 'Primary'
text: root.exp_text text: root.exp_text
halign: 'left' halign: 'left'
BoxLayout: BoxLayout:
id: box_height id: box2_height
size_hint_y: None
orientation: 'vertical' orientation: 'vertical'
height: dp(30) + self.minimum_height
MDLabel: MDLabel:
font_style: 'Body1' font_style: 'Body1'
theme_text_color: 'Primary' theme_text_color: 'Primary'
text: "Leave these input fields blank for the default behavior." text: "Leave these input fields blank for the default behavior."
halign: 'left' halign: 'left'
BoxLayout: BoxLayout:
orientation: 'horizontal' size_hint_y: None
orientation: 'vertical'
padding: [10, 0, 0, 0] padding: [10, 0, 0, 0]
height: dp(50) + self.minimum_height
BoxLayout: BoxLayout:
orientation: 'horizontal' orientation: 'horizontal'
MDLabel: MDLabel:
@ -525,10 +532,12 @@
text: "months" text: "months"
halign: 'left' halign: 'left'
BoxLayout: BoxLayout:
size_hint_y: None
spacing:5 spacing:5
orientation: 'horizontal' orientation: 'horizontal'
# pos_hint: {'left': 0} # pos_hint: {'left': 0}
pos_hint: {'x':.75} # pos_hint: {'x':.75}
height: dp(50) + self.minimum_height
MDRaisedButton: MDRaisedButton:
text: 'Reset' text: 'Reset'
MDRaisedButton: MDRaisedButton:

View File

@ -85,6 +85,7 @@
source: app.get_default_logo() source: app.get_default_logo()
ScrollView: ScrollView:
id: scroll_y
pos_hint: {"top": 1} pos_hint: {"top": 1}
GridLayout: GridLayout:
@ -97,7 +98,8 @@
text: "Accounts" text: "Accounts"
height:"35dp" height:"35dp"
NavigationItem: NavigationItem:
size: 50,50 # size: 50,50
height: dp(48)
CustomSpinner: CustomSpinner:
id: btn id: btn
pos_hint:{"x":0,"y":0} pos_hint:{"x":0,"y":0}
@ -155,6 +157,13 @@
on_release: app.root.ids.scr_mngr.current = 'allmails' on_release: app.root.ids.scr_mngr.current = 'allmails'
on_release: root.parent.set_state() on_release: root.parent.set_state()
on_press: app.load_screen(self) on_press: app.load_screen(self)
NavigationItem:
id: chat_rm
text: 'Chat Room'
icon: 'wechat'
divider: None
on_release: app.root.ids.scr_mngr.current = 'chlist'
on_release: root.parent.set_state()
NavigationDrawerDivider: NavigationDrawerDivider:
NavigationDrawerSubheader: NavigationDrawerSubheader:
text: "All labels" text: "All labels"
@ -188,6 +197,7 @@
divider: None divider: None
on_release: app.root.ids.scr_mngr.current = 'login' on_release: app.root.ids.scr_mngr.current = 'login'
on_release: root.parent.set_state() on_release: root.parent.set_state()
on_press: app.reset_login_screen()
NavigationItem: NavigationItem:
text: 'Network status' text: 'Network status'
icon: 'server-network' icon: 'server-network'
@ -259,6 +269,10 @@ NavigationLayout:
id:sc19 id:sc19
Archieve: Archieve:
id:sc20 id:sc20
ChatRoom:
id:sc21
ChatList:
id:sc22
MDNavigationDrawer: MDNavigationDrawer:
id: nav_drawer id: nav_drawer
@ -288,7 +302,7 @@ NavigationLayout:
orientation: 'vertical' orientation: 'vertical'
size_hint: (None, None) size_hint: (None, None)
pos_hint:{'center_x': .5, 'top': 0.9} pos_hint:{'center_x': .5, 'top': 0.9}
size: (app.window_size[0]/2, app.window_size[0]/2) size: (app.window_size[0]/1.8, app.window_size[0]/1.8)
id: qr id: qr
BoxLayout: BoxLayout:
orientation: 'vertical' orientation: 'vertical'
@ -302,9 +316,9 @@ NavigationLayout:
line_color_normal: [0,0,0,0] line_color_normal: [0,0,0,0]
_current_line_color: [0,0,0,0] _current_line_color: [0,0,0,0]
line_color_focus: [0,0,0,0] line_color_focus: [0,0,0,0]
font_size: '18sp' halign: 'center'
font_size: dp(15)
bold: True bold: True
pos_hint: {'x': .26, 'y': 0.5}
# MDLabel: # MDLabel:
# size_hint_y: None # size_hint_y: None
# font_style: 'Body1' # font_style: 'Body1'

View File

@ -3,6 +3,7 @@ Bitmessage android(mobile) interface
""" """
# pylint: disable=too-many-lines,import-error,no-name-in-module,unused-argument # pylint: disable=too-many-lines,import-error,no-name-in-module,unused-argument
# pylint: disable=too-many-ancestors,too-many-locals,useless-super-delegation # pylint: disable=too-many-ancestors,too-many-locals,useless-super-delegation
# pylint: disable=protected-access
import os import os
import time import time
from bitmessagekivy import identiconGeneration from bitmessagekivy import identiconGeneration
@ -57,6 +58,11 @@ from kivymd.uix.list import (
# ) # )
from kivymd.uix.selectioncontrol import MDCheckbox, MDSwitch from kivymd.uix.selectioncontrol import MDCheckbox, MDSwitch
from kivymd.uix.chip import MDChip from kivymd.uix.chip import MDChip
from kivy.uix.screenmanager import (
RiseInTransition,
SlideTransition,
FallOutTransition
)
import queues import queues
from semaphores import kivyuisignaler from semaphores import kivyuisignaler
@ -65,15 +71,18 @@ import state
from addresses import decodeAddress from addresses import decodeAddress
from kivy.uix.modalview import ModalView from kivy.uix.modalview import ModalView
from datetime import datetime from datetime import datetime
from kivy.config import Config
Config.set('input', 'mouse', 'mouse,multitouch_on_demand') if platform != 'android':
from kivy.config import Config
Config.set('input', 'mouse', 'mouse,multitouch_on_demand')
# pylint: disable=too-few-public-methods,too-many-arguments,attribute-defined-outside-init # pylint: disable=too-few-public-methods,too-many-arguments,attribute-defined-outside-init
KVFILES = [ KVFILES = [
'settings', 'popup', 'allmails', 'draft', 'settings', 'popup', 'allmails', 'draft',
'maildetail', 'common_widgets', 'addressbook', 'maildetail', 'common_widgets', 'addressbook',
'myaddress', 'composer', 'payment', 'sent', 'myaddress', 'composer', 'payment', 'sent',
'network', 'login', 'credits', 'trash', 'inbox' 'network', 'login', 'credits', 'trash', 'inbox',
'chat_room', 'chat_list'
] ]
@ -106,22 +115,22 @@ def ShowTimeHistoy(act_time):
def AddTimeWidget(time): # pylint: disable=redefined-outer-name def AddTimeWidget(time): # pylint: disable=redefined-outer-name
"""This method is used to create TimeWidget""" """This method is used to create TimeWidget"""
action_time = BadgeText( action_time = TimeTagRightSampleWidget(
size_hint=(None, None),
text=str(ShowTimeHistoy(time)), text=str(ShowTimeHistoy(time)),
halign='right',
font_style='Caption', font_style='Caption',
size=[65, 70]) size=[120, 140] if platform == 'android' else [64, 80])
action_time.font_size = '11sp'
return action_time return action_time
def chipTag(text): def chipTag(text):
"""This method is used for showing chip tag""" """This method is used for showing chip tag"""
obj = MDChip() obj = MDChip()
obj.size_hint = (None, None) # obj.size_hint = (None, None)
obj.size_hint = (.16 if platform == 'android' else .07, None)
obj.label = text obj.label = text
obj.icon = '' obj.icon = ''
obj.pos_hint = {'center_x': .96, 'center_y': .2} obj.pos_hint = {'center_x': .91 if platform == 'android' else .94, 'center_y': .3}
obj.height = dp(18) obj.height = dp(18)
obj.radius = 8 obj.radius = 8
return obj return obj
@ -213,6 +222,7 @@ class Inbox(Screen):
text=item['text'], secondary_text=item['secondary_text'], text=item['text'], secondary_text=item['secondary_text'],
theme_text_color='Custom', theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny._txt_right_pad = dp(70)
meny.add_widget(AvatarSampleWidget( meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format( source='./images/text_images/{}.png'.format(
avatarImageFirstLetter(item['secondary_text'].strip())))) avatarImageFirstLetter(item['secondary_text'].strip()))))
@ -398,6 +408,7 @@ class MyAddress(Screen):
text=item['text'], secondary_text=item['secondary_text'], text=item['text'], secondary_text=item['secondary_text'],
theme_text_color='Custom' if is_enable == 'true' else 'Primary', theme_text_color='Custom' if is_enable == 'true' else 'Primary',
text_color=NavigateApp().theme_cls.primary_color,) text_color=NavigateApp().theme_cls.primary_color,)
meny._txt_right_pad = dp(70)
try: try:
meny.canvas.children[6].rgba = [0, 0, 0, 0] if is_enable == 'true' else [0.5, 0.5, 0.5, 0.5] meny.canvas.children[6].rgba = [0, 0, 0, 0] if is_enable == 'true' else [0.5, 0.5, 0.5, 0.5]
except Exception: except Exception:
@ -408,31 +419,17 @@ class MyAddress(Screen):
meny.bind(on_press=partial( meny.bind(on_press=partial(
self.myadd_detail, item['secondary_text'], item['text'])) self.myadd_detail, item['secondary_text'], item['text']))
if state.association == item['secondary_text']: if state.association == item['secondary_text']:
meny.add_widget( badge_obj = BadgeText(
BadgeText( size_hint=(None, None),
size_hint=(None, None), size=[85 if platform == 'android' else 50, 60],
text='Active', halign='right', text='Active', halign='center',
font_style='Body1', size=[50, 60], font_style='Body1', theme_text_color='Custom',
theme_text_color='Custom', text_color=NavigateApp().theme_cls.primary_color
text_color=NavigateApp().theme_cls.primary_color)) )
badge_obj.font_size = '13sp'
meny.add_widget(badge_obj)
else: else:
meny.add_widget(ToggleBtn(active=True if is_enable == 'true' else False)) meny.add_widget(ToggleBtn(active=True if is_enable == 'true' else False))
# carousel = Carousel(direction='right')
# carousel.height = meny.height
# carousel.size_hint_y = None
# carousel.ignore_perpendicular_swipes = True
# carousel.data_index = 0
# carousel.min_move = 0.2
# del_btn = Button(text='Disable' if is_enable == 'true' else 'Enable')
# if is_enable == 'true':
# del_btn.background_normal = ''
# del_btn.background_color = (1, 0, 0, 1) if is_enable == 'true' else (0, 1, 0, 1)
# del_btn.bind(
# on_press=partial(
# self.disableAddress if is_enable == 'true' else self.enableAddress , item['secondary_text']))
# carousel.add_widget(del_btn)
# carousel.add_widget(meny)
# carousel.index = 1
self.ids.ml.add_widget(meny) self.ids.ml.add_widget(meny)
def check_scroll_y(self, instance, somethingelse): def check_scroll_y(self, instance, somethingelse):
@ -968,7 +965,19 @@ class NetworkStat(Screen):
class ContentNavigationDrawer(BoxLayout): class ContentNavigationDrawer(BoxLayout):
"""Navigate Content Drawer""" """Navigate Content Drawer"""
pass def __init__(self, *args, **kwargs):
"""Method used for contentNavigationDrawer"""
super(ContentNavigationDrawer, self).__init__(*args, **kwargs)
Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0):
"""Clock Schdule for class contentNavigationDrawer"""
self.ids.scroll_y.bind(scroll_y=self.check_scroll_y)
def check_scroll_y(self, instance, somethingelse):
"""show data on scroll down"""
if self.ids.btn.is_open:
self.ids.btn.is_open = False
class Random(Screen): class Random(Screen):
@ -979,13 +988,12 @@ class Random(Screen):
def generateaddress(self, navApp): def generateaddress(self, navApp):
"""Method for Address Generator""" """Method for Address Generator"""
entered_label = str(self.ids.label.text).strip() entered_label = str(self.ids.add_random_bx.children[0].ids.label.text).strip()
if not entered_label: if not entered_label:
self.ids.label.focus = True self.ids.add_random_bx.children[0].ids.label.focus = True
# self.ids.label.error = True # self.ids.label.error = True
# self.ids.label.helper_text = 'This field is required' # self.ids.label.helper_text = 'This field is required'
streamNumberForAddress = 1 streamNumberForAddress = 1
label = self.ids.label.text
eighteenByteRipe = False eighteenByteRipe = False
nonceTrialsPerByte = 1000 nonceTrialsPerByte = 1000
payloadLengthExtraBytes = 1000 payloadLengthExtraBytes = 1000
@ -994,44 +1002,54 @@ class Random(Screen):
if entered_label and entered_label not in lables: if entered_label and entered_label not in lables:
toast('Address Creating...') toast('Address Creating...')
queues.addressGeneratorQueue.put(( queues.addressGeneratorQueue.put((
'createRandomAddress', 4, streamNumberForAddress, label, 1, 'createRandomAddress', 4, streamNumberForAddress, entered_label, 1,
"", eighteenByteRipe, nonceTrialsPerByte, "", eighteenByteRipe, nonceTrialsPerByte,
payloadLengthExtraBytes)) payloadLengthExtraBytes))
self.ids.label.text = ''
self.parent.parent.ids.toolbar.opacity = 1 self.parent.parent.ids.toolbar.opacity = 1
self.parent.parent.ids.toolbar.disabled = False self.parent.parent.ids.toolbar.disabled = False
state.kivyapp.loadMyAddressScreen(True) state.kivyapp.loadMyAddressScreen(True)
self.manager.current = 'myaddress' self.manager.current = 'myaddress'
Clock.schedule_once(self.address_created_callback, 6) Clock.schedule_once(self.address_created_callback, 6)
@staticmethod def address_created_callback(self, dt=0):
def address_created_callback(dt=0):
"""New address created""" """New address created"""
state.kivyapp.loadMyAddressScreen(False) state.kivyapp.loadMyAddressScreen(False)
state.kivyapp.root.ids.sc10.ids.ml.clear_widgets() state.kivyapp.root.ids.sc10.ids.ml.clear_widgets()
state.kivyapp.root.ids.sc10.is_add_created = True state.kivyapp.root.ids.sc10.is_add_created = True
state.kivyapp.root.ids.sc10.init_ui() state.kivyapp.root.ids.sc10.init_ui()
self.reset_address_spinner()
toast('New address created') toast('New address created')
def add_validation(self, instance): def reset_address_spinner(self):
"""reseting spinner address and UI"""
addresses = [addr for addr in BMConfigParser().addresses()
if BMConfigParser().get(str(addr), 'enabled') == 'true']
self.manager.parent.ids.content_drawer.ids.btn.values = []
self.manager.parent.ids.sc3.children[1].ids.btn.values = []
self.manager.parent.ids.content_drawer.ids.btn.values = addresses
self.manager.parent.ids.sc3.children[1].ids.btn.values = addresses
@staticmethod
def add_validation(instance):
"""Checking validation at address creation time""" """Checking validation at address creation time"""
entered_label = str(instance.text.strip()) entered_label = str(instance.text.strip())
lables = [BMConfigParser().get(obj, 'label') lables = [BMConfigParser().get(obj, 'label')
for obj in BMConfigParser().addresses()] for obj in BMConfigParser().addresses()]
if entered_label in lables: if entered_label in lables:
self.ids.label.error = True instance.error = True
self.ids.label.helper_text = 'Label name is already exist you'\ instance.helper_text = 'Label name is already exist you'\
' can try this Ex. ( {0}_1, {0}_2 )'.format( ' can try this Ex. ( {0}_1, {0}_2 )'.format(
entered_label) entered_label)
elif entered_label: elif entered_label:
self.ids.label.error = False instance.error = False
else: else:
self.ids.label.error = False instance.error = False
self.ids.label.helper_text = 'This field is required' instance.helper_text = 'This field is required'
def reset_address_label(self): def reset_address_label(self):
"""Resetting address labels""" """Resetting address labels"""
self.ids.label.text = '' if not self.ids.add_random_bx.children:
self.ids.add_random_bx.add_widget(RandomBoxlayout())
class Sent(Screen): class Sent(Screen):
@ -1110,6 +1128,7 @@ class Sent(Screen):
text=item['text'], secondary_text=item['secondary_text'], text=item['text'], secondary_text=item['secondary_text'],
theme_text_color='Custom', theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny._txt_right_pad = dp(70)
meny.add_widget(AvatarSampleWidget( meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format( source='./images/text_images/{}.png'.format(
avatarImageFirstLetter(item['secondary_text'].strip())))) avatarImageFirstLetter(item['secondary_text'].strip()))))
@ -1328,6 +1347,7 @@ class Trash(Screen):
subject) >= 50 else (subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', ''), subject) >= 50 else (subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', ''),
theme_text_color='Custom', theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny._txt_right_pad = dp(70)
img_latter = './images/text_images/{}.png'.format( img_latter = './images/text_images/{}.png'.format(
subject[0].upper() if (subject[0].upper() >= 'A' and subject[0].upper() <= 'Z') else '!') subject[0].upper() if (subject[0].upper() >= 'A' and subject[0].upper() <= 'Z') else '!')
meny.add_widget(AvatarSampleWidget(source=img_latter)) meny.add_widget(AvatarSampleWidget(source=img_latter))
@ -1433,6 +1453,12 @@ class Create(Screen):
"SELECT label, address from addressbook")] "SELECT label, address from addressbook")]
widget_1.ids.txt_input.starting_no = 2 widget_1.ids.txt_input.starting_no = 2
self.add_widget(widget_1) self.add_widget(widget_1)
self.children[0].ids.id_scroll.bind(scroll_y=self.check_scroll_y)
def check_scroll_y(self, instance, somethingelse):
"""show data on scroll down"""
if self.children[1].ids.btn.is_open:
self.children[1].ids.btn.is_open = False
class Setting(Screen): class Setting(Screen):
@ -1554,10 +1580,12 @@ class NavigateApp(MDApp):
if platform == 'android': if platform == 'android':
# android_path = os.path.expanduser # android_path = os.path.expanduser
# ("~/user/0/org.test.bitapp/files/app/") # ("~/user/0/org.test.bitapp/files/app/")
android_path = os.path.join( if not os.path.exists('./images/default_identicon/{}.png'.format(
os.environ['ANDROID_PRIVATE'] + '/app/') BMConfigParser().addresses()[0])):
img.texture.save('{1}/images/default_identicon/{0}.png'.format( android_path = os.path.join(
BMConfigParser().addresses()[0], android_path)) os.environ['ANDROID_PRIVATE'] + '/app/')
img.texture.save('{1}/images/default_identicon/{0}.png'.format(
BMConfigParser().addresses()[0], android_path))
else: else:
if not os.path.exists('./images/default_identicon/{}.png'.format( if not os.path.exists('./images/default_identicon/{}.png'.format(
BMConfigParser().addresses()[0])): BMConfigParser().addresses()[0])):
@ -1602,14 +1630,20 @@ class NavigateApp(MDApp):
# pylint: disable=inconsistent-return-statements, too-many-branches # pylint: disable=inconsistent-return-statements, too-many-branches
"""Method is used for going on previous screen""" """Method is used for going on previous screen"""
if key == 27: if key == 27:
if state.in_search_mode and self.root.ids.scr_mngr.current != ( if state.in_search_mode and self.root.ids.scr_mngr.current not in [
"mailDetail"): "mailDetail", "create"]:
self.closeSearchScreen() self.closeSearchScreen()
elif self.root.ids.scr_mngr.current == "mailDetail": elif self.root.ids.scr_mngr.current == "mailDetail":
self.root.ids.scr_mngr.current = 'sent'\ self.root.ids.scr_mngr.current = 'sent'\
if state.detailPageType == 'sent' else 'inbox' \ if state.detailPageType == 'sent' else 'inbox' \
if state.detailPageType == 'inbox' else 'draft' if state.detailPageType == 'inbox' else 'draft'
self.back_press() self.back_press()
if state.in_search_mode and state.searcing_text:
toolbar_obj = self.root.ids.toolbar
toolbar_obj.left_action_items = [
['arrow-left', lambda x: self.closeSearchScreen()]]
toolbar_obj.right_action_items = []
self.root.ids.toolbar.title = ''
elif self.root.ids.scr_mngr.current == "create": elif self.root.ids.scr_mngr.current == "create":
self.save_draft() self.save_draft()
self.set_common_header() self.set_common_header()
@ -1622,13 +1656,23 @@ class NavigateApp(MDApp):
elif self.root.ids.scr_mngr.current == 'pay-options': elif self.root.ids.scr_mngr.current == 'pay-options':
self.set_common_header() self.set_common_header()
self.root.ids.scr_mngr.current = 'payment' self.root.ids.scr_mngr.current = 'payment'
elif self.root.ids.scr_mngr.current == 'chroom':
if state.association:
address_label = self.current_address_label(
BMConfigParser().get(
state.association, 'label'), state.association)
self.root.ids.toolbar.title = address_label
self.set_common_header()
self.root.ids.scr_mngr.transition = FallOutTransition()
self.root.ids.scr_mngr.current = 'chlist'
self.root.ids.scr_mngr.transition = SlideTransition()
else: else:
if state.kivyapp.variable_1: if state.kivyapp.variable_1:
self.root.ids.scr_mngr.current = 'inbox' self.root.ids.scr_mngr.current = 'inbox'
self.root.ids.scr_mngr.transition.direction = 'right' self.root.ids.scr_mngr.transition.direction = 'right'
self.root.ids.scr_mngr.transition.bind(on_complete=self.reset) self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
return True return True
elif key == 13 and state.searcing_text: elif key == 13 and state.searcing_text and not state.in_composer:
if state.search_screen == 'inbox': if state.search_screen == 'inbox':
self.root.ids.sc1.children[1].active = True self.root.ids.sc1.children[1].active = True
Clock.schedule_once(self.search_callback, 0.5) Clock.schedule_once(self.search_callback, 0.5)
@ -1742,12 +1786,21 @@ class NavigateApp(MDApp):
self.root.ids.toolbar.title = '' self.root.ids.toolbar.title = ''
else: else:
self.set_common_header() self.set_common_header()
if self.root.ids.scr_mngr.current == 'chroom' and state.association:
self.root.ids.scr_mngr.transition = FallOutTransition()
address_label = self.current_address_label(
BMConfigParser().get(
state.association, 'label'), state.association)
self.root.ids.toolbar.title = address_label
self.root.ids.scr_mngr.current = 'inbox' \ self.root.ids.scr_mngr.current = 'inbox' \
if state.in_composer else 'allmails'\ if state.in_composer else 'allmails'\
if state.is_allmail else state.detailPageType\ if state.is_allmail else state.detailPageType\
if state.detailPageType else 'myaddress'\ if state.detailPageType else 'myaddress'\
if self.root.ids.scr_mngr.current == 'showqrcode' else 'payment'\ if self.root.ids.scr_mngr.current == 'showqrcode' else 'payment'\
if self.root.ids.scr_mngr.current == 'pay-options' else 'inbox' if self.root.ids.scr_mngr.current == 'pay-options' else 'chlist'\
if self.root.ids.scr_mngr.current == 'chroom' else 'inbox'
if self.root.ids.scr_mngr.current == 'chlist':
self.root.ids.scr_mngr.transition = SlideTransition()
self.root.ids.scr_mngr.transition.direction = 'right' self.root.ids.scr_mngr.transition.direction = 'right'
self.root.ids.scr_mngr.transition.bind(on_complete=self.reset) self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
if state.is_allmail or state.detailPageType == 'draft': if state.is_allmail or state.detailPageType == 'draft':
@ -1892,6 +1945,11 @@ class NavigateApp(MDApp):
def set_mail_detail_header(self): def set_mail_detail_header(self):
"""Setting the details of the page""" """Setting the details of the page"""
if state.association and state.in_search_mode:
address_label = self.current_address_label(
BMConfigParser().get(
state.association, 'label'), state.association)
self.root.ids.toolbar.title = address_label
toolbar_obj = self.root.ids.toolbar toolbar_obj = self.root.ids.toolbar
toolbar_obj.left_action_items = [ toolbar_obj.left_action_items = [
['arrow-left', lambda x: self.back_press()]] ['arrow-left', lambda x: self.back_press()]]
@ -1960,24 +2018,51 @@ class NavigateApp(MDApp):
ext=['.png', '.jpg'] ext=['.png', '.jpg']
) )
self.manager.add_widget(self.file_manager) self.manager.add_widget(self.file_manager)
self.file_manager.show(os.environ["HOME"]) # self.file_manager.show(os.environ["HOME"])
if platform == 'android':
from android.permissions import request_permissions, Permission
request_permissions([Permission.WRITE_EXTERNAL_STORAGE, Permission.READ_EXTERNAL_STORAGE])
# from android.storage import app_storage_path
# settings_path = app_storage_path()
# print('path1................................', settings_path)
# from android.storage import primary_external_storage_path
# primary_ext_storage = primary_external_storage_path()
# print('path1................................', primary_ext_storage)
# from android.storage import secondary_external_storage_path
# secondary_ext_storage = secondary_external_storage_path()
# print('path1................................', secondary_ext_storage)
# from kivy.app import user_data_dir
# from os.path import dirname, join
# out = join(dirname(user_data_dir), 'DCIM')
# DCIM = join('/sdcard', 'DCIM')
self.file_manager.show(os.getenv('EXTERNAL_STORAGE') if platform == 'android' else os.environ["HOME"])
# self.file_manager.show(os.getenv('EXTERNAL_STORAGE'))
self.manager_open = True self.manager_open = True
self.manager.open() self.manager.open()
def select_path(self, path): def select_path(self, path):
"""This method is used to save the select image""" """This method is used to save the select image"""
from PIL import Image as PilImage from PIL import Image as PilImage
if not os.path.exists('./images/default_identicon/'):
os.makedirs('./images/default_identicon/')
newImg = PilImage.open(path).resize((300, 300)) newImg = PilImage.open(path).resize((300, 300))
newImg.save('./images/default_identicon/{0}.png'.format(state.association)) if platform == 'android':
android_path = os.path.join(
os.environ['ANDROID_PRIVATE'] + '/app/')
newImg.save('{1}/images/default_identicon/{0}.png'.format(
state.association, android_path))
else:
if not os.path.exists('./images/default_identicon/'):
os.makedirs('./images/default_identicon/')
newImg.save('./images/default_identicon/{0}.png'.format(state.association))
self.load_selected_Image(state.association) self.load_selected_Image(state.association)
self.exit_manager() self.exit_manager()
toast('Image changed') toast('Image changed')
def exit_manager(self, *args): def exit_manager(self, *args):
"""Called when the user reaches the root of the directory tree.""" """Called when the user reaches the root of the directory tree."""
self.manager.dismiss() self.manager.dismiss()
self.manager_open = False self.manager_open = False
@ -1995,6 +2080,11 @@ class NavigateApp(MDApp):
Clipboard.copy(text) Clipboard.copy(text)
toast('Copied') toast('Copied')
def reset_login_screen(self):
"""This method is used for clearing random screen"""
if self.root.ids.sc7.ids.add_random_bx.children:
self.root.ids.sc7.ids.add_random_bx.clear_widgets()
class GrashofPopup(Popup): class GrashofPopup(Popup):
"""Moule for save contacts and error messages""" """Moule for save contacts and error messages"""
@ -2040,9 +2130,9 @@ class GrashofPopup(Popup):
def checkAddress_valid(self, instance): def checkAddress_valid(self, instance):
"""Checking address is valid or not""" """Checking address is valid or not"""
# my_addresses = ( # my_addresses = (
# self.parent.children[1].children[2].children[0].ids.btn.values) # self.parent.children[1].children[0].children[0].ids.btn.values)
my_addresses = ( my_addresses = (
self.parent.children[1].children[0].children[0].ids.btn.values) state.kivyapp.root.children[0].children[0].ids.btn.values)
add_book = [addr[1] for addr in kivy_helper_search.search_sql( add_book = [addr[1] for addr in kivy_helper_search.search_sql(
folder="addressbook")] folder="addressbook")]
entered_text = str(instance.text).strip() entered_text = str(instance.text).strip()
@ -2129,6 +2219,12 @@ class IconRightSampleWidget(IRightBodyTouch, MDIconButton):
pass pass
class TimeTagRightSampleWidget(IRightBodyTouch, MDLabel):
"""Right icon sample widget"""
pass
class ToggleBtn(IRightBodyTouch, MDSwitch): class ToggleBtn(IRightBodyTouch, MDSwitch):
"""Right toggle button widget""" """Right toggle button widget"""
pass pass
@ -2254,6 +2350,7 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes
def inbox_reply(self): def inbox_reply(self):
"""Reply inbox messages""" """Reply inbox messages"""
state.in_composer = True
data = sqlQuery( data = sqlQuery(
"select toaddress, fromaddress, subject, message, received from inbox where" "select toaddress, fromaddress, subject, message, received from inbox where"
" msgid = ?;", state.mail_id) " msgid = ?;", state.mail_id)
@ -2265,10 +2362,11 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes
composer_obj.subject.text = 'Re: ' + (split_subject[1] if len(split_subject) > 1 else split_subject[0]) composer_obj.subject.text = 'Re: ' + (split_subject[1] if len(split_subject) > 1 else split_subject[0])
time_obj = datetime.fromtimestamp(int(data[0][4])) time_obj = datetime.fromtimestamp(int(data[0][4]))
time_tag = time_obj.strftime("%d %b %Y, %I:%M %p") time_tag = time_obj.strftime("%d %b %Y, %I:%M %p")
sender_name = BMConfigParser().get(data[0][1], 'label') # sender_name = BMConfigParser().get(data[0][1], 'label')
sender_name = data[0][1]
composer_obj.body.text = ( composer_obj.body.text = (
'\n\n ------------------------On ' + time_tag + ', ' '\n\n --------------On ' + time_tag + ', '
+ sender_name + ' wrote:-----------------------\n' + data[0][3]) + sender_name + ' wrote:--------------\n' + data[0][3])
composer_obj.body.focus = True composer_obj.body.focus = True
composer_obj.body.cursor = (0, 0) composer_obj.body.cursor = (0, 0)
state.kivyapp.root.ids.sc3.children[1].ids.rv.data = '' state.kivyapp.root.ids.sc3.children[1].ids.rv.data = ''
@ -2507,6 +2605,7 @@ class Draft(Screen):
text='Draft', secondary_text=item['text'], text='Draft', secondary_text=item['text'],
theme_text_color='Custom', theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny._txt_right_pad = dp(70)
meny.add_widget(AvatarSampleWidget( meny.add_widget(AvatarSampleWidget(
source='./images/avatar.png')) source='./images/avatar.png'))
meny.bind(on_press=partial( meny.bind(on_press=partial(
@ -2709,6 +2808,7 @@ class Allmails(Screen):
subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', ''), subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', ''),
theme_text_color='Custom', theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny._txt_right_pad = dp(70)
meny.add_widget(AvatarSampleWidget( meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format( source='./images/text_images/{}.png'.format(
avatarImageFirstLetter(body.strip())))) avatarImageFirstLetter(body.strip()))))
@ -2798,6 +2898,7 @@ class Allmails(Screen):
nav_lay_obj.sc5.clear_widgets() nav_lay_obj.sc5.clear_widgets()
nav_lay_obj.sc5.add_widget(Trash()) nav_lay_obj.sc5.add_widget(Trash())
nav_lay_obj.sc17.remove_widget(instance.parent.parent) nav_lay_obj.sc17.remove_widget(instance.parent.parent)
toast('Deleted')
def refresh_callback(self, *args): def refresh_callback(self, *args):
"""Method updates the state of application, """Method updates the state of application,
@ -2818,16 +2919,16 @@ class Allmails(Screen):
def avatarImageFirstLetter(letter_string): def avatarImageFirstLetter(letter_string):
"""This function is used to the first letter for the avatar image""" """This function is used to the first letter for the avatar image"""
if letter_string: try:
if letter_string[0].upper() >= 'A' and letter_string[0].upper() <= 'Z': if letter_string[0].upper() >= 'A' and letter_string[0].upper() <= 'Z':
img_latter = letter_string[0].upper() img_latter = letter_string[0].upper()
elif int(letter_string[0]) >= 0 and int(letter_string[0]) <= 9: elif int(letter_string[0]) >= 0 and int(letter_string[0]) <= 9:
img_latter = letter_string[0] img_latter = letter_string[0]
else: else:
img_latter = '!' img_latter = '!'
else: except ValueError:
img_latter = '!' img_latter = '!'
return img_latter return img_latter if img_latter else '!'
class Starred(Screen): class Starred(Screen):
@ -2945,18 +3046,23 @@ class SenderDetailPopup(Popup):
self.from_addr = from_addr self.from_addr = from_addr
time_obj = datetime.fromtimestamp(int(timeinseconds)) time_obj = datetime.fromtimestamp(int(timeinseconds))
self.time_tag = time_obj.strftime("%d %b %Y, %I:%M %p") self.time_tag = time_obj.strftime("%d %b %Y, %I:%M %p")
pop_height = 1.2 * (self.ids.sd_label.height + self.ids.sd_btn.children[0].height) device_type = 2 if platform == 'android' else 1.5
pop_height = device_type * (self.ids.sd_label.height + self.ids.sd_btn.children[0].height)
if len(to_addr) > 3: if len(to_addr) > 3:
self.height = 0 self.height = 0
self.height = pop_height self.height = pop_height
self.ids.to_addId.size_hint_y = None self.ids.to_addId.size_hint_y = None
self.ids.to_addId.height = 50 self.ids.to_addId.height = 50
self.ids.to_addtitle.add_widget(ToAddressTitle())
frmaddbox = ToAddrBoxlayout() frmaddbox = ToAddrBoxlayout()
frmaddbox.set_toAddress(to_addr) frmaddbox.set_toAddress(to_addr)
self.ids.to_addId.add_widget(frmaddbox) self.ids.to_addId.add_widget(frmaddbox)
else: else:
self.ids.space_1.height = dp(0)
self.ids.space_2.height = dp(0)
self.ids.myadd_popup_box.spacing = dp(8 if platform == 'android' else 3)
self.height = 0 self.height = 0
self.height = pop_height / 1.5 self.height = pop_height / 1.2
class OneLineListTitle(OneLineListItem): class OneLineListTitle(OneLineListItem):
@ -3006,3 +3112,91 @@ class ToAddrBoxlayout(BoxLayout):
def set_toAddress(self, to_addr): def set_toAddress(self, to_addr):
"""This method is use to set to address""" """This method is use to set to address"""
self.to_addr = to_addr self.to_addr = to_addr
class ToAddressTitle(BoxLayout):
"""class for BoxLayout behaviour"""
pass
class RandomBoxlayout(BoxLayout):
"""class for BoxLayout behaviour"""
pass
def esc_markup(msg):
"""this method is for replacing some property"""
return (msg.replace('&', '&amp;')
.replace('[', '&bl;')
.replace(']', '&br;'))
class ChatRoom(Screen):
"""class for chatroom screen"""
def send_msg(self):
"""This method is for sending message"""
msg = self.ids.message.text
if msg:
self.ids.chat_logs.text += (
'[b][color=2980b9]{}:[/color][/b] {}\n'
.format('Me', esc_markup(msg)))
# obj = MDChip(label=msg, radius=7)
# obj.icon = ''
# self.ids.ml.add_widget(obj)
self.ids.message.text = ''
class ChatList(Screen):
"""class for showing chat list"""
queryreturn = ListProperty()
has_refreshed = True
def __init__(self, *args, **kwargs):
"""Getting ChatList Details"""
super(ChatList, self).__init__(*args, **kwargs)
Clock.schedule_once(self.init_ui, 0)
def init_ui(self, dt=0):
"""Clock Schdule for method ChatList"""
self.loadAddresslist(None, 'All', '')
print(dt)
def loadAddresslist(self, account="", where="", what=""):
"""Clock Schdule for method ChatList"""
self.queryreturn = kivy_helper_search.search_sql(
'', account, "addressbook", where, what, False)
self.queryreturn = [obj for obj in reversed(self.queryreturn)]
if self.queryreturn:
self.set_mdList()
else:
content = MDLabel(
font_style='Caption',
theme_text_color='Primary',
text="No contact found!",
halign='center',
size_hint_y=None,
valign='top')
self.ids.ml.add_widget(content)
def set_mdList(self):
"""Creating the mdList"""
for item in self.queryreturn:
meny = TwoLineAvatarIconListItem(
text=item[0], secondary_text=item[1], theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color)
meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format(
avatarImageFirstLetter(item[0].strip()))))
meny.bind(on_release=partial(
self.redirect_to_chat, item[0], item[1]))
self.ids.ml.add_widget(meny)
def redirect_to_chat(self, label, addr, *args):
"""This method is redirecting on chatroom"""
self.manager.transition = RiseInTransition()
state.kivyapp.set_toolbar_for_QrCode()
label = label[:14].capitalize() + '...' if len(label) > 15 else label.capitalize()
addrs = ' (' + addr + ')'
self.manager.parent.ids.toolbar.title = label + addrs
self.manager.parent.ids.sc21.ids.chat_logs.text = ''
self.manager.current = 'chroom'

View File

@ -234,7 +234,7 @@ class NewAddressWizardWaitPage(QtGui.QWizardPage):
self.wizard().button(QtGui.QWizard.NextButton).click() self.wizard().button(QtGui.QWizard.NextButton).click()
return return
elif i == 101: elif i == 101:
print "haha" print("haha")
return return
self.progressBar.setValue(i) self.progressBar.setValue(i)
if i == 50: if i == 50:
@ -347,8 +347,8 @@ if __name__ == '__main__':
wizard = Ui_NewAddressWizard(["a", "b", "c", "d"]) wizard = Ui_NewAddressWizard(["a", "b", "c", "d"])
if (wizard.exec_()): if (wizard.exec_()):
print "Email: " + ("yes" if wizard.field("emailAsWell").toBool() else "no") print("Email: " + ("yes" if wizard.field("emailAsWell").toBool() else "no"))
print "BM: " + ("yes" if wizard.field("onlyBM").toBool() else "no") print("BM: " + ("yes" if wizard.field("onlyBM").toBool() else "no"))
else: else:
print "Wizard cancelled" print("Wizard cancelled")
sys.exit() sys.exit()

View File

@ -57,9 +57,7 @@ class BMConfigParser(configparser.ConfigParser):
return configparser.ConfigParser.set(self, section, option, value) return configparser.ConfigParser.set(self, section, option, value)
def get(self, section, option, raw=False, vars=None): def get(self, section, option, raw=False, vars=None):
# import pdb;pdb.set_trace()
# pylint: disable=unused-argument # pylint: disable=unused-argument
# import pdb; pdb.set_trace()
try: try:
if section == "bitmessagesettings" and option == "timeformat": if section == "bitmessagesettings" and option == "timeformat":
return configparser.ConfigParser.get( return configparser.ConfigParser.get(

View File

@ -1,10 +1,10 @@
[app] [app]
# (str) Title of your application # (str) Title of your application
title = bitapp title = py3
# (str) Package name # (str) Package name
package.name = bitapp package.name = py3
# (str) Package domain (needed for android/ios packaging) # (str) Package domain (needed for android/ios packaging)
package.domain = org.test package.domain = org.test
@ -37,12 +37,13 @@ version = 0.1
# (list) Application requirements # (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy # comma separated e.g. requirements = sqlite3,kivy
requirements = requirements =
python3,
openssl, openssl,
sqlite3, sqlite3,
python2,
kivy, kivy,
bitmsghash, bitmsghash,
kivymd, #git+https://github.com/surbhicis/KivyMD-1.git,
git+https://github.com/surbhicis/KivyMD-1#egg=kivymd,
kivy-garden, kivy-garden,
qrcode, qrcode,
Pillow, Pillow,
@ -206,7 +207,7 @@ android.arch = armeabi-v7a
# #
# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github) # (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
#p4a.source_dir = p4a.source_dir = /home/cis/Music/androidp4a/python-for-android
# (str) The directory in which python-for-android should look for your own build recipes (if any) # (str) The directory in which python-for-android should look for your own build recipes (if any)
p4a.local_recipes = /home/cis/navjotrepo/PyBitmessage/src/bitmessagekivy/android/python-for-android/recipes/ p4a.local_recipes = /home/cis/navjotrepo/PyBitmessage/src/bitmessagekivy/android/python-for-android/recipes/

View File

@ -390,7 +390,24 @@ class sqlThread(threading.Thread):
logger.debug( logger.debug(
'In messages.dat database, done adding address field to the pubkeys table' 'In messages.dat database, done adding address field to the pubkeys table'
' and removing the hash field.') ' and removing the hash field.')
self.cur.execute('''update settings set value=10 WHERE key='version';''') query = '''update settings set value=? WHERE key='version';'''
parameters = (10,)
self.cur.execute(query, parameters)
# Add a new table: chat and chatdata for storing chating conversation
item = '''SELECT value FROM settings WHERE key='version';'''
parameters = ''
self.cur.execute(item, parameters)
currentVersion = int(self.cur.fetchall()[0][0])
if currentVersion == 10:
self.cur.execute(
'''CREATE TABLE chat'''
''' (msgid blob, senderaddress text, receiveraddress text, message text,'''
''' receivedtime text, image blob, audio blob, reference blob,'''
''' UNIQUE(msgid) ON CONFLICT REPLACE)''')
item = '''update settings set value=? WHERE key='version';'''
parameters = (11,)
self.cur.execute(item, parameters)
# Are you hoping to add a new option to the keys.dat file of existing # Are you hoping to add a new option to the keys.dat file of existing
# Bitmessage users or modify the SQLite database? Add it right # Bitmessage users or modify the SQLite database? Add it right

View File

@ -4,6 +4,10 @@ and suggest how it may be installed
""" """
import sys import sys
import logging
import os
import state
from importlib import import_module
# Only really old versions of Python don't have sys.hexversion. We don't # Only really old versions of Python don't have sys.hexversion. We don't
# support them. The logging module was introduced in Python 2.3 # support them. The logging module was introduced in Python 2.3
@ -14,10 +18,6 @@ if not hasattr(sys, 'hexversion') or sys.hexversion < 0x20300F0:
% sys.version % sys.version
) )
import logging
import os
from importlib import import_module
import state
# We can now use logging so set up a simple configuration # We can now use logging so set up a simple configuration
formatter = logging.Formatter('%(levelname)s: %(message)s') formatter = logging.Formatter('%(levelname)s: %(message)s')
handler = logging.StreamHandler(sys.stdout) handler = logging.StreamHandler(sys.stdout)
@ -304,7 +304,10 @@ def check_openssl():
' OpenSSL 0.9.8b or later with AES, Elliptic Curves (EC),' ' OpenSSL 0.9.8b or later with AES, Elliptic Curves (EC),'
' ECDH, and ECDSA enabled.') ' ECDH, and ECDSA enabled.')
return False return False
matches = cflags_regex.findall(openssl_cflags) if sys.version_info >= (3, 0, 0):
matches = cflags_regex.findall(str(openssl_cflags))
else:
matches = cflags_regex.findall(openssl_cflags)
if matches: if matches:
logger.error( logger.error(
'This OpenSSL library is missing the following required' 'This OpenSSL library is missing the following required'
@ -356,7 +359,8 @@ def check_curses():
# The pythondialog author does not like Python2 str, so we have to use # The pythondialog author does not like Python2 str, so we have to use
# unicode for just the version otherwise we get the repr form which # unicode for just the version otherwise we get the repr form which
# includes the module and class names along with the actual version. # includes the module and class names along with the actual version.
logger.info('dialog Utility Version %s', unicode(dialog_util_version)) # logger.info('dialog Utility Version %s', unicode(dialog_util_version))
logger.info('dialog Utility Version %s', str(dialog_util_version))
return True return True

View File

@ -20,7 +20,7 @@ class MsgBase(object): # pylint: disable=too-few-public-methods
def constructObject(data): def constructObject(data):
"""Constructing an object""" """Constructing an object"""
whitelist = ["message"] whitelist = ["message", "chatmsg"]
if data[""] not in whitelist: if data[""] not in whitelist:
return None return None
try: try:

View File

@ -0,0 +1,34 @@
import logging
from messagetypes import MsgBase
# pylint: disable=attribute-defined-outside-init
logger = logging.getLogger('default')
class Chatmsg(MsgBase):
"""Encapsulate a chatmsg"""
# pylint: disable=attribute-defined-outside-init
def decode(self, data):
"""Decode a message"""
# UTF-8 and variable type validator
if isinstance(data["message"], str):
# Unicode is depreciated
self.message = data["message"]
else:
# Unicode is depreciated
self.message = str(data["message"])
def encode(self, data):
"""Encode a message"""
super(Chatmsg, self).__init__()
try:
self.data["message"] = data["message"]
except KeyError as e:
logger.error("Missing key %s", e)
return self.data
def process(self):
"""Process a message"""
logger.debug("Message: %i bytes", len(self.message))

View File

@ -174,7 +174,7 @@ class namecoinConnection(object):
message = ('failed', tr._translate("MainWindow", 'Couldn\'t understand NMControl.')) message = ('failed', tr._translate("MainWindow", 'Couldn\'t understand NMControl.'))
else: else:
print "Unsupported Namecoin type" print("Unsupported Namecoin type")
sys.exit(1) sys.exit(1)
return message return message

View File

@ -542,15 +542,11 @@ class BMProto(AdvancedDispatcher, ObjectTracker):
'%(host)s:%(port)i sending version', '%(host)s:%(port)i sending version',
self.destination._asdict()) self.destination._asdict())
if self.services & protocol.NODE_SSL == protocol.NODE_SSL: if self.services & protocol.NODE_SSL == protocol.NODE_SSL:
# self.isSSL = True self.isSSL = True
pass
if not self.verackReceived: if not self.verackReceived:
return True return True
# self.set_state(
# "tls_init" if self.isSSL else "connection_fully_established",
# length=self.payloadLength, expectBytes=0)
self.set_state( self.set_state(
"connection_fully_established", "tls_init" if self.isSSL else "connection_fully_established",
length=self.payloadLength, expectBytes=0) length=self.payloadLength, expectBytes=0)
return False return False

View File

@ -19,19 +19,19 @@ class HttpConnection(AdvancedDispatcher):
self.destination = (host, 80) self.destination = (host, 80)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM) self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.connect(self.destination) self.connect(self.destination)
print "connecting in background to %s:%i" % (self.destination[0], self.destination[1]) print("connecting in background to %s:%i" % (self.destination[0], self.destination[1]))
def state_init(self): def state_init(self):
self.append_write_buf( self.append_write_buf(
"GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n" % ( "GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n" % (
self.path, self.destination[0])) self.path, self.destination[0]))
print "Sending %ib" % (len(self.write_buf)) print("Sending %ib" % (len(self.write_buf)))
self.set_state("http_request_sent", 0) self.set_state("http_request_sent", 0)
return False return False
def state_http_request_sent(self): def state_http_request_sent(self):
if self.read_buf: if self.read_buf:
print "Received %ib" % (len(self.read_buf)) print("Received %ib" % (len(self.read_buf)))
self.read_buf = b"" self.read_buf = b""
if not self.connected: if not self.connected:
self.set_state("close", 0) self.set_state("close", 0)
@ -63,13 +63,13 @@ if __name__ == "__main__":
for host in ("bootstrap8080.bitmessage.org", "bootstrap8444.bitmessage.org"): for host in ("bootstrap8080.bitmessage.org", "bootstrap8444.bitmessage.org"):
proxy = Socks5Resolver(host=host) proxy = Socks5Resolver(host=host)
while asyncore.socket_map: while asyncore.socket_map:
print "loop %s, len %i" % (proxy.state, len(asyncore.socket_map)) print("loop %s, len %i" % (proxy.state, len(asyncore.socket_map)))
asyncore.loop(timeout=1, count=1) asyncore.loop(timeout=1, count=1)
proxy.resolved() proxy.resolved()
proxy = Socks4aResolver(host=host) proxy = Socks4aResolver(host=host)
while asyncore.socket_map: while asyncore.socket_map:
print "loop %s, len %i" % (proxy.state, len(asyncore.socket_map)) print("loop %s, len %i" % (proxy.state, len(asyncore.socket_map)))
asyncore.loop(timeout=1, count=1) asyncore.loop(timeout=1, count=1)
proxy.resolved() proxy.resolved()

View File

@ -49,7 +49,7 @@ if __name__ == "__main__":
if len(asyncore.socket_map) < parallel: if len(asyncore.socket_map) < parallel:
for i in range(parallel - len(asyncore.socket_map)): for i in range(parallel - len(asyncore.socket_map)):
HTTPClient('127.0.0.1', '/') HTTPClient('127.0.0.1', '/')
print "Active connections: %i" % (len(asyncore.socket_map)) print("Active connections: %i" % (len(asyncore.socket_map)))
asyncore.loop(count=len(asyncore.socket_map) / 2) asyncore.loop(count=len(asyncore.socket_map) / 2)
if requestCount % 100 == 0: if requestCount % 100 == 0:
print "Processed %i total messages" % (requestCount) print("Processed %i total messages" % (requestCount))

View File

@ -68,6 +68,7 @@ class TLSDispatcher(AdvancedDispatcher):
self.tlsDone = False self.tlsDone = False
self.tlsVersion = "N/A" self.tlsVersion = "N/A"
self.isSSL = False self.isSSL = False
self.sslSocket = None
def state_tls_init(self): def state_tls_init(self):
"""Prepare sockets for TLS handshake""" """Prepare sockets for TLS handshake"""
@ -76,28 +77,6 @@ class TLSDispatcher(AdvancedDispatcher):
self.tlsStarted = True self.tlsStarted = True
# Once the connection has been established, # Once the connection has been established,
# it's safe to wrap the socket. # it's safe to wrap the socket.
if sys.version_info >= (2, 7, 9):
context = ssl.create_default_context(
purpose=ssl.Purpose.SERVER_AUTH
if self.server_side else ssl.Purpose.CLIENT_AUTH)
context.set_ciphers(self.ciphers)
context.set_ecdh_curve("secp256k1")
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
# also exclude TLSv1 and TLSv1.1 in the future
context.options = ssl.OP_ALL | ssl.OP_NO_SSLv2 |\
ssl.OP_NO_SSLv3 | ssl.OP_SINGLE_ECDH_USE |\
ssl.OP_CIPHER_SERVER_PREFERENCE
self.sslSocket = context.wrap_socket(
self.socket, server_side=self.server_side,
do_handshake_on_connect=False)
else:
self.sslSocket = ssl.wrap_socket(
self.socket, server_side=self.server_side,
ssl_version=sslProtocolVersion,
certfile=self.certfile, keyfile=self.keyfile,
ciphers=self.ciphers, do_handshake_on_connect=False)
self.sslSocket.setblocking(0)
self.want_read = self.want_write = True self.want_read = self.want_write = True
self.set_state("tls_handshake") self.set_state("tls_handshake")
return False return False
@ -127,7 +106,6 @@ class TLSDispatcher(AdvancedDispatcher):
# during TLS handshake, and after flushing write buffer, # during TLS handshake, and after flushing write buffer,
# return status of last handshake attempt # return status of last handshake attempt
if self.tlsStarted and not self.tlsDone and not self.write_buf: if self.tlsStarted and not self.tlsDone and not self.write_buf:
# print "tls readable, %r" % (self.want_read)
return self.want_read return self.want_read
# prior to TLS handshake, # prior to TLS handshake,
# receiveDataThread should emulate synchronous behaviour # receiveDataThread should emulate synchronous behaviour
@ -145,7 +123,6 @@ class TLSDispatcher(AdvancedDispatcher):
and normal reads must be ignored. and normal reads must be ignored.
""" """
try: try:
# wait for write buffer flush
if self.tlsStarted and not self.tlsDone and not self.write_buf: if self.tlsStarted and not self.tlsDone and not self.write_buf:
# logger.debug( # logger.debug(
# "%s:%i TLS handshaking (read)", self.destination.host, # "%s:%i TLS handshaking (read)", self.destination.host,
@ -182,9 +159,6 @@ class TLSDispatcher(AdvancedDispatcher):
# self.destination.port) # self.destination.port)
self.tls_handshake() self.tls_handshake()
else: else:
# logger.debug(
# "%s:%i Not TLS handshaking (write)", self.destination.host,
# self.destination.port)
return AdvancedDispatcher.handle_write(self) return AdvancedDispatcher.handle_write(self)
except AttributeError: except AttributeError:
return AdvancedDispatcher.handle_write(self) return AdvancedDispatcher.handle_write(self)
@ -198,11 +172,37 @@ class TLSDispatcher(AdvancedDispatcher):
self.handle_close() self.handle_close()
return return
def tls_handshake(self): def tls_handshake(self): # pylint:disable=too-many-branches
"""Perform TLS handshake and handle its stages""" """Perform TLS handshake and handle its stages"""
# wait for flush # wait for flush
# self.sslSocket.setblocking(0)
if self.write_buf: if self.write_buf:
return False return False
if not self.sslSocket:
self.del_channel()
if sys.version_info >= (2, 7, 9):
context = ssl.create_default_context(
purpose=ssl.Purpose.SERVER_AUTH
if self.server_side else ssl.Purpose.CLIENT_AUTH)
context.set_ciphers(self.ciphers)
context.set_ecdh_curve("secp256k1")
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
# also exclude TLSv1 and TLSv1.1 in the future
context.options = ssl.OP_ALL | ssl.OP_NO_SSLv2 |\
ssl.OP_NO_SSLv3 | ssl.OP_SINGLE_ECDH_USE |\
ssl.OP_CIPHER_SERVER_PREFERENCE
self.sslSocket = context.wrap_socket(
self.socket, server_side=self.server_side,
do_handshake_on_connect=False)
else:
self.sslSocket = ssl.wrap_socket(
self.socket, server_side=self.server_side,
ssl_version=sslProtocolVersion,
certfile=self.certfile, keyfile=self.keyfile,
ciphers=self.ciphers, do_handshake_on_connect=False)
self.sslSocket.setblocking(0)
self.set_socket(self.sslSocket)
# Perform the handshake. # Perform the handshake.
try: try:
self.sslSocket.do_handshake() self.sslSocket.do_handshake()
@ -233,8 +233,6 @@ class TLSDispatcher(AdvancedDispatcher):
'%s:%i: TLS handshake success', '%s:%i: TLS handshake success',
self.destination.host, self.destination.port) self.destination.host, self.destination.port)
# The handshake has completed, so remove this channel and... # The handshake has completed, so remove this channel and...
self.del_channel()
self.set_socket(self.sslSocket)
self.tlsDone = True self.tlsDone = True
self.bm_proto_reset() self.bm_proto_reset()

View File

@ -231,7 +231,6 @@ def haveSSL(server=False):
python < 2.7.9's ssl library does not support ECDSA server due to python < 2.7.9's ssl library does not support ECDSA server due to
missing initialisation of available curves, but client works ok missing initialisation of available curves, but client works ok
""" """
return False
if not server: if not server:
return True return True
elif sys.version_info >= (2, 7, 9): elif sys.version_info >= (2, 7, 9):

View File

@ -82,7 +82,7 @@ class _OpenSSL(object):
"""Build the wrapper""" """Build the wrapper"""
self._lib = ctypes.CDLL(library) self._lib = ctypes.CDLL(library)
self._version, self._hexversion, self._cflags = get_version(self._lib) self._version, self._hexversion, self._cflags = get_version(self._lib)
self._libreSSL = (self._version).decode("utf-8").startswith("OpenSSL") self._libreSSL = (self._version).decode("utf-8").startswith("LibreSSL")
self.pointer = ctypes.pointer self.pointer = ctypes.pointer
self.c_int = ctypes.c_int self.c_int = ctypes.c_int

22
src/tests/test_chatmsg.py Normal file
View File

@ -0,0 +1,22 @@
"""
Test for chatmsg group
"""
import unittest
from messagetypes.chatmsg import Chatmsg
class TestCharMessage(unittest.TestCase):
"""
Test case for chat message group
"""
def test_decode(self):
"""Test various types of decode method"""
import messagetypes
result = messagetypes.constructObject({'': 'chatmsg', 'message': 'hello world'})
self.assertTrue(isinstance(result.message, str))
def test_encode(self):
"""Test various types of encode method"""
chat_obj = Chatmsg()
result = chat_obj.encode({'message': 'hello world'})
self.assertTrue(True if result['message'] else False)