Fixed typo and code quality

This commit is contained in:
shekhar-cis 2022-05-25 18:32:48 +05:30
parent 9ed856f3a7
commit 0becffb71f
Signed by untrusted user: shekhar-cis
GPG Key ID: F4F00AB04E83F9A7

View File

@ -28,9 +28,6 @@ from bitmessagekivy.get_platform import platform
ThemeClsColor = [0.12, 0.58, 0.95, 1] ThemeClsColor = [0.12, 0.58, 0.95, 1]
kivy_running_app = App.get_running_app()
kivy_state = kivy_running_app.kivy_state_obj
data_screens = { data_screens = {
"MailDetail": { "MailDetail": {
@ -74,12 +71,10 @@ def show_limited_cnt(total_msg):
def avatar_image_first_letter(letter_string): def avatar_image_first_letter(letter_string):
"""Returns first letter for the avatar image""" """Returns first letter for the avatar image"""
try: try:
if isinstance(letter_string, int): image_letter = letter_string.title()[0]
return letter_string[0] if image_letter.isalnum():
elif isinstance(letter_string, str) and letter_string[0].isalnum(): return image_letter
return letter_string.title()[0] return '!'
else:
return '!'
except IndexError: except IndexError:
return '!' return '!'
@ -128,7 +123,7 @@ class SwipeToDeleteItem(MDCardSwipe):
opening_time = NumericProperty(0.5) opening_time = NumericProperty(0.5)
class CutsomSwipeToDeleteItem(MDCardSwipe): class CustomSwipeToDeleteItem(MDCardSwipe):
"""Custom swipe delete class for App UI""" """Custom swipe delete class for App UI"""
text = StringProperty() text = StringProperty()
cla = Window.size[0] / 2 cla = Window.size[0] / 2
@ -138,6 +133,8 @@ class CutsomSwipeToDeleteItem(MDCardSwipe):
def empty_screen_label(label_str=None, no_search_res_found=None): def empty_screen_label(label_str=None, no_search_res_found=None):
"""Returns default text on screen when no address is there.""" """Returns default text on screen when no address is there."""
kivy_running_app = App.get_running_app()
kivy_state = kivy_running_app.kivy_state_obj
content = MDLabel( content = MDLabel(
font_style='Caption', font_style='Caption',
theme_text_color='Primary', theme_text_color='Primary',
@ -153,13 +150,13 @@ def mdlist_message_content(queryreturn, data):
secondary_txt_len = 10 secondary_txt_len = 10
third_txt_len = 25 third_txt_len = 25
dot_str = '...........' dot_str = '...........'
dot_str2 = '...!'
for mail in queryreturn: for mail in queryreturn:
third_text = mail[3].replace('\n', ' ') third_text = mail[3].replace('\n', ' ')
data.append({ data.append({
'text': mail[1].strip(), 'text': mail[1].strip(),
'secondary_text': mail[2][:secondary_txt_len] + dot_str if len( 'secondary_text': mail[2][:secondary_txt_len] + dot_str if len(
mail[2]) > secondary_txt_len else mail[2] + '\n' + " " + ( mail[2]) > secondary_txt_len else mail[2] + '\n' + " " + (
third_text[:third_txt_len] + '...!') if len( third_text[:third_txt_len] + dot_str2) if len(
third_text) > third_txt_len else third_text, third_text) > third_txt_len else third_text,
'ackdata': mail[5], 'senttime': mail[6]}) 'ackdata': mail[5], 'senttime': mail[6]})