fixed app crashing issues

This commit is contained in:
navjot 2021-03-25 01:47:26 +05:30
parent ebb350b81b
commit 6aee6f12d5
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
13 changed files with 104 additions and 83 deletions

View File

@ -17,9 +17,10 @@ from kivymd.uix.list import TwoLineAvatarIconListItem
import state import state
from bitmessagekivy.baseclass.common import ( from bitmessagekivy.baseclass.common import (
showLimitedCnt, toast, initailize_detail_page, ThemeClsColor, showLimitedCnt, toast, ThemeClsColor,
chipTag, avatarImageFirstLetter, AddTimeWidget, AvatarSampleWidget chipTag, avatarImageFirstLetter, AddTimeWidget, AvatarSampleWidget
) )
from bitmessagekivy.baseclass.maildetail import MailDetail
from bitmessagekivy.baseclass.trash import Trash from bitmessagekivy.baseclass.trash import Trash
@ -148,10 +149,9 @@ class Allmails(Screen):
src_mng_obj = self.manager src_mng_obj = self.manager
else: else:
src_mng_obj = self.parent.parent src_mng_obj = self.parent.parent
# src_mng_obj.screens[13].clear_widgets() src_mng_obj.screens[11].clear_widgets()
# src_mng_obj.screens[13].add_widget(MailDetail()) src_mng_obj.screens[11].add_widget(MailDetail())
# src_mng_obj.current = 'mailDetail' src_mng_obj.current = 'mailDetail'
initailize_detail_page(src_mng_obj)
def swipe_delete(self, unique_id, folder, instance, *args): def swipe_delete(self, unique_id, folder, instance, *args):
"""Delete inbox mail from all mail listing""" """Delete inbox mail from all mail listing"""

View File

@ -1,3 +1,5 @@
import time
from bitmessagekivy import kivy_helper_search from bitmessagekivy import kivy_helper_search
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from helper_sql import sqlExecute from helper_sql import sqlExecute
@ -18,9 +20,10 @@ from kivymd.uix.list import TwoLineAvatarIconListItem
import state import state
from bitmessagekivy.baseclass.common import ( from bitmessagekivy.baseclass.common import (
showLimitedCnt, initailize_detail_page, toast, ThemeClsColor, showLimitedCnt, toast, ThemeClsColor,
AddTimeWidget, AvatarSampleWidget AddTimeWidget, AvatarSampleWidget
) )
from bitmessagekivy.baseclass.maildetail import MailDetail
class Draft(Screen): class Draft(Screen):
@ -46,11 +49,12 @@ class Draft(Screen):
def sentaccounts(self): def sentaccounts(self):
"""Load draft accounts""" """Load draft accounts"""
self.account = state.association # self.account = state.association
self.loadDraft() self.loadDraft()
def loadDraft(self, where="", what=""): def loadDraft(self, where="", what=""):
"""Load draft list for Draft messages""" """Load draft list for Draft messages"""
self.account = state.association
xAddress = 'fromaddress' xAddress = 'fromaddress'
self.ids.tag_label.text = '' self.ids.tag_label.text = ''
self.draftDataQuery(xAddress, where, what) self.draftDataQuery(xAddress, where, what)
@ -144,10 +148,9 @@ class Draft(Screen):
src_mng_obj = self.manager src_mng_obj = self.manager
else: else:
src_mng_obj = self.parent.parent src_mng_obj = self.parent.parent
# src_mng_obj.screens[13].clear_widgets() src_mng_obj.screens[11].clear_widgets()
# src_mng_obj.screens[13].add_widget(MailDetail()) src_mng_obj.screens[11].add_widget(MailDetail())
# src_mng_obj.current = 'mailDetail' src_mng_obj.current = 'mailDetail'
initailize_detail_page(src_mng_obj)
def delete_draft(self, data_index, instance, *args): def delete_draft(self, data_index, instance, *args):
"""Delete draft message permanently""" """Delete draft message permanently"""

View File

