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
=== modified file 'debian/control'
--- debian/control 2014-09-10 20:02:04 +0000
+++ debian/control 2014-11-18 17:32:47 +0000
@@ -16,6 +16,7 @@
16 qtdeclarative5-gsettings1.0,16 qtdeclarative5-gsettings1.0,
17 qtdeclarative5-ubuntu-ui-toolkit-plugin,17 qtdeclarative5-ubuntu-ui-toolkit-plugin,
18 qtdeclarative5-ubuntu-history0.1,18 qtdeclarative5-ubuntu-history0.1,
19 qtdeclarative5-ubuntu-telephony-phonenumber0.1,
19 qtpim5-dev,20 qtpim5-dev,
20 xvfb,21 xvfb,
21Standards-Version: 3.9.422Standards-Version: 3.9.4
@@ -31,6 +32,7 @@
31Depends: ${misc:Depends},32Depends: ${misc:Depends},
32 ${shlibs:Depends},33 ${shlibs:Depends},
33 qtdeclarative5-ubuntu-ui-toolkit-plugin | qt-components-ubuntu,34 qtdeclarative5-ubuntu-ui-toolkit-plugin | qt-components-ubuntu,
35 qtdeclarative5-ubuntu-telephony-phonenumber0.1,
34 qtdeclarative5-ubuntu-history0.1 | qtdeclarative5-ubuntu-history-plugin,36 qtdeclarative5-ubuntu-history0.1 | qtdeclarative5-ubuntu-history-plugin,
35 qtdeclarative5-ubuntu-telephony0.1 | qtdeclarative5-ubuntu-telephony-plugin,37 qtdeclarative5-ubuntu-telephony0.1 | qtdeclarative5-ubuntu-telephony-plugin,
36 qtdeclarative5-ubuntu-contacts0.1 (>= 0.2+14.10.20140805),38 qtdeclarative5-ubuntu-contacts0.1 (>= 0.2+14.10.20140805),
3739
=== modified file 'src/qml/MessageBubble.qml'
--- src/qml/MessageBubble.qml 2014-10-21 16:17:17 +0000
+++ src/qml/MessageBubble.qml 2014-11-18 17:32:47 +0000
@@ -19,6 +19,7 @@
19import QtQuick 2.219import QtQuick 2.2
20import Ubuntu.Components 1.120import Ubuntu.Components 1.1
21import Ubuntu.History 0.121import Ubuntu.History 0.1
22import Ubuntu.Telephony.PhoneNumber 0.1 as PhoneNumber
2223
23import "dateUtils.js" as DateUtils24import "dateUtils.js" as DateUtils
24import "3rd_party/ba-linkify.js" as BaLinkify25import "3rd_party/ba-linkify.js" as BaLinkify
@@ -38,8 +39,17 @@
38 readonly property bool sending: (messageStatus === HistoryThreadModel.MessageStatusUnknown ||39 readonly property bool sending: (messageStatus === HistoryThreadModel.MessageStatusUnknown ||
39 messageStatus === HistoryThreadModel.MessageStatusTemporarilyFailed) && !messageIncoming40 messageStatus === HistoryThreadModel.MessageStatusTemporarilyFailed) && !messageIncoming
4041
42 // XXXX: should be hoisted
43 function getCountryCode() {
44 var localeName = Qt.locale().name
45 return localeName.substr(localeName.length - 2, 2)
46 }
47
48 function formatTelSchemeWith(phoneNumber) {
49 return '<a href="tel:///' + phoneNumber + '">' + phoneNumber + '</a>'
50 }
51
41 function parseText(text) {52 function parseText(text) {
42 var phoneExp = /(\+?([0-9]+[ ]?)?\(?([0-9]+)\)?[- ]?([0-9]+)[- ]?([0-9]+)[- ]?([0-9]+))/img;
43 // remove html tags53 // remove html tags
44 text = text.replace(/</g,'&lt;').replace(/>/g,'<tt>&gt;</tt>');54 text = text.replace(/</g,'&lt;').replace(/>/g,'<tt>&gt;</tt>');
45 // replace line breaks55 // replace line breaks
@@ -49,8 +59,14 @@
49 if (htmlText !== text) {59 if (htmlText !== text) {
50 return htmlText60 return htmlText
51 }61 }
62
52 // linkify phone numbers if no web links were found63 // linkify phone numbers if no web links were found
53 return text.replace(phoneExp, '<a href="tel:///$1">$1</a>');64 var phoneNumbers = PhoneNumber.PhoneUtils.matchInText(text, getCountryCode())
65 for (var i = 0; i < phoneNumbers.length; ++i) {
66 var currentNumber = phoneNumbers[i]
67 text = text.replace(currentNumber, formatTelSchemeWith(currentNumber))
68 }
69 return text
54 }70 }
5571
56 color: {72 color: {

Subscribers

People subscribed via source and target branches