Skip to content

Conversation

dsvf
Copy link
Contributor

@dsvf dsvf commented Nov 23, 2024

I find it difficult when switching between Server Box and other apps that the fingerprint auth activates immediately.

I implemented a delay, if switching away from Server Box and back to it within 10 seconds, then there is no auth request. I also added a setting under App/Android Setting and App/iOS Settings to enable and disable this behavior.

The Strings in the settings widget are hardcoded english since I did not want to add a second pull request to lppcg/fl_lib
Also, the 10 seconds are hardcoded and the "10" value in the settings subtitle is not synchronized with the delay in home.dart, since I'm not sure where and how you like to store a global constant in your project.

You are welcome to consider including this PR into the app.

Summary by Sourcery

Add an optional delay for biometric authentication when returning to the app shortly after backgrounding it.

New Features:

  • Introduce a setting to delay biometric auth lock for up to 10 seconds when switching back to the app
  • Add a new toggle for delayed bio auth lock in Android and iOS settings pages

Enhancements:

  • Track the app’s paused timestamp and conditionally skip authentication on resume if within the configured delay

@No06
Copy link
Collaborator

No06 commented Apr 22, 2025

perhaps could place this constant in PlatformPublicSettings?🤔

@lollipopkit lollipopkit mentioned this pull request Aug 16, 2025
Co-Authored-By: dsvf <philipp@dsvf.net>
@lollipopkit
Copy link
Owner

@sourcery-ai review

Copy link

sourcery-ai bot commented Aug 16, 2025

Reviewer's Guide

This PR adds a configurable delay before triggering biometric authentication by introducing a new setting toggle for a 10-second grace period and updating the app lifecycle handlers in HomePage to respect this delay.

Entity relationship diagram for new delayBioAuthLock setting property

Unable to render rich display

Could not find a suitable point for the given distance

For more information, see https://docs.github.com/get-started/writing-on-github/working-with-advanced-formatting/creating-diagrams#creating-mermaid-diagrams

erDiagram
    SETTING_STORE {
      bool useBioAuth
      bool delayBioAuthLock
      bool editorHighlight
    }
    SETTING_STORE ||--o| HOME_PAGE_STATE : uses

Class diagram for updated SettingStore and HomePageState

Loading
classDiagram
    class SettingStore {
      +useBioAuth: bool
      +delayBioAuthLock: bool
      +editorHighlight: bool
    }
    class _HomePageState {
      -_switchingPage: bool
      -_shouldAuth: bool
      -_pausedTime: DateTime?
      +dispose()
      +AppLifecycleState handler (updated)
    }
    SettingStore <.. _HomePageState : uses delayBioAuthLock

File-Level Changes

Change Details Files
Introduce delayBioAuthLock store property to track bio-auth delay setting
  • Add delayBioAuthLock using propertyDefault in SettingStore
lib/data/store/setting.dart
Add UI for toggling bio-auth delay in platform settings
  • Implement buildBioAuthDelay widget in PlatformPublicSettings
  • Inject buildBioAuthDelay into AndroidSettingsPage UI
  • Inject buildBioAuthDelay into IosSettingsPage UI
lib/view/page/setting/platform/platform_pub.dart
lib/view/page/setting/platform/android.dart
lib/view/page/setting/platform/ios.dart
Modify app lifecycle in HomePageState to conditionally delay biometric auth
  • Declare _pausedTime field
  • Record _pausedTime on AppLifecycleState.paused
  • On resumed, check delayBioAuthLock and time difference before calling _goAuth or resetting _shouldAuth
lib/view/page/home.dart

Possibly linked issues

  • Delay bio auth #642: The PR implements a delay for biometric authentication, adding a new setting and the corresponding logic.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `lib/view/page/home.dart:67` </location>
<code_context>
       case AppLifecycleState.resumed:
-        if (_shouldAuth) _goAuth();
+        if (_shouldAuth) {
+          if (Stores.setting.delayBioAuthLock.fetch() == true && _pausedTime != null) {
+            if (DateTime.now().difference(_pausedTime ?? DateTime.now()).inSeconds > 10) {
+              _goAuth();
+            } else {
</code_context>

<issue_to_address>
Consider extracting the delay duration into a configurable constant or setting.

Making the 10-second delay configurable will make future adjustments easier and enhance code maintainability.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
            if (DateTime.now().difference(_pausedTime ?? DateTime.now()).inSeconds > 10) {
              _goAuth();
            } else {
=======
            const int bioAuthLockDelaySeconds = 10; // Make this configurable as needed
            if (DateTime.now().difference(_pausedTime ?? DateTime.now()).inSeconds > bioAuthLockDelaySeconds) {
              _goAuth();
            } else {
>>>>>>> REPLACE

</suggested_fix>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@lollipopkit lollipopkit merged commit 4a7827f into lollipopkit:main Aug 17, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants