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
=== modified file '3rdParty/libthrift/transport/TSSLSocket.cpp'
--- 3rdParty/libthrift/transport/TSSLSocket.cpp 2013-11-21 23:30:15 +0000
+++ 3rdParty/libthrift/transport/TSSLSocket.cpp 2014-10-24 13:44:56 +0000
@@ -143,9 +143,11 @@
143void TSSLSocket::close() {143void TSSLSocket::close() {
144 if (ssl_ != NULL) {144 if (ssl_ != NULL) {
145 int rc = SSL_shutdown(ssl_);145 int rc = SSL_shutdown(ssl_);
146 if (rc == 0) {146 // FIXME: this freezes the app when switching account, check if it's needed
147 rc = SSL_shutdown(ssl_);147 // when upgrade evernote sdk
148 }148// if (rc == 0) {
149// rc = SSL_shutdown(ssl_);
150// }
149 if (rc < 0) {151 if (rc < 0) {
150 int errno_copy = errno;152 int errno_copy = errno;
151 string errors;153 string errors;
152154
=== modified file 'src/app/qml/reminders.qml'
--- src/app/qml/reminders.qml 2014-10-10 14:15:04 +0000
+++ src/app/qml/reminders.qml 2014-10-24 13:44:56 +0000
@@ -57,11 +57,12 @@
57 property var accountPage;57 property var accountPage;
5858
59 function openAccountPage(isChangingAccount) {59 function openAccountPage(isChangingAccount) {
60 var unauthorizedAccounts = allAccounts.count - accounts.count > 0 ? true : false
60 if (accountPage) {61 if (accountPage) {
61 accountPage.destroy(100)62 accountPage.destroy(100)
62 }63 }
63 var component = Qt.createComponent(Qt.resolvedUrl("ui/AccountSelectorPage.qml"));64 var component = Qt.createComponent(Qt.resolvedUrl("ui/AccountSelectorPage.qml"));
64 accountPage = component.createObject(root, {accounts: accounts, isChangingAccount: isChangingAccount});65 accountPage = component.createObject(root, { accounts: allAccounts, isChangingAccount: isChangingAccount, unauthorizedAccounts: unauthorizedAccounts });
65 accountPage.accountSelected.connect(function(handle) { accountService.objectHandle = handle; pagestack.pop(); root.accountPage = null });66 accountPage.accountSelected.connect(function(handle) { accountService.objectHandle = handle; pagestack.pop(); root.accountPage = null });
66 pagestack.push(accountPage);67 pagestack.push(accountPage);
67 }68 }
@@ -134,6 +135,12 @@
134 applicationId: "com.ubuntu.reminders_reminders"135 applicationId: "com.ubuntu.reminders_reminders"
135 }136 }
136137
138 AccountServiceModel {
139 id: allAccounts
140 service: useSandbox ? "evernote-sandbox" : "evernote"
141 includeDisabled: true
142 }
143
137 AccountService {144 AccountService {
138 id: accountService145 id: accountService
139 onObjectHandleChanged: {146 onObjectHandleChanged: {
140147
=== modified file 'src/app/qml/ui/AccountSelectorPage.qml'
--- src/app/qml/ui/AccountSelectorPage.qml 2014-09-23 12:39:27 +0000
+++ src/app/qml/ui/AccountSelectorPage.qml 2014-10-24 13:44:56 +0000
@@ -28,8 +28,9 @@
28 objectName: "Accountselectorpage"28 objectName: "Accountselectorpage"
29 title: i18n.tr("Select Evernote account")29 title: i18n.tr("Select Evernote account")
3030
31 property alias accounts: listView.model31 property alias accounts: optionSelector.model
32 property bool isChangingAccount32 property bool isChangingAccount
33 property bool unauthorizedAccounts
3334
34 signal accountSelected(var handle)35 signal accountSelected(var handle)
3536
@@ -41,33 +42,54 @@
4142
42 Column {43 Column {
43 anchors { fill: parent; margins: units.gu(2) }44 anchors { fill: parent; margins: units.gu(2) }
44 spacing: units.gu(1)45 spacing: units.gu(2)
4546
46 ListView {47 OptionSelector {
47 id: listView48 id: optionSelector
48 width: parent.width49 width: parent.width
49 height: units.gu(10)50 expanded: true
50 model: accounts
51 currentIndex: -1
5251
53 delegate: Standard {52 delegate: Standard {
54 objectName: "EvernoteAccount"53 objectName: "EvernoteAccount"
55 text: displayName54 text: displayName
55 showDivider: index + 1 !== accounts.count
56
56 MouseArea {57 MouseArea {
57 anchors.fill: parent58 anchors.fill: parent
58 onClicked: root.accountSelected(accountServiceHandle)59 onClicked: {
59 }60 if (model.enabled) {
60 }61 root.accountSelected(accountServiceHandle)
6162 }
62 footer: Button {63 else {
63 text: i18n.tr("Add account")64 console.log('authorize')
64 onClicked: setup.exec()65 }
65 }66 }
66 }67 }
67 }68
6869 Component.onCompleted: {
69 tools: ToolbarItems {70 if (isChangingAccount && displayName == preferences.accountName) {
70 locked: !isChangingAccount71 optionSelector.selectedIndex = index;
71 opened: isChangingAccount72 }
72 }73 if (!model.enabled) {
74 text = i18n.tr("%1 - Tap to authorize").arg(text)
75 }
76 }
77 }
78 }
79
80 Button {
81 anchors.horizontalCenter: parent.horizontalCenter
82 width: parent.width - units.gu(2)
83 text: i18n.tr("Add new account")
84 color: UbuntuColors.orange
85 onClicked: setup.exec()
86 }
87 }
88
89 head.backAction: Action {
90 visible: isChangingAccount
91 iconName: "back"
92 text: i18n.tr("Back")
93 onTriggered: { pagestack.pop(); }
94 }
73}95}
7496
=== modified file 'src/app/qml/ui/NotebooksPage.qml'
--- src/app/qml/ui/NotebooksPage.qml 2014-09-23 12:39:27 +0000
+++ src/app/qml/ui/NotebooksPage.qml 2014-10-24 13:44:56 +0000
@@ -72,7 +72,7 @@
72 action: Action {72 action: Action {
73 text: i18n.tr("Accounts")73 text: i18n.tr("Accounts")
74 iconName: "contacts-app-symbolic"74 iconName: "contacts-app-symbolic"
75 visible: accounts.count > 175 visible: allAccounts.count > 1
76 onTriggered: {76 onTriggered: {
77 openAccountPage(true);77 openAccountPage(true);
78 }78 }
7979
=== modified file 'src/app/qml/ui/NotesPage.qml'
--- src/app/qml/ui/NotesPage.qml 2014-10-20 15:02:09 +0000
+++ src/app/qml/ui/NotesPage.qml 2014-10-24 13:44:56 +0000
@@ -97,7 +97,7 @@
97 action: Action {97 action: Action {
98 text: i18n.tr("Accounts")98 text: i18n.tr("Accounts")
99 iconName: "contacts-app-symbolic"99 iconName: "contacts-app-symbolic"
100 visible: accounts.count > 1100 visible: allAccounts.count > 1
101 onTriggered: {101 onTriggered: {
102 openAccountPage(true);102 openAccountPage(true);
103 }103 }
104104
=== modified file 'src/app/qml/ui/RemindersPage.qml'
--- src/app/qml/ui/RemindersPage.qml 2014-10-15 10:24:28 +0000
+++ src/app/qml/ui/RemindersPage.qml 2014-10-24 13:44:56 +0000
@@ -43,7 +43,7 @@
43 action: Action {43 action: Action {
44 text: i18n.tr("Accounts")44 text: i18n.tr("Accounts")
45 iconName: "contacts-app-symbolic"45 iconName: "contacts-app-symbolic"
46 visible: accounts.count > 146 visible: allAccounts.count > 1
47 onTriggered: {47 onTriggered: {
48 openAccountPage(true);48 openAccountPage(true);
49 }49 }
5050
=== modified file 'src/plugin/Evernote/evernoteconnection.cpp'
--- src/plugin/Evernote/evernoteconnection.cpp 2014-09-19 21:31:39 +0000
+++ src/plugin/Evernote/evernoteconnection.cpp 2014-10-24 13:44:56 +0000
@@ -169,6 +169,9 @@
169 m_token = token;169 m_token = token;
170 emit tokenChanged();170 emit tokenChanged();
171171
172 qDeleteAll(m_jobQueue);
173 m_jobQueue.clear();
174
172 connectToEvernote();175 connectToEvernote();
173 }176 }
174}177}
175178
=== modified file 'src/plugin/Evernote/notesstore.cpp'
--- src/plugin/Evernote/notesstore.cpp 2014-10-09 17:24:22 +0000
+++ src/plugin/Evernote/notesstore.cpp 2014-10-24 13:44:56 +0000
@@ -53,6 +53,7 @@
53 connect(EvernoteConnection::instance(), &EvernoteConnection::isConnectedChanged, this, &NotesStore::refreshNotebooks);53 connect(EvernoteConnection::instance(), &EvernoteConnection::isConnectedChanged, this, &NotesStore::refreshNotebooks);
54 connect(EvernoteConnection::instance(), SIGNAL(isConnectedChanged()), this, SLOT(refreshNotes()));54 connect(EvernoteConnection::instance(), SIGNAL(isConnectedChanged()), this, SLOT(refreshNotes()));
55 connect(EvernoteConnection::instance(), &EvernoteConnection::isConnectedChanged, this, &NotesStore::refreshTags);55 connect(EvernoteConnection::instance(), &EvernoteConnection::isConnectedChanged, this, &NotesStore::refreshTags);
56 connect(EvernoteConnection::instance(), &EvernoteConnection::tokenChanged, this, &NotesStore::clear);
5657
57 qRegisterMetaType<evernote::edam::NotesMetadataList>("evernote::edam::NotesMetadataList");58 qRegisterMetaType<evernote::edam::NotesMetadataList>("evernote::edam::NotesMetadataList");
58 qRegisterMetaType<evernote::edam::Note>("evernote::edam::Note");59 qRegisterMetaType<evernote::edam::Note>("evernote::edam::Note");
@@ -334,13 +335,7 @@
334void NotesStore::refreshNotes(const QString &filterNotebookGuid)335void NotesStore::refreshNotes(const QString &filterNotebookGuid)
335{336{
336 if (EvernoteConnection::instance()->token().isEmpty()) {337 if (EvernoteConnection::instance()->token().isEmpty()) {
337 beginResetModel();338 clear();
338 foreach (Note *note, m_notes) {
339 emit noteRemoved(note->guid(), note->notebookGuid());
340 note->deleteLater();
341 }
342 m_notes.clear();
343 endResetModel();
344 emit countChanged();339 emit countChanged();
345 } else {340 } else {
346 m_loading = true;341 m_loading = true;
@@ -782,3 +777,15 @@
782 int idx = m_notes.indexOf(note);777 int idx = m_notes.indexOf(note);
783 emit dataChanged(index(idx), index(idx));778 emit dataChanged(index(idx), index(idx));
784}779}
780
781void NotesStore::clear()
782{
783 beginResetModel();
784 foreach (Note *note, m_notes) {
785 emit noteRemoved(note->guid(), note->notebookGuid());
786 note->deleteLater();
787 }
788 m_notes.clear();
789 m_notesHash.clear();
790 endResetModel();
791}
785792
=== modified file 'src/plugin/Evernote/notesstore.h'
--- src/plugin/Evernote/notesstore.h 2014-10-09 00:08:52 +0000
+++ src/plugin/Evernote/notesstore.h 2014-10-24 13:44:56 +0000
@@ -162,6 +162,8 @@
162 void saveTagJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage);162 void saveTagJobDone(EvernoteConnection::ErrorCode errorCode, const QString &errorMessage);
163163
164 void emitDataChanged();164 void emitDataChanged();
165 void clear();
166
165private:167private:
166 explicit NotesStore(QObject *parent = 0);168 explicit NotesStore(QObject *parent = 0);
167 static NotesStore *s_instance;169 static NotesStore *s_instance;

Subscribers

People subscribed via source and target branches