mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 14:20:30 +05:30
Customize the share time code
This commit is contained in:
parent
b8b3159362
commit
f7dacbb9bb
@ -3,6 +3,7 @@ package com.github.libretube.ui.dialogs
|
||||
import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.constants.PIPED_FRONTEND_URL
|
||||
@ -33,11 +34,7 @@ class ShareDialog(
|
||||
if (instanceUrl != "") shareOptions += getString(R.string.instance)
|
||||
|
||||
if (shareObjectType == ShareObjectType.VIDEO && position != null) {
|
||||
binding = DialogShareBinding.inflate(layoutInflater)
|
||||
binding?.timeCodeSwitch?.isChecked = PreferenceHelper.getBoolean(
|
||||
PreferenceKeys.SHARE_WITH_TIME_CODE,
|
||||
true
|
||||
)
|
||||
setupTimeStampBinding()
|
||||
}
|
||||
|
||||
return MaterialAlertDialogBuilder(requireContext())
|
||||
@ -59,7 +56,7 @@ class ShareDialog(
|
||||
var url = "$host$path"
|
||||
|
||||
if (shareObjectType == ShareObjectType.VIDEO && binding!!.timeCodeSwitch.isChecked) {
|
||||
url += "&t=$position"
|
||||
url += "&t=${binding!!.timeStamp.text}"
|
||||
}
|
||||
|
||||
val intent = Intent()
|
||||
@ -76,6 +73,19 @@ class ShareDialog(
|
||||
.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
|
||||
private fun getCustomInstanceFrontendUrl(): String {
|
||||
val instancePref = PreferenceHelper.getString(
|
||||
|
@ -1,15 +1,14 @@
|
||||
<?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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="vertical">
|
||||
|
||||
<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">
|
||||
|
||||
@ -28,4 +27,22 @@
|
||||
|
||||
</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="recentlyUpdatedReversed">Recently updated (reversed)</string>
|
||||
<string name="show_more">Show more</string>
|
||||
<string name="time_code">Time code</string>
|
||||
|
||||
<!-- Notification channel strings -->
|
||||
<string name="download_channel_name">Download Service</string>
|
||||
|
Loading…
Reference in New Issue
Block a user