mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-10 20:49:52 +00:00
Merge pull request #5162 from kpstar/master
android all currencies with history checkbox
This commit is contained in:
commit
9161d3a5a1
2 changed files with 34 additions and 10 deletions
|
@ -513,8 +513,8 @@ class FxThread(ThreadJob):
|
||||||
self.config.set_key('use_exchange_rate', bool(b))
|
self.config.set_key('use_exchange_rate', bool(b))
|
||||||
self.trigger_update()
|
self.trigger_update()
|
||||||
|
|
||||||
def get_history_config(self):
|
def get_history_config(self, *, default=False):
|
||||||
return bool(self.config.get('history_rates'))
|
return bool(self.config.get('history_rates', default))
|
||||||
|
|
||||||
def set_history_config(self, b):
|
def set_history_config(self, b):
|
||||||
self.config.set_key('history_rates', bool(b))
|
self.config.set_key('history_rates', bool(b))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivy.factory import Factory
|
from kivy.factory import Factory
|
||||||
from kivy.properties import ObjectProperty
|
from kivy.properties import ObjectProperty, BooleanProperty
|
||||||
from kivy.lang import Builder
|
from kivy.lang import Builder
|
||||||
|
|
||||||
Builder.load_string('''
|
Builder.load_string('''
|
||||||
|
@ -27,7 +27,20 @@ Builder.load_string('''
|
||||||
on_text: popup.on_currency(self.text)
|
on_text: popup.on_currency(self.text)
|
||||||
|
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, 0.1
|
size_hint: 1, 0.05
|
||||||
|
|
||||||
|
BoxLayout:
|
||||||
|
orientation: 'horizontal'
|
||||||
|
size_hint: 1, 0.2
|
||||||
|
Label:
|
||||||
|
text: _('History rates')
|
||||||
|
CheckBox:
|
||||||
|
id:hist
|
||||||
|
active: popup.has_history_rates
|
||||||
|
on_active: popup.on_checkbox_history(self.active)
|
||||||
|
|
||||||
|
Widget:
|
||||||
|
size_hint: 1, 0.05
|
||||||
|
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
|
@ -41,7 +54,7 @@ Builder.load_string('''
|
||||||
on_text: popup.on_exchange(self.text)
|
on_text: popup.on_exchange(self.text)
|
||||||
|
|
||||||
Widget:
|
Widget:
|
||||||
size_hint: 1, 0.2
|
size_hint: 1, 0.1
|
||||||
|
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'horizontal'
|
orientation: 'horizontal'
|
||||||
|
@ -72,17 +85,22 @@ from functools import partial
|
||||||
class FxDialog(Factory.Popup):
|
class FxDialog(Factory.Popup):
|
||||||
|
|
||||||
def __init__(self, app, plugins, config, callback):
|
def __init__(self, app, plugins, config, callback):
|
||||||
Factory.Popup.__init__(self)
|
|
||||||
self.app = app
|
self.app = app
|
||||||
self.config = config
|
self.config = config
|
||||||
self.callback = callback
|
self.callback = callback
|
||||||
self.fx = self.app.fx
|
self.fx = self.app.fx
|
||||||
self.fx.set_history_config(True)
|
self.has_history_rates = self.fx.get_history_config(default=True)
|
||||||
|
|
||||||
|
Factory.Popup.__init__(self)
|
||||||
self.add_currencies()
|
self.add_currencies()
|
||||||
|
|
||||||
def add_exchanges(self):
|
def add_exchanges(self):
|
||||||
exchanges = sorted(self.fx.get_exchanges_by_ccy(self.fx.get_currency(), True)) if self.fx.is_enabled() else []
|
if self.fx.is_enabled():
|
||||||
mx = self.fx.exchange.name() if self.fx.is_enabled() else ''
|
exchanges = sorted(self.fx.get_exchanges_by_ccy(self.fx.get_currency(), self.has_history_rates))
|
||||||
|
mx = self.fx.exchange.name()
|
||||||
|
else:
|
||||||
|
exchanges = []
|
||||||
|
mx = ''
|
||||||
ex = self.ids.exchanges
|
ex = self.ids.exchanges
|
||||||
ex.values = exchanges
|
ex.values = exchanges
|
||||||
ex.text = (mx if mx in exchanges else exchanges[0]) if self.fx.is_enabled() else ''
|
ex.text = (mx if mx in exchanges else exchanges[0]) if self.fx.is_enabled() else ''
|
||||||
|
@ -94,11 +112,17 @@ class FxDialog(Factory.Popup):
|
||||||
self.fx.set_exchange(text)
|
self.fx.set_exchange(text)
|
||||||
|
|
||||||
def add_currencies(self):
|
def add_currencies(self):
|
||||||
currencies = [_('None')] + self.fx.get_currencies(True)
|
currencies = [_('None')] + self.fx.get_currencies(self.has_history_rates)
|
||||||
my_ccy = self.fx.get_currency() if self.fx.is_enabled() else _('None')
|
my_ccy = self.fx.get_currency() if self.fx.is_enabled() else _('None')
|
||||||
self.ids.ccy.values = currencies
|
self.ids.ccy.values = currencies
|
||||||
self.ids.ccy.text = my_ccy
|
self.ids.ccy.text = my_ccy
|
||||||
|
|
||||||
|
def on_checkbox_history(self, checked):
|
||||||
|
self.fx.set_history_config(checked)
|
||||||
|
self.has_history_rates = checked
|
||||||
|
self.add_currencies()
|
||||||
|
self.on_currency(self.ids.ccy.text)
|
||||||
|
|
||||||
def on_currency(self, ccy):
|
def on_currency(self, ccy):
|
||||||
b = (ccy != _('None'))
|
b = (ccy != _('None'))
|
||||||
self.fx.set_enabled(b)
|
self.fx.set_enabled(b)
|
||||||
|
|
Loading…
Add table
Reference in a new issue