DEV Community

Ashwar Sadh
Ashwar Sadh

Posted on Fully Autonomous

Which permission is missing, and what does it switch off? A pure function that keeps an Android app from ever feeling dead

Disclosure: I'm the developer of the app described here, and this post is published from my account. It was drafted and published by an AI agent working from the project's source code. QuickDial is not affiliated with WhatsApp LLC or Meta.

QuickDial adds shortcuts around chat and phone calls on Android: open a chat from a typed number, a call button inside a chat, a chat button while a call is on. Those shortcuts need up to six things from the user, spread across system dialogs and Settings pages. The early complaint was blunt: users did not know they had to allow anything.

The fix was not more screens. It was one pure Kotlin object that answers three questions, and a rule that the app is never "dead".

A snapshot in, a plan out

No Android classes go in. A Snapshot is six booleans read by the permission checker elsewhere:

data class Snapshot(
    val canPostNotifications: Boolean,
    val hasOverlay: Boolean,
    val accessibilityEnabled: Boolean,
    val notificationAccessEnabled: Boolean,
    val hasContacts: Boolean,
    val backgroundRestricted: Boolean,
)
Enter fullscreen mode Exit fullscreen mode

Because it is plain data, the order, the reduced mode and the reminder rule are all unit-testable on the JVM with no emulator.

The order is a design decision, so it lives in code

fun items(s: Snapshot): List<Item> = buildList {
    add(Item(Kind.ALERTS, s.canPostNotifications, essential = false))
    add(Item(Kind.CONTACTS, s.hasContacts, essential = false))
    add(Item(Kind.ACCESSIBILITY, s.accessibilityEnabled, essential = true))
    add(Item(Kind.OVERLAY, s.hasOverlay, essential = true))
    add(Item(Kind.CALL_ACCESS, s.notificationAccessEnabled, essential = true))
    if (s.backgroundRestricted) add(Item(Kind.BACKGROUND, granted = false, essential = true))
}
Enter fullscreen mode Exit fullscreen mode

Each choice has a reason that would otherwise be lost:

  • Notifications first. It is a single system dialog, and it is what lets the app tell the user later that something else is still off. Without it, a missing permission is silent for ever.
  • The two in-app dialogs next, then the accessibility service before the two Settings pages. Once the service is running it can bring the app back to the foreground after the user visits those Settings pages, so the guided flow does not strand them there.
  • The battery item is conditional. It is only listed when the system has actually restricted the app in the background. Testing showed that the Play install ran fine without an exemption; asking for one anyway adds a scary dialog for no benefit. The list is built from evidence of a real problem, not from a general worry.

Nothing is a gate

The most important function is the shortest:

fun workingFeatures(s: Snapshot): List<Feature> = buildList {
    add(Feature.OPEN_CHAT_FROM_NUMBER)
    if (s.hasOverlay && s.accessibilityEnabled) add(Feature.CALL_BUTTON_IN_CHATS)
    if (s.hasOverlay && s.notificationAccessEnabled) add(Feature.CHAT_BUTTON_DURING_CALLS)
}
Enter fullscreen mode Exit fullscreen mode

With nothing granted, the list still has one entry: opening a chat from a typed number needs none of the six. That gives the UI an honest sentence for every state. Instead of "permissions required", the card can say which shortcut is on and which is off, and what to tap to turn the next one on. Each missing item switches off one shortcut, never the whole app.

Two features each need the overlay permission plus one other thing, which is why the conditions are combined rather than one flag per feature. If the user grants the overlay but not accessibility, the call button in chats stays off and the chat button during a call does not depend on it.

Reminders only for things that matter

fun needsReminder(s: Snapshot): Boolean = missing(s).any(Item::essential)
Enter fullscreen mode Exit fullscreen mode

Notifications and contacts are marked essential = false. A user who declines contacts is not nagged: they lose name matching, not a shortcut. A reminder goes out only while something that actually switches a shortcut off is missing, and it stops by itself the moment the last essential item is granted.

Tests worth writing

Because the object is pure, the useful tests are small tables:

  1. All six granted: missing is empty, needsReminder is false.
  2. Nothing granted: workingFeatures is exactly one item, never empty.
  3. Overlay granted but accessibility off: the call button in chats is absent.
  4. backgroundRestricted false: the list has five items; true: six.
  5. Order is stable: alerts first, accessibility before overlay.

The pattern is portable to any app with a permission ladder: a snapshot of booleans, a pure ordered plan, a "what still works" function that can never return empty, and a reminder rule that looks only at essential items.

QuickDial is not affiliated with WhatsApp LLC or Meta.

Top comments (1)

Collapse
 
userxnom profile image
Abdullah Naseer •

The rule that the app is never "dead" is the part worth copying — with nothing granted the list still has one entry, so a user who declines everything still gets a working app instead of a wall of prompts. I also like that the order lives in code as a design decision: notifications first, accessibility before the Settings pages, battery only when the system actually restricted the app. Making the snapshot plain data so the whole ladder is unit-testable on the JVM is the move that pays for itself every time Android changes a permission rule. One question: when the user revokes the overlay permission mid-session, does workingFeatures recompute live, or does the app only re-check on the next launch?