on xenial help sign in
allow SIM PIN entry to have a variable pin length (by adding a done-button). Fixes: https://bugs.launchpad.net/bugs/1240561.
fb1d1ffMichael Zanetti
Components/PinPadButton.qml+40−13
@@ -21,24 +21,51 @@ Item {
21 id: root
21 id: root
22
22
23 property alias text: label.text
23 property alias text: label.text
24− property alias iconName: icon.name
24+ property alias subText: subTextLabel.text
25+ property string iconName
25
26
26 signal clicked()
27 signal clicked()
27
28
28− Label {
29+ Column {
29− id: label
30 anchors.centerIn: parent
30 anchors.centerIn: parent
31− color: "#f3f3e7"
31+ width: parent.width
32− fontSize: "large"
32+ height: childrenRect.height
33− font.weight: Font.DemiBold
34− }
35
33
34+ Item {
35+ anchors {
36+ left: parent.left
37+ right: parent.right
38+ }
39+ height: label.visible || icon.visible ? Math.max(label.height, icon.height) : 0
40+
41+ Label {
42+ id: label
43+ anchors.centerIn: parent
44+ width: parent.width
45+ horizontalAlignment: Text.AlignHCenter
46+ color: "#f3f3e7"
47+ fontSize: "large"
48+ font.weight: Font.DemiBold
49+ visible: text.length > 0
50+ }
51+
36− Icon {
52+ Icon {
37− id: icon
53+ id: icon
38− height: units.gu(3)
54+ height: units.gu(3)
39− width: height
55+ width: height
40− anchors.centerIn: parent
56+ anchors.centerIn: parent
57+ name: root.iconName
41− color: "#f3f3e7"
58+ color: "#f3f3e7"
59+ visible: name.length > 0
60+ }
61+ }
62+ Label {
63+ id: subTextLabel
64+ fontSize: "small"
65+ color: "grey"
66+ anchors.horizontalCenter: parent.horizontalCenter
67+ visible: text.length > 0
68+ }
42 }
69 }
43
70
44 MouseArea {
71 MouseArea {
Greeter/PinLockscreen.qml+34−4
@@ -27,7 +27,7 @@ Column {
27 property alias placeholderText: pinentryField.placeholderText
27 property alias placeholderText: pinentryField.placeholderText
28 property int padWidth: units.gu(34)
28 property int padWidth: units.gu(34)
29 property int padHeight: units.gu(28)
29 property int padHeight: units.gu(28)
30− property int pinLength: 4
30+ property int pinLength: -1
31
31
32 signal entered(string passphrase)
32 signal entered(string passphrase)
33 signal cancel()
33 signal cancel()
@@ -65,6 +65,9 @@ Column {
65 Label {
65 Label {
66 id: pinentryFieldLabel
66 id: pinentryFieldLabel
67 anchors.centerIn: parent
67 anchors.centerIn: parent
68+ width: parent.width - (backspaceIcon.width + backspaceIcon.anchors.rightMargin) * 2
69+ elide: Text.ElideMiddle
70+ horizontalAlignment: Text.AlignHCenter
68 font.pixelSize: units.dp(44)
71 font.pixelSize: units.dp(44)
69 color: "#f3f3e7"
72 color: "#f3f3e7"
70 opacity: 0.6
73 opacity: 0.6
@@ -76,6 +79,26 @@ Column {
76 text: parent.placeholderText
79 text: parent.placeholderText
77 visible: pinentryFieldLabel.text.length == 0
80 visible: pinentryFieldLabel.text.length == 0
78 }
81 }
82+
83+ Icon {
84+ id: backspaceIcon
85+ objectName: "backspaceIcon"
86+ anchors {
87+ top: parent.top
88+ topMargin: units.gu(1)
89+ right: parent.right
90+ rightMargin: units.gu(2)
91+ bottom: parent.bottom
92+ bottomMargin: units.gu(1)
93+ }
94+ visible: root.pinLength == -1
95+ width: height
96+ name: "erase"
97+ MouseArea {
98+ anchors.fill: parent
99+ onClicked: pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1);
100+ }
101+ }
79 }
102 }
80
103
81 UbuntuShape {
104 UbuntuShape {
@@ -154,7 +177,7 @@ Column {
154 objectName: "pinPadButtonBack"
177 objectName: "pinPadButtonBack"
155 width: root.padWidth / 3
178 width: root.padWidth / 3
156 height: root.padHeight / 4
179 height: root.padHeight / 4
157− iconName: "back"
180+ subText: "CANCEL"
158 onClicked: root.cancel();
181 onClicked: root.cancel();
159 }
182 }
160
183
@@ -171,8 +194,15 @@ Column {
171 objectName: "pinPadButtonErase"
194 objectName: "pinPadButtonErase"
172 width: root.padWidth / 3
195 width: root.padWidth / 3
173 height: root.padHeight / 4
196 height: root.padHeight / 4
174− iconName: "erase"
197+ iconName: root.pinLength == -1 ? "" : "erase"
198+ subText: root.pinLength == -1 ? "DONE" : ""
199+ onClicked: {
200+ if (root.pinLength !== -1) {
175− onClicked: pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1)
201+ pinentryField.text = pinentryField.text.substring(0, pinentryField.text.length-1);
202+ } else {
203+ root.entered(pinentryField.text);
204+ }
205+ }
176 enabled: entryEnabled
206 enabled: entryEnabled
177 }
207 }
178 }
208 }
Notifications/NotificationMenuItemFactory.qml−5
@@ -97,11 +97,6 @@ Loader {
97 PinLockscreen {
97 PinLockscreen {
98 anchors.left: parent.left; anchors.right: parent.right
98 anchors.left: parent.left; anchors.right: parent.right
99
99
100− Component.onCompleted: {
101− menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-pin-length': 'int'});
102− pinLength = menuData.ext.xCanonicalPinLength;
103− }
104−
105 onEntered: {
100 onEntered: {
106 menuModel.changeState(menuIndex, passphrase);
101 menuModel.changeState(menuIndex, passphrase);
107 entryEnabled = false;
102 entryEnabled = false;
tests/qmltests/Greeter/tst_Lockscreen.qml+42−4
@@ -176,15 +176,17 @@ Rectangle {
176
176
177 function test_unlock_data() {
177 function test_unlock_data() {
178 return [
178 return [
179− {tag: "numeric", alphanumeric: false, username: "has-pin", password: "1234", unlockedSignal: true},
179+ {tag: "numeric", alphanumeric: false, username: "has-pin", password: "1234", unlockedSignal: true, pinLength: 4},
180− {tag: "alphanumeric", alphanumeric: true, username: "has-password", password: "password", unlockedSignal: true},
180+ {tag: "alphanumeric", alphanumeric: true, username: "has-password", password: "password", unlockedSignal: true, pinLength: -1},
181− {tag: "numeric (wrong)", alphanumeric: false, username: "has-pin", password: "4321", unlockedSignal: false},
181+ {tag: "numeric (wrong)", alphanumeric: false, username: "has-pin", password: "4321", unlockedSignal: false, pinLength: 4},
182− {tag: "alphanumeric (wrong)", alphanumeric: true, username: "has-password", password: "drowssap", unlockedSignal: false},
182+ {tag: "alphanumeric (wrong)", alphanumeric: true, username: "has-password", password: "drowssap", unlockedSignal: false, pinLength: -1},
183+ {tag: "flexible length", alphanumeric: false, username: "has-pin", password: "1234", unlockedSignal: true, pinLength: -1},
183 ]
184 ]
184 }
185 }
185
186
186 function test_unlock(data) {
187 function test_unlock(data) {
187 unlockedCheckBox.checked = false
188 unlockedCheckBox.checked = false
189+ pinLengthTextField.text = data.pinLength
188 LightDM.Greeter.authenticate(data.username)
190 LightDM.Greeter.authenticate(data.username)
189 waitForRendering(lockscreen)
191 waitForRendering(lockscreen)
190
192
@@ -199,7 +201,12 @@ Rectangle {
199 var button = findChild(lockscreen, "pinPadButton" + character)
201 var button = findChild(lockscreen, "pinPadButton" + character)
200 mouseClick(button, units.gu(1), units.gu(1))
202 mouseClick(button, units.gu(1), units.gu(1))
201 }
203 }
204+ if (data.pinLength == -1) {
205+ var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
206+ mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
207+ }
202 }
208 }
209+
203 tryCompare(unlockedCheckBox, "checked", data.unlockedSignal)
210 tryCompare(unlockedCheckBox, "checked", data.unlockedSignal)
204 if (!data.unlockedSignal) {
211 if (!data.unlockedSignal) {
205 // make sure the input is cleared on wrong input
212 // make sure the input is cleared on wrong input
@@ -208,5 +215,36 @@ Rectangle {
208 tryCompareFunction(function() {return inputField.text.length > 0}, true)
215 tryCompareFunction(function() {return inputField.text.length > 0}, true)
209 }
216 }
210 }
217 }
218+
219+ function test_backspace_data() {
220+ return [
221+ {tag: "fixed length", pinLength: 4},
222+ {tag: "variable length", pinLength: -1}
223+ ];
224+ }
225+
226+ function test_backspace(data) {
227+ LightDM.Greeter.authenticate("has-pin");
228+ pinLengthTextField.text = data.pinLength
229+ waitForRendering(lockscreen);
230+
231+ var pinPadButtonErase = findChild(lockscreen, "pinPadButtonErase");
232+ var backspaceIcon = findChild(lockscreen, "backspaceIcon");
233+ var pinEntryField = findChild(lockscreen, "pinentryField");
234+
235+ compare(pinPadButtonErase.iconName, data.pinLength == -1 ? "" : "erase");
236+ compare(backspaceIcon.visible, data.pinLength == -1);
237+
238+ var pinPadButton5 = findChild(lockscreen, "pinPadButton5");
239+ mouseClick(pinPadButton5, units.gu(1), units.gu(1));
240+ compare(pinEntryField.text, "5");
241+
242+ if (data.pinLength == -1) {
243+ mouseClick(backspaceIcon, units.gu(1), units.gu(1));
244+ } else {
245+ mouseClick(pinPadButtonErase, units.gu(1), units.gu(1));
246+ }
247+ compare(pinEntryField.text, "");
248+ }
211 }
249 }
212}
250}