mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Merge pull request #4323 from Bnyro/master
feat: support for video tags
This commit is contained in:
commit
801c454790
@ -0,0 +1,33 @@
|
|||||||
|
package com.github.libretube.ui.activities
|
||||||
|
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.github.libretube.R
|
||||||
|
import com.github.libretube.constants.IntentData
|
||||||
|
import com.github.libretube.databinding.VideoTagRowBinding
|
||||||
|
import com.github.libretube.ui.viewholders.VideoTagsViewHolder
|
||||||
|
|
||||||
|
class VideoTagsAdapter(private val tags: List<String>) :
|
||||||
|
RecyclerView.Adapter<VideoTagsViewHolder>() {
|
||||||
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VideoTagsViewHolder {
|
||||||
|
val binding = VideoTagRowBinding.inflate(LayoutInflater.from(parent.context))
|
||||||
|
return VideoTagsViewHolder(binding)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getItemCount() = tags.size
|
||||||
|
|
||||||
|
override fun onBindViewHolder(holder: VideoTagsViewHolder, position: Int) {
|
||||||
|
val tag = tags[position]
|
||||||
|
holder.binding.apply {
|
||||||
|
tagText.text = tag
|
||||||
|
root.setOnClickListener {
|
||||||
|
val mainActivity = root.context as MainActivity
|
||||||
|
mainActivity.searchView.setQuery(tag, true)
|
||||||
|
// minimizes the player fragment to the mini player
|
||||||
|
mainActivity.onBackPressedDispatcher.onBackPressed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -93,6 +93,7 @@ import com.github.libretube.obj.VideoResolution
|
|||||||
import com.github.libretube.parcelable.PlayerData
|
import com.github.libretube.parcelable.PlayerData
|
||||||
import com.github.libretube.services.DownloadService
|
import com.github.libretube.services.DownloadService
|
||||||
import com.github.libretube.ui.activities.MainActivity
|
import com.github.libretube.ui.activities.MainActivity
|
||||||
|
import com.github.libretube.ui.activities.VideoTagsAdapter
|
||||||
import com.github.libretube.ui.adapters.ChaptersAdapter
|
import com.github.libretube.ui.adapters.ChaptersAdapter
|
||||||
import com.github.libretube.ui.adapters.VideosAdapter
|
import com.github.libretube.ui.adapters.VideosAdapter
|
||||||
import com.github.libretube.ui.dialogs.AddToPlaylistDialog
|
import com.github.libretube.ui.dialogs.AddToPlaylistDialog
|
||||||
@ -996,6 +997,12 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
|
|||||||
"${context?.getString(R.string.license)}: ${streams.license}\n" +
|
"${context?.getString(R.string.license)}: ${streams.license}\n" +
|
||||||
"${context?.getString(R.string.visibility)}: $visibility"
|
"${context?.getString(R.string.visibility)}: $visibility"
|
||||||
|
|
||||||
|
if (streams.tags.isNotEmpty()) {
|
||||||
|
binding.tagsRecycler.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
||||||
|
binding.tagsRecycler.adapter = VideoTagsAdapter(streams.tags)
|
||||||
|
}
|
||||||
|
binding.tagsRecycler.isVisible = streams.tags.isNotEmpty()
|
||||||
|
|
||||||
binding.playerChannel.setOnClickListener {
|
binding.playerChannel.setOnClickListener {
|
||||||
val activity = view?.context as MainActivity
|
val activity = view?.context as MainActivity
|
||||||
val bundle = bundleOf(IntentData.channelId to streams.uploaderUrl)
|
val bundle = bundleOf(IntentData.channelId to streams.uploaderUrl)
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.github.libretube.ui.viewholders
|
||||||
|
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.github.libretube.databinding.VideoTagRowBinding
|
||||||
|
|
||||||
|
class VideoTagsViewHolder(
|
||||||
|
val binding: VideoTagRowBinding
|
||||||
|
): RecyclerView.ViewHolder(binding.root)
|
@ -132,6 +132,11 @@
|
|||||||
android:textIsSelectable="true"
|
android:textIsSelectable="true"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/tags_recycler"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
23
app/src/main/res/layout/video_tag_row.xml
Normal file
23
app/src/main/res/layout/video_tag_row.xml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<com.google.android.material.card.MaterialCardView
|
||||||
|
style="@style/Widget.Material3.CardView.Elevated"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="3dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tag_text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="8dp"
|
||||||
|
android:layout_marginVertical="6dp"
|
||||||
|
tools:text="Gaming" />
|
||||||
|
|
||||||
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
|
||||||
|
</FrameLayout>
|
Loading…
Reference in New Issue
Block a user