Merge pull request #67 from jaicis/Chatroom

worked on message listing compatibility or chip tag labeling
This commit is contained in:
navjotcis 2020-05-13 21:33:07 +05:30 committed by GitHub
commit d2e2a9bfaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 46 deletions

View File

@ -30,3 +30,8 @@
id: ml id: ml
Loader: Loader:
ComposerButton: ComposerButton:
<TimeTagRightSampleWidget>:
size_hint:(None, None)
font_style: 'Caption'
halign: 'center'

View File

@ -32,18 +32,21 @@
divider: None divider: None
on_press: root.detailedPopup() on_press: root.detailedPopup()
BadgeText: BadgeText:
size_hint:(None, None)
size:[120, 140] if app.app_platform == 'android' else [64, 80]
text: root.time_tag text: root.time_tag
halign:'right' halign:'center'
font_style:'Caption' font_style:'Caption'
pos_hint: {'center_y': .8} pos_hint: {'center_y': .8}
_txt_right_pad: dp(70) _txt_right_pad: dp(70)
font_size: '11sp'
MDChip: MDChip:
size_hint: (None, None) size_hint: (.16 if app.app_platform == 'android' else .07 , None)
label: root.page_type label: root.page_type
icon: '' icon: ''
pos_hint: {'center_x': .94, 'center_y': .3} pos_hint: {'center_x': .91 if app.app_platform == 'android' else .95, 'center_y': .3}
radius: 8 radius: 8
height: 18 height: self.parent.height/4
AvatarSampleWidget: AvatarSampleWidget:
source: root.avatarImg source: root.avatarImg
MDLabel: MDLabel:

View File

@ -102,7 +102,7 @@
BoxLayout: BoxLayout:
size_hint_y: None size_hint_y: None
orientation: 'vertical' orientation: 'vertical'
spacing:dp(20) spacing:dp(15)
MDLabel: MDLabel:
font_style: 'Subtitle2' font_style: 'Subtitle2'
theme_text_color: 'Primary' theme_text_color: 'Primary'
@ -128,6 +128,9 @@
text: "Address" text: "Address"
font_size: '17sp' font_size: '17sp'
halign: 'left' halign: 'left'
Widget:
size_hint_y: None
height: dp(1)
BoxLayout: BoxLayout:
orientation: 'horizontal' orientation: 'horizontal'
MDLabel: MDLabel:

View File

