with qr codes in webviews
This commit is contained in:
parent
aa3ff22c19
commit
a4e2dc8ea6
|
@ -28,10 +28,6 @@ from decimal import Decimal
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
|
|
||||||
droid = android.Android()
|
|
||||||
wallet = Wallet()
|
|
||||||
wallet.set_path("/sdcard/electrum.dat")
|
|
||||||
wallet.read()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,11 +35,17 @@ wallet.read()
|
||||||
def select_from_contacts():
|
def select_from_contacts():
|
||||||
title = 'Contacts:'
|
title = 'Contacts:'
|
||||||
droid.dialogCreateAlert(title)
|
droid.dialogCreateAlert(title)
|
||||||
|
droid.dialogSetPositiveButtonText('New contact')
|
||||||
droid.dialogSetItems(wallet.addressbook)
|
droid.dialogSetItems(wallet.addressbook)
|
||||||
droid.dialogShow()
|
droid.dialogShow()
|
||||||
response = droid.dialogGetResponse()
|
response = droid.dialogGetResponse().result
|
||||||
result = response.result.get('item')
|
|
||||||
droid.dialogDismiss()
|
droid.dialogDismiss()
|
||||||
|
|
||||||
|
if response.get('which') == 'positive':
|
||||||
|
return 'newcontact'
|
||||||
|
|
||||||
|
result = response.get('item')
|
||||||
|
print result
|
||||||
if result is not None:
|
if result is not None:
|
||||||
addr = wallet.addressbook[result]
|
addr = wallet.addressbook[result]
|
||||||
return addr
|
return addr
|
||||||
|
@ -67,6 +69,38 @@ def select_from_addresses():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def qr_code_layout(addr):
|
||||||
|
return """<html>
|
||||||
|
<head>
|
||||||
|
<title>QR code</title>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
|
||||||
|
<script type="text/javascript" src="http://ecdsa.org/jquery.qrcode.min.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var address = '%s';
|
||||||
|
var droid = new Android();
|
||||||
|
var cb = function() {
|
||||||
|
droid.eventPost("main", "");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="qrcode"></div>
|
||||||
|
<div id="address"></div>
|
||||||
|
<script>
|
||||||
|
jQuery('#address').html("bitcoin:"+address);
|
||||||
|
jQuery('#qrcode').qrcode("bitcoin:"+address);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<form onsubmit="cb(); return false;">
|
||||||
|
<input type="submit" value="Exit" />
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>"""%addr
|
||||||
|
|
||||||
|
|
||||||
title = """
|
title = """
|
||||||
<TextView android:id="@+id/titleTextView"
|
<TextView android:id="@+id/titleTextView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -79,18 +113,36 @@ title = """
|
||||||
</TextView>
|
</TextView>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def main_layout():
|
def make_layout(s):
|
||||||
return """<?xml version="1.0" encoding="utf-8"?>
|
return """<?xml version="1.0" encoding="utf-8"?>
|
||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/background"
|
android:id="@+id/background"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="#ff000022">
|
android:background="#ff000022">
|
||||||
|
%s
|
||||||
|
%s
|
||||||
|
</LinearLayout>"""%(title,s)
|
||||||
|
|
||||||
|
|
||||||
|
def main_layout():
|
||||||
|
return """<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:background="#ff000022"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:id="@+id/background"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" >
|
||||||
|
|
||||||
%s
|
%s
|
||||||
|
|
||||||
|
@ -116,46 +168,12 @@ def main_layout():
|
||||||
|
|
||||||
%s
|
%s
|
||||||
|
|
||||||
<TableLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/linearLayout1">
|
|
||||||
<TableRow>
|
|
||||||
<Button android:id="@+id/buttonSend"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text=" Send ">
|
|
||||||
</Button>
|
|
||||||
<Button android:id="@+id/buttonReceive"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Receive">
|
|
||||||
</Button>
|
|
||||||
<Button android:id="@+id/buttonContacts"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Contacts">
|
|
||||||
</Button>
|
|
||||||
</TableRow>
|
|
||||||
</TableLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
</LinearLayout>
|
||||||
"""%(title, get_history_layout(15))
|
"""%(title, get_history_layout(15))
|
||||||
|
|
||||||
|
|
||||||
def make_layout(s):
|
|
||||||
return """<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/background"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="#ff000022">
|
|
||||||
%s
|
|
||||||
%s
|
|
||||||
</LinearLayout>"""%(title,s)
|
|
||||||
|
|
||||||
|
|
||||||
payto_layout = make_layout("""
|
payto_layout = make_layout("""
|
||||||
<TextView android:id="@+id/recipientTextView"
|
<TextView android:id="@+id/recipientTextView"
|
||||||
|
@ -177,9 +195,9 @@ payto_layout = make_layout("""
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<Button android:id="@+id/buttonQR" android:layout_width="wrap_content"
|
<Button android:id="@+id/buttonQR" android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" android:text="Scan QR"></Button>
|
android:layout_height="wrap_content" android:text="From QR code"></Button>
|
||||||
<Button android:id="@+id/buttonContacts" android:layout_width="wrap_content"
|
<Button android:id="@+id/buttonContacts" android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" android:text="Contacts"></Button>
|
android:layout_height="wrap_content" android:text="From Contacts"></Button>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,38 +233,27 @@ payto_layout = make_layout("""
|
||||||
android:layout_height="wrap_content" android:id="@+id/linearLayout1">
|
android:layout_height="wrap_content" android:id="@+id/linearLayout1">
|
||||||
<Button android:id="@+id/buttonPay" android:layout_width="wrap_content"
|
<Button android:id="@+id/buttonPay" android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" android:text="Send"></Button>
|
android:layout_height="wrap_content" android:text="Send"></Button>
|
||||||
<Button android:id="@+id/buttonCancelSend" android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" android:text="Cancel"></Button>
|
|
||||||
</LinearLayout>""")
|
</LinearLayout>""")
|
||||||
|
|
||||||
|
|
||||||
receive_layout = make_layout("""
|
|
||||||
<TextView android:id="@+id/receiveTextView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Addr"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
|
||||||
android:gravity="left">
|
|
||||||
</TextView>""")
|
|
||||||
|
|
||||||
contacts_layout = make_layout("""
|
settings_layout = make_layout("""
|
||||||
<TextView android:id="@+id/contactTextView"
|
|
||||||
|
<TextView android:id="@+id/feeTextView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Contacts"
|
android:text="Fee:"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||||
android:gravity="left">
|
android:gravity="left">
|
||||||
</TextView>
|
</TextView>
|
||||||
|
|
||||||
<TextView android:id="@+id/labelTextView"
|
<EditText android:id="@+id/fee"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Label:"
|
android:tag="Tag Me"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
android:inputType="numberDecimal">
|
||||||
android:gravity="left">
|
</EditText>
|
||||||
</TextView>""")
|
|
||||||
|
|
||||||
settings_layout = make_layout("""
|
|
||||||
<TextView android:id="@+id/serverTextView"
|
<TextView android:id="@+id/serverTextView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -258,18 +265,32 @@ settings_layout = make_layout("""
|
||||||
<EditText android:id="@+id/server"
|
<EditText android:id="@+id/server"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:tag="Tag Me" android:inputType="*">
|
android:tag="Tag Me"
|
||||||
|
android:inputType="textCapWords|textPhonetic|number">
|
||||||
</EditText>
|
</EditText>
|
||||||
|
|
||||||
<LinearLayout android:layout_width="match_parent"
|
<LinearLayout android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" android:id="@+id/linearLayout1">
|
android:layout_height="wrap_content"
|
||||||
<Button android:id="@+id/buttonServer" android:layout_width="wrap_content"
|
android:id="@+id/linearLayout1">
|
||||||
android:layout_height="wrap_content" android:text="Server List"></Button>
|
|
||||||
|
<Button android:id="@+id/buttonServer"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Public servers">
|
||||||
|
</Button>
|
||||||
|
<Button android:id="@+id/buttonProtocol"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Protocol">
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<Button android:id="@+id/buttonSave" android:layout_width="wrap_content"
|
<Button android:id="@+id/buttonSave" android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" android:text="Save"></Button>
|
android:layout_height="wrap_content" android:text="Save"></Button>
|
||||||
<Button android:id="@+id/buttonCancel" android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" android:text="Cancel"></Button>
|
""")
|
||||||
</LinearLayout>""")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -361,7 +382,7 @@ def set_history_layout(n):
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
first_time_update = True
|
|
||||||
|
|
||||||
def update_layout():
|
def update_layout():
|
||||||
|
|
||||||
|
@ -420,8 +441,7 @@ def pay_to(recipient, amount, fee, label):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def recover():
|
||||||
if not wallet.file_exists:
|
|
||||||
droid.dialogCreateAlert("wallet file not found")
|
droid.dialogCreateAlert("wallet file not found")
|
||||||
droid.dialogSetPositiveButtonText('OK')
|
droid.dialogSetPositiveButtonText('OK')
|
||||||
droid.dialogShow()
|
droid.dialogShow()
|
||||||
|
@ -463,55 +483,10 @@ if not wallet.file_exists:
|
||||||
else:
|
else:
|
||||||
droid.dialogCreateSpinnerProgress("wallet not found")
|
droid.dialogCreateSpinnerProgress("wallet not found")
|
||||||
droid.dialogShow()
|
droid.dialogShow()
|
||||||
exit(1)
|
|
||||||
|
|
||||||
else:
|
|
||||||
WalletSynchronizer(wallet,True).start()
|
|
||||||
|
|
||||||
|
|
||||||
def add_menu():
|
|
||||||
droid.addOptionsMenuItem("Network","settings",None,"")
|
|
||||||
droid.addOptionsMenuItem("New contact","newcontact",None,"")
|
|
||||||
droid.addOptionsMenuItem("Quit","quit",None,"")
|
|
||||||
|
|
||||||
add_menu()
|
def make_new_contact():
|
||||||
|
|
||||||
|
|
||||||
def main_loop():
|
|
||||||
droid.fullShow(main_layout())
|
|
||||||
update_layout()
|
|
||||||
out = None
|
|
||||||
while out is None:
|
|
||||||
|
|
||||||
event = droid.eventWait(1000).result # wait for 1 second
|
|
||||||
if not event:
|
|
||||||
update_layout()
|
|
||||||
continue
|
|
||||||
|
|
||||||
print "got event in main loop", event
|
|
||||||
|
|
||||||
if event["name"]=="click":
|
|
||||||
id=event["data"]["id"]
|
|
||||||
|
|
||||||
if id=="buttonSend":
|
|
||||||
out = 'payto'
|
|
||||||
|
|
||||||
if id=="buttonContacts":
|
|
||||||
global contact_addr
|
|
||||||
contact_addr = select_from_contacts()
|
|
||||||
if contact_addr:
|
|
||||||
out = 'contacts'
|
|
||||||
|
|
||||||
elif id=="buttonReceive":
|
|
||||||
global receive_addr
|
|
||||||
receive_addr = select_from_addresses()
|
|
||||||
if receive_addr:
|
|
||||||
out = 'receive'
|
|
||||||
|
|
||||||
elif event["name"]=="settings":
|
|
||||||
out = 'settings'
|
|
||||||
|
|
||||||
elif event["name"]=="newcontact":
|
|
||||||
code = droid.scanBarcode()
|
code = droid.scanBarcode()
|
||||||
r = code.result
|
r = code.result
|
||||||
if r:
|
if r:
|
||||||
|
@ -535,17 +510,51 @@ def main_loop():
|
||||||
response = droid.dialogGetResponse().result
|
response = droid.dialogGetResponse().result
|
||||||
droid.dialogDismiss()
|
droid.dialogDismiss()
|
||||||
|
|
||||||
|
|
||||||
|
def main_loop():
|
||||||
|
update_layout()
|
||||||
|
out = None
|
||||||
|
while out is None:
|
||||||
|
|
||||||
|
event = droid.eventWait(1000).result # wait for 1 second
|
||||||
|
if not event:
|
||||||
|
update_layout()
|
||||||
|
continue
|
||||||
|
|
||||||
|
print "got event in main loop", event
|
||||||
|
|
||||||
|
if event["name"]=="click":
|
||||||
|
id=event["data"]["id"]
|
||||||
|
|
||||||
|
elif event["name"]=="settings":
|
||||||
|
out = 'settings'
|
||||||
|
|
||||||
elif event["name"]=="key":
|
elif event["name"]=="key":
|
||||||
if event["data"]["key"] == '4':
|
if event["data"]["key"] == '4':
|
||||||
out = 'quit'
|
out = 'quit'
|
||||||
|
|
||||||
elif event["name"]=="quit":
|
elif event["name"] in menu_commands:
|
||||||
out = 'quit'
|
out = event["name"]
|
||||||
|
|
||||||
|
if out == 'contacts':
|
||||||
|
global contact_addr
|
||||||
|
contact_addr = select_from_contacts()
|
||||||
|
if contact_addr == 'newcontact':
|
||||||
|
make_new_contact()
|
||||||
|
contact_addr = None
|
||||||
|
if not contact_addr:
|
||||||
|
out = None
|
||||||
|
|
||||||
|
elif out == "receive":
|
||||||
|
global receive_addr
|
||||||
|
receive_addr = select_from_addresses()
|
||||||
|
if not receive_addr:
|
||||||
|
out = None
|
||||||
|
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def payto_loop():
|
def payto_loop():
|
||||||
droid.fullShow(payto_layout)
|
|
||||||
out = None
|
out = None
|
||||||
while out is None:
|
while out is None:
|
||||||
event = droid.eventWait().result
|
event = droid.eventWait().result
|
||||||
|
@ -584,14 +593,8 @@ def payto_loop():
|
||||||
if addr:
|
if addr:
|
||||||
droid.fullSetProperty("recipient","text",addr)
|
droid.fullSetProperty("recipient","text",addr)
|
||||||
|
|
||||||
elif id=="buttonCancelSend":
|
elif event["name"] in menu_commands:
|
||||||
out = 'main'
|
out = event["name"]
|
||||||
|
|
||||||
elif event["name"]=="settings":
|
|
||||||
out = 'settings'
|
|
||||||
|
|
||||||
elif event["name"]=="quit":
|
|
||||||
out = 'quit'
|
|
||||||
|
|
||||||
elif event["name"]=="key":
|
elif event["name"]=="key":
|
||||||
if event["data"]["key"] == '4':
|
if event["data"]["key"] == '4':
|
||||||
|
@ -609,39 +612,19 @@ contact_addr = ''
|
||||||
|
|
||||||
|
|
||||||
def receive_loop():
|
def receive_loop():
|
||||||
droid.fullShow(receive_layout)
|
|
||||||
droid.fullSetProperty("receiveTextView","text", receive_addr)
|
|
||||||
out = None
|
out = None
|
||||||
while out is None:
|
while out is None:
|
||||||
event = droid.eventWait().result
|
event = droid.eventWait().result
|
||||||
print "got event", event
|
print "got event", event
|
||||||
if event["name"] == "click":
|
|
||||||
|
|
||||||
if event["data"]["text"] == "OK":
|
|
||||||
out = 'main'
|
out = 'main'
|
||||||
|
|
||||||
elif event["name"]=="key":
|
|
||||||
if event["data"]["key"] == '4':
|
|
||||||
out = 'main'
|
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def contacts_loop():
|
def contacts_loop():
|
||||||
droid.fullShow(contacts_layout)
|
|
||||||
droid.fullSetProperty("contactTextView","text", contact_addr)
|
|
||||||
out = None
|
out = None
|
||||||
while out is None:
|
while out is None:
|
||||||
event = droid.eventWait().result
|
event = droid.eventWait().result
|
||||||
print "got event", event
|
print "got event", event
|
||||||
if event["name"] == "click":
|
|
||||||
|
|
||||||
if event["data"]["text"] == "OK":
|
|
||||||
out = 'main'
|
out = 'main'
|
||||||
|
|
||||||
elif event["name"]=="key":
|
|
||||||
if event["data"]["key"] == '4':
|
|
||||||
out = 'main'
|
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
@ -664,12 +647,13 @@ def protocol_dialog(plist):
|
||||||
|
|
||||||
|
|
||||||
def settings_loop():
|
def settings_loop():
|
||||||
droid.fullShow(settings_layout)
|
|
||||||
droid.fullSetProperty("server","text",wallet.server)
|
droid.fullSetProperty("server","text",wallet.server)
|
||||||
|
|
||||||
out = None
|
out = None
|
||||||
while out is None:
|
while out is None:
|
||||||
event = droid.eventWait().result
|
event = droid.eventWait().result
|
||||||
|
print "got event", event
|
||||||
|
|
||||||
if event["name"] == "click":
|
if event["name"] == "click":
|
||||||
|
|
||||||
id = event["data"]["id"]
|
id = event["data"]["id"]
|
||||||
|
@ -711,30 +695,80 @@ def settings_loop():
|
||||||
if event["data"]["key"] == '4':
|
if event["data"]["key"] == '4':
|
||||||
out = 'main'
|
out = 'main'
|
||||||
|
|
||||||
elif event["name"]=="quit":
|
elif event["name"] in menu_commands:
|
||||||
out = 'quit'
|
out = event["name"]
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
menu_commands = ["send", "receive", "settings", "contacts", "main"]
|
||||||
|
|
||||||
|
|
||||||
|
first_time_update = True
|
||||||
|
droid = android.Android()
|
||||||
|
wallet = Wallet()
|
||||||
|
|
||||||
|
wallet.set_path("/sdcard/electrum.dat")
|
||||||
|
wallet.read()
|
||||||
|
if not wallet.file_exists:
|
||||||
|
recover()
|
||||||
|
exit(1)
|
||||||
|
else:
|
||||||
|
WalletSynchronizer(wallet,True).start()
|
||||||
|
|
||||||
|
|
||||||
s = 'main'
|
s = 'main'
|
||||||
while True:
|
|
||||||
|
def add_menu(s):
|
||||||
|
droid.clearOptionsMenu()
|
||||||
if s == 'main':
|
if s == 'main':
|
||||||
s = main_loop()
|
droid.addOptionsMenuItem("Send","send",None,"")
|
||||||
elif s == 'payto':
|
droid.addOptionsMenuItem("Receive","receive",None,"")
|
||||||
s = payto_loop()
|
droid.addOptionsMenuItem("Contacts","contacts",None,"")
|
||||||
elif s == 'receive':
|
droid.addOptionsMenuItem("Settings","settings",None,"")
|
||||||
s = receive_loop()
|
|
||||||
elif s == 'contacts':
|
elif s == 'contacts':
|
||||||
s = contacts_loop()
|
droid.addOptionsMenuItem("Pay to","paytocontact",None,"")
|
||||||
|
droid.addOptionsMenuItem("Edit label","editcontact",None,"")
|
||||||
|
droid.addOptionsMenuItem("Delete","removecontact",None,"")
|
||||||
elif s == 'settings':
|
elif s == 'settings':
|
||||||
s = settings_loop()
|
droid.addOptionsMenuItem("Save","save",None,"")
|
||||||
|
droid.addOptionsMenuItem("Cancel","cancel",None,"")
|
||||||
|
|
||||||
|
|
||||||
|
#droid.addOptionsMenuItem("Quit","quit",None,"")
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
add_menu(s)
|
||||||
|
if s == 'main':
|
||||||
|
droid.fullShow(main_layout())
|
||||||
|
s = main_loop()
|
||||||
|
droid.fullDismiss()
|
||||||
|
elif s == 'send':
|
||||||
|
droid.fullShow(payto_layout)
|
||||||
|
s = payto_loop()
|
||||||
|
droid.fullDismiss()
|
||||||
|
|
||||||
|
elif s == 'receive':
|
||||||
|
f = open('/sdcard/sl4a/scripts/recv.html',"w")
|
||||||
|
f.write(qr_code_layout(receive_addr))
|
||||||
|
f.close()
|
||||||
|
droid.webViewShow("file:///sdcard/sl4a/scripts/recv.html?url=%s"%receive_addr,True)
|
||||||
|
s = receive_loop()
|
||||||
|
|
||||||
elif s == 'contacts':
|
elif s == 'contacts':
|
||||||
|
f = open('/sdcard/sl4a/scripts/recv.html',"w")
|
||||||
|
f.write(qr_code_layout(contact_addr))
|
||||||
|
f.close()
|
||||||
|
droid.webViewShow("file:///sdcard/sl4a/scripts/recv.html?url=%s"%contact_addr,True)
|
||||||
s = contacts_loop()
|
s = contacts_loop()
|
||||||
|
|
||||||
|
elif s == 'settings':
|
||||||
|
droid.fullShow(settings_layout)
|
||||||
|
s = settings_loop()
|
||||||
|
droid.fullDismiss()
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
|
|
||||||
droid.fullDismiss()
|
|
||||||
droid.makeToast("Bye!")
|
droid.makeToast("Bye!")
|
||||||
|
|
Loading…
Reference in New Issue