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

Proposed by Riccardo Padovani
Status: Merged
Approved by: David Planella
Approved revision: 175
Merged at revision: 184
Proposed branch: lp:~rpadovani/reminders-app/upgradeToOxide
Merge into: lp:reminders-app
Diff against target: 149 lines (+54/-46)
4 files modified
apparmor.json (+2/-1)
src/app/qml/reminders.qml (+2/-1)
src/app/qml/ui/NoteView.qml (+49/-43)
src/app/qml/ui/reminders-scripts.js (+1/-1)
To merge this branch: bzr merge lp:~rpadovani/reminders-app/upgradeToOxide
Reviewer Review Type Date Requested Status
David Planella Approve
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve
Review via email: mp+225737@code.launchpad.net

Commit message

Upgraded the WebView to Oxide

Description of the change

All works now, thanks oSoMoN!

===

I updated the NoteView to Oxide, but I have few notes:

- I used com.canonical.Oxide 1.0 instead of Ubuntu.Web 0.2 because I need UserScript and WebContextDelegateWorker types, that there aren't in Ubuntu.Web
- I'm not sure about onMessage new implementation. seems it works but have a double-check, please
- I removed the Flickable because I was not able to reproduce the wrong behavior there was with old WebView
- After this update, the app will not work on trusty, because Oxide is old on trusty. I needed to upgrade to Utopic (seems stable, btw)

Needs to find a workaround to https://bugs.launchpad.net/oxide/+bug/1338639

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
Riccardo Padovani (rpadovani) wrote :

I put this on hold because there is a segmentation fault in phone mode when you try to view a note: http://paste.ubuntu.com/7760088/

I'll talk to oSoMoN asap

Revision history for this message
Olivier Tilloy (osomon) wrote :

I investigated bug #1338639 and commented on my findings there, including a workaround until the bug is properly fixed in oxide.

Revision history for this message
Olivier Tilloy (osomon) wrote :

31 +// FIXME: we need com.canonical.Oxide to have UserScript type available and
32 +// WebContextDelegateWorker to intercette messages. As
33 +// soon as this will be implemented also in Ubuntu.Web we will switch to last
34 +// one
35 +import com.canonical.Oxide 1.0

UserScript and WebContextDelegateWorker will probably never be exposed through the Ubuntu.Web API (at least not in the foreseeable future), which is intended as a simple API for application developers to display web content. For advanced functionality like this, it’s fine to use oxide directly (although it’s not publicly advertised and documented). So this comment can be removed.

Revision history for this message
Olivier Tilloy (osomon) wrote :

I don’t think the use of a WebContextDelegateWorker is correct here. If I understand the intent correctly, you want to:

 - remove that WebContextDelegateWorker
 - update the reminders-scripts.js script to use oxide.sendMessage(…) instead of navigator.qt.postMessage(…)
 - add an Oxide.ScriptMessageHandler to the messageHandlers property of the webview to handle the message sent above

See http://bazaar.launchpad.net/~oxide-developers/oxide/oxide.trunk/view/head:/qt/tests/qmltests/api/tst_ScriptMessage.qml for a complete example of how user scripts work in oxide.

Revision history for this message
Olivier Tilloy (osomon) wrote :

> After this update, the app will not work on trusty, because Oxide is
> old on trusty. I needed to upgrade to Utopic (seems stable, btw)

Note that oxide 1.0.2 will soon be backported to trusty via the trusty-security channel.

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 :

For this to run on the emulator or on a device, it needs the "webview" policy added to apparmor.json

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

After testing this branch on the emulator:

- The single note views with plain text work well
- The font in general appears to be really small
- RTM notes are displayed as expected
- Image attachments are displayed as expected
- TODO checklists seem to no longer work

172. By Riccardo Padovani

Set a minimum font size

173. By Riccardo Padovani

Added webview to apparmor.json

Revision history for this message
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
174. By Riccardo Padovani

Updated UserScript to work. Thanks to oSoMoN

175. By Riccardo Padovani

Removed unused try/catch

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 :

As per the discussion in the meeting yesterday, and after checking out that the trusty PPA daily updates are disabled (*), I'll top-approve this MP.

(*) we can reenable them once Oxide 1.0.2 is backported to Trusty

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'apparmor.json'
2--- apparmor.json 2014-07-14 07:38:42 +0000
3+++ apparmor.json 2014-07-14 15:44:46 +0000
4@@ -3,7 +3,8 @@
5 "networking",
6 "accounts",
7 "content_exchange",
8- "audio"
9+ "audio",
10+ "webview"
11 ],
12 "policy_version": 1.2
13 }
14\ No newline at end of file
15
16=== modified file 'src/app/qml/reminders.qml'
17--- src/app/qml/reminders.qml 2014-07-03 07:50:06 +0000
18+++ src/app/qml/reminders.qml 2014-07-14 15:44:46 +0000
19@@ -76,7 +76,8 @@
20 if (root.narrowMode) {
21 print("creating noteview");
22 var component = Qt.createComponent(Qt.resolvedUrl("ui/NotePage.qml"));
23- var page = component.createObject(root, {note: note});
24+ var page = component.createObject(root);
25+ page.note = note;
26 page.editNote.connect(function(note) {root.switchToEditMode(note)})
27 pagestack.push(page)
28 } else {
29
30=== modified file 'src/app/qml/ui/NoteView.qml'
31--- src/app/qml/ui/NoteView.qml 2014-05-09 14:57:31 +0000
32+++ src/app/qml/ui/NoteView.qml 2014-07-14 15:44:46 +0000
33@@ -18,7 +18,7 @@
34
35 import QtQuick 2.0
36 import Ubuntu.Components 0.1
37-import Ubuntu.Components.Extras.Browser 0.1
38+import com.canonical.Oxide 1.0
39 import Evernote 0.1
40 import "../components"
41
42@@ -40,47 +40,53 @@
43 visible: running
44 }
45
46- // FIXME: This is a workaround for an issue in the WebView. For some reason certain
47- // documents cause a binding loop in the webview's contentHeight. Wrapping it inside
48- // another flickable prevents this from happening.
49- Flickable {
50- anchors { fill: parent }
51- contentHeight: height
52-
53- UbuntuWebView {
54- id: noteTextArea
55- anchors { fill: parent}
56- property string html: note.htmlContent
57- onHtmlChanged: {
58- loadHtml(html, "file:///")
59- }
60-
61- Connections {
62- target: note
63- onResourcesChanged: {
64- noteTextArea.loadHtml(noteTextArea.html, "file:///")
65- }
66- }
67-
68- experimental.preferences.standardFontFamily: 'Ubuntu'
69- experimental.preferences.navigatorQtObjectEnabled: true
70- experimental.preferredMinimumContentsWidth: root.width
71- experimental.userScripts: [Qt.resolvedUrl("reminders-scripts.js")]
72- experimental.onMessageReceived: {
73- var data = null;
74- try {
75- data = JSON.parse(message.data);
76- } catch (error) {
77- print("Failed to parse message:", message.data, error);
78- }
79-
80- switch (data.type) {
81- case "checkboxChanged":
82- note.markTodo(data.todoId, data.checked);
83- NotesStore.saveNote(note.guid);
84- break;
85- }
86- }
87- }
88+ WebContext {
89+ id: webContext
90+
91+ userScripts: [
92+ UserScript {
93+ context: 'reminders://todo'
94+ url: Qt.resolvedUrl("reminders-scripts.js");
95+ }
96+ ]
97 }
98+
99+ WebView {
100+ id: noteTextArea
101+ anchors { fill: parent}
102+
103+ property string html: note.htmlContent
104+
105+ onHtmlChanged: {
106+ loadHtml(html, "file:///")
107+ }
108+
109+ context: webContext
110+ preferences.standardFontFamily: 'Ubuntu'
111+ preferences.minimumFontSize: 14
112+
113+ Connections {
114+ target: note
115+ onResourcesChanged: {
116+ noteTextArea.loadHtml(noteTextArea.html, "file:///")
117+ }
118+ }
119+
120+ messageHandlers: [
121+ ScriptMessageHandler {
122+ msgId: 'todo'
123+ contexts: ['reminders://todo']
124+ callback: function(message, frame) {
125+ var data = message.args;
126+
127+ switch (data.type) {
128+ case "checkboxChanged":
129+ note.markTodo(data.todoId, data.checked);
130+ NotesStore.saveNote(note.guid);
131+ break;
132+ }
133+ }
134+ }
135+ ]
136+ }
137 }
138
139=== modified file 'src/app/qml/ui/reminders-scripts.js'
140--- src/app/qml/ui/reminders-scripts.js 2013-12-17 23:19:58 +0000
141+++ src/app/qml/ui/reminders-scripts.js 2014-07-14 15:44:46 +0000
142@@ -5,7 +5,7 @@
143 message.type = "checkboxChanged";
144 message.todoId = event.srcElement.id;
145 message.checked = event.srcElement.checked;
146- navigator.qt.postMessage(JSON.stringify(message));
147+ oxide.sendMessage('todo', message);
148 }
149 }
150

Subscribers

People subscribed via source and target branches