Merge pull request #1503 from Bnyro/master

Rename files when downloading + indicate when comments are available
This commit is contained in:
Bnyro 2022-10-06 14:37:37 +02:00 committed by GitHub
commit f4b9614e68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 66 additions and 14 deletions

View File

@ -1,5 +1,6 @@
package com.github.libretube.ui.adapters
import android.annotation.SuppressLint
import android.util.Log
import android.view.LayoutInflater
import android.view.View
@ -43,17 +44,16 @@ class CommentsAdapter(
return CommentsViewHolder(binding)
}
@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: CommentsViewHolder, position: Int) {
val comment = comments[position]
holder.binding.apply {
commentInfos.text =
comment.author.toString() +
"" + comment.commentedTime.toString()
commentText.text =
comment.commentText.toString()
commentInfos.text = comment.author.toString() + "" + comment.commentedTime.toString()
commentText.text = comment.commentText.toString()
ImageHelper.loadImage(comment.thumbnail, commentorImage)
likesTextView.text =
comment.likeCount?.toLong().formatShort()
likesTextView.text = comment.likeCount?.toLong().formatShort()
if (comment.verified == true) {
verifiedImageView.visibility = View.VISIBLE
}
@ -63,23 +63,29 @@ class CommentsAdapter(
if (comment.hearted == true) {
heartedImageView.visibility = View.VISIBLE
}
if (comment.repliesPage != null) {
commentsAvailable.visibility = View.VISIBLE
}
commentorImage.setOnClickListener {
NavigationHelper.navigateChannel(root.context, comment.commentorUrl)
}
repliesRecView.layoutManager = LinearLayoutManager(root.context)
val repliesAdapter = RepliesAdapter(CommentsPage().comments)
repliesRecView.adapter = repliesAdapter
root.setOnClickListener {
if (repliesAdapter.itemCount == 0) {
if (comment.repliesPage != null) {
when {
repliesAdapter.itemCount.equals(0) && comment.repliesPage != null -> {
nextpage = comment.repliesPage
fetchReplies(nextpage, repliesAdapter)
} else {
}
repliesAdapter.itemCount.equals(0) -> {
Toast.makeText(root.context, R.string.no_replies, Toast.LENGTH_SHORT)
.show()
}
} else {
repliesAdapter.clear()
else -> repliesAdapter.clear()
}
}
}

View File

@ -12,6 +12,7 @@ import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
import com.github.libretube.R
import com.github.libretube.api.RetrofitInstance
import com.github.libretube.api.obj.Streams
import com.github.libretube.databinding.DialogDownloadBinding
import com.github.libretube.extensions.TAG
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 videoUrl = arrayListOf<String>()
@ -118,9 +121,14 @@ class DownloadDialog(
if (binding.audioSpinner.size >= 1) binding.audioSpinner.setSelection(1)
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)
intent.putExtra("videoName", streams.title)
intent.putExtra("videoName", binding.fileName.text.toString())
intent.putExtra("videoUrl", videoUrl[binding.videoSpinner.selectedItemPosition])
intent.putExtra("audioUrl", audioUrl[binding.audioSpinner.selectedItemPosition])

View 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>

View File

@ -104,8 +104,20 @@
android:layout_marginTop="3dp"
android:visibility="gone"
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>
<androidx.recyclerview.widget.RecyclerView

View File

@ -14,6 +14,20 @@
android:text="@string/app_name"
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
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View File

@ -339,6 +339,8 @@
<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="playback_pitch">Pitch</string>
<string name="filename">Filename</string>
<string name="invalid_filename">Invalid filename!</string>
<!-- Notification channel strings -->
<string name="download_channel_name">Download Service</string>