From 337d2a32d8f166888c3bfa7974d08af5a7a9c47d Mon Sep 17 00:00:00 2001 From: ThomasV Date: Thu, 16 Mar 2023 09:11:48 +0100 Subject: [PATCH] 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 --- electrum/gui/qml/components/Preferences.qml | 2 +- electrum/gui/qml/components/main.qml | 32 --------------------- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/electrum/gui/qml/components/Preferences.qml b/electrum/gui/qml/components/Preferences.qml index 2dbefa60b..bc090c9ea 100644 --- a/electrum/gui/qml/components/Preferences.qml +++ b/electrum/gui/qml/components/Preferences.qml @@ -191,7 +191,7 @@ Pane { } Label { Layout.fillWidth: true - text: qsTr('PIN') + text: qsTr('PIN protect payments') wrapMode: Text.Wrap } } diff --git a/electrum/gui/qml/components/main.qml b/electrum/gui/qml/components/main.qml index ae5b59150..adc334025 100644 --- a/electrum/gui/qml/components/main.qml +++ b/electrum/gui/qml/components/main.qml @@ -485,9 +485,6 @@ ApplicationWindow } } - property var _lastCorrectPinTime: 0 - property int _pinValidSeconds: 5*60 - function handleAuthRequired(qtobject, method) { console.log('auth using method ' + method) if (method == 'wallet') { @@ -513,14 +510,8 @@ ApplicationWindow // no PIN configured qtobject.authProceed() } 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}) dialog.accepted.connect(function() { - _lastCorrectPinTime = Date.now() qtobject.authProceed() dialog.close() }) @@ -538,27 +529,4 @@ ApplicationWindow property var _lastActive: 0 // record time of last activity 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 - } - } - } - }