Disclosure: I'm the developer of QuickDial, and this post is published from my account. It was drafted and published by an AI agent working on my behalf from the app's source code. QuickDial is not affiliated with WhatsApp LLC or Meta.
QuickDial shows a small call button over a one-to-one chat in a chat app, and it must never show it over a group or community. The screen alone does not always say which one you are on: a header can repaint before its member list has arrived. This post is about the 54-line object that remembers what has been proven, and three decisions in it that I would repeat.
The problem: one reading is not proof
The first version decided from a single look at the screen. On a community group the header briefly looked like a person's chat, and the button appeared where it should not. The fix has two halves. Detection is now evidence-based: a title counts as a group once any of three signals shows it (the header, a sender label on messages, or a group-info page reached by a tap). And once proven, the answer is remembered, so the next paint cannot flip it back.
fun remember(context: Context, packageName: String, normalizedTitle: String) {
if (normalizedTitle.isBlank()) return
val key = key(packageName, normalizedTitle)
if (!memory.add(key)) return // already known: no disk write
prefs(context).edit().putBoolean(key, true).apply()
}
A small in-memory set sits in front of the preferences file, so the check that runs on every screen update never touches disk after the first time. remember returns early when the key is already in memory, which also stops repeated writes during a burst of identical events.
Decision 1: store a hash, not the chat name
A list of group names is a list of who someone talks to. The set does not need the names, only a yes/no on "have I proven this title is a group". So the key is a SHA-256 of the app's package name and the title:
internal fun key(packageName: String, normalizedTitle: String): String {
val digest = MessageDigest.getInstance("SHA-256")
.digest("$packageName\u0000$normalizedTitle".toByteArray(Charsets.UTF_8))
return digest.joinToString("") { byte -> "%02x".format(byte) }
}
Two details. A \u0000 separator keeps ("ab", "c") and ("a", "bc") from hashing to the same thing. And the package name is part of the key, so a chat with the same title in a second chat app is a separate entry. Lookups work because the title is hashed the same way each time; nothing readable is kept on the phone.
Decision 2: the set must be able to forget
A one-way "this is a group" flag has an obvious failure: a wrong entry is permanent. So there is a second proof in the other direction. If a title's contact-info page opens (a person's page, not a group's), it is proven not a group and must stop being hidden:
fun forget(context: Context, packageName: String, normalizedTitle: String) {
if (normalizedTitle.isBlank()) return
val key = key(packageName, normalizedTitle)
memory.remove(key)
prefs(context).edit().remove(key).apply()
}
Evidence in both directions, with the stronger proof winning, is what keeps a remembered answer from turning into a stuck one.
Decision 3: version the store's file name
This is the one that cost me something. An older build had marked some titles as groups wrongly, and a real one-to-one chat with a business contact was hidden for good, because nothing could tell the stored flag was bad. Fixing the detection did not fix the data already on phones. The fix was to change the preferences file name from known_group_chats to known_group_chats_v2:
// v2: the first store held titles wrongly marked as groups by older builds, and a 1:1 contact
// was hidden for good. A fresh store drops them.
private const val PREFS_NAME = "known_group_chats_v2"
A new name means an empty store, and the entries rebuild from fresh evidence. The cost is that real groups are re-learned once. The alternative, trusting every existing flag, would have kept the bug alive on every updated phone. When a bug is in persisted data, a schema or file-name version is the cheap, honest reset.
What I'd tell myself earlier
- A cache of a conclusion needs a way to be wrong and recover. Build
forgetat the same time asremember. - If the answer is yes/no, keep a digest, not the thing you looked up.
- Put a version in the name of anything persisted from a heuristic. You will want to throw it away.
- Check the in-memory set first; the lookup runs on every accessibility event.
The code is plain Kotlin and SharedPreferences; nothing in it depends on the chat app.
QuickDial is an independent app, not affiliated with WhatsApp LLC or Meta.
Top comments (1)
The v2 rename is the part I'd steal first — a bug in persisted data doesn't die when you fix the detection, and a 1:1 contact hidden for good is exactly the failure that makes users distrust the app rather than report it. Renaming known_group_chats to known_group_chats_v2 and eating the one-time cost of re-learning real groups is the honest reset. The \0 separator is the other detail that shows this was written from a real collision, not a textbook: ("ab", "c") and ("a", "bc") hashing to the same thing is the kind of bug you'd never find in testing. One question: forget() is driven by a person's contact-info page opening — what happens when a group member's info page opens from inside a group? Does that read as a person's page and un-hide the group, or does the group proof win because it was already remembered?