mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
Merge pull request #161 from Bnyro/createplaylistmenu
Create Playlist Rework
This commit is contained in:
commit
f8dacd3d26
@ -0,0 +1,41 @@
|
|||||||
|
package com.github.libretube
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import android.widget.Button
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.core.os.bundleOf
|
||||||
|
import androidx.fragment.app.DialogFragment
|
||||||
|
import androidx.fragment.app.setFragmentResult
|
||||||
|
|
||||||
|
class CreatePlaylistDialog : DialogFragment() {
|
||||||
|
override fun onCreateView(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup?,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View? {
|
||||||
|
var rootView: View = inflater.inflate(R.layout.dialog_create_playlist, container, false)
|
||||||
|
|
||||||
|
val cancelBtn = rootView.findViewById<Button>(R.id.cancel_button)
|
||||||
|
cancelBtn.setOnClickListener {
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
val playlistName = rootView.findViewById<com.google.android.material.textfield.TextInputEditText>(R.id.playlist_name)
|
||||||
|
val createPlaylistBtn = rootView.findViewById<Button>(R.id.create_new_playlist)
|
||||||
|
createPlaylistBtn.setOnClickListener {
|
||||||
|
var listName = playlistName.text.toString()
|
||||||
|
if(listName != "") {
|
||||||
|
setFragmentResult("key_parent", bundleOf("playlistName" to "$listName"))
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Toast.makeText(context, R.string.emptyPlaylistName, Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return rootView
|
||||||
|
}
|
||||||
|
}
|
@ -3,21 +3,20 @@ package com.github.libretube
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.*
|
import android.widget.Button
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
import com.github.libretube.adapters.ChannelAdapter
|
|
||||||
import com.github.libretube.adapters.PlaylistsAdapter
|
import com.github.libretube.adapters.PlaylistsAdapter
|
||||||
import com.github.libretube.adapters.SubscriptionAdapter
|
|
||||||
import com.github.libretube.obj.Playlists
|
import com.github.libretube.obj.Playlists
|
||||||
import com.squareup.picasso.Picasso
|
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
@ -59,10 +58,13 @@ class Library : Fragment() {
|
|||||||
Log.d(TAG,"hmm")
|
Log.d(TAG,"hmm")
|
||||||
fetchPlaylists(view)
|
fetchPlaylists(view)
|
||||||
}
|
}
|
||||||
val playlistName = view.findViewById<EditText>(R.id.playlists_name)
|
|
||||||
view.findViewById<Button>(R.id.create_playlist).setOnClickListener {
|
view.findViewById<Button>(R.id.create_playlist).setOnClickListener {
|
||||||
if(playlistName.text.toString()!="") createPlaylist(playlistName.text.toString(),view)
|
val newFragment = CreatePlaylistDialog()
|
||||||
hideKeyboard()
|
newFragment.show(childFragmentManager, "Create Playlist")
|
||||||
|
}
|
||||||
|
childFragmentManager.setFragmentResultListener("key_parent", this) { _, result->
|
||||||
|
val playlistName = result.getString("playlistName")
|
||||||
|
createPlaylist("$playlistName", view);
|
||||||
}
|
}
|
||||||
} else{
|
} else{
|
||||||
with(view.findViewById<ImageView>(R.id.boogh2)){
|
with(view.findViewById<ImageView>(R.id.boogh2)){
|
||||||
|
61
app/src/main/res/layout/dialog_create_playlist.xml
Normal file
61
app/src/main/res/layout/dialog_create_playlist.xml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
>
|
||||||
|
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="300dp"
|
||||||
|
android:layout_height="64dp"
|
||||||
|
android:background="#CD5757"
|
||||||
|
android:contentDescription="@string/app_name"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:src="@drawable/ic_libretube_foreground" />
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:hintEnabled="false"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginLeft="7dp"
|
||||||
|
android:layout_marginRight="7dp"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
|
>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/playlist_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/playlistName"
|
||||||
|
android:inputType="text"
|
||||||
|
android:padding="12dp" />
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center">
|
||||||
|
<Button
|
||||||
|
android:id="@+id/cancel_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/cancel"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:layout_margin="8dp"/>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/create_new_playlist"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/createPlaylist"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:layout_margin="8dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -48,34 +48,6 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
<com.google.android.material.card.MaterialCardView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:id="@+id/outlinedTextField"
|
|
||||||
style="@style/Widget.Material3.CardView.Filled"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
|
||||||
android:layout_margin="5dp"
|
|
||||||
>
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
|
||||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:hintEnabled="false"
|
|
||||||
android:layout_marginRight="20dp"
|
|
||||||
android:layout_marginLeft="20dp"
|
|
||||||
android:background="@android:color/transparent">
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/playlists_name"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:layout_margin="8dp"
|
|
||||||
android:background="@android:color/transparent"
|
|
||||||
android:hint="@string/playlistName"/>
|
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/create_playlist"
|
android:id="@+id/create_playlist"
|
||||||
|
@ -46,8 +46,9 @@
|
|||||||
<string name="areYouSure">Delete the playlist?</string>
|
<string name="areYouSure">Delete the playlist?</string>
|
||||||
<string name="createPlaylist">Create playlist</string>
|
<string name="createPlaylist">Create playlist</string>
|
||||||
<string name="playlistCreated">Playlist created!</string>
|
<string name="playlistCreated">Playlist created!</string>
|
||||||
<string name="playlistName">Playlist name</string>
|
<string name="playlistName">Playlist Name</string>
|
||||||
<string name="addToPlaylist">Add to playlist</string>
|
<string name="emptyPlaylistName">The playlist name can\'t be empty</string>
|
||||||
|
<string name="addToPlaylist">Add to Playlist</string>
|
||||||
<string name="success">Success!</string>
|
<string name="success">Success!</string>
|
||||||
<string name="fail">Failed :(</string>
|
<string name="fail">Failed :(</string>
|
||||||
<string name="about">About</string>
|
<string name="about">About</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user