Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
64de77b
feat: Google Messages New conversation and New group UI
an1ndra Dec 1, 2026
db9b28c
fix: match the live Google Messages start-chat visuals
an1ndra Dec 1, 2026
0148604
feat: Add group name step and Google Messages search states
an1ndra Dec 1, 2026
dca9066
fix: match Google Messages' naming step and short-code subtitles
an1ndra Dec 1, 2026
f3a4bb5
fix: align the group naming step pixel for pixel with Google Messages
an1ndra Dec 1, 2026
ab27b68
fix: match Google Messages' New conversation rows and three-avatar na…
an1ndra Dec 1, 2026
a204f1e
fix: give the group picker GM's rows and both pickers its initials
an1ndra Dec 1, 2026
45d5712
fix: match Google Messages in dark theme and its chip gestures
an1ndra Dec 2, 2026
0cc60a6
fix: group the suggestion cards the way Google Messages does
an1ndra Dec 2, 2026
442691b
fix: keep the To caret and outline it in dark, and stack group initials
an1ndra Dec 2, 2026
a2fd3f2
feat: rebuild group threads when importing a backup
an1ndra Dec 2, 2026
dca35dc
fix: seat the recipient avatar inside its pill and show the pill in dark
an1ndra Dec 2, 2026
2c280c7
fix: drop the email promise from the start-chat hints
an1ndra Dec 2, 2026
dad45fc
fix: create the group on Done and show three or four initials
an1ndra Dec 2, 2026
215322d
fix: wait a frame before refocusing the picker field
an1ndra Dec 2, 2026
cde5bc1
test: pin the group screens to Material colour roles
an1ndra Dec 2, 2026
1cd6b2e
Merge remote-tracking branch 'origin/Develop' into feat/google-messag…
an1ndra Dec 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import com.anindra.messages.ui.LocationDialog
import com.anindra.messages.ui.MessageDetailsDialog
import com.anindra.messages.ui.OwnerAvatar
import com.anindra.messages.ui.ScheduleDialog
import com.anindra.messages.ui.ConversationAvatar
import com.anindra.messages.ui.PersonAvatar
import com.anindra.messages.ui.ProvideShimmer
import com.anindra.messages.ui.RowPosition
Expand Down Expand Up @@ -258,6 +259,33 @@ private fun AvatarsAndBadgesPreview() {
}
}

@PreviewLightDark
@Preview(name = "Conversation avatars", showBackground = true, widthDp = 380)
@Composable
private fun ConversationAvatarsPreview() {
Stage() {
Row(verticalAlignment = Alignment.CenterVertically) {
ConversationAvatar(
name = "Alex, Mom, Bank",
address = "+15551230001",
modifier = Modifier.padding(end = 10.dp)
)
ConversationAvatar(
name = "Alex, Mom",
address = "+15551230002",
groupTitle = "Weekend",
modifier = Modifier.padding(end = 10.dp)
)
ConversationAvatar(
name = "Prize Team",
address = "+15551230003",
modifier = Modifier.padding(end = 10.dp)
)
ConversationAvatar(name = "+15551230004", address = "+15551230004")
}
}
}

@PreviewLightDark
@Preview(name = "Avatars (large touch)", showBackground = true, widthDp = 380)
@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.anindra.messages.ui.previews

import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.tooling.preview.PreviewLightDark
import com.anindra.messages.ui.GroupNameScreen
import com.anindra.messages.ui.theme.MessagesTheme

@PreviewLightDark
@Preview(name = "Add group name", showBackground = true, widthDp = 380, heightDp = 760)
@Composable
private fun AddGroupNamePreview() {
MessagesTheme(mode = "system") {
GroupNameScreen(
addresses = listOf("+15551230001", "+15551230002", "+15551230003"),
onDone = {},
onBack = {}
)
}
}
57 changes: 57 additions & 0 deletions app/src/main/java/com/anindra/messages/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ import com.anindra.messages.ui.SettingsJump
import com.anindra.messages.ui.InboxCategoryRulesScreen
import com.anindra.messages.ui.ScheduledMessagesScreen
import com.anindra.messages.ui.NewChatScreen
import com.anindra.messages.ui.GroupNameScreen
import com.anindra.messages.ui.NewGroupScreen
import com.anindra.messages.ui.AboutScreen
import com.anindra.messages.ui.SettingsScreen
import com.anindra.messages.ui.AdvancedSettingsScreen
Expand Down Expand Up @@ -218,6 +220,9 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
contactsObserver = observer
}

/** Reads Contacts again after the permission dialog answers. */
fun reloadContacts() = loadContacts()

private fun loadContacts() {
val ctx = getApplication<Application>()
scope.launch(kotlinx.coroutines.Dispatchers.IO) {
Expand Down Expand Up @@ -965,6 +970,14 @@ class AppViewModel(app: Application) : AndroidViewModel(app) {
* thread, so the private history between the two stays put. [onReady]
* receives the group's conversation id.
*/
/** New group: create the thread from the picked people and open it. */
fun createGroup(addresses: List<String>, onReady: (Long) -> Unit) {
scope.launch(Dispatchers.IO) {
val id = repo.createGroup(addresses)
withContext(Dispatchers.Main) { if (id > 0) onReady(id) }
}
}

fun finishAddPeople(conversationId: Long, addresses: List<String>, onReady: (Long) -> Unit) {
scope.launch(Dispatchers.IO) {
val id = if (repo.isGroup(conversationId)) {
Expand Down Expand Up @@ -1546,6 +1559,12 @@ open class MainActivity : FragmentActivity() {
val repo = (application as MessagesApplication).repository
if (repo.needsInitialImport) repo.requeryFromSystem()
}
// The contacts role is asked for on the screen that needs it, after
// the ViewModel's first read; without this the new-chat pickers stay
// empty until a contacts change or a restart (#405 follow-up).
if (grants[Manifest.permission.READ_CONTACTS] == true) {
androidx.lifecycle.ViewModelProvider(this)[AppViewModel::class.java].reloadContacts()
}
if (Build.VERSION.SDK_INT >= 33 &&
grants[Manifest.permission.POST_NOTIFICATIONS] == false
) {
Expand All @@ -1565,6 +1584,10 @@ open class MainActivity : FragmentActivity() {
}

private var navRoute by androidx.compose.runtime.mutableStateOf("list")
// A group created from the New group picker waits on the naming screen
// before the chat opens.
/** The people picked in the group picker, carried into the naming step. */
private var namingAddresses by androidx.compose.runtime.mutableStateOf(listOf<String>())
private var pendingOpenAddress by androidx.compose.runtime.mutableStateOf<String?>(null)
private var pendingOpenConversationId by androidx.compose.runtime.mutableStateOf<Long?>(null)
private var pendingShareBody by androidx.compose.runtime.mutableStateOf("")
Expand Down Expand Up @@ -2051,6 +2074,8 @@ open class MainActivity : FragmentActivity() {
"trash" -> navRoute = "settings"
"inbox" -> navRoute = "settings"
"inbox-rules" -> navRoute = "inbox"
"new-group" -> navRoute = "new"
"group-name" -> navRoute = "new-group"
"notif-settings" -> navRoute = "advanced"
"auto-delete" -> navRoute = "advanced"
"links" -> navRoute = "advanced"
Expand All @@ -2064,6 +2089,8 @@ open class MainActivity : FragmentActivity() {

val routeDepth = mapOf("list" to 0, "opening" to 0, "chat" to 1, "details" to 2, "new" to 1, "settings" to 1, "trash" to 2, "spam" to 2, "inbox" to 2, "inbox-rules" to 3,
"advanced" to 2, "about" to 2, "accessibility" to 3,
"new-group" to 2,
"group-name" to 2,
"notif-settings" to 3, "auto-delete" to 3, "links" to 3,
"transfer-log" to 3,
"add-people" to 3, "mms-check" to 3, "scheduled" to 2)
Expand Down Expand Up @@ -2190,8 +2217,38 @@ open class MainActivity : FragmentActivity() {
chatSearchQuery = null
navRoute = "chat"
}
},
onNewGroup = { navRoute = "new-group" }
)
"new-group" -> NewGroupScreen(
vm = vm,
initialChosen = namingAddresses,
onBack = {
namingAddresses = emptyList()
navRoute = "new"
},
onCreate = { addresses ->
// Next only remembers the people: the
// thread is created when the name step
// is finished, so Back can return to
// the picker with the chips still set.
namingAddresses = addresses
navRoute = "group-name"
}
)
"group-name" -> GroupNameScreen(
addresses = namingAddresses,
onDone = { name ->
vm.createGroup(namingAddresses) { id ->
if (name.isNotBlank()) vm.setGroupTitle(id, name)
namingAddresses = emptyList()
chatId = id
chatSearchQuery = null
navRoute = "chat"
}
},
onBack = { navRoute = "new-group" }
)
"settings" -> if (useNewUi) SettingsScreen(
vm = vm,
onBack = { navRoute = "list" },
Expand Down
38 changes: 38 additions & 0 deletions app/src/main/java/com/anindra/messages/data/ImportGroups.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.anindra.messages.data

/**
* Rebuilding a backup's group threads.
*
* An MMS record carries one sender, its shipping addresses and the exporting
* phone's thread id. Every message in a group names the same people, so the
* union of sender and recipients (minus this device's own numbers) is the
* group. Dropping our own number matters: an outbound MMS lists us among its
* recipients, and a group that includes ourselves is not a group.
*/
object ImportGroups {

/** The people on the thread, order-independent. Empty or one means 1:1. */
fun members(
sender: String,
recipients: List<String>,
ownNumbers: List<String>
): List<String> {
val own = ownNumbers.map(::token).filter { it.isNotEmpty() }.toSet()
val people = LinkedHashSet<String>()
for (raw in listOf(sender) + recipients) {
val value = raw.trim()
if (value.isEmpty()) continue
val t = token(value)
if (t.isNotEmpty() && t in own) continue
people += value
}
return people.sortedBy(::token)
}

/** A stable identity for a participant set, formatting-independent. */
fun key(members: List<String>): String =
members.map(::token).sorted().joinToString("\u001f")

private fun token(address: String): String =
address.filter(Char::isDigit).ifEmpty { address.trim().lowercase() }
}
108 changes: 106 additions & 2 deletions app/src/main/java/com/anindra/messages/data/Repository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,38 @@ class Repository(private val context: Context) {
*
* Returns the new conversation id, or -1 if it could not be created.
*/
/**
* Creates a group from the New group picker: no 1:1 conversation exists
* yet, so the first address becomes the thread's primary and everyone else
* a recipient. A 1:1 with the first person is left untouched.
*/
fun createGroup(addresses: List<String>): Long = runOnIo {
val wanted = addresses.map { canonical(it).ifEmpty { it.trim() } }
.filter { it.isNotEmpty() }
.distinct()
if (wanted.size < 2) return@runOnIo -1L
val primary = wanted.first()
val cv = ContentValues().apply {
put("address", primary)
put("name", "")
put("snippet", "")
put("timestamp", System.currentTimeMillis())
put("last_is_me", 0)
}
val newId = db.writableDatabase.insert("conversations", null, cv)
if (newId <= 0) return@runOnIo -1L
for (a in wanted) {
upsertParticipant(db.writableDatabase, a)
db.writableDatabase.execSQL(
"INSERT OR IGNORE INTO conversation_recipients(conversation_id, address) VALUES(?,?)",
arrayOf(newId, a)
)
}
ensureGroupTitle(newId)
notifyChanged()
newId
}

fun createGroupFrom(conversationId: Long, addresses: List<String>): Long = runOnIo {
val primaryRow = db.readableDatabase.rawQuery(
"SELECT address, name FROM conversations WHERE id=?", arrayOf(conversationId.toString())
Expand Down Expand Up @@ -3402,6 +3434,24 @@ class Repository(private val context: Context) {
}
}

// Existing groups, keyed by their participant set, so a merge import
// files straight back into the thread the user already has.
val groupIds = HashMap<String, Long>()
run {
val byConversation = HashMap<Long, MutableList<String>>()
database.rawQuery(
"SELECT conversation_id, address FROM conversation_recipients", null
).use { c ->
while (c.moveToNext()) {
byConversation.getOrPut(c.getLong(0)) { mutableListOf() } += c.getString(1)
}
}
byConversation.forEach { (id, people) ->
if (people.size > 1) groupIds.putIfAbsent(ImportGroups.key(people), id)
}
}
val ownNumbers = ownNumbersBlocking()

val batch = ArrayList<SmsIeBackup.Message>(IMPORT_BATCH)
var added = 0
var seen = 0
Expand All @@ -3425,6 +3475,7 @@ class Repository(private val context: Context) {
val baseConflicts = LinkedHashMap(conflicts)
val baseKnown = HashSet(known)
val baseByAddress = HashMap(byAddress)
val baseGroupIds = HashMap(groupIds)
val outcome = TransferRetry.run {
added = baseAdded
skipped = baseSkipped
Expand All @@ -3434,12 +3485,50 @@ class Repository(private val context: Context) {
known.addAll(baseKnown)
byAddress.clear()
byAddress.putAll(baseByAddress)
groupIds.clear()
groupIds.putAll(baseGroupIds)
database.beginTransaction()
try {
for (msg in rows) {
val address = canonical(msg.address).ifEmpty { msg.address }
var cid = byAddress[address] ?: byAddress[msg.address]
if (cid == null) {
val group = if (msg.isMms) {
ImportGroups.members(msg.address, msg.recipients, ownNumbers)
} else {
emptyList()
}
val groupKey = if (group.size > 1) ImportGroups.key(group) else null
val threadKey = if (groupKey != null && msg.threadId > 0) {
"thread:${msg.threadId}"
} else {
null
}
var cid: Long? = if (groupKey != null) {
groupIds[groupKey] ?: threadKey?.let { groupIds[it] }
} else {
byAddress[address] ?: byAddress[msg.address]
}
if (cid == null && groupKey != null) {
// A thread from another phone has no usable address,
// so the first member stands in for it; the group's
// identity is the participant set.
cid = database.insert("conversations", null, ContentValues().apply {
put("address", group.first())
put("name", "")
})
if (cid <= 0) {
skipped++
conflicts.count(Conflict.CONVERSATION_UNRESOLVED)
continue
}
for (person in group) {
database.execSQL(
"INSERT OR IGNORE INTO conversation_recipients(conversation_id, address) VALUES(?,?)",
arrayOf(cid, person)
)
upsertParticipant(database, person)
}
ensureGroupTitle(cid)
} else if (cid == null) {
cid = database.insert("conversations", null, ContentValues().apply {
put("address", address)
put("name", contactNameFor(address) ?: address)
Expand All @@ -3450,6 +3539,19 @@ class Repository(private val context: Context) {
continue
}
byAddress[address] = cid
} else if (groupKey != null) {
// The thread may have gained a member since its first
// message; keep the roster complete.
for (person in group) {
database.execSQL(
"INSERT OR IGNORE INTO conversation_recipients(conversation_id, address) VALUES(?,?)",
arrayOf(cid, person)
)
}
}
if (groupKey != null) {
groupIds[groupKey] = cid
threadKey?.let { groupIds[it] = cid }
}
val transport = if (msg.isMms) MmsSupport.TRANSPORT_MMS else MmsSupport.TRANSPORT_SMS
val key = messageKey(address, msg.timestamp, msg.isMe, msg.body, transport)
Expand All @@ -3468,6 +3570,8 @@ class Repository(private val context: Context) {
put("transport", transport)
put("media_type", if (image != null) "image" else "text")
put("media_uri", if (image != null) storeImportedImage(image, msg) else "")
// In a group bubble the sender is what labels it.
if (groupKey != null && !msg.isMe) put("address", msg.address)
})
if (row <= 0) {
skipped++
Expand Down
Loading