mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
Create a AppNameTextView
component to clean up dialogs
This commit is contained in:
parent
5cdf670b15
commit
0dfb47143b
@ -17,7 +17,6 @@ import com.github.libretube.extensions.TAG
|
|||||||
import com.github.libretube.extensions.toStreamItem
|
import com.github.libretube.extensions.toStreamItem
|
||||||
import com.github.libretube.extensions.toastFromMainThread
|
import com.github.libretube.extensions.toastFromMainThread
|
||||||
import com.github.libretube.ui.models.PlaylistViewModel
|
import com.github.libretube.ui.models.PlaylistViewModel
|
||||||
import com.github.libretube.util.ThemeHelper
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@ -31,7 +30,6 @@ class AddToPlaylistDialog(
|
|||||||
|
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
binding = DialogAddtoplaylistBinding.inflate(layoutInflater)
|
binding = DialogAddtoplaylistBinding.inflate(layoutInflater)
|
||||||
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
|
||||||
|
|
||||||
binding.createPlaylist.setOnClickListener {
|
binding.createPlaylist.setOnClickListener {
|
||||||
CreatePlaylistDialog {
|
CreatePlaylistDialog {
|
||||||
|
@ -9,7 +9,6 @@ import com.github.libretube.R
|
|||||||
import com.github.libretube.api.PlaylistsHelper
|
import com.github.libretube.api.PlaylistsHelper
|
||||||
import com.github.libretube.databinding.DialogCreatePlaylistBinding
|
import com.github.libretube.databinding.DialogCreatePlaylistBinding
|
||||||
import com.github.libretube.util.TextUtils
|
import com.github.libretube.util.TextUtils
|
||||||
import com.github.libretube.util.ThemeHelper
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
|
||||||
class CreatePlaylistDialog(
|
class CreatePlaylistDialog(
|
||||||
@ -20,8 +19,6 @@ class CreatePlaylistDialog(
|
|||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
binding = DialogCreatePlaylistBinding.inflate(layoutInflater)
|
binding = DialogCreatePlaylistBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
|
||||||
|
|
||||||
binding.clonePlaylist.setOnClickListener {
|
binding.clonePlaylist.setOnClickListener {
|
||||||
val playlistUrl = binding.playlistUrl.text.toString()
|
val playlistUrl = binding.playlistUrl.text.toString()
|
||||||
if (!TextUtils.validateUrl(playlistUrl)) {
|
if (!TextUtils.validateUrl(playlistUrl)) {
|
||||||
|
@ -9,7 +9,6 @@ import com.github.libretube.databinding.DialogCustomInstanceBinding
|
|||||||
import com.github.libretube.db.DatabaseHolder.Companion.Database
|
import com.github.libretube.db.DatabaseHolder.Companion.Database
|
||||||
import com.github.libretube.db.obj.CustomInstance
|
import com.github.libretube.db.obj.CustomInstance
|
||||||
import com.github.libretube.extensions.query
|
import com.github.libretube.extensions.query
|
||||||
import com.github.libretube.util.ThemeHelper
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
|
||||||
@ -64,8 +63,6 @@ class CustomInstanceDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
|
||||||
|
|
||||||
return MaterialAlertDialogBuilder(requireContext())
|
return MaterialAlertDialogBuilder(requireContext())
|
||||||
.setView(binding.root)
|
.setView(binding.root)
|
||||||
.show()
|
.show()
|
||||||
|
@ -11,7 +11,6 @@ import com.github.libretube.api.RetrofitInstance
|
|||||||
import com.github.libretube.databinding.DialogDeleteAccountBinding
|
import com.github.libretube.databinding.DialogDeleteAccountBinding
|
||||||
import com.github.libretube.extensions.TAG
|
import com.github.libretube.extensions.TAG
|
||||||
import com.github.libretube.util.PreferenceHelper
|
import com.github.libretube.util.PreferenceHelper
|
||||||
import com.github.libretube.util.ThemeHelper
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
|
||||||
class DeleteAccountDialog : DialogFragment() {
|
class DeleteAccountDialog : DialogFragment() {
|
||||||
@ -32,8 +31,6 @@ class DeleteAccountDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
|
||||||
|
|
||||||
return MaterialAlertDialogBuilder(requireContext())
|
return MaterialAlertDialogBuilder(requireContext())
|
||||||
.setView(binding.root)
|
.setView(binding.root)
|
||||||
.show()
|
.show()
|
||||||
|
@ -19,7 +19,6 @@ import com.github.libretube.extensions.sanitize
|
|||||||
import com.github.libretube.services.DownloadService
|
import com.github.libretube.services.DownloadService
|
||||||
import com.github.libretube.util.ImageHelper
|
import com.github.libretube.util.ImageHelper
|
||||||
import com.github.libretube.util.MetadataHelper
|
import com.github.libretube.util.MetadataHelper
|
||||||
import com.github.libretube.util.ThemeHelper
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import retrofit2.HttpException
|
import retrofit2.HttpException
|
||||||
@ -34,8 +33,6 @@ class DownloadDialog(
|
|||||||
|
|
||||||
fetchAvailableSources()
|
fetchAvailableSources()
|
||||||
|
|
||||||
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
|
||||||
|
|
||||||
binding.audioRadio.setOnClickListener {
|
binding.audioRadio.setOnClickListener {
|
||||||
binding.videoSpinner.visibility = View.GONE
|
binding.videoSpinner.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import com.github.libretube.databinding.DialogLoginBinding
|
|||||||
import com.github.libretube.extensions.TAG
|
import com.github.libretube.extensions.TAG
|
||||||
import com.github.libretube.util.PreferenceHelper
|
import com.github.libretube.util.PreferenceHelper
|
||||||
import com.github.libretube.util.TextUtils
|
import com.github.libretube.util.TextUtils
|
||||||
import com.github.libretube.util.ThemeHelper
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
|
||||||
class LoginDialog : DialogFragment() {
|
class LoginDialog : DialogFragment() {
|
||||||
@ -57,8 +56,6 @@ class LoginDialog : DialogFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
|
||||||
|
|
||||||
return MaterialAlertDialogBuilder(requireContext())
|
return MaterialAlertDialogBuilder(requireContext())
|
||||||
.setView(binding.root)
|
.setView(binding.root)
|
||||||
.show()
|
.show()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.libretube.ui.dialogs
|
package com.github.libretube.ui.dialogs
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.Dialog
|
import android.app.Dialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
@ -7,12 +8,12 @@ import androidx.fragment.app.DialogFragment
|
|||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
import com.github.libretube.databinding.DialogLogoutBinding
|
import com.github.libretube.databinding.DialogLogoutBinding
|
||||||
import com.github.libretube.util.PreferenceHelper
|
import com.github.libretube.util.PreferenceHelper
|
||||||
import com.github.libretube.util.ThemeHelper
|
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
|
||||||
class LogoutDialog : DialogFragment() {
|
class LogoutDialog : DialogFragment() {
|
||||||
private lateinit var binding: DialogLogoutBinding
|
private lateinit var binding: DialogLogoutBinding
|
||||||
|
|
||||||
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||||
binding = DialogLogoutBinding.inflate(layoutInflater)
|
binding = DialogLogoutBinding.inflate(layoutInflater)
|
||||||
|
|
||||||
@ -27,8 +28,6 @@ class LogoutDialog : DialogFragment() {
|
|||||||
activity?.recreate()
|
activity?.recreate()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.title.text = ThemeHelper.getStyledAppName(requireContext())
|
|
||||||
|
|
||||||
return MaterialAlertDialogBuilder(requireContext())
|
return MaterialAlertDialogBuilder(requireContext())
|
||||||
.setView(binding.root)
|
.setView(binding.root)
|
||||||
.show()
|
.show()
|
||||||
|
@ -4,7 +4,6 @@ import android.os.Bundle
|
|||||||
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 androidx.recyclerview.widget.GridLayoutManager
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.github.libretube.databinding.FragmentBookmarksBinding
|
import com.github.libretube.databinding.FragmentBookmarksBinding
|
||||||
import com.github.libretube.db.DatabaseHolder.Companion.Database
|
import com.github.libretube.db.DatabaseHolder.Companion.Database
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.github.libretube.ui.views
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.util.TypedValue
|
||||||
|
import androidx.appcompat.widget.AppCompatTextView
|
||||||
|
import com.github.libretube.util.ThemeHelper
|
||||||
|
|
||||||
|
class AppNameTextView : AppCompatTextView {
|
||||||
|
constructor(context: Context, attributeSet: AttributeSet?) : super(context, attributeSet)
|
||||||
|
|
||||||
|
constructor(context: Context) : super(context, null)
|
||||||
|
|
||||||
|
init {
|
||||||
|
text = ThemeHelper.getStyledAppName(context)
|
||||||
|
textSize = spToPixel(10f)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("SameParameterValue")
|
||||||
|
private fun spToPixel(sp: Float): Float {
|
||||||
|
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, sp, resources.displayMetrics)
|
||||||
|
}
|
||||||
|
}
|
@ -5,14 +5,11 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<com.github.libretube.ui.views.AppNameTextView
|
||||||
android:id="@+id/title"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:gravity="center"
|
android:gravity="center" />
|
||||||
android:text="@string/app_name"
|
|
||||||
android:textSize="20sp" />
|
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/playlists_spinner"
|
android:id="@+id/playlists_spinner"
|
||||||
|
@ -4,14 +4,11 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<com.github.libretube.ui.views.AppNameTextView
|
||||||
android:id="@+id/title"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:gravity="center"
|
android:gravity="center" />
|
||||||
android:text="@string/app_name"
|
|
||||||
android:textSize="20sp" />
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
style="@style/CustomDialogTextInputLayout"
|
style="@style/CustomDialogTextInputLayout"
|
||||||
|
@ -4,14 +4,11 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<com.github.libretube.ui.views.AppNameTextView
|
||||||
android:id="@+id/title"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:gravity="center"
|
android:gravity="center" />
|
||||||
android:text="@string/app_name"
|
|
||||||
android:textSize="20sp" />
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
style="@style/CustomDialogTextInputLayout"
|
style="@style/CustomDialogTextInputLayout"
|
||||||
|
@ -5,14 +5,11 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<com.github.libretube.ui.views.AppNameTextView
|
||||||
android:id="@+id/title"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:gravity="center"
|
android:gravity="center" />
|
||||||
android:text="@string/app_name"
|
|
||||||
android:textSize="20sp" />
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
style="@style/CustomDialogTextInputLayout"
|
style="@style/CustomDialogTextInputLayout"
|
||||||
|
@ -5,14 +5,11 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:paddingHorizontal="20dp">
|
android:paddingHorizontal="20dp">
|
||||||
|
|
||||||
<TextView
|
<com.github.libretube.ui.views.AppNameTextView
|
||||||
android:id="@+id/title"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:gravity="center"
|
android:gravity="center" />
|
||||||
android:text="@string/app_name"
|
|
||||||
android:textSize="20sp" />
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -5,14 +5,11 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<com.github.libretube.ui.views.AppNameTextView
|
||||||
android:id="@+id/title"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:gravity="center"
|
android:gravity="center" />
|
||||||
android:text="@string/app_name"
|
|
||||||
android:textSize="20sp" />
|
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputLayout
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
style="@style/CustomDialogTextInputLayout"
|
style="@style/CustomDialogTextInputLayout"
|
||||||
|
@ -4,14 +4,11 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<TextView
|
<com.github.libretube.ui.views.AppNameTextView
|
||||||
android:id="@+id/title"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:gravity="center"
|
android:gravity="center" />
|
||||||
android:text="@string/app_name"
|
|
||||||
android:textSize="20sp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/user"
|
android:id="@+id/user"
|
||||||
@ -24,7 +21,7 @@
|
|||||||
<Button
|
<Button
|
||||||
android:id="@+id/logout"
|
android:id="@+id/logout"
|
||||||
style="@style/CustomDialogButton"
|
style="@style/CustomDialogButton"
|
||||||
android:layout_marginRight="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:text="@string/logout" />
|
android:text="@string/logout" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
<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="emptyPlaylistName">The playlist name can\'t be empty</string>
|
<string name="emptyPlaylistName">The playlist name can\'t be empty</string>
|
||||||
<string name="addToPlaylist">Add</string>
|
<string name="addToPlaylist">Add to playlist</string>
|
||||||
<string name="success">Done.</string>
|
<string name="success">Done.</string>
|
||||||
<string name="fail">Failed :(</string>
|
<string name="fail">Failed :(</string>
|
||||||
<string name="about">About</string>
|
<string name="about">About</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user