kivy-code-quality-2 #2269
|
@ -6,14 +6,12 @@ allmail.py
|
|||
==============
|
||||
|
||||
All mails are managed in allmail screen
|
||||
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from kivy.clock import Clock
|
||||
from kivy.properties import (
|
||||
ListProperty,
|
||||
StringProperty
|
||||
)
|
||||
from kivy.properties import ListProperty, StringProperty
|
||||
from kivy.uix.screenmanager import Screen
|
||||
from kivy.app import App
|
||||
|
||||
|
@ -21,47 +19,52 @@ from pybitmessage.bitmessagekivy.baseclass.common import (
|
|||
show_limited_cnt, empty_screen_label, kivy_state_variables,
|
||||
)
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger('default')
|
||||
|
||||
|
||||
class Allmails(Screen):
|
||||
"""Allmails Screen for kivy Ui"""
|
||||
class AllMails(Screen):
|
||||
"""AllMails Screen for Kivy UI"""
|
||||
data = ListProperty()
|
||||
has_refreshed = True
|
||||
all_mails = ListProperty()
|
||||
account = StringProperty()
|
||||
label_str = 'yet no message for this account!!!!!!!!!!!!!'
|
||||
label_str = 'No messages for this account.'
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Method Parsing the address"""
|
||||
super(Allmails, self).__init__(*args, **kwargs)
|
||||
"""Initialize the AllMails screen."""
|
||||
super().__init__(*args, **kwargs) # pylint: disable=missing-super-argument
|
||||
self.kivy_state = kivy_state_variables()
|
||||
if self.kivy_state.selected_address == '':
|
||||
if App.get_running_app().identity_list:
|
||||
self.kivy_state.selected_address = App.get_running_app().identity_list[0]
|
||||
self._initialize_selected_address()
|
||||
Clock.schedule_once(self.init_ui, 0)
|
||||
|
||||
def init_ui(self, dt=0):
|
||||
"""Clock Schdule for method all mails"""
|
||||
self.loadMessagelist()
|
||||
logger.debug(dt)
|
||||
def _initialize_selected_address(self):
|
||||
"""Initialize the selected address from the identity list."""
|
||||
if not self.kivy_state.selected_address and App.get_running_app().identity_list:
|
||||
self.kivy_state.selected_address = App.get_running_app().identity_list[0]
|
||||
|
||||
def loadMessagelist(self):
|
||||
"""Load Inbox, Sent anf Draft list of messages"""
|
||||
def init_ui(self, dt=0):
|
||||
"""Initialize the UI by loading the message list."""
|
||||
self.load_message_list()
|
||||
logger.debug("UI initialized after %s seconds.", dt)
|
||||
|
||||
def load_message_list(self):
|
||||
"""Load the Inbox, Sent, and Draft message lists."""
|
||||
self.account = self.kivy_state.selected_address
|
||||
self.ids.tag_label.text = ''
|
||||
self.ids.tag_label.text = 'All Mails' if self.all_mails else ''
|
||||
self._update_mail_count()
|
||||
|
||||
def _update_mail_count(self):
|
||||
"""Update the mail count and handle empty states."""
|
||||
if self.all_mails:
|
||||
self.ids.tag_label.text = 'All Mails'
|
||||
self.kivy_state.all_count = str(
|
||||
int(self.kivy_state.sent_count) + int(self.kivy_state.inbox_count))
|
||||
self.set_AllmailCnt(self.kivy_state.all_count)
|
||||
total_count = int(self.kivy_state.sent_count) + int(self.kivy_state.inbox_count)
|
||||
self.kivy_state.all_count = str(total_count)
|
||||
self.set_all_mail_count(self.kivy_state.all_count)
|
||||
else:
|
||||
self.set_AllmailCnt('0')
|
||||
self.set_all_mail_count('0')
|
||||
self.ids.ml.add_widget(empty_screen_label(self.label_str))
|
||||
|
||||
@staticmethod
|
||||
def set_AllmailCnt(Count):
|
||||
"""This method is used to set allmails message count"""
|
||||
allmailCnt_obj = App.get_running_app().root.ids.content_drawer.ids.allmail_cnt
|
||||
allmailCnt_obj.ids.badge_txt.text = show_limited_cnt(int(Count))
|
||||
def set_all_mail_count(count):
|
||||
"""Set the message count for all mails."""
|
||||
allmail_count_widget = App.get_running_app().root.ids.content_drawer.ids.allmail_cnt
|
||||
allmail_count_widget.ids.badge_txt.text = show_limited_cnt(int(count))
|
||||
|
|
|
@ -174,7 +174,7 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes
|
|||
self.parent.screens[3].clear_widgets()
|
||||
self.parent.screens[3].add_widget(Factory.Trash())
|
||||
self.parent.screens[14].clear_widgets()
|
||||
self.parent.screens[14].add_widget(Factory.Allmails())
|
||||
self.parent.screens[14].add_widget(Factory.AllMails())
|
||||
Clock.schedule_once(self.callback_for_delete, 4)
|
||||
|
||||
def callback_for_delete(self, dt=0):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Allmails>:
|
||||
<AllMails>:
|
||||
name: 'allmails'
|
||||
BoxLayout:
|
||||
orientation: 'vertical'
|
||||
|
|
|
@ -250,7 +250,7 @@ MDNavigationLayout:
|
|||
id:id_sent
|
||||
Trash:
|
||||
id:id_trash
|
||||
Allmails:
|
||||
AllMails:
|
||||
id:id_allmail
|
||||
Draft:
|
||||
id:id_draft
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
"All Mails": {
|
||||
"kv_string": "allmails",
|
||||
"name_screen": "allmails",
|
||||
"Import": "from pybitmessage.bitmessagekivy.baseclass.allmail import Allmails"
|
||||
"Import": "from pybitmessage.bitmessagekivy.baseclass.allmail import AllMails"
|
||||
},
|
||||
"MailDetail": {
|
||||
"kv_string": "maildetail",
|
||||
|
|
Reference in New Issue
Block a user