예제 #1
0
    def ui_layout(self):
        calibration_card = MDCard(padding=dp(24),
                                  spacing=dp(24),
                                  orientation='vertical',
                                  size_hint=(0.75, 0.45),
                                  pos_hint={
                                      'top': 0.75,
                                      'center_x': 0.5
                                  })

        calibration_label = MDLabel(text='Calibrate Audio Input',
                                    font_style='H4',
                                    halign='center')
        calibration_label.theme_text_color = 'Custom'
        calibration_label.text_color = [1, 1, 1, 1]

        self.slider = Slider(size_hint=(0.75, None),
                             pos_hint={'center_x': 0.5})
        self.slider.bind(value=self.on_value_change)

        helper_box = BoxLayout(orientation='horizontal')
        left_label = MDLabel(text='Less Sensitive', font_style='Caption')
        left_label.theme_text_color = 'Custom'
        left_label.text_color = [1, 1, 1, 1]
        right_label = MDLabel(text='More Sensitive', font_style='Caption')
        right_label.theme_text_color = 'Custom'
        right_label.text_color = [1, 1, 1, 1]

        helper_box.add_widget(Widget())
        helper_box.add_widget(left_label)
        helper_box.add_widget(Widget())
        helper_box.add_widget(Widget())
        helper_box.add_widget(Widget())
        helper_box.add_widget(right_label)
        helper_box.add_widget(Widget())

        calibration_card.add_widget(calibration_label)
        calibration_card.add_widget(Widget())
        calibration_card.add_widget(Widget())
        calibration_card.add_widget(self.slider)
        calibration_card.add_widget(helper_box)
        calibration_card.add_widget(Widget())

        toolbar_anchor = AnchorLayout(anchor_x='center', anchor_y='top')
        toolbar = MDToolbar(title='Add Contact', anchor_title='center')
        toolbar.md_bg_color = App.get_running_app().theme_cls.primary_color
        toolbar.left_action_items = [[
            'arrow-left', lambda x: self.change_screen('welcome')
        ]]
        toolbar_anchor.add_widget(toolbar)

        self.add_widget(calibration_card)
        self.add_widget(toolbar_anchor)
예제 #2
0
    def ui_layout(self):
        self.clear_widgets()

        layout = BoxLayout(orientation='vertical')
        scroll = ScrollView(do_scroll_x=False,
                            size_hint=(1, None),
                            size=(Window.width, Window.height))
        scroll_box = BoxLayout(orientation='vertical',
                               size_hint_y=None,
                               padding=(dp(12), dp(60)),
                               spacing=dp(5))
        scroll_box.bind(minimum_height=scroll_box.setter('height'))
        # Add more self.scrollbox.add_widget(MDLabel(text='')) to increase padding
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' ', size_hint=(1, 5)))

        for contact in self.util.contact_list:
            contact_card = ContactCard(util=self.util,
                                       contact=contact
                                       )
            scroll_box.add_widget(contact_card)

        scroll.add_widget(scroll_box)
        layout.add_widget(scroll)

        # Add floating action button to write messages
        add_contact_anchor = AnchorLayout(anchor_x='right', anchor_y='bottom',
                                          padding=[dp(25), dp(25), dp(25), dp(25)])
        add_contact_btn = MDFloatingActionButton(icon='account-plus', size=[dp(56), dp(56)])
        add_contact_btn.md_bg_color = App.get_running_app().theme_cls.primary_color
        add_contact_btn.theme_text_color = "Custom"
        add_contact_btn.text_color = [1, 1, 1, 1]
        add_contact_btn.bind(on_press=lambda x: self.change_screen('add_contact'))
        add_contact_anchor.add_widget(add_contact_btn)

        toolbar_anchor = AnchorLayout(anchor_x='center', anchor_y='top')
        toolbar = MDToolbar(title='Contacts', anchor_title='center')
        toolbar.md_bg_color = App.get_running_app().theme_cls.primary_color
        toolbar.left_action_items = [['arrow-left', lambda x: self.change_screen('message')]]
        toolbar_anchor.add_widget(toolbar)

        self.add_widget(layout)
        self.add_widget(add_contact_anchor)
        self.add_widget(toolbar_anchor)

        self.do_layout()
예제 #3
0
    def ui_layout(self):
        add_contact_card = MDCard(padding=dp(24),
                                  spacing=dp(24),
                                  orientation='vertical',
                                  size_hint=(0.75, 0.45),
                                  pos_hint={
                                      'top': 0.75,
                                      'center_x': 0.5
                                  })

        add_contact_label = MDLabel(text='Enter In a User Name',
                                    font_style='H4',
                                    halign='center')
        add_contact_label.theme_text_color = 'Custom'
        add_contact_label.text_color = [1, 1, 1, 1]

        self.info_text = MDLabel(text='', halign='center')
        self.info_text.theme_text_color = 'Error'

        self.contact_input = MDTextFieldRound(size_hint=(0.75, None),
                                              pos_hint={'center_x': 0.5})
        # Hides left icon
        self.contact_input.icon_left_dasabled = True
        # Moves widget out of the field of view
        self.contact_input.children[2].children[2].pos_hint = {
            'center_x': 500,
            'center_y': 500
        }
        self.contact_input.icon_right = 'send'
        self.contact_input.children[2].children[0].bind(
            on_press=lambda x: self.check_name(self.contact_input.text))

        add_contact_card.add_widget(add_contact_label)
        add_contact_card.add_widget(self.info_text)
        add_contact_card.add_widget(Widget())
        add_contact_card.add_widget(Widget())
        add_contact_card.add_widget(self.contact_input)

        toolbar_anchor = AnchorLayout(anchor_x='center', anchor_y='top')
        toolbar = MDToolbar(title='Add Contact', anchor_title='center')
        toolbar.md_bg_color = App.get_running_app().theme_cls.primary_color
        toolbar.left_action_items = [[
            'arrow-left', lambda x: self.change_screen('contact')
        ]]
        toolbar_anchor.add_widget(toolbar)

        self.add_widget(add_contact_card)
        self.add_widget(toolbar_anchor)
예제 #4
0
    def ui_layout(self):
        self.clear_widgets()
        signin_card = MDCard(padding=dp(24),
                             spacing=dp(24),
                             orientation='vertical',
                             size_hint=(0.75, 0.65),
                             pos_hint={'top': 0.8, 'center_x': 0.5}
                             )

        sign_in_label = MDLabel(text='Sign in or Create an Account',
                                font_style='H4', halign='center')
        sign_in_label.theme_text_color = 'Custom'
        sign_in_label.text_color = [1, 1, 1, 1]

        self.helper_label = MDLabel(text='', font_style='Caption', halign='center')
        self.helper_label.theme_text_color = 'Custom'
        self.helper_label.text_color = [1, 1, 1, 1]

        self.username_field = MDTextField()
        self.username_field.hint_text = "User Name"

        # Password
        self.password_field = MDTextField(password=True)
        self.password_field.hint_text = "Password"
        self.password_field.helper_text = "Password must be at least 8 characters"
        self.password_field.helper_text_mode = "on_focus"
        self.proceedButton = WelcomeButton(icon='account-alert', text='  Enter',
                                           size_hint=(None, None), size=(4 * dp(48), dp(48)))

        signin_card.add_widget(sign_in_label)
        if self.status == 'signed_in':
            sign_in_label.text = '%s already signed in!' % self.util.username
            signin_card.add_widget(self.helper_label)
            signin_card.add_widget(Widget())
            signin_card.add_widget(Widget())
            self.proceedButton.text = 'Logout'
            self.proceedButton.icon = 'logout'
            self.proceedButton.bind(on_press=lambda x: self.remove_user_data())
            signin_card.add_widget(self.proceedButton)
        elif self.status == 'sign_in':
            sign_in_label.text = 'Sign In'
            self.proceedButton.bind(on_press=lambda x: self.auth_token())
            signin_card.add_widget(self.helper_label)
            signin_card.add_widget(self.username_field)
            signin_card.add_widget(self.password_field)
            signin_card.add_widget(self.proceedButton)
            signin_card.add_widget(Widget())
        elif self.status == 'create':
            sign_in_label.text = 'Create Account'
            signin_card.add_widget(self.helper_label)
            signin_card.add_widget(self.username_field)
            signin_card.add_widget(self.password_field)
            signin_card.add_widget(self.proceedButton)
            signin_card.add_widget(Widget())
            self.proceedButton.bind(on_press=lambda x: self.create_account())
        else:
            sign_in_button = WelcomeButton(icon='login', text='Sign-in')
            sign_in_button.bind(on_press=lambda x: self.up_date_layout('sign_in'))
            create_account_button = WelcomeButton(icon='creation', text='Sign-up')
            create_account_button.bind(on_press=lambda x: self.up_date_layout('create'))

            choice_box = BoxLayout(orientation='horizontal')
            choice_box.add_widget(Widget())
            choice_box.add_widget(sign_in_button)
            choice_box.add_widget(Widget())
            choice_box.add_widget(Widget())
            choice_box.add_widget(create_account_button)
            choice_box.add_widget(Widget())

            signin_card.add_widget(Widget())
            signin_card.add_widget(Widget())
            signin_card.add_widget(choice_box)
            signin_card.add_widget(Widget())

        toolbar_anchor = AnchorLayout(anchor_x='center', anchor_y='top')
        toolbar = MDToolbar(title='Add Contact', anchor_title='center')
        toolbar.md_bg_color = App.get_running_app().theme_cls.primary_color
        toolbar.left_action_items = [['arrow-left', lambda x: self.change_screen('welcome')]]
        toolbar_anchor.add_widget(toolbar)

        self.add_widget(signin_card)
        self.add_widget(toolbar_anchor)
        self.do_layout()
예제 #5
0
    def __init__(self, **kwargs):
        super(box, self).__init__(**kwargs)
        global bt1, bt2, bt3, main_box_self

        main_box = BoxLayout()
        main_box.orientation = 'vertical'
        main_box_self = main_box
        self.anim_type = 'slide_above_simple'
        ####################################################################
        self.menu1 = BoxLayout(orientation='vertical', spacing=0.2)

        self.im1 = Image(source='image_2.jpg', color=(1, 1, 1, .5))

        self.im1.size_hint = [
            self.menu1.size_hint[0] * 0.3, self.menu1.size_hint[1] * 0.3
        ]
        #        self.im1.pos  = (self.height*1, self.width*1)

        gd_menu = GridLayout(cols=1, spacing=0.1)
        menu_btn = Button(text='change wallpaper',
                          background_color=(0, 0, 0, 0.2),
                          color=(1, 1, 1, 1),
                          size_hint_y=None)
        menu_btn.bind(on_release=lambda x: self.toggle_nav_drawer())
        menu_btn.bind(on_release=(self.gonext))
        menu_btn.bind(
            on_release=partial(change_image1.file_manager_open, self))

        gd_menu.add_widget(menu_btn)

        self.menu1.add_widget(self.im1)
        self.menu1.add_widget(gd_menu)
        #        self.menu1.add_widget(gd_menu.menu_btn)
        #
        self.add_widget(self.menu1)

        ########################################################

        tb = MDToolbar(title='menu', background_palette='Primary')
        tb.md_bg_color = [0, 0, 0, 0]
        tb.left_action_items = [['menu', lambda x: self.toggle_nav_drawer()]]

        main_box.add_widget(tb)

        gridlayout = GridLayout(cols=1, size_hint_y=None, spacing=2)
        gridlayout.bind(minimum_height=gridlayout.setter('height'))
        index = 0
        main_lyt = main_box
        dirpath = os.getcwd()
        for dirpath, dir_name, filename in os.walk(r'/storage/emulated/0/'):
            if (os.path.basename(dirpath) == 'Download'
                    or os.path.basename(dirpath) == 'audios'):
                for fn in glob(dirpath + '/*.mp3'):
                    btn = tbtn(id='song_btn', song_index=index)
                    btn_inst.append(btn)
                    songlist[index] = [fn, btn]
                    #                print(ID3(fn).text)
                    file2 = File(str(fn))
                    #                song_length = float(file2.info.pprint().split(',')[-1:][0][:-8])
                    #                print(float(song_length))
                    try:
                        pic_name = fn.split('/')[-1:][0][:-4]
                        artwork = file2.tags['APIC:'].data
                        with open(pic_name + '.jpg', 'wb') as img:
                            img.write(artwork)
                        cover_album.append(pic_name + '.jpg')
                    except:
                        rand_val = random.randint(0, 9)
                        cover_album.append(m_image[rand_val])
                    btn.bind(on_press=partial(song_btn, index, main_lyt))
                    index = index + 1
                    gridlayout.add_widget(btn)

        for i in range(index):
            img = Image(
                id='tn',
                source=cover_album[index - 1 - i],
                #            img = Image(id='tn',source='icon.png',
                size=(btn_inst[index - 1 - i].height * 0.8,
                      btn_inst[index - 1 - i].height * 0.8),
                pos=(btn_inst[index - 1 - i].width - main_box.width * 0.8,
                     (btn_inst[index - 1 - i].size[1] * i) +
                     (main_box.width * 0.5)),
                allow_stretch=False)
            btn_inst[index - 1 - i].add_widget(img)
            lbl = Label(
                text=str(songlist[index - 1 - i][0].split('/')[-1:][0]),
                text_size=(btn_inst[index - 1 - i].width * 7.5, None),
                halign='left',
                valign='middle',
                max_lines=1,
                shorten=True,
                shorten_from='right',
                color=(1, 1, 1, 1),
                pos=(img.pos[0] * 30,
                     (btn_inst[index - 1 - i].size[1] * i) + (main_box.width)))
            btn_inst[index - 1 - i].add_widget(lbl)

        scrollview = ScrollView()
        scrollview.add_widget(gridlayout)
        main_box.add_widget(scrollview)

        with self.menu1.canvas.before:
            Color(1, 1, 1, .8)
            self.menu1.rect1 = Rectangle(pos=self.menu1.pos,
                                         size=self.menu1.size)
            self.menu1.rect1.source = 'menu_image.jpg'

        with main_box.canvas.before:
            main_box.rect = Rectangle(pos=main_box.pos,
                                      size=np.array(Window.size))
            main_box.rect.source = 'image_1.jpg'


#

        def update_rect1(instance, value):
            instance.rect1.pos = instance.pos
            instance.rect1.size = instance.size

        def update_rect(instance, value):
            instance.rect.pos = instance.pos
            instance.rect.size = instance.size

        self.menu1.bind(pos=update_rect1, size=update_rect1)

        main_box.bind(pos=update_rect, size=update_rect)

        self.add_widget(main_box)
예제 #6
0
    def ui_layout(self, contact):
        self.contact = contact
        self.clear_widgets()

        layout = BoxLayout(orientation='vertical')
        scroll = ScrollView(do_scroll_x=False,
                            size_hint=(1, None),
                            size=(Window.width, Window.height))
        scroll_box = BoxLayout(orientation='vertical',
                               size_hint_y=None,
                               padding=(dp(12), dp(60)),
                               spacing=dp(5))
        scroll_box.bind(minimum_height=scroll_box.setter('height'))
        # Add more self.scrollbox.add_widget(MDLabel(text='')) to increase padding
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' ', size_hint=(1, 5)))

        if contact != '' and contact in self.util.user_data[
                'message_dict'].keys():
            for message in self.util.user_data['message_dict'][contact]:
                if self.util.username != message['sender']:
                    pos_hint = {'center_x': 0.3}
                    md_bg_color = [0.698, 0.875, 0.859, 1]
                    text_color = [0, 0, 0, 1]
                else:
                    pos_hint = {'center_x': 0.7}
                    md_bg_color = [1, 1, 1, 0.6]
                    text_color = [0, 0, 0, 1]
                message_label = MDLabel(text=message['message'],
                                        font_style='Caption',
                                        size_hint=(1, None))
                if '_' not in message_label.text:
                    self.util.morse.read(words=str(message_label.text))
                    message_label.text = self.util.morse.morse
                message_card = ConversationBubble(util=self.util,
                                                  size=message_label.size,
                                                  message=message_label,
                                                  pos_hint=pos_hint,
                                                  md_bg_color=md_bg_color,
                                                  text_color=text_color)
                scroll_box.add_widget(message_card)

        # This is disgusting but its late and I'm running out of time
        # keeps the text off of the text input
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))
        scroll_box.add_widget(MDLabel(text=' '))

        scroll.add_widget(scroll_box)
        layout.add_widget(scroll)

        self.text_input = MDTextFieldRound()
        # Hides left icon
        self.text_input.icon_left_dasabled = True
        # Moves widget out of the field of view
        self.text_input.children[2].children[2].pos_hint = {
            'center_x': 500,
            'center_y': 500
        }

        self.text_input.icon_right = 'send'
        self.text_input.children[2].children[0].bind(
            on_press=lambda x: self.send_message(self.text_input.text))

        self.long_press_btn = LongpressButton(text_input_cb=self.text_input_cb,
                                              size=(dp(50), dp(1)),
                                              size_hint=(3, None))

        input_box_horz = BoxLayout(orientation='horizontal')
        input_box_horz.add_widget(MDLabel(text='', size_hint=(0.05, None)))
        input_box_horz.add_widget(self.long_press_btn)
        input_box_horz.add_widget(MDLabel(text='', size_hint=(0.05, None)))

        text_input_anchor = AnchorLayout(anchor_x='center',
                                         anchor_y='bottom',
                                         padding=dp(65))
        text_input_anchor.add_widget(self.text_input)

        tap_input_anchor = AnchorLayout(anchor_x='center',
                                        anchor_y='bottom',
                                        size_hint=(1, 0.1),
                                        padding=dp(15))
        tap_input_anchor.add_widget(input_box_horz)

        toolbar_anchor = AnchorLayout(anchor_x='center', anchor_y='top')
        toolbar = MDToolbar(title=contact, anchor_title='center')
        toolbar.md_bg_color = App.get_running_app().theme_cls.primary_color
        toolbar.left_action_items = [[
            'arrow-left', lambda x: self.return_screen()
        ]]
        toolbar_anchor.add_widget(toolbar)

        self.add_widget(layout)
        self.add_widget(text_input_anchor)
        self.add_widget(tap_input_anchor)
        self.add_widget(toolbar_anchor)
        self.do_layout()
        scroll.scroll_y = 0
