2
2
# pylint: disable=no-member, no-name-in-module, unused-argument, too-few-public-methods
3
3
4
4
"""
5
- All the popup are managed here.
6
-
5
+ All the popups are managed here.
7
6
"""
7
+
8
8
import logging
9
9
from datetime import datetime
10
10
17
17
18
18
from pybitmessage .bitmessagekivy import kivy_helper_search
19
19
from pybitmessage .bitmessagekivy .get_platform import platform
20
-
21
20
from pybitmessage .bitmessagekivy .baseclass .common import toast
22
-
23
21
from pybitmessage .addresses import decodeAddress
24
22
25
23
logger = logging .getLogger ('default' )
26
24
27
25
28
26
class AddressChangingLoader (Popup ):
29
- """Run a Screen Loader when changing the Identity for kivy UI"""
27
+ """Run a Screen Loader when changing the Identity for Kivy UI"""
30
28
31
29
def __init__ (self , ** kwargs ):
32
- super (AddressChangingLoader , self ).__init__ (** kwargs )
30
+ super ().__init__ (** kwargs ) # pylint: disable=missing-super-argument
33
31
Clock .schedule_once (self .dismiss_popup , 0.5 )
34
32
35
33
def dismiss_popup (self , dt ):
36
- """Dismiss popups """
34
+ """Dismiss popup """
37
35
self .dismiss ()
38
36
39
37
40
38
class AddAddressPopup (BoxLayout ):
41
- """Popup for adding new address to addressbook """
39
+ """Popup for adding new address to address book """
42
40
43
41
validation_dict = {
44
- "missingbm" : "The address should start with '' BM-' '" ,
42
+ "missingbm" : "The address should start with 'BM-'" ,
45
43
"checksumfailed" : "The address is not typed or copied correctly" ,
46
- "versiontoohigh" : "The version number of this address is higher than this"
47
- " software can support. Please upgrade Bitmessage." ,
44
+ "versiontoohigh" : (
45
+ "The version number of this address is higher than this "
46
+ "software can support. Please upgrade Bitmessage."
47
+ ),
48
48
"invalidcharacters" : "The address contains invalid characters." ,
49
49
"ripetooshort" : "Some data encoded in the address is too short." ,
50
50
"ripetoolong" : "Some data encoded in the address is too long." ,
@@ -53,19 +53,19 @@ class AddAddressPopup(BoxLayout):
53
53
valid = False
54
54
55
55
def __init__ (self , ** kwargs ):
56
- super (AddAddressPopup , self ).__init__ (** kwargs )
56
+ super ().__init__ (** kwargs ) # pylint: disable=missing-super-argument
57
57
58
58
def checkAddress_valid (self , instance ):
59
- """Checking address is valid or not"""
59
+ """Check if the address is valid or not"""
60
60
my_addresses = (
61
61
App .get_running_app ().root .ids .content_drawer .ids .identity_dropdown .values )
62
62
add_book = [addr [1 ] for addr in kivy_helper_search .search_sql (
63
63
folder = "addressbook" )]
64
64
entered_text = str (instance .text ).strip ()
65
65
if entered_text in add_book :
66
- text = 'Address is already in the addressbook .'
66
+ text = 'Address is already in the address book .'
67
67
elif entered_text in my_addresses :
68
- text = 'You can not save your own address.'
68
+ text = 'You cannot save your own address.'
69
69
elif entered_text :
70
70
text = self .addressChanged (entered_text )
71
71
@@ -82,7 +82,7 @@ def checkAddress_valid(self, instance):
82
82
self .ids .address .helper_text = 'This field is required'
83
83
84
84
def checkLabel_valid (self , instance ):
85
- """Checking address label is unique or not"""
85
+ """Check if the address label is unique or not"""
86
86
entered_label = instance .text .strip ()
87
87
addr_labels = [labels [0 ] for labels in kivy_helper_search .search_sql (
88
88
folder = "addressbook" )]
@@ -112,25 +112,25 @@ def addressChanged(self, addr):
112
112
113
113
114
114
class SavedAddressDetailPopup (BoxLayout ):
115
- """Pop-up for Saved Address details for kivy UI"""
115
+ """Popup for saved address details for Kivy UI"""
116
116
117
117
address_label = StringProperty ()
118
118
address = StringProperty ()
119
119
120
120
def __init__ (self , ** kwargs ):
121
121
"""Set screen of address detail page"""
122
- super (SavedAddressDetailPopup , self ).__init__ (** kwargs )
122
+ super ().__init__ (** kwargs ) # pylint: disable=missing-super-argument
123
123
124
124
def checkLabel_valid (self , instance ):
125
- """Checking address label is unique of not"""
125
+ """Check if the address label is unique or not"""
126
126
entered_label = str (instance .text .strip ())
127
127
address_list = kivy_helper_search .search_sql (folder = "addressbook" )
128
128
addr_labels = [labels [0 ] for labels in address_list ]
129
129
add_dict = dict (address_list )
130
130
if self .address and entered_label in addr_labels \
131
131
and self .address != add_dict [entered_label ]:
132
132
self .ids .add_label .error = True
133
- self .ids .add_label .helper_text = 'label name already exists.'
133
+ self .ids .add_label .helper_text = 'Label name already exists.'
134
134
elif entered_label :
135
135
self .ids .add_label .error = False
136
136
else :
@@ -139,17 +139,17 @@ def checkLabel_valid(self, instance):
139
139
140
140
141
141
class MyaddDetailPopup (BoxLayout ):
142
- """MyaddDetailPopup class for kivy Ui """
142
+ """Popup for my address details for Kivy UI """
143
143
144
144
address_label = StringProperty ()
145
145
address = StringProperty ()
146
146
147
147
def __init__ (self , ** kwargs ):
148
- """My Address Details screen setting """
149
- super (MyaddDetailPopup , self ).__init__ (** kwargs )
148
+ """Set screen of my address details """
149
+ super ().__init__ (** kwargs ) # pylint: disable=missing-super-argument
150
150
151
151
def send_message_from (self ):
152
- """Method used to fill from address of composer autofield"""
152
+ """Fill from address of composer autofield"""
153
153
App .get_running_app ().set_navbar_for_composer ()
154
154
window_obj = App .get_running_app ().root .ids
155
155
window_obj .id_create .children [1 ].ids .ti .text = self .address
@@ -161,16 +161,16 @@ def send_message_from(self):
161
161
self .parent .parent .parent .dismiss ()
162
162
163
163
def close_pop (self ):
164
- """Pop is Cancelled """
164
+ """Cancel the popup """
165
165
self .parent .parent .parent .dismiss ()
166
166
toast ('Cancelled' )
167
167
168
168
169
169
class AppClosingPopup (Popup ):
170
- """AppClosingPopup class for kivy Ui """
170
+ """Popup for closing the application for Kivy UI """
171
171
172
172
def __init__ (self , ** kwargs ):
173
- super (AppClosingPopup , self ).__init__ (** kwargs )
173
+ super ().__init__ (** kwargs ) # pylint: disable=missing-super-argument
174
174
175
175
def closingAction (self , text ):
176
176
"""Action on closing window"""
@@ -185,22 +185,30 @@ def closingAction(self, text):
185
185
186
186
187
187
class SenderDetailPopup (Popup ):
188
- """SenderDetailPopup class for kivy Ui """
188
+ """Popup for sender details for Kivy UI """
189
189
190
190
to_addr = StringProperty ()
191
191
from_addr = StringProperty ()
192
192
time_tag = StringProperty ()
193
193
194
194
def __init__ (self , ** kwargs ):
195
- """this metthod initialized the send message detial popup"""
196
- super (SenderDetailPopup , self ).__init__ (** kwargs )
195
+ """Initialize the send message detail popup"""
196
+ super ().__init__ (** kwargs ) # pylint: disable=missing-super-argument
197
197
198
198
def assignDetail (self , to_addr , from_addr , timeinseconds ):
199
- """Detailes assigned """
199
+ """Assign details to the popup """
200
200
self .to_addr = to_addr
201
201
self .from_addr = from_addr
202
+ self .time_tag = self .format_time (timeinseconds )
203
+ self .adjust_popup_height (to_addr )
204
+
205
+ def format_time (self , timeinseconds ):
206
+ """Format the timestamp into a readable string"""
202
207
time_obj = datetime .fromtimestamp (int (timeinseconds ))
203
- self .time_tag = time_obj .strftime ("%d %b %Y, %I:%M %p" )
208
+ return time_obj .strftime ("%d %b %Y, %I:%M %p" )
209
+
210
+ def adjust_popup_height (self , to_addr ):
211
+ """Adjust the height of the popup based on the address length"""
204
212
device_type = 2 if platform == 'android' else 1.5
205
213
pop_height = 1.2 * device_type * (self .ids .sd_label .height + self .ids .dismiss_btn .height )
206
214
if len (to_addr ) > 3 :
@@ -219,13 +227,14 @@ def assignDetail(self, to_addr, from_addr, timeinseconds):
219
227
220
228
221
229
class ToAddrBoxlayout (BoxLayout ):
222
- """ToAddrBoxlayout class for kivy Ui"""
230
+ """BoxLayout for displaying the to address"""
231
+
223
232
to_addr = StringProperty ()
224
233
225
234
def set_toAddress (self , to_addr ):
226
- """This method is use to set to address"""
235
+ """Set the to address"""
227
236
self .to_addr = to_addr
228
237
229
238
230
239
class ToAddressTitle (BoxLayout ):
231
- """ToAddressTitle class for BoxLayout behaviour """
240
+ """BoxLayout for displaying the to address title """
0 commit comments