mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 14:50:30 +05:30
Merge pull request #1168 from Bnyro/master
Toggle for sharing with time code
This commit is contained in:
commit
3afdb9feaf
@ -29,21 +29,17 @@ class AddToPlaylistDialog : DialogFragment() {
|
||||
private lateinit var token: String
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return activity?.let {
|
||||
videoId = arguments?.getString("videoId")!!
|
||||
val builder = MaterialAlertDialogBuilder(it)
|
||||
// Get the layout inflater
|
||||
binding = DialogAddtoplaylistBinding.inflate(layoutInflater)
|
||||
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
||||
|
||||
token = PreferenceHelper.getToken()
|
||||
|
||||
if (token != "") fetchPlaylists()
|
||||
|
||||
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
||||
|
||||
builder.setView(binding.root)
|
||||
builder.create()
|
||||
} ?: throw IllegalStateException("Activity cannot be null")
|
||||
return MaterialAlertDialogBuilder(requireContext())
|
||||
.setView(binding.root)
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun fetchPlaylists() {
|
||||
|
@ -23,8 +23,6 @@ class CreatePlaylistDialog : DialogFragment() {
|
||||
private lateinit var binding: DialogCreatePlaylistBinding
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return activity?.let {
|
||||
val builder = MaterialAlertDialogBuilder(it)
|
||||
binding = DialogCreatePlaylistBinding.inflate(layoutInflater)
|
||||
|
||||
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
||||
@ -46,9 +44,9 @@ class CreatePlaylistDialog : DialogFragment() {
|
||||
}
|
||||
}
|
||||
|
||||
builder.setView(binding.root)
|
||||
builder.create()
|
||||
} ?: throw IllegalStateException("Activity cannot be null")
|
||||
return MaterialAlertDialogBuilder(requireContext())
|
||||
.setView(binding.root)
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun createPlaylist(name: String) {
|
||||
|
@ -16,8 +16,6 @@ class CustomInstanceDialog : DialogFragment() {
|
||||
private lateinit var binding: DialogCustomInstanceBinding
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return activity?.let {
|
||||
val builder = MaterialAlertDialogBuilder(it)
|
||||
binding = DialogCustomInstanceBinding.inflate(layoutInflater)
|
||||
|
||||
binding.cancel.setOnClickListener {
|
||||
@ -67,8 +65,8 @@ class CustomInstanceDialog : DialogFragment() {
|
||||
|
||||
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
||||
|
||||
builder.setView(binding.root)
|
||||
builder.create()
|
||||
} ?: throw IllegalStateException("Activity cannot be null")
|
||||
return MaterialAlertDialogBuilder(requireContext())
|
||||
.setView(binding.root)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,6 @@ class DeleteAccountDialog : DialogFragment() {
|
||||
private lateinit var binding: DialogDeleteAccountBinding
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return activity?.let {
|
||||
val builder = MaterialAlertDialogBuilder(it)
|
||||
binding = DialogDeleteAccountBinding.inflate(layoutInflater)
|
||||
|
||||
binding.cancelButton.setOnClickListener {
|
||||
@ -37,9 +35,9 @@ class DeleteAccountDialog : DialogFragment() {
|
||||
|
||||
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
||||
|
||||
builder.setView(binding.root)
|
||||
builder.create()
|
||||
} ?: throw IllegalStateException("Activity cannot be null")
|
||||
return MaterialAlertDialogBuilder(requireContext())
|
||||
.setView(binding.root)
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun deleteAccount(password: String) {
|
||||
|
@ -28,8 +28,6 @@ class DownloadDialog(
|
||||
private lateinit var binding: DialogDownloadBinding
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return activity?.let {
|
||||
val builder = MaterialAlertDialogBuilder(it)
|
||||
binding = DialogDownloadBinding.inflate(layoutInflater)
|
||||
|
||||
fetchAvailableSources()
|
||||
@ -48,9 +46,9 @@ class DownloadDialog(
|
||||
binding.videoSpinner.visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
builder.setView(binding.root)
|
||||
builder.create()
|
||||
} ?: throw IllegalStateException("Activity cannot be null")
|
||||
return MaterialAlertDialogBuilder(requireContext())
|
||||
.setView(binding.root)
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun fetchAvailableSources() {
|
||||
|
@ -21,9 +21,6 @@ class LoginDialog : DialogFragment() {
|
||||
private lateinit var binding: DialogLoginBinding
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return activity?.let {
|
||||
val builder = MaterialAlertDialogBuilder(it)
|
||||
// Get the layout inflater
|
||||
binding = DialogLoginBinding.inflate(layoutInflater)
|
||||
|
||||
binding.login.setOnClickListener {
|
||||
@ -52,9 +49,9 @@ class LoginDialog : DialogFragment() {
|
||||
|
||||
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
||||
|
||||
builder.setView(binding.root)
|
||||
builder.create()
|
||||
} ?: throw IllegalStateException("Activity cannot be null")
|
||||
return MaterialAlertDialogBuilder(requireContext())
|
||||
.setView(binding.root)
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun login(login: Login) {
|
||||
|
@ -14,8 +14,6 @@ class LogoutDialog : DialogFragment() {
|
||||
private lateinit var binding: DialogLogoutBinding
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return activity?.let {
|
||||
val builder = MaterialAlertDialogBuilder(it)
|
||||
binding = DialogLogoutBinding.inflate(layoutInflater)
|
||||
|
||||
val user = PreferenceHelper.getUsername()
|
||||
@ -31,8 +29,8 @@ class LogoutDialog : DialogFragment() {
|
||||
|
||||
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
||||
|
||||
builder.setView(binding.root)
|
||||
builder.create()
|
||||
} ?: throw IllegalStateException("Activity cannot be null")
|
||||
return MaterialAlertDialogBuilder(requireContext())
|
||||
.setView(binding.root)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
class RequireRestartDialog : DialogFragment() {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return activity?.let {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
return MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.require_restart)
|
||||
.setMessage(R.string.require_restart_message)
|
||||
.setPositiveButton(R.string.okay) { _, _ ->
|
||||
@ -19,7 +18,6 @@ class RequireRestartDialog : DialogFragment() {
|
||||
ThemeHelper.restartMainActivity(requireContext())
|
||||
}
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.create()
|
||||
} ?: throw IllegalStateException("Activity cannot be null")
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
@ -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,11 +18,11 @@ 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 {
|
||||
return activity?.let {
|
||||
var shareOptions = arrayOf(
|
||||
getString(R.string.piped),
|
||||
getString(R.string.youtube)
|
||||
@ -31,7 +32,15 @@ class ShareDialog(
|
||||
// add instanceUrl option if custom instance frontend url available
|
||||
if (instanceUrl != "") shareOptions += getString(R.string.instance)
|
||||
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
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(
|
||||
shareOptions
|
||||
@ -44,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"
|
||||
}
|
||||
|
||||
@ -62,8 +68,8 @@ class ShareDialog(
|
||||
Intent.createChooser(intent, context?.getString(R.string.shareTo))
|
||||
)
|
||||
}
|
||||
.setView(binding?.root)
|
||||
.show()
|
||||
} ?: throw IllegalStateException("Activity cannot be null")
|
||||
}
|
||||
|
||||
// get the frontend url if it's a custom instance
|
||||
|
@ -18,8 +18,7 @@ class UpdateDialog(
|
||||
) : DialogFragment() {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return activity?.let {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
return MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(context?.getString(R.string.update_available, updateInfo.name))
|
||||
.setMessage(context?.getString(R.string.update_now))
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
@ -37,8 +36,7 @@ class UpdateDialog(
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
.create()
|
||||
} ?: throw IllegalStateException("Activity cannot be null")
|
||||
.show()
|
||||
}
|
||||
|
||||
private fun getDownloadUrl(updateInfo: UpdateInfo): String? {
|
||||
|
@ -37,6 +37,13 @@ class VideoOptionsDialog(
|
||||
context?.getString(R.string.share)
|
||||
)
|
||||
|
||||
// remove the add to playlist option if not logged in
|
||||
if (PreferenceHelper.getToken() == "") {
|
||||
optionsList.remove(
|
||||
context?.getString(R.string.addToPlaylist)
|
||||
|
||||
)
|
||||
}
|
||||
/**
|
||||
* Check whether the player is running by observing the notification
|
||||
*/
|
||||
|
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…
Reference in New Issue
Block a user