Merge lp:~mikemc/ubuntuone-credentials/faster-spinner into lp:ubuntuone-credentials

Proposed by Mike McCracken
Status: Merged
Approved by: Mike McCracken
Approved revision: 59
Merged at revision: 57
Proposed branch: lp:~mikemc/ubuntuone-credentials/faster-spinner
Merge into: lp:ubuntuone-credentials
Prerequisite: lp:~mikemc/ubuntuone-credentials/improve-fontsize-spacing
Diff against target: 81 lines (+33/-17)
2 files modified
online-accounts-provider/Main.qml (+16/-0)
online-accounts-provider/NewAccount.qml (+17/-17)
To merge this branch: bzr merge lp:~mikemc/ubuntuone-credentials/faster-spinner
Reviewer Review Type Date Requested Status
Diego Sarmentero (community) Approve
Roberto Alsina (community) Approve
Review via email: mp+183776@code.launchpad.net

Commit message

- Provide faster visual feedback of activity after clicking 'continue'

Description of the change

- Provide faster visual feedback of activity after clicking 'continue'

Use a timer to delay calling slow login/register functions until after the runloop shows the activity indicator.

TO TEST ON SAUCY desktop:
sudo apt-get build-dep ubuntuone-credentials
branch this , cd into it
mkdir build
cmake -DLIB_SUFFIX=/i386-linux-gnu -DCMAKE_INSTALL_PREFIX=/usr ..
sudo make install

run system-settings.
- click on "accounts" then "Add account", then "Ubuntu One"
try logging in to u1 with a bogus password/username. (make it valid enough to hit the server)
look for the spinner!
it should be in the middle and it should show up right away.

To post a comment you must log in.
Revision history for this message
Roberto Alsina (ralsina) :
review: Approve
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

You shouldn't do: width: parent.width, height: parent.height. In that case you should do: anchors.fill: parent, it's faster (for the loadingOverlay rectangle).

review: Needs Fixing
58. By Mike McCracken

use parent.visible as per suggestion of gatox.

Revision history for this message
Mike McCracken (mikemc) wrote :

My responses pasted from IRC yesterday :

changing the width/height to anchors.fill: parent causes the overlay to only fill the initial bounds of the
       UI. Once I swap in extra UI, the overlay's size isn't updated and it's
       too small.

about the suggestion to use onRunningChanged instead:

using onRunningChanged is problematic because the loadingoverlay can't
       see the function we want to call - it's in a different file that gets
       loaded in as a sibling of the loading overlay element

59. By Mike McCracken

remove unnecessary centerIn and add comment to make use of timer obvious

Revision history for this message
Mike McCracken (mikemc) wrote :

With the current code, using anchors.fill:parent instead of setting width and height directly doesn't work.

I'd like to land this branch as it is now and defer layout changes to the next branch, which will rework the layout and sizing code quite a bit, and does use anchors.fill:parent, which works with the other changes.

Re: Diego's suggestion from yesterday to use the onRunningChanged signal handler of the loading overlay to call submitFormFromTimer instead of using a timer: (as in lp:~diegosarmentero/+junk/uoa-spinner )
I'd rather stick with the timer, where I can have all the relevant code in the same place. I think moving the actual call to a separate file makes it harder to follow for maintainers, and I don't think anyone would naturally expect that just setting loadingOverlay.visible = true would also call the next function.

Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1 (I don't want to block, and you told me that this issues are going to be fixed in the next branch)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'online-accounts-provider/Main.qml'
2--- online-accounts-provider/Main.qml 2013-08-21 20:54:55 +0000
3+++ online-accounts-provider/Main.qml 2013-09-06 16:03:59 +0000
4@@ -47,4 +47,20 @@
5 onFinished: root.finished()
6 }
7 }
8+
9+ Rectangle {
10+ id: loadingOverlay
11+ opacity: 0.7
12+ color: "white"
13+ visible: false
14+ width: parent.width
15+ height: parent.height
16+
17+ ActivityIndicator {
18+ id: activity
19+ anchors.centerIn: parent
20+ running: parent.visible
21+ }
22+ }
23+
24 }
25
26=== modified file 'online-accounts-provider/NewAccount.qml'
27--- online-accounts-provider/NewAccount.qml 2013-09-03 22:14:05 +0000
28+++ online-accounts-provider/NewAccount.qml 2013-09-06 16:03:59 +0000
29@@ -124,22 +124,6 @@
30 anchors.margins: parent.anchors.margins
31 }
32
33- Rectangle {
34- id: loadingOverlay
35- opacity: 0.6
36- color: "white"
37- visible: false
38- width: main.width
39- height: main.height
40- //TODO: anchors.centerIn: main.parent
41-
42- ActivityIndicator {
43- id: activity
44- //TODO: anchors.centerIn: parent
45- running: true
46- }
47- }
48-
49 // -------------------------------------------------
50
51 UbuntuOneCredentialsService {
52@@ -196,12 +180,28 @@
53 }
54 }
55
56+ /* processForm uses a timer to delay calling u1credservice, which can
57+ take a while, to ensure that the loadingOverlay is shown
58+ immediately.
59+ */
60 function processForm() {
61+ loadingOverlay.visible = true;
62+ formSubmitTimer.running = true;
63+ }
64+
65+ Timer {
66+ id: formSubmitTimer;
67+ interval: 0;
68+ onTriggered: submitFormFromTimer();
69+ }
70+
71+ function submitFormFromTimer() {
72 validateInput();
73 if (!formValid) {
74+ loadingOverlay.visible = false;
75 return;
76 }
77- loadingOverlay.visible = true;
78+
79 if(state == "login") {
80 var password = loginForm.password;
81 u1credservice.login(emailTextField.text, password);

Subscribers

People subscribed via source and target branches

to all changes: