Added changes for create new message feature for send button and cancel button

This commit is contained in:
surbhi 2018-07-24 18:12:53 +05:30
parent b0809c3c23
commit 8d5ff9abba
No known key found for this signature in database
GPG Key ID: 88928762974D3618
2 changed files with 84 additions and 10 deletions

View File

@ -175,12 +175,19 @@ BoxLayout:
size_hint: 1,2 size_hint: 1,2
Button: Button:
text: 'SEND' text: 'send'
size_hint_y: 0.1 size_hint_y: 0.1
size_hint_x: 0.3 size_hint_x: 0.2
height: '32dp' height: '32dp'
pos_hint: {'x': .5, 'y': 0.1} pos_hint: {'x': .5, 'y': 0.1}
on_press: root.send() on_press: root.send()
Button:
text: 'cancel'
size_hint_y: 0.1
size_hint_x: 0.2
height: '32dp'
pos_hint: {'x': .72, 'y': 0.1}
on_press: root.cancel()
<NewIdentity>: <NewIdentity>:
name: 'newidentity' name: 'newidentity'

View File

@ -1,5 +1,7 @@
import os import os
import time
import shutdown import shutdown
import queues
from kivy.app import App from kivy.app import App
from kivy.lang import Builder from kivy.lang import Builder
from kivy.uix.screenmanager import Screen from kivy.uix.screenmanager import Screen
@ -7,13 +9,16 @@ from kivy.properties import ObjectProperty, StringProperty
from kivymd.theming import ThemeManager from kivymd.theming import ThemeManager
from kivy.uix.widget import Widget from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout from kivy.uix.boxlayout import BoxLayout
from kivy.properties import BooleanProperty
from kivymd.toolbar import Toolbar from kivymd.toolbar import Toolbar
from navigationdrawer import NavigationDrawer from navigationdrawer import NavigationDrawer
from kivy.uix.label import Label from kivy.uix.label import Label
from kivy.uix.textinput import TextInput from kivy.uix.textinput import TextInput
from kivy.clock import Clock from kivy.clock import Clock
from bmconfigparser import BMConfigParser from bmconfigparser import BMConfigParser
from kivy.properties import BooleanProperty from helper_ackPayload import genAckPayload
from addresses import decodeAddress, addBMIfNotPresent
from helper_sql import sqlExecute
statusIconColor = 'red' statusIconColor = 'red'
@ -22,7 +27,8 @@ class NavigateApp(App, TextInput):
nav_drawer = ObjectProperty() nav_drawer = ObjectProperty()
def build(self): def build(self):
main_widget = Builder.load_file(os.path.join(os.path.dirname(__file__), 'main.kv')) main_widget = Builder.load_file(
os.path.join(os.path.dirname(__file__), 'main.kv'))
self.nav_drawer = Navigator() self.nav_drawer = Navigator()
return main_widget return main_widget
@ -44,7 +50,8 @@ class Inbox(Screen):
val_z = 0 val_z = 0
my_box1 = BoxLayout(orientation='vertical') my_box1 = BoxLayout(orientation='vertical')
for i in range(1, 5): for i in range(1, 5):
my_box1.add_widget(Label(text="I am in inbox", size_hint = (.3,.1), pos_hint = {'x': val_z,'top': val_y},color = (0,0,0,1), background_color = (0,0,0,0))) my_box1.add_widget(Label(text="I am in inbox", size_hint=(.3, .1), pos_hint={
'x': val_z, 'top': val_y}, color=(0, 0, 0, 1), background_color=(0, 0, 0, 0)))
val_y += .1 val_y += .1
self.add_widget(my_box1) self.add_widget(my_box1)
@ -56,7 +63,8 @@ class Sent(Screen):
val_z = 0 val_z = 0
my_box1 = BoxLayout(orientation='vertical') my_box1 = BoxLayout(orientation='vertical')
for i in range(1, 5): for i in range(1, 5):
my_box1.add_widget(Label(text="I am in sent", size_hint = (.3,.1), pos_hint = {'x': val_z,'top': val_y},color = (0,0,0,1), background_color = (0,0,0,0))) my_box1.add_widget(Label(text="I am in sent", size_hint=(.3, .1), pos_hint={
'x': val_z, 'top': val_y}, color=(0, 0, 0, 1), background_color=(0, 0, 0, 0)))
val_y += .1 val_y += .1
self.add_widget(my_box1) self.add_widget(my_box1)
@ -68,7 +76,8 @@ class Trash(Screen):
val_z = 0 val_z = 0
my_box1 = BoxLayout(orientation='vertical') my_box1 = BoxLayout(orientation='vertical')
for i in range(1, 5): for i in range(1, 5):
my_box1.add_widget(Label(text="I am in trash", size_hint = (.3,.1), pos_hint = {'x': val_z,'top': val_y},color = (0,0,0,1), background_color = (0,0,0,0))) my_box1.add_widget(Label(text="I am in trash", size_hint=(.3, .1), pos_hint={
'x': val_z, 'top': val_y}, color=(0, 0, 0, 1), background_color=(0, 0, 0, 0)))
val_y += .1 val_y += .1
self.add_widget(my_box1) self.add_widget(my_box1)
@ -95,11 +104,69 @@ class Create(Screen, Widget):
return BMConfigParser().addresses() return BMConfigParser().addresses()
def send(self): def send(self):
pass # toAddress = self.ids.recipent.text
fromAddress = self.ids.spinner_id.text
# For now we are using static address i.e we are not using recipent field value.
toAddress = "BM-2cWyUfBdY2FbgyuCb7abFZ49JYxSzUhNFe"
message = self.ids.message.text
subject = self.ids.subject.text
encoding = 3
print("message: ", self.ids.message.text)
sendMessageToPeople = True
if sendMessageToPeople:
if toAddress != '':
status, addressVersionNumber, streamNumber, ripe = decodeAddress(
toAddress)
if status == 'success':
toAddress = addBMIfNotPresent(toAddress)
if addressVersionNumber > 4 or addressVersionNumber <= 1:
print("addressVersionNumber > 4 or addressVersionNumber <= 1")
if streamNumber > 1 or streamNumber == 0:
print("streamNumber > 1 or streamNumber == 0")
if statusIconColor == 'red':
print("shared.statusIconColor == 'red'")
stealthLevel = BMConfigParser().safeGetInt(
'bitmessagesettings', 'ackstealthlevel')
ackdata = genAckPayload(streamNumber, stealthLevel)
t = ()
sqlExecute(
'''INSERT INTO sent VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)''',
'',
toAddress,
ripe,
fromAddress,
subject,
message,
ackdata,
int(time.time()),
int(time.time()),
0,
'msgqueued',
0,
'sent',
encoding,
BMConfigParser().getint('bitmessagesettings', 'ttl'))
toLabel = ''
queues.workerQueue.put(('sendmessage', toAddress))
print("sqlExecute successfully ##### ##################")
self.ids.message.text = ''
self.ids.spinner_id.text = '<select>'
self.ids.subject.text = ''
self.ids.recipent.text = ''
return None
def cancel(self):
self.ids.message.text = ''
self.ids.spinner_id.text = '<select>'
self.ids.subject.text = ''
self.ids.recipent.text = ''
return None
class NewIdentity(Screen): class NewIdentity(Screen):
is_active = BooleanProperty(False) is_active = BooleanProperty(False)
if __name__ == '__main__': if __name__ == '__main__':
NavigateApp().run() NavigateApp().run()