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 { binding.appIcon.setOnClickListener {
val sendIntent = Intent().apply { val sendIntent = Intent(Intent.ACTION_SEND)
action = Intent.ACTION_SEND .putExtra(Intent.EXTRA_TEXT, GITHUB_URL)
putExtra(Intent.EXTRA_TEXT, GITHUB_URL) .setType("text/plain")
type = "text/plain" startActivity(Intent.createChooser(sendIntent, null))
}
val shareIntent = Intent.createChooser(sendIntent, null)
startActivity(shareIntent)
} }
setupCard(binding.website, WEBSITE_URL) setupCard(binding.website, WEBSITE_URL)

View File

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