Merge pull request #46 from navjotcis/codequalitykivy

Codequalitykivy
This commit is contained in:
navjotcis 2019-10-11 16:23:49 +05:30 committed by GitHub
commit 33cc400219
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 59 deletions

View File

@ -1,42 +1,18 @@
#:import Toolbar kivymd.toolbar.Toolbar #:import Toolbar kivymd.toolbar.Toolbar
#:import ThemeManager kivymd.theming.ThemeManager
#:import MDNavigationDrawer kivymd.navigationdrawer.MDNavigationDrawer
#:import NavigationLayout kivymd.navigationdrawer.NavigationLayout #:import NavigationLayout kivymd.navigationdrawer.NavigationLayout
#:import NavigationDrawerDivider kivymd.navigationdrawer.NavigationDrawerDivider #:import NavigationDrawerDivider kivymd.navigationdrawer.NavigationDrawerDivider
#:import NavigationDrawerToolbar kivymd.navigationdrawer.NavigationDrawerToolbar
#:import NavigationDrawerSubheader kivymd.navigationdrawer.NavigationDrawerSubheader #:import NavigationDrawerSubheader kivymd.navigationdrawer.NavigationDrawerSubheader
#:import MDCheckbox kivymd.selectioncontrols.MDCheckbox #:import MDCheckbox kivymd.selectioncontrols.MDCheckbox
#:import MDSwitch kivymd.selectioncontrols.MDSwitch
#:import MDList kivymd.list.MDList #:import MDList kivymd.list.MDList
#:import OneLineListItem kivymd.list.OneLineListItem #:import OneLineListItem kivymd.list.OneLineListItem
#:import TwoLineListItem kivymd.list.TwoLineListItem
#:import ThreeLineListItem kivymd.list.ThreeLineListItem
#:import OneLineAvatarListItem kivymd.list.OneLineAvatarListItem
#:import OneLineIconListItem kivymd.list.OneLineIconListItem
#:import OneLineAvatarIconListItem kivymd.list.OneLineAvatarIconListItem
#:import MDTextField kivymd.textfields.MDTextField #:import MDTextField kivymd.textfields.MDTextField
#:import MDSpinner kivymd.spinner.MDSpinner
#:import MDCard kivymd.card.MDCard
#:import MDSeparator kivymd.card.MDSeparator
#:import MDDropdownMenu kivymd.menu.MDDropdownMenu
#:import get_color_from_hex kivy.utils.get_color_from_hex #:import get_color_from_hex kivy.utils.get_color_from_hex
#:import colors kivymd.color_definitions.colors #:import colors kivymd.color_definitions.colors
#:import SmartTile kivymd.grid.SmartTile
#:import MDSlider kivymd.slider.MDSlider
#:import MDTabbedPanel kivymd.tabs.MDTabbedPanel #:import MDTabbedPanel kivymd.tabs.MDTabbedPanel
#:import MDTab kivymd.tabs.MDTab #:import MDTab kivymd.tabs.MDTab
#:import MDProgressBar kivymd.progressbar.MDProgressBar
#:import MDAccordion kivymd.accordion.MDAccordion
#:import MDAccordionItem kivymd.accordion.MDAccordionItem
#:import MDAccordionSubItem kivymd.accordion.MDAccordionSubItem
#:import MDThemePicker kivymd.theme_picker.MDThemePicker
#:import MDBottomNavigation kivymd.tabs.MDBottomNavigation
#:import MDBottomNavigationItem kivymd.tabs.MDBottomNavigationItem
#:import MDFloatingActionButton kivymd.button.MDFloatingActionButton #:import MDFloatingActionButton kivymd.button.MDFloatingActionButton
#:import Factory kivy.factory.Factory #:import Factory kivy.factory.Factory
#:import MDTextButton kivymd.button.MDTextButton
#:import FadeTransition kivy.uix.screenmanager.FadeTransition
#:import MDScrollViewRefreshLayout kivymd.refreshlayout.MDScrollViewRefreshLayout #:import MDScrollViewRefreshLayout kivymd.refreshlayout.MDScrollViewRefreshLayout
#:set color_button (0.784, 0.443, 0.216, 1) # brown #:set color_button (0.784, 0.443, 0.216, 1) # brown
@ -55,8 +31,7 @@
<ContentNavigationDrawer@Navigatorss>: <ContentNavigationDrawer@Navigatorss>:
drawer_logo: app.address_identicon() drawer_logo: app.address_identicon()
NavigationDrawerDivider: NavigationDrawerDivider:
NavigationDrawerSubheader:
NavigationDrawerTwoLineListItem:
text: "Accounts" text: "Accounts"
NavigationDrawerIconButton: NavigationDrawerIconButton:
CustomSpinner: CustomSpinner:
@ -143,7 +118,7 @@
on_press: app.refreshScreen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
text: "Subscriptions/Payment" text: "Subscriptions/Payment"
icon:'wallet' icon:'bell'
on_release: app.root.ids.scr_mngr.current = 'payment' on_release: app.root.ids.scr_mngr.current = 'payment'
on_press: app.refreshScreen(self) on_press: app.refreshScreen(self)
NavigationDrawerIconButton: NavigationDrawerIconButton:
@ -417,17 +392,6 @@ NavigationLayout:
helper_text_mode: "on_error" helper_text_mode: "on_error"
BoxLayout: BoxLayout:
spacing:50 spacing:50
AnchorLayout:
MDRaisedButton:
size_hint: 1, None
height: dp(40)
on_press: root.reset_composer()
MDLabel:
font_style: 'Title'
text: 'reset'
font_size: '13sp'
color: (1,1,1,1)
halign: 'center'
<MyTextInput>: <MyTextInput>:
readonly: False readonly: False

