qml PIN: do not lock inactive app, and remove timeout
- the activity callback does not work properly on android (does not work on my phone). Also, it duplicates the lock screen function of most phones. - if we do not lock inactive app, then the PIN feature does not need a timeout, and is easier to understand without it. - in Preferences, explain what it does
This commit is contained in:
@@ -191,7 +191,7 @@ Pane {
|
|||||||
}
|
}
|
||||||
Label {
|
Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: qsTr('PIN')
|
text: qsTr('PIN protect payments')
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -485,9 +485,6 @@ ApplicationWindow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property var _lastCorrectPinTime: 0
|
|
||||||
property int _pinValidSeconds: 5*60
|
|
||||||
|
|
||||||
function handleAuthRequired(qtobject, method) {
|
function handleAuthRequired(qtobject, method) {
|
||||||
console.log('auth using method ' + method)
|
console.log('auth using method ' + method)
|
||||||
if (method == 'wallet') {
|
if (method == 'wallet') {
|
||||||
@@ -513,14 +510,8 @@ ApplicationWindow
|
|||||||
// no PIN configured
|
// no PIN configured
|
||||||
qtobject.authProceed()
|
qtobject.authProceed()
|
||||||
} else {
|
} else {
|
||||||
if (Date.now() - _lastCorrectPinTime <= _pinValidSeconds * 1000) {
|
|
||||||
// correct pin entered recently, accept.
|
|
||||||
qtobject.authProceed()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
var dialog = app.pinDialog.createObject(app, {mode: 'check', pincode: Config.pinCode})
|
var dialog = app.pinDialog.createObject(app, {mode: 'check', pincode: Config.pinCode})
|
||||||
dialog.accepted.connect(function() {
|
dialog.accepted.connect(function() {
|
||||||
_lastCorrectPinTime = Date.now()
|
|
||||||
qtobject.authProceed()
|
qtobject.authProceed()
|
||||||
dialog.close()
|
dialog.close()
|
||||||
})
|
})
|
||||||
@@ -538,27 +529,4 @@ ApplicationWindow
|
|||||||
property var _lastActive: 0 // record time of last activity
|
property var _lastActive: 0 // record time of last activity
|
||||||
property bool _lockDialogShown: false
|
property bool _lockDialogShown: false
|
||||||
|
|
||||||
onActiveChanged: {
|
|
||||||
console.log('app active = ' + active)
|
|
||||||
if (active) {
|
|
||||||
if (!_lastActive) {
|
|
||||||
_lastActive = Date.now()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// activated
|
|
||||||
if (Date.now() - _lastCorrectPinTime > _pinValidSeconds * 1000) {
|
|
||||||
if (_lockDialogShown || Config.pinCode == '')
|
|
||||||
return
|
|
||||||
var dialog = app.pinDialog.createObject(app, {mode: 'check', canCancel: false, pincode: Config.pinCode})
|
|
||||||
dialog.accepted.connect(function() {
|
|
||||||
_lastCorrectPinTime = Date.now()
|
|
||||||
dialog.close()
|
|
||||||
_lockDialogShown = false
|
|
||||||
})
|
|
||||||
dialog.open()
|
|
||||||
_lockDialogShown = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user