Urgent.News

What's breaking now, across thousands of outlets.

Tech

Building StareBrain, Part 18: Auto-Collapse — The Overlay That Knows When to Hide

Building StareBrain, Part 18: Auto-Collapse — The Overlay That Knows When to Hide Part 17 covered drag-to-reposition. Today we tackle the other half of staying out of the way: auto-collapse. The overlay has three states — Idle, Running, AwaitingConfirmation. What we hadn't solved was when to transition between them based on what the user is doing, not just what the task is doing. If a step…

In this section of the StareBrain building process, the focus is on implementing an auto-collapse feature for the overlay. The overlay has three states: Idle, Running, and AwaitingConfirmation. The challenge lies in determining when to transition between these states based on user activity rather than just task activity. If a step completes while the user is typing in another app, expanding the overlay mid-keystroke would be incorrect.

To address this, an auto-collapse mechanism is introduced, which shrinks the overlay to a dot when the user is actively interacting with another app and expands it only when necessary attention is required. The implementation relies on an AccessibilityService that tracks user interactions using events such as focus changes, window changes, and text input.

A UserInteractionTracker class keeps track of the last interaction timestamp and whether the user is considered active. If there is no interaction for 3 seconds, the user is considered inactive. The CollapseController class then uses this information to decide whether to collapse the overlay based on task state and user activity.

Brief written by urgent.news from Dev.to's own syndicated text. Machine-written — may contain errors; check the original before relying on it.

This story

This is one outlet's version. Read the fullest account.

Read the original at dev.to →

More in Tech

32.3 million WhatsApp users in Malaysia face malware threat

AN estimated 32.3 million WhatsApp users in Malaysia could be exposed to cyberattacks involving malicious files designed to infiltrate smartphones, steal personal information and gain access to…

  • 32.3 million Malaysian WhatsApp users at malware risk
  • Cybercriminals exploit trusted contacts to infect devices
  • Disable auto-downloads, verify messages, activate 2-step verification

Markdown vs. JSON: Which Response Format Should You Use?

When using APIs to get search results, the format you choose can impact how easily your application uses that data. Markdown and JSON both let you work with search results, but they're designed for…

  • Markdown format is ideal for readability and reasoning with data
  • JSON format is suited for processing and manipulating data
  • Both Markdown and JSON supported by SerpApi APIs

More from Sunday 8 November →