Browse Source

add protocol to settings

283
ThomasV 13 years ago
parent
commit
f034a5ed4a
  1. 36
      client/electrum4a.py

36
client/electrum4a.py

@ -37,8 +37,8 @@ def modal_dialog(title, msg = None):
droid.dialogGetResponse() droid.dialogGetResponse()
droid.dialogDismiss() droid.dialogDismiss()
def modal_input(title, msg, value = None): def modal_input(title, msg, value = None, etype=None):
droid.dialogCreateInput(title, msg, value) droid.dialogCreateInput(title, msg, value, etype)
droid.dialogSetPositiveButtonText('OK') droid.dialogSetPositiveButtonText('OK')
droid.dialogSetNegativeButtonText('Cancel') droid.dialogSetNegativeButtonText('Cancel')
droid.dialogShow() droid.dialogShow()
@ -114,17 +114,19 @@ def protocol_name(p):
if p == 'h': return 'HTTP/Stratum' if p == 'h': return 'HTTP/Stratum'
if p == 'n': return 'TCP/native' if p == 'n': return 'TCP/native'
def protocol_dialog(host, z): def protocol_dialog(host, protocol, z):
droid.dialogCreateAlert('Protocol',host) droid.dialogCreateAlert('Protocol',host)
protocols = z.keys() protocols = z.keys()
l = [] l = []
current = protocols.index(protocol)
for p in protocols: for p in protocols:
l.append(protocol_name(p)) l.append(protocol_name(p))
droid.dialogSetSingleChoiceItems(l) droid.dialogSetSingleChoiceItems(l, current)
droid.dialogSetPositiveButtonText('OK') droid.dialogSetPositiveButtonText('OK')
droid.dialogSetNegativeButtonText('Cancel') droid.dialogSetNegativeButtonText('Cancel')
droid.dialogShow() droid.dialogShow()
response = droid.dialogGetResponse().result response = droid.dialogGetResponse().result
if not response: return
if response.get('which') == 'positive': if response.get('which') == 'positive':
response = droid.dialogGetSelectedItems().result[0] response = droid.dialogGetSelectedItems().result[0]
droid.dialogDismiss() droid.dialogDismiss()
@ -780,7 +782,7 @@ def settings_loop():
is_encrypted = 'yes' if wallet.use_encryption else 'no' is_encrypted = 'yes' if wallet.use_encryption else 'no'
protocol = protocol_name(p) protocol = protocol_name(p)
droid.fullShow(settings_layout) droid.fullShow(settings_layout)
droid.fullSetList("myListView",['Server: ' + server, 'Protocol: '+ protocol, 'Fee: '+fee, 'Password: '+is_encrypted, 'Seed']) droid.fullSetList("myListView",['Server: ' + server, 'Port: '+port, 'Protocol: '+ protocol, 'Fee: '+fee, 'Password: '+is_encrypted, 'Seed'])
set_listview() set_listview()
@ -802,6 +804,7 @@ def settings_loop():
if event["name"] == "itemclick": if event["name"] == "itemclick":
pos = event["data"]["position"] pos = event["data"]["position"]
host, port, protocol = wallet.server.split(':')
if pos == "0": #server if pos == "0": #server
host = server_dialog(plist) host = server_dialog(plist)
@ -815,9 +818,20 @@ def settings_loop():
modal_dialog('error','invalid server') modal_dialog('error','invalid server')
set_listview() set_listview()
elif pos == "1": #protocol elif pos == "1": #port
a_port = modal_input('Port', 'port number', port, "number")
if a_port:
if a_port != port:
srv = host + ':' + a_port + ':t'
try:
wallet.set_server(srv)
except:
modal_dialog('error','invalid port number')
set_listview()
elif pos == "2": #protocol
if host in plist: if host in plist:
srv = protocol_dialog(host, plist[host]) srv = protocol_dialog(host, protocol, plist[host])
if srv: if srv:
try: try:
wallet.set_server(srv) wallet.set_server(srv)
@ -825,8 +839,8 @@ def settings_loop():
modal_dialog('error','invalid server') modal_dialog('error','invalid server')
set_listview() set_listview()
elif pos == "2": #fee elif pos == "3": #fee
fee = modal_input('fee', 'miners fee', str( Decimal( wallet.fee)/100000000 )) fee = modal_input('fee', 'miners fee', str( Decimal( wallet.fee)/100000000 ), "number")
if fee: if fee:
try: try:
fee = int( 100000000 * Decimal(fee) ) fee = int( 100000000 * Decimal(fee) )
@ -837,10 +851,10 @@ def settings_loop():
wallet.save() wallet.save()
set_listview() set_listview()
elif pos == "3": elif pos == "4":
change_password_dialog() change_password_dialog()
elif pos == "4": elif pos == "5":
seed_dialog() seed_dialog()

Loading…
Cancel
Save