Commit 1ee0243e authored by David Walsh's avatar David Walsh Committed by Jeff Boek
Browse files

Fix 4021 - Provide tab title during share

parent c556e819
......@@ -7,6 +7,7 @@ package org.mozilla.fenix.share
import android.content.Context
import android.content.Intent
import android.content.Intent.ACTION_SEND
import android.content.Intent.EXTRA_SUBJECT
import android.content.Intent.EXTRA_TEXT
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.net.Uri
......@@ -80,6 +81,7 @@ class DefaultShareController(
override fun handleShareToApp(app: AppShareOption) {
val intent = Intent(ACTION_SEND).apply {
putExtra(EXTRA_TEXT, getShareText())
putExtra(EXTRA_SUBJECT, shareData.map { it.title }.joinToString(", "))
type = "text/plain"
flags = FLAG_ACTIVITY_NEW_TASK
setClassName(app.packageName, app.activityName)
......@@ -161,8 +163,8 @@ class DefaultShareController(
}
@VisibleForTesting
fun getShareText() = shareData.joinToString("\n") { data ->
listOfNotNull(data.url, data.text).joinToString(" ")
fun getShareText() = shareData.joinToString("\n\n") { data ->
listOfNotNull(data.title, data.url).joinToString(" ")
}
// Navigation between app fragments uses ShareTab as arguments. SendTabUseCases uses TabData.
......
......@@ -57,7 +57,7 @@ class ShareControllerTest {
TabData("title0", "url0"),
TabData("title1", "url1")
)
private val textToShare = "${shareData[0].url}\n${shareData[1].url}"
private val textToShare = "${shareData[0].title} ${shareData[0].url}\n\n${shareData[1].title} ${shareData[1].url}"
private val sendTabUseCases = mockk<SendTabUseCases>(relaxed = true)
private val snackbar = mockk<FenixSnackbar>(relaxed = true)
private val navController = mockk<NavController>(relaxed = true)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment