Merge pull request #959 from Bnyro/master

share with time code
This commit is contained in:
Bnyro 2022-08-03 13:50:32 +02:00 committed by GitHub
commit 3dc8edf954
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 3 deletions

View File

@ -13,7 +13,8 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
class ShareDialog(
private val id: String,
private val isPlaylist: Boolean
private val isPlaylist: Boolean,
private val position: Long = 0L
) : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
@ -39,7 +40,14 @@ class ShareDialog(
else -> instanceUrl
}
val path = if (!isPlaylist) "/watch?v=$id" else "/playlist?list=$id"
val url = "$host$path"
var url = "$host$path"
if (PreferenceHelper.getBoolean(
PreferenceKeys.SHARE_WITH_TIME_CODE,
true
)
) {
url += "?t=$position"
}
val intent = Intent()
intent.apply {

View File

@ -540,7 +540,7 @@ class PlayerFragment : Fragment() {
// share button
binding.relPlayerShare.setOnClickListener {
val shareDialog = ShareDialog(videoId!!, false)
val shareDialog = ShareDialog(videoId!!, false, exoPlayer.currentPosition)
shareDialog.show(childFragmentManager, "ShareDialog")
}

View File

@ -80,6 +80,7 @@ object PreferenceKeys {
const val CLEAR_SEARCH_HISTORY = "clear_search_history"
const val CLEAR_WATCH_HISTORY = "clear_watch_history"
const val CLEAR_WATCH_POSITIONS = "clear_watch_positions"
const val SHARE_WITH_TIME_CODE = "share_with_time_code"
/**
* Error logs

View File

@ -290,4 +290,5 @@
<string name="error_occurred">Error occurred</string>
<string name="copied">Copied</string>
<string name="downloadsucceeded">Download succeeded</string>
<string name="share_with_time">Share with time code</string>
</resources>

View File

@ -22,6 +22,16 @@
</PreferenceCategory>
<PreferenceCategory app:title="@string/share">
<SwitchPreferenceCompat
app:defaultValue="true"
app:icon="@drawable/ic_time"
app:key="share_with_time_code"
app:title="@string/share_with_time" />
</PreferenceCategory>
<PreferenceCategory app:title="@string/advanced">
<SwitchPreferenceCompat