Merge pull request #74 from FireMasterK/share-button

Improve share button instance preference.
This commit is contained in:
Farbod 2022-03-17 23:18:29 -07:00 committed by GitHub
commit 3fc2056a0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
@ -388,9 +389,14 @@ class PlayerFragment : Fragment() {
}
//share button
view.findViewById<RelativeLayout>(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:"))
}