mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30:31 +05:30
commit
e9d57e31dd
@ -688,19 +688,36 @@ class PlayerFragment : Fragment() {
|
||||
view.findViewById<LinearLayout>(R.id.relPlayer_share).setOnClickListener {
|
||||
val sharedPreferences =
|
||||
PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
val intent = Intent()
|
||||
intent.action = Intent.ACTION_SEND
|
||||
var url = "https://piped.kavin.rocks/watch?v=$videoId"
|
||||
val instance = sharedPreferences.getString(
|
||||
val instancePref = sharedPreferences.getString(
|
||||
"instance",
|
||||
"https://pipedapi.kavin.rocks"
|
||||
)!!
|
||||
if (instance != "https://pipedapi.kavin.rocks")
|
||||
url += "&instance=${URLEncoder.encode(instance, "UTF-8")}"
|
||||
val instance = "&instance=${URLEncoder.encode(instancePref, "UTF-8")}"
|
||||
val shareOptions = arrayOf(
|
||||
getString(R.string.piped),
|
||||
getString(R.string.instance),
|
||||
getString(R.string.youtube)
|
||||
)
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(getString(R.string.share))
|
||||
.setItems(
|
||||
shareOptions,
|
||||
DialogInterface.OnClickListener { _, id ->
|
||||
val url = when (id) {
|
||||
0 -> "https://piped.kavin.rocks/watch?v=$videoId"
|
||||
1 -> "https://piped.kavin.rocks/watch?v=$videoId$instance"
|
||||
2 -> "https://youtu.be/$videoId"
|
||||
else -> "https://piped.kavin.rocks/watch?v=$videoId"
|
||||
}
|
||||
val intent = Intent()
|
||||
intent.action = Intent.ACTION_SEND
|
||||
intent.putExtra(Intent.EXTRA_TEXT, url)
|
||||
intent.type = "text/plain"
|
||||
startActivity(Intent.createChooser(intent, "Share Url To:"))
|
||||
}
|
||||
)
|
||||
.show()
|
||||
}
|
||||
// check if livestream
|
||||
if (response.duration!! > 0) {
|
||||
// download clicked
|
||||
|
@ -113,4 +113,6 @@
|
||||
<string name="app_icon">App Icon</string>
|
||||
<string name="enabled">Enabled</string>
|
||||
<string name="disabled">Disabled</string>
|
||||
<string name="piped">Piped</string>
|
||||
<string name="youtube">YouTube</string>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user