From 1018fd80fb1c8138683009cbad4bada6d63b5cff Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 6 Oct 2022 14:26:30 +0200 Subject: [PATCH 1/3] allow renaming files to download --- .../github/libretube/ui/dialogs/DownloadDialog.kt | 12 ++++++++++-- app/src/main/res/layout/dialog_download.xml | 11 +++++++++++ app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 23 insertions(+), 2 deletions(-) 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/layout/dialog_download.xml b/app/src/main/res/layout/dialog_download.xml index 0743059f1..93986ba7d 100644 --- a/app/src/main/res/layout/dialog_download.xml +++ b/app/src/main/res/layout/dialog_download.xml @@ -14,6 +14,17 @@ android:text="@string/app_name" android:textSize="20sp" /> + + + + + A lower value may speed up initial video loading. Default Pitch + Filename + Invalid filename! Download Service From 5c4a23aa33c6cb3098db4ae37936ef9f511f8d3c Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 6 Oct 2022 14:35:42 +0200 Subject: [PATCH 2/3] indicate when replies are available --- .../libretube/ui/adapters/CommentsAdapter.kt | 30 +++++++++++-------- app/src/main/res/drawable/ic_comment.xml | 10 +++++++ app/src/main/res/layout/comments_row.xml | 12 ++++++++ 3 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 app/src/main/res/drawable/ic_comment.xml 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/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" /> + + + + + Date: Thu, 6 Oct 2022 14:36:46 +0200 Subject: [PATCH 3/3] UI improvements --- app/src/main/res/layout/dialog_download.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/res/layout/dialog_download.xml b/app/src/main/res/layout/dialog_download.xml index 93986ba7d..aafcb7991 100644 --- a/app/src/main/res/layout/dialog_download.xml +++ b/app/src/main/res/layout/dialog_download.xml @@ -15,7 +15,10 @@ android:textSize="20sp" />