implemented reset default avatar feature

This commit is contained in:
navjot 2021-01-28 13:52:04 +05:30
parent ba7a23ae20
commit b53f0a44c0
No known key found for this signature in database
GPG Key ID: 9EE70AFD71357F1C
4 changed files with 71 additions and 29 deletions

View File

@ -4,7 +4,7 @@
BoxLayout:
orientation: 'vertical'
size_hint_y: None
height: self.minimum_height + 2 * self.parent.height/4
height: self.minimum_height + 3 * self.parent.height/4
padding: dp(20)
spacing: 15
BoxLayout:
@ -76,17 +76,25 @@
Color:
rgba: (0,0,0,1)
MyMDTextField:
id: body
multiline: True
hint_text: 'body'
size_hint_y: None
font_size: '15sp'
required: True
helper_text_mode: "on_error"
canvas.before:
Color:
rgba: (0,0,0,1)
# MyMDTextField:
# id: body
# multiline: True
# hint_text: 'body'
# size_hint_y: None
# font_size: '15sp'
# required: True
# helper_text_mode: "on_error"
# canvas.before:
# Color:
# rgba: (0,0,0,1)
ScrollView:
id: scrlv
TextInput:
id: body
# text: 'srggdfsfhgfg'
hint_text: 'body'
size_hint: 1, None
height: app.window_size[1]/4
BoxLayout:
spacing:50

View File

@ -65,6 +65,20 @@
size_hint_y: None
height: "200dp"
MDIconButton:
id: reset_image
icon: "refresh"
x: root.parent.x + dp(10)
pos_hint: {"top": 1, 'left': 1}
color: [1,0,0,1]
on_release: app.rest_default_avatar_img()
theme_text_color: "Custom"
text_color: app.theme_cls.primary_color
# opacity: 1 if app.current_address_label() else 0
# disabled: False if app.current_address_label() else True
opacity: 0
disabled: True
MDIconButton:
id: file_manager
icon: "file-image"
@ -111,7 +125,7 @@
pos_hint:{"x":0,"y":0}
option_cls: Factory.get("MySpinnerOption")
font_size: '12.5sp'
text: app.getDefaultAccData()
text: app.getDefaultAccData(self)
#background_color: color_button if self.state == 'normal' else color_button_pressed
#background_down: 'atlas://data/images/defaulttheme/spinner'
color: color_font

View File

@ -1782,6 +1782,7 @@ class Create(Screen):
def __init__(self, **kwargs):
"""Getting Labels and address from addressbook"""
super(Create, self).__init__(**kwargs)
Window.softinput_mode = "below_target"
widget_1 = DropDownWidget()
widget_1.ids.txt_input.word_list = [
addr[1] for addr in sqlQuery(
@ -1951,6 +1952,8 @@ class NavigateApp(MDApp):
self.load_selected_Image(text)
else:
self.set_identicon(text)
self.root.ids.content_drawer.ids.reset_image.opacity = 0
self.root.ids.content_drawer.ids.reset_image.disabled = True
address_label = self.current_address_label(
BMConfigParser().get(text, 'label'), text)
self.root_window.children[1].ids.toolbar.title = address_label
@ -2086,25 +2089,27 @@ class NavigateApp(MDApp):
self.add_popup.dismiss()
toast('Canceled')
def getDefaultAccData(self):
def getDefaultAccData(self, instance):
"""Getting Default Account Data"""
if BMConfigParser().addresses():
img = identiconGeneration.generate(BMConfigParser().addresses()[0])
self.createFolder(state.imageDir + '/default_identicon/')
if platform == 'android':
# android_path = os.path.expanduser
# ("~/user/0/org.test.bitapp/files/app/")
if not os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(
BMConfigParser().addresses()[0])):
android_path = os.path.join(
os.environ['ANDROID_PRIVATE'] + '/app/')
img.texture.save('{1}/images/kivy/default_identicon/{0}.png'.format(
BMConfigParser().addresses()[0], android_path))
else:
if not os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(
BMConfigParser().addresses()[0])):
img.texture.save(state.imageDir + '/default_identicon/{}.png'.format(
BMConfigParser().addresses()[0]))
# self.createFolder(state.imageDir + '/default_identicon/')
# if platform == 'android':
# # android_path = os.path.expanduser
# # ("~/user/0/org.test.bitapp/files/app/")
# if not os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(
# BMConfigParser().addresses()[0])):
# android_path = os.path.join(
# os.environ['ANDROID_PRIVATE'] + '/app/')
# img.texture.save('{1}/images/kivy/default_identicon/{0}.png'.format(
# BMConfigParser().addresses()[0], android_path))
# else:
# if not os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(
# BMConfigParser().addresses()[0])):
# img.texture.save(state.imageDir + '/default_identicon/{}.png'.format(
# BMConfigParser().addresses()[0]))
instance.parent.parent.parent.parent.parent.ids.top_box.children[0].texture = (
img.texture)
return BMConfigParser().addresses()[0]
return 'Select Address'
@ -2579,9 +2584,24 @@ class NavigateApp(MDApp):
# spinner_img_obj = self.root.ids.content_drawer.ids.btn.children[1]
# spinner_img_obj.source = top_box_obj.source ='./images/default_identicon/{0}.png'.format(curerentAddr)
top_box_obj.source = state.imageDir + '/default_identicon/{0}.png'.format(curerentAddr)
self.root.ids.content_drawer.ids.reset_image.opacity = 1
self.root.ids.content_drawer.ids.reset_image.disabled = False
top_box_obj.reload()
# spinner_img_obj.reload()
def rest_default_avatar_img(self):
"""set default avatar generated image"""
self.set_identicon(state.association)
img_path = state.imageDir + '/default_identicon/{}.png'.format(state.association)
try:
if os.path.exists(img_path):
os.remove(img_path)
self.root.ids.content_drawer.ids.reset_image.opacity = 0
self.root.ids.content_drawer.ids.reset_image.disabled = True
except Exception as e:
pass
toast('Avatar reset')
def copy_composer_text(self, text): # pylint: disable=no-self-use
"""Copy the data from mail detail page"""
Clipboard.copy(text)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB