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