mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-01-06 01:20:29 +05:30
Merge pull request #1503 from Bnyro/master
Rename files when downloading + indicate when comments are available
This commit is contained in:
commit
f4b9614e68
@ -1,5 +1,6 @@
|
|||||||
package com.github.libretube.ui.adapters
|
package com.github.libretube.ui.adapters
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@ -43,17 +44,16 @@ class CommentsAdapter(
|
|||||||
return CommentsViewHolder(binding)
|
return CommentsViewHolder(binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onBindViewHolder(holder: CommentsViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: CommentsViewHolder, position: Int) {
|
||||||
val comment = comments[position]
|
val comment = comments[position]
|
||||||
holder.binding.apply {
|
holder.binding.apply {
|
||||||
commentInfos.text =
|
commentInfos.text = comment.author.toString() + " • " + comment.commentedTime.toString()
|
||||||
comment.author.toString() +
|
commentText.text = comment.commentText.toString()
|
||||||
" • " + comment.commentedTime.toString()
|
|
||||||
commentText.text =
|
|
||||||
comment.commentText.toString()
|
|
||||||
ImageHelper.loadImage(comment.thumbnail, commentorImage)
|
ImageHelper.loadImage(comment.thumbnail, commentorImage)
|
||||||
likesTextView.text =
|
likesTextView.text = comment.likeCount?.toLong().formatShort()
|
||||||
comment.likeCount?.toLong().formatShort()
|
|
||||||
if (comment.verified == true) {
|
if (comment.verified == true) {
|
||||||
verifiedImageView.visibility = View.VISIBLE
|
verifiedImageView.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
@ -63,23 +63,29 @@ class CommentsAdapter(
|
|||||||
if (comment.hearted == true) {
|
if (comment.hearted == true) {
|
||||||
heartedImageView.visibility = View.VISIBLE
|
heartedImageView.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (comment.repliesPage != null) {
|
||||||
|
commentsAvailable.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
|
|
||||||
commentorImage.setOnClickListener {
|
commentorImage.setOnClickListener {
|
||||||
NavigationHelper.navigateChannel(root.context, comment.commentorUrl)
|
NavigationHelper.navigateChannel(root.context, comment.commentorUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
repliesRecView.layoutManager = LinearLayoutManager(root.context)
|
repliesRecView.layoutManager = LinearLayoutManager(root.context)
|
||||||
val repliesAdapter = RepliesAdapter(CommentsPage().comments)
|
val repliesAdapter = RepliesAdapter(CommentsPage().comments)
|
||||||
repliesRecView.adapter = repliesAdapter
|
repliesRecView.adapter = repliesAdapter
|
||||||
root.setOnClickListener {
|
root.setOnClickListener {
|
||||||
if (repliesAdapter.itemCount == 0) {
|
when {
|
||||||
if (comment.repliesPage != null) {
|
repliesAdapter.itemCount.equals(0) && comment.repliesPage != null -> {
|
||||||
nextpage = comment.repliesPage
|
nextpage = comment.repliesPage
|
||||||
fetchReplies(nextpage, repliesAdapter)
|
fetchReplies(nextpage, repliesAdapter)
|
||||||
} else {
|
}
|
||||||
|
repliesAdapter.itemCount.equals(0) -> {
|
||||||
Toast.makeText(root.context, R.string.no_replies, Toast.LENGTH_SHORT)
|
Toast.makeText(root.context, R.string.no_replies, Toast.LENGTH_SHORT)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
} else {
|
else -> repliesAdapter.clear()
|
||||||
repliesAdapter.clear()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import androidx.fragment.app.DialogFragment
|
|||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.api.RetrofitInstance
|
import com.github.libretube.api.RetrofitInstance
|
||||||
|
import com.github.libretube.api.obj.Streams
|
||||||
import com.github.libretube.databinding.DialogDownloadBinding
|
import com.github.libretube.databinding.DialogDownloadBinding
|
||||||
import com.github.libretube.extensions.TAG
|
import com.github.libretube.extensions.TAG
|
||||||
import com.github.libretube.services.DownloadService
|
import com.github.libretube.services.DownloadService
|
||||||
@ -63,7 +64,9 @@ class DownloadDialog(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initDownloadOptions(streams: com.github.libretube.api.obj.Streams) {
|
private fun initDownloadOptions(streams: Streams) {
|
||||||
|
binding.fileName.setText(streams.title.toString())
|
||||||
|
|
||||||
val vidName = arrayListOf<String>()
|
val vidName = arrayListOf<String>()
|
||||||
val videoUrl = arrayListOf<String>()
|
val videoUrl = arrayListOf<String>()
|
||||||
|
|
||||||
@ -118,9 +121,14 @@ class DownloadDialog(
|
|||||||
if (binding.audioSpinner.size >= 1) binding.audioSpinner.setSelection(1)
|
if (binding.audioSpinner.size >= 1) binding.audioSpinner.setSelection(1)
|
||||||
|
|
||||||
binding.download.setOnClickListener {
|
binding.download.setOnClickListener {
|
||||||
|
if (binding.fileName.text.toString().length < 1) {
|
||||||
|
Toast.makeText(context, R.string.invalid_filename, Toast.LENGTH_SHORT).show()
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
|
||||||
val intent = Intent(context, DownloadService::class.java)
|
val intent = Intent(context, DownloadService::class.java)
|
||||||
|
|
||||||
intent.putExtra("videoName", streams.title)
|
intent.putExtra("videoName", binding.fileName.text.toString())
|
||||||
intent.putExtra("videoUrl", videoUrl[binding.videoSpinner.selectedItemPosition])
|
intent.putExtra("videoUrl", videoUrl[binding.videoSpinner.selectedItemPosition])
|
||||||
intent.putExtra("audioUrl", audioUrl[binding.audioSpinner.selectedItemPosition])
|
intent.putExtra("audioUrl", audioUrl[binding.audioSpinner.selectedItemPosition])
|
||||||
|
|
||||||
|
10
app/src/main/res/drawable/ic_comment.xml
Normal file
10
app/src/main/res/drawable/ic_comment.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="?attr/colorControlNormal"
|
||||||
|
android:viewportWidth="48"
|
||||||
|
android:viewportHeight="48">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M12.4,27.5h24v-3h-24ZM12.4,21h24v-3h-24ZM12.4,14.5h24v-3h-24ZM44,44l-8,-8L7,36q-1.15,0 -2.075,-0.925Q4,34.15 4,33L4,7q0,-1.15 0.925,-2.075Q5.85,4 7,4h34q1.2,0 2.1,0.925Q44,5.85 44,7Z" />
|
||||||
|
</vector>
|
@ -104,8 +104,20 @@
|
|||||||
android:layout_marginTop="3dp"
|
android:layout_marginTop="3dp"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:srcCompat="@drawable/ic_hearted" />
|
app:srcCompat="@drawable/ic_hearted" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/comments_available"
|
||||||
|
android:layout_width="14dp"
|
||||||
|
android:layout_height="14dp"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:srcCompat="@drawable/ic_comment" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
@ -14,6 +14,20 @@
|
|||||||
android:text="@string/app_name"
|
android:text="@string/app_name"
|
||||||
android:textSize="20sp" />
|
android:textSize="20sp" />
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:hint="@string/filename">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/fileName"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:inputType="text" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -339,6 +339,8 @@
|
|||||||
<string name="progressive_load_interval_summary">A lower value may speed up initial video loading.</string>
|
<string name="progressive_load_interval_summary">A lower value may speed up initial video loading.</string>
|
||||||
<string name="default_load_interval">Default</string>
|
<string name="default_load_interval">Default</string>
|
||||||
<string name="playback_pitch">Pitch</string>
|
<string name="playback_pitch">Pitch</string>
|
||||||
|
<string name="filename">Filename</string>
|
||||||
|
<string name="invalid_filename">Invalid filename!</string>
|
||||||
|
|
||||||
<!-- Notification channel strings -->
|
<!-- Notification channel strings -->
|
||||||
<string name="download_channel_name">Download Service</string>
|
<string name="download_channel_name">Download Service</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user