Skip to content

Commit 7dd4366

Browse files
committed
fix(shareable): headline the group's name, not the invitation
EXTRA_TITLE carried the invitation sentence, so the Sharesheet drew it as the headline directly above the same sentence as the first line of the body — and truncated it there, the headline being a single line. The group's name is what that slot is for. EXTRA_SUBJECT keeps the sentence. It is an email's subject line rather than a headline sitting above a body, so there is nothing to repeat.
1 parent 6edcf08 commit 7dd4366

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

‎apps/flipcash/shared/shareable/src/main/kotlin/com/flipcash/app/shareable/ShareSheetController.kt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ sealed interface Shareable {
5454
*/
5555
data class GroupInvite(
5656
val url: String,
57-
// The group's name, which the invitation sentence names. Null or blank shares the bare link.
57+
// The group's name: the Sharesheet's headline, and what the invitation sentence names.
58+
// Null or blank shares the bare link, with no headline.
5859
val title: String? = null,
5960
/**
6061
* The group's picture, as a download URL, for the Sharesheet's preview thumbnail. Null for

‎apps/flipcash/shared/shareable/src/main/kotlin/com/flipcash/app/shareable/internal/InternalShareSheetController.kt‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,8 @@ internal class InternalShareSheetController(
303303
// link rather than an invitation with a hole in it. Blank counts as no name: an untitled
304304
// group reaches this as "" via ChatSubject.Group.title. Same wording as iOS'
305305
// GroupInviteShareItem, which trims and checks the same way.
306-
val invitation = shareable.title
307-
?.takeIf { it.isNotBlank() }
308-
?.let { resources.getString(R.string.message_groupInvite, it.trim()) }
306+
val name = shareable.title?.takeIf { it.isNotBlank() }?.trim()
307+
val invitation = name?.let { resources.getString(R.string.message_groupInvite, it) }
309308

310309
// The group's own picture as the Sharesheet's thumbnail, so the invite is recognisable
311310
// before it is sent. Best-effort: no picture, a slow fetch or an expired URL all share
@@ -316,10 +315,14 @@ internal class InternalShareSheetController(
316315

317316
val intent = Intent().apply {
318317
action = Intent.ACTION_SEND
319-
invitation?.let {
320-
putExtra(Intent.EXTRA_TITLE, it)
321-
putExtra(Intent.EXTRA_SUBJECT, it)
322-
}
318+
// The headline above the Sharesheet's preview. The group's name, not the invitation:
319+
// the sentence is already the first line of the body directly beneath it, and the
320+
// headline is one truncated line, so putting it in both says the name twice and cuts
321+
// it off once.
322+
name?.let { putExtra(Intent.EXTRA_TITLE, it) }
323+
// EXTRA_SUBJECT is an email's subject line rather than a preview headline, so the
324+
// invitation belongs here — it reads as the message it is, with no body beside it.
325+
invitation?.let { putExtra(Intent.EXTRA_SUBJECT, it) }
323326
putExtra(
324327
Intent.EXTRA_TEXT,
325328
if (invitation != null) "$invitation\n\n${shareable.url}" else shareable.url

‎apps/flipcash/shared/shareable/src/test/kotlin/com/flipcash/app/shareable/internal/ShareGroupInviteTest.kt‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ class ShareGroupInviteTest {
4545
"Join Book Club on Flipcash and let's chat\n\nhttps://app.flipcash.com/chat/abc",
4646
sent.getStringExtra(Intent.EXTRA_TEXT)
4747
)
48-
assertEquals(
49-
"Join Book Club on Flipcash and let's chat",
50-
sent.getStringExtra(Intent.EXTRA_TITLE)
51-
)
48+
// The headline names the group; repeating the sentence there would show it twice, once
49+
// truncated. The subject is an email's, where the sentence is the message.
50+
assertEquals("Book Club", sent.getStringExtra(Intent.EXTRA_TITLE))
5251
assertEquals(
5352
"Join Book Club on Flipcash and let's chat",
5453
sent.getStringExtra(Intent.EXTRA_SUBJECT)

0 commit comments

Comments
 (0)