Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

White or black screen before app go's to recent #6

Open
dhorajiaabhishek opened this issue May 17, 2020 · 5 comments
Open

White or black screen before app go's to recent #6

dhorajiaabhishek opened this issue May 17, 2020 · 5 comments
Labels
enhancement New feature or request
Milestone

Comments

@dhorajiaabhishek
Copy link

Hey can we have feature where white or black screen before app go's to recent or stay in recent .
you can check this app, it has this feature.
https://play.google.com/store/apps/details?id=ru.alexandermalikov.protectednotes

thanx for this lib

@dhorajiaabhishek dhorajiaabhishek changed the title White or black screen before app go's to resent White or black screen before app go's to recent May 17, 2020
@tomalabaster
Copy link
Owner

Ah yes, good idea. Will give it a look.

@tomalabaster
Copy link
Owner

Right now this package only uses Dart code. I can't see a way of achieving this without adding in method channels as after the Flutter application lifecycle enters an inactive or paused state it won't call build methods until it's resumed again.

It's a trade off I'm going to have to consider.

@tomalabaster tomalabaster added the enhancement New feature or request label May 20, 2020
@tomalabaster
Copy link
Owner

Just revisited this, not sure when it was introduced or if I even checked how possible this was way back when but it looks like this is now possible..! Will add this in to the API

@tomalabaster tomalabaster added this to the 4.1.0 milestone Dec 30, 2023
tomalabaster added a commit that referenced this issue Dec 30, 2023
tomalabaster added a commit that referenced this issue Dec 30, 2023
tomalabaster added a commit that referenced this issue Dec 30, 2023
tomalabaster added a commit that referenced this issue Dec 30, 2023
tomalabaster added a commit that referenced this issue Dec 30, 2023
tomalabaster added a commit that referenced this issue Dec 30, 2023
@tomalabaster
Copy link
Owner

tomalabaster commented Dec 30, 2023

Good news! Version 4.1.0 Version 4.1.1 has some work in to support this feature.

inactiveBuilder allows the app utilising AppLock to provide a screen to be shown then the app is in an inactive state. See here for an example.

The conditions which need to be met for the inactive screen to be shown are:

  • AppLock is enabled, either using the enabled property on the AppLock widget or calling AppLock.of(context)!.enable()/AppLock.of(context)!.setEnabled(true)
  • inactiveBuilder is set on the AppLock widget
  • The app enters an "inactive" state which gets triggered from the WidgetsBindingObserver.didChangeAppLifecycleState method (on iOS and Android known ways are by opening the app switcher or notification centre while the app is open)
  • The app isn't already locked

You can see tests confirming this behaviour here.

Less good news is that the Android behaviour isn't consistent with iOS... On Android, if you press the home button and then view the app switcher, the app before the inactive screen is shown.

Scenario iOS outcome Android outcome Other platforms
App is open and unlocked, device home button pressed, app switcher opened Inactive screen shown ✅ Inactive screen may flicker as app is dismissing, app switcher shows app as it was before pressing the home button ❌ Untested ➖
App is open and unlocked, device app switcher is opened Inactive screen shown ✅ Inactive screen shown ✅ Untested ➖
App is open and unlocked, device notification centre is opened Inactive screen shown ✅ Inactive screen shown ✅ Untested ➖
App is open and unlocked, device app switcher is opened, device home button pressed, app switcher opened Inactive screen shown ✅ Inactive screen shown ✅ Untested ➖
App is open and unlocked, device notification centre is opened, device home button pressed, app switcher opened Inactive screen shown ✅ Inactive screen shown ✅ Untested ➖
App is open and already locked, any of the above scenarios repeated Lock screen continues to show ✅ Lock screen continues to show ✅ Untested ➖

I'll keep monitoring this issue, your milage may vary. My testing on Android was on a Pixel 4 emulator running Android 14 (build UPB1.230309.013).

@coalacorey
Copy link

coalacorey commented Jul 31, 2024

Just an additional comment regarding a scenario where the app is unlocked and the device itself is locked (i.e. power button pressed / screen timeout).
On an iOS simulator the InactiveScreen is shown (if configured) before the device locks. On device unlock the screen transitions from InactiveScreen to LockScreen. On a real device the ScreenContent is visible after device unlock and then the LockScreen is shown.
On Android there is also a split second where the ContentScreen is shown before the app is locked because the inactive screen . This can be fixed by setting
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
in the MainActivity because then instead of the previous opened screen a black screen is visible in that split second.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants