@@ -158,59 +158,83 @@ Pane {
158158 }
159159
160160 RowLayout {
161+ Layout .columnSpan : 2
161162 Layout .fillWidth : true
162163 spacing: 0
164+ // isAvailable checks phone support and if a fingerprint is enrolled on the system
165+ enabled: Biometrics .isAvailable && Daemon .currentWallet
166+
167+ Connections {
168+ target: Biometrics
169+ function onEnablingFailed (error ) {
170+ if (error === ' CANCELLED' ) {
171+ return // don't show error popup
172+ }
173+ var err = app .messageDialog .createObject (app, {
174+ text: qsTr (' Failed to enable biometric authentication: ' ) + error
175+ })
176+ err .open ()
177+ }
178+ }
179+
163180 Switch {
164- id: usePin
165- checked: Config . pinCode
181+ id: useBiometrics
182+ checked: Biometrics . isEnabled
166183 onCheckedChanged: {
167184 if (activeFocus) {
168- console . log ( ' PIN active ' + checked)
185+ useBiometrics . focus = false
169186 if (checked) {
170- var dialog = pinSetup .createObject (preferences, {mode: ' enter' })
171- dialog .accepted .connect (function () {
172- Config .pinCode = dialog .pincode
173- dialog .close ()
174- })
175- dialog .rejected .connect (function () {
176- checked = false
177- })
178- dialog .open ()
187+ if (Daemon .singlePasswordEnabled ) {
188+ Biometrics .enable (Daemon .singlePassword )
189+ } else {
190+ useBiometrics .checked = false
191+ var err = app .messageDialog .createObject (app, {
192+ title: qsTr (' Unavailable' ),
193+ text: [
194+ qsTr (" Cannot activate biometric authentication because you have wallets with different passwords." ),
195+ qsTr (" To use biometric authentication you first need to change all wallet passwords to the same password." )
196+ ].join (" \n " )
197+ })
198+ err .open ()
199+ }
179200 } else {
180- focus = false
181- Config .pinCode = ' '
182- // re-add binding, pincode still set if auth failed
183- checked = Qt .binding (function () { return Config .pinCode })
201+ Biometrics .disableProtected ()
184202 }
185203 }
186-
187204 }
188205 }
189206 Label {
190207 Layout .fillWidth : true
191- text: qsTr (' PIN protect payments ' )
208+ text: qsTr (' Biometric authentication ' )
192209 wrapMode: Text .Wrap
193210 }
194211 }
195212
196- Pane {
197- background: Rectangle { color: Material .dialogColor }
198- padding: 0
199- visible: Config .pinCode != ' '
200- FlatButton {
201- text: qsTr (' Modify' )
202- onClicked: {
203- var dialog = pinSetup .createObject (preferences, {
204- mode: ' change' ,
205- pincode: Config .pinCode
206- })
207- dialog .accepted .connect (function () {
208- Config .pinCode = dialog .pincode
209- dialog .close ()
210- })
211- dialog .open ()
213+ RowLayout {
214+ Layout .columnSpan : 2
215+ Layout .fillWidth : true
216+ spacing: 0
217+
218+ property bool noWalletPassword: Daemon .currentWallet ? Daemon .currentWallet .verifyPassword (' ' ) : true
219+ enabled: Daemon .currentWallet && ! noWalletPassword
220+
221+ Switch {
222+ id: paymentAuthentication
223+ // showing the toggle as checked even if the wallet has no password would be misleading
224+ checked: Config .paymentAuthentication && ! (Daemon .currentWallet && parent .noWalletPassword )
225+ onCheckedChanged: {
226+ if (activeFocus) {
227+ // will request authentication when checked = false
228+ console .log (' paymentAuthentication: ' + checked)
229+ Config .paymentAuthentication = checked;
230+ }
212231 }
213232 }
233+ Label {
234+ Layout .fillWidth : true
235+ text: qsTr (' Payment authentication' )
236+ wrapMode: Text .Wrap
237+ }
214238 }
215239
216240 RowLayout {
@@ -462,11 +486,6 @@ Pane {
462486 }
463487 }
464488
465- Component {
466- id: pinSetup
467- Pin {}
468- }
469-
470489 Component .onCompleted : {
471490 language .currentIndex = language .indexOfValue (Config .language )
472491 baseUnit .currentIndex = _baseunits .indexOf (Config .baseUnit )
0 commit comments