From 3e3cccbb15eec77c80c373ab12ee7108656e0499 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Wed, 16 Mar 2022 16:34:02 +0000 Subject: [PATCH] Improve share button instance preference. --- app/src/main/java/com/github/libretube/PlayerFragment.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/PlayerFragment.kt b/app/src/main/java/com/github/libretube/PlayerFragment.kt index e196000db..8bc578ca8 100644 --- a/app/src/main/java/com/github/libretube/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/PlayerFragment.kt @@ -28,6 +28,7 @@ import androidx.core.net.toUri import androidx.core.os.bundleOf import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope +import androidx.preference.PreferenceManager import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView import com.github.libretube.adapters.TrendingAdapter @@ -367,9 +368,14 @@ class PlayerFragment : Fragment() { } //share button view.findViewById(R.id.relPlayer_share).setOnClickListener { + val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext()) val intent= Intent() intent.action=Intent.ACTION_SEND - intent.putExtra(Intent.EXTRA_TEXT, "https://piped.tokhmi.xyz/$videoId") + var url = "https://piped.kavin.rocks/watch?v=$videoId" + val instance = sharedPreferences.getString("instance", "https://pipedapi.kavin.rocks/")!!.dropLast(1) + if (instance != "https://pipedapi.kavin.rocks") + url += "&instance=$instance" + intent.putExtra(Intent.EXTRA_TEXT, url) intent.type="text/plain" startActivity(Intent.createChooser(intent,"Share Url To:")) }