more views

This commit is contained in:
LagradOst 2023-07-14 22:05:13 +02:00
parent 647e91bc4b
commit 273a947f8e
7 changed files with 491 additions and 454 deletions

View file

@ -11,9 +11,9 @@ import androidx.recyclerview.widget.RecyclerView
import com.lagradost.cloudstream3.LoadResponse import com.lagradost.cloudstream3.LoadResponse
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.utils.UIHelper.setImage import com.lagradost.cloudstream3.utils.UIHelper.setImage
import kotlinx.android.synthetic.main.fragment_home_head_tv.* import kotlinx.android.synthetic.main.home_scroll_view.view.home_scroll_preview
import kotlinx.android.synthetic.main.fragment_home_head_tv.view.* import kotlinx.android.synthetic.main.home_scroll_view.view.home_scroll_preview_tags
import kotlinx.android.synthetic.main.home_scroll_view.view.* import kotlinx.android.synthetic.main.home_scroll_view.view.home_scroll_preview_title
class HomeScrollAdapter( class HomeScrollAdapter(

View file

@ -1,14 +1,10 @@
package com.lagradost.cloudstream3.ui.player.source_priority package com.lagradost.cloudstream3.ui.player.source_priority
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.databinding.PlayerPrioritizeItemBinding
import com.lagradost.cloudstream3.utils.AppUtils import com.lagradost.cloudstream3.utils.AppUtils
import kotlinx.android.synthetic.main.player_prioritize_item.view.*
data class SourcePriority<T>( data class SourcePriority<T>(
val data: T, val data: T,
@ -20,7 +16,8 @@ class PriorityAdapter<T>(override val items: MutableList<SourcePriority<T>>) :
AppUtils.DiffAdapter<SourcePriority<T>>(items) { AppUtils.DiffAdapter<SourcePriority<T>>(items) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return PriorityViewHolder( 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( class PriorityViewHolder(
itemView: View, val binding: PlayerPrioritizeItemBinding,
) : RecyclerView.ViewHolder(itemView) { ) : RecyclerView.ViewHolder(binding.root) {
fun <T> bind(item: SourcePriority<T>) { 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 subtractButton: ImageView = itemView.subtract_button
val priorityText: TextView = itemView.priority_text val priorityText: TextView = itemView.priority_text
val priorityNumber: TextView = itemView.priority_number val priorityNumber: TextView = itemView.priority_number*/
priorityText.text = item.name binding.priorityText.text = item.name
fun updatePriority() { fun updatePriority() {
priorityNumber.text = item.priority.toString() binding.priorityNumber.text = item.priority.toString()
} }
updatePriority() updatePriority()
plusButton.setOnClickListener { binding.addButton.setOnClickListener {
// If someone clicks til the integer limit then they deserve to crash. // If someone clicks til the integer limit then they deserve to crash.
item.priority++ item.priority++
updatePriority() updatePriority()
} }
subtractButton.setOnClickListener { binding.subtractButton.setOnClickListener {
item.priority-- item.priority--
updatePriority() updatePriority()
} }

View file

@ -8,19 +8,13 @@ import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.content.res.ResourcesCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.databinding.PlayerQualityProfileItemBinding
import com.lagradost.cloudstream3.ui.result.UiImage import com.lagradost.cloudstream3.ui.result.UiImage
import com.lagradost.cloudstream3.utils.AppUtils import com.lagradost.cloudstream3.utils.AppUtils
import com.lagradost.cloudstream3.utils.UIHelper.setImage 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( class ProfilesAdapter(
override val items: MutableList<QualityDataHelper.QualityProfile>, override val items: MutableList<QualityDataHelper.QualityProfile>,
@ -34,8 +28,9 @@ class ProfilesAdapter(
}) { }) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return ProfilesViewHolder( return ProfilesViewHolder(
LayoutInflater.from(parent.context) PlayerQualityProfileItemBinding.inflate(LayoutInflater.from(parent.context),parent,false)
.inflate(R.layout.player_quality_profile_item, parent, false) //LayoutInflater.from(parent.context)
// .inflate(R.layout.player_quality_profile_item, parent, false)
) )
} }
@ -52,8 +47,8 @@ class ProfilesAdapter(
} }
inner class ProfilesViewHolder( inner class ProfilesViewHolder(
itemView: View, val binding: PlayerQualityProfileItemBinding,
) : RecyclerView.ViewHolder(itemView) { ) : RecyclerView.ViewHolder(binding.root) {
private val art = listOf( private val art = listOf(
R.drawable.profile_bg_teal, R.drawable.profile_bg_teal,
R.drawable.profile_bg_blue, R.drawable.profile_bg_blue,
@ -65,12 +60,12 @@ class ProfilesAdapter(
) )
fun bind(item: QualityDataHelper.QualityProfile, index: Int) { fun bind(item: QualityDataHelper.QualityProfile, index: Int) {
val priorityText: TextView = itemView.profile_text val priorityText: TextView = binding.profileText
val profileBg: ImageView = itemView.profile_image_background val profileBg: ImageView = binding.profileImageBackground
val wifiText: TextView = itemView.text_is_wifi val wifiText: TextView = binding.textIsWifi
val dataText: TextView = itemView.text_is_mobile_data val dataText: TextView = binding.textIsMobileData
val outline: View = itemView.outline val outline: View = binding.outline
val cardView: View = itemView.card_view val cardView: View = binding.cardView
priorityText.text = item.name.asString(itemView.context) priorityText.text = item.name.asString(itemView.context)
dataText.isVisible = item.type == QualityDataHelper.QualityProfileType.Data dataText.isVisible = item.type == QualityDataHelper.QualityProfileType.Data

View file

@ -1,20 +1,16 @@
package com.lagradost.cloudstream3.ui.player.source_priority package com.lagradost.cloudstream3.ui.player.source_priority
import android.app.Dialog import android.app.Dialog
import android.view.View
import android.widget.TextView
import androidx.annotation.StyleRes import androidx.annotation.StyleRes
import androidx.core.view.isVisible
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import androidx.recyclerview.widget.RecyclerView
import com.lagradost.cloudstream3.R 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.getProfileName
import com.lagradost.cloudstream3.ui.player.source_priority.QualityDataHelper.getProfiles import com.lagradost.cloudstream3.ui.player.source_priority.QualityDataHelper.getProfiles
import com.lagradost.cloudstream3.ui.result.txt import com.lagradost.cloudstream3.ui.result.txt
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
import kotlinx.android.synthetic.main.player_quality_profile_dialog.*
class QualityProfileDialog( class QualityProfileDialog(
val activity: FragmentActivity, val activity: FragmentActivity,
@ -24,83 +20,86 @@ class QualityProfileDialog(
private val profileSelectionCallback: (QualityDataHelper.QualityProfile) -> Unit private val profileSelectionCallback: (QualityDataHelper.QualityProfile) -> Unit
) : Dialog(activity, themeRes) { ) : Dialog(activity, themeRes) {
override fun show() { 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 useBtt: View = use_btt
val editBtt: View = edit_btt val editBtt: View = edit_btt
val cancelBtt: View = cancel_btt val cancelBtt: View = cancel_btt
val defaultBtt: View = set_default_btt val defaultBtt: View = set_default_btt
val currentProfileText: TextView = currently_selected_profile_text val currentProfileText: TextView = currently_selected_profile_text
val selectedItemActionsHolder: View = selected_item_holder val selectedItemActionsHolder: View = selected_item_holder*/
binding.apply {
fun getCurrentProfile(): QualityDataHelper.QualityProfile? { fun getCurrentProfile(): QualityDataHelper.QualityProfile? {
return (profilesRecyclerView.adapter as? ProfilesAdapter)?.getCurrentProfile() 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)
} }
}
refreshProfiles() fun refreshProfiles() {
currentlySelectedProfileText.text = getProfileName(usedProfile).asString(context)
editBtt.setOnClickListener { (profilesRecyclerview.adapter as? ProfilesAdapter)?.updateList(getProfiles())
getCurrentProfile()?.let { profile -> }
SourcePriorityDialog(context, themeRes, links, profile) {
refreshProfiles() profilesRecyclerview.adapter = ProfilesAdapter(
}.show() 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 { setDefaultBtt.setOnClickListener {
val currentProfile = getCurrentProfile() ?: return@setOnClickListener val currentProfile = getCurrentProfile() ?: return@setOnClickListener
val choices = QualityDataHelper.QualityProfileType.values() val choices = QualityDataHelper.QualityProfileType.values()
.filter { it != QualityDataHelper.QualityProfileType.None } .filter { it != QualityDataHelper.QualityProfileType.None }
val choiceNames = choices.map { txt(it.stringRes).asString(context) } val choiceNames = choices.map { txt(it.stringRes).asString(context) }
activity.showBottomDialog( activity.showBottomDialog(
choiceNames, choiceNames,
choices.indexOf(currentProfile.type), choices.indexOf(currentProfile.type),
txt(R.string.set_default).asString(context), txt(R.string.set_default).asString(context),
false, false,
{}, {},
{ index -> { index ->
val pickedChoice = choices.getOrNull(index) ?: return@showBottomDialog val pickedChoice = choices.getOrNull(index) ?: return@showBottomDialog
// Remove previous picks // Remove previous picks
if (pickedChoice.unique) { if (pickedChoice.unique) {
getProfiles().filter { it.type == pickedChoice }.forEach { getProfiles().filter { it.type == pickedChoice }.forEach {
QualityDataHelper.setQualityProfileType(it.id, null) QualityDataHelper.setQualityProfileType(it.id, null)
}
} }
}
QualityDataHelper.setQualityProfileType(currentProfile.id, pickedChoice) QualityDataHelper.setQualityProfileType(currentProfile.id, pickedChoice)
refreshProfiles() refreshProfiles()
}) })
} }
cancelBtt.setOnClickListener { cancelBtt.setOnClickListener {
this.dismissSafe() this@QualityProfileDialog.dismissSafe()
} }
useBtt.setOnClickListener { useBtt.setOnClickListener {
getCurrentProfile()?.let { getCurrentProfile()?.let {
profileSelectionCallback.invoke(it) profileSelectionCallback.invoke(it)
this.dismissSafe() this@QualityProfileDialog.dismissSafe()
}
} }
} }
super.show() super.show()
} }
} }

View file

@ -2,30 +2,29 @@ package com.lagradost.cloudstream3.ui.settings.extensions
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.os.Bundle 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.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup 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 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
import com.lagradost.cloudstream3.plugins.VotingApi.canVote
import com.lagradost.cloudstream3.plugins.VotingApi.getVoteType import com.lagradost.cloudstream3.plugins.VotingApi.getVoteType
import com.lagradost.cloudstream3.plugins.VotingApi.getVotes import com.lagradost.cloudstream3.plugins.VotingApi.getVotes
import com.lagradost.cloudstream3.plugins.VotingApi.vote import com.lagradost.cloudstream3.plugins.VotingApi.vote
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
import com.lagradost.cloudstream3.utils.Coroutines.main 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.fromTwoLettersToLanguage
import com.lagradost.cloudstream3.utils.SubtitleHelper.getFlagFromIso 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() { 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( override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View? { ): View {
return inflater.inflate(R.layout.fragment_plugin_details, container, false) 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?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
val metadata = data.plugin.second val metadata = data.plugin.second
if (plugin_icon?.setImage(//plugin_icon?.height ?: binding?.apply {
if (!pluginIcon.setImage(//plugin_icon?.height ?:
metadata.iconUrl?.replace( metadata.iconUrl?.replace(
"%size%", "%size%",
"$iconSize" "$iconSize"
@ -64,23 +72,33 @@ class PluginDetailsFragment(val data: PluginViewData) : BottomSheetDialogFragmen
), ),
null, null,
errorImageDrawable = R.drawable.ic_baseline_extension_24 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") pluginName.text = metadata.name.removeSuffix("Provider")
plugin_version?.text = metadata.version.toString() pluginVersion.text = metadata.version.toString()
plugin_description?.text = metadata.description ?: getString(R.string.no_data) pluginDescription.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) pluginSize.text =
plugin_author?.text = if (metadata.authors.isEmpty()) getString(R.string.no_data) else metadata.authors.joinToString(", ") if (metadata.fileSize == null) getString(R.string.no_data) else formatFileSize(
plugin_status?.text = resources.getStringArray(R.array.extension_statuses)[metadata.status] context,
plugin_types?.text = if ((metadata.tvTypes == null) || metadata.tvTypes.isEmpty()) getString(R.string.no_data) else metadata.tvTypes.joinToString(", ") metadata.fileSize
plugin_lang?.text = if (metadata.language == null) )
getString(R.string.no_data) 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 else
"${getFlagFromIso(metadata.language)} ${fromTwoLettersToLanguage(metadata.language)}" "${getFlagFromIso(metadata.language)} ${fromTwoLettersToLanguage(metadata.language)}"
github_btn.setOnClickListener { githubBtn.setOnClickListener {
if (metadata.repositoryUrl != null) { if (metadata.repositoryUrl != null) {
openBrowser(metadata.repositoryUrl) openBrowser(metadata.repositoryUrl)
} }
@ -93,10 +111,11 @@ class PluginDetailsFragment(val data: PluginViewData) : BottomSheetDialogFragmen
if (data.isDownloaded) { if (data.isDownloaded) {
// On local plugins page the filepath is provided instead of url. // 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) { if (plugin?.openSettings != null && context != null) {
action_settings?.isVisible = true actionSettings.isVisible = true
action_settings.setOnClickListener { actionSettings.setOnClickListener {
try { try {
plugin.openSettings!!.invoke(requireContext()) plugin.openSettings!!.invoke(requireContext())
} catch (e: Throwable) { } catch (e: Throwable) {
@ -109,10 +128,10 @@ class PluginDetailsFragment(val data: PluginViewData) : BottomSheetDialogFragmen
} }
} }
} else { } else {
action_settings?.isVisible = false actionSettings.isVisible = false
} }
} else { } else {
action_settings?.isVisible = false actionSettings.isVisible = false
} }
upvote.setOnClickListener { upvote.setOnClickListener {
@ -136,23 +155,40 @@ class PluginDetailsFragment(val data: PluginViewData) : BottomSheetDialogFragmen
updateVoting(it) updateVoting(it)
} }
} }
}
} }
private fun updateVoting(value: Int) { private fun updateVoting(value: Int) {
val metadata = data.plugin.second val metadata = data.plugin.second
plugin_votes.text = value.toString() binding?.apply {
when (metadata.getVoteType()) { pluginVotes.text = value.toString()
VotingApi.VoteType.UPVOTE -> { when (metadata.getVoteType()) {
upvote.imageTintList = ColorStateList.valueOf(context?.colorFromAttribute(R.attr.colorPrimary) ?: R.color.colorPrimary) VotingApi.VoteType.UPVOTE -> {
downvote.imageTintList = ColorStateList.valueOf(context?.colorFromAttribute(R.attr.white) ?: R.color.white) upvote.imageTintList = ColorStateList.valueOf(
} context?.colorFromAttribute(R.attr.colorPrimary) ?: R.color.colorPrimary
VotingApi.VoteType.DOWNVOTE -> { )
downvote.imageTintList = ColorStateList.valueOf(context?.colorFromAttribute(R.attr.colorPrimary) ?: R.color.colorPrimary) downvote.imageTintList = ColorStateList.valueOf(
upvote.imageTintList = ColorStateList.valueOf(context?.colorFromAttribute(R.attr.white) ?: R.color.white) 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) 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
)
}
} }
} }
} }

View file

@ -10,19 +10,20 @@ import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.lagradost.cloudstream3.MainAPI import com.lagradost.cloudstream3.MainAPI
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.databinding.ProviderTestItemBinding
import com.lagradost.cloudstream3.mvvm.getAllMessages import com.lagradost.cloudstream3.mvvm.getAllMessages
import com.lagradost.cloudstream3.mvvm.getStackTracePretty import com.lagradost.cloudstream3.mvvm.getStackTracePretty
import com.lagradost.cloudstream3.utils.AppUtils import com.lagradost.cloudstream3.utils.AppUtils
import com.lagradost.cloudstream3.utils.SubtitleHelper.getFlagFromIso import com.lagradost.cloudstream3.utils.SubtitleHelper.getFlagFromIso
import com.lagradost.cloudstream3.utils.TestingUtils 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>>) : class TestResultAdapter(override val items: MutableList<Pair<MainAPI, TestingUtils.TestResultProvider>>) :
AppUtils.DiffAdapter<Pair<MainAPI, TestingUtils.TestResultProvider>>(items) { AppUtils.DiffAdapter<Pair<MainAPI, TestingUtils.TestResultProvider>>(items) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return ProviderTestViewHolder( return ProviderTestViewHolder(
LayoutInflater.from(parent.context) ProviderTestItemBinding.inflate(LayoutInflater.from(parent.context), parent,false)
.inflate(R.layout.provider_test_item, 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) { inner class ProviderTestViewHolder(binding: ProviderTestItemBinding) : RecyclerView.ViewHolder(binding.root) {
private val languageText: TextView = itemView.lang_icon private val languageText: TextView = binding.langIcon
private val providerTitle: TextView = itemView.main_text private val providerTitle: TextView = binding.mainText
private val statusText: TextView = itemView.passed_failed_marker private val statusText: TextView = binding.passedFailedMarker
private val failDescription: TextView = itemView.fail_description private val failDescription: TextView = binding.failDescription
private val logButton: ImageView = itemView.action_button private val logButton: ImageView = binding.actionButton
private fun String.lastLine(): String? { private fun String.lastLine(): String? {
return this.lines().lastOrNull { it.isNotBlank() } return this.lines().lastOrNull { it.isNotBlank() }

View file

@ -27,6 +27,7 @@ import com.lagradost.cloudstream3.CommonActivity.onColorSelectedEvent
import com.lagradost.cloudstream3.CommonActivity.onDialogDismissedEvent import com.lagradost.cloudstream3.CommonActivity.onDialogDismissedEvent
import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.CommonActivity.showToast
import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.databinding.SubtitleSettingsBinding
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings
import com.lagradost.cloudstream3.utils.DataStore.setKey import com.lagradost.cloudstream3.utils.DataStore.setKey
import com.lagradost.cloudstream3.utils.Event 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.hideSystemUI
import com.lagradost.cloudstream3.utils.UIHelper.navigate import com.lagradost.cloudstream3.utils.UIHelper.navigate
import com.lagradost.cloudstream3.utils.UIHelper.popCurrentPage 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 import java.io.File
const val SUBTITLE_KEY = "subtitle_settings" const val SUBTITLE_KEY = "subtitle_settings"
@ -184,10 +183,10 @@ class SubtitlesFragment : Fragment() {
} }
private fun Context.updateState() { private fun Context.updateState() {
subtitle_text?.setStyle(fromSaveToStyle(state)) binding?.subtitleText?.setStyle(fromSaveToStyle(state))
val text = subtitle_text.context.getString(R.string.subtitles_example_text) val text = getString(R.string.subtitles_example_text)
val fixedText = if (state.upperCase) text.uppercase() else text val fixedText = if (state.upperCase) text.uppercase() else text
subtitle_text?.setCues( binding?.subtitleText?.setCues(
listOf( listOf(
Cue.Builder() Cue.Builder()
.setTextSize( .setTextSize(
@ -213,12 +212,21 @@ class SubtitlesFragment : Fragment() {
return if (color == Color.TRANSPARENT) Color.BLACK else color return if (color == Color.TRANSPARENT) Color.BLACK else color
} }
override fun onDestroyView() {
binding = null
super.onDestroyView()
}
var binding: SubtitleSettingsBinding? = null
override fun onCreateView( override fun onCreateView(
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle?, savedInstanceState: Bundle?
): View? { ): View {
return inflater.inflate(R.layout.subtitle_settings, container, false) 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 private lateinit var state: SaveCaptionStyle
@ -234,11 +242,11 @@ class SubtitlesFragment : Fragment() {
hide = arguments?.getBoolean("hide") ?: true hide = arguments?.getBoolean("hide") ?: true
onColorSelectedEvent += ::onColorSelected onColorSelectedEvent += ::onColorSelected
onDialogDismissedEvent += ::onDialogDismissed 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" context?.getExternalFilesDir(null)?.absolutePath.toString() + "/Fonts"
) )
fixPaddingStatusbar(subs_root) fixPaddingStatusbar(binding?.subsRoot)
state = getCurrentSavedStyle() state = getCurrentSavedStyle()
context?.updateState() context?.updateState()
@ -268,313 +276,314 @@ class SubtitlesFragment : Fragment() {
return@setOnLongClickListener true return@setOnLongClickListener true
} }
} }
binding?.apply {
subsTextColor.setup(0)
subsOutlineColor.setup(1)
subsBackgroundColor.setup(2)
subsWindowColor.setup(3)
subs_text_color.setup(0) val dismissCallback = {
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()
if (hide) if (hide)
activity?.hideSystemUI() activity?.hideSystemUI()
} }
}
subs_subtitle_elevation.setOnLongClickListener { subsSubtitleElevation.setFocusableInTv()
state.elevation = DEF_SUBS_ELEVATION subsSubtitleElevation.setOnClickListener { textView ->
it.context.updateState() val suffix = "dp"
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT) val elevationTypes = listOf(
return@setOnLongClickListener true 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() //showBottomDialog
subs_edge_type.setOnClickListener { textView -> activity?.showDialog(
val edgeTypes = listOf( elevationTypes.map { it.second },
Pair( elevationTypes.map { it.first }.indexOf(state.elevation),
CaptionStyleCompat.EDGE_TYPE_NONE, (textView as TextView).text.toString(),
textView.context.getString(R.string.subtitles_none) false,
), dismissCallback
Pair( ) { index ->
CaptionStyleCompat.EDGE_TYPE_OUTLINE, state.elevation = elevationTypes.map { it.first }[index]
textView.context.getString(R.string.subtitles_outline) textView.context.updateState()
), if (hide)
Pair( activity?.hideSystemUI()
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
} }
}
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() textView.context.updateState()
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true
} }
}
subs_font.setOnLongClickListener { textView -> subsAutoSelectLanguage.setFocusableInTv()
state.typeface = null subsAutoSelectLanguage.setOnClickListener { textView ->
state.typefaceFilePath = null val langMap = arrayListOf(
textView.context.updateState() SubtitleHelper.Language639(
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT) textView.context.getString(R.string.none),
return@setOnLongClickListener true textView.context.getString(R.string.none),
} "",
"",
"",
"",
""
),
)
langMap.addAll(SubtitleHelper.languages)
subs_auto_select_language.setFocusableInTv() val lang639_1 = langMap.map { it.ISO_639_1 }
subs_auto_select_language.setOnClickListener { textView -> activity?.showDialog(
val langMap = arrayListOf( langMap.map { it.languageName },
SubtitleHelper.Language639( lang639_1.indexOf(getAutoSelectLanguageISO639_1()),
textView.context.getString(R.string.none), (textView as TextView).text.toString(),
textView.context.getString(R.string.none), true,
"", dismissCallback
"", ) { index ->
"", setKey(SUBTITLE_AUTO_SELECT_KEY, lang639_1[index])
"", }
""
),
)
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])
} }
}
subs_auto_select_language.setOnLongClickListener { subsAutoSelectLanguage.setOnLongClickListener {
setKey(SUBTITLE_AUTO_SELECT_KEY, "en") setKey(SUBTITLE_AUTO_SELECT_KEY, "en")
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT) showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true 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())
} }
}
subs_download_languages.setOnLongClickListener { subsDownloadLanguages.setFocusableInTv()
setKey(SUBTITLE_DOWNLOAD_KEY, listOf("en")) 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) activity?.showMultiDialog(
return@setOnLongClickListener true 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 { subsDownloadLanguages.setOnLongClickListener {
activity?.popCurrentPage() setKey(SUBTITLE_DOWNLOAD_KEY, listOf("en"))
}
apply_btt.setOnClickListener { showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
it.context.saveStyle(state) return@setOnLongClickListener true
applyStyleEvent.invoke(state) }
it.context.fromSaveToStyle(state)
activity?.popCurrentPage() cancelBtt.setOnClickListener {
activity?.popCurrentPage()
}
applyBtt.setOnClickListener {
it.context.saveStyle(state)
applyStyleEvent.invoke(state)
it.context.fromSaveToStyle(state)
activity?.popCurrentPage()
}
} }
} }
} }