mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
allow toggling share with time code in dialog
This commit is contained in:
parent
fdacc32383
commit
58efe901d9
@ -7,6 +7,7 @@ import androidx.fragment.app.DialogFragment
|
||||
import com.github.libretube.PIPED_FRONTEND_URL
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.YOUTUBE_FRONTEND_URL
|
||||
import com.github.libretube.databinding.DialogShareBinding
|
||||
import com.github.libretube.db.DatabaseHolder
|
||||
import com.github.libretube.db.obj.CustomInstance
|
||||
import com.github.libretube.extensions.await
|
||||
@ -17,8 +18,9 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
class ShareDialog(
|
||||
private val id: String,
|
||||
private val isPlaylist: Boolean,
|
||||
private val position: Long = 0L
|
||||
private val position: Long? = null
|
||||
) : DialogFragment() {
|
||||
private var binding: DialogShareBinding? = null
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
var shareOptions = arrayOf(
|
||||
@ -30,6 +32,14 @@ class ShareDialog(
|
||||
// add instanceUrl option if custom instance frontend url available
|
||||
if (instanceUrl != "") shareOptions += getString(R.string.instance)
|
||||
|
||||
if (position != null) {
|
||||
binding = DialogShareBinding.inflate(layoutInflater)
|
||||
binding!!.timeCodeSwitch.isChecked = PreferenceHelper.getBoolean(
|
||||
PreferenceKeys.SHARE_WITH_TIME_CODE,
|
||||
true
|
||||
)
|
||||
}
|
||||
|
||||
return MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(context?.getString(R.string.share))
|
||||
.setItems(
|
||||
@ -43,11 +53,8 @@ class ShareDialog(
|
||||
}
|
||||
val path = if (!isPlaylist) "/watch?v=$id" else "/playlist?list=$id"
|
||||
var url = "$host$path"
|
||||
if (PreferenceHelper.getBoolean(
|
||||
PreferenceKeys.SHARE_WITH_TIME_CODE,
|
||||
true
|
||||
)
|
||||
) {
|
||||
|
||||
if (binding != null && binding!!.timeCodeSwitch.isChecked) {
|
||||
url += "?t=$position"
|
||||
}
|
||||
|
||||
@ -61,6 +68,7 @@ class ShareDialog(
|
||||
Intent.createChooser(intent, context?.getString(R.string.shareTo))
|
||||
)
|
||||
}
|
||||
.setView(binding?.root)
|
||||
.show()
|
||||
}
|
||||
|
||||
|
31
app/src/main/res/layout/dialog_share.xml
Normal file
31
app/src/main/res/layout/dialog_share.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="25dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UselessParent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/share_with_time" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/timeCodeSwitch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
@ -283,7 +283,7 @@
|
||||
<string name="error_occurred">Error</string>
|
||||
<string name="copied">Copied</string>
|
||||
<string name="downloadsucceeded">Download succeeded</string>
|
||||
<string name="share_with_time">Share with start time</string>
|
||||
<string name="share_with_time">Share with time code</string>
|
||||
<string name="export_subscriptions">Export Subscriptions</string>
|
||||
<string name="skip_buttons">Skip buttons</string>
|
||||
<string name="skip_buttons_summary">Show buttons to skip to the next or previous video.</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user