예제 #7
0
    def gotoTableView(self, stream, parent='', search=''):
        "Data records can be attatched to a post."
        self.currentPageNewRecordHandler = None
        self.streamEditPanel.clear_widgets()
        s = daemonconfig.userDatabases[stream]
        parentDoc = daemonconfig.userDatabases[stream].getDocumentByID(
            parent, allowOrphans=True)
        if not parentDoc:
            logging.error("nonexistent parent document")
            return
        themeColor = getColor(parentDoc)
        self.streamEditPanel.add_widget(self.makeBackButton())

        postWidget = self.makePostWidget(stream,
                                         parentDoc,
                                         indexAssumption=False)
        self.streamEditPanel.add_widget(postWidget)
        t = (MDToolbar(title="Data Table View"))

        if themeColor:
            t.md_bg_color = themeColor
            t.specific_text_color = getFGForColor(themeColor)

        self.streamEditPanel.add_widget(t)

        topbar = BoxLayout(orientation="horizontal",
                           spacing=10,
                           adaptive_height=True)

        searchBar = BoxLayout(orientation="horizontal",
                              spacing=10,
                              adaptive_height=True)

        searchQuery = MDTextField(size_hint=(0.68, None),
                                  multiline=False,
                                  text=search)
        searchButton = MDRoundFlatButton(text="Search")
        searchBar.add_widget(searchQuery)
        searchBar.add_widget(searchButton)

        def doSearch(*a):
            self.currentPageNewRecordHandler = None
            self.gotoTableView(stream, parent, searchQuery.text.strip())

        searchButton.bind(on_release=doSearch)

        def goHere():
            self.currentPageNewRecordHandler = None
            self.gotoTableView(stream, parent, search)

        self.backStack.append(goHere)
        self.backStack = self.backStack[-50:]

        newEntryBar = BoxLayout(orientation="horizontal",
                                spacing=10,
                                adaptive_height=True)

        newRowName = MDTextField(size_hint=(0.68, None),
                                 multiline=False,
                                 text=search)

        def write(*a):
            for i in newRowName.text:
                if i in "[]{}:,./\\":
                    return

            if newRowName.text.strip():
                id = uuid.uuid5(
                    uuid.UUID(parent),
                    newRowName.text.strip().lower().replace(' ', ""))
                #That name already exists, jump to it
                if daemonconfig.userDatabases[stream].getDocumentByID(
                        id, allowOrphans=True):
                    self.currentPageNewRecordHandler = None
                    self.gotoStreamRow(stream, id)
                    return
            else:
                id = str(uuid.uuid4())

            x = daemonconfig.userDatabases[stream].getDocumentsByType(
                "row.template", parent=parent, limit=1, allowOrphans=True)
            newDoc = {
                'parent': parent,
                'id': id,
                'name': newRowName.text.strip() or id,
                'type': 'row',
                'leafNode': True
            }

            #Use the previously created or modified row as the template
            for i in x:
                for j in i:
                    if j.startswith('row.'):
                        newDoc[j] = ''

            self.currentPageNewRecordHandler = None
            self.gotoStreamRow(stream, id, newDoc)

        btn1 = Button(text='New Entry')

        btn1.bind(on_press=write)
        newEntryBar.add_widget(newRowName)
        newEntryBar.add_widget(btn1)

        if s.writePassword:
            topbar.add_widget(newEntryBar)

        self.streamEditPanel.add_widget(topbar)

        if not search:
            p = s.getDocumentsByType("row",
                                     limit=1000,
                                     parent=parent,
                                     allowOrphans=True)
        else:
            p = s.searchDocuments(search, "row", limit=1000, parent=parent)

        t = MDToolbar(title="Data Rows")

        if themeColor:
            t.md_bg_color = themeColor
            t.specific_text_color = getFGForColor(themeColor)

        self.streamEditPanel.add_widget(t)
        self.streamEditPanel.add_widget(searchBar)

        for i in p:
            self.streamEditPanel.add_widget(self.makeRowWidget(stream, i))
        self.screenManager.current = "EditStream"

        def onNewRecord(db, r, sig):
            if db is daemonconfig.userDatabases[stream]:
                if r.get('parent', '') == parentDoc.get(
                        'parent', '') and r['type'] == "post":
                    if not self.unsavedDataCallback:
                        self.gotoStreamPost(stream, postID, noBack=True)

                elif parentDoc['id'] in r.get("parent", ''):
                    postWidget.body.text = renderPostTemplate(
                        daemonconfig.userDatabases[stream], parentDoc['id'],
                        parentDoc.get("body", ''))[0]

        self.currentPageNewRecordHandler = onNewRecord