View File

@ -61,9 +61,8 @@ import identiconGeneration
def toast(text): def toast(text):
"""Method will display the toast message.""" """Method will display the toast message."""
if platform == 'linux': from kivymd.toast.kivytoast import toast # pylint: disable=redefined-outer-name
from kivymd.toast.kivytoast import toast # pylint: disable=redefined-outer-name toast(text)
toast(text)
return return
@ -379,8 +378,9 @@ class AddressBook(Screen):
@staticmethod @staticmethod
def refreshs(*args): def refreshs(*args):
"""Refresh the Widget.""" """Refresh the Widget."""
state.navinstance.ids.sc11.ids.ml.clear_widgets() # state.navinstance.ids.sc11.ids.ml.clear_widgets()
state.navinstance.ids.sc11.loadAddresslist(None, 'All', '') # state.navinstance.ids.sc11.loadAddresslist(None, 'All', '')
pass
@staticmethod @staticmethod
def addBook_detail(address, label, *args): def addBook_detail(address, label, *args):
@ -558,6 +558,7 @@ class DropDownWidget(BoxLayout):
self.ids.txt_input.text = '' self.ids.txt_input.text = ''
self.ids.subject.text = '' self.ids.subject.text = ''
self.ids.body.text = '' self.ids.body.text = ''
toast("Reset message")
def auto_fill_fromaddr(self): def auto_fill_fromaddr(self):
"""Mehtod used to fill the text automatically From Address.""" """Mehtod used to fill the text automatically From Address."""
@ -694,6 +695,7 @@ class Random(Screen):
self.parent.parent.parent.parent.ids.toolbar.opacity = 1 self.parent.parent.parent.parent.ids.toolbar.opacity = 1
self.parent.parent.parent.parent.ids.toolbar.disabled = False self.parent.parent.parent.parent.ids.toolbar.disabled = False
self.parent.parent.parent.parent.ids.sc10.ids.ml.clear_widgets() self.parent.parent.parent.parent.ids.sc10.ids.ml.clear_widgets()
self.manager.current = 'myaddress'
self.parent.parent.parent.parent.ids.sc10.init_ui() self.parent.parent.parent.parent.ids.sc10.init_ui()
self.manager.current = 'myaddress' self.manager.current = 'myaddress'
toast('New address created') toast('New address created')
@ -1094,7 +1096,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
"""Getting default image on address""" """Getting default image on address"""
if BMConfigParser().addresses(): if BMConfigParser().addresses():
return './images/default_identicon/{}.png'.format(BMConfigParser().addresses()[0]) return './images/default_identicon/{}.png'.format(BMConfigParser().addresses()[0])
return '' return './images/no_identicons.png'
@staticmethod @staticmethod
def addressexist(): def addressexist():
@ -1158,6 +1160,7 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
self.root.ids.toolbar.left_action_items = [ self.root.ids.toolbar.left_action_items = [
['arrow-left', lambda x: self.back_press()]] ['arrow-left', lambda x: self.back_press()]]
self.root.ids.toolbar.right_action_items = [ self.root.ids.toolbar.right_action_items = [
['refresh', lambda x: self.root.ids.sc3.children[0].reset_composer()],
['send', lambda x: self.root.ids.sc3.children[0].send(self)]] ['send', lambda x: self.root.ids.sc3.children[0].send(self)]]
def back_press(self): def back_press(self):
@ -1167,7 +1170,9 @@ class NavigateApp(App): # pylint: disable=too-many-public-methods
self.root.ids.toolbar.left_action_items = \ self.root.ids.toolbar.left_action_items = \
[['menu', lambda x: self.root.toggle_nav_drawer()]] [['menu', lambda x: self.root.toggle_nav_drawer()]]
self.root.ids.scr_mngr.current = 'inbox' \ self.root.ids.scr_mngr.current = 'inbox' \
if state.in_composer else 'allmails' if state.is_allmail else state.detailPageType if state.in_composer else 'allmails'\
if state.is_allmail else state.detailPageType\
if state.detailPageType else 'inbox'
self.root.ids.scr_mngr.transition.direction = 'right' self.root.ids.scr_mngr.transition.direction = 'right'
self.root.ids.scr_mngr.transition.bind(on_complete=self.reset) self.root.ids.scr_mngr.transition.bind(on_complete=self.reset)
if state.is_allmail or state.detailPageType == 'draft': if state.is_allmail or state.detailPageType == 'draft':
@ -1299,10 +1304,12 @@ class GrashofPopup(Popup):
stored_address = [addr[1] for addr in kivy_helper_search.search_sql( stored_address = [addr[1] for addr in kivy_helper_search.search_sql(
folder="addressbook")] folder="addressbook")]
if label and address and address not in stored_address: if label and address and address not in stored_address:
state.navinstance = self.parent.children[1] # state.navinstance = self.parent.children[1]
queues.UISignalQueue.put(('rerenderAddressBook', '')) queues.UISignalQueue.put(('rerenderAddressBook', ''))
self.dismiss() self.dismiss()
sqlExecute("INSERT INTO addressbook VALUES(?,?)", label, address) sqlExecute("INSERT INTO addressbook VALUES(?,?)", label, address)
state.kivyapp.root.ids.sc11.ids.ml.clear_widgets()
state.kivyapp.root.ids.sc11.loadAddresslist(None, 'All', '')
self.parent.children[1].ids.scr_mngr.current = 'addressbook' self.parent.children[1].ids.scr_mngr.current = 'addressbook'
toast('Saved') toast('Saved')
@ -1463,6 +1470,8 @@ class MailDetail(Screen):
sqlExecute( sqlExecute(
"UPDATE inbox SET folder = 'trash' WHERE \ "UPDATE inbox SET folder = 'trash' WHERE \
msgid = ?;", str(state.mail_id)) msgid = ?;", str(state.mail_id))
msg_count_objs.inbox_cnt.badge_text = str(int(state.inbox_count) - 1)
state.inbox_count = str(int(state.inbox_count) - 1)
self.parent.screens[0].ids.ml.clear_widgets() self.parent.screens[0].ids.ml.clear_widgets()
self.parent.screens[0].loadMessagelist(state.association) self.parent.screens[0].loadMessagelist(state.association)
elif state.detailPageType == 'draft': elif state.detailPageType == 'draft':
@ -1591,7 +1600,7 @@ class AddbookDetailPopup(Popup):
window_obj = self.parent.children[1].ids window_obj = self.parent.children[1].ids
window_obj.sc3.children[0].ids.txt_input.text = self.address window_obj.sc3.children[0].ids.txt_input.text = self.address
window_obj.sc3.children[0].ids.ti.text = '' window_obj.sc3.children[0].ids.ti.text = ''
window_obj.sc3.children[0].ids.btn.text = '' window_obj.sc3.children[0].ids.btn.text = 'Select'
window_obj.sc3.children[0].ids.subject.text = '' window_obj.sc3.children[0].ids.subject.text = ''
window_obj.sc3.children[0].ids.body.text = '' window_obj.sc3.children[0].ids.body.text = ''
window_obj.scr_mngr.current = 'create' window_obj.scr_mngr.current = 'create'
@ -1809,16 +1818,11 @@ class Allmails(Screen):
def loadMessagelist(self, account, where="", what=""): def loadMessagelist(self, account, where="", what=""):
"""Load Inbox, Sent anf Draft list of messages.""" """Load Inbox, Sent anf Draft list of messages."""
inbox = sqlQuery( all_mails = sqlQuery(
"SELECT toaddress, fromaddress, subject, message, folder, msgid from\ "SELECT toaddress, fromaddress, subject, message, folder, ackdata As id, DATE(lastactiontime)"
inbox WHERE folder = 'inbox' and toaddress = '{}';".format( " As actionTime FROM sent WHERE folder = 'sent' UNION"
account)) " SELECT toaddress, fromaddress, subject, message, folder, msgid As id, DATE(received) As"
sent_and_draft = sqlQuery( " actionTime FROM inbox WHERE folder = 'inbox' ORDER BY actionTime DESC")
"SELECT toaddress, fromaddress, subject, message, folder, ackdata from sent \
WHERE folder = 'sent' and fromaddress = '{}';".format(
account))
all_mails = inbox + sent_and_draft
if all_mails: if all_mails:
state.kivyapp.root.children[2].children[0].ids.allmail_cnt.badge_text = str(len(all_mails)) state.kivyapp.root.children[2].children[0].ids.allmail_cnt.badge_text = str(len(all_mails))
state.all_count = str(len(all_mails)) state.all_count = str(len(all_mails))

View File

@ -16,8 +16,9 @@ class UIkivySignaler(Thread):
if command == 'writeNewAddressToTable': if command == 'writeNewAddressToTable':
label, address, streamNumber = data label, address, streamNumber = data
state.kivyapp.variable_1.append(address) state.kivyapp.variable_1.append(address)
elif command == 'rerenderAddressBook': # elif command == 'rerenderAddressBook':
state.kivyapp.obj_1.refreshs() # state.kivyapp.obj_1.refreshs()
# Need to discuss this
elif command == 'updateSentItemStatusByAckdata': elif command == 'updateSentItemStatusByAckdata':
state.kivyapp.status_dispatching(data) state.kivyapp.status_dispatching(data)