Skip to content

Commit

Permalink
Fix laggy sidebar animations, fixes #122
Browse files Browse the repository at this point in the history
The idea is to let the application render before trying to add
child widget.
  • Loading branch information
AndreMiras committed Dec 5, 2017
1 parent fddb69f commit b514479
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
2 changes: 2 additions & 0 deletions root/etc/udev/rules.d/51-android.rules
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# https://developer.android.com/studio/run/device.html
# copy to:
# /etc/udev/rules.d/
# then:
# sudo systemctl restart udev
# Huawei (12d1)
SUBSYSTEM=="usb", ATTR{idVendor}=="12d1", MODE="0666", GROUP="plugdev"
# Samsung (04e8)
Expand Down
7 changes: 4 additions & 3 deletions src/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

## [Unreleased]

- Fix back to home on empty account, fixes #115
- Handle UnknownEtherscanException gracefully, fixes #112
- Fix crash on delete last account, fixes #120
- Fix back to home on empty account, refs #115
- Handle UnknownEtherscanException gracefully, refs #112
- Fix crash on delete last account, refs #120
- Fix laggy sidebar animations, refs #122

## [v20171126]

Expand Down
35 changes: 31 additions & 4 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@

kivy.require('1.10.0')

# Time before loading the next screen.
# The idea is to let the application render before trying to add child widget,
# refs #122.
SCREEN_SWITCH_DELAY = 0.4


def run_in_thread(fn):
"""
Expand Down Expand Up @@ -1429,7 +1434,12 @@ def load_landing_page(self):
try:
# will trigger account data fetching
self.current_account = self.pywalib.get_main_account()
self.screen_manager_current('overview')
if SCREEN_SWITCH_DELAY:
Clock.schedule_once(
lambda dt: self.screen_manager_current('overview'),
SCREEN_SWITCH_DELAY)
else:
self.screen_manager_current('overview')
except IndexError:
self.load_create_new_account()

Expand Down Expand Up @@ -1539,20 +1549,35 @@ def load_switch_account(self):
Loads the switch account screen.
"""
# loads the switch account screen
self.screen_manager_current('switch_account', direction='left')
Clock.schedule_once(
lambda dt: self.screen_manager_current(
'switch_account', direction='left'),
SCREEN_SWITCH_DELAY)

def load_manage_keystores(self):
"""
Loads the manage keystores screen.
"""
# loads the manage keystores screen
self.screen_manager_current('manage_keystores', direction='left')
if SCREEN_SWITCH_DELAY:
Clock.schedule_once(
lambda dt: self.screen_manager_current(
'manage_keystores', direction='left'),
SCREEN_SWITCH_DELAY)
else:
self.screen_manager_current(
'manage_keystores', direction='left')

def load_create_new_account(self):
"""
Loads the create new account tab from the manage keystores screen.
"""
# we need the screen now
global SCREEN_SWITCH_DELAY
saved_delay = SCREEN_SWITCH_DELAY
SCREEN_SWITCH_DELAY = None
self.load_manage_keystores()
SCREEN_SWITCH_DELAY = saved_delay
# loads the create new account tab
manage_keystores = self.manage_keystores
create_new_account_nav_item = \
Expand All @@ -1573,7 +1598,9 @@ def load_about_screen(self):
"""
Loads the about screen.
"""
self.screen_manager_current('about', direction='left')
Clock.schedule_once(
lambda dt: self.screen_manager_current('about', direction='left'),
SCREEN_SWITCH_DELAY)


class DebugRavenClient(object):
Expand Down
9 changes: 9 additions & 0 deletions src/tests/ui/test_ui_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def advance_frames(self, count):
for i in range(count):
EventLoop.idle()

def helper_setup(self, app):
main.SCREEN_SWITCH_DELAY = 0.001

def helper_test_empty_account(self, app):
"""
Verifies the UI behaves as expected on empty account list.
Expand Down Expand Up @@ -130,13 +133,16 @@ def helper_test_create_first_account(self, app):
# self.assertEqual(new_password1_id.text, '')
# self.assertEqual(new_password2_id.text, '')
# we should get redirected to the overview page
self.advance_frames(1)
self.assertEqual(controller.screen_manager.current, 'overview')
# the new account should be loaded in the controller
self.assertEqual(
controller.current_account,
pywalib.get_account_list()[0])
# TODO: also verify the Toolbar title was updated correctly
# self.assertEqual('TODO', app.controller.toolbar.title)
# joins ongoing threads
[t.join() for t in threading.enumerate()[1:]]
# check the redirect dialog
dialogs = controller.dialogs
self.assertEqual(len(dialogs), 1)
Expand Down Expand Up @@ -242,6 +248,7 @@ def helper_load_switch_account(self, app):
controller = app.controller
# TODO: use dispatch('on_release') on navigation drawer
controller.load_switch_account()
self.advance_frames(1)
switch_account = controller.switch_account
self.assertEqual(switch_account.__class__, main.SwitchAccount)
return switch_account
Expand Down Expand Up @@ -324,6 +331,7 @@ def helper_test_delete_account(self, app):
# go to the manage account screen
# TODO: use dispatch('on_release') on navigation drawer
controller.load_manage_keystores()
self.advance_frames(1)
self.assertEqual('Manage existing', app.controller.toolbar.title)
# verifies an account is showing
manage_existing = controller.manage_existing
Expand Down Expand Up @@ -567,6 +575,7 @@ def helper_test_delete_last_account(self, app):
# main test function
def run_test(self, app, *args):
Clock.schedule_interval(self.pause, 0.000001)
self.helper_setup(app)
self.helper_test_empty_account(app)
self.helper_test_back_home_empty_account(app)
self.helper_test_create_first_account(app)
Expand Down

0 comments on commit b514479

Please sign in to comment.