Skip to content

Commit 4ad06d7

Browse files
author
surbhi
committed
code-quality: Update code quality kivy/baseclass/allmail and related references
1 parent 85c3720 commit 4ad06d7

File tree

5 files changed

+36
-33
lines changed

5 files changed

+36
-33
lines changed

src/bitmessagekivy/baseclass/allmail.py

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,62 +6,65 @@
66
==============
77
88
All mails are managed in allmail screen
9-
109
"""
1110

11+
import logging
12+
1213
from kivy.clock import Clock
13-
from kivy.properties import (
14-
ListProperty,
15-
StringProperty
16-
)
14+
from kivy.properties import ListProperty, StringProperty
1715
from kivy.uix.screenmanager import Screen
1816
from kivy.app import App
1917

2018
from pybitmessage.bitmessagekivy.baseclass.common import (
2119
show_limited_cnt, empty_screen_label, kivy_state_variables,
2220
)
2321

24-
import logging
2522
logger = logging.getLogger('default')
2623

2724

28-
class Allmails(Screen):
29-
"""Allmails Screen for kivy Ui"""
25+
class AllMails(Screen):
26+
"""AllMails Screen for Kivy UI"""
3027
data = ListProperty()
3128
has_refreshed = True
3229
all_mails = ListProperty()
3330
account = StringProperty()
34-
label_str = 'yet no message for this account!!!!!!!!!!!!!'
31+
label_str = 'No messages for this account.'
3532

3633
def __init__(self, *args, **kwargs):
37-
"""Method Parsing the address"""
38-
super(Allmails, self).__init__(*args, **kwargs)
34+
"""Initialize the AllMails screen."""
35+
super().__init__(*args, **kwargs)
3936
self.kivy_state = kivy_state_variables()
40-
if self.kivy_state.selected_address == '':
41-
if App.get_running_app().identity_list:
42-
self.kivy_state.selected_address = App.get_running_app().identity_list[0]
37+
self._initialize_selected_address()
4338
Clock.schedule_once(self.init_ui, 0)
4439

40+
def _initialize_selected_address(self):
41+
"""Initialize the selected address from the identity list."""
42+
if not self.kivy_state.selected_address and App.get_running_app().identity_list:
43+
self.kivy_state.selected_address = App.get_running_app().identity_list[0]
44+
4545
def init_ui(self, dt=0):
46-
"""Clock Schdule for method all mails"""
47-
self.loadMessagelist()
48-
logger.debug(dt)
46+
"""Initialize the UI by loading the message list."""
47+
self.load_message_list()
48+
logger.debug("UI initialized after %s seconds.", dt)
4949

50-
def loadMessagelist(self):
51-
"""Load Inbox, Sent anf Draft list of messages"""
50+
def load_message_list(self):
51+
"""Load the Inbox, Sent, and Draft message lists."""
5252
self.account = self.kivy_state.selected_address
53-
self.ids.tag_label.text = ''
53+
self.ids.tag_label.text = 'All Mails' if self.all_mails else ''
54+
self._update_mail_count()
55+
56+
def _update_mail_count(self):
57+
"""Update the mail count and handle empty states."""
5458
if self.all_mails:
55-
self.ids.tag_label.text = 'All Mails'
56-
self.kivy_state.all_count = str(
57-
int(self.kivy_state.sent_count) + int(self.kivy_state.inbox_count))
58-
self.set_AllmailCnt(self.kivy_state.all_count)
59+
total_count = int(self.kivy_state.sent_count) + int(self.kivy_state.inbox_count)
60+
self.kivy_state.all_count = str(total_count)
61+
self.set_all_mail_count(self.kivy_state.all_count)
5962
else:
60-
self.set_AllmailCnt('0')
63+
self.set_all_mail_count('0')
6164
self.ids.ml.add_widget(empty_screen_label(self.label_str))
6265

6366
@staticmethod
64-
def set_AllmailCnt(Count):
65-
"""This method is used to set allmails message count"""
66-
allmailCnt_obj = App.get_running_app().root.ids.content_drawer.ids.allmail_cnt
67-
allmailCnt_obj.ids.badge_txt.text = show_limited_cnt(int(Count))
67+
def set_all_mail_count(count):
68+
"""Set the message count for all mails."""
69+
allmail_count_widget = App.get_running_app().root.ids.content_drawer.ids.allmail_cnt
70+
allmail_count_widget.ids.badge_txt.text = show_limited_cnt(int(count))

src/bitmessagekivy/baseclass/maildetail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def delete_mail(self):
174174
self.parent.screens[3].clear_widgets()
175175
self.parent.screens[3].add_widget(Factory.Trash())
176176
self.parent.screens[14].clear_widgets()
177-
self.parent.screens[14].add_widget(Factory.Allmails())
177+
self.parent.screens[14].add_widget(Factory.AllMails())
178178
Clock.schedule_once(self.callback_for_delete, 4)
179179

180180
def callback_for_delete(self, dt=0):

src/bitmessagekivy/kv/allmails.kv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Allmails>:
1+
<AllMails>:
22
name: 'allmails'
33
BoxLayout:
44
orientation: 'vertical'

src/bitmessagekivy/main.kv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ MDNavigationLayout:
250250
id:id_sent
251251
Trash:
252252
id:id_trash
253-
Allmails:
253+
AllMails:
254254
id:id_allmail
255255
Draft:
256256
id:id_draft

src/bitmessagekivy/screens_data.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"All Mails": {
6060
"kv_string": "allmails",
6161
"name_screen": "allmails",
62-
"Import": "from pybitmessage.bitmessagekivy.baseclass.allmail import Allmails"
62+
"Import": "from pybitmessage.bitmessagekivy.baseclass.allmail import AllMails"
6363
},
6464
"MailDetail": {
6565
"kv_string": "maildetail",

0 commit comments

Comments
 (0)