mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
Merge pull request #5106 from Bnyro/master
refactor: make dialogs more uniform
This commit is contained in:
commit
3421ecae32
@ -2,6 +2,7 @@ package com.github.libretube.ui.dialogs
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
import android.content.DialogInterface
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.ArrayAdapter
|
import android.widget.ArrayAdapter
|
||||||
@ -14,6 +15,7 @@ import androidx.lifecycle.repeatOnLifecycle
|
|||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.api.PlaylistsHelper
|
import com.github.libretube.api.PlaylistsHelper
|
||||||
import com.github.libretube.api.RetrofitInstance
|
import com.github.libretube.api.RetrofitInstance
|
||||||
|
import com.github.libretube.api.obj.Playlists
|
||||||
import com.github.libretube.constants.IntentData
|
import com.github.libretube.constants.IntentData
|
||||||
import com.github.libretube.databinding.DialogAddToPlaylistBinding
|
import com.github.libretube.databinding.DialogAddToPlaylistBinding
|
||||||
import com.github.libretube.extensions.TAG
|
import com.github.libretube.extensions.TAG
|
||||||
@ -31,6 +33,8 @@ class AddToPlaylistDialog : DialogFragment() {
|
|||||||
private var videoId: String? = null
|
private var videoId: String? = null
|
||||||
private val viewModel: PlaylistViewModel by activityViewModels()
|
private val viewModel: PlaylistViewModel by activityViewModels()
|
||||||
|
|
||||||
|
var playlists = emptyList<Playlists>()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
videoId = arguments?.getString(IntentData.videoId)
|
videoId = arguments?.getString(IntentData.videoId)
|
||||||
@ -48,15 +52,30 @@ class AddToPlaylistDialog : DialogFragment() {
|
|||||||
fetchPlaylists(binding)
|
fetchPlaylists(binding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
binding.createPlaylist.setOnClickListener {
|
|
||||||
CreatePlaylistDialog().show(childFragmentManager, null)
|
|
||||||
}
|
|
||||||
|
|
||||||
fetchPlaylists(binding)
|
fetchPlaylists(binding)
|
||||||
|
|
||||||
return MaterialAlertDialogBuilder(requireContext())
|
return MaterialAlertDialogBuilder(requireContext())
|
||||||
|
.setTitle(R.string.addToPlaylist)
|
||||||
|
.setNegativeButton(R.string.createPlaylist, null)
|
||||||
|
.setPositiveButton(R.string.addToPlaylist, null)
|
||||||
.setView(binding.root)
|
.setView(binding.root)
|
||||||
.show()
|
.show()
|
||||||
|
.apply {
|
||||||
|
getButton(DialogInterface.BUTTON_NEGATIVE).setOnClickListener {
|
||||||
|
CreatePlaylistDialog().show(childFragmentManager, null)
|
||||||
|
}
|
||||||
|
getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener {val index = binding.playlistsSpinner.selectedItemPosition
|
||||||
|
val playlist = playlists[index]
|
||||||
|
viewModel.lastSelectedPlaylistId = playlist.id!!
|
||||||
|
dialog?.hide()
|
||||||
|
lifecycleScope.launch {
|
||||||
|
addToPlaylist(playlist.id, playlist.name!!)
|
||||||
|
dialog?.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchPlaylists(binding: DialogAddToPlaylistBinding) {
|
private fun fetchPlaylists(binding: DialogAddToPlaylistBinding) {
|
||||||
@ -70,7 +89,7 @@ class AddToPlaylistDialog : DialogFragment() {
|
|||||||
return@repeatOnLifecycle
|
return@repeatOnLifecycle
|
||||||
}
|
}
|
||||||
|
|
||||||
val playlists = response.filter { !it.name.isNullOrEmpty() }
|
playlists = response.filter { !it.name.isNullOrEmpty() }
|
||||||
if (playlists.isEmpty()) return@repeatOnLifecycle
|
if (playlists.isEmpty()) return@repeatOnLifecycle
|
||||||
|
|
||||||
binding.playlistsSpinner.adapter =
|
binding.playlistsSpinner.adapter =
|
||||||
@ -85,16 +104,6 @@ class AddToPlaylistDialog : DialogFragment() {
|
|||||||
val latestIndex = response.indexOfFirst { it.id == id }.takeIf { it >= 0 } ?: 0
|
val latestIndex = response.indexOfFirst { it.id == id }.takeIf { it >= 0 } ?: 0
|
||||||
binding.playlistsSpinner.setSelection(latestIndex)
|
binding.playlistsSpinner.setSelection(latestIndex)
|
||||||
}
|
}
|
||||||
binding.addToPlaylist.setOnClickListener {
|
|
||||||
val index = binding.playlistsSpinner.selectedItemPosition
|
|
||||||
val playlist = playlists[index]
|
|
||||||
viewModel.lastSelectedPlaylistId = playlist.id!!
|
|
||||||
dialog?.hide()
|
|
||||||
lifecycleScope.launch {
|
|
||||||
addToPlaylist(playlist.id, playlist.name!!)
|
|
||||||
dialog?.dismiss()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,6 @@ class CreatePlaylistDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.cancelButton.setOnClickListener {
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.createNewPlaylist.setOnClickListener {
|
binding.createNewPlaylist.setOnClickListener {
|
||||||
val appContext = context?.applicationContext
|
val appContext = context?.applicationContext
|
||||||
val listName = binding.playlistName.text?.toString()
|
val listName = binding.playlistName.text?.toString()
|
||||||
@ -84,7 +80,9 @@ class CreatePlaylistDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return MaterialAlertDialogBuilder(requireContext())
|
return MaterialAlertDialogBuilder(requireContext())
|
||||||
|
.setTitle(R.string.createPlaylist)
|
||||||
.setView(binding.root)
|
.setView(binding.root)
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,35 +18,32 @@ class CustomInstanceDialog : DialogFragment() {
|
|||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val binding = DialogCustomInstanceBinding.inflate(layoutInflater)
|
val binding = DialogCustomInstanceBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
binding.cancel.setOnClickListener {
|
return MaterialAlertDialogBuilder(requireContext())
|
||||||
dismiss()
|
.setTitle(R.string.customInstance)
|
||||||
}
|
.setView(binding.root)
|
||||||
|
.setPositiveButton(R.string.addInstance) { _, _ ->
|
||||||
|
val instanceName = binding.instanceName.text.toString()
|
||||||
|
val apiUrl = binding.instanceApiUrl.text.toString()
|
||||||
|
val frontendUrl = binding.instanceFrontendUrl.text.toString()
|
||||||
|
|
||||||
binding.addInstance.setOnClickListener {
|
if (instanceName.isNotEmpty() && apiUrl.isNotEmpty() && frontendUrl.isNotEmpty()) {
|
||||||
val instanceName = binding.instanceName.text.toString()
|
if (apiUrl.toHttpUrlOrNull() != null && frontendUrl.toHttpUrlOrNull() != null) {
|
||||||
val apiUrl = binding.instanceApiUrl.text.toString()
|
lifecycleScope.launch {
|
||||||
val frontendUrl = binding.instanceFrontendUrl.text.toString()
|
Database.customInstanceDao()
|
||||||
|
.insert(CustomInstance(instanceName, apiUrl, frontendUrl))
|
||||||
if (instanceName.isNotEmpty() && apiUrl.isNotEmpty() && frontendUrl.isNotEmpty()) {
|
ActivityCompat.recreate(requireActivity())
|
||||||
if (apiUrl.toHttpUrlOrNull() != null && frontendUrl.toHttpUrlOrNull() != null) {
|
dismiss()
|
||||||
lifecycleScope.launch {
|
}
|
||||||
Database.customInstanceDao()
|
} else {
|
||||||
.insert(CustomInstance(instanceName, apiUrl, frontendUrl))
|
Toast.makeText(requireContext(), R.string.invalid_url, Toast.LENGTH_SHORT)
|
||||||
ActivityCompat.recreate(requireActivity())
|
.show()
|
||||||
dismiss()
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(requireContext(), R.string.invalid_url, Toast.LENGTH_SHORT)
|
// at least one empty input
|
||||||
.show()
|
Toast.makeText(requireContext(), R.string.empty_instance, Toast.LENGTH_SHORT).show()
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// at least one empty input
|
|
||||||
Toast.makeText(requireContext(), R.string.empty_instance, Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
}
|
||||||
}
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
|
||||||
return MaterialAlertDialogBuilder(requireContext())
|
|
||||||
.setView(binding.root)
|
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
package com.github.libretube.ui.dialogs
|
package com.github.libretube.ui.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
import android.content.DialogInterface
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.fragment.app.DialogFragment
|
import androidx.fragment.app.DialogFragment
|
||||||
import androidx.fragment.app.setFragmentResult
|
import androidx.fragment.app.setFragmentResult
|
||||||
import androidx.lifecycle.Lifecycle
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.lifecycle.repeatOnLifecycle
|
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.api.RetrofitInstance
|
import com.github.libretube.api.RetrofitInstance
|
||||||
import com.github.libretube.api.obj.DeleteUserRequest
|
import com.github.libretube.api.obj.DeleteUserRequest
|
||||||
@ -27,46 +26,46 @@ class DeleteAccountDialog : DialogFragment() {
|
|||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val binding = DialogDeleteAccountBinding.inflate(layoutInflater)
|
val binding = DialogDeleteAccountBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
binding.cancelButton.setOnClickListener {
|
|
||||||
dialog?.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
binding.deleteAccountConfirm.setOnClickListener {
|
|
||||||
val password = binding.deletePassword.text?.toString()
|
|
||||||
if (!password.isNullOrEmpty()) {
|
|
||||||
deleteAccount(password)
|
|
||||||
} else {
|
|
||||||
Toast.makeText(context, R.string.empty, Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return MaterialAlertDialogBuilder(requireContext())
|
return MaterialAlertDialogBuilder(requireContext())
|
||||||
.setView(binding.root)
|
.setView(binding.root)
|
||||||
|
.setPositiveButton(R.string.deleteAccount, null)
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.show()
|
.show()
|
||||||
|
.apply {
|
||||||
|
getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener {
|
||||||
|
requireDialog().hide()
|
||||||
|
|
||||||
|
val password = binding.deletePassword.text?.toString()
|
||||||
|
if (password.isNullOrEmpty()) {
|
||||||
|
Toast.makeText(context, R.string.empty, Toast.LENGTH_SHORT).show()
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
|
||||||
|
lifecycleScope.launch {
|
||||||
|
deleteAccount(password)
|
||||||
|
dismiss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun deleteAccount(password: String) {
|
private fun deleteAccount(password: String) = lifecycleScope.launch {
|
||||||
lifecycleScope.launch {
|
val token = PreferenceHelper.getToken()
|
||||||
repeatOnLifecycle(Lifecycle.State.CREATED) {
|
|
||||||
val token = PreferenceHelper.getToken()
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
withContext(Dispatchers.IO) {
|
withContext(Dispatchers.IO) {
|
||||||
RetrofitInstance.authApi.deleteAccount(token, DeleteUserRequest(password))
|
RetrofitInstance.authApi.deleteAccount(token, DeleteUserRequest(password))
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e(TAG(), e.toString())
|
|
||||||
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
|
||||||
return@repeatOnLifecycle
|
|
||||||
}
|
|
||||||
Toast.makeText(context, R.string.success, Toast.LENGTH_SHORT).show()
|
|
||||||
|
|
||||||
setFragmentResult(
|
|
||||||
InstanceSettings.INSTANCE_DIALOG_REQUEST_KEY,
|
|
||||||
bundleOf(IntentData.logoutTask to true)
|
|
||||||
)
|
|
||||||
dialog?.dismiss()
|
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e(TAG(), e.toString())
|
||||||
|
Toast.makeText(context, R.string.unknown_error, Toast.LENGTH_SHORT).show()
|
||||||
|
return@launch
|
||||||
}
|
}
|
||||||
|
Toast.makeText(context, R.string.success, Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
|
setFragmentResult(
|
||||||
|
InstanceSettings.INSTANCE_DIALOG_REQUEST_KEY,
|
||||||
|
bundleOf(IntentData.logoutTask to true)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ class DownloadDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return MaterialAlertDialogBuilder(requireContext())
|
return MaterialAlertDialogBuilder(requireContext())
|
||||||
|
.setTitle(R.string.download)
|
||||||
.setView(binding.root)
|
.setView(binding.root)
|
||||||
.setPositiveButton(R.string.download, null)
|
.setPositiveButton(R.string.download, null)
|
||||||
.show()
|
.show()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.github.libretube.ui.dialogs
|
package com.github.libretube.ui.dialogs
|
||||||
|
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
|
import android.content.DialogInterface
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.util.Patterns
|
import android.util.Patterns
|
||||||
@ -30,39 +31,36 @@ class LoginDialog : DialogFragment() {
|
|||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val binding = DialogLoginBinding.inflate(layoutInflater)
|
val binding = DialogLoginBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
binding.login.setOnClickListener {
|
|
||||||
val email = binding.username.text?.toString()
|
|
||||||
val password = binding.password.text?.toString()
|
|
||||||
|
|
||||||
if (!email.isNullOrEmpty() && !password.isNullOrEmpty()) {
|
|
||||||
signIn(email, password)
|
|
||||||
} else {
|
|
||||||
Toast.makeText(context, R.string.empty, Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
binding.register.setOnClickListener {
|
|
||||||
val email = binding.username.text?.toString().orEmpty()
|
|
||||||
val password = binding.password.text?.toString().orEmpty()
|
|
||||||
|
|
||||||
if (isEmail(email)) {
|
|
||||||
MaterialAlertDialogBuilder(requireContext())
|
|
||||||
.setTitle(R.string.privacy_alert)
|
|
||||||
.setMessage(R.string.username_email)
|
|
||||||
.setNegativeButton(R.string.proceed) { _, _ ->
|
|
||||||
signIn(email, password, true)
|
|
||||||
}
|
|
||||||
.setPositiveButton(R.string.cancel, null)
|
|
||||||
.show()
|
|
||||||
} else if (email.isNotEmpty() && password.isNotEmpty()) {
|
|
||||||
signIn(email, password, true)
|
|
||||||
} else {
|
|
||||||
Toast.makeText(context, R.string.empty, Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return MaterialAlertDialogBuilder(requireContext())
|
return MaterialAlertDialogBuilder(requireContext())
|
||||||
|
.setTitle(R.string.login)
|
||||||
|
.setPositiveButton(R.string.login, null)
|
||||||
|
.setNegativeButton(R.string.register, null)
|
||||||
.setView(binding.root)
|
.setView(binding.root)
|
||||||
.show()
|
.show()
|
||||||
|
.apply {
|
||||||
|
getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener {
|
||||||
|
val email = binding.username.text?.toString()
|
||||||
|
val password = binding.password.text?.toString()
|
||||||
|
|
||||||
|
if (!email.isNullOrEmpty() && !password.isNullOrEmpty()) {
|
||||||
|
signIn(email, password)
|
||||||
|
} else {
|
||||||
|
Toast.makeText(context, R.string.empty, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getButton(DialogInterface.BUTTON_NEGATIVE).setOnClickListener {
|
||||||
|
val email = binding.username.text?.toString().orEmpty()
|
||||||
|
val password = binding.password.text?.toString().orEmpty()
|
||||||
|
|
||||||
|
if (isEmail(email)) {
|
||||||
|
showPrivacyAlertDialog(email, password)
|
||||||
|
} else if (email.isNotEmpty() && password.isNotEmpty()) {
|
||||||
|
signIn(email, password, true)
|
||||||
|
} else {
|
||||||
|
Toast.makeText(context, R.string.empty, Toast.LENGTH_SHORT).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun signIn(username: String, password: String, createNewAccount: Boolean = false) {
|
private fun signIn(username: String, password: String, createNewAccount: Boolean = false) {
|
||||||
@ -109,6 +107,17 @@ class LoginDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun showPrivacyAlertDialog(email: String, password: String) {
|
||||||
|
MaterialAlertDialogBuilder(requireContext())
|
||||||
|
.setTitle(R.string.privacy_alert)
|
||||||
|
.setMessage(R.string.username_email)
|
||||||
|
.setNegativeButton(R.string.proceed) { _, _ ->
|
||||||
|
signIn(email, password, true)
|
||||||
|
}
|
||||||
|
.setPositiveButton(R.string.cancel, null)
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
private fun isEmail(text: String): Boolean {
|
private fun isEmail(text: String): Boolean {
|
||||||
return Patterns.EMAIL_ADDRESS.toRegex().matches(text)
|
return Patterns.EMAIL_ADDRESS.toRegex().matches(text)
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import androidx.fragment.app.DialogFragment
|
|||||||
import androidx.fragment.app.setFragmentResult
|
import androidx.fragment.app.setFragmentResult
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.constants.IntentData
|
import com.github.libretube.constants.IntentData
|
||||||
import com.github.libretube.databinding.DialogLogoutBinding
|
|
||||||
import com.github.libretube.helpers.PreferenceHelper
|
import com.github.libretube.helpers.PreferenceHelper
|
||||||
import com.github.libretube.ui.preferences.InstanceSettings
|
import com.github.libretube.ui.preferences.InstanceSettings
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
@ -17,23 +16,19 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|||||||
class LogoutDialog : DialogFragment() {
|
class LogoutDialog : DialogFragment() {
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
val binding = DialogLogoutBinding.inflate(layoutInflater)
|
|
||||||
|
|
||||||
val user = PreferenceHelper.getUsername()
|
val user = PreferenceHelper.getUsername()
|
||||||
|
|
||||||
binding.user.text = binding.user.text.toString() + " ($user)"
|
|
||||||
binding.logout.setOnClickListener {
|
|
||||||
Toast.makeText(context, R.string.loggedout, Toast.LENGTH_SHORT).show()
|
|
||||||
|
|
||||||
setFragmentResult(
|
|
||||||
InstanceSettings.INSTANCE_DIALOG_REQUEST_KEY,
|
|
||||||
bundleOf(IntentData.logoutTask to true)
|
|
||||||
)
|
|
||||||
dialog?.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
return MaterialAlertDialogBuilder(requireContext())
|
return MaterialAlertDialogBuilder(requireContext())
|
||||||
.setView(binding.root)
|
.setTitle(R.string.logout)
|
||||||
|
.setMessage(getString(R.string.already_logged_in) + " ($user)")
|
||||||
|
.setPositiveButton(R.string.logout) { _, _ ->
|
||||||
|
Toast.makeText(context, R.string.loggedout, Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
|
setFragmentResult(
|
||||||
|
InstanceSettings.INSTANCE_DIALOG_REQUEST_KEY,
|
||||||
|
bundleOf(IntentData.logoutTask to true)
|
||||||
|
)
|
||||||
|
}
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
package com.github.libretube.ui.views
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import androidx.appcompat.widget.AppCompatTextView
|
|
||||||
import androidx.core.util.TypedValueCompat
|
|
||||||
import com.github.libretube.helpers.ThemeHelper
|
|
||||||
|
|
||||||
class AppNameTextView : AppCompatTextView {
|
|
||||||
constructor(context: Context, attributeSet: AttributeSet?) : super(context, attributeSet)
|
|
||||||
|
|
||||||
constructor(context: Context) : super(context, null)
|
|
||||||
|
|
||||||
init {
|
|
||||||
text = ThemeHelper.getStyledAppName(context)
|
|
||||||
textSize = TypedValueCompat.spToPx(10f, resources.displayMetrics)
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,38 +6,13 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.github.libretube.ui.views.AppNameTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="10dp"
|
|
||||||
android:gravity="center" />
|
|
||||||
|
|
||||||
<com.github.libretube.ui.views.DropdownMenu
|
<com.github.libretube.ui.views.DropdownMenu
|
||||||
android:id="@+id/playlists_spinner"
|
android:id="@+id/playlists_spinner"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="24dp"
|
android:layout_marginHorizontal="24dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginTop="8dp"
|
||||||
app:icon="@drawable/ic_playlist_add"
|
app:icon="@drawable/ic_playlist_add"
|
||||||
tools:ignore="RtlSymmetry" />
|
tools:ignore="RtlSymmetry" />
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="end"
|
|
||||||
android:layout_marginEnd="16dp">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/create_playlist"
|
|
||||||
style="@style/CustomDialogButton"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:text="@string/createPlaylist" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/addToPlaylist"
|
|
||||||
style="@style/CustomDialogButton"
|
|
||||||
android:text="@string/addToPlaylist" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -2,13 +2,8 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="8dp">
|
||||||
<com.github.libretube.ui.views.AppNameTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="10dp"
|
|
||||||
android:gravity="center" />
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
style="@style/CustomDialogTextInputLayout"
|
style="@style/CustomDialogTextInputLayout"
|
||||||
@ -48,16 +43,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="end"
|
android:layout_gravity="end"
|
||||||
android:layout_marginEnd="20dp"
|
android:layout_marginEnd="20dp"
|
||||||
android:layout_marginBottom="10dp"
|
|
||||||
android:drawableStart="@drawable/ic_copy"
|
android:drawableStart="@drawable/ic_copy"
|
||||||
android:text="@string/createPlaylist" />
|
android:text="@string/createPlaylist" />
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/cancel_button"
|
|
||||||
style="@style/CustomDialogButton"
|
|
||||||
android:layout_gravity="end"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:text="@string/cancel" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -2,13 +2,8 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="8dp">
|
||||||
<com.github.libretube.ui.views.AppNameTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="10dp"
|
|
||||||
android:gravity="center" />
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
style="@style/CustomDialogTextInputLayout"
|
style="@style/CustomDialogTextInputLayout"
|
||||||
@ -43,23 +38,4 @@
|
|||||||
android:inputType="text" />
|
android:inputType="text" />
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="end"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/cancel"
|
|
||||||
style="@style/CustomDialogButton"
|
|
||||||
android:text="@string/cancel" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/addInstance"
|
|
||||||
style="@style/CustomDialogButton"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:text="@string/addInstance" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -3,13 +3,8 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="8dp">
|
||||||
<com.github.libretube.ui.views.AppNameTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="10dp"
|
|
||||||
android:gravity="center" />
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
style="@style/CustomDialogTextInputLayout"
|
style="@style/CustomDialogTextInputLayout"
|
||||||
@ -23,24 +18,4 @@
|
|||||||
android:inputType="textPassword" />
|
android:inputType="textPassword" />
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="end"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/cancel_button"
|
|
||||||
style="@style/CustomDialogButton"
|
|
||||||
android:text="@string/cancel" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/delete_account_confirm"
|
|
||||||
style="@style/CustomDialogButton"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:text="@string/deleteAccount" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -6,12 +6,6 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingHorizontal="20dp">
|
android:paddingHorizontal="20dp">
|
||||||
|
|
||||||
<com.github.libretube.ui.views.AppNameTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="10dp"
|
|
||||||
android:gravity="center" />
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -5,12 +5,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.github.libretube.ui.views.AppNameTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="10dp"
|
|
||||||
android:gravity="center" />
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
style="@style/CustomDialogTextInputLayout"
|
style="@style/CustomDialogTextInputLayout"
|
||||||
android:hint="@string/username">
|
android:hint="@string/username">
|
||||||
@ -34,24 +28,4 @@
|
|||||||
android:inputType="textPassword" />
|
android:inputType="textPassword" />
|
||||||
</com.google.android.material.textfield.TextInputLayout>
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:gravity="end"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/register"
|
|
||||||
style="@style/CustomDialogButton"
|
|
||||||
android:text="@string/register" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/login"
|
|
||||||
style="@style/CustomDialogButton"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:text="@string/login" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<com.github.libretube.ui.views.AppNameTextView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="10dp"
|
|
||||||
android:gravity="center" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/user"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_margin="8dp"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:text="@string/already_logged_in" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/logout"
|
|
||||||
style="@style/CustomDialogButton"
|
|
||||||
android:layout_marginEnd="16dp"
|
|
||||||
android:text="@string/logout" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
@ -43,16 +43,6 @@
|
|||||||
<item name="android:paddingBottom">15dp</item>
|
<item name="android:paddingBottom">15dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="CustomDialogButton" parent="@style/Widget.Material3.Button.TextButton">
|
|
||||||
|
|
||||||
<item name="android:layout_width">wrap_content</item>
|
|
||||||
<item name="android:layout_height">wrap_content</item>
|
|
||||||
<item name="android:layout_gravity">end</item>
|
|
||||||
<item name="android:layout_marginBottom">8dp</item>
|
|
||||||
<item name="android:padding">8dp</item>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="CustomDialogTextInputLayout" parent="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
|
<style name="CustomDialogTextInputLayout" parent="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">
|
||||||
|
|
||||||
<item name="android:layout_width">match_parent</item>
|
<item name="android:layout_width">match_parent</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user