1
- # -*- coding : utf-8 -*-
1
+ """Coding : utf-8."""
2
2
from kivy .app import App
3
3
from kivy .lang import Builder
4
4
from kivy .metrics import dp
5
5
from kivy .properties import ObjectProperty
6
6
from kivy .uix .image import Image
7
- from kivy .uix .screenmanager import Screen , NoTransition
8
- from kivymd .bottomsheet import MDListBottomSheet , MDGridBottomSheet
7
+ from kivy .uix .screenmanager import Screen
9
8
from kivymd .button import MDIconButton
10
- from kivymd .date_picker import MDDatePicker
11
9
from kivymd .dialog import MDDialog
12
10
from kivymd .label import MDLabel
13
- from kivymd .list import ILeftBody , ILeftBodyTouch , IRightBodyTouch , BaseListItem
14
- from kivymd .material_resources import DEVICE_TYPE
11
+ from kivymd .list import ILeftBody , ILeftBodyTouch , IRightBodyTouch
15
12
from kivymd .navigationdrawer import MDNavigationDrawer , NavigationDrawerHeaderBase
16
13
from kivymd .selectioncontrols import MDCheckbox
17
- from kivymd .snackbar import Snackbar
18
14
from kivymd .theming import ThemeManager
19
- from kivymd .time_picker import MDTimePicker
20
15
from kivymd .list import ThreeLineAvatarIconListItem , TwoLineAvatarIconListItem , TwoLineListItem
21
16
from kivy .properties import ListProperty , StringProperty , BooleanProperty
22
17
from kivy .clock import Clock
23
18
from bmconfigparser import BMConfigParser
24
19
import state
25
20
import queues
26
21
from kivy .uix .popup import Popup
27
- from helper_sql import *
28
- from kivy .uix .gridlayout import GridLayout
29
- from kivy .app import App
22
+ from helper_sql import sqlQuery , sqlExecute
30
23
from kivy .uix .textinput import TextInput
31
- from kivy .lang import Builder
32
24
from kivy .uix .boxlayout import BoxLayout
33
25
from kivy .uix .floatlayout import FloatLayout
34
- from kivy .properties import NumericProperty , ListProperty , BooleanProperty , ObjectProperty
26
+ from kivy .properties import NumericProperty
35
27
from kivy .uix .recycleview import RecycleView
36
- from kivy .uix .recyclegridlayout import RecycleGridLayout
37
28
from kivy .uix .recycleview .views import RecycleDataViewBehavior
38
29
from kivy .uix .label import Label
39
30
from kivy .uix .recycleboxlayout import RecycleBoxLayout
50
41
from kivy .utils import platform
51
42
from kivy .uix .spinner import Spinner
52
43
44
+
53
45
class Navigatorss (MDNavigationDrawer ):
46
+ """Navigators class contains image, title and logo."""
47
+
54
48
image_source = StringProperty ('images/qidenticon_two.png' )
55
49
title = StringProperty ('Navigation' )
56
50
drawer_logo = StringProperty ()
57
51
58
52
59
53
class Inbox (Screen ):
60
54
"""Inbox Screen uses screen to show widgets of screens."""
55
+
61
56
data = ListProperty ()
62
57
63
58
def __init__ (self , * args , ** kwargs ):
59
+ """Method Parsing the address."""
64
60
super (Inbox , self ).__init__ (* args , ** kwargs )
65
61
if state .association == '' :
66
62
if BMConfigParser ().addresses ():
@@ -89,16 +85,31 @@ def loadMessagelist(self, account, where="", what=""):
89
85
if queryreturn :
90
86
for mail in queryreturn :
91
87
third_text = mail [3 ].replace ('\n ' , ' ' )
92
- data .append ({'text' : mail [4 ].strip (), 'secondary_text' : mail [5 ][:10 ] + '...........' if len (mail [3 ]) > 10 else mail [3 ] + '\n ' + " " + (third_text [:25 ] + '...!' ) if len (third_text ) > 25 else third_text , 'receivedTime' : mail [6 ] })
88
+ data .append ({
89
+ 'text' : mail [4 ].strip (),
90
+ 'secondary_text' : mail [5 ][:10 ] + '...........' if len (
91
+ mail [3 ]) > 10 else mail [3 ] + '\n ' + " " + (
92
+ third_text [:25 ] + '...!' ) if len (
93
+ third_text ) > 25 else third_text ,
94
+ 'receivedTime' : mail [6 ]})
93
95
for item in data :
94
- meny = ThreeLineAvatarIconListItem (text = item ['text' ], secondary_text = item ['secondary_text' ], theme_text_color = 'Custom' , text_color = NavigateApp ().theme_cls .primary_color )
95
- meny .add_widget (AvatarSampleWidget (source = './images/text_images/{}.png' .format (item ['secondary_text' ][0 ].upper () if (item ['secondary_text' ][0 ].upper () >= 'A' and item ['secondary_text' ][0 ].upper () <= 'Z' ) else '!' )))
96
- meny .bind (on_press = partial (self .inbox_detail , item ['receivedTime' ]))
96
+ meny = ThreeLineAvatarIconListItem (
97
+ text = item ['text' ],
98
+ secondary_text = item ['secondary_text' ],
99
+ theme_text_color = 'Custom' ,
100
+ text_color = NavigateApp ().theme_cls .primary_color )
101
+ meny .add_widget (
102
+ AvatarSampleWidget (
103
+ source = './images/text_images/{}.png' .format (
104
+ item ['secondary_text' ][0 ].upper () if (
105
+ item ['secondary_text' ][0 ].upper () >= 'A' and item [
106
+ 'secondary_text' ][0 ].upper () <= 'Z' ) else '!' )))
107
+ meny .bind (on_press = partial (self .inbox_detail , item ['receivedTime' ]))
97
108
carousel = Carousel (direction = 'right' )
98
109
if platform == 'android' :
99
110
carousel .height = 150
100
111
elif platform == 'linux' :
101
- carousel .height = meny .height - 10
112
+ carousel .height = meny .height - 10
102
113
carousel .size_hint_y = None
103
114
carousel .ignore_perpendicular_swipes = True
104
115
carousel .data_index = 0
@@ -110,7 +121,7 @@ def loadMessagelist(self, account, where="", what=""):
110
121
carousel .add_widget (del_btn )
111
122
carousel .add_widget (meny )
112
123
ach_btn = Button (text = 'Achieve' )
113
- ach_btn .background_color = (0 ,1 , 0 , 1 )
124
+ ach_btn .background_color = (0 , 1 , 0 , 1 )
114
125
ach_btn .bind (on_press = partial (self .archive , item ['receivedTime' ]))
115
126
carousel .add_widget (ach_btn )
116
127
carousel .index = 1
@@ -126,7 +137,7 @@ def loadMessagelist(self, account, where="", what=""):
126
137
self .ids .ml .add_widget (content )
127
138
128
139
def inbox_detail (self , receivedTime , * args ):
129
- """Load inbox page details"""
140
+ """Load inbox page details. """
130
141
state .detailPageType = 'inbox'
131
142
state .sentMailTime = receivedTime
132
143
if self .manager :
@@ -140,7 +151,7 @@ def inbox_detail(self, receivedTime, *args):
140
151
src_mng_obj .current = 'mailDetail'
141
152
142
153
def delete (self , data_index , instance , * args ):
143
- """Delete inbox mail from inbox listing"""
154
+ """Delete inbox mail from inbox listing. """
144
155
sqlExecute ("UPDATE inbox SET folder = 'trash' WHERE received = {};" .format (data_index ))
145
156
msg_count_objs = self .parent .parent .parent .parent .children [2 ].children [0 ].ids
146
157
if int (state .inbox_count ) > 0 :
@@ -152,13 +163,13 @@ def delete(self, data_index, instance, *args):
152
163
self .update_trash ()
153
164
154
165
def archive (self , data_index , instance , * args ):
155
- """Archive inbox mail from inbox listing"""
166
+ """Archive inbox mail from inbox listing. """
156
167
sqlExecute ("UPDATE inbox SET folder = 'trash' WHERE received = {};" .format (data_index ))
157
168
self .ids .ml .remove_widget (instance .parent .parent )
158
169
self .update_trash ()
159
170
160
171
def update_trash (self ):
161
- """Update trash screen mails which is deleted from inbox"""
172
+ """Update trash screen mails which is deleted from inbox. """
162
173
try :
163
174
self .parent .screens [4 ].clear_widgets ()
164
175
self .parent .screens [4 ].add_widget (Trash ())
@@ -167,11 +178,9 @@ def update_trash(self):
167
178
self .parent .parent .screens [4 ].add_widget (Trash ())
168
179
169
180
def refresh_callback (self , * args ):
170
- """A method that updates the state of your application
171
- while the spinner remains on the screen."""
172
-
181
+ """A method that updates the state of your application while the spinner remains on the screen."""
173
182
def refresh_callback (interval ):
174
- """This methods is used for loading the inbox screen data"""
183
+ """Method used for loading the inbox screen data. """
175
184
self .ids .ml .clear_widgets ()
176
185
self .remove_widget (self .children [1 ])
177
186
try :
@@ -187,7 +196,9 @@ def refresh_callback(interval):
187
196
188
197
class MyAddress (Screen ):
189
198
"""MyAddress Screen uses screen to show widgets of screens."""
199
+
190
200
def __init__ (self , * args , ** kwargs ):
201
+ """Clock Schdule for method inbox accounts."""
191
202
super (MyAddress , self ).__init__ (* args , ** kwargs )
192
203
Clock .schedule_once (self .init_ui , 0 )
193
204
@@ -198,8 +209,15 @@ def init_ui(self, dt=0):
198
209
for address in state .kivyapp .variable_1 :
199
210
data .append ({'text' : BMConfigParser ().get (address , 'label' ), 'secondary_text' : address })
200
211
for item in data :
201
- meny = TwoLineAvatarIconListItem (text = item ['text' ], secondary_text = item ['secondary_text' ], theme_text_color = 'Custom' ,text_color = NavigateApp ().theme_cls .primary_color )
202
- meny .add_widget (AvatarSampleWidget (source = './images/text_images/{}.png' .format (item ['text' ][0 ].upper () if (item ['text' ][0 ].upper () >= 'A' and item ['text' ][0 ].upper () <= 'Z' ) else '!' )))
212
+ meny = TwoLineAvatarIconListItem (
213
+ text = item ['text' ],
214
+ secondary_text = item ['secondary_text' ],
215
+ theme_text_color = 'Custom' ,
216
+ text_color = NavigateApp ().theme_cls .primary_color )
217
+ meny .add_widget (AvatarSampleWidget (
218
+ source = './images/text_images/{}.png' .format (
219
+ item ['text' ][0 ].upper () if (item ['text' ][0 ].upper () >= 'A' and item [
220
+ 'text' ][0 ].upper () <= 'Z' ) else '!' )))
203
221
meny .bind (on_press = partial (self .myadd_detail , item ['secondary_text' ], item ['text' ]))
204
222
self .ids .ml .add_widget (meny )
205
223
else :
@@ -217,16 +235,15 @@ def init_ui(self, dt=0):
217
235
pass
218
236
219
237
def myadd_detail (self , fromaddress , label , * args ):
238
+ """Myaddress Details."""
220
239
p = MyaddDetailPopup ()
221
240
p .open ()
222
241
p .set_address (fromaddress , label )
223
242
224
243
def refresh_callback (self , * args ):
225
- """A method that updates the state of your application
226
- while the spinner remains on the screen."""
227
-
244
+ """A method that updates the state of your application while the spinner remains on the screen."""
228
245
def refresh_callback (interval ):
229
- """This methods is used for loading the myaddress screen data"""
246
+ """Method used for loading the myaddress screen data. """
230
247
self .ids .ml .clear_widgets ()
231
248
self .remove_widget (self .children [1 ])
232
249
try :
@@ -242,7 +259,9 @@ def refresh_callback(interval):
242
259
243
260
class AddressBook (Screen ):
244
261
"""AddressBook Screen uses screen to show widgets of screens."""
262
+
245
263
def __init__ (self , * args , ** kwargs ):
264
+ """Getting AddressBook Details."""
246
265
super (AddressBook , self ).__init__ (* args , ** kwargs )
247
266
Clock .schedule_once (self .init_ui , 0 )
248
267
@@ -251,9 +270,15 @@ def init_ui(self, dt=0):
251
270
data = sqlQuery ("SELECT label, address from addressbook" )
252
271
if data :
253
272
for item in data :
254
- meny = TwoLineAvatarIconListItem (text = item [0 ], secondary_text = item [1 ], theme_text_color = 'Custom' ,text_color = NavigateApp ().theme_cls .primary_color )
255
- meny .add_widget (AvatarSampleWidget (source = './images/text_images/{}.png' .format (item [0 ][0 ].upper () if (item [0 ][0 ].upper () >= 'A' and item [0 ][0 ].upper () <= 'Z' ) else '!' )))
256
- meny .bind (on_press = partial (self .addBook_detail , item [1 ], item [0 ]))
273
+ meny = TwoLineAvatarIconListItem (
274
+ text = item [0 ],
275
+ secondary_text = item [1 ],
276
+ theme_text_color = 'Custom' ,
277
+ text_color = NavigateApp ().theme_cls .primary_color )
278
+ meny .add_widget (AvatarSampleWidget (
279
+ source = './images/text_images/{}.png' .format (
280
+ item [0 ][0 ].upper () if (item [0 ][0 ].upper () >= 'A' and item [0 ][0 ].upper () <= 'Z' ) else '!' )))
281
+ meny .bind (on_press = partial (self .addBook_detail , item [1 ], item [0 ]))
257
282
carousel = Carousel (direction = 'right' )
258
283
if platform == 'android' :
259
284
carousel .height = 140
@@ -269,7 +294,7 @@ def init_ui(self, dt=0):
269
294
del_btn .bind (on_press = partial (self .delete_address , item [1 ]))
270
295
carousel .add_widget (del_btn )
271
296
carousel .add_widget (meny )
272
- carousel .index = 1
297
+ carousel .index = 1
273
298
self .ids .ml .add_widget (carousel )
274
299
else :
275
300
content = MDLabel (font_style = 'Body1' ,
@@ -282,59 +307,69 @@ def init_ui(self, dt=0):
282
307
self .ids .ml .add_widget (content )
283
308
284
309
def refreshs (self , * args ):
310
+ """Refresh the Widget."""
285
311
state .navinstance .ids .sc11 .clear_widgets ()
286
312
state .navinstance .ids .sc11 .add_widget (AddressBook ())
287
313
288
314
def addBook_detail (self , address , label , * args ):
315
+ """Addressbook Details."""
289
316
p = AddbookDetailPopup ()
290
317
p .open ()
291
318
p .set_addbook_data (address , label )
292
319
293
320
def delete_address (self , address , instance , * args ):
294
- """Delete inbox mail from inbox listing"""
321
+ """Delete inbox mail from inbox listing. """
295
322
self .ids .ml .remove_widget (instance .parent .parent )
296
323
sqlExecute ("DELETE FROM addressbook WHERE address = '{}';" .format (address ))
297
324
298
325
299
326
class SelectableRecycleBoxLayout (FocusBehavior , LayoutSelectionBehavior ,
300
327
RecycleBoxLayout ):
301
- ''' Adds selection and focus behaviour to the view. '''
328
+ """Adds selection and focus behaviour to the view."""
329
+
302
330
pass
303
331
304
332
305
333
class SelectableLabel (RecycleDataViewBehavior , Label ):
306
- ''' Add selection support to the Label '''
334
+ """Add selection support to the Label."""
335
+
307
336
index = None
308
337
selected = BooleanProperty (False )
309
338
selectable = BooleanProperty (True )
310
339
311
340
def refresh_view_attrs (self , rv , index , data ):
312
- ''' Catch and handle the view changes '''
341
+ """ Catch and handle the view changes."""
313
342
self .index = index
314
343
return super (SelectableLabel , self ).refresh_view_attrs (
315
344
rv , index , data )
316
345
317
346
def on_touch_down (self , touch ):
318
- ''' Add selection on touch down '''
347
+ """ Add selection on touch down."""
319
348
if super (SelectableLabel , self ).on_touch_down (touch ):
320
349
return True
321
350
if self .collide_point (* touch .pos ) and self .selectable :
322
351
return self .parent .select_with_touch (self .index , touch )
323
352
324
353
def apply_selection (self , rv , index , is_selected ):
325
- ''' Respond to the selection of items in the view. '''
354
+ """ Respond to the selection of items in the view."""
326
355
self .selected = is_selected
327
356
if is_selected :
328
357
print ("selection changed to {0}" .format (rv .data [index ]))
329
- rv .parent .txt_input .text = rv .parent .txt_input .text .replace (rv .parent .txt_input .text , rv .data [index ]['text' ])
358
+ rv .parent .txt_input .text = rv .parent .txt_input .text .replace (
359
+ rv .parent .txt_input .text , rv .data [index ]['text' ])
330
360
331
361
332
362
class RV (RecycleView ):
363
+ """Recycling View."""
364
+
333
365
def __init__ (self , ** kwargs ):
366
+ """Recycling Method."""
334
367
super (RV , self ).__init__ (** kwargs )
335
368
336
369
337
370
class DropDownWidget (BoxLayout ):
371
+ """Adding Dropdown Widget."""
372
+
338
373
txt_input = ObjectProperty ()
339
374
rv = ObjectProperty ()
340
375
@@ -353,7 +388,7 @@ def send(self):
353
388
status , addressVersionNumber , streamNumber , ripe = decodeAddress (
354
389
toAddress )
355
390
if status == 'success' :
356
- from addresses import *
391
+ from addresses import addBMIfNotPresent
357
392
toAddress = addBMIfNotPresent (toAddress )
358
393
statusIconColor = 'red'
359
394
if addressVersionNumber > 4 or addressVersionNumber <= 1 :
@@ -385,9 +420,8 @@ def send(self):
385
420
encoding ,
386
421
BMConfigParser ().getint ('bitmessagesettings' , 'ttl' ))
387
422
state .check_sent_acc = fromAddress
388
- state .msg_counter_objs = self .parent .parent .parent .parent .parent .parent .children [0 ].children [2 ].children [0 ].ids
389
- # state.msg_counter_objs.send_cnt.badge_text = str(int(state.sent_count) + 1)
390
- # state.sent_count = str(int(state.sent_count) + 1)
423
+ state .msg_counter_objs = \
424
+ self .parent .parent .parent .parent .parent .parent .children [0 ].children [2 ].children [0 ].ids
391
425
self .parent .parent .screens [3 ].clear_widgets ()
392
426
self .parent .parent .screens [3 ].add_widget (Sent ())
393
427
toLabel = ''
@@ -423,7 +457,6 @@ def address_error_message(self, msg):
423
457
self .main_pop = Popup (title = "Error" , content = self .box ,
424
458
size_hint = (None , None ), size = (550 , 400 ), auto_dismiss = False , title_size = 30 )
425
459
self .but .bind (on_press = self .main_pop .dismiss )
426
- # self.main_pop.background = './images/popup.jpeg'
427
460
self .main_pop .open ()
428
461
429
462
0 commit comments