add options dialog to playlist fragment

This commit is contained in:
Bnyro 2022-07-08 14:00:11 +02:00
parent 0622672e4c
commit 3ed130c62c
3 changed files with 43 additions and 9 deletions

View File

@ -11,6 +11,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import com.github.libretube.R
import com.github.libretube.adapters.PlaylistAdapter
import com.github.libretube.databinding.FragmentPlaylistBinding
import com.github.libretube.dialogs.PlaylistOptionsDialog
import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.util.RetrofitInstance
import retrofit2.HttpException
@ -72,11 +73,18 @@ class PlaylistFragment : Fragment() {
binding.playlistUploader.text = response.uploader
binding.playlistTotVideos.text =
getString(R.string.videoCount, response.videos.toString())
val user = PreferenceHelper.getUsername(requireContext())
var isOwner = false
if (response.uploaderUrl == null && response.uploader.equals(user, true)) {
isOwner = true
// show playlist options
binding.optionsMenu.setOnClickListener {
val newFragment = PlaylistOptionsDialog(playlistId!!, requireContext())
newFragment.show(childFragmentManager, "PlaylistOptionsDialog")
}
val user = PreferenceHelper.getUsername(requireContext())
// check whether the user owns the playlist
val isOwner = response.uploaderUrl == null &&
response.uploader.equals(user, true)
playlistAdapter = PlaylistAdapter(
response.relatedStreams!!.toMutableList(),
playlistId!!,

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="16"
android:viewportHeight="16">
<path
android:fillColor="@android:color/black"
android:pathData="M9.5,13a1.5,1.5 0,1 1,-3 0,1.5 1.5,0 0,1 3,0zM9.5,8a1.5,1.5 0,1 1,-3 0,1.5 1.5,0 0,1 3,0zM9.5,3a1.5,1.5 0,1 1,-3 0,1.5 1.5,0 0,1 3,0z" />
</vector>

View File

@ -23,14 +23,30 @@
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/playlist_name"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:text=""
android:textSize="24sp"
android:textStyle="bold" />
android:orientation="horizontal">
<TextView
android:id="@+id/playlist_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=""
android:textSize="24sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/optionsMenu"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginRight="10dp"
android:layout_gravity="center"
android:src="@drawable/ic_three_dots" />
</LinearLayout>
<TextView
android:id="@+id/playlist_uploader"