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,32 +20,35 @@ 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
|
||||
|
||||
val selectedItemActionsHolder: View = selected_item_holder*/
|
||||
binding.apply {
|
||||
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())
|
||||
currentlySelectedProfileText.text = getProfileName(usedProfile).asString(context)
|
||||
(profilesRecyclerview.adapter as? ProfilesAdapter)?.updateList(getProfiles())
|
||||
}
|
||||
|
||||
profilesRecyclerView.adapter = ProfilesAdapter(
|
||||
profilesRecyclerview.adapter = ProfilesAdapter(
|
||||
mutableListOf(),
|
||||
usedProfile,
|
||||
) { oldIndex: Int?, newIndex: Int ->
|
||||
profilesRecyclerView.adapter?.notifyItemChanged(newIndex)
|
||||
selectedItemActionsHolder.alpha = 1f
|
||||
profilesRecyclerview.adapter?.notifyItemChanged(newIndex)
|
||||
selectedItemHolder.alpha = 1f
|
||||
if (oldIndex != null) {
|
||||
profilesRecyclerView.adapter?.notifyItemChanged(oldIndex)
|
||||
profilesRecyclerview.adapter?.notifyItemChanged(oldIndex)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +63,7 @@ class QualityProfileDialog(
|
|||
}
|
||||
|
||||
|
||||
defaultBtt.setOnClickListener {
|
||||
setDefaultBtt.setOnClickListener {
|
||||
val currentProfile = getCurrentProfile() ?: return@setOnClickListener
|
||||
val choices = QualityDataHelper.QualityProfileType.values()
|
||||
.filter { it != QualityDataHelper.QualityProfileType.None }
|
||||
|
@ -91,16 +90,16 @@ class QualityProfileDialog(
|
|||
}
|
||||
|
||||
cancelBtt.setOnClickListener {
|
||||
this.dismissSafe()
|
||||
this@QualityProfileDialog.dismissSafe()
|
||||
}
|
||||
|
||||
useBtt.setOnClickListener {
|
||||
getCurrentProfile()?.let {
|
||||
profileSelectionCallback.invoke(it)
|
||||
this.dismissSafe()
|
||||
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)
|
||||
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)}"
|
||||
|
||||
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 {
|
||||
|
@ -137,22 +156,39 @@ class PluginDetailsFragment(val data: PluginViewData) : BottomSheetDialogFragmen
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateVoting(value: Int) {
|
||||
val metadata = data.plugin.second
|
||||
plugin_votes.text = value.toString()
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
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,19 +276,19 @@ class SubtitlesFragment : Fragment() {
|
|||
return@setOnLongClickListener true
|
||||
}
|
||||
}
|
||||
|
||||
subs_text_color.setup(0)
|
||||
subs_outline_color.setup(1)
|
||||
subs_background_color.setup(2)
|
||||
subs_window_color.setup(3)
|
||||
binding?.apply {
|
||||
subsTextColor.setup(0)
|
||||
subsOutlineColor.setup(1)
|
||||
subsBackgroundColor.setup(2)
|
||||
subsWindowColor.setup(3)
|
||||
|
||||
val dismissCallback = {
|
||||
if (hide)
|
||||
activity?.hideSystemUI()
|
||||
}
|
||||
|
||||
subs_subtitle_elevation.setFocusableInTv()
|
||||
subs_subtitle_elevation.setOnClickListener { textView ->
|
||||
subsSubtitleElevation.setFocusableInTv()
|
||||
subsSubtitleElevation.setOnClickListener { textView ->
|
||||
val suffix = "dp"
|
||||
val elevationTypes = listOf(
|
||||
Pair(0, textView.context.getString(R.string.none)),
|
||||
|
@ -311,15 +319,15 @@ class SubtitlesFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
subs_subtitle_elevation.setOnLongClickListener {
|
||||
subsSubtitleElevation.setOnLongClickListener {
|
||||
state.elevation = DEF_SUBS_ELEVATION
|
||||
it.context.updateState()
|
||||
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
|
||||
subs_edge_type.setFocusableInTv()
|
||||
subs_edge_type.setOnClickListener { textView ->
|
||||
subsEdgeType.setFocusableInTv()
|
||||
subsEdgeType.setOnClickListener { textView ->
|
||||
val edgeTypes = listOf(
|
||||
Pair(
|
||||
CaptionStyleCompat.EDGE_TYPE_NONE,
|
||||
|
@ -356,15 +364,15 @@ class SubtitlesFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
subs_edge_type.setOnLongClickListener {
|
||||
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
|
||||
}
|
||||
|
||||
subs_font_size.setFocusableInTv()
|
||||
subs_font_size.setOnClickListener { textView ->
|
||||
subsFontSize.setFocusableInTv()
|
||||
subsFontSize.setOnClickListener { textView ->
|
||||
val suffix = "sp"
|
||||
val fontSizes = listOf(
|
||||
Pair(null, textView.context.getString(R.string.normal)),
|
||||
|
@ -415,22 +423,22 @@ class SubtitlesFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
subtitles_remove_bloat?.isChecked = state.removeBloat
|
||||
subtitles_remove_bloat?.setOnCheckedChangeListener { _, b ->
|
||||
subtitlesRemoveBloat.isChecked = state.removeBloat
|
||||
subtitlesRemoveBloat.setOnCheckedChangeListener { _, b ->
|
||||
state.removeBloat = b
|
||||
}
|
||||
subtitles_uppercase?.isChecked = state.upperCase
|
||||
subtitles_uppercase?.setOnCheckedChangeListener { _, b ->
|
||||
subtitlesUppercase.isChecked = state.upperCase
|
||||
subtitlesUppercase.setOnCheckedChangeListener { _, b ->
|
||||
state.upperCase = b
|
||||
context?.updateState()
|
||||
}
|
||||
|
||||
subtitles_remove_captions?.isChecked = state.removeCaptions
|
||||
subtitles_remove_captions?.setOnCheckedChangeListener { _, b ->
|
||||
subtitlesRemoveCaptions.isChecked = state.removeCaptions
|
||||
subtitlesRemoveCaptions.setOnCheckedChangeListener { _, b ->
|
||||
state.removeCaptions = b
|
||||
}
|
||||
|
||||
subs_font_size.setOnLongClickListener { _ ->
|
||||
subsFontSize.setOnLongClickListener { _ ->
|
||||
state.fixedTextSize = null
|
||||
//textView.context.updateState() // font size not changed
|
||||
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
|
||||
|
@ -439,12 +447,12 @@ class SubtitlesFragment : Fragment() {
|
|||
|
||||
//Fetch current value from preference
|
||||
context?.let { ctx ->
|
||||
subtitles_filter_sub_lang?.isChecked =
|
||||
subtitlesFilterSubLang.isChecked =
|
||||
PreferenceManager.getDefaultSharedPreferences(ctx)
|
||||
.getBoolean(getString(R.string.filter_sub_lang_key), false)
|
||||
}
|
||||
|
||||
subtitles_filter_sub_lang?.setOnCheckedChangeListener { _, b ->
|
||||
subtitlesFilterSubLang.setOnCheckedChangeListener { _, b ->
|
||||
context?.let { ctx ->
|
||||
PreferenceManager.getDefaultSharedPreferences(ctx)
|
||||
.edit()
|
||||
|
@ -453,8 +461,8 @@ class SubtitlesFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
subs_font.setFocusableInTv()
|
||||
subs_font.setOnClickListener { textView ->
|
||||
subsFont.setFocusableInTv()
|
||||
subsFont.setOnClickListener { textView ->
|
||||
val fontTypes = listOf(
|
||||
Pair(null, textView.context.getString(R.string.normal)),
|
||||
Pair(R.font.trebuchet_ms, "Trebuchet MS"),
|
||||
|
@ -501,7 +509,7 @@ class SubtitlesFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
subs_font.setOnLongClickListener { textView ->
|
||||
subsFont.setOnLongClickListener { textView ->
|
||||
state.typeface = null
|
||||
state.typefaceFilePath = null
|
||||
textView.context.updateState()
|
||||
|
@ -509,8 +517,8 @@ class SubtitlesFragment : Fragment() {
|
|||
return@setOnLongClickListener true
|
||||
}
|
||||
|
||||
subs_auto_select_language.setFocusableInTv()
|
||||
subs_auto_select_language.setOnClickListener { textView ->
|
||||
subsAutoSelectLanguage.setFocusableInTv()
|
||||
subsAutoSelectLanguage.setOnClickListener { textView ->
|
||||
val langMap = arrayListOf(
|
||||
SubtitleHelper.Language639(
|
||||
textView.context.getString(R.string.none),
|
||||
|
@ -536,14 +544,14 @@ class SubtitlesFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
subs_auto_select_language.setOnLongClickListener {
|
||||
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.setFocusableInTv()
|
||||
subs_download_languages.setOnClickListener { textView ->
|
||||
subsDownloadLanguages.setFocusableInTv()
|
||||
subsDownloadLanguages.setOnClickListener { textView ->
|
||||
val langMap = SubtitleHelper.languages
|
||||
val lang639_1 = langMap.map { it.ISO_639_1 }
|
||||
val keys = getDownloadSubsLanguageISO639_1()
|
||||
|
@ -559,18 +567,18 @@ class SubtitlesFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
subs_download_languages.setOnLongClickListener {
|
||||
subsDownloadLanguages.setOnLongClickListener {
|
||||
setKey(SUBTITLE_DOWNLOAD_KEY, listOf("en"))
|
||||
|
||||
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
|
||||
return@setOnLongClickListener true
|
||||
}
|
||||
|
||||
cancel_btt.setOnClickListener {
|
||||
cancelBtt.setOnClickListener {
|
||||
activity?.popCurrentPage()
|
||||
}
|
||||
|
||||
apply_btt.setOnClickListener {
|
||||
applyBtt.setOnClickListener {
|
||||
it.context.saveStyle(state)
|
||||
applyStyleEvent.invoke(state)
|
||||
it.context.fromSaveToStyle(state)
|
||||
|
@ -578,3 +586,4 @@ class SubtitlesFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue