Merge lp:~renatofilho/telephony-service/fix-1372548-rtm into lp:telephony-service/rtm-14.09

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Bill Filler
Approved revision: 911
Merged at revision: 913
Proposed branch: lp:~renatofilho/telephony-service/fix-1372548-rtm
Merge into: lp:telephony-service/rtm-14.09
Diff against target: 90 lines (+25/-6)
4 files modified
Ubuntu/Telephony/PhoneNumber/asyoutypeformatter.cpp (+6/-1)
Ubuntu/Telephony/PhoneNumber/phoneutils.cpp (+1/-1)
Ubuntu/Telephony/tests/tst_PhoneNumberData.js (+16/-2)
Ubuntu/Telephony/tests/tst_PhoneNumberPhoneUtils.qml (+2/-2)
To merge this branch: bzr merge lp:~renatofilho/telephony-service/fix-1372548-rtm
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+244812@code.launchpad.net

Commit message

Added support for [',', ';', '+', '*', '#'] on phone number fields.

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 'Ubuntu/Telephony/PhoneNumber/asyoutypeformatter.cpp'
2--- Ubuntu/Telephony/PhoneNumber/asyoutypeformatter.cpp 2014-07-14 23:06:34 +0000
3+++ Ubuntu/Telephony/PhoneNumber/asyoutypeformatter.cpp 2014-12-16 01:10:10 +0000
4@@ -185,6 +185,11 @@
5
6 QString AsYouTypeFormatter::formatTextImpl(const QString &text, int *cursorPosition)
7 {
8+ static QList<QChar> validChars;
9+ if (validChars.isEmpty()) {
10+ validChars << QChar(',') << QChar(';') << QChar('+') << QChar('*') << QChar('#');
11+ }
12+
13 // if the number starts with "+" we will use unknown region otherwise we will use the default region
14 QString numberRegion = m_defaultRegionCode;
15 if (m_rawText.startsWith("+")) {
16@@ -209,7 +214,7 @@
17 for(int i = 0, iMax = text.size(); i < iMax; i++) {
18 bool savePosition = (cursorPosition != 0) && (i < *cursorPosition);
19 QChar iChar = text.at(i);
20- if (iChar.isDigit() || (iChar.toLatin1() == '+')) {
21+ if (iChar.isDigit() || validChars.contains(iChar)) {
22 if (savePosition) {
23 m_formatter->InputDigitAndRememberPosition(iChar.toLatin1(), &result);
24 } else {
25
26=== modified file 'Ubuntu/Telephony/PhoneNumber/phoneutils.cpp'
27--- Ubuntu/Telephony/PhoneNumber/phoneutils.cpp 2014-07-14 23:06:34 +0000
28+++ Ubuntu/Telephony/PhoneNumber/phoneutils.cpp 2014-12-16 01:10:10 +0000
29@@ -67,7 +67,7 @@
30
31 switch(error) {
32 case i18n::phonenumbers::PhoneNumberUtil::INVALID_COUNTRY_CODE_ERROR:
33- qWarning() << "Invalid coutry code for:" << phoneNumber;
34+ qWarning() << "Invalid country code for:" << phoneNumber;
35 return "";
36 case i18n::phonenumbers::PhoneNumberUtil::NOT_A_NUMBER:
37 qWarning() << "The phone number is not a valid number:" << phoneNumber;
38
39=== modified file 'Ubuntu/Telephony/tests/tst_PhoneNumberData.js'
40--- Ubuntu/Telephony/tests/tst_PhoneNumberData.js 2014-07-05 15:00:45 +0000
41+++ Ubuntu/Telephony/tests/tst_PhoneNumberData.js 2014-12-16 01:10:10 +0000
42@@ -29,10 +29,16 @@
43 {
44 var data = [];
45 data.push({input: "7572923", expectedOutput: "757-2923", expectedCursorPosition: 8}) // Local number
46- data.push({input: "7327572923", expectedOutput: "(732) 757-2923", expectedCursorPosition: 14}) // Coutry number
47+ data.push({input: "7327572923", expectedOutput: "(732) 757-2923", expectedCursorPosition: 14}) // Country number
48 data.push({input: "+558187042155", expectedOutput: "+55 81 8704-2155", expectedCursorPosition: 16}) // International number
49 data.push({input: "55555555555", expectedOutput: "55555555555", expectedCursorPosition: 11}) // Ivalid number
50-
51+ data.push({input: "123#", expectedOutput: "123#", expectedCursorPosition: 4}) // Special number
52+ data.push({input: "#123#", expectedOutput: "#123#", expectedCursorPosition: 5})
53+ data.push({input: "*144", expectedOutput: "*144", expectedCursorPosition: 4})
54+ data.push({input: "123#456", expectedOutput: "123#456", expectedCursorPosition: 7})
55+ data.push({input: "123,456", expectedOutput: "123,456", expectedCursorPosition: 7})
56+ data.push({input: "123,;456;", expectedOutput: "123,;456;", expectedCursorPosition: 9})
57+ data.push({input: "1+2;3,4*5#6;", expectedOutput: "1+2;3,4*5#6;", expectedCursorPosition: 12})
58 return data
59 }
60
61@@ -62,5 +68,13 @@
62 action: "remove", text: "",
63 newFormatedInput: "(089) 908-6488", expectedCursorPosition: 3})
64
65+ // special numbers
66+ data.push({input: "123", formatedInput: "1 23", moveCursor: 4,
67+ action: "insert", text: "#",
68+ newFormatedInput: "123#", expectedCursorPosition: 4})
69+ data.push({input: "144", formatedInput: "1 44", moveCursor: 0,
70+ action: "insert", text: "*",
71+ newFormatedInput: "*144", expectedCursorPosition: 1})
72+
73 return data
74 }
75
76=== modified file 'Ubuntu/Telephony/tests/tst_PhoneNumberPhoneUtils.qml'
77--- Ubuntu/Telephony/tests/tst_PhoneNumberPhoneUtils.qml 2014-07-14 23:06:34 +0000
78+++ Ubuntu/Telephony/tests/tst_PhoneNumberPhoneUtils.qml 2014-12-16 01:10:10 +0000
79@@ -28,9 +28,9 @@
80 {
81 var data = [];
82 data.push({input: "6681800", expectedOutput: "668-1800"}) // Local number
83- data.push({input: "7327572923", expectedOutput: "(732) 757-2923"}) // Coutry number
84+ data.push({input: "7327572923", expectedOutput: "(732) 757-2923"}) // Country number
85 data.push({input: "+558187042155", expectedOutput: "+55 81 8704-2155"}) // International number
86- data.push({input: "55555555555", expectedOutput: "55555555555"}) // Ivalid number
87+ data.push({input: "55555555555", expectedOutput: "55555555555"}) // Invalid number
88 data.push({input: "*144", expectedOutput: "*144"}) // Special number
89 data.push({input: "#123#", expectedOutput: "#123#"}) // Operators command
90 return data

Subscribers

People subscribed via source and target branches