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