mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-27 15:31:31 +00:00
new settings layout using listview. do not use the logo to save space.
This commit is contained in:
parent
6329120847
commit
8b59bb85d4
1 changed files with 73 additions and 101 deletions
|
@ -109,14 +109,17 @@ def select_from_addresses():
|
||||||
return addr
|
return addr
|
||||||
|
|
||||||
|
|
||||||
|
def protocol_name(p):
|
||||||
|
if p == 't': return 'TCP/stratum'
|
||||||
|
if p == 'h': return 'HTTP/Stratum'
|
||||||
|
if p == 'n': return 'TCP/native'
|
||||||
|
|
||||||
def protocol_dialog(host, z):
|
def protocol_dialog(host, z):
|
||||||
droid.dialogCreateAlert('Protocol',host)
|
droid.dialogCreateAlert('Protocol',host)
|
||||||
protocols = z.keys()
|
protocols = z.keys()
|
||||||
l = []
|
l = []
|
||||||
for p in protocols:
|
for p in protocols:
|
||||||
if p == 't': l.append('TCP/stratum')
|
l.append(protocol_name(p))
|
||||||
if p == 'h': l.append('HTTP/Stratum')
|
|
||||||
if p == 'n': l.append('TCP/native')
|
|
||||||
droid.dialogSetSingleChoiceItems(l)
|
droid.dialogSetSingleChoiceItems(l)
|
||||||
droid.dialogSetPositiveButtonText('OK')
|
droid.dialogSetPositiveButtonText('OK')
|
||||||
droid.dialogSetNegativeButtonText('Cancel')
|
droid.dialogSetNegativeButtonText('Cancel')
|
||||||
|
@ -131,14 +134,26 @@ def protocol_dialog(host, z):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def make_layout(s, scrollable = False):
|
def make_layout(s, scrollable = False):
|
||||||
content = """
|
content = """
|
||||||
<ImageView
|
|
||||||
android:id="@+id/imageView1"
|
<LinearLayout
|
||||||
|
android:id="@+id/zz"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:gravity="center"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:src="file:///sdcard/sl4a/electrum_text_320.png" />
|
android:background="#ff222222">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textElectrum"
|
||||||
|
android:text="Electrum"
|
||||||
|
android:textSize="7pt"
|
||||||
|
android:textColor="#ff4444ff"
|
||||||
|
android:gravity="left"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
%s """%s
|
%s """%s
|
||||||
|
|
||||||
|
@ -292,59 +307,10 @@ payto_layout = make_layout("""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
settings_layout = make_layout("""
|
settings_layout = make_layout(""" <ListView
|
||||||
|
android:id="@+id/myListView"
|
||||||
<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" />""")
|
||||||
android:text="Server:"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
|
||||||
android:gravity="left">
|
|
||||||
</TextView>
|
|
||||||
|
|
||||||
<EditText android:id="@+id/server"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:tag="Tag Me"
|
|
||||||
android:inputType="text">
|
|
||||||
</EditText>
|
|
||||||
|
|
||||||
<LinearLayout android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/linearLayout1">
|
|
||||||
|
|
||||||
<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>
|
|
||||||
|
|
||||||
<TextView android:id="@+id/feeTextView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Fee:"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
|
||||||
android:gravity="left">
|
|
||||||
</TextView>
|
|
||||||
|
|
||||||
<EditText android:id="@+id/fee"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:tag="Tag Me"
|
|
||||||
android:inputType="numberDecimal">
|
|
||||||
</EditText>
|
|
||||||
|
|
||||||
<Button android:id="@+id/buttonSave" android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content" android:text="Save"></Button>
|
|
||||||
|
|
||||||
""",False)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -762,7 +728,7 @@ def server_dialog(plist):
|
||||||
|
|
||||||
def seed_dialog():
|
def seed_dialog():
|
||||||
if wallet.use_encryption:
|
if wallet.use_encryption:
|
||||||
password = droid.dialogGetPassword('Password').result
|
password = droid.dialogGetPassword('Seed').result
|
||||||
if not password: return
|
if not password: return
|
||||||
else:
|
else:
|
||||||
password = None
|
password = None
|
||||||
|
@ -807,13 +773,24 @@ def change_password_dialog():
|
||||||
|
|
||||||
|
|
||||||
def settings_loop():
|
def settings_loop():
|
||||||
droid.fullSetProperty("server","text",wallet.server)
|
|
||||||
droid.fullSetProperty("fee","text", "%s"% str( Decimal( wallet.fee)/100000000 ) )
|
|
||||||
|
def set_listview():
|
||||||
|
server, port, p = wallet.server.split(':')
|
||||||
|
fee = str( Decimal( wallet.fee)/100000000 )
|
||||||
|
is_encrypted = 'yes' if wallet.use_encryption else 'no'
|
||||||
|
protocol = protocol_name(p)
|
||||||
|
droid.fullShow(settings_layout)
|
||||||
|
droid.fullSetList("myListView",['server: ' + server, 'protocol: '+ protocol, 'fee: '+fee, 'password: '+is_encrypted, 'seed'])
|
||||||
|
|
||||||
|
set_listview()
|
||||||
|
|
||||||
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 == 'OK': continue
|
||||||
|
if not event: continue
|
||||||
|
|
||||||
plist = {}
|
plist = {}
|
||||||
for item in wallet.interface.servers:
|
for item in wallet.interface.servers:
|
||||||
|
@ -824,55 +801,53 @@ def settings_loop():
|
||||||
z[protocol] = port
|
z[protocol] = port
|
||||||
plist[host] = z
|
plist[host] = z
|
||||||
|
|
||||||
|
if event["name"] == "itemclick":
|
||||||
|
pos = event["data"]["position"]
|
||||||
|
|
||||||
if event["name"] == "click":
|
if pos == "0": #server
|
||||||
id = event["data"]["id"]
|
|
||||||
|
|
||||||
if id=="buttonServer":
|
|
||||||
host = server_dialog(plist)
|
host = server_dialog(plist)
|
||||||
if host:
|
if host:
|
||||||
p = plist[host]
|
p = plist[host]
|
||||||
port = p['t']
|
port = p['t']
|
||||||
srv = host + ':' + port + ':t'
|
srv = host + ':' + port + ':t'
|
||||||
droid.fullSetProperty("server","text",srv)
|
|
||||||
|
|
||||||
elif id=="buttonProtocol":
|
|
||||||
droid.fullQuery()
|
|
||||||
srv = droid.fullQueryDetail("server").result.get('text')
|
|
||||||
host = srv.split(':')[0]
|
|
||||||
if host in plist:
|
|
||||||
server = protocol_dialog(host, plist[host])
|
|
||||||
if server:
|
|
||||||
droid.fullSetProperty("server","text",server)
|
|
||||||
|
|
||||||
|
|
||||||
elif id=="buttonSave":
|
|
||||||
droid.fullQuery()
|
|
||||||
srv = droid.fullQueryDetail("server").result.get('text')
|
|
||||||
fee = droid.fullQueryDetail("fee").result.get('text')
|
|
||||||
try:
|
try:
|
||||||
wallet.set_server(srv)
|
wallet.set_server(srv)
|
||||||
except:
|
except:
|
||||||
modal_dialog('error','invalid server')
|
modal_dialog('error','invalid server')
|
||||||
|
set_listview()
|
||||||
|
|
||||||
|
elif pos == "1": #protocol
|
||||||
|
if host in plist:
|
||||||
|
srv = protocol_dialog(host, plist[host])
|
||||||
|
if srv:
|
||||||
|
try:
|
||||||
|
wallet.set_server(srv)
|
||||||
|
except:
|
||||||
|
modal_dialog('error','invalid server')
|
||||||
|
set_listview()
|
||||||
|
|
||||||
|
elif pos == "2": #fee
|
||||||
|
fee = modal_input('fee', 'miners fee', str( Decimal( wallet.fee)/100000000 ))
|
||||||
|
if fee:
|
||||||
try:
|
try:
|
||||||
fee = int( 100000000 * Decimal(fee) )
|
fee = int( 100000000 * Decimal(fee) )
|
||||||
|
except:
|
||||||
|
modal_dialog('error','invalid fee value')
|
||||||
if wallet.fee != fee:
|
if wallet.fee != fee:
|
||||||
wallet.fee = fee
|
wallet.fee = fee
|
||||||
wallet.save()
|
wallet.save()
|
||||||
out = 'main'
|
set_listview()
|
||||||
except:
|
|
||||||
modal_dialog('error','invalid fee value')
|
elif pos == "3":
|
||||||
|
change_password_dialog()
|
||||||
|
|
||||||
|
elif pos == "4":
|
||||||
|
seed_dialog()
|
||||||
|
|
||||||
|
|
||||||
elif event["name"] in menu_commands:
|
elif event["name"] in menu_commands:
|
||||||
out = event["name"]
|
out = event["name"]
|
||||||
|
|
||||||
elif event["name"] == 'password':
|
|
||||||
change_password_dialog()
|
|
||||||
|
|
||||||
elif event["name"] == 'seed':
|
|
||||||
seed_dialog()
|
|
||||||
|
|
||||||
elif event["name"] == 'cancel':
|
elif event["name"] == 'cancel':
|
||||||
out = 'main'
|
out = 'main'
|
||||||
|
|
||||||
|
@ -914,9 +889,6 @@ def add_menu(s):
|
||||||
droid.addOptionsMenuItem("Label","edit",None,"")
|
droid.addOptionsMenuItem("Label","edit",None,"")
|
||||||
droid.addOptionsMenuItem("Pay to","paytocontact",None,"")
|
droid.addOptionsMenuItem("Pay to","paytocontact",None,"")
|
||||||
#droid.addOptionsMenuItem("Delete","deletecontact",None,"")
|
#droid.addOptionsMenuItem("Delete","deletecontact",None,"")
|
||||||
elif s == 'settings':
|
|
||||||
droid.addOptionsMenuItem("Password","password",None,"")
|
|
||||||
droid.addOptionsMenuItem("Seed","seed",None,"")
|
|
||||||
|
|
||||||
def make_bitmap(addr):
|
def make_bitmap(addr):
|
||||||
# fixme: this is highly inefficient
|
# fixme: this is highly inefficient
|
||||||
|
@ -971,7 +943,7 @@ while True:
|
||||||
s = contacts_loop()
|
s = contacts_loop()
|
||||||
|
|
||||||
elif s == 'settings':
|
elif s == 'settings':
|
||||||
droid.fullShow(settings_layout)
|
#droid.fullShow(settings_layout)
|
||||||
s = settings_loop()
|
s = settings_loop()
|
||||||
#droid.fullDismiss()
|
#droid.fullDismiss()
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue