on xenial help sign in
implement dualsim pin unlock dialog.
52e1e56Antti Kaijanmäki
qml/Components/Lockscreen.qml+3
@@ -81,6 +81,9 @@ Showable {
81
81
82 function showInfoPopup(title, text) {
82 function showInfoPopup(title, text) {
83 PopupUtils.open(infoPopupComponent, root, {title: title, text: text})
83 PopupUtils.open(infoPopupComponent, root, {title: title, text: text})
84+ /// FIXME: calling infoPopupConfirmed() here to get the signaling right
85+ /// even though the popup it self does not work
86+ infoPopupConfirmed()
84 }
87 }
85
88
86 Timer {
89 Timer {
qml/Notifications/NotificationMenuItemFactory.qml+77−5
@@ -19,6 +19,7 @@
19
19
20import QtQuick 2.0
20import QtQuick 2.0
21import Ubuntu.Components 0.1
21import Ubuntu.Components 0.1
22+import QMenuModel 0.1
22import "../Components"
23import "../Components"
23
24
24Loader {
25Loader {
@@ -26,7 +27,7 @@ Loader {
26
27
27 property QtObject menuModel: null
28 property QtObject menuModel: null
28 property QtObject menuData: null
29 property QtObject menuData: null
29− property int menuIndex
30+ property int menuIndex : -1
30 property int maxHeight
31 property int maxHeight
31 readonly property bool fullscreen: menuData.type === "com.canonical.snapdecision.pinlock"
32 readonly property bool fullscreen: menuData.type === "com.canonical.snapdecision.pinlock"
32
33
@@ -46,6 +47,13 @@ Loader {
46 }
47 }
47 }
48 }
48
49
50+ function getExtendedProperty(object, propertyName, defaultValue) {
51+ if (object && object.hasOwnProperty(propertyName)) {
52+ return object[propertyName];
53+ }
54+ return defaultValue;
55+ }
56+
49 Component {
57 Component {
50 id: textfield
58 id: textfield
51
59
@@ -117,14 +125,14 @@ Loader {
117 right: parent.right
125 right: parent.right
118 }
126 }
119 height: menuFactory.maxHeight
127 height: menuFactory.maxHeight
120− infoText: i18n.tr("Enter SIM PIN")
128+ infoText: notification.summary
121− errorText: i18n.tr("Sorry, incorrect PIN")
129+ errorText: errorAction.valid ? errorAction.state : ""
122− minPinLength: 4
130+ retryText: notification.body
123− maxPinLength: 8
124 background: shell.background
131 background: shell.background
125
132
126 onEntered: {
133 onEntered: {
127 menuModel.changeState(menuIndex, passphrase);
134 menuModel.changeState(menuIndex, passphrase);
135+ clear(false);
128 }
136 }
129
137
130 onCancel: {
138 onCancel: {
@@ -135,6 +143,70 @@ Loader {
135 shell.activateApplication("dialer-app")
143 shell.activateApplication("dialer-app")
136 menuModel.activate(menuIndex, false)
144 menuModel.activate(menuIndex, false)
137 }
145 }
146+
147+ property var extendedData: menuData && menuData.ext || undefined
148+
149+ property var pinMinMaxAction : UnityMenuAction {
150+ model: menuModel
151+ index: menuIndex
152+ name: getExtendedProperty(extendedData, "xCanonicalPinMinMax", "")
153+
154+ onStateChanged: {
155+ var min = pinMinMaxAction.state[0];
156+ var max = pinMinMaxAction.state[1];
157+
158+ if (min === 0) min = -1;
159+ if (max === 0) max = -1;
160+
161+ minPinLength = min
162+ maxPinLength = max
163+ }
164+ }
165+
166+ property var popupAction: UnityMenuAction {
167+ model: menuModel
168+ index: menuIndex
169+ name: getExtendedProperty(extendedData, "xCanonicalPinPopup", "")
170+ onStateChanged: {
171+ if (state !== "")
172+ showInfoPopup("", state);
173+ }
174+ }
175+ onInfoPopupConfirmed: {
176+ popupAction.activate();
177+ }
178+
179+ Timer {
180+ id: errorTimer
181+ interval: 4000;
182+ running: false;
183+ repeat: false
184+ onTriggered: {
185+ errorAction.activate();
186+ }
187+ }
188+ property var errorAction: UnityMenuAction {
189+ model: menuModel
190+ index: menuIndex
191+ name: getExtendedProperty(extendedData, "xCanonicalPinError", "")
192+ onStateChanged: {
193+ errorText = state;
194+ if (state !== "") {
195+ clear(true);
196+ errorTimer.running = true;
197+ }
198+ }
199+ }
200+
201+ function loadAttributes() {
202+ if (!menuModel || menuIndex == -1) return;
203+ menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-pin-min-max': 'string',
204+ 'x-canonical-pin-popup': 'string',
205+ 'x-canonical-pin-error': 'string'});
206+ }
207+ Component.onCompleted: {
208+ loadAttributes();
209+ }
138 }
210 }
139 }
211 }
140}
212}