Merge lp:~rpadovani/reminders-app/multipleAccounts into lp:reminders-app

Proposed by Riccardo Padovani
Status: Merged
Approved by: Michael Zanetti
Approved revision: 267
Merged at revision: 291
Proposed branch: lp:~rpadovani/reminders-app/multipleAccounts
Merge into: lp:reminders-app
Diff against target: 249 lines (+79/-36)
9 files modified
3rdParty/libthrift/transport/TSSLSocket.cpp (+5/-3)
src/app/qml/reminders.qml (+8/-1)
src/app/qml/ui/AccountSelectorPage.qml (+44/-22)
src/app/qml/ui/NotebooksPage.qml (+1/-1)
src/app/qml/ui/NotesPage.qml (+1/-1)
src/app/qml/ui/RemindersPage.qml (+1/-1)
src/plugin/Evernote/evernoteconnection.cpp (+3/-0)
src/plugin/Evernote/notesstore.cpp (+14/-7)
src/plugin/Evernote/notesstore.h (+2/-0)
To merge this branch: bzr merge lp:~rpadovani/reminders-app/multipleAccounts
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
David Planella Needs Fixing
Review via email: mp+237682@code.launchpad.net

Commit message

Fixed change accounts page

Description of the change

Implemented new change accounts page as discussed during lasts meetings.

When you change account you don't see account name due https://bugs.launchpad.net/ubuntu-system-settings-online-accounts/+bug/1374432

For the same reason, autologin doesn't work

To post a comment you must log in.
Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
David Planella (dpm) wrote :

Thanks Riccardo!

After testing this on the emulator, I've observed a few things:

- Nice work with the Accounts action on the toolbar.
- Switching accounts seems to freeze the app. I'm not sure if it's an issue with the app or the emulator
- I added my first account with reminders, closed the app and the second one via System settings, and it then showed me a message about the account needing authorization. Functionally, this demonstrates that it works, but the placement of the message might be a bit confusing, as it seems it refers to the account I had already authorized. I would suggest to do the following changes:

http://i.imgur.com/ujy3RQ7.jpg

In summary, have an option selector, and when the unauthorized account is tapped, then the authorization dialog should pop up, rather than using the "Add account" for two different and unrelated purposes.

review: Needs Fixing
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Hey David,
thanks for your test and your suggestions.

So, I implemented the page as you suggested, but I have your same problem on Unity 7: when you choose an account, it freezes the app. I set this branch WIP until I understand what's going on.

Revision history for this message
David Planella (dpm) wrote :

So I've tested again on the emulator: switching accounts freezes the app. On a device with rtm image 81, it won't even add any accounts (*). Not sure what's going on, as with trunk adding accounts does work.

(*) when clicking to add an account, I get a full-screen blank page.

Revision history for this message
Riccardo Padovani (rpadovani) wrote :

I did last modifications to UI, I'm investigating on freeze

Revision history for this message
David Planella (dpm) wrote :

Thanks! The branch has now conflicts, so it needs merging trunk into it.

Also, if adding an UbuntuShape complicates the code, then we can perhaps leave it out. The reason I suggested it was because I thought we could use a standard OptionSelector. Would it not be possible at all?

review: Needs Fixing
Revision history for this message
Riccardo Padovani (rpadovani) wrote :

On Sun, Oct 12, 2014 at 06:24:38AM -0000, David Planella wrote:
>
> Review: Needs Fixing
>
> Thanks! The branch has now conflicts, so it needs merging trunk into it.

Thanks for the notice. I merged with trunk.

> Also, if adding an UbuntuShape complicates the code, then we can perhaps leave it out. The reason I suggested it was because I thought we could use a standard OptionSelector. Would it not be possible at all?

Well, you can see the code, do you think is too much complicate?
Anyway, there is no (simple? I think all is possible...) way to use
OptionSelector right now, because we need to add a different delegate for
unknown account.
So, ListView has property footer, and we can use that, but OptionSelector has
nothing like this, you can use only one type of delegate for all things in the
model.

Or we change our approach to the unknown account (like the first I had) and we
can use OptionSelector for the regular accounts, or this is the simplest way I
found to implement UbuntuShape.

Let me know!

Revision history for this message
David Planella (dpm) wrote :

After the conversation on IRC, if that makes things easier for the implementation, I'd suggest this new sketch http://i.imgur.com/zT8A3lo.jpg

The point is to separate the authorized from unauthorized accounts. I'm not too worried if the unauthorized accounts can be authorized individually in a list or if there is a single button to authorize them all in system settings.

Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Aha. I read the documentation and I found a way to implement your first mockup - only the UI for now, I'm working on the backend

Revision history for this message
Riccardo Padovani (rpadovani) wrote :

This is ready to be reviewed now

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

one inline comment

267. By Riccardo Padovani

Better implementation of a string

Revision history for this message
Riccardo Padovani (rpadovani) wrote :

Done

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

let's get this in. thanks

review: Approve
Revision history for this message
David Planella (dpm) wrote :

For some reason, when testing trunk I can't see any action to switch accounts.

