diff --git a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt index 042ad28b1..23577291b 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt @@ -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() } } } diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/DownloadDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/DownloadDialog.kt index 9a1236a2a..87430c670 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/DownloadDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/DownloadDialog.kt @@ -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() val videoUrl = arrayListOf() @@ -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]) diff --git a/app/src/main/res/drawable/ic_comment.xml b/app/src/main/res/drawable/ic_comment.xml new file mode 100644 index 000000000..570a62b7c --- /dev/null +++ b/app/src/main/res/drawable/ic_comment.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/comments_row.xml b/app/src/main/res/layout/comments_row.xml index 2a4602244..afb717b09 100644 --- a/app/src/main/res/layout/comments_row.xml +++ b/app/src/main/res/layout/comments_row.xml @@ -104,8 +104,20 @@ android:layout_marginTop="3dp" android:visibility="gone" app:srcCompat="@drawable/ic_hearted" /> + + + + + + + + + + A lower value may speed up initial video loading. Default Pitch + Filename + Invalid filename! Download Service