Merge pull request #82 from jaicis/Chatroom
implemented reset default avatar feature
This commit is contained in:
commit
09a76054e4
|
@ -4,7 +4,7 @@
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
size_hint_y: None
|
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)
|
padding: dp(20)
|
||||||
spacing: 15
|
spacing: 15
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
|
@ -76,17 +76,25 @@
|
||||||
Color:
|
Color:
|
||||||
rgba: (0,0,0,1)
|
rgba: (0,0,0,1)
|
||||||
|
|
||||||
MyMDTextField:
|
# MyMDTextField:
|
||||||
id: body
|
# id: body
|
||||||
multiline: True
|
# multiline: True
|
||||||
hint_text: 'body'
|
# hint_text: 'body'
|
||||||
size_hint_y: None
|
# size_hint_y: None
|
||||||
font_size: '15sp'
|
# font_size: '15sp'
|
||||||
required: True
|
# required: True
|
||||||
helper_text_mode: "on_error"
|
# helper_text_mode: "on_error"
|
||||||
canvas.before:
|
# canvas.before:
|
||||||
Color:
|
# Color:
|
||||||
rgba: (0,0,0,1)
|
# 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:
|
BoxLayout:
|
||||||
spacing:50
|
spacing:50
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,20 @@
|
||||||
size_hint_y: None
|
size_hint_y: None
|
||||||
height: "200dp"
|
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:
|
MDIconButton:
|
||||||
id: file_manager
|
id: file_manager
|
||||||
icon: "file-image"
|
icon: "file-image"
|
||||||
|
@ -111,7 +125,7 @@
|
||||||
pos_hint:{"x":0,"y":0}
|
pos_hint:{"x":0,"y":0}
|
||||||
option_cls: Factory.get("MySpinnerOption")
|
option_cls: Factory.get("MySpinnerOption")
|
||||||
font_size: '12.5sp'
|
font_size: '12.5sp'
|
||||||
text: app.getDefaultAccData()
|
text: app.getDefaultAccData(self)
|
||||||
#background_color: color_button if self.state == 'normal' else color_button_pressed
|
#background_color: color_button if self.state == 'normal' else color_button_pressed
|
||||||
#background_down: 'atlas://data/images/defaulttheme/spinner'
|
#background_down: 'atlas://data/images/defaulttheme/spinner'
|
||||||
color: color_font
|
color: color_font
|
||||||
|
|
|
@ -538,7 +538,7 @@ class MyAddress(Screen):
|
||||||
avatarImageFirstLetter(item['text'].strip()))))
|
avatarImageFirstLetter(item['text'].strip()))))
|
||||||
meny.bind(on_press=partial(
|
meny.bind(on_press=partial(
|
||||||
self.myadd_detail, item['secondary_text'], item['text']))
|
self.myadd_detail, item['secondary_text'], item['text']))
|
||||||
if state.association == item['secondary_text']:
|
if state.association == item['secondary_text'] and is_enable == 'true':
|
||||||
badge_obj = BadgeText(
|
badge_obj = BadgeText(
|
||||||
size_hint=(None, None),
|
size_hint=(None, None),
|
||||||
size=[90 if platform == 'android' else 50, 60],
|
size=[90 if platform == 'android' else 50, 60],
|
||||||
|
@ -1782,6 +1782,7 @@ class Create(Screen):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Getting Labels and address from addressbook"""
|
"""Getting Labels and address from addressbook"""
|
||||||
super(Create, self).__init__(**kwargs)
|
super(Create, self).__init__(**kwargs)
|
||||||
|
Window.softinput_mode = "below_target"
|
||||||
widget_1 = DropDownWidget()
|
widget_1 = DropDownWidget()
|
||||||
widget_1.ids.txt_input.word_list = [
|
widget_1.ids.txt_input.word_list = [
|
||||||
addr[1] for addr in sqlQuery(
|
addr[1] for addr in sqlQuery(
|
||||||
|
@ -1951,6 +1952,8 @@ class NavigateApp(MDApp):
|
||||||
self.load_selected_Image(text)
|
self.load_selected_Image(text)
|
||||||
else:
|
else:
|
||||||
self.set_identicon(text)
|
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(
|
address_label = self.current_address_label(
|
||||||
BMConfigParser().get(text, 'label'), text)
|
BMConfigParser().get(text, 'label'), text)
|
||||||
self.root_window.children[1].ids.toolbar.title = address_label
|
self.root_window.children[1].ids.toolbar.title = address_label
|
||||||
|
@ -2086,26 +2089,30 @@ class NavigateApp(MDApp):
|
||||||
self.add_popup.dismiss()
|
self.add_popup.dismiss()
|
||||||
toast('Canceled')
|
toast('Canceled')
|
||||||
|
|
||||||
def getDefaultAccData(self):
|
def getDefaultAccData(self, instance):
|
||||||
"""Getting Default Account Data"""
|
"""Getting Default Account Data"""
|
||||||
if BMConfigParser().addresses():
|
if BMConfigParser().addresses():
|
||||||
img = identiconGeneration.generate(BMConfigParser().addresses()[0])
|
first_addr = BMConfigParser().addresses()[0]
|
||||||
self.createFolder(state.imageDir + '/default_identicon/')
|
if BMConfigParser().get(str(first_addr), 'enabled') == 'true':
|
||||||
if platform == 'android':
|
img = identiconGeneration.generate(first_addr)
|
||||||
# android_path = os.path.expanduser
|
# self.createFolder(state.imageDir + '/default_identicon/')
|
||||||
# ("~/user/0/org.test.bitapp/files/app/")
|
# if platform == 'android':
|
||||||
if not os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(
|
# # android_path = os.path.expanduser
|
||||||
BMConfigParser().addresses()[0])):
|
# # ("~/user/0/org.test.bitapp/files/app/")
|
||||||
android_path = os.path.join(
|
# if not os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(
|
||||||
os.environ['ANDROID_PRIVATE'] + '/app/')
|
# BMConfigParser().addresses()[0])):
|
||||||
img.texture.save('{1}/images/kivy/default_identicon/{0}.png'.format(
|
# android_path = os.path.join(
|
||||||
BMConfigParser().addresses()[0], android_path))
|
# os.environ['ANDROID_PRIVATE'] + '/app/')
|
||||||
else:
|
# img.texture.save('{1}/images/kivy/default_identicon/{0}.png'.format(
|
||||||
if not os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(
|
# BMConfigParser().addresses()[0], android_path))
|
||||||
BMConfigParser().addresses()[0])):
|
# else:
|
||||||
img.texture.save(state.imageDir + '/default_identicon/{}.png'.format(
|
# if not os.path.exists(state.imageDir + '/default_identicon/{}.png'.format(
|
||||||
BMConfigParser().addresses()[0]))
|
# BMConfigParser().addresses()[0])):
|
||||||
return 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 first_addr
|
||||||
return 'Select Address'
|
return 'Select Address'
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -2129,8 +2136,10 @@ class NavigateApp(MDApp):
|
||||||
def get_default_logo():
|
def get_default_logo():
|
||||||
"""Getting default logo image"""
|
"""Getting default logo image"""
|
||||||
if BMConfigParser().addresses():
|
if BMConfigParser().addresses():
|
||||||
return state.imageDir + '/default_identicon/{}.png'.format(
|
first_addr = BMConfigParser().addresses()[0]
|
||||||
BMConfigParser().addresses()[0])
|
if BMConfigParser().get(str(first_addr), 'enabled') == 'true':
|
||||||
|
return state.imageDir + '/default_identicon/{}.png'.format(
|
||||||
|
first_addr)
|
||||||
return state.imageDir + '/drawer_logo1.png'
|
return state.imageDir + '/drawer_logo1.png'
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -2384,6 +2393,8 @@ class NavigateApp(MDApp):
|
||||||
else:
|
else:
|
||||||
addr = BMConfigParser().addresses()[0]
|
addr = BMConfigParser().addresses()[0]
|
||||||
first_name = BMConfigParser().get(addr, 'label')
|
first_name = BMConfigParser().get(addr, 'label')
|
||||||
|
if BMConfigParser().get(addr, 'enabled') != 'true':
|
||||||
|
return ''
|
||||||
f_name = first_name.split()
|
f_name = first_name.split()
|
||||||
label = f_name[0][:14].capitalize() + '...' if len(
|
label = f_name[0][:14].capitalize() + '...' if len(
|
||||||
f_name[0]) > 15 else f_name[0].capitalize()
|
f_name[0]) > 15 else f_name[0].capitalize()
|
||||||
|
@ -2579,9 +2590,24 @@ class NavigateApp(MDApp):
|
||||||
# spinner_img_obj = self.root.ids.content_drawer.ids.btn.children[1]
|
# 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)
|
# 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)
|
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()
|
top_box_obj.reload()
|
||||||
# spinner_img_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
|
def copy_composer_text(self, text): # pylint: disable=no-self-use
|
||||||
"""Copy the data from mail detail page"""
|
"""Copy the data from mail detail page"""
|
||||||
Clipboard.copy(text)
|
Clipboard.copy(text)
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 26 KiB |
Reference in New Issue
Block a user