Skip to content
This repository was archived by the owner on Sep 1, 2021. It is now read-only.

Commit 4648b40

Browse files
committed
Fixes rounding display issue on Android
Bet size was showing very long float.
1 parent e6f2438 commit 4648b40

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

src/constants.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# default pyethapp keystore path
2+
KEYSTORE_DIR_SUFFIX = ".config/pyethapp/keystore/"
3+
ROUND_DIGITS = 1

src/etheroll.kv

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#:import Toolbar kivymd.toolbar.Toolbar
1111
#:import AddressButton addressbutton.AddressButton
1212
#:import RollResultsScreen roll_results.RollResultsScreen
13-
#:import ROUND_DIGITS etheroll.ROUND_DIGITS
13+
#:import ROUND_DIGITS constants.ROUND_DIGITS
1414

1515

1616
# need this hack to push widgets up

src/etheroll.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from raven.conf import setup_logging
2222
from raven.handlers.logging import SentryHandler
2323

24+
import constants
2425
from utils import (Dialog, SubScreen, patch_find_library_android,
2526
patch_typing_python351, run_in_thread)
2627
from version import __version__
@@ -31,10 +32,6 @@
3132
from ethereum_utils import AccountUtils # noqa: E402, isort:skip
3233
import pyetheroll # noqa: E402, isort:skip
3334

34-
# default pyethapp keystore path
35-
KEYSTORE_DIR_SUFFIX = ".config/pyethapp/keystore/"
36-
ROUND_DIGITS = 1
37-
3835

3936
class PasswordForm(BoxLayout):
4037
password = StringProperty()
@@ -329,7 +326,7 @@ def _after_init(self, dt):
329326

330327
@staticmethod
331328
def bind_slider_input(
332-
slider, inpt, cast_to=float, round_digits=ROUND_DIGITS):
329+
slider, inpt, cast_to=float, round_digits=constants.ROUND_DIGITS):
333330
"""
334331
Binds slider <-> input both ways.
335332
"""
@@ -356,7 +353,8 @@ def value(self):
356353
Returns normalized bet size value.
357354
"""
358355
try:
359-
return round(float(self.ids.bet_size_input_id.text), ROUND_DIGITS)
356+
return round(
357+
float(self.ids.bet_size_input_id.text), constants.ROUND_DIGITS)
360358
except ValueError:
361359
return 0
362360

@@ -490,7 +488,8 @@ def get_default_keystore_path():
490488
# uses kivy user_data_dir (/sdcard/<app_name>)
491489
if platform == "android":
492490
KEYSTORE_DIR_PREFIX = App.get_running_app().user_data_dir
493-
keystore_dir = os.path.join(KEYSTORE_DIR_PREFIX, KEYSTORE_DIR_SUFFIX)
491+
keystore_dir = os.path.join(
492+
KEYSTORE_DIR_PREFIX, constants.KEYSTORE_DIR_SUFFIX)
494493
return keystore_dir
495494

496495
def bind_wager_property(self):

src/roll_results.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from kivy.properties import ListProperty
44
from kivymd.list import TwoLineListItem
55

6+
import constants
67
from utils import SubScreen, load_kv_from_py, run_in_thread
78

89
load_kv_from_py(__file__)
@@ -51,8 +52,8 @@ def create_item_from_dict(roll_dict):
5152
"""
5253
bet_size_ether = roll_dict['bet_size_ether']
5354
roll_under = roll_dict['roll_under']
54-
text = 'roll under: {}, bet size: {} ETH'.format(
55-
roll_under, bet_size_ether)
55+
text = 'roll under: {0}, bet size: {1:.{2}f} ETH'.format(
56+
roll_under, bet_size_ether, constants.ROUND_DIGITS)
5657
secondary_text = text
5758
list_item = TwoLineListItem(
5859
text=text, secondary_text=secondary_text)

0 commit comments

Comments
 (0)