mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
refactor
This commit is contained in:
parent
b52f341e3c
commit
af99b0121e
6 changed files with 17 additions and 36 deletions
|
@ -754,16 +754,10 @@ open class ResultFragmentPhone : FullScreenPlayer() {
|
|||
resultReloadConnectionOpenInBrowser.isVisible = data is Resource.Failure
|
||||
|
||||
resultTitle.setOnLongClickListener {
|
||||
val titleString = activity?.getString(R.string.title) as String
|
||||
val titleString = txt(R.string.title)
|
||||
clipboardHelper(titleString, resultTitle.text)
|
||||
true
|
||||
}
|
||||
|
||||
resultDescription.setOnLongClickListener {
|
||||
val synopsisString = activity?.getString(R.string.torrent_plot) as String
|
||||
clipboardHelper(synopsisString, resultDescription.text)
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1693,8 +1693,8 @@ class ResultViewModel2 : ViewModel() {
|
|||
txt(R.string.episode_action_copy_link)
|
||||
) { (result, index) ->
|
||||
val link = result.links[index]
|
||||
val clip = "${link.name} , ${link.url}"
|
||||
clipboardHelper(link.name, clip )
|
||||
val linkCopyLabel = UiText.DynamicString(link.name)
|
||||
clipboardHelper(linkCopyLabel, link.url)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import androidx.preference.PreferenceFragmentCompat
|
|||
import androidx.preference.PreferenceManager
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.google.android.material.appbar.MaterialToolbar
|
||||
import com.lagradost.cloudstream3.AcraApplication.Companion.context
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.databinding.MainSettingsBinding
|
||||
import com.lagradost.cloudstream3.mvvm.logError
|
||||
|
@ -156,12 +155,6 @@ class SettingsFragment : Fragment() {
|
|||
return getLayoutInt() == 2
|
||||
}
|
||||
|
||||
// phone exclusive
|
||||
fun isTruePhone(): Boolean {
|
||||
return !isTrueTvSettings() && !isTvSettings() && context?.isEmulatorSettings() != true
|
||||
&& context?.isAutoTv() != true && !isTrueTv && !isTv
|
||||
}
|
||||
|
||||
private fun Context.isAutoTv(): Boolean {
|
||||
val uiModeManager = getSystemService(Context.UI_MODE_SERVICE) as UiModeManager?
|
||||
// AFT = Fire TV
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.lagradost.cloudstream3.ui.settings
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.os.TransactionTooLargeException
|
||||
import android.view.View
|
||||
|
@ -19,8 +17,8 @@ import com.lagradost.cloudstream3.databinding.LogcatBinding
|
|||
import com.lagradost.cloudstream3.mvvm.logError
|
||||
import com.lagradost.cloudstream3.network.initClient
|
||||
import com.lagradost.cloudstream3.services.BackupWorkManager
|
||||
import com.lagradost.cloudstream3.ui.result.UiText
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTruePhone
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setPaddingBottom
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setToolBarScrollFlags
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar
|
||||
|
@ -115,19 +113,13 @@ class SettingsUpdates : PreferenceFragmentCompat() {
|
|||
}
|
||||
|
||||
val text = log.toString()
|
||||
val lagraAppsSupportUri = "https://discord.com/channels/737724143126052974/737725084881387652"
|
||||
binding.text1.text = text
|
||||
|
||||
binding.copyBtt.setOnClickListener {
|
||||
// Can crash on too much text
|
||||
try {
|
||||
clipboardHelper("Logcat", text)
|
||||
// copy log and open support channel of Lagra apps server
|
||||
if (isTruePhone())
|
||||
{
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(lagraAppsSupportUri)))
|
||||
}
|
||||
|
||||
val logcat = UiText.DynamicString("Logcat")
|
||||
clipboardHelper(logcat, text)
|
||||
dialog.dismissSafe(activity)
|
||||
} catch (e: TransactionTooLargeException) {
|
||||
showToast(R.string.clipboard_too_large)
|
||||
|
|
|
@ -5,11 +5,11 @@ import android.view.ViewGroup
|
|||
import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.lagradost.cloudstream3.CommonActivity.activity
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.databinding.RepositoryItemBinding
|
||||
import com.lagradost.cloudstream3.databinding.RepositoryItemTvBinding
|
||||
import com.lagradost.cloudstream3.plugins.RepositoryManager.PREBUILT_REPOSITORIES
|
||||
import com.lagradost.cloudstream3.ui.result.txt
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.clipboardHelper
|
||||
|
||||
|
@ -117,9 +117,8 @@ class RepoAdapter(
|
|||
|
||||
repositoryItemRoot.setOnLongClickListener {
|
||||
val shareableRepoData = "${repositoryData.name} : \n ${repositoryData.url}"
|
||||
val copyLabel = activity?.getString(R.string.repo_copy_label) as String
|
||||
|
||||
clipboardHelper(copyLabel, shareableRepoData)
|
||||
val repoCopyLabel = txt(R.string.repo_copy_label)
|
||||
clipboardHelper(repoCopyLabel, shareableRepoData)
|
||||
true
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,8 @@ import com.lagradost.cloudstream3.MainActivity
|
|||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.mvvm.logError
|
||||
import com.lagradost.cloudstream3.ui.result.UiImage
|
||||
import com.lagradost.cloudstream3.ui.result.UiText
|
||||
import com.lagradost.cloudstream3.ui.result.txt
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isEmulatorSettings
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
|
||||
import jp.wasabeef.glide.transformations.BlurTransformation
|
||||
|
@ -127,17 +129,18 @@ object UIHelper {
|
|||
)
|
||||
}
|
||||
|
||||
fun clipboardHelper(label: String, text: CharSequence) {
|
||||
fun clipboardHelper(label: UiText, text: CharSequence) {
|
||||
try {
|
||||
val clip = ClipData.newPlainText(label, text)
|
||||
val labelSuffix = activity?.getString(R.string.toast_copied) as String
|
||||
val clip = ClipData.newPlainText(label.asString(context!!), text)
|
||||
val labelSuffix = txt(R.string.toast_copied)
|
||||
context?.getSystemService<ClipboardManager>()!!.setPrimaryClip(clip)
|
||||
|
||||
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.S_V2) {
|
||||
showToast("$label $labelSuffix", Toast.LENGTH_SHORT)
|
||||
showToast("${label.asString(context!!)} ${labelSuffix.asString(context!!)}")
|
||||
}
|
||||
|
||||
} catch (e: Exception) {
|
||||
} catch (t: Throwable) {
|
||||
Log.e("ClipboardService", "$t")
|
||||
showToast(R.string.clipboard_too_large)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue