Merge lp:~abreu-alexandre/messaging-app/phone-number-detection-msg-bubbles into lp:messaging-app

Proposed by Alexandre Abreu
Status: Merged
Approved by: Bill Filler
Approved revision: 276
Merged at revision: 273
Proposed branch: lp:~abreu-alexandre/messaging-app/phone-number-detection-msg-bubbles
Merge into: lp:messaging-app
Diff against target: 66 lines (+20/-2)
2 files modified
debian/control (+2/-0)
src/qml/MessageBubble.qml (+18/-2)
To merge this branch: bzr merge lp:~abreu-alexandre/messaging-app/phone-number-detection-msg-bubbles
Reviewer Review Type Date Requested Status
Tiago Salem Herrmann (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+241197@code.launchpad.net

Commit message

Localize and strengthen the phone number detection scheme used from within a given message bubble as it is replaced by tel:// URIs.

It needs some new APIs from the libphonenumber QML plugin

https://code.launchpad.net/~abreu-alexandre/telephony-service/expose-phone-number-matcher/+merge/241196

Description of the change

Localize and strengthen the phone number detection scheme used from within a given message bubble as it is replaced by tel:// URIs.

It needs some new APIs from the libphonenumber QML plugin

https://code.launchpad.net/~abreu-alexandre/telephony-service/expose-phone-number-matcher/+merge/241196

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
270. By Alexandre Abreu

fix build

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
271. By Alexandre Abreu

rever uneeded additional dep

272. By Alexandre Abreu

rever uneeded additional dep

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
273. By Alexandre Abreu

update

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
274. By Alexandre Abreu

remove confusion about phone number plugin dep

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
275. By Alexandre Abreu

cleanup formatting

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
276. By Alexandre Abreu

Add build dep for qtdeclarative5-ubuntu-telephony-phonenumber0.1 since it is needed for unit tests

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Tiago Salem Herrmann (tiagosh) wrote :

It looks good.
Tested on the device and it seems to work well.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2014-09-10 20:02:04 +0000
3+++ debian/control 2014-11-18 17:32:47 +0000
4@@ -16,6 +16,7 @@
5 qtdeclarative5-gsettings1.0,
6 qtdeclarative5-ubuntu-ui-toolkit-plugin,
7 qtdeclarative5-ubuntu-history0.1,
8+ qtdeclarative5-ubuntu-telephony-phonenumber0.1,
9 qtpim5-dev,
10 xvfb,
11 Standards-Version: 3.9.4
12@@ -31,6 +32,7 @@
13 Depends: ${misc:Depends},
14 ${shlibs:Depends},
15 qtdeclarative5-ubuntu-ui-toolkit-plugin | qt-components-ubuntu,
16+ qtdeclarative5-ubuntu-telephony-phonenumber0.1,
17 qtdeclarative5-ubuntu-history0.1 | qtdeclarative5-ubuntu-history-plugin,
18 qtdeclarative5-ubuntu-telephony0.1 | qtdeclarative5-ubuntu-telephony-plugin,
19 qtdeclarative5-ubuntu-contacts0.1 (>= 0.2+14.10.20140805),
20
21=== modified file 'src/qml/MessageBubble.qml'
22--- src/qml/MessageBubble.qml 2014-10-21 16:17:17 +0000
23+++ src/qml/MessageBubble.qml 2014-11-18 17:32:47 +0000
24@@ -19,6 +19,7 @@
25 import QtQuick 2.2
26 import Ubuntu.Components 1.1
27 import Ubuntu.History 0.1
28+import Ubuntu.Telephony.PhoneNumber 0.1 as PhoneNumber
29
30 import "dateUtils.js" as DateUtils
31 import "3rd_party/ba-linkify.js" as BaLinkify
32@@ -38,8 +39,17 @@
33 readonly property bool sending: (messageStatus === HistoryThreadModel.MessageStatusUnknown ||
34 messageStatus === HistoryThreadModel.MessageStatusTemporarilyFailed) && !messageIncoming
35
36+ // XXXX: should be hoisted
37+ function getCountryCode() {
38+ var localeName = Qt.locale().name
39+ return localeName.substr(localeName.length - 2, 2)
40+ }
41+
42+ function formatTelSchemeWith(phoneNumber) {
43+ return '<a href="tel:///' + phoneNumber + '">' + phoneNumber + '</a>'
44+ }
45+
46 function parseText(text) {
47- var phoneExp = /(\+?([0-9]+[ ]?)?\(?([0-9]+)\)?[- ]?([0-9]+)[- ]?([0-9]+)[- ]?([0-9]+))/img;
48 // remove html tags
49 text = text.replace(/</g,'&lt;').replace(/>/g,'<tt>&gt;</tt>');
50 // replace line breaks
51@@ -49,8 +59,14 @@
52 if (htmlText !== text) {
53 return htmlText
54 }
55+
56 // linkify phone numbers if no web links were found
57- return text.replace(phoneExp, '<a href="tel:///$1">$1</a>');
58+ var phoneNumbers = PhoneNumber.PhoneUtils.matchInText(text, getCountryCode())
59+ for (var i = 0; i < phoneNumbers.length; ++i) {
60+ var currentNumber = phoneNumbers[i]
61+ text = text.replace(currentNumber, formatTelSchemeWith(currentNumber))
62+ }
63+ return text
64 }
65
66 color: {

Subscribers

People subscribed via source and target branches