From d832d17c1adcc8ec7a7a8484a3eafc8adb40da42 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 27 May 2022 20:25:20 +0200 Subject: [PATCH 1/3] Add to Playlist in Video Option Dialog --- .../com/github/libretube/VideoOptionsDialog.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/VideoOptionsDialog.kt b/app/src/main/java/com/github/libretube/VideoOptionsDialog.kt index 392220714..4346feb30 100644 --- a/app/src/main/java/com/github/libretube/VideoOptionsDialog.kt +++ b/app/src/main/java/com/github/libretube/VideoOptionsDialog.kt @@ -2,10 +2,15 @@ package com.github.libretube import android.app.Dialog import android.content.Context +import android.content.DialogInterface +import android.content.Intent import android.os.Bundle import android.widget.ArrayAdapter import androidx.fragment.app.DialogFragment +import androidx.fragment.app.FragmentActivity +import androidx.preference.PreferenceManager import com.google.android.material.dialog.MaterialAlertDialogBuilder +import java.net.URLEncoder /** * Dialog with different options for a selected video. @@ -17,7 +22,8 @@ class VideoOptionsDialog(private val videoId: String, context: Context) : Dialog * List that stores the different menu options. In the future could be add more options here. */ private val list = listOf( - context.getString(R.string.playOnBackground) + context.getString(R.string.playOnBackground), + context.getString(R.string.addToPlaylist) ) /** @@ -44,6 +50,14 @@ class VideoOptionsDialog(private val videoId: String, context: Context) : Dialog .getInstance() .playOnBackgroundMode(requireContext(), videoId, 0) } + // Add Video to Playlist Dialog + 1 -> { + val newFragment = AddtoPlaylistDialog() + var bundle = Bundle() + bundle.putString("videoId", videoId) + newFragment.arguments = bundle + newFragment.show(parentFragmentManager, "AddToPlaylist") + } else -> { dialog.dismiss() } From 4947c97d70d115e236b5d232819f0645e6924bef Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 27 May 2022 20:51:56 +0200 Subject: [PATCH 2/3] create playlist rewrite --- .../github/libretube/CreatePlaylistDialog.kt | 42 ++++++++++++++++++- .../main/java/com/github/libretube/Library.kt | 30 +------------ 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/com/github/libretube/CreatePlaylistDialog.kt b/app/src/main/java/com/github/libretube/CreatePlaylistDialog.kt index bfbfa70f2..c5704aa9c 100644 --- a/app/src/main/java/com/github/libretube/CreatePlaylistDialog.kt +++ b/app/src/main/java/com/github/libretube/CreatePlaylistDialog.kt @@ -1,6 +1,8 @@ package com.github.libretube +import android.content.Context import android.os.Bundle +import android.util.Log import android.util.TypedValue import android.view.LayoutInflater import android.view.View @@ -12,9 +14,16 @@ import androidx.core.os.bundleOf import androidx.core.text.HtmlCompat import androidx.fragment.app.DialogFragment import androidx.fragment.app.setFragmentResult +import androidx.lifecycle.lifecycleScope +import com.github.libretube.obj.Playlists import com.google.android.material.textfield.TextInputEditText +import retrofit2.HttpException +import java.io.IOException class CreatePlaylistDialog : DialogFragment() { + val TAG = "CreatePlaylistDialog" + private var token: String = "" + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, @@ -36,13 +45,15 @@ class CreatePlaylistDialog : DialogFragment() { dismiss() } + val sharedPref = context?.getSharedPreferences("token", Context.MODE_PRIVATE) + token = sharedPref?.getString("token", "")!! + val playlistName = rootView.findViewById(R.id.playlist_name) val createPlaylistBtn = rootView.findViewById