mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 00:10:32 +05:30
Merge pull request #1563 from Bnyro/master
Customize the share time code
This commit is contained in:
commit
e26afc3564
@ -3,6 +3,7 @@ package com.github.libretube.ui.dialogs
|
|||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.View
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.constants.PIPED_FRONTEND_URL
|
import com.github.libretube.constants.PIPED_FRONTEND_URL
|
||||||
@ -33,11 +34,7 @@ class ShareDialog(
|
|||||||
if (instanceUrl != "") shareOptions += getString(R.string.instance)
|
if (instanceUrl != "") shareOptions += getString(R.string.instance)
|
||||||
|
|
||||||
if (shareObjectType == ShareObjectType.VIDEO && position != null) {
|
if (shareObjectType == ShareObjectType.VIDEO && position != null) {
|
||||||
binding = DialogShareBinding.inflate(layoutInflater)
|
setupTimeStampBinding()
|
||||||
binding?.timeCodeSwitch?.isChecked = PreferenceHelper.getBoolean(
|
|
||||||
PreferenceKeys.SHARE_WITH_TIME_CODE,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return MaterialAlertDialogBuilder(requireContext())
|
return MaterialAlertDialogBuilder(requireContext())
|
||||||
@ -59,7 +56,7 @@ class ShareDialog(
|
|||||||
var url = "$host$path"
|
var url = "$host$path"
|
||||||
|
|
||||||
if (shareObjectType == ShareObjectType.VIDEO && binding!!.timeCodeSwitch.isChecked) {
|
if (shareObjectType == ShareObjectType.VIDEO && binding!!.timeCodeSwitch.isChecked) {
|
||||||
url += "&t=$position"
|
url += "&t=${binding!!.timeStamp.text}"
|
||||||
}
|
}
|
||||||
|
|
||||||
val intent = Intent()
|
val intent = Intent()
|
||||||
@ -76,6 +73,19 @@ class ShareDialog(
|
|||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setupTimeStampBinding() {
|
||||||
|
binding = DialogShareBinding.inflate(layoutInflater)
|
||||||
|
binding!!.timeCodeSwitch.isChecked = PreferenceHelper.getBoolean(
|
||||||
|
PreferenceKeys.SHARE_WITH_TIME_CODE,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
binding!!.timeCodeSwitch.setOnCheckedChangeListener { _, isChecked ->
|
||||||
|
binding!!.timeStampLayout.visibility = if (isChecked) View.VISIBLE else View.GONE
|
||||||
|
}
|
||||||
|
binding!!.timeStamp.setText(position.toString())
|
||||||
|
if (binding!!.timeCodeSwitch.isChecked) binding!!.timeStampLayout.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
// get the frontend url if it's a custom instance
|
// get the frontend url if it's a custom instance
|
||||||
private fun getCustomInstanceFrontendUrl(): String {
|
private fun getCustomInstanceFrontendUrl(): String {
|
||||||
val instancePref = PreferenceHelper.getString(
|
val instancePref = PreferenceHelper.getString(
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="25dp"
|
android:layout_marginHorizontal="25dp"
|
||||||
android:layout_marginBottom="15dp"
|
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
tools:ignore="UselessParent">
|
tools:ignore="UselessParent">
|
||||||
|
|
||||||
@ -28,4 +27,22 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:visibility="gone"
|
||||||
|
android:id="@+id/timeStampLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="25dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginBottom="25dp"
|
||||||
|
android:hint="@string/time_code">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/timeStamp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="number" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -346,6 +346,7 @@
|
|||||||
<string name="recentlyUpdated">Recently updated</string>
|
<string name="recentlyUpdated">Recently updated</string>
|
||||||
<string name="recentlyUpdatedReversed">Recently updated (reversed)</string>
|
<string name="recentlyUpdatedReversed">Recently updated (reversed)</string>
|
||||||
<string name="show_more">Show more</string>
|
<string name="show_more">Show more</string>
|
||||||
|
<string name="time_code">Time code</string>
|
||||||
|
|
||||||
<!-- Notification channel strings -->
|
<!-- Notification channel strings -->
|
||||||
<string name="download_channel_name">Download Service</string>
|
<string name="download_channel_name">Download Service</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user