Merge lp:~boiko/messaging-app/rtm-fix_1376803 into lp:messaging-app/rtm-14.09

Proposed by Gustavo Pichorim Boiko
Status: Merged
Approved by: Bill Filler
Approved revision: 204
Merged at revision: 209
Proposed branch: lp:~boiko/messaging-app/rtm-fix_1376803
Merge into: lp:messaging-app/rtm-14.09
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:~boiko/messaging-app/rtm-fix_1376803
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+247172@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.

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.

To post a comment you must log in.

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 2015-01-21 16:51:48 +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-12-16 01:44:00 +0000
23+++ src/qml/MessageBubble.qml 2015-01-21 16:51:48 +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