mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
more views
This commit is contained in:
parent
647e91bc4b
commit
273a947f8e
7 changed files with 491 additions and 454 deletions
|
@ -11,9 +11,9 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import com.lagradost.cloudstream3.LoadResponse
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.setImage
|
||||
import kotlinx.android.synthetic.main.fragment_home_head_tv.*
|
||||
import kotlinx.android.synthetic.main.fragment_home_head_tv.view.*
|
||||
import kotlinx.android.synthetic.main.home_scroll_view.view.*
|
||||
import kotlinx.android.synthetic.main.home_scroll_view.view.home_scroll_preview
|
||||
import kotlinx.android.synthetic.main.home_scroll_view.view.home_scroll_preview_tags
|
||||
import kotlinx.android.synthetic.main.home_scroll_view.view.home_scroll_preview_title
|
||||
|
||||
|
||||
class HomeScrollAdapter(
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
package com.lagradost.cloudstream3.ui.player.source_priority
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.databinding.PlayerPrioritizeItemBinding
|
||||
import com.lagradost.cloudstream3.utils.AppUtils
|
||||
import kotlinx.android.synthetic.main.player_prioritize_item.view.*
|
||||
|
||||
data class SourcePriority<T>(
|
||||
val data: T,
|
||||
|
@ -20,7 +16,8 @@ class PriorityAdapter<T>(override val items: MutableList<SourcePriority<T>>) :
|
|||
AppUtils.DiffAdapter<SourcePriority<T>>(items) {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
return PriorityViewHolder(
|
||||
LayoutInflater.from(parent.context).inflate(R.layout.player_prioritize_item, parent, false)
|
||||
PlayerPrioritizeItemBinding.inflate(LayoutInflater.from(parent.context),parent,false),
|
||||
//LayoutInflater.from(parent.context).inflate(R.layout.player_prioritize_item, parent, false)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -31,27 +28,27 @@ class PriorityAdapter<T>(override val items: MutableList<SourcePriority<T>>) :
|
|||
}
|
||||
|
||||
class PriorityViewHolder(
|
||||
itemView: View,
|
||||
) : RecyclerView.ViewHolder(itemView) {
|
||||
val binding: PlayerPrioritizeItemBinding,
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
fun <T> bind(item: SourcePriority<T>) {
|
||||
val plusButton: ImageView = itemView.add_button
|
||||
/* val plusButton: ImageView = itemView.add_button
|
||||
val subtractButton: ImageView = itemView.subtract_button
|
||||
val priorityText: TextView = itemView.priority_text
|
||||
val priorityNumber: TextView = itemView.priority_number
|
||||
priorityText.text = item.name
|
||||
val priorityNumber: TextView = itemView.priority_number*/
|
||||
binding.priorityText.text = item.name
|
||||
|
||||
fun updatePriority() {
|
||||
priorityNumber.text = item.priority.toString()
|
||||
binding.priorityNumber.text = item.priority.toString()
|
||||
}
|
||||
|
||||
updatePriority()
|
||||
plusButton.setOnClickListener {
|
||||
binding.addButton.setOnClickListener {
|
||||
// If someone clicks til the integer limit then they deserve to crash.
|
||||
item.priority++
|
||||
updatePriority()
|
||||
}
|
||||
|
||||
subtractButton.setOnClickListener {
|
||||
binding.subtractButton.setOnClickListener {
|
||||
item.priority--
|
||||
updatePriority()
|
||||
}
|
||||
|
|
|
@ -8,19 +8,13 @@ import android.view.ViewGroup
|
|||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.databinding.PlayerQualityProfileItemBinding
|
||||
import com.lagradost.cloudstream3.ui.result.UiImage
|
||||
import com.lagradost.cloudstream3.utils.AppUtils
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.setImage
|
||||
import kotlinx.android.synthetic.main.player_quality_profile_item.view.card_view
|
||||
import kotlinx.android.synthetic.main.player_quality_profile_item.view.outline
|
||||
import kotlinx.android.synthetic.main.player_quality_profile_item.view.profile_image_background
|
||||
import kotlinx.android.synthetic.main.player_quality_profile_item.view.profile_text
|
||||
import kotlinx.android.synthetic.main.player_quality_profile_item.view.text_is_mobile_data
|
||||
import kotlinx.android.synthetic.main.player_quality_profile_item.view.text_is_wifi
|
||||
|
||||
class ProfilesAdapter(
|
||||
override val items: MutableList<QualityDataHelper.QualityProfile>,
|
||||
|
@ -34,8 +28,9 @@ class ProfilesAdapter(
|
|||
}) {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
return ProfilesViewHolder(
|
||||
LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.player_quality_profile_item, parent, false)
|
||||
PlayerQualityProfileItemBinding.inflate(LayoutInflater.from(parent.context),parent,false)
|
||||
//LayoutInflater.from(parent.context)
|
||||
// .inflate(R.layout.player_quality_profile_item, parent, false)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -52,8 +47,8 @@ class ProfilesAdapter(
|
|||
}
|
||||
|
||||
inner class ProfilesViewHolder(
|
||||
itemView: View,
|
||||
) : RecyclerView.ViewHolder(itemView) {
|
||||
val binding: PlayerQualityProfileItemBinding,
|
||||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
private val art = listOf(
|
||||
R.drawable.profile_bg_teal,
|
||||
R.drawable.profile_bg_blue,
|
||||
|
@ -65,12 +60,12 @@ class ProfilesAdapter(
|
|||
)
|
||||
|
||||
fun bind(item: QualityDataHelper.QualityProfile, index: Int) {
|
||||
val priorityText: TextView = itemView.profile_text
|
||||
val profileBg: ImageView = itemView.profile_image_background
|
||||
val wifiText: TextView = itemView.text_is_wifi
|
||||
val dataText: TextView = itemView.text_is_mobile_data
|
||||
val outline: View = itemView.outline
|
||||
val cardView: View = itemView.card_view
|
||||
val priorityText: TextView = binding.profileText
|
||||
val profileBg: ImageView = binding.profileImageBackground
|
||||
val wifiText: TextView = binding.textIsWifi
|
||||
val dataText: TextView = binding.textIsMobileData
|
||||
val outline: View = binding.outline
|
||||
val cardView: View = binding.cardView
|
||||
|
||||
priorityText.text = item.name.asString(itemView.context)
|
||||
dataText.isVisible = item.type == QualityDataHelper.QualityProfileType.Data
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
package com.lagradost.cloudstream3.ui.player.source_priority
|
||||
|
||||
import android.app.Dialog
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.StyleRes
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.databinding.PlayerQualityProfileDialogBinding
|
||||
import com.lagradost.cloudstream3.ui.player.source_priority.QualityDataHelper.getProfileName
|
||||
import com.lagradost.cloudstream3.ui.player.source_priority.QualityDataHelper.getProfiles
|
||||
import com.lagradost.cloudstream3.ui.result.txt
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||
import kotlinx.android.synthetic.main.player_quality_profile_dialog.*
|
||||
|
||||
class QualityProfileDialog(
|
||||
val activity: FragmentActivity,
|
||||
|
@ -24,83 +20,86 @@ class QualityProfileDialog(
|
|||
private val profileSelectionCallback: (QualityDataHelper.QualityProfile) -> Unit
|
||||
) : Dialog(activity, themeRes) {
|
||||
override fun show() {
|
||||
setContentView(R.layout.player_quality_profile_dialog)
|
||||
val profilesRecyclerView: RecyclerView = profiles_recyclerview
|
||||
|
||||
val binding = PlayerQualityProfileDialogBinding.inflate(this.layoutInflater, null, false)
|
||||
|
||||
setContentView(binding.root)//R.layout.player_quality_profile_dialog)
|
||||
/*val profilesRecyclerView: RecyclerView = profiles_recyclerview
|
||||
val useBtt: View = use_btt
|
||||
val editBtt: View = edit_btt
|
||||
val cancelBtt: View = cancel_btt
|
||||
val defaultBtt: View = set_default_btt
|
||||
val currentProfileText: TextView = currently_selected_profile_text
|
||||
val selectedItemActionsHolder: View = selected_item_holder
|
||||
|
||||
fun getCurrentProfile(): QualityDataHelper.QualityProfile? {
|
||||
return (profilesRecyclerView.adapter as? ProfilesAdapter)?.getCurrentProfile()
|
||||
}
|
||||
|
||||
fun refreshProfiles() {
|
||||
currentProfileText.text = getProfileName(usedProfile).asString(context)
|
||||
(profilesRecyclerView.adapter as? ProfilesAdapter)?.updateList(getProfiles())
|
||||
}
|
||||
|
||||
profilesRecyclerView.adapter = ProfilesAdapter(
|
||||
mutableListOf(),
|
||||
usedProfile,
|
||||
) { oldIndex: Int?, newIndex: Int ->
|
||||
profilesRecyclerView.adapter?.notifyItemChanged(newIndex)
|
||||
selectedItemActionsHolder.alpha = 1f
|
||||
if (oldIndex != null) {
|
||||
profilesRecyclerView.adapter?.notifyItemChanged(oldIndex)
|
||||
val selectedItemActionsHolder: View = selected_item_holder*/
|
||||
binding.apply {
|
||||
fun getCurrentProfile(): QualityDataHelper.QualityProfile? {
|
||||
return (profilesRecyclerview.adapter as? ProfilesAdapter)?.getCurrentProfile()
|
||||
}
|
||||
}
|
||||
|
||||
refreshProfiles()
|
||||
|
||||
editBtt.setOnClickListener {
|
||||
getCurrentProfile()?.let { profile ->
|
||||
SourcePriorityDialog(context, themeRes, links, profile) {
|
||||
refreshProfiles()
|
||||
}.show()
|
||||
fun refreshProfiles() {
|
||||
currentlySelectedProfileText.text = getProfileName(usedProfile).asString(context)
|
||||
(profilesRecyclerview.adapter as? ProfilesAdapter)?.updateList(getProfiles())
|
||||
}
|
||||
|
||||
profilesRecyclerview.adapter = ProfilesAdapter(
|
||||
mutableListOf(),
|
||||
usedProfile,
|
||||
) { oldIndex: Int?, newIndex: Int ->
|
||||
profilesRecyclerview.adapter?.notifyItemChanged(newIndex)
|
||||
selectedItemHolder.alpha = 1f
|
||||
if (oldIndex != null) {
|
||||
profilesRecyclerview.adapter?.notifyItemChanged(oldIndex)
|
||||
}
|
||||
}
|
||||
|
||||
refreshProfiles()
|
||||
|
||||
editBtt.setOnClickListener {
|
||||
getCurrentProfile()?.let { profile ->
|
||||
SourcePriorityDialog(context, themeRes, links, profile) {
|
||||
refreshProfiles()
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
defaultBtt.setOnClickListener {
|
||||
val currentProfile = getCurrentProfile() ?: return@setOnClickListener
|
||||
val choices = QualityDataHelper.QualityProfileType.values()
|
||||
.filter { it != QualityDataHelper.QualityProfileType.None }
|
||||
val choiceNames = choices.map { txt(it.stringRes).asString(context) }
|
||||
setDefaultBtt.setOnClickListener {
|
||||
val currentProfile = getCurrentProfile() ?: return@setOnClickListener
|
||||
val choices = QualityDataHelper.QualityProfileType.values()
|
||||
.filter { it != QualityDataHelper.QualityProfileType.None }
|
||||
val choiceNames = choices.map { txt(it.stringRes).asString(context) }
|
||||
|
||||
activity.showBottomDialog(
|
||||
choiceNames,
|
||||
choices.indexOf(currentProfile.type),
|
||||
txt(R.string.set_default).asString(context),
|
||||
false,
|
||||
{},
|
||||
{ index ->
|
||||
val pickedChoice = choices.getOrNull(index) ?: return@showBottomDialog
|
||||
// Remove previous picks
|
||||
if (pickedChoice.unique) {
|
||||
getProfiles().filter { it.type == pickedChoice }.forEach {
|
||||
QualityDataHelper.setQualityProfileType(it.id, null)
|
||||
activity.showBottomDialog(
|
||||
choiceNames,
|
||||
choices.indexOf(currentProfile.type),
|
||||
txt(R.string.set_default).asString(context),
|
||||
false,
|
||||
{},
|
||||
{ index ->
|
||||
val pickedChoice = choices.getOrNull(index) ?: return@showBottomDialog
|
||||
// Remove previous picks
|
||||
if (pickedChoice.unique) {
|
||||
getProfiles().filter { it.type == pickedChoice }.forEach {
|
||||
QualityDataHelper.setQualityProfileType(it.id, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QualityDataHelper.setQualityProfileType(currentProfile.id, pickedChoice)
|
||||
refreshProfiles()
|
||||
})
|
||||
}
|
||||
QualityDataHelper.setQualityProfileType(currentProfile.id, pickedChoice)
|
||||
refreshProfiles()
|
||||
})
|
||||
}
|
||||
|
||||
cancelBtt.setOnClickListener {
|
||||
this.dismissSafe()
|
||||
}
|
||||
cancelBtt.setOnClickListener {
|
||||
this@QualityProfileDialog.dismissSafe()
|
||||
}
|
||||
|
||||
useBtt.setOnClickListener {
|
||||
getCurrentProfile()?.let {
|
||||
profileSelectionCallback.invoke(it)
|
||||
this.dismissSafe()
|
||||
useBtt.setOnClickListener {
|
||||
getCurrentProfile()?.let {
|
||||
profileSelectionCallback.invoke(it)
|
||||
this@QualityProfileDialog.dismissSafe()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.show()
|
||||
}
|
||||
}
|
|
@ -2,30 +2,29 @@ package com.lagradost.cloudstream3.ui.settings.extensions
|
|||
|
||||
import android.content.res.ColorStateList
|
||||
import android.os.Bundle
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import android.text.format.Formatter.formatFileSize
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.setImage
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.toPx
|
||||
import kotlinx.android.synthetic.main.fragment_plugin_details.*
|
||||
import android.text.format.Formatter.formatFileSize
|
||||
import android.util.Log
|
||||
import androidx.core.view.isVisible
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.databinding.FragmentPluginDetailsBinding
|
||||
import com.lagradost.cloudstream3.plugins.PluginManager
|
||||
import com.lagradost.cloudstream3.plugins.VotingApi
|
||||
import com.lagradost.cloudstream3.plugins.VotingApi.canVote
|
||||
import com.lagradost.cloudstream3.plugins.VotingApi.getVoteType
|
||||
import com.lagradost.cloudstream3.plugins.VotingApi.getVotes
|
||||
import com.lagradost.cloudstream3.plugins.VotingApi.vote
|
||||
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
||||
import com.lagradost.cloudstream3.utils.Coroutines.main
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
||||
import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser
|
||||
import com.lagradost.cloudstream3.plugins.PluginManager
|
||||
import com.lagradost.cloudstream3.plugins.VotingApi.canVote
|
||||
import com.lagradost.cloudstream3.utils.SubtitleHelper.fromTwoLettersToLanguage
|
||||
import com.lagradost.cloudstream3.utils.SubtitleHelper.getFlagFromIso
|
||||
import kotlinx.android.synthetic.main.repository_item.view.*
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.setImage
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.toPx
|
||||
|
||||
|
||||
class PluginDetailsFragment(val data: PluginViewData) : BottomSheetDialogFragment() {
|
||||
|
@ -43,18 +42,27 @@ class PluginDetailsFragment(val data: PluginViewData) : BottomSheetDialogFragmen
|
|||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
binding = null
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
var binding: FragmentPluginDetailsBinding? = null
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_plugin_details, container, false)
|
||||
|
||||
): View {
|
||||
val localBinding = FragmentPluginDetailsBinding.inflate(inflater, container, false)
|
||||
binding = localBinding
|
||||
return localBinding.root
|
||||
//return inflater.inflate(R.layout.fragment_plugin_details, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val metadata = data.plugin.second
|
||||
if (plugin_icon?.setImage(//plugin_icon?.height ?:
|
||||
binding?.apply {
|
||||
if (!pluginIcon.setImage(//plugin_icon?.height ?:
|
||||
metadata.iconUrl?.replace(
|
||||
"%size%",
|
||||
"$iconSize"
|
||||
|
@ -64,23 +72,33 @@ class PluginDetailsFragment(val data: PluginViewData) : BottomSheetDialogFragmen
|
|||
),
|
||||
null,
|
||||
errorImageDrawable = R.drawable.ic_baseline_extension_24
|
||||
) != true
|
||||
)
|
||||
) {
|
||||
plugin_icon?.setImageResource(R.drawable.ic_baseline_extension_24)
|
||||
pluginIcon.setImageResource(R.drawable.ic_baseline_extension_24)
|
||||
}
|
||||
plugin_name?.text = metadata.name.removeSuffix("Provider")
|
||||
plugin_version?.text = metadata.version.toString()
|
||||
plugin_description?.text = metadata.description ?: getString(R.string.no_data)
|
||||
plugin_size?.text = if (metadata.fileSize == null) getString(R.string.no_data) else formatFileSize(context, metadata.fileSize)
|
||||
plugin_author?.text = if (metadata.authors.isEmpty()) getString(R.string.no_data) else metadata.authors.joinToString(", ")
|
||||
plugin_status?.text = resources.getStringArray(R.array.extension_statuses)[metadata.status]
|
||||
plugin_types?.text = if ((metadata.tvTypes == null) || metadata.tvTypes.isEmpty()) getString(R.string.no_data) else metadata.tvTypes.joinToString(", ")
|
||||
plugin_lang?.text = if (metadata.language == null)
|
||||
getString(R.string.no_data)
|
||||
pluginName.text = metadata.name.removeSuffix("Provider")
|
||||
pluginVersion.text = metadata.version.toString()
|
||||
pluginDescription.text = metadata.description ?: getString(R.string.no_data)
|
||||
pluginSize.text =
|
||||
if (metadata.fileSize == null) getString(R.string.no_data) else formatFileSize(
|
||||
context,
|
||||
metadata.fileSize
|
||||
)
|
||||
pluginAuthor.text =
|
||||
if (metadata.authors.isEmpty()) getString(R.string.no_data) else metadata.authors.joinToString(
|
||||
", "
|
||||
)
|
||||
pluginStatus.text = resources.getStringArray(R.array.extension_statuses)[metadata.status]
|
||||
pluginTypes.text =
|
||||
if (metadata.tvTypes.isNullOrEmpty()) getString(R.string.no_data) else metadata.tvTypes.joinToString(
|
||||
", "
|
||||
)
|
||||
pluginLang.text = if (metadata.language == null)
|
||||
getString(R.string.no_data)
|
||||
else
|
||||
"${getFlagFromIso(metadata.language)} ${fromTwoLettersToLanguage(metadata.language)}"
|
||||
"${getFlagFromIso(metadata.language)} ${fromTwoLettersToLanguage(metadata.language)}"
|
||||
|
||||
github_btn.setOnClickListener {
|
||||
githubBtn.setOnClickListener {
|
||||
if (metadata.repositoryUrl != null) {
|
||||
openBrowser(metadata.repositoryUrl)
|
||||
}
|
||||
|
@ -93,10 +111,11 @@ class PluginDetailsFragment(val data: PluginViewData) : BottomSheetDialogFragmen
|
|||
|
||||
if (data.isDownloaded) {
|
||||
// On local plugins page the filepath is provided instead of url.
|
||||
val plugin = PluginManager.urlPlugins[metadata.url] ?: PluginManager.plugins[metadata.url]
|
||||
val plugin =
|
||||
PluginManager.urlPlugins[metadata.url] ?: PluginManager.plugins[metadata.url]
|
||||
if (plugin?.openSettings != null && context != null) {
|
||||
action_settings?.isVisible = true
|
||||
action_settings.setOnClickListener {
|
||||
actionSettings.isVisible = true
|
||||
actionSettings.setOnClickListener {
|
||||
try {
|
||||
plugin.openSettings!!.invoke(requireContext())
|
||||
} catch (e: Throwable) {
|
||||
|
@ -109,10 +128,10 @@ class PluginDetailsFragment(val data: PluginViewData) : BottomSheetDialogFragmen
|
|||
}
|
||||
}
|
||||
} else {
|
||||
action_settings?.isVisible = false
|
||||
actionSettings.isVisible = false
|
||||
}
|
||||
} else {
|
||||
action_settings?.isVisible = false
|
||||
actionSettings.isVisible = false
|
||||
}
|
||||
|
||||
upvote.setOnClickListener {
|
||||
|
@ -136,23 +155,40 @@ class PluginDetailsFragment(val data: PluginViewData) : BottomSheetDialogFragmen
|
|||
updateVoting(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateVoting(value: Int) {
|
||||
val metadata = data.plugin.second
|
||||
plugin_votes.text = value.toString()
|
||||
when (metadata.getVoteType()) {
|
||||
VotingApi.VoteType.UPVOTE -> {
|
||||
upvote.imageTintList = ColorStateList.valueOf(context?.colorFromAttribute(R.attr.colorPrimary) ?: R.color.colorPrimary)
|
||||
downvote.imageTintList = ColorStateList.valueOf(context?.colorFromAttribute(R.attr.white) ?: R.color.white)
|
||||
}
|
||||
VotingApi.VoteType.DOWNVOTE -> {
|
||||
downvote.imageTintList = ColorStateList.valueOf(context?.colorFromAttribute(R.attr.colorPrimary) ?: R.color.colorPrimary)
|
||||
upvote.imageTintList = ColorStateList.valueOf(context?.colorFromAttribute(R.attr.white) ?: R.color.white)
|
||||
}
|
||||
VotingApi.VoteType.NONE -> {
|
||||
upvote.imageTintList = ColorStateList.valueOf(context?.colorFromAttribute(R.attr.white) ?: R.color.white)
|
||||
downvote.imageTintList = ColorStateList.valueOf(context?.colorFromAttribute(R.attr.white) ?: R.color.white)
|
||||
binding?.apply {
|
||||
pluginVotes.text = value.toString()
|
||||
when (metadata.getVoteType()) {
|
||||
VotingApi.VoteType.UPVOTE -> {
|
||||
upvote.imageTintList = ColorStateList.valueOf(
|
||||
context?.colorFromAttribute(R.attr.colorPrimary) ?: R.color.colorPrimary
|
||||
)
|
||||
downvote.imageTintList = ColorStateList.valueOf(
|
||||
context?.colorFromAttribute(R.attr.white) ?: R.color.white
|
||||
)
|
||||
}
|
||||
|
||||
VotingApi.VoteType.DOWNVOTE -> {
|
||||
downvote.imageTintList = ColorStateList.valueOf(
|
||||
context?.colorFromAttribute(R.attr.colorPrimary) ?: R.color.colorPrimary
|
||||
)
|
||||
upvote.imageTintList = ColorStateList.valueOf(
|
||||
context?.colorFromAttribute(R.attr.white) ?: R.color.white
|
||||
)
|
||||
}
|
||||
|
||||
VotingApi.VoteType.NONE -> {
|
||||
upvote.imageTintList = ColorStateList.valueOf(
|
||||
context?.colorFromAttribute(R.attr.white) ?: R.color.white
|
||||
)
|
||||
downvote.imageTintList = ColorStateList.valueOf(
|
||||
context?.colorFromAttribute(R.attr.white) ?: R.color.white
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,19 +10,20 @@ import androidx.core.content.ContextCompat
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lagradost.cloudstream3.MainAPI
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.databinding.ProviderTestItemBinding
|
||||
import com.lagradost.cloudstream3.mvvm.getAllMessages
|
||||
import com.lagradost.cloudstream3.mvvm.getStackTracePretty
|
||||
import com.lagradost.cloudstream3.utils.AppUtils
|
||||
import com.lagradost.cloudstream3.utils.SubtitleHelper.getFlagFromIso
|
||||
import com.lagradost.cloudstream3.utils.TestingUtils
|
||||
import kotlinx.android.synthetic.main.provider_test_item.view.*
|
||||
|
||||
class TestResultAdapter(override val items: MutableList<Pair<MainAPI, TestingUtils.TestResultProvider>>) :
|
||||
AppUtils.DiffAdapter<Pair<MainAPI, TestingUtils.TestResultProvider>>(items) {
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
return ProviderTestViewHolder(
|
||||
LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.provider_test_item, parent, false),
|
||||
ProviderTestItemBinding.inflate(LayoutInflater.from(parent.context), parent,false)
|
||||
//LayoutInflater.from(parent.context)
|
||||
// .inflate(R.layout.provider_test_item, parent, false),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -35,12 +36,12 @@ class TestResultAdapter(override val items: MutableList<Pair<MainAPI, TestingUti
|
|||
}
|
||||
}
|
||||
|
||||
inner class ProviderTestViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
private val languageText: TextView = itemView.lang_icon
|
||||
private val providerTitle: TextView = itemView.main_text
|
||||
private val statusText: TextView = itemView.passed_failed_marker
|
||||
private val failDescription: TextView = itemView.fail_description
|
||||
private val logButton: ImageView = itemView.action_button
|
||||
inner class ProviderTestViewHolder(binding: ProviderTestItemBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
private val languageText: TextView = binding.langIcon
|
||||
private val providerTitle: TextView = binding.mainText
|
||||
private val statusText: TextView = binding.passedFailedMarker
|
||||
private val failDescription: TextView = binding.failDescription
|
||||
private val logButton: ImageView = binding.actionButton
|
||||
|
||||
private fun String.lastLine(): String? {
|
||||
return this.lines().lastOrNull { it.isNotBlank() }
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.lagradost.cloudstream3.CommonActivity.onColorSelectedEvent
|
|||
import com.lagradost.cloudstream3.CommonActivity.onDialogDismissedEvent
|
||||
import com.lagradost.cloudstream3.CommonActivity.showToast
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.databinding.SubtitleSettingsBinding
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings
|
||||
import com.lagradost.cloudstream3.utils.DataStore.setKey
|
||||
import com.lagradost.cloudstream3.utils.Event
|
||||
|
@ -37,8 +38,6 @@ import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
|
|||
import com.lagradost.cloudstream3.utils.UIHelper.hideSystemUI
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage
|
||||
import kotlinx.android.synthetic.main.subtitle_settings.*
|
||||
import kotlinx.android.synthetic.main.toast.view.*
|
||||
import java.io.File
|
||||
|
||||
const val SUBTITLE_KEY = "subtitle_settings"
|
||||
|
@ -184,10 +183,10 @@ class SubtitlesFragment : Fragment() {
|
|||
}
|
||||
|
||||
private fun Context.updateState() {
|
||||
subtitle_text?.setStyle(fromSaveToStyle(state))
|
||||
val text = subtitle_text.context.getString(R.string.subtitles_example_text)
|
||||
binding?.subtitleText?.setStyle(fromSaveToStyle(state))
|
||||
val text = getString(R.string.subtitles_example_text)
|
||||
val fixedText = if (state.upperCase) text.uppercase() else text
|
||||
subtitle_text?.setCues(
|
||||
binding?.subtitleText?.setCues(
|
||||
listOf(
|
||||
Cue.Builder()
|
||||
.setTextSize(
|
||||
|
@ -213,12 +212,21 @@ class SubtitlesFragment : Fragment() {
|
|||
return if (color == Color.TRANSPARENT) Color.BLACK else color
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
binding = null
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
var binding: SubtitleSettingsBinding? = null
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?,
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.subtitle_settings, container, false)
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
val localBinding = SubtitleSettingsBinding.inflate(inflater, container, false)
|
||||
binding = localBinding
|
||||
return localBinding.root
|
||||
//return inflater.inflate(R.layout.subtitle_settings, container, false)
|
||||
}
|
||||
|
||||
private lateinit var state: SaveCaptionStyle
|
||||
|
@ -234,11 +242,11 @@ class SubtitlesFragment : Fragment() {
|
|||
hide = arguments?.getBoolean("hide") ?: true
|
||||
onColorSelectedEvent += ::onColorSelected
|
||||
onDialogDismissedEvent += ::onDialogDismissed
|
||||
subs_import_text?.text = getString(R.string.subs_import_text).format(
|
||||
binding?.subsImportText?.text = getString(R.string.subs_import_text).format(
|
||||
context?.getExternalFilesDir(null)?.absolutePath.toString() + "/Fonts"
|
||||
)
|
||||
|
||||
fixPaddingStatusbar(subs_root)
|
||||
fixPaddingStatusbar(binding?.subsRoot)
|
||||
|
||||
state = getCurrentSavedStyle()
|
||||
context?.updateState()
|
||||
|
@ -268,313 +276,314 @@ class SubtitlesFragment : Fragment() {
|
|||
return@setOnLongClickListener true
|
||||
}
|
||||
}
|
||||
binding?.apply {
|
||||
subsTextColor.setup(0)
|
||||
subsOutlineColor.setup(1)
|
||||
subsBackgroundColor.setup(2)
|
||||
subsWindowColor.setup(3)
|
||||
|
||||
subs_text_color.setup(0)
|
||||
subs_outline_color.setup(1)
|
||||
subs_background_color.setup(2)
|
||||
subs_window_color.setup(3)
|
||||
|
||||
val dismissCallback = {
|
||||
if (hide)
|
||||
activity?.hideSystemUI()
|
||||
}
|
||||
|
||||
subs_subtitle_elevation.setFocusableInTv()
|
||||
subs_subtitle_elevation.setOnClickListener { textView ->
|
||||
val suffix = "dp"
|
||||
val elevationTypes = listOf(
|
||||
Pair(0, textView.context.getString(R.string.none)),
|
||||
Pair(10, "10$suffix"),
|
||||
Pair(20, "20$suffix"),
|
||||
Pair(30, "30$suffix"),
|
||||
Pair(40, "40$suffix"),
|
||||
Pair(50, "50$suffix"),
|
||||
Pair(60, "60$suffix"),
|
||||
Pair(70, "70$suffix"),
|
||||
Pair(80, "80$suffix"),
|
||||
Pair(90, "90$suffix"),
|
||||
Pair(100, "100$suffix"),
|
||||
)
|
||||
|
||||
//showBottomDialog
|
||||
activity?.showDialog(
|
||||
elevationTypes.map { it.second },
|
||||
elevationTypes.map { it.first }.indexOf(state.elevation),
|
||||
(textView as TextView).text.toString(),
|
||||
false,
|
||||
dismissCallback
|
||||
) { index ->
|
||||
state.elevation = elevationTypes.map { it.first }[index]
|
||||
textView.context.updateState()
|
||||
val dismissCallback = {
|
||||
if (hide)
|
||||
activity?.hideSystemUI()
|
||||
}
|
||||
}
|
||||
|
||||
subs_subtitle_elevation.setOnLongClickListener {
|
||||
state.elevation = DEF_SUBS_ELEVATION
|
||||
it.context.updateState()
|
||||
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
subsSubtitleElevation.setFocusableInTv()
|
||||
subsSubtitleElevation.setOnClickListener { textView ->
|
||||
val suffix = "dp"
|
||||
val elevationTypes = listOf(
|
||||
Pair(0, textView.context.getString(R.string.none)),
|
||||
Pair(10, "10$suffix"),
|
||||
Pair(20, "20$suffix"),
|
||||
Pair(30, "30$suffix"),
|
||||
Pair(40, "40$suffix"),
|
||||
Pair(50, "50$suffix"),
|
||||
Pair(60, "60$suffix"),
|
||||
Pair(70, "70$suffix"),
|
||||
Pair(80, "80$suffix"),
|
||||
Pair(90, "90$suffix"),
|
||||
Pair(100, "100$suffix"),
|
||||
)
|
||||
|
||||
subs_edge_type.setFocusableInTv()
|
||||
subs_edge_type.setOnClickListener { textView ->
|
||||
val edgeTypes = listOf(
|
||||
Pair(
|
||||
CaptionStyleCompat.EDGE_TYPE_NONE,
|
||||
textView.context.getString(R.string.subtitles_none)
|
||||
),
|
||||
Pair(
|
||||
CaptionStyleCompat.EDGE_TYPE_OUTLINE,
|
||||
textView.context.getString(R.string.subtitles_outline)
|
||||
),
|
||||
Pair(
|
||||
CaptionStyleCompat.EDGE_TYPE_DEPRESSED,
|
||||
textView.context.getString(R.string.subtitles_depressed)
|
||||
),
|
||||
Pair(
|
||||
CaptionStyleCompat.EDGE_TYPE_DROP_SHADOW,
|
||||
textView.context.getString(R.string.subtitles_shadow)
|
||||
),
|
||||
Pair(
|
||||
CaptionStyleCompat.EDGE_TYPE_RAISED,
|
||||
textView.context.getString(R.string.subtitles_raised)
|
||||
),
|
||||
)
|
||||
|
||||
//showBottomDialog
|
||||
activity?.showDialog(
|
||||
edgeTypes.map { it.second },
|
||||
edgeTypes.map { it.first }.indexOf(state.edgeType),
|
||||
(textView as TextView).text.toString(),
|
||||
false,
|
||||
dismissCallback
|
||||
) { index ->
|
||||
state.edgeType = edgeTypes.map { it.first }[index]
|
||||
textView.context.updateState()
|
||||
}
|
||||
}
|
||||
|
||||
subs_edge_type.setOnLongClickListener {
|
||||
state.edgeType = CaptionStyleCompat.EDGE_TYPE_OUTLINE
|
||||
it.context.updateState()
|
||||
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
|
||||
subs_font_size.setFocusableInTv()
|
||||
subs_font_size.setOnClickListener { textView ->
|
||||
val suffix = "sp"
|
||||
val fontSizes = listOf(
|
||||
Pair(null, textView.context.getString(R.string.normal)),
|
||||
Pair(6f, "6$suffix"),
|
||||
Pair(7f, "7$suffix"),
|
||||
Pair(8f, "8$suffix"),
|
||||
Pair(9f, "9$suffix"),
|
||||
Pair(10f, "10$suffix"),
|
||||
Pair(11f, "11$suffix"),
|
||||
Pair(12f, "12$suffix"),
|
||||
Pair(13f, "13$suffix"),
|
||||
Pair(14f, "14$suffix"),
|
||||
Pair(15f, "15$suffix"),
|
||||
Pair(16f, "16$suffix"),
|
||||
Pair(17f, "17$suffix"),
|
||||
Pair(18f, "18$suffix"),
|
||||
Pair(19f, "19$suffix"),
|
||||
Pair(20f, "20$suffix"),
|
||||
Pair(21f, "21$suffix"),
|
||||
Pair(22f, "22$suffix"),
|
||||
Pair(23f, "23$suffix"),
|
||||
Pair(24f, "24$suffix"),
|
||||
Pair(25f, "25$suffix"),
|
||||
Pair(26f, "26$suffix"),
|
||||
Pair(28f, "28$suffix"),
|
||||
Pair(30f, "30$suffix"),
|
||||
Pair(32f, "32$suffix"),
|
||||
Pair(34f, "34$suffix"),
|
||||
Pair(36f, "36$suffix"),
|
||||
Pair(38f, "38$suffix"),
|
||||
Pair(40f, "40$suffix"),
|
||||
Pair(42f, "42$suffix"),
|
||||
Pair(44f, "44$suffix"),
|
||||
Pair(48f, "48$suffix"),
|
||||
Pair(60f, "60$suffix"),
|
||||
)
|
||||
|
||||
//showBottomDialog
|
||||
activity?.showDialog(
|
||||
fontSizes.map { it.second },
|
||||
fontSizes.map { it.first }.indexOf(state.fixedTextSize),
|
||||
(textView as TextView).text.toString(),
|
||||
false,
|
||||
dismissCallback
|
||||
) { index ->
|
||||
state.fixedTextSize = fontSizes.map { it.first }[index]
|
||||
//textView.context.updateState() // font size not changed
|
||||
}
|
||||
}
|
||||
|
||||
subtitles_remove_bloat?.isChecked = state.removeBloat
|
||||
subtitles_remove_bloat?.setOnCheckedChangeListener { _, b ->
|
||||
state.removeBloat = b
|
||||
}
|
||||
subtitles_uppercase?.isChecked = state.upperCase
|
||||
subtitles_uppercase?.setOnCheckedChangeListener { _, b ->
|
||||
state.upperCase = b
|
||||
context?.updateState()
|
||||
}
|
||||
|
||||
subtitles_remove_captions?.isChecked = state.removeCaptions
|
||||
subtitles_remove_captions?.setOnCheckedChangeListener { _, b ->
|
||||
state.removeCaptions = b
|
||||
}
|
||||
|
||||
subs_font_size.setOnLongClickListener { _ ->
|
||||
state.fixedTextSize = null
|
||||
//textView.context.updateState() // font size not changed
|
||||
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
|
||||
//Fetch current value from preference
|
||||
context?.let { ctx ->
|
||||
subtitles_filter_sub_lang?.isChecked =
|
||||
PreferenceManager.getDefaultSharedPreferences(ctx)
|
||||
.getBoolean(getString(R.string.filter_sub_lang_key), false)
|
||||
}
|
||||
|
||||
subtitles_filter_sub_lang?.setOnCheckedChangeListener { _, b ->
|
||||
context?.let { ctx ->
|
||||
PreferenceManager.getDefaultSharedPreferences(ctx)
|
||||
.edit()
|
||||
.putBoolean(getString(R.string.filter_sub_lang_key), b)
|
||||
.apply()
|
||||
}
|
||||
}
|
||||
|
||||
subs_font.setFocusableInTv()
|
||||
subs_font.setOnClickListener { textView ->
|
||||
val fontTypes = listOf(
|
||||
Pair(null, textView.context.getString(R.string.normal)),
|
||||
Pair(R.font.trebuchet_ms, "Trebuchet MS"),
|
||||
Pair(R.font.netflix_sans, "Netflix Sans"),
|
||||
Pair(R.font.google_sans, "Google Sans"),
|
||||
Pair(R.font.open_sans, "Open Sans"),
|
||||
Pair(R.font.futura, "Futura"),
|
||||
Pair(R.font.consola, "Consola"),
|
||||
Pair(R.font.gotham, "Gotham"),
|
||||
Pair(R.font.lucida_grande, "Lucida Grande"),
|
||||
Pair(R.font.stix_general, "STIX General"),
|
||||
Pair(R.font.times_new_roman, "Times New Roman"),
|
||||
Pair(R.font.verdana, "Verdana"),
|
||||
Pair(R.font.ubuntu_regular, "Ubuntu"),
|
||||
Pair(R.font.comic_sans, "Comic Sans"),
|
||||
Pair(R.font.poppins_regular, "Poppins"),
|
||||
)
|
||||
val savedFontTypes = textView.context.getSavedFonts()
|
||||
|
||||
val currentIndex =
|
||||
savedFontTypes.indexOfFirst { it.absolutePath == state.typefaceFilePath }
|
||||
.let { index ->
|
||||
if (index == -1)
|
||||
fontTypes.indexOfFirst { it.first == state.typeface }
|
||||
else index + fontTypes.size
|
||||
}
|
||||
|
||||
//showBottomDialog
|
||||
activity?.showDialog(
|
||||
fontTypes.map { it.second } + savedFontTypes.map { it.name },
|
||||
currentIndex,
|
||||
(textView as TextView).text.toString(),
|
||||
false,
|
||||
dismissCallback
|
||||
) { index ->
|
||||
if (index < fontTypes.size) {
|
||||
state.typeface = fontTypes[index].first
|
||||
state.typefaceFilePath = null
|
||||
} else {
|
||||
state.typefaceFilePath = savedFontTypes[index - fontTypes.size].absolutePath
|
||||
state.typeface = null
|
||||
//showBottomDialog
|
||||
activity?.showDialog(
|
||||
elevationTypes.map { it.second },
|
||||
elevationTypes.map { it.first }.indexOf(state.elevation),
|
||||
(textView as TextView).text.toString(),
|
||||
false,
|
||||
dismissCallback
|
||||
) { index ->
|
||||
state.elevation = elevationTypes.map { it.first }[index]
|
||||
textView.context.updateState()
|
||||
if (hide)
|
||||
activity?.hideSystemUI()
|
||||
}
|
||||
}
|
||||
|
||||
subsSubtitleElevation.setOnLongClickListener {
|
||||
state.elevation = DEF_SUBS_ELEVATION
|
||||
it.context.updateState()
|
||||
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
|
||||
subsEdgeType.setFocusableInTv()
|
||||
subsEdgeType.setOnClickListener { textView ->
|
||||
val edgeTypes = listOf(
|
||||
Pair(
|
||||
CaptionStyleCompat.EDGE_TYPE_NONE,
|
||||
textView.context.getString(R.string.subtitles_none)
|
||||
),
|
||||
Pair(
|
||||
CaptionStyleCompat.EDGE_TYPE_OUTLINE,
|
||||
textView.context.getString(R.string.subtitles_outline)
|
||||
),
|
||||
Pair(
|
||||
CaptionStyleCompat.EDGE_TYPE_DEPRESSED,
|
||||
textView.context.getString(R.string.subtitles_depressed)
|
||||
),
|
||||
Pair(
|
||||
CaptionStyleCompat.EDGE_TYPE_DROP_SHADOW,
|
||||
textView.context.getString(R.string.subtitles_shadow)
|
||||
),
|
||||
Pair(
|
||||
CaptionStyleCompat.EDGE_TYPE_RAISED,
|
||||
textView.context.getString(R.string.subtitles_raised)
|
||||
),
|
||||
)
|
||||
|
||||
//showBottomDialog
|
||||
activity?.showDialog(
|
||||
edgeTypes.map { it.second },
|
||||
edgeTypes.map { it.first }.indexOf(state.edgeType),
|
||||
(textView as TextView).text.toString(),
|
||||
false,
|
||||
dismissCallback
|
||||
) { index ->
|
||||
state.edgeType = edgeTypes.map { it.first }[index]
|
||||
textView.context.updateState()
|
||||
}
|
||||
}
|
||||
|
||||
subsEdgeType.setOnLongClickListener {
|
||||
state.edgeType = CaptionStyleCompat.EDGE_TYPE_OUTLINE
|
||||
it.context.updateState()
|
||||
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
|
||||
subsFontSize.setFocusableInTv()
|
||||
subsFontSize.setOnClickListener { textView ->
|
||||
val suffix = "sp"
|
||||
val fontSizes = listOf(
|
||||
Pair(null, textView.context.getString(R.string.normal)),
|
||||
Pair(6f, "6$suffix"),
|
||||
Pair(7f, "7$suffix"),
|
||||
Pair(8f, "8$suffix"),
|
||||
Pair(9f, "9$suffix"),
|
||||
Pair(10f, "10$suffix"),
|
||||
Pair(11f, "11$suffix"),
|
||||
Pair(12f, "12$suffix"),
|
||||
Pair(13f, "13$suffix"),
|
||||
Pair(14f, "14$suffix"),
|
||||
Pair(15f, "15$suffix"),
|
||||
Pair(16f, "16$suffix"),
|
||||
Pair(17f, "17$suffix"),
|
||||
Pair(18f, "18$suffix"),
|
||||
Pair(19f, "19$suffix"),
|
||||
Pair(20f, "20$suffix"),
|
||||
Pair(21f, "21$suffix"),
|
||||
Pair(22f, "22$suffix"),
|
||||
Pair(23f, "23$suffix"),
|
||||
Pair(24f, "24$suffix"),
|
||||
Pair(25f, "25$suffix"),
|
||||
Pair(26f, "26$suffix"),
|
||||
Pair(28f, "28$suffix"),
|
||||
Pair(30f, "30$suffix"),
|
||||
Pair(32f, "32$suffix"),
|
||||
Pair(34f, "34$suffix"),
|
||||
Pair(36f, "36$suffix"),
|
||||
Pair(38f, "38$suffix"),
|
||||
Pair(40f, "40$suffix"),
|
||||
Pair(42f, "42$suffix"),
|
||||
Pair(44f, "44$suffix"),
|
||||
Pair(48f, "48$suffix"),
|
||||
Pair(60f, "60$suffix"),
|
||||
)
|
||||
|
||||
//showBottomDialog
|
||||
activity?.showDialog(
|
||||
fontSizes.map { it.second },
|
||||
fontSizes.map { it.first }.indexOf(state.fixedTextSize),
|
||||
(textView as TextView).text.toString(),
|
||||
false,
|
||||
dismissCallback
|
||||
) { index ->
|
||||
state.fixedTextSize = fontSizes.map { it.first }[index]
|
||||
//textView.context.updateState() // font size not changed
|
||||
}
|
||||
}
|
||||
|
||||
subtitlesRemoveBloat.isChecked = state.removeBloat
|
||||
subtitlesRemoveBloat.setOnCheckedChangeListener { _, b ->
|
||||
state.removeBloat = b
|
||||
}
|
||||
subtitlesUppercase.isChecked = state.upperCase
|
||||
subtitlesUppercase.setOnCheckedChangeListener { _, b ->
|
||||
state.upperCase = b
|
||||
context?.updateState()
|
||||
}
|
||||
|
||||
subtitlesRemoveCaptions.isChecked = state.removeCaptions
|
||||
subtitlesRemoveCaptions.setOnCheckedChangeListener { _, b ->
|
||||
state.removeCaptions = b
|
||||
}
|
||||
|
||||
subsFontSize.setOnLongClickListener { _ ->
|
||||
state.fixedTextSize = null
|
||||
//textView.context.updateState() // font size not changed
|
||||
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
|
||||
//Fetch current value from preference
|
||||
context?.let { ctx ->
|
||||
subtitlesFilterSubLang.isChecked =
|
||||
PreferenceManager.getDefaultSharedPreferences(ctx)
|
||||
.getBoolean(getString(R.string.filter_sub_lang_key), false)
|
||||
}
|
||||
|
||||
subtitlesFilterSubLang.setOnCheckedChangeListener { _, b ->
|
||||
context?.let { ctx ->
|
||||
PreferenceManager.getDefaultSharedPreferences(ctx)
|
||||
.edit()
|
||||
.putBoolean(getString(R.string.filter_sub_lang_key), b)
|
||||
.apply()
|
||||
}
|
||||
}
|
||||
|
||||
subsFont.setFocusableInTv()
|
||||
subsFont.setOnClickListener { textView ->
|
||||
val fontTypes = listOf(
|
||||
Pair(null, textView.context.getString(R.string.normal)),
|
||||
Pair(R.font.trebuchet_ms, "Trebuchet MS"),
|
||||
Pair(R.font.netflix_sans, "Netflix Sans"),
|
||||
Pair(R.font.google_sans, "Google Sans"),
|
||||
Pair(R.font.open_sans, "Open Sans"),
|
||||
Pair(R.font.futura, "Futura"),
|
||||
Pair(R.font.consola, "Consola"),
|
||||
Pair(R.font.gotham, "Gotham"),
|
||||
Pair(R.font.lucida_grande, "Lucida Grande"),
|
||||
Pair(R.font.stix_general, "STIX General"),
|
||||
Pair(R.font.times_new_roman, "Times New Roman"),
|
||||
Pair(R.font.verdana, "Verdana"),
|
||||
Pair(R.font.ubuntu_regular, "Ubuntu"),
|
||||
Pair(R.font.comic_sans, "Comic Sans"),
|
||||
Pair(R.font.poppins_regular, "Poppins"),
|
||||
)
|
||||
val savedFontTypes = textView.context.getSavedFonts()
|
||||
|
||||
val currentIndex =
|
||||
savedFontTypes.indexOfFirst { it.absolutePath == state.typefaceFilePath }
|
||||
.let { index ->
|
||||
if (index == -1)
|
||||
fontTypes.indexOfFirst { it.first == state.typeface }
|
||||
else index + fontTypes.size
|
||||
}
|
||||
|
||||
//showBottomDialog
|
||||
activity?.showDialog(
|
||||
fontTypes.map { it.second } + savedFontTypes.map { it.name },
|
||||
currentIndex,
|
||||
(textView as TextView).text.toString(),
|
||||
false,
|
||||
dismissCallback
|
||||
) { index ->
|
||||
if (index < fontTypes.size) {
|
||||
state.typeface = fontTypes[index].first
|
||||
state.typefaceFilePath = null
|
||||
} else {
|
||||
state.typefaceFilePath = savedFontTypes[index - fontTypes.size].absolutePath
|
||||
state.typeface = null
|
||||
}
|
||||
textView.context.updateState()
|
||||
}
|
||||
}
|
||||
|
||||
subsFont.setOnLongClickListener { textView ->
|
||||
state.typeface = null
|
||||
state.typefaceFilePath = null
|
||||
textView.context.updateState()
|
||||
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
}
|
||||
|
||||
subs_font.setOnLongClickListener { textView ->
|
||||
state.typeface = null
|
||||
state.typefaceFilePath = null
|
||||
textView.context.updateState()
|
||||
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
subsAutoSelectLanguage.setFocusableInTv()
|
||||
subsAutoSelectLanguage.setOnClickListener { textView ->
|
||||
val langMap = arrayListOf(
|
||||
SubtitleHelper.Language639(
|
||||
textView.context.getString(R.string.none),
|
||||
textView.context.getString(R.string.none),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
),
|
||||
)
|
||||
langMap.addAll(SubtitleHelper.languages)
|
||||
|
||||
subs_auto_select_language.setFocusableInTv()
|
||||
subs_auto_select_language.setOnClickListener { textView ->
|
||||
val langMap = arrayListOf(
|
||||
SubtitleHelper.Language639(
|
||||
textView.context.getString(R.string.none),
|
||||
textView.context.getString(R.string.none),
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
),
|
||||
)
|
||||
langMap.addAll(SubtitleHelper.languages)
|
||||
|
||||
val lang639_1 = langMap.map { it.ISO_639_1 }
|
||||
activity?.showDialog(
|
||||
langMap.map { it.languageName },
|
||||
lang639_1.indexOf(getAutoSelectLanguageISO639_1()),
|
||||
(textView as TextView).text.toString(),
|
||||
true,
|
||||
dismissCallback
|
||||
) { index ->
|
||||
setKey(SUBTITLE_AUTO_SELECT_KEY, lang639_1[index])
|
||||
val lang639_1 = langMap.map { it.ISO_639_1 }
|
||||
activity?.showDialog(
|
||||
langMap.map { it.languageName },
|
||||
lang639_1.indexOf(getAutoSelectLanguageISO639_1()),
|
||||
(textView as TextView).text.toString(),
|
||||
true,
|
||||
dismissCallback
|
||||
) { index ->
|
||||
setKey(SUBTITLE_AUTO_SELECT_KEY, lang639_1[index])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subs_auto_select_language.setOnLongClickListener {
|
||||
setKey(SUBTITLE_AUTO_SELECT_KEY, "en")
|
||||
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
|
||||
subs_download_languages.setFocusableInTv()
|
||||
subs_download_languages.setOnClickListener { textView ->
|
||||
val langMap = SubtitleHelper.languages
|
||||
val lang639_1 = langMap.map { it.ISO_639_1 }
|
||||
val keys = getDownloadSubsLanguageISO639_1()
|
||||
val keyMap = keys.map { lang639_1.indexOf(it) }.filter { it >= 0 }
|
||||
|
||||
activity?.showMultiDialog(
|
||||
langMap.map { it.languageName },
|
||||
keyMap,
|
||||
(textView as TextView).text.toString(),
|
||||
dismissCallback
|
||||
) { indexList ->
|
||||
setKey(SUBTITLE_DOWNLOAD_KEY, indexList.map { lang639_1[it] }.toList())
|
||||
subsAutoSelectLanguage.setOnLongClickListener {
|
||||
setKey(SUBTITLE_AUTO_SELECT_KEY, "en")
|
||||
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
}
|
||||
|
||||
subs_download_languages.setOnLongClickListener {
|
||||
setKey(SUBTITLE_DOWNLOAD_KEY, listOf("en"))
|
||||
subsDownloadLanguages.setFocusableInTv()
|
||||
subsDownloadLanguages.setOnClickListener { textView ->
|
||||
val langMap = SubtitleHelper.languages
|
||||
val lang639_1 = langMap.map { it.ISO_639_1 }
|
||||
val keys = getDownloadSubsLanguageISO639_1()
|
||||
val keyMap = keys.map { lang639_1.indexOf(it) }.filter { it >= 0 }
|
||||
|
||||
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
activity?.showMultiDialog(
|
||||
langMap.map { it.languageName },
|
||||
keyMap,
|
||||
(textView as TextView).text.toString(),
|
||||
dismissCallback
|
||||
) { indexList ->
|
||||
setKey(SUBTITLE_DOWNLOAD_KEY, indexList.map { lang639_1[it] }.toList())
|
||||
}
|
||||
}
|
||||
|
||||
cancel_btt.setOnClickListener {
|
||||
activity?.popCurrentPage()
|
||||
}
|
||||
subsDownloadLanguages.setOnLongClickListener {
|
||||
setKey(SUBTITLE_DOWNLOAD_KEY, listOf("en"))
|
||||
|
||||
apply_btt.setOnClickListener {
|
||||
it.context.saveStyle(state)
|
||||
applyStyleEvent.invoke(state)
|
||||
it.context.fromSaveToStyle(state)
|
||||
activity?.popCurrentPage()
|
||||
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
|
||||
cancelBtt.setOnClickListener {
|
||||
activity?.popCurrentPage()
|
||||
}
|
||||
|
||||
applyBtt.setOnClickListener {
|
||||
it.context.saveStyle(state)
|
||||
applyStyleEvent.invoke(state)
|
||||
it.context.fromSaveToStyle(state)
|
||||
activity?.popCurrentPage()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue