Merge pull request #3183 from Isira-Seneviratne/Intent_method_chaining

Use Intent method chaining.
This commit is contained in:
Bnyro 2023-02-25 09:42:14 +01:00 committed by GitHub
commit 8e603464d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 21 deletions

View File

@ -33,14 +33,10 @@ class AboutActivity : BaseActivity() {
}
binding.appIcon.setOnClickListener {
val sendIntent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, GITHUB_URL)
type = "text/plain"
}
val shareIntent = Intent.createChooser(sendIntent, null)
startActivity(shareIntent)
val sendIntent = Intent(Intent.ACTION_SEND)
.putExtra(Intent.EXTRA_TEXT, GITHUB_URL)
.setType("text/plain")
startActivity(Intent.createChooser(sendIntent, null))
}
setupCard(binding.website, WEBSITE_URL)

View File

@ -45,9 +45,7 @@ class ShareDialog(
return MaterialAlertDialogBuilder(requireContext())
.setTitle(context?.getString(R.string.share))
.setItems(
shareOptions
) { _, which ->
.setItems(shareOptions) { _, which ->
val host = when (which) {
0 -> PIPED_FRONTEND_URL
1 -> YOUTUBE_FRONTEND_URL
@ -65,16 +63,12 @@ class ShareDialog(
url += "&t=${binding!!.timeStamp.text}"
}
val intent = Intent()
intent.apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_TEXT, url)
putExtra(Intent.EXTRA_SUBJECT, shareableTitle)
type = "text/plain"
}
context?.startActivity(
Intent.createChooser(intent, context?.getString(R.string.shareTo))
)
val intent = Intent(Intent.ACTION_SEND)
.putExtra(Intent.EXTRA_TEXT, url)
.putExtra(Intent.EXTRA_SUBJECT, shareableTitle)
.setType("text/plain")
val shareIntent = Intent.createChooser(intent, getString(R.string.shareTo))
requireContext().startActivity(shareIntent)
}
.setView(binding?.root)
.show()