@ -19,9 +19,11 @@ from kivymd.uix.list import TwoLineAvatarIconListItem
import state import state
from bitmessagekivy.baseclass.common import ( from bitmessagekivy.baseclass.common import (
showLimitedCnt, initailize_detail_page, avatarImageFirstLetter, showLimitedCnt, avatarImageFirstLetter,
AddTimeWidget, ThemeClsColor, AvatarSampleWidget, toast AddTimeWidget, ThemeClsColor, AvatarSampleWidget, toast
) )
from bitmessagekivy.baseclass.maildetail import MailDetail
from bitmessagekivy.baseclass.trash import Trash
class Inbox(Screen): class Inbox(Screen):
@ -195,10 +197,9 @@ class Inbox(Screen):
src_mng_obj = self.manager src_mng_obj = self.manager
else: else:
src_mng_obj = self.parent.parent src_mng_obj = self.parent.parent
# src_mng_obj.screens[13].clear_widgets() src_mng_obj.screens[11].clear_widgets()
# src_mng_obj.screens[13].add_widget(MailDetail()) src_mng_obj.screens[11].add_widget(MailDetail())
# src_mng_obj.current = "mailDetail" src_mng_obj.current = "mailDetail"
initailize_detail_page(src_mng_obj)
def delete(self, data_index, instance, *args): def delete(self, data_index, instance, *args):
"""Delete inbox mail from inbox listing""" """Delete inbox mail from inbox listing"""
@ -235,12 +236,14 @@ class Inbox(Screen):
def update_trash(self): def update_trash(self):
"""Update trash screen mails which is deleted from inbox""" """Update trash screen mails which is deleted from inbox"""
try: self.manager.parent.ids.sc5.clear_widgets()
self.parent.screens[4].clear_widgets() self.manager.parent.ids.sc5.add_widget(Trash())
self.parent.screens[4].add_widget(Trash()) # try:
except Exception: # self.parent.screens[4].clear_widgets()
self.parent.parent.screens[4].clear_widgets() # self.parent.screens[4].add_widget(Trash())
self.parent.parent.screens[4].add_widget(Trash()) # except Exception:
# self.parent.parent.screens[4].clear_widgets()
# self.parent.parent.screens[4].add_widget(Trash())
def refresh_callback(self, *args): def refresh_callback(self, *args):
"""Method updates the state of application, """Method updates the state of application,

View File

