AppScrollDetector

Core detector that monitors scrolling behavior and triggers interventions.

This object manages the state machine for doom scrolling detection:

  • WARN1: After 10 minutes of scrolling, shows first warning
  • WARN2: After 5 more minutes, shows second warning
  • LOCK: After 5 more minutes, locks the app for 15 minutes

Features:

  • Whitelist support - certain apps bypass monitoring
  • Inactivity detection - resets if user stops scrolling
  • Grace period - allows 2-minute breaks without resetting
  • One-minute unlock - users can unlock for 1 minute during lock

See also

Functions

Link copied to clipboard

Gets the formatted warning time for display in messages.

Link copied to clipboard
fun onAppForeground(context: Context, pkg: String)

Called when a monitored app comes to foreground. Checks if app is locked and shows lock overlay if needed.

Link copied to clipboard
fun onAppGone()

Called when the user leaves a monitored app. Pauses all timers and tracks when the app was left.

Link copied to clipboard
fun onAppScrolled(context: Context, pkg: String)

Called when scrolling is detected in a monitored app.

Link copied to clipboard
fun setTimingConfig(warn1: Long, warn2: Long, lockAfter: Long, lockTime: Long, inactivity: Long, returnGrace: Long, reentryEarly: Long, graceBonus: Long)

Configures timing parameters for warnings and locks.

Link copied to clipboard

Sets the whitelist of package names that should not trigger monitoring.