Merge lp:~renatofilho/address-book-app/fix-1450252 into lp:address-book-app

Proposed by Renato Araujo Oliveira Filho
Status: Superseded
Proposed branch: lp:~renatofilho/address-book-app/fix-1450252
Merge into: lp:address-book-app
Diff against target: 444 lines (+161/-25)
17 files modified
src/imports/ABContactListPage.qml (+3/-0)
src/imports/Ubuntu/AddressBook/ContactEditor/ContactEditorPage.qml (+2/-1)
src/imports/Ubuntu/AddressBook/ContactEditor/TextInputDetail.qml (+0/-1)
src/imports/Ubuntu/AddressBook/ContactView/BasicFieldView.qml (+0/-1)
src/imports/Ubuntu/Contacts/CMakeLists.txt (+1/-0)
src/imports/Ubuntu/Contacts/ContactAvatar.qml (+19/-7)
src/imports/Ubuntu/Contacts/ContactDelegate.qml (+1/-1)
src/imports/Ubuntu/Contacts/ContactDetailPickerPhoneNumberDelegate.qml (+0/-2)
src/imports/Ubuntu/Contacts/ContactListButtonDelegate.qml (+0/-1)
src/imports/Ubuntu/Contacts/Contacts.js (+7/-0)
src/imports/Ubuntu/Contacts/FastScroll.qml (+20/-5)
src/imports/Ubuntu/Contacts/ListItemWithActions.qml (+1/-1)
src/imports/Ubuntu/Contacts/SIMCardImportPage.qml (+30/-4)
src/imports/Ubuntu/Contacts/Triangle.qml (+52/-0)
src/imports/Ubuntu/Contacts/contacts.cpp (+16/-0)
src/imports/Ubuntu/Contacts/contacts.h (+2/-0)
tests/qml/tst_ContactAvatar.qml (+7/-1)
To merge this branch: bzr merge lp:~renatofilho/address-book-app/fix-1450252
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+284907@code.launchpad.net

This proposal has been superseded by a proposal from 2016-02-03.

Commit message

Make sure the import page still visible while importing contacts from sim.

To post a comment you must log in.
536. By Renato Araujo Oliveira Filho

Add debug messages.

537. By Renato Araujo Oliveira Filho

Pop import contacts from sim page on import complet.

538. By Renato Araujo Oliveira Filho

Parent merged.

539. By Renato Araujo Oliveira Filho

Removed debug messages.

540. By Renato Araujo Oliveira Filho

Remove debug messages.

541. By Renato Araujo Oliveira Filho

Trunk merged.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/imports/ABContactListPage.qml'
2--- src/imports/ABContactListPage.qml 2016-01-06 18:54:25 +0000
3+++ src/imports/ABContactListPage.qml 2016-02-03 14:15:56 +0000
4@@ -791,8 +791,11 @@
5 mainPage.state = "vcardImported"
6
7 if (mainPage._busyDialog) {
8+ console.debug("Closing import dialog")
9 PopupUtils.close(mainPage._busyDialog)
10 mainPage._busyDialog = null
11+ } else {
12+ console.debug("No import dialog")
13 }
14 }
15 }
16
17=== modified file 'src/imports/Ubuntu/AddressBook/ContactEditor/ContactEditorPage.qml'
18--- src/imports/Ubuntu/AddressBook/ContactEditor/ContactEditorPage.qml 2016-01-07 12:21:49 +0000
19+++ src/imports/Ubuntu/AddressBook/ContactEditor/ContactEditorPage.qml 2016-02-03 14:15:56 +0000
20@@ -118,7 +118,8 @@
21 if (!item)
22 return
23
24- var position = activeItem.mapToItem(editEditor, item.x, item.y);
25+
26+ var position = item.mapToItem(editEditor, item.x, item.y);
27 // check if the item is already visible
28 var bottomY = scrollArea.contentY + scrollArea.height
29 var itemBottom = position.y + (item.height * 3) // extra margin
30
31=== modified file 'src/imports/Ubuntu/AddressBook/ContactEditor/TextInputDetail.qml'
32--- src/imports/Ubuntu/AddressBook/ContactEditor/TextInputDetail.qml 2016-01-06 18:54:07 +0000
33+++ src/imports/Ubuntu/AddressBook/ContactEditor/TextInputDetail.qml 2016-02-03 14:15:56 +0000
34@@ -91,7 +91,6 @@
35 overlaySpacing: 0
36 frameSpacing: 0
37 background: Item {}
38- color: UbuntuColors.lightAubergine
39 }
40 onActiveFocusChanged: {
41 if (activeFocus) {
42
43=== modified file 'src/imports/Ubuntu/AddressBook/ContactView/BasicFieldView.qml'
44--- src/imports/Ubuntu/AddressBook/ContactView/BasicFieldView.qml 2015-12-10 19:13:20 +0000
45+++ src/imports/Ubuntu/AddressBook/ContactView/BasicFieldView.qml 2016-02-03 14:15:56 +0000
46@@ -59,7 +59,6 @@
47
48 // style
49 fontSize: "medium"
50- color: UbuntuColors.lightAubergine
51 }
52 }
53 }
54
55=== modified file 'src/imports/Ubuntu/Contacts/CMakeLists.txt'
56--- src/imports/Ubuntu/Contacts/CMakeLists.txt 2015-09-03 17:15:32 +0000
57+++ src/imports/Ubuntu/Contacts/CMakeLists.txt 2016-02-03 14:15:56 +0000
58@@ -31,6 +31,7 @@
59 SIMList.qml
60 SIMCardImportPage.qml
61 SubtitledWithColors.qml
62+ Triangle.qml
63 VCardParser.qml
64 )
65
66
67=== modified file 'src/imports/Ubuntu/Contacts/ContactAvatar.qml'
68--- src/imports/Ubuntu/Contacts/ContactAvatar.qml 2015-10-26 13:18:11 +0000
69+++ src/imports/Ubuntu/Contacts/ContactAvatar.qml 2016-02-03 14:15:56 +0000
70@@ -40,8 +40,9 @@
71 initialsLabel.contactDisplayName = Qt.binding(function() { return ContactsJS.formatToDisplayWithDetails(contactElement, ContactDetail.Name, [Name.FirstName, Name.LastName], fallbackDisplayName) })
72 }
73
74+ aspect: UbuntuShape.Flat
75 radius: "medium"
76- backgroundColor: Theme.palette.normal.overlay
77+ backgroundColor: ContactsJS.contactColor(displayName)
78
79 Label {
80 id: initialsLabel
81@@ -51,8 +52,8 @@
82
83 anchors.centerIn: parent
84 text: Contacts.contactInitialsFromString(contactDisplayName)
85- color: UbuntuColors.lightAubergine
86- visible: (img.status != Image.Ready)
87+ color: "white"
88+ visible: (img.status != Image.Ready) && !fallbackIcon.visible
89 fontSize: "large"
90 }
91
92@@ -65,13 +66,24 @@
93
94 property string avatarUrl: ContactsJS.getAvatar(contactElement, fallbackAvatarUrl)
95
96- anchors.centerIn: visible ? avatar : undefined
97 asynchronous: true
98- source: avatar.showAvatarPicture ? avatar.avatarUrl : ""
99- height: visible ? units.gu(3) : avatar.height
100+ source: avatar.showAvatarPicture && (avatar.avatarUrl.indexOf("image://theme/") === -1) ? avatar.avatarUrl : ""
101+ height: avatar.height
102 width: height
103- visible: avatar.avatarUrl.indexOf("image://theme/") === 0
104+ visible: false
105 sourceSize.width: avatar.width
106 sourceSize.height: avatar.height
107 }
108+
109+ Icon {
110+ id: fallbackIcon
111+ objectName: "fallbackIcon"
112+
113+ source: visible ? img.avatarUrl : ""
114+ visible: avatar.showAvatarPicture && (avatar.avatarUrl.indexOf("image://theme/") === 0)
115+ color: "white"
116+ anchors.centerIn: avatar
117+ height: units.gu(3)
118+ width: height
119+ }
120 }
121
122=== modified file 'src/imports/Ubuntu/Contacts/ContactDelegate.qml'
123--- src/imports/Ubuntu/Contacts/ContactDelegate.qml 2015-12-10 19:13:20 +0000
124+++ src/imports/Ubuntu/Contacts/ContactDelegate.qml 2016-02-03 14:15:56 +0000
125@@ -76,7 +76,7 @@
126 verticalCenter: parent.verticalCenter
127 right: parent.right
128 }
129- color: UbuntuColors.lightAubergine
130+ color: selected ? "white" : UbuntuColors.darkGrey
131 text: root.displayLabel != "" ? root.displayLabel : i18n.dtr("address-book-app", "No name")
132 elide: Text.ElideRight
133 }
134
135=== modified file 'src/imports/Ubuntu/Contacts/ContactDetailPickerPhoneNumberDelegate.qml'
136--- src/imports/Ubuntu/Contacts/ContactDetailPickerPhoneNumberDelegate.qml 2015-10-26 13:18:11 +0000
137+++ src/imports/Ubuntu/Contacts/ContactDetailPickerPhoneNumberDelegate.qml 2016-02-03 14:15:56 +0000
138@@ -80,7 +80,6 @@
139 }
140
141 text: i18n.dtr("address-book-app", "Add number...")
142- color: UbuntuColors.lightAubergine
143 }
144 visible: phoneNumberEntries.count == 0
145 MouseArea {
146@@ -104,7 +103,6 @@
147 text: modelData.number
148 subText: phoneTypeModel.get(phoneTypeModel.getTypeIndex(modelData)).label
149 onClicked: root.detailClicked(modelData, "call")
150- textColor: UbuntuColors.lightAubergine
151
152 MouseArea {
153 anchors {
154
155=== modified file 'src/imports/Ubuntu/Contacts/ContactListButtonDelegate.qml'
156--- src/imports/Ubuntu/Contacts/ContactListButtonDelegate.qml 2015-10-26 13:18:11 +0000
157+++ src/imports/Ubuntu/Contacts/ContactListButtonDelegate.qml 2016-02-03 14:15:56 +0000
158@@ -73,7 +73,6 @@
159 right: parent.right
160 rightMargin: units.gu(2)
161 }
162- color: UbuntuColors.lightAubergine
163 elide: Text.ElideRight
164 visible: root.showContents
165 }
166
167=== modified file 'src/imports/Ubuntu/Contacts/Contacts.js'
168--- src/imports/Ubuntu/Contacts/Contacts.js 2015-06-01 18:26:26 +0000
169+++ src/imports/Ubuntu/Contacts/Contacts.js 2016-02-03 14:15:56 +0000
170@@ -1,5 +1,6 @@
171
172 var phoneTypeModel = null
173+var contactColors = ["#DC3023", "#FF8936", "#FFB95A", "#8DB255", "#749F8D", "#48929B", "#A87CA0"]
174
175 // Format contact name to be displayed
176 function formatToDisplayWithDetails(contact, contactDetail, detailFields, defaultTitle)
177@@ -145,3 +146,9 @@
178 {
179 return (contact && (contact.contactId === "qtcontacts:::"))
180 }
181+
182+function contactColor(name)
183+{
184+ var hash = Contacts.qHash(name)
185+ return contactColors[(hash % contactColors.length)]
186+}
187
188=== modified file 'src/imports/Ubuntu/Contacts/FastScroll.qml'
189--- src/imports/Ubuntu/Contacts/FastScroll.qml 2015-12-10 19:08:19 +0000
190+++ src/imports/Ubuntu/Contacts/FastScroll.qml 2016-02-03 14:15:56 +0000
191@@ -72,15 +72,16 @@
192 }
193
194
195- Rectangle {
196+ UbuntuShape {
197 id: magnified
198
199+ aspect: UbuntuShape.Flat
200 color: Theme.palette.normal.foreground
201- radius: height * 0.3
202- height: pinSize * 2
203- width: height
204+ radius: "medium"
205+ height: units.gu(6)
206+ width: units.gu(8)
207 opacity: internal.fastScrolling && root.enabled ? 1.0 : 0.0
208- x: -cursor.width - units.gu(3)
209+ x: -magnified.width
210 y: {
211 if (internal.currentItem) {
212 var itemCenterY = rail.y + internal.currentItem.y + (internal.currentItem.height / 2)
213@@ -90,6 +91,20 @@
214 }
215 }
216
217+ Triangle {
218+ id: arrow
219+
220+ color: magnified.color
221+ fill: true
222+ height: units.gu(1.5)
223+ width: units.gu(0.5)
224+ anchors {
225+ verticalCenter: parent.verticalCenter
226+ right: parent.right
227+ rightMargin: -width
228+ }
229+ }
230+
231 Label {
232 color: Theme.palette.normal.foregroundText
233 anchors.fill: parent
234
235=== modified file 'src/imports/Ubuntu/Contacts/ListItemWithActions.qml'
236--- src/imports/Ubuntu/Contacts/ListItemWithActions.qml 2016-01-06 15:09:18 +0000
237+++ src/imports/Ubuntu/Contacts/ListItemWithActions.qml 2016-02-03 14:15:56 +0000
238@@ -246,7 +246,7 @@
239 width: units.gu(3)
240 height: units.gu(3)
241 name: modelData.iconName
242- color: root.activeAction === modelData ? UbuntuColors.lightAubergine : UbuntuColors.lightGrey
243+ color: root.activeAction === modelData ? UbuntuColors.orange : UbuntuColors.lightGrey
244 }
245 }
246 }
247
248=== modified file 'src/imports/Ubuntu/Contacts/SIMCardImportPage.qml'
249--- src/imports/Ubuntu/Contacts/SIMCardImportPage.qml 2015-12-02 13:36:03 +0000
250+++ src/imports/Ubuntu/Contacts/SIMCardImportPage.qml 2016-02-03 14:15:56 +0000
251@@ -26,7 +26,7 @@
252 Page {
253 id: root
254
255- readonly property string exportFile: "file://%1/ubuntu_contacts_sim.vcf".arg(Contacts.tempPath)
256+ readonly property string exportFile: Contacts.tempFile("ubuntu_contacts_XXXXXX.vcf")
257 readonly property alias hasContacts: simCardContacts.hasContacts
258 property var targetModel: null
259 property var sims: []
260@@ -98,7 +98,7 @@
261 multiSelectionEnabled: true
262 multipleSelection: true
263 showSections: false
264- visible: !indicator.visible
265+ visible: !indicator.visible && !statusMessage.visible
266 showBusyIndicator: false
267
268 manager: "memory"
269@@ -168,9 +168,26 @@
270
271 onExportCompleted: {
272 if ((error === ContactModel.ExportNoError) && targetModel) {
273+ root.state = "saving"
274 targetModel.importContacts(url)
275+ } else {
276+ console.debug("Failt to export selected contacts")
277+ root.state = "error"
278+ }
279+ }
280+ }
281+
282+ Connections {
283+ target: root.targetModel
284+ onImportCompleted: {
285+ if (error === ContactModel.ImportNoError) {
286+ Contacts.removeFile(root.exportFile)
287+ root.state = ""
288+ root.importCompleted()
289+ } else {
290+ console.error("Fail to import contacts on device")
291+ root.state = "error"
292 }
293- root.importCompleted()
294 }
295 }
296
297@@ -235,7 +252,15 @@
298 name: "importing"
299 PropertyChanges {
300 target: indicator
301- title: i18n.dtr("address-book-app", "Importing...")
302+ title: i18n.dtr("address-book-app", "Reading contacts from SIM...")
303+ visible: true
304+ }
305+ },
306+ State {
307+ name: "saving"
308+ PropertyChanges {
309+ target: indicator
310+ title: i18n.dtr("address-book-app", "Saving contacts on phone...")
311 visible: true
312 }
313 },
314@@ -249,6 +274,7 @@
315 }
316 ]
317
318+ Component.onCompleted: console.debug("Temporary file:" + exportFile)
319 Component.onDestruction: {
320 Contacts.removeFile(root.exportFile)
321 }
322
323=== added file 'src/imports/Ubuntu/Contacts/Triangle.qml'
324--- src/imports/Ubuntu/Contacts/Triangle.qml 1970-01-01 00:00:00 +0000
325+++ src/imports/Ubuntu/Contacts/Triangle.qml 2016-02-03 14:15:56 +0000
326@@ -0,0 +1,52 @@
327+/*
328+ * Copyright (C) 2016 Canonical, Ltd.
329+ *
330+ * This program is free software; you can redistribute it and/or modify
331+ * it under the terms of the GNU General Public License as published by
332+ * the Free Software Foundation; version 3.
333+ *
334+ * This program is distributed in the hope that it will be useful,
335+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
336+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
337+ * GNU General Public License for more details.
338+ *
339+ * You should have received a copy of the GNU General Public License
340+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
341+ */
342+
343+import QtQuick 2.4
344+
345+Canvas {
346+ id: triangle
347+ antialiasing: true
348+
349+ property color color: "#ffffff"
350+ property int lineWidth: 3
351+ property bool fill: false
352+
353+ onLineWidthChanged:requestPaint();
354+ onFillChanged:requestPaint();
355+
356+ onPaint: {
357+ var ctx = getContext("2d");
358+ ctx.save();
359+ ctx.clearRect(0,0,triangle.width, triangle.height);
360+ ctx.strokeStyle = triangle.color;
361+ ctx.lineWidth = triangle.lineWidth
362+ ctx.fillStyle = triangle.color
363+ ctx.globalAlpha = 1.0
364+ ctx.lineJoin = "round";
365+ ctx.beginPath();
366+
367+ ctx.translate(0, 0);
368+ ctx.lineTo(0, triangle.height);
369+ ctx.lineTo(triangle.width, 0.5 * triangle.height);
370+ ctx.lineTo(0, 0);
371+
372+ if (triangle.fill)
373+ ctx.fill();
374+ if (triangle.stroke)
375+ ctx.stroke();
376+ ctx.restore();
377+ }
378+}
379
380=== modified file 'src/imports/Ubuntu/Contacts/contacts.cpp'
381--- src/imports/Ubuntu/Contacts/contacts.cpp 2015-10-28 19:42:30 +0000
382+++ src/imports/Ubuntu/Contacts/contacts.cpp 2016-02-03 14:15:56 +0000
383@@ -109,6 +109,22 @@
384 return QFile::exists(updaterLockFile());
385 }
386
387+
388+QUrl UbuntuContacts::tempFile(const QString &templateName)
389+{
390+ QTemporaryFile tmp(QString("%1/%2").arg(tempPath()).arg(templateName));
391+ tmp.setAutoRemove(false);
392+ if (tmp.open())
393+ return QUrl::fromLocalFile(tmp.fileName());
394+ else
395+ return QUrl();
396+}
397+
398+uint UbuntuContacts::qHash(const QString &str)
399+{
400+ return ::qHash(str);
401+}
402+
403 QString UbuntuContacts::updaterLockFile()
404 {
405 return QString("%1/%2").arg(QDir::tempPath()).arg("/address-book-updater.lock");
406
407=== modified file 'src/imports/Ubuntu/Contacts/contacts.h'
408--- src/imports/Ubuntu/Contacts/contacts.h 2015-10-28 19:42:30 +0000
409+++ src/imports/Ubuntu/Contacts/contacts.h 2016-02-03 14:15:56 +0000
410@@ -40,6 +40,8 @@
411 Q_INVOKABLE bool containsLetters(const QString &value);
412 Q_INVOKABLE bool removeFile(const QUrl &file);
413 Q_INVOKABLE bool updateIsRunning() const;
414+ Q_INVOKABLE QUrl tempFile(const QString &suffix);
415+ Q_INVOKABLE uint qHash(const QString &str);
416
417 Q_SIGNALS:
418 void imageCopyDone(const QString &id, const QString &fileName);
419
420=== modified file 'tests/qml/tst_ContactAvatar.qml'
421--- tests/qml/tst_ContactAvatar.qml 2015-10-26 13:18:11 +0000
422+++ tests/qml/tst_ContactAvatar.qml 2016-02-03 14:15:56 +0000
423@@ -151,14 +151,20 @@
424 waitForRendering(avatarComponent);
425 var avatarInitials = findChild(avatarComponent, "avatarInitials")
426 var avatarImage = findChild(avatarComponent, "avatarImage")
427+ var avatarFallback = findChild(avatarComponent, "fallbackIcon")
428
429 avatarComponent.showAvatarPicture = true
430 tryCompare(avatarInitials, "visible", false)
431- tryCompare(avatarImage, "source", avatarComponent.fallbackAvatarUrl)
432+ tryCompare(avatarImage, "source", "")
433+ tryCompare(avatarFallback, "visible", true)
434+ tryCompare(avatarFallback, "source", avatarComponent.fallbackAvatarUrl)
435
436 avatarComponent.showAvatarPicture = false
437 tryCompare(avatarImage, "source", "")
438 tryCompare(avatarImage, "status", Image.Null)
439+ tryCompare(avatarFallback, "visible", false)
440+ tryCompare(avatarFallback, "source", "")
441+
442 tryCompare(avatarInitials, "visible", true)
443 }
444 }

Subscribers

People subscribed via source and target branches