on xenial help sign in
implement dualsim pin unlock dialog.
commit52e1e5673d76a435cdeff36f37d402c109309e86 authorAntti Kaijanmäki <antti.kaijanmaki@canonical.com> dateFri 29 Aug 2014, 11:07 (12 years ago) parent1fbc843
2 files changed+80−5
qml/Components/Lockscreen.qml+3 qml/Notifications/NotificationMenuItemFactory.qml+77−5
qml/Components/Lockscreen.qml+3
@@ -81,6 +81,9 @@ Showable {
8181
8282 function showInfoPopup(title, text) {
8383 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()
8487 }
8588
8689 Timer {
qml/Notifications/NotificationMenuItemFactory.qml+77−5
@@ -19,6 +19,7 @@
1919
2020import QtQuick 2.0
2121import Ubuntu.Components 0.1
22+import QMenuModel 0.1
2223import "../Components"
2324
2425Loader {
@@ -26,7 +27,7 @@ Loader {
2627
2728 property QtObject menuModel: null
2829 property QtObject menuData: null
29− property int menuIndex
30+ property int menuIndex : -1
3031 property int maxHeight
3132 readonly property bool fullscreen: menuData.type === "com.canonical.snapdecision.pinlock"
3233
@@ -46,6 +47,13 @@ Loader {
4647 }
4748 }
4849
50+ function getExtendedProperty(object, propertyName, defaultValue) {
51+ if (object && object.hasOwnProperty(propertyName)) {
52+ return object[propertyName];
53+ }
54+ return defaultValue;
55+ }
56+
4957 Component {
5058 id: textfield
5159
@@ -117,14 +125,14 @@ Loader {
117125 right: parent.right
118126 }
119127 height: menuFactory.maxHeight
120− infoText: i18n.tr("Enter SIM PIN")
121− errorText: i18n.tr("Sorry, incorrect PIN")
122− minPinLength: 4
123− maxPinLength: 8
128+ infoText: notification.summary
129+ errorText: errorAction.valid ? errorAction.state : ""
130+ retryText: notification.body
124131 background: shell.background
125132
126133 onEntered: {
127134 menuModel.changeState(menuIndex, passphrase);
135+ clear(false);
128136 }
129137
130138 onCancel: {
@@ -135,6 +143,70 @@ Loader {
135143 shell.activateApplication("dialer-app")
136144 menuModel.activate(menuIndex, false)
137145 }
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+ }
138210 }
139211 }
140212}