@ -1,3 +1,5 @@
from datetime import datetime
from bitmessagekivy.get_platform import platform from bitmessagekivy.get_platform import platform
from helper_sql import sqlExecute, sqlQuery from helper_sql import sqlExecute, sqlQuery
@ -7,6 +9,8 @@ from kivy.properties import (
StringProperty, StringProperty,
NumericProperty NumericProperty
) )
from kivy.factory import Factory
from kivymd.uix.button import MDFlatButton, MDIconButton from kivymd.uix.button import MDFlatButton, MDIconButton
from kivymd.uix.dialog import MDDialog from kivymd.uix.dialog import MDDialog
from kivymd.uix.list import ( from kivymd.uix.list import (
@ -22,7 +26,6 @@ from bitmessagekivy.baseclass.common import (
toast, avatarImageFirstLetter, ShowTimeHistoy toast, avatarImageFirstLetter, ShowTimeHistoy
) )
from bitmessagekivy.baseclass.popup import SenderDetailPopup from bitmessagekivy.baseclass.popup import SenderDetailPopup
from bitmessagekivy.baseclass.trash import Trash
class OneLineListTitle(OneLineListItem): class OneLineListTitle(OneLineListItem):
@ -95,6 +98,7 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes
def init_ui(self, dt=0): def init_ui(self, dt=0):
"""Clock Schdule for method MailDetail mails""" """Clock Schdule for method MailDetail mails"""
self.page_type = state.detailPageType if state.detailPageType else '' self.page_type = state.detailPageType if state.detailPageType else ''
try:
if state.detailPageType == 'sent' or state.detailPageType == 'draft': if state.detailPageType == 'sent' or state.detailPageType == 'draft':
data = sqlQuery( data = sqlQuery(
"select toaddress, fromaddress, subject, message, status," "select toaddress, fromaddress, subject, message, status,"
@ -109,6 +113,8 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes
" where msgid = ?;", state.mail_id) " where msgid = ?;", state.mail_id)
self.assign_mail_details(data) self.assign_mail_details(data)
state.kivyapp.set_mail_detail_header() state.kivyapp.set_mail_detail_header()
except Exception as e:
print('Something wents wrong!!')
def assign_mail_details(self, data): def assign_mail_details(self, data):
"""Assigning mail details""" """Assigning mail details"""
@ -139,8 +145,8 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes
" ackdata = ?;", state.mail_id) " ackdata = ?;", state.mail_id)
msg_count_objs.send_cnt.ids.badge_txt.text = str(int(state.sent_count) - 1) msg_count_objs.send_cnt.ids.badge_txt.text = str(int(state.sent_count) - 1)
state.sent_count = str(int(state.sent_count) - 1) state.sent_count = str(int(state.sent_count) - 1)
self.parent.screens[3].ids.ml.clear_widgets() self.parent.screens[2].ids.ml.clear_widgets()
self.parent.screens[3].loadSent(state.association) self.parent.screens[2].loadSent(state.association)
elif state.detailPageType == 'inbox': elif state.detailPageType == 'inbox':
state.kivyapp.root.ids.sc1.ids.inbox_search.ids.search_field.text = '' state.kivyapp.root.ids.sc1.ids.inbox_search.ids.search_field.text = ''
sqlExecute( sqlExecute(
@ -157,8 +163,8 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes
msg_count_objs.draft_cnt.ids.badge_txt.text = str( msg_count_objs.draft_cnt.ids.badge_txt.text = str(
int(state.draft_count) - 1) int(state.draft_count) - 1)
state.draft_count = str(int(state.draft_count) - 1) state.draft_count = str(int(state.draft_count) - 1)
self.parent.screens[15].clear_widgets() self.parent.screens[13].ids.ml.clear_widgets()
self.parent.screens[15].add_widget(Draft()) self.parent.screens[13].loadDraft(state.association)
if state.detailPageType != 'draft': if state.detailPageType != 'draft':
msg_count_objs.trash_cnt.ids.badge_txt.text = str( msg_count_objs.trash_cnt.ids.badge_txt.text = str(
@ -167,10 +173,10 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes
int(state.all_count) - 1) int(state.all_count) - 1)
state.trash_count = str(int(state.trash_count) + 1) state.trash_count = str(int(state.trash_count) + 1)
state.all_count = str(int(state.all_count) - 1) if int(state.all_count) else '0' state.all_count = str(int(state.all_count) - 1) if int(state.all_count) else '0'
self.parent.screens[4].clear_widgets() self.parent.screens[3].clear_widgets()
self.parent.screens[4].add_widget(Trash()) self.parent.screens[3].add_widget(Factory.Trash())
self.parent.screens[16].clear_widgets() self.parent.screens[14].clear_widgets()
self.parent.screens[16].add_widget(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):
@ -189,7 +195,7 @@ class MailDetail(Screen): # pylint: disable=too-many-instance-attributes
data = sqlQuery( data = sqlQuery(
"select toaddress, fromaddress, subject, message, received from inbox where" "select toaddress, fromaddress, subject, message, received from inbox where"
" msgid = ?;", state.mail_id) " msgid = ?;", state.mail_id)
composer_obj = self.parent.screens[2].children[1].ids composer_obj = self.parent.screens[1].children[1].ids
composer_obj.ti.text = data[0][0] composer_obj.ti.text = data[0][0]
composer_obj.btn.text = data[0][0] composer_obj.btn.text = data[0][0]
composer_obj.txt_input.text = data[0][1] composer_obj.txt_input.text = data[0][1]

View File

@ -5,6 +5,7 @@ from bmconfigparser import BMConfigParser
from helper_sql import sqlExecute, sqlQuery from helper_sql import sqlExecute, sqlQuery
from kivy.clock import Clock from kivy.clock import Clock
from kivy.core.window import Window from kivy.core.window import Window
from kivy.factory import Factory
from kivy.properties import ( from kivy.properties import (
BooleanProperty, BooleanProperty,
ListProperty, ListProperty,
@ -107,8 +108,8 @@ class DropDownWidget(BoxLayout):
int(time.time()), int(time.time()),
int(time.time()), int(time.time()),
state.send_draft_mail) state.send_draft_mail)
self.parent.parent.screens[15].clear_widgets() self.parent.parent.screens[13].clear_widgets()
self.parent.parent.screens[15].add_widget(Draft()) self.parent.parent.screens[13].add_widget(Factory.Draft())
# state.detailPageType = '' # state.detailPageType = ''
# state.send_draft_mail = None # state.send_draft_mail = None
else: else:

View File

@ -7,6 +7,7 @@ from kivy.properties import (
ListProperty, ListProperty,
StringProperty StringProperty
) )
from kivymd.uix.button import MDFlatButton
from kivymd.uix.dialog import MDDialog from kivymd.uix.dialog import MDDialog
from kivymd.uix.label import MDLabel from kivymd.uix.label import MDLabel
from kivymd.uix.list import ( from kivymd.uix.list import (
@ -19,7 +20,8 @@ from kivy.uix.screenmanager import Screen
import state import state
from bitmessagekivy.baseclass.common import ( from bitmessagekivy.baseclass.common import (
avatarImageFirstLetter, AvatarSampleWidget,ThemeClsColor avatarImageFirstLetter, AvatarSampleWidget,ThemeClsColor,
toast
) )
from bitmessagekivy.baseclass.popup import MyaddDetailPopup from bitmessagekivy.baseclass.popup import MyaddDetailPopup
@ -100,12 +102,9 @@ class MyAddress(Screen):
text_color=ThemeClsColor,) text_color=ThemeClsColor,)
meny._txt_right_pad = dp(70) meny._txt_right_pad = dp(70)
try: try:
meny.canvas.children[6].rgba = [0, 0, 0, 0] if is_enable == 'true' else [0.5, 0.5, 0.5, 0.5] meny.canvas.children[3].rgba = [0, 0, 0, 0] if is_enable == 'true' else [0.5, 0.5, 0.5, 0.5]
except Exception: except Exception:
try: pass
meny.canvas.children[9].rgba = [0, 0, 0, 0] if is_enable == 'true' else [0.5, 0.5, 0.5, 0.5]
except Exception as e:
print('Exception: ', e)
meny.add_widget(AvatarSampleWidget( meny.add_widget(AvatarSampleWidget(
source=state.imageDir + '/text_images/{}.png'.format( source=state.imageDir + '/text_images/{}.png'.format(
avatarImageFirstLetter(item['text'].strip())))) avatarImageFirstLetter(item['text'].strip()))))
@ -125,6 +124,7 @@ class MyAddress(Screen):
meny.add_widget(ToggleBtn(active=True if is_enable == 'true' else False)) meny.add_widget(ToggleBtn(active=True if is_enable == 'true' else False))
self.ids.ml.add_widget(meny) self.ids.ml.add_widget(meny)
def check_scroll_y(self, instance, somethingelse): def check_scroll_y(self, instance, somethingelse):
"""Load data on scroll down""" """Load data on scroll down"""
if self.ids.refresh_layout.scroll_y <= -0.0 and self.has_refreshed: if self.ids.refresh_layout.scroll_y <= -0.0 and self.has_refreshed:
@ -214,10 +214,11 @@ class MyAddress(Screen):
BMConfigParser().set(str(address), 'enabled', 'false') BMConfigParser().set(str(address), 'enabled', 'false')
BMConfigParser().save() BMConfigParser().save()
instance.parent.parent.theme_text_color = 'Primary' instance.parent.parent.theme_text_color = 'Primary'
try: instance.parent.parent.canvas.children[3].rgba = [0.5, 0.5, 0.5, 0.5]
instance.parent.parent.canvas.children[6].rgba = [0.5, 0.5, 0.5, 0.5] # try:
except Exception: # instance.parent.parent.canvas.children[6].rgba = [0.5, 0.5, 0.5, 0.5]
instance.parent.parent.canvas.children[9].rgba = [0.5, 0.5, 0.5, 0.5] # except Exception:
# instance.parent.parent.canvas.children[9].rgba = [0.5, 0.5, 0.5, 0.5]
toast('Address disabled') toast('Address disabled')
Clock.schedule_once(self.address_permision_callback, 0) Clock.schedule_once(self.address_permision_callback, 0)
@ -226,10 +227,11 @@ class MyAddress(Screen):
BMConfigParser().set(address, 'enabled', 'true') BMConfigParser().set(address, 'enabled', 'true')
BMConfigParser().save() BMConfigParser().save()
instance.parent.parent.theme_text_color = 'Custom' instance.parent.parent.theme_text_color = 'Custom'
try: instance.parent.parent.canvas.children[3].rgba = [0, 0, 0, 0]
instance.parent.parent.canvas.children[6].rgba = [0, 0, 0, 0] # try:
except Exception: # instance.parent.parent.canvas.children[6].rgba = [0, 0, 0, 0]
instance.parent.parent.canvas.children[9].rgba = [0, 0, 0, 0] # except Exception:
# instance.parent.parent.canvas.children[9].rgba = [0, 0, 0, 0]
toast('Address Enabled') toast('Address Enabled')
Clock.schedule_once(self.address_permision_callback, 0) Clock.schedule_once(self.address_permision_callback, 0)

View File

@ -2,6 +2,7 @@ from bitmessagekivy.get_platform import platform
from bitmessagekivy import kivy_helper_search from bitmessagekivy import kivy_helper_search
from kivy.clock import Clock from kivy.clock import Clock
from kivy.metrics import dp
from kivy.properties import StringProperty from kivy.properties import StringProperty
from kivy.uix.boxlayout import BoxLayout from kivy.uix.boxlayout import BoxLayout

View File

@ -5,8 +5,10 @@ from bmconfigparser import BMConfigParser
from functools import partial from functools import partial
from helper_sql import sqlExecute from helper_sql import sqlExecute
from kivy.clock import Clock from kivy.clock import Clock
from kivy.factory import Factory
from kivy.metrics import dp from kivy.metrics import dp
from kivy.properties import StringProperty, ListProperty from kivy.properties import StringProperty, ListProperty
from kivy.uix.button import Button from kivy.uix.button import Button
from kivy.uix.carousel import Carousel from kivy.uix.carousel import Carousel
from kivy.uix.screenmanager import Screen from kivy.uix.screenmanager import Screen
@ -16,10 +18,10 @@ from kivymd.uix.list import TwoLineAvatarIconListItem
import state import state
from bitmessagekivy.baseclass.common import ( from bitmessagekivy.baseclass.common import (
showLimitedCnt, initailize_detail_page, ThemeClsColor, showLimitedCnt, ThemeClsColor, avatarImageFirstLetter,
avatarImageFirstLetter, AddTimeWidget, AvatarSampleWidget, AddTimeWidget, AvatarSampleWidget, toast
toast
) )
from bitmessagekivy.baseclass.maildetail import MailDetail
class Sent(Screen): class Sent(Screen):
@ -201,10 +203,9 @@ class Sent(Screen):
src_mng_obj = self.manager src_mng_obj = self.manager
else: else:
src_mng_obj = self.parent.parent src_mng_obj = self.parent.parent
# src_mng_obj.screens[13].clear_widgets() src_mng_obj.screens[11].clear_widgets()
# src_mng_obj.screens[13].add_widget(MailDetail()) src_mng_obj.screens[11].add_widget(MailDetail())
# src_mng_obj.current = 'mailDetail' src_mng_obj.current = 'mailDetail'
initailize_detail_page(src_mng_obj)
def delete(self, data_index, instance, *args): def delete(self, data_index, instance, *args):
"""Delete sent mail from sent mail listing""" """Delete sent mail from sent mail listing"""
@ -236,12 +237,12 @@ class Sent(Screen):
def update_trash(self): def update_trash(self):
"""Update trash screen mails which is deleted from inbox""" """Update trash screen mails which is deleted from inbox"""
try: try:
self.parent.screens[4].clear_widgets() self.parent.screens[3].clear_widgets()
self.parent.screens[4].add_widget(Trash()) self.parent.screens[3].add_widget(Factory.Trash())
self.parent.screens[16].clear_widgets() self.parent.screens[14].clear_widgets()
self.parent.screens[16].add_widget(Allmails()) self.parent.screens[14].add_widget(Factory.Allmails())
except Exception: except Exception:
self.parent.parent.screens[4].clear_widgets() self.parent.parent.screens[3].clear_widgets()
self.parent.parent.screens[4].add_widget(Trash()) self.parent.parent.screens[3].add_widget(Factory.Trash())
self.parent.parent.screens[16].clear_widgets() self.parent.parent.screens[14].clear_widgets()
self.parent.parent.screens[16].add_widget(Allmails()) self.parent.parent.screens[14].add_widget(Factory.Allmails())

View File

@ -19,7 +19,7 @@ from kivy.uix.screenmanager import Screen
import state import state
from bitmessagekivy.baseclass.common import ( from bitmessagekivy.baseclass.common import (
showLimitedCnt, initailize_detail_page, avatarImageFirstLetter, showLimitedCnt, avatarImageFirstLetter,
AddTimeWidget, ThemeClsColor, AvatarSampleWidget AddTimeWidget, ThemeClsColor, AvatarSampleWidget
) )

View File

@ -24,3 +24,10 @@
MDList: MDList:
id: ml id: ml
Loader: Loader:
<ToggleBtn>:
size_hint: None, None
size: dp(36), dp(48)
pos_hint: {'center_x': .95, 'center_y': .4}
on_active: app.root.ids.sc10.toggleAction(self)

View File

@ -267,8 +267,8 @@ MDNavigationLayout:
id:sc12 id:sc12
NetworkStat: NetworkStat:
id:sc13 id:sc13
# MailDetail: MailDetail:
# id:sc14 id:sc14
ShowQRCode: ShowQRCode:
id:sc15 id:sc15
Draft: Draft:

View File

@ -564,7 +564,6 @@ class NavigateApp(MDApp):
def clear_composer(self): def clear_composer(self):
"""If slow down, the new composer edit screen""" """If slow down, the new composer edit screen"""
self.set_navbar_for_composer() self.set_navbar_for_composer()
# import pdb;pdb.set_trace()
composer_obj = self.root.ids.sc3.children[1].ids composer_obj = self.root.ids.sc3.children[1].ids
composer_obj.ti.text = '' composer_obj.ti.text = ''
composer_obj.btn.text = 'Select' composer_obj.btn.text = 'Select'
@ -811,7 +810,6 @@ class NavigateApp(MDApp):
try: try:
self.root.ids.sc17.children[1].active = True self.root.ids.sc17.children[1].active = True
except Exception: except Exception:
# import pdb;pdb.set_trace()
self.root.ids.sc17.children[0].children[1].active = True self.root.ids.sc17.children[0].children[1].active = True
Clock.schedule_once(partial(self.load_screen_callback, instance), 1) Clock.schedule_once(partial(self.load_screen_callback, instance), 1)

View File

@ -50,7 +50,6 @@
"Import": "from bitmessagekivy.baseclass.myaddress import MyAddress", "Import": "from bitmessagekivy.baseclass.myaddress import MyAddress",
}, },
"MailDetail": { "MailDetail": {
"_comment1": "this is my comment",
"kv_string": "maildetail", "kv_string": "maildetail",
"name_screen": "mailDetail", "name_screen": "mailDetail",
"Import": "from bitmessagekivy.baseclass.maildetail import MailDetail", "Import": "from bitmessagekivy.baseclass.maildetail import MailDetail",