@ -3,6 +3,7 @@ Bitmessage android(mobile) interface
""" """
# pylint: disable=too-many-lines,import-error,no-name-in-module,unused-argument # pylint: disable=too-many-lines,import-error,no-name-in-module,unused-argument
# pylint: disable=too-many-ancestors,too-many-locals,useless-super-delegation # pylint: disable=too-many-ancestors,too-many-locals,useless-super-delegation
# pylint: disable=protected-access
import os import os
import time import time
from bitmessagekivy import identiconGeneration from bitmessagekivy import identiconGeneration
@ -114,22 +115,22 @@ def ShowTimeHistoy(act_time):
def AddTimeWidget(time): # pylint: disable=redefined-outer-name def AddTimeWidget(time): # pylint: disable=redefined-outer-name
"""This method is used to create TimeWidget""" """This method is used to create TimeWidget"""
action_time = BadgeText( action_time = TimeTagRightSampleWidget(
size_hint=(None, None),
text=str(ShowTimeHistoy(time)), text=str(ShowTimeHistoy(time)),
halign='right',
font_style='Caption', font_style='Caption',
size=[65, 70]) size=[120, 140] if platform == 'android' else [64, 80])
action_time.font_size = '11sp'
return action_time return action_time
def chipTag(text): def chipTag(text):
"""This method is used for showing chip tag""" """This method is used for showing chip tag"""
obj = MDChip() obj = MDChip()
obj.size_hint = (None, None) # obj.size_hint = (None, None)
obj.size_hint = (.16 if platform == 'android' else .07, None)
obj.label = text obj.label = text
obj.icon = '' obj.icon = ''
obj.pos_hint = {'center_x': .96, 'center_y': .2} obj.pos_hint = {'center_x': .91 if platform == 'android' else .94, 'center_y': .3}
obj.height = dp(18) obj.height = dp(18)
obj.radius = 8 obj.radius = 8
return obj return obj
@ -221,7 +222,7 @@ class Inbox(Screen):
text=item['text'], secondary_text=item['secondary_text'], text=item['text'], secondary_text=item['secondary_text'],
theme_text_color='Custom', theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny._txt_right_pad=dp(70) meny._txt_right_pad = dp(70)
meny.add_widget(AvatarSampleWidget( meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format( source='./images/text_images/{}.png'.format(
avatarImageFirstLetter(item['secondary_text'].strip())))) avatarImageFirstLetter(item['secondary_text'].strip()))))
@ -407,7 +408,7 @@ class MyAddress(Screen):
text=item['text'], secondary_text=item['secondary_text'], text=item['text'], secondary_text=item['secondary_text'],
theme_text_color='Custom' if is_enable == 'true' else 'Primary', theme_text_color='Custom' if is_enable == 'true' else 'Primary',
text_color=NavigateApp().theme_cls.primary_color,) text_color=NavigateApp().theme_cls.primary_color,)
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[6].rgba = [0, 0, 0, 0] if is_enable == 'true' else [0.5, 0.5, 0.5, 0.5]
except Exception: except Exception:
@ -419,32 +420,16 @@ class MyAddress(Screen):
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']:
badge_obj = BadgeText( badge_obj = BadgeText(
size_hint=(None, None), size_hint=(None, None),
text='Active', halign='right', size=[85 if platform == 'android' else 50, 60],
# font_size = '50sp', text='Active', halign='center',
font_style='Body1', size=[50, 60], font_style='Body1', theme_text_color='Custom',
theme_text_color='Custom', text_color=NavigateApp().theme_cls.primary_color
text_color=NavigateApp().theme_cls.primary_color) )
badge_obj.font_size = '13sp' badge_obj.font_size = '13sp'
meny.add_widget(badge_obj) meny.add_widget(badge_obj)
else: else:
meny.add_widget(ToggleBtn(active=True if is_enable == 'true' else False)) meny.add_widget(ToggleBtn(active=True if is_enable == 'true' else False))
# carousel = Carousel(direction='right')
# carousel.height = meny.height
# carousel.size_hint_y = None
# carousel.ignore_perpendicular_swipes = True
# carousel.data_index = 0
# carousel.min_move = 0.2
# del_btn = Button(text='Disable' if is_enable == 'true' else 'Enable')
# if is_enable == 'true':
# del_btn.background_normal = ''
# del_btn.background_color = (1, 0, 0, 1) if is_enable == 'true' else (0, 1, 0, 1)
# del_btn.bind(
# on_press=partial(
# self.disableAddress if is_enable == 'true' else self.enableAddress , item['secondary_text']))
# carousel.add_widget(del_btn)
# carousel.add_widget(meny)
# carousel.index = 1
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):
@ -1143,7 +1128,7 @@ class Sent(Screen):
text=item['text'], secondary_text=item['secondary_text'], text=item['text'], secondary_text=item['secondary_text'],
theme_text_color='Custom', theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny._txt_right_pad=dp(70) meny._txt_right_pad = dp(70)
meny.add_widget(AvatarSampleWidget( meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format( source='./images/text_images/{}.png'.format(
avatarImageFirstLetter(item['secondary_text'].strip())))) avatarImageFirstLetter(item['secondary_text'].strip()))))
@ -1362,7 +1347,7 @@ class Trash(Screen):
subject) >= 50 else (subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', ''), subject) >= 50 else (subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', ''),
theme_text_color='Custom', theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny._txt_right_pad=dp(70) meny._txt_right_pad = dp(70)
img_latter = './images/text_images/{}.png'.format( img_latter = './images/text_images/{}.png'.format(
subject[0].upper() if (subject[0].upper() >= 'A' and subject[0].upper() <= 'Z') else '!') subject[0].upper() if (subject[0].upper() >= 'A' and subject[0].upper() <= 'Z') else '!')
meny.add_widget(AvatarSampleWidget(source=img_latter)) meny.add_widget(AvatarSampleWidget(source=img_latter))
@ -1596,7 +1581,7 @@ class NavigateApp(MDApp):
# android_path = os.path.expanduser # android_path = os.path.expanduser
# ("~/user/0/org.test.bitapp/files/app/") # ("~/user/0/org.test.bitapp/files/app/")
if not os.path.exists('./images/default_identicon/{}.png'.format( if not os.path.exists('./images/default_identicon/{}.png'.format(
BMConfigParser().addresses()[0])): BMConfigParser().addresses()[0])):
android_path = os.path.join( android_path = os.path.join(
os.environ['ANDROID_PRIVATE'] + '/app/') os.environ['ANDROID_PRIVATE'] + '/app/')
img.texture.save('{1}/images/default_identicon/{0}.png'.format( img.texture.save('{1}/images/default_identicon/{0}.png'.format(
@ -2028,7 +2013,7 @@ class NavigateApp(MDApp):
self.manager = ModalView(size_hint=(1, 1), auto_dismiss=False) self.manager = ModalView(size_hint=(1, 1), auto_dismiss=False)
self.file_manager = MDFileManager( self.file_manager = MDFileManager(
exit_manager=self.exit_manager, exit_manager=self.exit_manager,
select_path=self.select_path, select_path=self.select_path,
previous=False, previous=False,
ext=['.png', '.jpg'] ext=['.png', '.jpg']
) )
@ -2065,7 +2050,7 @@ class NavigateApp(MDApp):
newImg = PilImage.open(path).resize((300, 300)) newImg = PilImage.open(path).resize((300, 300))
if platform == 'android': if platform == 'android':
android_path = os.path.join( android_path = os.path.join(
os.environ['ANDROID_PRIVATE'] + '/app/') os.environ['ANDROID_PRIVATE'] + '/app/')
newImg.save('{1}/images/default_identicon/{0}.png'.format( newImg.save('{1}/images/default_identicon/{0}.png'.format(
state.association, android_path)) state.association, android_path))
else: else:
@ -2234,6 +2219,12 @@ class IconRightSampleWidget(IRightBodyTouch, MDIconButton):
pass pass
class TimeTagRightSampleWidget(IRightBodyTouch, MDLabel):
"""Right icon sample widget"""
pass
class ToggleBtn(IRightBodyTouch, MDSwitch): class ToggleBtn(IRightBodyTouch, MDSwitch):
"""Right toggle button widget""" """Right toggle button widget"""
pass pass
@ -2614,7 +2605,7 @@ class Draft(Screen):
text='Draft', secondary_text=item['text'], text='Draft', secondary_text=item['text'],
theme_text_color='Custom', theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny._txt_right_pad=dp(70) meny._txt_right_pad = dp(70)
meny.add_widget(AvatarSampleWidget( meny.add_widget(AvatarSampleWidget(
source='./images/avatar.png')) source='./images/avatar.png'))
meny.bind(on_press=partial( meny.bind(on_press=partial(
@ -2817,7 +2808,7 @@ class Allmails(Screen):
subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', ''), subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', ''),
theme_text_color='Custom', theme_text_color='Custom',
text_color=NavigateApp().theme_cls.primary_color) text_color=NavigateApp().theme_cls.primary_color)
meny._txt_right_pad=dp(70) meny._txt_right_pad = dp(70)
meny.add_widget(AvatarSampleWidget( meny.add_widget(AvatarSampleWidget(
source='./images/text_images/{}.png'.format( source='./images/text_images/{}.png'.format(
avatarImageFirstLetter(body.strip())))) avatarImageFirstLetter(body.strip()))))

View File

@ -11,13 +11,12 @@ class TestCharMessage(unittest.TestCase):
""" """
def test_decode(self): def test_decode(self):
"""Test various types of decode method""" """Test various types of decode method"""
chat_obj = Chatmsg()
import messagetypes import messagetypes
result = messagetypes.constructObject({'': 'chatmsg', 'message': 'hello world'}) result = messagetypes.constructObject({'': 'chatmsg', 'message': 'hello world'})
self.assertTrue(isinstance(result.message, str)) self.assertTrue(isinstance(result.message, str))
def test_encode(self): def test_encode(self):
"""Test various types of encode method"""
chat_obj = Chatmsg() chat_obj = Chatmsg()
result = chat_obj.encode({'message':'hello world'}) result = chat_obj.encode({'message': 'hello world'})
self.assertTrue(True if result['message'] else False) self.assertTrue(True if result['message'] else False)