Revision history for this message
Michael Zanetti (mzanetti) wrote :

Weird thing: It works fine on the desktop for me, but not on the phone. I think it's a difference in behavior of OA.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '3rdParty/libthrift/transport/TSSLSocket.cpp'
2--- 3rdParty/libthrift/transport/TSSLSocket.cpp 2013-11-21 23:30:15 +0000
3+++ 3rdParty/libthrift/transport/TSSLSocket.cpp 2014-10-24 13:44:56 +0000
4@@ -143,9 +143,11 @@
5 void TSSLSocket::close() {
6 if (ssl_ != NULL) {
7 int rc = SSL_shutdown(ssl_);
8- if (rc == 0) {
9- rc = SSL_shutdown(ssl_);
10- }
11+ // FIXME: this freezes the app when switching account, check if it's needed
12+ // when upgrade evernote sdk
13+// if (rc == 0) {
14+// rc = SSL_shutdown(ssl_);
15+// }
16 if (rc < 0) {
17 int errno_copy = errno;
18 string errors;
19
20=== modified file 'src/app/qml/reminders.qml'
21--- src/app/qml/reminders.qml 2014-10-10 14:15:04 +0000
22+++ src/app/qml/reminders.qml 2014-10-24 13:44:56 +0000
23@@ -57,11 +57,12 @@
24 property var accountPage;
25
26 function openAccountPage(isChangingAccount) {
27+ var unauthorizedAccounts = allAccounts.count - accounts.count > 0 ? true : false
28 if (accountPage) {
29 accountPage.destroy(100)
30 }
31 var component = Qt.createComponent(Qt.resolvedUrl("ui/AccountSelectorPage.qml"));
32- accountPage = component.createObject(root, {accounts: accounts, isChangingAccount: isChangingAccount});
33+ accountPage = component.createObject(root, { accounts: allAccounts, isChangingAccount: isChangingAccount, unauthorizedAccounts: unauthorizedAccounts });
34 accountPage.accountSelected.connect(function(handle) { accountService.objectHandle = handle; pagestack.pop(); root.accountPage = null });
35 pagestack.push(accountPage);
36 }
37@@ -134,6 +135,12 @@
38 applicationId: "com.ubuntu.reminders_reminders"
39 }
40
41+ AccountServiceModel {
42+ id: allAccounts
43+ service: useSandbox ? "evernote-sandbox" : "evernote"
44+ includeDisabled: true
45+ }
46+
47 AccountService {
48 id: accountService
49 onObjectHandleChanged: {
50
51=== modified file 'src/app/qml/ui/AccountSelectorPage.qml'
52--- src/app/qml/ui/AccountSelectorPage.qml 2014-09-23 12:39:27 +0000
53+++ src/app/qml/ui/AccountSelectorPage.qml 2014-10-24 13:44:56 +0000
54@@ -28,8 +28,9 @@
55 objectName: "Accountselectorpage"
56 title: i18n.tr("Select Evernote account")
57
58- property alias accounts: listView.model
59+ property alias accounts: optionSelector.model
60 property bool isChangingAccount
61+ property bool unauthorizedAccounts
62
63 signal accountSelected(var handle)
64
65@@ -41,33 +42,54 @@
66
67 Column {
68 anchors { fill: parent; margins: units.gu(2) }
69- spacing: units.gu(1)
70+ spacing: units.gu(2)
71
72- ListView {
73- id: listView
74+ OptionSelector {
75+ id: optionSelector
76 width: parent.width
77- height: units.gu(10)
78- model: accounts
79- currentIndex: -1
80+ expanded: true
81
82 delegate: Standard {
83 objectName: "EvernoteAccount"
84 text: displayName
85+ showDivider: index + 1 !== accounts.count
86+
87 MouseArea {
88 anchors.fill: parent
89- onClicked: root.accountSelected(accountServiceHandle)
90- }
91- }
92-
93- footer: Button {
94- text: i18n.tr("Add account")
95- onClicked: setup.exec()
96- }
97- }
98- }
99-
100- tools: ToolbarItems {
101- locked: !isChangingAccount
102- opened: isChangingAccount
103- }
104+ onClicked: {
105+ if (model.enabled) {
106+ root.accountSelected(accountServiceHandle)
107+ }
108+ else {
109+ console.log('authorize')
110+ }
111+ }
112+ }
113+
114+ Component.onCompleted: {
115+ if (isChangingAccount && displayName == preferences.accountName) {
116+ optionSelector.selectedIndex = index;
117+ }
118+ if (!model.enabled) {
119+ text = i18n.tr("%1 - Tap to authorize").arg(text)
120+ }
121+ }
122+ }
123+ }
124+
125+ Button {
126+ anchors.horizontalCenter: parent.horizontalCenter
127+ width: parent.width - units.gu(2)
128+ text: i18n.tr("Add new account")
129+ color: UbuntuColors.orange
130+ onClicked: setup.exec()
131+ }
132+ }
133+
134+ head.backAction: Action {
135+ visible: isChangingAccount
136+ iconName: "back"
137+ text: i18n.tr("Back")
138+ onTriggered: { pagestack.pop(); }
139+ }
140 }
141
142=== modified file 'src/app/qml/ui/NotebooksPage.qml'
143--- src/app/qml/ui/NotebooksPage.qml 2014-09-23 12:39:27 +0000
144+++ src/app/qml/ui/NotebooksPage.qml 2014-10-24 13:44:56 +0000
145@@ -72,7 +72,7 @@
146 action: Action {
147 text: i18n.tr("Accounts")
148 iconName: "contacts-app-symbolic"
149- visible: accounts.count > 1
150+ visible: allAccounts.count > 1
151 onTriggered: {
152 openAccountPage(true);
153 }
154
155=== modified file 'src/app/qml/ui/NotesPage.qml'
156--- src/app/qml/ui/NotesPage.qml 2014-10-20 15:02:09 +0000
157+++ src/app/qml/ui/NotesPage.qml 2014-10-24 13:44:56 +0000
158@@ -97,7 +97,7 @@
159 action: Action {
160 text: i18n.tr("Accounts")
161 iconName: "contacts-app-symbolic"
162- visible: accounts.count > 1
163+ visible: allAccounts.count > 1
164 onTriggered: {
165 openAccountPage(true);
166 }
167
168=== modified file 'src/app/qml/ui/RemindersPage.qml'
169--- src/app/qml/ui/RemindersPage.qml 2014-10-15 10:24:28 +0000
170+++ src/app/qml/ui/RemindersPage.qml 2014-10-24 13:44:56 +0000
171@@ -43,7 +43,7 @@
172 action: Action {
173 text: i18n.tr("Accounts")
174 iconName: "contacts-app-symbolic"
175- visible: accounts.count > 1
176+ visible: allAccounts.count > 1
177 onTriggered: {
178 openAccountPage(true);
179 }
180
181=== modified file 'src/plugin/Evernote/evernoteconnection.cpp'
182--- src/plugin/Evernote/evernoteconnection.cpp 2014-09-19 21:31:39 +0000
183+++ src/plugin/Evernote/evernoteconnection.cpp 2014-10-24 13:44:56 +0000
184@@ -169,6 +169,9 @@
185 m_token = token;
186 emit tokenChanged();
187
188+ qDeleteAll(m_jobQueue);
189+ m_jobQueue.clear();
190+
191 connectToEvernote();
192 }
193 }
194
195=== modified file 'src/plugin/Evernote/notesstore.cpp'
196--- src/plugin/Evernote/notesstore.cpp 2014-10-09 17:24:22 +0000
197+++ src/plugin/Evernote/notesstore.cpp 2014-10-24 13:44:56 +0000
198@@ -53,6 +53,7 @@
199 connect(EvernoteConnection::instance(), &EvernoteConnection::isConnectedChanged, this, &NotesStore::refreshNotebooks);
200 connect(EvernoteConnection::instance(), SIGNAL(isConnectedChanged()), this, SLOT(refreshNotes()));
201 connect(EvernoteConnection::instance(), &EvernoteConnection::isConnectedChanged, this, &NotesStore::refreshTags);
202+ connect(EvernoteConnection::instance(), &EvernoteConnection::tokenChanged, this, &NotesStore::clear);
203
204 qRegisterMetaType<evernote::edam::NotesMetadataList>("evernote::edam::NotesMetadataList");
205 qRegisterMetaType<evernote::edam::Note>("evernote::edam::Note");
206@@ -334,13 +335,7 @@
207 void NotesStore::refreshNotes(const QString &filterNotebookGuid)
208 {
209 if (EvernoteConnection::instance()->token().isEmpty()) {
210- beginResetModel();
211- foreach (Note *note, m_notes) {
212- emit noteRemoved(note->guid(), note->notebookGuid());
213- note->deleteLater();
214- }
215- m_notes.clear();
216- endResetModel();
217+ clear();
218 emit countChanged();
219 } else {
220 m_loading = true;
221@@ -782,3 +777,15 @@
222 int idx = m_notes.indexOf(note);
223 emit dataChanged(index(idx), index(idx));
224 }
225+
226+void NotesStore::clear()
227+{
228+ beginResetModel();
229+ foreach (Note *note, m_notes) {
230+ emit noteRemoved(note->guid(), note->notebookGuid());
231+ note->deleteLater();
232+ }
233+ m_notes.clear();
234+ m_notesHash.clear();
235+ endResetModel();
236+}
237
238=== modified file 'src/plugin/Evernote/notesstore.h'
239--- src/plugin/Evernote/notesstore.h 2014-10-09 00:08:52 +0000
240+++ src/plugin/Evernote/notesstore.h 2014-10-24 13:44:56 +0000
241@@ -162,6 +162,8 @@
242 void saveTagJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage);
243
244 void emitDataChanged();
245+ void clear();
246+
247 private:
248 explicit NotesStore(QObject *parent = 0);
249 static NotesStore *s_instance;

Subscribers

People subscribed via source and target branches