feat: Open playlist video in player, string update

This commit is contained in:
digiwizkid 2022-01-08 20:07:30 +05:30
parent 96ec510f40
commit c23c17d2ef
6 changed files with 18 additions and 7 deletions

View File

@ -18,12 +18,13 @@ package net.schueller.peertube.activity
import android.app.AlertDialog import android.app.AlertDialog
import android.content.DialogInterface import android.content.DialogInterface
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.widget.Toast
import androidx.activity.viewModels import androidx.activity.viewModels
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import net.schueller.peertube.R import net.schueller.peertube.R
import net.schueller.peertube.adapter.MultiViewRecyclerViewHolder
import net.schueller.peertube.adapter.PlaylistAdapter import net.schueller.peertube.adapter.PlaylistAdapter
import net.schueller.peertube.database.Video import net.schueller.peertube.database.Video
import net.schueller.peertube.database.VideoViewModel import net.schueller.peertube.database.VideoViewModel
@ -58,7 +59,9 @@ class PlaylistActivity : CommonActivity() {
} }
private fun onVideoClick(video: Video) { private fun onVideoClick(video: Video) {
Toast.makeText(this, "Clicked", Toast.LENGTH_SHORT).show() val intent = Intent(this, VideoPlayActivity::class.java)
intent.putExtra(MultiViewRecyclerViewHolder.EXTRA_VIDEOID, video.videoUUID)
startActivity(intent)
} }
private fun showServers() { private fun showServers() {
@ -75,8 +78,8 @@ class PlaylistActivity : CommonActivity() {
override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) { override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
AlertDialog.Builder(this@PlaylistActivity) AlertDialog.Builder(this@PlaylistActivity)
.setTitle("Remove Video") .setTitle(getString(R.string.remove_video))
.setMessage("Are you sure you want to remove this video from playlist?") .setMessage(getString(R.string.remove_video_warning_message))
.setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int -> .setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
val position = viewHolder.bindingAdapterPosition val position = viewHolder.bindingAdapterPosition
val video = adapter.getVideoAtPosition(position) val video = adapter.getVideoAtPosition(position)

View File

@ -136,7 +136,7 @@ sealed class MultiViewRecyclerViewHolder(binding: ViewBinding) : RecyclerView.Vi
// Add to playlist // Add to playlist
binding.videoAddToPlaylistWrapper.setOnClickListener { binding.videoAddToPlaylistWrapper.setOnClickListener {
videoMetaDataFragment.saveToPlaylist(video) videoMetaDataFragment.saveToPlaylist(video)
Toast.makeText(context, "Saved to playlist", Toast.LENGTH_SHORT).show() Toast.makeText(context, context.getString(string.saved_to_playlist), Toast.LENGTH_SHORT).show()
} }
binding.videoBlockWrapper.setOnClickListener { binding.videoBlockWrapper.setOnClickListener {

View File

@ -5,6 +5,7 @@ import androidx.room.ColumnInfo
import androidx.room.Entity import androidx.room.Entity
import androidx.room.PrimaryKey import androidx.room.PrimaryKey
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
import java.util.*
@Parcelize @Parcelize
@Entity(tableName = "watch_later") @Entity(tableName = "watch_later")
@ -12,6 +13,9 @@ data class Video(
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
var id: Int = 0, var id: Int = 0,
@ColumnInfo(name = "video_uuid")
var videoUUID: String,
@ColumnInfo(name = "video_name") @ColumnInfo(name = "video_name")
var videoName: String, var videoName: String,

View File

@ -220,7 +220,7 @@ class VideoMetaDataFragment : Fragment() {
} }
fun saveToPlaylist(video: Video) { fun saveToPlaylist(video: Video) {
val playlistVideo: net.schueller.peertube.database.Video = net.schueller.peertube.database.Video(videoName = video.name, videoDescription = video.description) val playlistVideo: net.schueller.peertube.database.Video = net.schueller.peertube.database.Video(videoUUID = video.uuid, videoName = video.name, videoDescription = video.description)
mVideoViewModel.insert(playlistVideo) mVideoViewModel.insert(playlistVideo)
} }

View File

@ -116,7 +116,7 @@
android:drawablePadding="16dp" android:drawablePadding="16dp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Playlist" android:text="@string/playlist"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"/> android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"/>
</LinearLayout> </LinearLayout>

View File

@ -384,4 +384,8 @@
<string name="video_owner_fqdn_line">%1$s@%2$s</string> <string name="video_owner_fqdn_line">%1$s@%2$s</string>
<string name="video_sub_del_alert_title">Unsubscribe</string> <string name="video_sub_del_alert_title">Unsubscribe</string>
<string name="video_sub_del_alert_msg">Are you sure you would like to unsubscribe?</string> <string name="video_sub_del_alert_msg">Are you sure you would like to unsubscribe?</string>
<string name="saved_to_playlist">Saved to playlist</string>
<string name="remove_video">Remove Video</string>
<string name="remove_video_warning_message">Are you sure you want to remove this video from playlist?</string>
<string name="playlist">Playlist</string>
</resources> </resources>