Compare commits

..

1 commit

Author SHA1 Message Date
firelight
9964f6fbf0
fix subtitle clipping 2026-07-31 01:53:01 +00:00
328 changed files with 869 additions and 15399 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

View file

@ -1,7 +1,6 @@
# CloudStream
**⚠️ Warning: By default, this app doesn't provide any video sources; you have to install extensions to add functionality to the app.**
<p align="left"><a href="https://github.com/recloudstream/cloudstream/releases/download/pre-release/app-prerelease-release.apk"><img src=".github/images/download-cloudstream-pre.png" alt="Download Cloudstream Pre-Release" width=430/></a></p>
[![Discord](https://invidget.switchblade.xyz/5Hus6fM)](https://discord.gg/5Hus6fM)

View file

@ -9,8 +9,6 @@ plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.dokka)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.compose.multiplatform)
alias(libs.plugins.compose.compiler)
}
val javaTarget = JvmTarget.fromTarget(libs.versions.jvmTarget.get())
@ -290,12 +288,7 @@ dependencies {
implementation(libs.work.runtime.ktx)
implementation(libs.nicehttp) // HTTP Lib
implementation(libs.bundles.compose)
implementation(libs.activity.compose)
implementation(libs.kotlinx.io.core) // Logcat parser
implementation(project(":library"))
implementation(project(":shared"))
}
tasks.register<Jar>("androidSourcesJar") {

View file

@ -253,10 +253,6 @@
</intent-filter>
</receiver>
<receiver
android:name=".receivers.PackageInstallerStatusReceiver"
android:exported="false" />
<service
android:name=".services.VideoDownloadService"
android:enabled="true"

View file

@ -170,11 +170,11 @@ class CloudStreamApp : Application(), SingletonImageLoader.Factory {
}
/** Will fall back to WebView if in TV or emulator layout. */
fun openBrowser(url: String, activity: Activity?) {
fun openBrowser(url: String, activity: FragmentActivity?) {
openBrowser(
url,
isLayout(TV or EMULATOR),
(activity as? FragmentActivity)?.supportFragmentManager?.fragments?.lastOrNull()
activity?.supportFragmentManager?.fragments?.lastOrNull()
)
}
}

View file

@ -179,7 +179,6 @@ import com.lagradost.cloudstream3.utils.downloader.DownloadQueueManager
import com.lagradost.cloudstream3.utils.setText
import com.lagradost.cloudstream3.utils.setTextHtml
import com.lagradost.cloudstream3.utils.txt
import com.lagradost.cloudstream4.theme.CloudStreamTheme
import com.lagradost.safefile.SafeFile
import kotlinx.coroutines.Job
import kotlinx.coroutines.cancel
@ -1298,14 +1297,6 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
padRight = false,
padTop = false
)
composeView.apply {
setContent {
CloudStreamTheme {
MainActivityScreen.Content()
}
}
}
}
// overscan
@ -1989,7 +1980,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
handleAppIntent(intent)
ioSafe {
runAutoUpdate() // TODO remove this when we update the updater autosearch
runAutoUpdate()
}
FcastManager().init(this, false)

View file

@ -1,250 +0,0 @@
package com.lagradost.cloudstream3
import android.text.format.Formatter.formatFileSize
import androidx.activity.ComponentActivity
import androidx.activity.compose.LocalActivity
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.window.DialogProperties
import androidx.lifecycle.viewmodel.compose.viewModel
import com.lagradost.cloudstream3.mvvm.getStackTracePretty
import com.lagradost.cloudstream3.ui.settings.APK_CONTENT_TYPE
import com.lagradost.cloudstream3.ui.settings.APK_PRERELEASE
import com.lagradost.cloudstream3.ui.settings.APK_REPOSITORY
import com.lagradost.cloudstream3.ui.settings.APK_USERNAME
import com.lagradost.cloudstream3.ui.settings.ApkUpdater
import com.lagradost.cloudstream3.ui.settings.GithubAction
import com.lagradost.cloudstream3.ui.settings.GithubAction.AutoSearchForUpdate
import com.lagradost.cloudstream3.ui.settings.GithubAction.Dismiss
import com.lagradost.cloudstream3.ui.settings.GithubAction.SearchForUpdate
import com.lagradost.cloudstream3.ui.settings.GithubAction.SkipUpdate
import com.lagradost.cloudstream3.ui.settings.GithubAction.Update
import com.lagradost.cloudstream3.ui.settings.GithubState
import com.lagradost.cloudstream3.ui.settings.GithubUpdateDialogState
import com.lagradost.cloudstream3.ui.settings.GithubViewModel
import com.lagradost.cloudstream3.utils.GitInfo.currentCommitHash
import com.lagradost.cloudstream4.compose.BlackButton
import com.lagradost.cloudstream4.compose.Screen
import com.lagradost.cloudstream4.compose.WhiteButton
import com.lagradost.cloudstream4.rememberAppSettings
import com.mihon.material.padding
object MainActivityScreen : Screen {
@Composable
fun githubViewModel(): GithubViewModel? {
// By having the ComponentActivity as the owner we can have a singleton viewmodel
val activity = LocalActivity.current as? ComponentActivity ?: return null
val settings = rememberAppSettings()
return viewModel(viewModelStoreOwner = activity) {
GithubViewModel(
remoteUserName = APK_USERNAME,
remoteRepository = APK_REPOSITORY,
remotePrereleaseTag = APK_PRERELEASE,
remoteContentType = APK_CONTENT_TYPE,
versionName = BuildConfig.VERSION_NAME,
isPrerelease = BuildConfig.FLAVOR == "prerelease",
isDebug = BuildConfig.DEBUG,
buildSha = activity.currentCommitHash(),
settings = settings,
updater = ApkUpdater
)/*.apply {
onAction(AutoSearchForUpdate) // Remove this for now
}*/
}
}
@Composable
override fun Content() {
GithubView()
}
@Composable
fun GithubView() {
val updateViewModel = githubViewModel() ?: return
val state by updateViewModel.state.collectAsState()
GithubState(state, updateViewModel::onAction)
}
@Composable
fun GithubState(updaterState: GithubState, onAction: (GithubAction) -> Unit) {
if (updaterState.dialog == null) {
return
}
val title: String
val body: @Composable () -> Unit
val confirmButton: @Composable () -> Unit
val dismissButton: @Composable () -> Unit
val cancelable: Boolean
when (val state = updaterState.dialog.state) {
is GithubUpdateDialogState.Error -> {
// Only show error if it is initialized by the user
if (!updaterState.dialog.isFromUser) return
cancelable = true
title = stringResource(R.string.download_failed)
body = { Text(text = state.error.getStackTracePretty()) }
confirmButton = {
WhiteButton(text = stringResource(R.string.check_for_update), onClick = {
onAction(SearchForUpdate)
})
}
dismissButton = {
BlackButton(text = stringResource(R.string.ok), onClick = {
onAction(Dismiss)
})
}
}
GithubUpdateDialogState.Loading -> {
// Only show loading if it is initialized by the user
if (!updaterState.dialog.isFromUser) return
cancelable = true
title = stringResource(R.string.loading)
body = {
LinearProgressIndicator(
modifier = Modifier.fillMaxWidth(),
color = MaterialTheme.colorScheme.onBackground,
trackColor = MaterialTheme.colorScheme.surfaceVariant,
)
}
confirmButton = {}
dismissButton = {
BlackButton(text = stringResource(R.string.cancel), onClick = {
onAction(Dismiss)
})
}
}
GithubUpdateDialogState.NoUpdateFound -> {
// Only show error if it is initialized by the user
if (!updaterState.dialog.isFromUser) return
cancelable = true
title = stringResource(R.string.no_update_found)
body = {}
confirmButton = {
WhiteButton(text = stringResource(R.string.ok), onClick = {
onAction(Dismiss)
})
}
dismissButton = {}
}
is GithubUpdateDialogState.UpdateFound -> {
cancelable = true
title = stringResource(
R.string.new_update_format,
(state.oldSha ?: BuildConfig.VERSION_NAME),
(state.newSha ?: state.file.displayName)
)
body = { Text(text = state.file.changeLog) }
confirmButton = {
WhiteButton(text = stringResource(R.string.update), onClick = {
onAction(Update(state.file))
})
}
dismissButton = {
BlackButton(text = stringResource(R.string.skip_update), onClick = {
onAction(SkipUpdate(state.file))
onAction(Dismiss)
})
BlackButton(text = stringResource(R.string.cancel), onClick = {
onAction(Dismiss)
})
}
}
is GithubUpdateDialogState.DownloadProgress -> {
cancelable = false
title = stringResource(R.string.update_notification_downloading)
body = {
if (state.total != null) {
val progress =
(state.progress.toFloat() / state.total.toFloat()).coerceIn(0.0f, 1.0f)
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Text(
color = MaterialTheme.colorScheme.onBackground,
style = MaterialTheme.typography.bodyMedium,
textAlign = TextAlign.Center,
// Round down the progress to avoid 100%
text = "${(progress * 100.0f).toInt()}% (${
formatFileSize(
LocalContext.current,
state.progress
)
} / ${
formatFileSize(
LocalContext.current,
state.total
)
})"
)
Spacer(modifier = Modifier.height(MaterialTheme.padding.medium))
LinearProgressIndicator(
modifier = Modifier.fillMaxWidth(),
color = MaterialTheme.colorScheme.onBackground,
trackColor = MaterialTheme.colorScheme.surfaceVariant,
progress = { progress }
)
}
} else {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Text(
color = MaterialTheme.colorScheme.onBackground,
style = MaterialTheme.typography.bodyMedium,
textAlign = TextAlign.Center,
text = formatFileSize(
LocalContext.current,
state.progress
)
)
Spacer(modifier = Modifier.height(MaterialTheme.padding.medium))
LinearProgressIndicator(
modifier = Modifier.fillMaxWidth(),
color = MaterialTheme.colorScheme.onBackground,
trackColor = MaterialTheme.colorScheme.surfaceVariant,
)
}
}
}
confirmButton = {}
dismissButton = {
BlackButton(text = stringResource(R.string.cancel), onClick = {
onAction(Dismiss)
})
}
}
}
AlertDialog(
properties = DialogProperties(usePlatformDefaultWidth = false),
containerColor = MaterialTheme.colorScheme.background,
onDismissRequest = {
if (cancelable) {
onAction(Dismiss)
}
},
title = { Text(text = title) },
text = body,
confirmButton = confirmButton,
dismissButton = dismissButton
)
}
}

View file

@ -98,7 +98,7 @@ object VideoClickActionHolder {
?.second
}
fun getPlayers(context: Context? = null) = allVideoClickActions.filter { it.isPlayer && it.shouldShowSafe(context, null) }
fun getPlayers(activity: Activity? = null) = allVideoClickActions.filter { it.isPlayer && it.shouldShowSafe(activity, null) }
}
abstract class VideoClickAction {

View file

@ -37,7 +37,7 @@ fun buildDefaultClient(context: Context, ignoreSSL: Boolean = false): OkHttpClie
safe { Security.insertProviderAt(Conscrypt.newProvider(), 1) }
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
val dns = settingsManager.getInt(context.getString(R.string.dns_key), 0)
val dns = settingsManager.getInt(context.getString(R.string.dns_pref), 0)
val baseClient = OkHttpClient.Builder()
.followRedirects(true)
.followSslRedirects(true)

View file

@ -1,28 +0,0 @@
package com.lagradost.cloudstream3.receivers
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.pm.PackageInstaller
import com.lagradost.cloudstream3.utils.getSafeParcelableExtra
/** https://medium.com/@solrudev/painless-building-of-an-android-package-installer-app-d5a09b5df432 */
class PackageInstallerStatusReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
when (val status = intent.getIntExtra(PackageInstaller.EXTRA_STATUS, -1)) {
PackageInstaller.STATUS_PENDING_USER_ACTION -> {
intent.getSafeParcelableExtra<Intent>(Intent.EXTRA_INTENT)?.let { userAction->
userAction.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
context.startActivity(userAction)
}
}
PackageInstaller.STATUS_SUCCESS -> {
// do something on success
}
else -> {
val message = intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE)
println("PackageInstallerStatusReceiver: status=$status, message=$message")
}
}
}
}

View file

@ -1,8 +1,11 @@
package com.lagradost.cloudstream3.ui.account
import android.os.Build
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.view.isVisible
import coil3.transform.RoundedCornersTransformation
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.databinding.AccountListItemAddBinding
import com.lagradost.cloudstream3.databinding.AccountListItemBinding
@ -15,8 +18,6 @@ import com.lagradost.cloudstream3.ui.settings.Globals.TV
import com.lagradost.cloudstream3.ui.settings.Globals.isLayout
import com.lagradost.cloudstream3.utils.DataStoreHelper
import com.lagradost.cloudstream3.utils.ImageLoader.loadImage
import android.util.TypedValue
import android.view.View
class AccountAdapter(
private val accountSelectCallback: (DataStoreHelper.Account) -> Unit,
@ -28,12 +29,6 @@ class AccountAdapter(
companion object {
const val VIEW_TYPE_SELECT_ACCOUNT = 0
const val VIEW_TYPE_EDIT_ACCOUNT = 2
fun View.setRippleForeground() {
val outValue = TypedValue()
context.theme.resolveAttribute(android.R.attr.selectableItemBackgroundBorderless, outValue, true)
foreground = context.getDrawable(outValue.resourceId)
}
}
@ -52,25 +47,45 @@ class AccountAdapter(
when (val binding = holder.view) {
is AccountListItemBinding -> binding.apply {
val isTv = isLayout(TV or EMULATOR) || !root.isInTouchMode
val isLastUsedAccount = item.keyIndex == DataStoreHelper.selectedKeyIndex
accountName.text = item.name
accountImage.loadImage(item.image)
lockIcon.isVisible = item.lockPin != null
root.isSelected = isLastUsedAccount
cardView.isSelected = isLastUsedAccount
outline.isVisible = !isTv && isLastUsedAccount
if (!isTv) cardView.setRippleForeground()
if (isTv) {
// For emulator but this is fine on TV also
root.isFocusableInTouchMode = true
if (isLastUsedAccount) {
root.requestFocus()
}
if (!isTv) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
root.foreground = ContextCompat.getDrawable(
root.context,
R.drawable.outline_drawable
)
}
} else {
root.setOnLongClickListener {
showAccountEditDialog(
context = root.context,
account = item,
isNewAccount = false,
accountEditCallback = { account -> accountEditCallback.invoke(account) },
accountDeleteCallback = { account -> accountDeleteCallback.invoke(account) }
accountEditCallback = { account ->
accountEditCallback.invoke(
account
)
},
accountDeleteCallback = { account ->
accountDeleteCallback.invoke(
account
)
}
)
true
}
}
@ -82,15 +97,30 @@ class AccountAdapter(
is AccountListItemEditBinding -> binding.apply {
val isTv = isLayout(TV or EMULATOR) || !root.isInTouchMode
val isLastUsedAccount = item.keyIndex == DataStoreHelper.selectedKeyIndex
accountName.text = item.name
accountImage.loadImage(item.image)
accountImage.loadImage(item.image) {
RoundedCornersTransformation(10f)
}
lockIcon.isVisible = item.lockPin != null
root.isSelected = isLastUsedAccount
cardView.isSelected = isLastUsedAccount
outline.isVisible = !isTv && isLastUsedAccount
if (!isTv) cardView.setRippleForeground()
if (isTv) {
// For emulator but this is fine on TV also
root.isFocusableInTouchMode = true
if (isLastUsedAccount) {
root.requestFocus()
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
root.foreground = ContextCompat.getDrawable(
root.context,
R.drawable.outline_drawable
)
}
}
root.setOnClickListener {
showAccountEditDialog(
@ -98,7 +128,11 @@ class AccountAdapter(
account = item,
isNewAccount = false,
accountEditCallback = { account -> accountEditCallback.invoke(account) },
accountDeleteCallback = { account -> accountDeleteCallback.invoke(account) }
accountDeleteCallback = { account ->
accountDeleteCallback.invoke(
account
)
}
)
}
}
@ -108,9 +142,6 @@ class AccountAdapter(
override fun onBindFooter(holder: ViewHolderState<Any>) {
val binding = holder.view as? AccountListItemAddBinding ?: return
binding.apply {
val isTv = isLayout(TV or EMULATOR) || !root.isInTouchMode
if (!isTv) cardView.setRippleForeground()
root.setOnClickListener {
val accounts = this@AccountAdapter.immutableCurrentList

View file

@ -41,10 +41,6 @@ import com.lagradost.cloudstream3.utils.UIHelper.hideProgress
import com.lagradost.cloudstream3.utils.UIHelper.navigate
import com.lagradost.cloudstream3.utils.UIHelper.showInputMethod
import com.lagradost.cloudstream3.utils.UIHelper.showProgress
import com.lagradost.cloudstream3.ui.account.AccountAdapter.Companion.setRippleForeground
import com.lagradost.cloudstream3.ui.settings.Globals.EMULATOR
import com.lagradost.cloudstream3.ui.settings.Globals.TV
import com.lagradost.cloudstream3.ui.settings.Globals.isLayout
object AccountHelper {
fun showAccountEditDialog(
@ -60,12 +56,6 @@ object AccountHelper {
var currentEditAccount = account
val dialog = builder.show()
binding.accountImageHolder.requestFocus()
if (!isLayout(TV or EMULATOR)) {
binding.accountImageHolder.setRippleForeground()
binding.editProfilePhotoButtonHolder.setRippleForeground()
}
if (!isNewAccount) binding.title.setText(R.string.edit_account)
@ -110,7 +100,7 @@ object AccountHelper {
// Handle the profile picture and its interactions
binding.accountImage.loadImage(account.image)
binding.accountImageHolder.setOnClickListener {
binding.accountImage.setOnClickListener {
// Roll the image forwards once
currentEditAccount = currentEditAccount.copy(customImage = null)
currentEditAccount =
@ -176,12 +166,11 @@ object AccountHelper {
canSetPin = true
binding.editProfilePhotoButtonHolder.setOnClickListener {
val builder = AlertDialog.Builder(context, R.style.AlertDialogCustom)
binding.editProfilePhotoButton.setOnClickListener {
val bottomSheetDialog = BottomSheetDialog(context)
val sheetBinding = BottomInputDialogBinding.inflate(LayoutInflater.from(context))
builder.setView(sheetBinding.root)
val dialog = builder.create()
dialog.show()
bottomSheetDialog.setContentView(sheetBinding.root)
bottomSheetDialog.show()
sheetBinding.apply {
text1.text = context.getString(R.string.edit_profile_image_title)
@ -206,7 +195,7 @@ object AccountHelper {
R.string.edit_profile_image_success,
Toast.LENGTH_SHORT
)
dialog.dismissSafe()
bottomSheetDialog.dismissSafe()
},
onError = { _, _ ->
showToast(
@ -223,7 +212,7 @@ object AccountHelper {
imageLoader.enqueue(request)
}
sheetBinding.cancelBtt.setOnClickListener {
dialog.dismissSafe()
bottomSheetDialog.dismissSafe()
}
}
}

View file

@ -54,15 +54,10 @@ class AccountSelectActivity : FragmentActivity(), BiometricCallback {
false
)
val isFromMainActivity = intent.getBooleanExtra(
"isFromMainActivity",
false
)
// Sometimes we start this activity when we have already logged in
// For example when using cloudstreamsearch://
// In those cases we want to just go to the main activity instantly
if (hasLoggedIn && !isEditingFromMainActivity && !isFromMainActivity) {
if (hasLoggedIn && !isEditingFromMainActivity) {
navigateToMainActivity()
return
}
@ -103,7 +98,7 @@ class AccountSelectActivity : FragmentActivity(), BiometricCallback {
// Don't show account selection if there is only
// one account that exists
if (!isFromMainActivity && !isEditingFromMainActivity && skipStartup) {
if (!isEditingFromMainActivity && skipStartup) {
val currentAccount = accounts.firstOrNull { it.keyIndex == selectedKeyIndex }
if (currentAccount?.lockPin != null) {
CommonActivity.init(this)
@ -165,11 +160,6 @@ class AccountSelectActivity : FragmentActivity(), BiometricCallback {
// Scroll to current account (which is focused by default)
val layoutManager = recyclerView.layoutManager as GridLayoutManager
layoutManager.scrollToPositionWithOffset(selectedKeyIndex, 0)
if (isLayout(TV or EMULATOR)) {
recyclerView.post {
layoutManager.findViewByPosition(selectedKeyIndex)?.requestFocus()
}
}
}
observe(accountViewModel.isEditing) { isEditing ->

View file

@ -8,7 +8,7 @@ class AccountSelectLinearItemDecoration(private val size: Int) : RecyclerView.It
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
val layoutParams = view.layoutParams as RecyclerView.LayoutParams
layoutParams.width = size
layoutParams.height = RecyclerView.LayoutParams.WRAP_CONTENT
layoutParams.height = size
view.layoutParams = layoutParams
}
}

View file

@ -18,7 +18,6 @@ import android.widget.Toast
import androidx.activity.ComponentActivity
import androidx.appcompat.app.AlertDialog
import androidx.core.net.toUri
import androidx.core.view.doOnLayout
import androidx.core.view.isGone
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
@ -31,9 +30,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.chip.Chip
import com.lagradost.api.Log
import com.lagradost.cloudstream3.APIHolder
import com.lagradost.cloudstream3.APIHolder.apis
import com.lagradost.cloudstream3.APIHolder.getApiFromNameNull
import com.lagradost.cloudstream3.AllLanguagesName
import com.lagradost.cloudstream3.CommonActivity.showToast
import com.lagradost.cloudstream3.MainAPI
@ -69,7 +66,6 @@ import com.lagradost.cloudstream3.utils.AppContextUtils.getApiProviderLangSettin
import com.lagradost.cloudstream3.utils.AppContextUtils.isNetworkAvailable
import com.lagradost.cloudstream3.utils.AppContextUtils.isRecyclerScrollable
import com.lagradost.cloudstream3.utils.AppContextUtils.loadSearchResult
import com.lagradost.cloudstream3.utils.AppContextUtils.openBrowser
import com.lagradost.cloudstream3.utils.AppContextUtils.ownHide
import com.lagradost.cloudstream3.utils.AppContextUtils.ownShow
import com.lagradost.cloudstream3.utils.AppContextUtils.setDefaultFocus
@ -113,14 +109,6 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(
val errorProfilePic = errorProfilePics.random()
fun Context.getDisplayName(apiName: String?): String? {
return when (apiName) {
noneApi.name -> getString(R.string.none)
randomApi.name -> getString(R.string.home_random)
else -> apiName
}
}
//fun Activity.loadHomepageList(
// item: HomePageList,
// deleteCallback: (() -> Unit)? = null,
@ -514,10 +502,8 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(
addAll(remainingApis)
}
val names = currentValidApis.map {
val displayName = getDisplayName(it.name)
if (isMultiLang) "${getFlagFromIso(it.lang)?.plus(" ") ?: ""}$displayName" else displayName
}
val names =
currentValidApis.map { if (isMultiLang) "${getFlagFromIso(it.lang)?.plus(" ") ?: ""}${it.name}" else it.name }
val index = currentValidApis.map { it.name }.indexOf(currentApiName)
listView?.setItemChecked(index, true)
arrayAdapter.addAll(names)
@ -715,38 +701,6 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(
homeViewModel.queryTextSubmit("")
}
homePreviewSettingsButton.setOnClickListener { view ->
val apiName = homeViewModel.apiName.value
val plugin = APIHolder.getApiFromNameNull(apiName)
?.sourcePlugin?.let { PluginManager.plugins[it] } as? Plugin
val openSettings = plugin?.openSettings
if (openSettings != null) {
try {
val activityContext = view.context.getActivity() ?: view.context
openSettings.invoke(activityContext)
} catch (e: Throwable) {
logError(e)
}
}
}
// Load value for toggling Tv layout real time clock. Hide by default at startup
// set visibility first, to apply a scroll effect later
context?.let {
if (isLayout(TV)) {
val settingsManager = PreferenceManager.getDefaultSharedPreferences(it)
val toggleClock =
settingsManager.getBoolean(
getString(R.string.tv_layout_clock_key),
false
)
binding.homeClock.isVisible = toggleClock
} else {
binding.homeClock.isVisible = false
}
}
homeMasterRecycler.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
if (isLayout(PHONE)) {
@ -786,26 +740,12 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(
view.getLocationInWindow(rect)
scrollParent.isVisible = true
scrollParent.translationY = rect[1].toFloat() - 60.toPx
// Move the TV layout real time clock out of the way too
// We check if we have the correct layout and if the clock is enabled
if(isLayout(TV) && binding.homeClock.isVisible) {
val scrollParent = binding.homeClock
val rect = IntArray(2)
view.getLocationInWindow(rect)
scrollParent.isVisible = true
scrollParent.translationY = rect[1].toFloat() - 60.toPx
}
}
}
super.onScrolled(recyclerView, dx, dy)
updateTvRailFocus()
}
})
homeMasterRecycler.doOnLayout { updateTvRailFocus() }
}
//Load value for toggling Random button. Hide at startup
@ -822,10 +762,9 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(
observe(homeViewModel.apiName) { apiName ->
currentApiName = apiName
val displayApiName = context?.getDisplayName(apiName) ?: apiName
binding.apply {
homeApiFab.text = displayApiName
homeChangeApi.text = displayApiName
homeApiFab.text = apiName
homeChangeApi.text = apiName
homePreviewReloadProvider.isGone = (apiName == noneApi.name)
homePreviewSearchButton.isGone = (apiName == noneApi.name)
}
@ -833,12 +772,6 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(
observe(homeViewModel.page) { data ->
binding.apply {
if (isLayout(TV or EMULATOR)) {
val plugin = APIHolder.getApiFromNameNull(homeViewModel.apiName.value)
?.sourcePlugin?.let { PluginManager.plugins[it] } as? Plugin
homePreviewSettingsButton.isGone = plugin?.openSettings == null
}
when (data) {
is Resource.Success -> {
val d = data.value
@ -854,7 +787,6 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(
homeLoadingError.isVisible = false
homeMasterRecycler.isVisible = true
homeLoadingShimmer.stopShimmer()
//home_loaded?.isVisible = true
if (toggleRandomButton) {
val distinct = d.values
@ -875,16 +807,26 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(
homeRandomButtonTv.isGone = true
}
}
//Open browser directly, without a menu.
is Resource.Failure -> {
homeLoadingShimmer.stopShimmer()
homeReloadConnectionerror.setOnClickListener(apiChangeClickListener)
homeReloadConnectionOpenInBrowser.setOnClickListener {
val currentApi = currentApiName?.let { getApiFromNameNull(it) }
?: homeViewModel.apiName.value?.let { getApiFromNameNull(it) }
val mainUrl = currentApi?.mainUrl
if (!mainUrl.isNullOrBlank()) {
context?.openBrowser(mainUrl)
homeReloadConnectionOpenInBrowser.setOnClickListener { view ->
val validAPIs = apis//.filter { api -> api.hasMainPage }
view.popupMenuNoIconsAndNoStringRes(validAPIs.mapIndexed { index, api ->
Pair(
index,
api.name
)
}) {
try {
val i = Intent(Intent.ACTION_VIEW)
i.data = validAPIs[itemId].mainUrl.toUri()
startActivity(i)
} catch (e: Exception) {
logError(e)
}
}
}
@ -979,29 +921,6 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>(
}*/
}
private fun updateTvRailFocus() {
if (!isLayout(TV or EMULATOR)) return
// home_api_holder is glued to the header row's top by the mirror logic in
// the scroll listener above. Only target the provider button while the
// holder is actually on screen; once the header scrolls off (y < 0) let
// the rail fall back to default focus search so RIGHT enters content rows
val holder = binding?.homeApiHolder
val target =
if (holder != null && holder.isVisible && holder.y >= 0f) R.id.home_change_api
else View.NO_ID
val rail = activity?.findViewById<View>(R.id.nav_rail_view) ?: return
rail.nextFocusRightId = target
for (focusView in arrayOf(
R.id.navigation_downloads,
R.id.navigation_home,
R.id.navigation_search,
R.id.navigation_library,
R.id.navigation_settings,
)) {
rail.findViewById<View>(focusView)?.nextFocusRightId = target
}
}
private fun handleTvBackPress(helper: BackPressedCallbackHelper.CallbackHelper) {
// Only apply custom behavior on TV interface
if (!isLayout(TV)) {

View file

@ -159,7 +159,7 @@ open class ParentItemAdapter(
})
//(recyclerView.adapter as HomeChildItemAdapter).notifyDataSetChanged()
if (isLayout(PHONE or EMULATOR)) {
if (isLayout(PHONE)) {
homeChildMoreInfo.setOnClickListener {
moreInfoClickCallback.invoke(item)
}

View file

@ -108,7 +108,6 @@ import com.lagradost.cloudstream3.utils.PLAYREADY_DRM_UUID
import com.lagradost.cloudstream3.utils.SubtitleHelper.fromTagToLanguageName
import com.lagradost.cloudstream3.utils.WIDEVINE_DRM_UUID
import com.lagradost.cloudstream3.utils.videoskip.VideoSkipStamp
import com.lagradost.cloudstream4.AppSettings
import kotlinx.coroutines.delay
import okhttp3.Interceptor
import org.chromium.net.CronetEngine
@ -1390,17 +1389,10 @@ class CS3IPlayer : IPlayer {
context.getString(if (context.isUsingMobileData()) R.string.quality_pref_mobile_data_key else R.string.quality_pref_key),
Int.MAX_VALUE
)
val settings = AppSettings(context)
try {
hasUsedFirstRender = false
val playWhenReady = if (settings.player.startPaused.get()) {
false
} else {
isPlaying // this keep the current state of the player
}
// ye this has to be a val for whatever reason
// this makes no sense
exoPlayer = buildExoPlayer(
@ -1412,7 +1404,7 @@ class CS3IPlayer : IPlayer {
playBackSpeed,
cacheSize = cacheSize,
videoBufferMs = videoBufferMs,
playWhenReady = playWhenReady,
playWhenReady = isPlaying, // this keep the current state of the player
subtitleOffset = currentSubtitleOffset,
maxVideoHeight = maxVideoHeight,
audioSources = audioSources,

View file

@ -102,12 +102,12 @@ open class FullScreenPlayer : AbstractPlayerFragment<FragmentPlayerBinding>(
private var hideControlsNames = false
protected var subtitleDelay
set(value) = try {
player.setSubtitleOffset(value)
player.setSubtitleOffset(-value)
} catch (e: Exception) {
logError(e)
}
get() = try {
player.getSubtitleOffset()
-player.getSubtitleOffset()
} catch (e: Exception) {
logError(e)
0L
@ -307,7 +307,6 @@ open class FullScreenPlayer : AbstractPlayerFragment<FragmentPlayerBinding>(
playerVideoTitleRez,
playerVideoInfo,
playerGoBackHolder,
playerVideoClock,
).forEach {
it.animateY(titleMove)
}
@ -527,7 +526,7 @@ open class FullScreenPlayer : AbstractPlayerFragment<FragmentPlayerBinding>(
// Scroll to the first active subtitle
val playerPosition = player.getPosition() ?: 0
val totalPosition = playerPosition + currentOffset
val totalPosition = playerPosition - currentOffset
subtitleAdapter?.updateTime(totalPosition)
subtitleAdapter?.getLatestActiveItem(totalPosition)
@ -537,11 +536,11 @@ open class FullScreenPlayer : AbstractPlayerFragment<FragmentPlayerBinding>(
val str = when {
time > 0L -> {
txt(R.string.subtitle_offset_extra_hint_before_format, time)
txt(R.string.subtitle_offset_extra_hint_later_format, time)
}
time < 0L -> {
txt(R.string.subtitle_offset_extra_hint_later_format, -time)
txt(R.string.subtitle_offset_extra_hint_before_format, -time)
}
else -> {
@ -559,12 +558,12 @@ open class FullScreenPlayer : AbstractPlayerFragment<FragmentPlayerBinding>(
subtitleOffsetRecyclerview.isVisible = subtitles.isNotEmpty()
noSubtitlesLoadedNotice.isVisible = subtitles.isEmpty()
val initialSubtitlePosition = (player.getPosition() ?: 0) + currentOffset
val initialSubtitlePosition = (player.getPosition() ?: 0) - currentOffset
subtitleAdapter =
SubtitleOffsetItemAdapter(initialSubtitlePosition) { subtitleCue ->
val playerPosition = player.getPosition() ?: 0
subtitleOffsetInput.text = Editable.Factory.getInstance()
?.newEditable((subtitleCue.startTimeMs - playerPosition).toString())
?.newEditable((playerPosition - subtitleCue.startTimeMs).toString())
}.apply {
submitList(subtitles)
}
@ -773,7 +772,7 @@ open class FullScreenPlayer : AbstractPlayerFragment<FragmentPlayerBinding>(
val showPlayerEpisodes = !isGone && isThereEpisodes()
playerEpisodesButtonRoot.isVisible = showPlayerEpisodes
playerEpisodesButton.isVisible = showPlayerEpisodes
playerVideoTitleHolder.isGone = togglePlayerTitleGone || playerVideoTitle.text.isBlank()
playerVideoTitleHolder.isGone = togglePlayerTitleGone
playerVideoTitleRez.isGone = isGone || playerVideoTitleRez.text.isBlank()
playerEpisodeFiller.isGone = isGone
playerCenterMenu.isGone = isGone

View file

@ -8,7 +8,6 @@ import android.content.Context
import android.content.Intent
import android.content.res.ColorStateList
import android.graphics.Bitmap
import android.graphics.Typeface
import android.os.Build
import android.os.Bundle
import android.text.Spanned
@ -80,7 +79,6 @@ import com.lagradost.cloudstream3.ui.player.CS3IPlayer.Companion.preferredAudioT
import com.lagradost.cloudstream3.ui.player.CustomDecoder.Companion.updateForcedEncoding
import com.lagradost.cloudstream3.ui.player.PlayerSubtitleHelper.Companion.toSubtitleMimeType
import com.lagradost.cloudstream3.ui.player.source_priority.LinkSource
import com.lagradost.cloudstream3.ui.player.source_priority.ProfileSettings
import com.lagradost.cloudstream3.ui.player.source_priority.QualityDataHelper
import com.lagradost.cloudstream3.ui.player.source_priority.QualityDataHelper.getLinkPriority
import com.lagradost.cloudstream3.ui.player.source_priority.QualityProfileDialog
@ -101,7 +99,6 @@ import com.lagradost.cloudstream3.ui.settings.Globals.isLayout
import com.lagradost.cloudstream3.ui.subtitles.SUBTITLE_AUTO_SELECT_KEY
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.getAutoSelectLanguageTagIETF
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragmentDialog2
import com.lagradost.cloudstream3.utils.AppContextUtils.getShortSeasonText
import com.lagradost.cloudstream3.utils.AppContextUtils.html
import com.lagradost.cloudstream3.utils.AppContextUtils.sortSubs
@ -135,7 +132,6 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import java.io.Serializable
import java.lang.ref.WeakReference
import java.util.Calendar
import java.util.UUID
import java.util.concurrent.ConcurrentHashMap
@ -1047,7 +1043,7 @@ class GeneratorPlayer : FullScreenPlayer() {
binding.subtitleSettingsBtt.setOnClickListener {
safe {
val subtitlesFragment = SubtitlesFragmentDialog2()
val subtitlesFragment = SubtitlesFragment()
subtitlesFragment.systemBarsAddPadding = true
subtitlesFragment.show(this.parentFragmentManager, "SubtitleSettings")
}
@ -1116,29 +1112,21 @@ class GeneratorPlayer : FullScreenPlayer() {
var sourceIndex = 0
var startSource = 0
// Filtered and sorted links
var currentHiddenFooter: View? = null
var filteredLinks: List<DisplayLink> = emptyList()
var sortedUrls = emptyList<Pair<ExtractorLink?, ExtractorUri?>>()
fun refreshLinks(qualityProfile: Int) {
val currentLinkUsed = currentSelectedLink
// Always display current linkFooter
val sortedLinks = viewModel.state.sortLinks(qualityProfile)
filteredLinks = sortedLinks.filter { it.shouldUseLink || it.link == currentLinkUsed }
if (sortedLinks.isEmpty()) {
sortedUrls = viewModel.state.sortLinks(qualityProfile)
if (sortedUrls.isEmpty()) {
sourceDialog.findViewById<LinearLayout>(R.id.sort_sources_holder)?.isGone =
true
} else {
startSource = filteredLinks.indexOfFirst { it.link == currentLinkUsed }
startSource = sortedUrls.indexOf(currentSelectedLink)
sourceIndex = startSource
val sourcesArrayAdapter =
ArrayAdapter<String>(ctx, R.layout.sort_bottom_single_choice)
sourcesArrayAdapter.addAll(filteredLinks.map { displayLink ->
val (link, uri) = displayLink.link
sourcesArrayAdapter.addAll(sortedUrls.map { (link, uri) ->
val name = link?.name ?: uri?.name ?: "NULL"
"$name ${Qualities.getStringByInt(link?.quality)}"
})
@ -1154,7 +1142,7 @@ class GeneratorPlayer : FullScreenPlayer() {
}
providerList.setOnItemLongClickListener { _, _, position, _ ->
sortedLinks.getOrNull(position)?.link?.first?.url?.let {
sortedUrls.getOrNull(position)?.first?.url?.let {
clipboardHelper(
txt(R.string.video_source),
it
@ -1162,25 +1150,6 @@ class GeneratorPlayer : FullScreenPlayer() {
}
true
}
val hiddenLinks = sortedLinks.size - filteredLinks.size
providerList.removeFooterView(currentHiddenFooter)
if (hiddenLinks > 0) {
val hiddenLinksFooter: TextView = layoutInflater.inflate(
R.layout.sort_bottom_footer_add_choice, null
) as TextView
providerList.addFooterView(hiddenLinksFooter, null, false)
currentHiddenFooter = hiddenLinksFooter
val hiddenLinksText =
ctx.resources.getQuantityString(R.plurals.links_hidden, hiddenLinks)
.format(hiddenLinks)
hiddenLinksFooter.text = hiddenLinksText
hiddenLinksFooter.setCompoundDrawables(null, null, null, null)
hiddenLinksFooter.setTypeface(null, Typeface.ITALIC)
}
}
}
@ -1394,8 +1363,8 @@ class GeneratorPlayer : FullScreenPlayer() {
}
}
if (init) {
filteredLinks.getOrNull(sourceIndex)?.let {
loadLink(it.link, true)
sortedUrls.getOrNull(sourceIndex)?.let {
loadLink(it, true)
}
}
sourceDialog.dismissSafe(activity)
@ -1563,10 +1532,6 @@ class GeneratorPlayer : FullScreenPlayer() {
}
override fun playerError(exception: Throwable) {
currentSelectedLink?.let { link ->
viewModel.modifyState { this.addError(link) }
}
val currentUrl =
currentSelectedLink?.let { it.first?.url ?: it.second?.uri?.toString() } ?: "unknown"
val headers = currentSelectedLink?.first?.headers?.toString() ?: "none"
@ -1589,22 +1554,8 @@ class GeneratorPlayer : FullScreenPlayer() {
private fun noLinksFound() {
viewModel.forceClearCache = true
val hiddenLinks = viewModel.state.sortLinks(currentQualityProfile).count { !it.shouldUseLink }
context?.let { ctx ->
// Display that there are hidden links to the user.
if (hiddenLinks > 0) {
val noLinksString = ctx.getString(R.string.no_links_found_toast)
val hiddenString =
ctx.resources.getQuantityString(R.plurals.links_hidden, hiddenLinks)
.format(hiddenLinks)
val toastText = "$noLinksString\n($hiddenString)"
showToast(toastText, Toast.LENGTH_SHORT)
} else {
showToast(R.string.no_links_found_toast, Toast.LENGTH_SHORT)
}
}
showToast(R.string.no_links_found_toast, Toast.LENGTH_SHORT)
activity?.popCurrentPage()
}
@ -1615,9 +1566,7 @@ class GeneratorPlayer : FullScreenPlayer() {
}
val links = viewModel.state.sortLinks(currentQualityProfile)
val firstAvailableLink = links.firstOrNull { it.shouldUseLink }?.link
if (firstAvailableLink == null) {
if (links.isEmpty()) {
noLinksFound()
return
}
@ -1625,7 +1574,7 @@ class GeneratorPlayer : FullScreenPlayer() {
if (!isPlayerActive.compareAndSet(false, true)) {
return
}
loadLink(firstAvailableLink, false)
loadLink(links.first(), false)
showPlayerMetadata()
}
@ -1692,26 +1641,25 @@ class GeneratorPlayer : FullScreenPlayer() {
}
}
private fun getNextLink(): DisplayLink? {
val links = viewModel.state.sortLinks(currentQualityProfile)
val currentIndex = links.indexOfFirst { it.link == currentSelectedLink }
val nextPotentialLink =
links.withIndex().firstOrNull { it.index > currentIndex && it.value.shouldUseLink }
return nextPotentialLink?.value
}
override fun hasNextMirror(): Boolean {
return getNextLink() != null
val links = viewModel.state.sortLinks(currentQualityProfile)
return links.isNotEmpty() && links.indexOf(currentSelectedLink) + 1 < links.size
}
override fun nextMirror() {
val nextLink = getNextLink()
if (nextLink == null) {
val links = viewModel.state.sortLinks(currentQualityProfile)
if (links.isEmpty()) {
noLinksFound()
return
}
loadLink(nextLink.link, true)
val newIndex = links.indexOf(currentSelectedLink) + 1
if (newIndex >= links.size) {
noLinksFound()
return
}
loadLink(links[newIndex], true)
}
override fun onDestroy() {
@ -2218,7 +2166,6 @@ class GeneratorPlayer : FullScreenPlayer() {
isPlayerActive.set(false)
binding?.overlayLoadingSkipButton?.isVisible = false
binding?.playerLoadingOverlay?.isVisible = true
viewModel.modifyState { setError(emptyList()) }
uiReset()
}
@ -2272,14 +2219,6 @@ class GeneratorPlayer : FullScreenPlayer() {
fromTagToEnglishLanguageName(it)?.lowercase() ?: return@mapNotNull null
} ?: listOf()
}
// Set up TV clock visibility
if (isLayout(TV)) {
val showTvClock = settingsManager.getBoolean(ctx.getString(R.string.tv_layout_clock_key), false)
playerBinding?.playerVideoClock?.isVisible = showTvClock
} else {
playerBinding?.playerVideoClock?.isVisible = false
}
}
unwrapBundle(savedInstanceState)
@ -2358,23 +2297,19 @@ class GeneratorPlayer : FullScreenPlayer() {
}
}
observe(viewModel.currentLinks) { (_, instance) ->
observe(viewModel.currentLinks) { (links, instance) ->
if (instance != viewModel.state.instance) return@observe // Outdated observe
val sortedLinks = viewModel.state.sortLinks(currentQualityProfile)
val usableLinks = sortedLinks.count { link -> link.shouldUseLink }
val turnVisible = usableLinks > 0 && viewModel.generator?.canSkipLoading == true
val turnVisible = links.isNotEmpty() && viewModel.generator?.canSkipLoading == true
val wasGone = binding.overlayLoadingSkipButton.isGone
binding.overlayLoadingSkipButton.apply {
isVisible = turnVisible
if (usableLinks == 0) {
if (links.isEmpty()) {
setText(R.string.skip_loading)
} else {
@SuppressLint("SetTextI18n")
text = "${context.getString(R.string.skip_loading)} (${usableLinks})"
text = "${context.getString(R.string.skip_loading)} (${links.size})"
}
}

View file

@ -10,8 +10,6 @@ import com.lagradost.cloudstream3.mvvm.Resource
import com.lagradost.cloudstream3.mvvm.launchSafe
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.mvvm.safeApiCall
import com.lagradost.cloudstream3.ui.player.source_priority.ProfileSettings
import com.lagradost.cloudstream3.ui.player.source_priority.QualityDataHelper
import com.lagradost.cloudstream3.ui.player.source_priority.QualityDataHelper.getLinkPriority
import com.lagradost.cloudstream3.ui.result.ResultEpisode
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
@ -42,20 +40,12 @@ data class GeneratorState(
val id: Int?,
)
data class DisplayLink(
val link: VideoLink,
// If the link should be displayed and used by the player
val shouldUseLink: Boolean,
val priority: Int
)
/** Immutable state of all current links relevant to displaying the video */
// @MustUseReturnValues
// @Immutable
data class VideoState(
val subtitles: PersistentSet<SubtitleData> = persistentSetOf(),
val links: PersistentSet<VideoLink> = persistentSetOf(),
val erroredLinks: PersistentSet<VideoLink> = persistentSetOf(),
val stamps: PersistentList<VideoSkipStamp> = persistentListOf(),
val loading: Resource<Unit> = Resource.Loading(),
val generatorState: GeneratorState? = null,
@ -66,52 +56,19 @@ data class VideoState(
*
* sortedBy is not exactly expensive, but each hasNextMirror does it again, so this alleviates unnecessary recomputation
* */
private val sortedLinks: ConcurrentHashMap<Int, List<DisplayLink>> = ConcurrentHashMap()
private val sortedLinks: ConcurrentHashMap<Int, List<VideoLink>> = ConcurrentHashMap()
/**
* The cache is guaranteed to be up to date link-wise due to the immutable links.
* However, hideNegativeSources and hideErrorSources could be updated, which requires clearing the cache.
*/
fun clearSortedLinksCache() = sortedLinks.clear()
private fun hasLinkErrored(link: VideoLink): Boolean {
return erroredLinks.any { it == link }
}
private fun VideoLink.toDisplayLink(
qualityProfile: Int,
hideNegativeSources: Boolean,
hideErrorSources: Boolean
): DisplayLink {
val priority = getLinkPriority(qualityProfile, this.first)
val shouldHideLink =
(hideNegativeSources && priority < 0) || (hideErrorSources && hasLinkErrored(this))
val displayLink = DisplayLink(this, !shouldHideLink, priority)
return displayLink
}
// Modifying sortedLinks is not considered a "visible" side effect, and rerunning it does not change the result
// It is by all standards, idempotent and by extension also pure as it has no "visible" side effect
/** Returns .links in the sorted order according to the qualityProfile.
* Use .links if order is not needed */
@Contract(pure = true)
fun sortLinks(qualityProfile: Int): List<DisplayLink> {
sortedLinks[qualityProfile]?.let {
return it
}
val hideNegativeSources =
QualityDataHelper.getProfileSetting(qualityProfile, ProfileSettings.HideNegativeSources)
val hideErrorSources =
QualityDataHelper.getProfileSetting(qualityProfile, ProfileSettings.HideErrorSources)
return links.map { link ->
fun sortLinks(qualityProfile: Int): List<VideoLink> {
return sortedLinks[qualityProfile] ?: links.sortedBy { link ->
// negative because we want to sort highest quality first
link.toDisplayLink(qualityProfile, hideNegativeSources, hideErrorSources)
}.sortedBy {
// negative because we want to sort highest quality first
-it.priority
-getLinkPriority(qualityProfile, link.first)
}.also { value -> sortedLinks[qualityProfile] = value }
}
@ -156,12 +113,6 @@ data class VideoState(
@JvmName("setVideoSkipStamp")
@Contract(pure = true)
fun set(items: Collection<VideoSkipStamp>): VideoState = copy(stamps = items.toPersistentList())
@Contract(pure = true)
fun addError(item: VideoLink): VideoState = copy(erroredLinks = erroredLinks.add(item))
@Contract(pure = true)
fun setError(items: Collection<VideoLink>): VideoState = copy(erroredLinks = items.toPersistentSet())
}
data class VideoLive<T>(
@ -190,8 +141,9 @@ class PlayerGeneratorViewModel : ViewModel() {
var state = VideoState(instance = 0)
private set
private val _currentLinks = MutableLiveData<VideoLive<Set<VideoLink>>>(null)
val currentLinks: LiveData<VideoLive<Set<VideoLink>>> = _currentLinks
private val _currentLinks =
MutableLiveData<VideoLive<Set<Pair<ExtractorLink?, ExtractorUri?>>>>(null)
val currentLinks: LiveData<VideoLive<Set<Pair<ExtractorLink?, ExtractorUri?>>>> = _currentLinks
private val _currentSubtitles = MutableLiveData<VideoLive<Set<SubtitleData>>>(null)
val currentSubtitles: LiveData<VideoLive<Set<SubtitleData>>> = _currentSubtitles

View file

@ -12,16 +12,12 @@ import com.lagradost.cloudstream3.utils.txt
import com.lagradost.cloudstream3.utils.DataStoreHelper.currentAccount
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities
import java.util.EnumMap
import java.util.concurrent.ConcurrentHashMap
import kotlin.also
import kotlin.math.abs
object QualityDataHelper {
private const val VIDEO_SOURCE_PRIORITY = "video_source_priority"
private const val VIDEO_PROFILE_NAME = "video_profile_name"
private const val VIDEO_QUALITY_PRIORITY = "video_quality_priority"
const val VIDEO_PROFILE_SETTINGS = "video_profile_settings"
// Old key only supporting one type per profile
@Deprecated("Changed to support multiple types per profile")
@ -57,21 +53,13 @@ object QualityDataHelper {
val types: Set<QualityProfileType>
)
// Map profile and name to priority
val sourcePriorityCache: ConcurrentHashMap<Int, HashMap<String, Int>> = ConcurrentHashMap()
fun getSourcePriority(profile: Int, name: String?): Int {
if (name == null) return DEFAULT_SOURCE_PRIORITY
return sourcePriorityCache[profile]?.get(name) ?: (getKey<Int>(
return getKey<Int>(
"$currentAccount/$VIDEO_SOURCE_PRIORITY/$profile",
name,
DEFAULT_SOURCE_PRIORITY
) ?: DEFAULT_SOURCE_PRIORITY).also {
sourcePriorityCache.getOrPut(profile) { hashMapOf() }
sourcePriorityCache[profile]?.set(name, it)
}
) ?: DEFAULT_SOURCE_PRIORITY
}
fun getAllSourcePriorityNames(profile: Int): List<String> {
@ -89,8 +77,6 @@ object QualityDataHelper {
} else {
setKey(folder, name, priority)
}
sourcePriorityCache[profile]?.set(name, priority)
}
fun setProfileName(profile: Int, name: String?) {
@ -107,17 +93,12 @@ object QualityDataHelper {
?: txt(R.string.profile_number, profile)
}
// Map profile and quality to priority
val qualityPriorityCache: ConcurrentHashMap<Int, EnumMap<Qualities, Int>> = ConcurrentHashMap()
fun getQualityPriority(profile: Int, quality: Qualities): Int {
return qualityPriorityCache[profile]?.get(quality) ?: (getKey<Int>(
return getKey<Int>(
"$currentAccount/$VIDEO_QUALITY_PRIORITY/$profile",
quality.value.toString(),
quality.defaultPriority
)?.also {
qualityPriorityCache.getOrPut(profile) { EnumMap(Qualities::class.java) }
qualityPriorityCache[profile]?.set(quality, it)
}) ?: quality.defaultPriority
) ?: quality.defaultPriority
}
fun setQualityPriority(profile: Int, quality: Qualities, priority: Int) {
@ -126,24 +107,8 @@ object QualityDataHelper {
quality.value.toString(),
priority
)
qualityPriorityCache[profile]?.set(quality, priority)
}
fun <T> setProfileSetting(profile: Int, setting: ProfileSettings<T>, value: T) {
val folder = "$currentAccount/$VIDEO_PROFILE_SETTINGS/$profile"
// Prevent unnecessary keys
if (value == setting.defaultValue) {
removeKey(folder, setting.key)
} else {
setKey(folder, setting.key, value)
}
}
inline fun <reified T : Any> getProfileSetting(profile: Int, setting: ProfileSettings<T>): T {
val folder = "$currentAccount/$VIDEO_PROFILE_SETTINGS/$profile"
val value = getKey<T>(folder, setting.key)
return value ?: setting.defaultValue
}
@Suppress("DEPRECATION")
fun getQualityProfileTypes(profile: Int): Set<QualityProfileType> {
@ -259,8 +224,3 @@ object QualityDataHelper {
return Qualities.entries.minBy { abs(it.value - target) }
}
}
sealed class ProfileSettings<T>(val key: String, val defaultValue: T) {
object HideErrorSources : ProfileSettings<Boolean>("hide_error_sources", false)
object HideNegativeSources : ProfileSettings<Boolean>("hide_negative_sources", false)
}

View file

@ -1,6 +1,5 @@
package com.lagradost.cloudstream3.ui.player.source_priority
import android.app.Activity
import android.app.Dialog
import androidx.annotation.StyleRes
import androidx.core.view.isVisible
@ -27,7 +26,7 @@ data class LinkSource(
class QualityProfileDialog private constructor(
val activity: Activity,
val activity: FragmentActivity,
@StyleRes val themeRes: Int,
private val links: List<LinkSource>,
private val usedProfile: Int?,
@ -35,7 +34,7 @@ class QualityProfileDialog private constructor(
private val useProfileSelection: Boolean
) : Dialog(activity, themeRes) {
constructor(
activity: Activity,
activity: FragmentActivity,
@StyleRes themeRes: Int,
links: List<LinkSource>,
usedProfile: Int,
@ -43,7 +42,7 @@ class QualityProfileDialog private constructor(
) : this(activity, themeRes, links, usedProfile, profileSelectionCallback, true)
constructor(
activity: Activity,
activity: FragmentActivity,
@StyleRes themeRes: Int,
links: List<LinkSource>
) : this(activity, themeRes, links, null, null, false)

View file

@ -14,7 +14,7 @@ import com.lagradost.cloudstream3.utils.UIHelper.fixSystemBarsPadding
class SourcePriorityDialog(
val ctx: Context,
@StyleRes val themeRes: Int,
@StyleRes themeRes: Int,
val links: List<LinkSource>,
private val profile: QualityDataHelper.QualityProfile,
/**
@ -28,79 +28,76 @@ class SourcePriorityDialog(
PlayerSelectSourcePriorityBinding.inflate(LayoutInflater.from(ctx), null, false)
setContentView(binding.root)
fixSystemBarsPadding(binding.root)
val sourcesRecyclerView = binding.sortSources
val qualitiesRecyclerView = binding.sortQualities
val profileText = binding.profileTextEditable
val saveBtt = binding.saveBtt
val exitBtt = binding.closeBtt
val helpBtt = binding.helpBtt
binding.apply {
profileTextEditable.setText(
QualityDataHelper.getProfileName(profile.id).asString(context)
)
profileTextEditable.hint = txt(R.string.profile_number, profile.id).asString(context)
profileText.setText(QualityDataHelper.getProfileName(profile.id).asString(context))
profileText.hint = txt(R.string.profile_number, profile.id).asString(context)
sortSources.adapter = PriorityAdapter<Nothing?>(
).apply {
val sortedLinks = links.map { link ->
SourcePriority(
null,
link.source,
QualityDataHelper.getSourcePriority(profile.id, link.source)
)
}.distinctBy { it.name }.sortedBy { -it.priority }
submitList(sortedLinks)
}
sortQualities.adapter = PriorityAdapter<Qualities>(
).apply {
submitList(Qualities.entries.mapNotNull {
SourcePriority(
it,
Qualities.getStringByIntFull(it.value).ifBlank { return@mapNotNull null },
QualityDataHelper.getQualityPriority(profile.id, it)
)
}.sortedBy { -it.priority })
}
@Suppress("UNCHECKED_CAST") // We know the types
saveBtt.setOnClickListener {
val qualityAdapter = sortQualities.adapter as? PriorityAdapter<Qualities>
val sourcesAdapter = sortSources.adapter as? PriorityAdapter<Nothing?>
val qualities = qualityAdapter?.immutableCurrentList ?: emptyList()
val sources = sourcesAdapter?.immutableCurrentList ?: emptyList()
qualities.forEach {
QualityDataHelper.setQualityPriority(profile.id, it.data, it.priority)
}
sources.forEach {
QualityDataHelper.setSourcePriority(profile.id, it.name, it.priority)
}
qualityAdapter?.submitList(qualities.sortedBy { -it.priority })
sourcesAdapter?.submitList(sources.sortedBy { -it.priority })
val savedProfileName = profileTextEditable.text.toString()
if (savedProfileName.isBlank()) {
QualityDataHelper.setProfileName(profile.id, null)
} else {
QualityDataHelper.setProfileName(profile.id, savedProfileName)
}
updatedCallback.invoke()
}
closeBtt.setOnClickListener {
dismissSafe()
}
helpBtt.setOnClickListener {
AlertDialog.Builder(context, R.style.AlertDialogCustom).apply {
setMessage(R.string.quality_profile_help)
}.show()
}
settingsBtt.setOnClickListener {
SourceProfileSettingsDialog(ctx, themeRes, profile.id).show()
}
sourcesRecyclerView.adapter = PriorityAdapter<Nothing?>(
).apply {
submitList(links.map { link ->
SourcePriority(
null,
link.source,
QualityDataHelper.getSourcePriority(profile.id, link.source)
)
}.distinctBy { it.name }.sortedBy { -it.priority })
}
qualitiesRecyclerView.adapter = PriorityAdapter<Qualities>(
).apply {
submitList(Qualities.entries.mapNotNull {
SourcePriority(
it,
Qualities.getStringByIntFull(it.value).ifBlank { return@mapNotNull null },
QualityDataHelper.getQualityPriority(profile.id, it)
)
}.sortedBy { -it.priority })
}
@Suppress("UNCHECKED_CAST") // We know the types
saveBtt.setOnClickListener {
val qualityAdapter = qualitiesRecyclerView.adapter as? PriorityAdapter<Qualities>
val sourcesAdapter = sourcesRecyclerView.adapter as? PriorityAdapter<Nothing?>
val qualities = qualityAdapter?.immutableCurrentList ?: emptyList()
val sources = sourcesAdapter?.immutableCurrentList ?: emptyList()
qualities.forEach {
QualityDataHelper.setQualityPriority(profile.id, it.data, it.priority)
}
sources.forEach {
QualityDataHelper.setSourcePriority(profile.id, it.name, it.priority)
}
qualityAdapter?.submitList(qualities.sortedBy { -it.priority })
sourcesAdapter?.submitList(sources.sortedBy { -it.priority })
val savedProfileName = profileText.text.toString()
if (savedProfileName.isBlank()) {
QualityDataHelper.setProfileName(profile.id, null)
} else {
QualityDataHelper.setProfileName(profile.id, savedProfileName)
}
updatedCallback.invoke()
}
exitBtt.setOnClickListener {
this.dismissSafe()
}
helpBtt.setOnClickListener {
AlertDialog.Builder(context, R.style.AlertDialogCustom).apply {
setMessage(R.string.quality_profile_help)
}.show()
}
super.show()
}
}

View file

@ -1,48 +0,0 @@
package com.lagradost.cloudstream3.ui.player.source_priority
import android.app.Dialog
import android.content.Context
import android.view.LayoutInflater
import androidx.annotation.StyleRes
import com.lagradost.cloudstream3.databinding.SourceProfileSettingsDialogBinding
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
import com.lagradost.cloudstream3.utils.UIHelper.fixSystemBarsPadding
class SourceProfileSettingsDialog(
val ctx: Context,
@StyleRes themeRes: Int,
val profile: Int
) : Dialog(ctx, themeRes) {
override fun show() {
val binding =
SourceProfileSettingsDialogBinding.inflate(LayoutInflater.from(ctx), null, false)
setContentView(binding.root)
fixSystemBarsPadding(binding.root)
binding.apply {
var hideErrorSources = QualityDataHelper.getProfileSetting(profile, ProfileSettings.HideErrorSources)
var hideNegativeSources = QualityDataHelper.getProfileSetting(profile, ProfileSettings.HideNegativeSources)
profileHideErrorSources.isChecked = hideErrorSources
profileHideErrorSources.setOnCheckedChangeListener { _, bool ->
hideErrorSources = bool
}
profileHideNegativeSources.isChecked = hideNegativeSources
profileHideNegativeSources.setOnCheckedChangeListener { _, bool ->
hideNegativeSources = bool
}
applyBtt.setOnClickListener {
QualityDataHelper.setProfileSetting(profile, ProfileSettings.HideErrorSources, hideErrorSources)
QualityDataHelper.setProfileSetting(profile, ProfileSettings.HideNegativeSources, hideNegativeSources)
dismissSafe()
}
cancelBtt.setOnClickListener {
dismissSafe()
}
}
super.show()
}
}

View file

@ -874,6 +874,7 @@ class ResultFragmentTv : BaseFragment<FragmentResultTvBinding>(
resultMetaRating.setText(d.ratingText)
resultMetaStatus.setText(d.onGoingText)
resultMetaContentRating.setText(d.contentRatingText)
resultCastText.setText(d.actorsText)
resultNextAiring.setText(d.nextAiringEpisode)
resultNextAiringTime.setText(d.nextAiringDate)
resultPoster.loadImage(d.posterImage, headers = d.posterHeaders)
@ -931,7 +932,6 @@ class ResultFragmentTv : BaseFragment<FragmentResultTvBinding>(
true
)
resultCastText.setText(if (showCast) d.actorsText else null)
resultCastItems.isGone = !showCast || d.actors.isNullOrEmpty()
(resultCastItems.adapter as? ActorAdaptor)?.submitList(if (showCast) d.actors else emptyList())

View file

@ -149,7 +149,6 @@ class SearchFragment : BaseFragment<FragmentSearchBinding>(
override fun onResume() {
super.onResume()
searchViewModel.clearSuggestions()
afterPluginsLoadedEvent += ::reloadRepos
}
@ -168,7 +167,6 @@ class SearchFragment : BaseFragment<FragmentSearchBinding>(
**/
fun search(query: String?) {
if (query == null) return
searchViewModel.clearSuggestions()
// don't resume state from prev search
(binding?.searchMasterRecycler?.adapter as? BaseAdapter<*, *>)?.clearState()
context?.let { ctx ->

View file

@ -1,220 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import android.annotation.SuppressLint
import android.app.Activity
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.pm.PackageInstaller
import android.os.Build
import androidx.core.content.FileProvider
import com.lagradost.cloudstream3.BuildConfig
import com.lagradost.cloudstream3.CommonActivity
import com.lagradost.cloudstream3.ErrorLoadingException
import com.lagradost.cloudstream3.MainActivity.Companion.deleteFileOnExit
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.mvvm.safe
import com.lagradost.cloudstream3.receivers.PackageInstallerStatusReceiver
import com.lagradost.cloudstream4.AppSettings
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.currentCoroutineContext
import kotlinx.coroutines.ensureActive
import kotlinx.coroutines.withContext
import java.io.File
import java.io.InputStream
import java.io.OutputStream
import java.security.DigestException
import java.security.MessageDigest
object ApkUpdater : AppUpdater {
private const val APP_UPDATE_NAME = "CloudStream"
private const val APP_UPDATE_SUFFIX = "apk"
@Throws
override suspend fun update(
settings: AppSettings,
url: String,
digest: DigestPair?,
downloadProgress: (Long, Long?) -> Unit
) {
val activity = CommonActivity.activity ?: throw ErrorLoadingException("No activity found")
clearOldFiles(activity)
val request = app.get(url)
val length = request.size
val body = request.body
body.use { body ->
val length = length ?: body.contentLength()
val readStream = body.byteStream()
when (settings.updates.apkInstaller.get()) {
0 -> {
packageInstallerDownloader(
activity,
readStream,
length,
digest,
downloadProgress
)
}
else -> {
legacyDownloader(activity, readStream, length, digest, downloadProgress)
}
}
}
}
fun clearOldFiles(activity: Activity) {
// Delete old files
activity.cacheDir.listFiles()?.filter {
it.name.startsWith(APP_UPDATE_NAME) && it.extension == APP_UPDATE_SUFFIX
}?.forEach {
deleteFileOnExit(it)
}
}
/** https://medium.com/@solrudev/painless-building-of-an-android-package-installer-app-d5a09b5df432 */
@SuppressLint("RequestInstallPackagesPolicy")
@Throws
suspend fun packageInstallerDownloader(
activity: Activity,
readStream: InputStream,
length: Long?,
digest: DigestPair?,
downloadProgress: (Long, Long?) -> Unit,
) = withContext(Dispatchers.IO) {
var sessionId: Int? = null
val packageInstaller = activity.packageManager.packageInstaller
try {
val installParams =
PackageInstaller.SessionParams(PackageInstaller.SessionParams.MODE_FULL_INSTALL)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
installParams.setRequireUserAction(PackageInstaller.SessionParams.USER_ACTION_NOT_REQUIRED)
}
if (length != null) {
installParams.setSize(length)
}
sessionId = packageInstaller.createSession(installParams)
val session = packageInstaller.openSession(sessionId)
// We do not need to buffer this because transfer has large writes
session.openWrite(activity.packageName, 0, length ?: -1L)
.use { writeStream ->
transfer(writeStream, readStream, length, downloadProgress, digest)
session.fsync(writeStream)
}
val receiverIntent = Intent(activity, PackageInstallerStatusReceiver::class.java)
val flags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
} else {
PendingIntent.FLAG_UPDATE_CURRENT
}
val receiverPendingIntent =
PendingIntent.getBroadcast(activity, 0, receiverIntent, flags)
// Avoid delayed updates, and just commit instantly
session.commit(receiverPendingIntent.intentSender)
session.close()
} catch (t: Throwable) {
sessionId?.let { sessionId ->
packageInstaller.abandonSession(sessionId)
}
throw t
}
}
/**
* Write the "readStream" to the "writeStream", while notifying the "downloadProgress" and
* calculating the digest
*
* ------------------------------------------------------------------------------------------
*
* throws a DigestException if the Digest can be calculated (non-null + correct algorithm),
* and is mismatched
*
* throws a CancellationException if canceled, but may not be "instant" if the read is blocking
*
* throws IOException and similar for reading
*
* ------------------------------------------------------------------------------------------
*
* In case of crashes from the digest, we ignore it as we do not want to "block" someone from
* updating if they got a broken OS without the desired algorithm or implementation.
*
* This is because a malicious CDN should not be able to "crash" the algorithm, but a broken
* OS will. And recovering from a broken OS by ignoring it is better than refusing it.
* */
@Throws
suspend fun transfer(
writeStream: OutputStream,
readStream: InputStream,
length: Long?,
downloadProgress: (Long, Long?) -> Unit,
digest: DigestPair?,
) = withContext(Dispatchers.IO) {
val md = digest?.algorithm?.let { digestAlgorithm ->
safe {
MessageDigest.getInstance(digestAlgorithm)
}
}
val context = currentCoroutineContext()
val buffer = ByteArray(DEFAULT_BUFFER_SIZE)
var read: Int
var transferred: Long = 0
while ((readStream.read(buffer, 0, DEFAULT_BUFFER_SIZE)
.also { read = it }) >= 0
) {
writeStream.write(buffer, 0, read)
safe {
md?.update(buffer, 0, read)
}
transferred += read.toLong()
downloadProgress(transferred, length)
context.ensureActive()
}
writeStream.flush()
val check = safe { md?.digest() }
if (check != null && !check.contentEquals(digest?.digest)) {
throw DigestException("Mismatched digest on transfer ${digest?.algorithm} : ${check.toHexString()} / ${digest?.digest?.toHexString()}")
}
}
@Throws
suspend fun legacyDownloader(
activity: Activity,
readStream: InputStream,
length: Long?,
digest: DigestPair?,
downloadProgress: (Long, Long?) -> Unit
) = withContext(Dispatchers.IO) {
val downloadedFile = File.createTempFile(APP_UPDATE_NAME, ".$APP_UPDATE_SUFFIX")
// We do not need to buffer this because transfer has large writes
downloadedFile.outputStream().use { writeStream ->
transfer(writeStream, readStream, length, downloadProgress, digest)
}
openApk(activity, downloadedFile)
}
fun openApk(context: Context, file: File) {
val contentUri = FileProvider.getUriForFile(
context, BuildConfig.APPLICATION_ID + ".provider", file
)
val installIntent = Intent(Intent.ACTION_VIEW).apply {
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true)
data = contentUri
}
context.startActivity(installIntent)
}
}

View file

@ -1,117 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import androidx.compose.runtime.Immutable
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.app
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlin.jvm.Throws
object GithubReleases {
@Serializable
private data class GithubAsset(
@JsonProperty("name") @SerialName("name") val name: String,
@JsonProperty("size") @SerialName("size") val size: Int, // Size in bytes
@JsonProperty("browser_download_url") @SerialName("browser_download_url") val browserDownloadUrl: String,
@JsonProperty("content_type") @SerialName("content_type") val contentType: String, // application/vnd.android.package-archive
@JsonProperty("digest") @SerialName("digest") val digest: String? = null, // sha256:..., may be null
)
@Serializable
private data class GithubRelease(
@JsonProperty("tag_name") @SerialName("tag_name") val tagName: String, // Version code
@JsonProperty("body") @SerialName("body") val body: String, // Description
@JsonProperty("assets") @SerialName("assets") val assets: List<GithubAsset>,
@JsonProperty("target_commitish") @SerialName("target_commitish") val targetCommitish: String, // Branch
@JsonProperty("prerelease") @SerialName("prerelease") val prerelease: Boolean,
@JsonProperty("node_id") @SerialName("node_id") val nodeId: String,
@JsonProperty("created_at") @SerialName("created_at") val createdAt: String, // YYYY-MM-DDTHH:MM:SSZ
)
@Serializable
private data class GithubObject(
@JsonProperty("sha") @SerialName("sha") val sha: String, // SHA-256 hash
//@JsonProperty("type") @SerialName("type") val type: String,
///@JsonProperty("url") @SerialName("url") val url: String,
)
@Serializable
private data class GithubTag(
//@JsonProperty("node_id") @SerialName("node_id") val nodeId: String,
@JsonProperty("object") @SerialName("object") val githubObject: GithubObject,
)
/** GitHub file update package */
@Immutable
data class GithubFile(
/** File digest, sha:xxx */
val digest: String?,
/** File url for download */
val downloadUrl: String,
/** Filename without the extension */
val displayName: String,
/** Changelog, aka the commit message */
val changeLog: String,
/** Name of the tag, aka unique release name like vX.X.X or pre-release */
val tagName: String,
/** Unique node id */
val nodeId: String,
)
private val defaultHeaders = mapOf("Accept" to "application/vnd.github.v3+json")
@Throws
suspend fun getShaFromTag(
userName: String,
repository: String,
tag: String,
): String {
return app.get(
url = "https://api.github.com/repos/$userName/$repository/git/ref/tags/$tag",
headers = defaultHeaders
).parsed<GithubTag>().githubObject.sha
}
@Throws
suspend fun getLatestReleaseFile(
userName: String,
repository: String,
prerelease: Boolean,
prereleaseTag: String,
contentType: String,
): GithubFile? {
val latestReleaseUrl = if (prerelease) {
// Find the release object
// https://docs.github.com/en/rest/releases/releases?apiVersion=2026-03-10#get-a-release-by-tag-name
"https://api.github.com/repos/$userName/$repository/releases/tags/$prereleaseTag"
} else {
// Just get the latest release
// https://docs.github.com/en/rest/releases/releases?apiVersion=2026-03-10#get-the-latest-release
// The latest release is the most recent non-prerelease, non-draft release, sorted by the created_at attribute
"https://api.github.com/repos/$userName/$repository/releases/latest"
}
val latestRelease = app.get(
url = latestReleaseUrl,
headers = defaultHeaders
).parsed<GithubRelease>()
// Find the first correct asset, given that we might have other binaries we release in the same version
val foundAsset = latestRelease.assets.firstOrNull { asset ->
asset.contentType == contentType
}
if (foundAsset == null) {
return null
}
return GithubFile(
digest = foundAsset.digest,
downloadUrl = foundAsset.browserDownloadUrl,
displayName = foundAsset.name.substringBeforeLast("."),
changeLog = latestRelease.body,
tagName = latestRelease.tagName,
nodeId = latestRelease.nodeId
)
}
}

View file

@ -1,299 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import androidx.compose.runtime.Immutable
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.lagradost.cloudstream3.mvvm.safe
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
import com.lagradost.cloudstream4.AppSettings
import com.lagradost.cloudstream4.compose.ActionHandler
import com.lagradost.cloudstream4.compose.DefaultStateContainer
import com.lagradost.cloudstream4.compose.SingleActiveQuery
import com.lagradost.cloudstream4.compose.StateContainer
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import java.io.FileNotFoundException
@Immutable
data class GithubState(
val dialog: GithubDialog? = null,
)
@Immutable
sealed class GithubUpdateDialogState {
data class Error(val error: Throwable) : GithubUpdateDialogState()
data class DownloadProgress(val progress: Long, val total: Long?) : GithubUpdateDialogState()
object Loading : GithubUpdateDialogState()
object NoUpdateFound : GithubUpdateDialogState()
data class UpdateFound(
val file: GithubReleases.GithubFile,
val newSha: String?,
val oldSha: String?,
) : GithubUpdateDialogState()
}
@Immutable
data class GithubDialog(
val isPrerelease: Boolean,
val isFromUser: Boolean,
val state: GithubUpdateDialogState,
)
@Immutable
sealed class GithubAction {
object AutoSearchForUpdate : GithubAction()
object SearchForUpdate : GithubAction()
object Dismiss : GithubAction()
data class SkipThisUpdate(val file: GithubReleases.GithubFile) : GithubAction()
data class Update(val file: GithubReleases.GithubFile) : GithubAction()
data class SkipUpdate(val file: GithubReleases.GithubFile) : GithubAction()
}
const val APK_USERNAME = "recloudstream"
const val APK_REPOSITORY = "cloudstream"
const val APK_PRERELEASE = "pre-release"
const val APK_CONTENT_TYPE = "application/vnd.android.package-archive"
interface AppUpdater {
@Throws
suspend fun update(
settings: AppSettings,
url: String,
digest: DigestPair?,
downloadProgress: (Long, Long?) -> Unit,
)
}
/** The digest pair to verify that a file is correctly downloaded */
data class DigestPair(
val algorithm : String,
val digest : ByteArray,
) {
companion object {
// "sha256:XXXX" or "sha256-XXXX" -> "sha256", bytearray(XXXX)
fun parse(digestPair: String?) : DigestPair? {
if(digestPair == null) return null
var split = digestPair.split(":", limit = 2)
if(split.size != 2) {
split = digestPair.split("-", limit = 2)
}
if(split.size != 2) {
return null
}
val digestAlgorithm = split.getOrNull(0) ?: return null
val digestByteArray = safe { split.getOrNull(1)?.hexToByteArray() } ?: return null
return DigestPair(digestAlgorithm, digestByteArray)
}
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
val other = other as? DigestPair ?: return false
if (algorithm != other.algorithm) return false
if (!digest.contentEquals(other.digest)) return false
return true
}
override fun hashCode(): Int {
var result = algorithm.hashCode()
result = 31 * result + digest.contentHashCode()
return result
}
}
/**
* Cross-platform downloader for updates served by GitHub.
*
* To allow this Cross-platform behavior work we split up the UI from the Viewmodel,
* and the Viewmodel from the installer.
* ```
* UI: Renders the current viewmodel state
* Viewmodel: Searches for updates on GitHub
* AppUpdater: Installs the update from the raw GitHub url
*
* UI -(onAction)-> Viewmodel -(invokes)-> AppUpdater
* <---(state)---/ <--(callback)--/
* ```
* */
class GithubViewModel(
val remoteUserName: String,
val remoteRepository: String,
val remotePrereleaseTag: String,
val remoteContentType: String,
val versionName: String,
val isPrerelease: Boolean,
val isDebug: Boolean,
val buildSha: String,
val settings: AppSettings,
val updater: AppUpdater,
) : ViewModel(), StateContainer<GithubState> by DefaultStateContainer(GithubState()),
ActionHandler<GithubAction> {
private val updateDispatcher = SingleActiveQuery(Dispatchers.IO)
override fun onAction(action: GithubAction) {
when (action) {
GithubAction.SearchForUpdate -> {
ioSafe {
searchForUpdate(prerelease = isPrerelease, fromUser = true)
}
}
GithubAction.Dismiss -> {
viewModelScope.launch {
updateDispatcher.cancel()
updateState { copy(dialog = null) }
}
}
is GithubAction.SkipThisUpdate -> {
settings.updates.skipUpdate.set(action.file.nodeId)
}
GithubAction.AutoSearchForUpdate -> {
if (!isDebug && settings.updates.showAppUpdates.get()) {
ioSafe {
searchForUpdate(prerelease = isPrerelease, fromUser = false)
}
}
}
is GithubAction.SkipUpdate -> {
settings.updates.skipUpdate.set(action.file.nodeId)
}
is GithubAction.Update -> {
ioSafe {
installUpdate(action.file.downloadUrl, action.file.digest)
}
}
}
}
/** Cancel the old update, and catch possible errors from the block and show as a new state */
private suspend fun dispatchUpdate(block: /* @Throws */ suspend () -> Unit) {
updateDispatcher.launch {
try {
block()
} catch (t: Throwable) {
// If it was canceled ignore it as we probably launched another update check
if (!isActive) {
return@launch
}
// Otherwise we display the error
updateState {
copy(dialog = dialog?.copy(state = GithubUpdateDialogState.Error(t)))
}
}
}
}
private suspend fun installUpdate(url: String, digestPair: String?) = dispatchUpdate {
updater.update(
settings = settings,
url = url,
digest = DigestPair.parse(digestPair),
) { progress, total ->
updateState {
copy(
dialog = dialog?.copy(
state = GithubUpdateDialogState.DownloadProgress(
progress = progress,
total = total
)
)
)
}
}
updateState {
copy(
dialog = null
)
}
}
private suspend fun searchForUpdate(
prerelease: Boolean,
fromUser: Boolean,
) = dispatchUpdate {
val baseDialog = GithubDialog(
isPrerelease = prerelease,
isFromUser = fromUser,
state = GithubUpdateDialogState.Loading
)
updateState {
copy(dialog = baseDialog)
}
// If on pre-release check if the sha matches, as we do not look at the version
var oldSha: String? = null
var newSha: String? = null
if (prerelease) {
val sha = getSha(remotePrereleaseTag)
oldSha = buildSha.take(7)
newSha = sha.take(7)
// Only match the first 7 chars, as that is what is saved
if (oldSha == newSha) {
updateState {
copy(dialog = baseDialog.copy(state = GithubUpdateDialogState.NoUpdateFound))
}
return@dispatchUpdate
}
}
val release = getRelease(prerelease)
// If on stable, only check that the display name matches
if (!prerelease && release.displayName == versionName) {
updateState {
copy(dialog = baseDialog.copy(state = GithubUpdateDialogState.NoUpdateFound))
}
return@dispatchUpdate
}
// If this was automated, and we have pressed "skip this update" then check the node-id
if (!fromUser && release.nodeId == settings.updates.skipUpdate.get()) {
updateState {
copy(dialog = baseDialog.copy(state = GithubUpdateDialogState.NoUpdateFound))
}
return@dispatchUpdate
}
updateState {
copy(
dialog = baseDialog.copy(
state = GithubUpdateDialogState.UpdateFound(
file = release,
newSha = newSha,
oldSha = oldSha
)
)
)
}
}
@Throws
private suspend fun getRelease(prerelease: Boolean) =
GithubReleases.getLatestReleaseFile(
prerelease = prerelease,
userName = remoteUserName,
repository = remoteRepository,
prereleaseTag = remotePrereleaseTag,
contentType = remoteContentType
) ?: throw FileNotFoundException()
@Throws
private suspend fun getSha(tag: String) =
GithubReleases.getShaFromTag(
tag = tag,
userName = remoteUserName,
repository = remoteRepository,
)
}

View file

@ -1,18 +1,19 @@
package com.lagradost.cloudstream3.ui.settings
import android.app.UiModeManager
import android.content.Context
import android.content.res.Configuration
import android.content.res.Resources
import android.os.Build
import androidx.preference.PreferenceManager
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream4.compose.DeviceLayout.Companion.isAutoTv
object Globals {
var beneneCount = 0
const val PHONE: Int = 0b00001
const val TV: Int = 0b00010
const val EMULATOR: Int = 0b00100
const val PHONE : Int = 0b001
const val TV : Int = 0b010
const val EMULATOR : Int = 0b100
private const val INVALID = -1
private var layoutId = INVALID
@ -21,9 +22,18 @@ object Globals {
return settingsManager.getInt(this.getString(R.string.app_layout_key), -1)
}
fun Context.updateTv() {
layoutId = when (getLayoutInt()) {
-1 -> if (isAutoTv(this)) TV else PHONE
private fun Context.isAutoTv(): Boolean {
val uiModeManager = getSystemService(Context.UI_MODE_SERVICE) as UiModeManager?
// AFT = Fire TV
val model = Build.MODEL.lowercase()
return uiModeManager?.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION || Build.MODEL.contains(
"AFT"
) || model.contains("firestick") || model.contains("fire tv") || model.contains("chromecast")
}
private fun Context.layoutIntCorrected(): Int {
return when(getLayoutInt()) {
-1 -> if (isAutoTv()) TV else PHONE
0 -> PHONE
1 -> TV
2 -> EMULATOR
@ -31,10 +41,14 @@ object Globals {
}
}
fun Context.updateTv() {
layoutId = layoutIntCorrected()
}
/** Returns true if the current orientation is landscape. */
fun isLandscape(): Boolean =
isLayout(TV or EMULATOR) ||
Resources.getSystem().configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
Resources.getSystem().configuration.orientation == Configuration.ORIENTATION_LANDSCAPE
/** Returns true if the layout is any of the flags,
* so isLayout(TV or EMULATOR) is a valid statement for checking if the layout is in the emulator
@ -42,7 +56,7 @@ object Globals {
*
* Valid flags are: PHONE, TV, EMULATOR
* */
fun isLayout(flags: Int): Boolean {
fun isLayout(flags: Int) : Boolean {
return (layoutId and flags) != 0
}
}

View file

@ -1,7 +1,6 @@
package com.lagradost.cloudstream3.ui.settings
import android.annotation.SuppressLint
import android.app.Activity
import android.graphics.Bitmap
import android.os.Bundle
import android.os.CountDownTimer
@ -14,6 +13,7 @@ import androidx.appcompat.app.AlertDialog
import androidx.core.content.edit
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.fragment.app.FragmentActivity
import androidx.preference.PreferenceManager
import androidx.preference.SwitchPreference
import androidx.recyclerview.widget.RecyclerView
@ -29,8 +29,8 @@ import com.lagradost.cloudstream3.databinding.DeviceAuthBinding
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.aniListApi
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.animeSkipApi
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.kitsuApi
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.malApi
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.kitsuApi
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.openSubtitlesApi
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.simklApi
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.subDlApi
@ -42,8 +42,8 @@ import com.lagradost.cloudstream3.syncproviders.SubtitleRepo
import com.lagradost.cloudstream3.syncproviders.SyncRepo
import com.lagradost.cloudstream3.ui.BasePreferenceFragmentCompat
import com.lagradost.cloudstream3.ui.settings.Globals.EMULATOR
import com.lagradost.cloudstream3.ui.settings.Globals.PHONE
import com.lagradost.cloudstream3.ui.settings.Globals.TV
import com.lagradost.cloudstream3.ui.settings.Globals.PHONE
import com.lagradost.cloudstream3.ui.settings.Globals.isLayout
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.hideOn
@ -76,7 +76,7 @@ class SettingsAccount : BasePreferenceFragmentCompat(), BiometricCallback {
/** Used by nginx plugin too */
@SuppressLint("StringFormatInvalid")
fun showLoginInfo(
activity: Activity?,
activity: FragmentActivity?,
api: AuthRepo,
info: AuthUser?,
index: Int,
@ -121,7 +121,7 @@ class SettingsAccount : BasePreferenceFragmentCompat(), BiometricCallback {
}
}
private fun showAccountSwitch(activity: Activity, api: AuthRepo) {
private fun showAccountSwitch(activity: FragmentActivity, api: AuthRepo) {
val accounts = api.accounts
val binding: AccountSwitchBinding =
AccountSwitchBinding.inflate(activity.layoutInflater, null, false)
@ -153,7 +153,7 @@ class SettingsAccount : BasePreferenceFragmentCompat(), BiometricCallback {
@UiThread
fun showPin(activity: Activity, api: AuthRepo) {
fun showPin(activity: FragmentActivity, api: AuthRepo) {
val binding: DeviceAuthBinding =
DeviceAuthBinding.inflate(activity.layoutInflater, null, false)
@ -273,7 +273,8 @@ class SettingsAccount : BasePreferenceFragmentCompat(), BiometricCallback {
}
fun showAppLogin(activity: Activity, api: AuthRepo) {
fun showAppLogin(activity: FragmentActivity, api: AuthRepo) {
val binding: AddAccountInputBinding =
AddAccountInputBinding.inflate(activity.layoutInflater, null, false)
val builder =
@ -314,7 +315,7 @@ class SettingsAccount : BasePreferenceFragmentCompat(), BiometricCallback {
binding.createAccount.setOnClickListener {
openBrowser(
api.createAccountUrl ?: return@setOnClickListener,
activity,
activity
)
dialog.dismissSafe()
}
@ -390,7 +391,7 @@ class SettingsAccount : BasePreferenceFragmentCompat(), BiometricCallback {
}
@UiThread
fun addAccount(activity: Activity, api: AuthRepo) {
fun addAccount(activity: FragmentActivity, api: AuthRepo) {
try {
if (api.hasPin && !isLayout(PHONE)) {
showPin(activity, api)

View file

@ -1,7 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import com.lagradost.cloudstream3.utils.BaseComposeFragment
import com.mihon.presentation.settings.SearchableSettings
/** Empty glue code to connect the old navigation graph to Compose */
class SettingsAccount2 : BaseComposeFragment(), SearchableSettings by SettingsAccountScreen

View file

@ -1,148 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import android.content.Context
import androidx.activity.compose.LocalActivity
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.fragment.app.FragmentActivity
import com.lagradost.cloudstream3.CommonActivity.activity
import com.lagradost.cloudstream3.CommonActivity.onDialogDismissedEvent
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.aniListApi
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.animeSkipApi
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.kitsuApi
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.malApi
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.openSubtitlesApi
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.simklApi
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.subDlApi
import com.lagradost.cloudstream3.syncproviders.PlainAuthRepo
import com.lagradost.cloudstream3.syncproviders.SubtitleRepo
import com.lagradost.cloudstream3.syncproviders.SyncRepo
import com.lagradost.cloudstream3.ui.settings.SettingsAccount.Companion.addAccount
import com.lagradost.cloudstream3.ui.settings.SettingsAccount.Companion.showLoginInfo
import com.lagradost.cloudstream3.utils.AppContextUtils.html
import com.lagradost.cloudstream3.utils.BackupUtils
import com.lagradost.cloudstream3.utils.BiometricAuthenticator
import com.lagradost.cloudstream3.utils.BiometricAuthenticator.authCallback
import com.lagradost.cloudstream3.utils.BiometricAuthenticator.biometricPrompt
import com.lagradost.cloudstream3.utils.BiometricAuthenticator.deviceHasPasswordPinLock
import com.lagradost.cloudstream3.utils.BiometricAuthenticator.isAuthEnabled
import com.lagradost.cloudstream3.utils.BiometricAuthenticator.promptInfo
import com.lagradost.cloudstream3.utils.BiometricAuthenticator.startBiometricAuthentication
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialogText
import com.lagradost.cloudstream4.AppSettings
import com.lagradost.cloudstream4.compose.PHONE
import com.lagradost.cloudstream4.compose.isLayout
import com.lagradost.cloudstream4.rememberAppSettings
import com.mihon.presentation.settings.Preference
import com.mihon.presentation.settings.SearchableSettings
import kotlinx.collections.immutable.persistentListOf
object SettingsAccountScreen : SearchableSettings, BiometricAuthenticator.BiometricCallback {
val syncApis = persistentListOf(
SyncRepo(malApi),
SyncRepo(kitsuApi),
SyncRepo(aniListApi),
SyncRepo(simklApi),
SubtitleRepo(openSubtitlesApi),
SubtitleRepo(subDlApi),
PlainAuthRepo(animeSkipApi),
)
private fun updateAuthPreference(context: Context, enabled: Boolean) {
val settings = AppSettings(context)
settings.security.biometrics.set(enabled)
}
override fun onAuthenticationError() {
val context = activity ?: return
updateAuthPreference(context, !isAuthEnabled(context))
}
override fun onAuthenticationSuccess() {
val context = activity ?: return
if (isAuthEnabled(context)) {
updateAuthPreference(context, true)
BackupUtils.backup(context)
context.showBottomDialogText(
context.getString(R.string.biometric_setting),
context.getString(R.string.biometric_warning).html()
) { onDialogDismissedEvent }
} else {
updateAuthPreference(context, false)
}
}
@Composable
override fun getTitleRes(): String = stringResource(R.string.category_account)
@Composable
override fun getPreferences(): List<Preference> {
val settings = rememberAppSettings()
val activity = LocalActivity.current
val context = LocalContext.current
val hasSecurity = remember(context) {
try {
deviceHasPasswordPinLock(context)
} catch (_ : Throwable) {
// e.g preview
false
}
}
return persistentListOf(
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_accounts),
preferenceItems = syncApis.map { api ->
Preference.PreferenceItem.TextPreference(
title = api.name,
icon = api.icon?.let { painterResource(it) },
onClick = {
val activity = activity ?: return@TextPreference
val info = api.authUser()
val index =
api.accounts.indexOfFirst { account -> account.user.id == info?.id }
if (api.accounts.isNotEmpty()) {
showLoginInfo(activity, api, info, index)
} else {
addAccount(activity, api)
}
})
} + Preference.PreferenceItem.SwitchPreference(
preference = settings.security.skipAccountSelection,
title = stringResource(R.string.skip_startup_account_select_pref),
icon = painterResource(R.drawable.ic_outline_account_circle_24)
),
), Preference.PreferenceGroup(
enabled = hasSecurity && isLayout(PHONE),
title = stringResource(R.string.pref_category_security),
preferenceItems = persistentListOf(
Preference.PreferenceItem.SwitchPreference(
preference = settings.security.biometrics,
title = stringResource(R.string.biometric_setting),
subtitle = stringResource(R.string.biometric_setting_summary),
icon = painterResource(R.drawable.ic_fingerprint),
onValueChanged = { _ ->
val activity =
activity as? FragmentActivity ?: return@SwitchPreference false
if (deviceHasPasswordPinLock(activity)) {
startBiometricAuthentication(
activity, R.string.biometric_authentication_title, false
)
promptInfo?.let {
authCallback = this
biometricPrompt?.authenticate(it)
}
}
return@SwitchPreference true
})
)
)
)
}
}

View file

@ -1,8 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import com.lagradost.cloudstream3.utils.BaseComposeFragment
import com.lagradost.cloudstream4.compose.Screen
/** Empty glue code to connect the old navigation graph to Compose */
class SettingsFragment2 : BaseComposeFragment(), Screen by SettingsFragmentScreen

View file

@ -1,444 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import android.annotation.SuppressLint
import android.os.Bundle
import androidx.compose.animation.Crossfade
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.text.input.TextFieldState
import androidx.compose.foundation.text.input.rememberTextFieldState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ProvideTextStyle
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.material3.rememberSearchBarState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.NonRestartableComposable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
import androidx.compose.ui.input.nestedscroll.NestedScrollSource
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.tooling.preview.PreviewLightDark
import androidx.compose.ui.unit.dp
import coil3.compose.AsyncImage
import com.lagradost.cloudstream3.BuildConfig
import com.lagradost.cloudstream3.CommonActivity.activity
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.utils.DataStoreHelper
import com.lagradost.cloudstream3.utils.DataStoreHelper.profileImages
import com.lagradost.cloudstream3.utils.GitInfo.currentCommitHash
import com.lagradost.cloudstream3.utils.UIHelper.clipboardHelper
import com.lagradost.cloudstream3.utils.UIHelper.navigate
import com.lagradost.cloudstream3.utils.txt
import com.lagradost.cloudstream4.compose.Screen
import com.lagradost.cloudstream4.compose.TV
import com.lagradost.cloudstream4.compose.circleBorder
import com.lagradost.cloudstream4.compose.focusOutline
import com.lagradost.cloudstream4.compose.isLayout
import com.lagradost.cloudstream4.theme.CloudStreamPreviewTheme
import com.mihon.material.padding
import com.mihon.presentation.settings.SearchableSettings
import com.mihon.presentation.settings.SettingSearchResults
import com.mihon.presentation.settings.SettingsData
import com.mihon.presentation.settings.widget.TextPreferenceWidget
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import java.util.TimeZone
object SettingsFragmentScreen : Screen {
val screens = persistentListOf(
SettingsNavigation(
title = R.string.category_general,
navigation = R.id.action_navigation_global_to_navigation_settings_general,
screen = SettingsGeneralScreen,
icon = R.drawable.build_24px,
subtitle = persistentListOf(
R.string.extension_language,
R.string.title_downloads,
R.string.pref_category_bypass,
R.string.pref_category_links
)
),
SettingsNavigation(
title = R.string.category_player,
navigation = R.id.action_navigation_global_to_navigation_settings_player,
screen = SettingsPlayerScreen,
icon = R.drawable.play_arrow_24px,
subtitle = persistentListOf(
R.string.pref_category_subtitles,
R.string.pref_category_player_features,
R.string.pref_category_gestures,
R.string.pref_category_player_layout,
R.string.pref_category_cache
)
),
/*SettingsNavigation(
title = R.string.category_providers,
navigation = R.id.action_navigation_global_to_navigation_settings_providers,
screen = SettingsProvidersScreen,
icon = R.drawable.build_24px,
),*/
SettingsNavigation(
title = R.string.category_ui,
navigation = R.id.action_navigation_global_to_navigation_settings_ui,
screen = SettingsUIScreen,
icon = R.drawable.format_paint_24px,
subtitle = persistentListOf(
R.string.pref_category_looks,
R.string.pref_category_ui_features,
R.string.search_poster_img_des,
R.string.poster_ui_settings
)
),
SettingsNavigation(
title = R.string.category_updates,
navigation = R.id.action_navigation_global_to_navigation_settings_updates,
screen = SettingsUpdatesScreen,
icon = R.drawable.mobile_arrow_down_24px,
subtitle = persistentListOf(
R.string.pref_category_app_updates,
R.string.pref_category_backup,
R.string.pref_category_extensions,
R.string.pref_category_actions
)
),
SettingsNavigation(
title = R.string.category_account,
navigation = R.id.action_navigation_global_to_navigation_settings_account,
screen = SettingsAccountScreen,
icon = R.drawable.encrypted_24px,
subtitle = persistentListOf(
R.string.pref_category_accounts,
R.string.pref_category_security
)
),
SettingsNavigation(
title = R.string.pref_category_extensions,
navigation = R.id.action_navigation_global_to_navigation_settings_extensions,
screen = null,
icon = R.drawable.extension_24px,
subtitle = persistentListOf(R.string.add_repository)
),
)
@Immutable
data class SettingsNavigation(
val title: Int,
val navigation: Int,
val screen: SearchableSettings?,
val icon: Int,
val subtitle: PersistentList<Int>,
)
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@SuppressLint("UnusedMaterial3ScaffoldPaddingParameter")
override fun Content() {
val textFieldState = rememberTextFieldState()
val outerListState = rememberScrollState()
val parentFirstScrollConnection = remember {
object : NestedScrollConnection {
override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {
val delta = available.y
return if (delta < 0 && outerListState.canScrollForward) {
val consumed = outerListState.dispatchRawDelta(-delta)
Offset(0f, -consumed)
} else {
Offset.Zero
}
}
}
}
Scaffold { _ ->
Column(modifier = Modifier.verticalScroll(outerListState)) {
Spacer(modifier = Modifier.height(MaterialTheme.padding.small))
val default = DataStoreHelper.getDefaultAccount(
LocalContext.current
)
val flow by DataStoreHelper.selectedAccountNumberFlow.collectAsState()
val account = remember(flow) {
DataStoreHelper.getCurrentAccount() ?: default
}
Row(
modifier = Modifier
.fillMaxSize()
.focusOutline()
.clickable {
activity.navigate(
R.id.accountSelectActivity,
Bundle().apply { putBoolean("isFromMainActivity", true) }
)
}
.padding(
vertical = MaterialTheme.padding.large,
horizontal = MaterialTheme.padding.medium
)
) {
val image =
account.customImage ?: profileImages.getOrNull(account.defaultImageIndex)
?: profileImages.first()
AsyncImage(
contentScale = ContentScale.Crop,
model = image,
modifier = Modifier.circleBorder(50.dp),
contentDescription = null,
)
Spacer(modifier = Modifier.width(MaterialTheme.padding.medium))
Column {
Text(
text = account.name,
style = MaterialTheme.typography.titleLarge,
)
Text(
text = stringResource(R.string.title_settings),
style = MaterialTheme.typography.bodyMedium,
)
}
}
Spacer(modifier = Modifier.height(MaterialTheme.padding.small))
SettingsSearch(textFieldState = textFieldState)
Spacer(modifier = Modifier.height(MaterialTheme.padding.small))
SettingSearchResults(
nestedScrollConnection = parentFirstScrollConnection,
searchKey = textFieldState.text.toString(),
deferredItems = ::generateSearchItems,
onItemClick = { item ->
SearchableSettings.highlightKey = item.highlightKey
activity?.navigate(item.navigation)
}, empty = {
Column(
modifier = Modifier
.nestedScroll(parentFirstScrollConnection)
) {
screens.forEach { settingsTab ->
SettingsTab(settingsTab)
}
BuildStamp()
}
})
}
}
}
@Composable
@NonRestartableComposable
fun generateSearchItems() =
screens.mapNotNull { item ->
val contents = item.screen?.getPreferences() ?: return@mapNotNull null
SettingsData(
title = stringResource(item.title),
navigation = item.navigation,
contents = contents
)
}.toPersistentList()
@OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterial3ExpressiveApi::class)
@Composable
fun SettingsSearch(textFieldState : TextFieldState) {
var hasFocus by remember { mutableStateOf(false) }
val focusProgress by animateFloatAsState(targetValue = if (hasFocus) 1.0f else 0.0f)
val focusManager = LocalFocusManager.current
val focusRequester = remember { FocusRequester() }
TextField(
state = textFieldState,
keyboardOptions = KeyboardOptions.Default.copy(
imeAction = ImeAction.Search,
// This option is bugged on compose, making it unable to open at all
// showKeyboardOnFocus = false
),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 24.dp - 12.dp * focusProgress)
.focusOutline(enabled = isLayout(TV), CircleShape)
.onFocusChanged { newFocus ->
hasFocus = newFocus.hasFocus
}.focusRequester(focusRequester),
placeholder = {
Text(text = stringResource(R.string.search_hint))
},
shape = CircleShape,
colors = TextFieldDefaults.colors(
focusedContainerColor = MaterialTheme.colorScheme.surfaceVariant,
unfocusedContainerColor = MaterialTheme.colorScheme.surfaceVariant,
unfocusedLeadingIconColor = MaterialTheme.colorScheme.onBackground,
unfocusedTrailingIconColor = MaterialTheme.colorScheme.onBackground,
focusedTrailingIconColor = MaterialTheme.colorScheme.onBackground,
focusedLeadingIconColor = MaterialTheme.colorScheme.onBackground,
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
focusedPlaceholderColor = MaterialTheme.colorScheme.onSurfaceVariant,
unfocusedPlaceholderColor = MaterialTheme.colorScheme.onSurfaceVariant,
cursorColor = MaterialTheme.colorScheme.onBackground,
),
leadingIcon = {
Crossfade(
targetState = hasFocus,
label = "leftsearch",
) { value ->
if (value) {
IconButton(onClick = {
textFieldState.edit { replace(0, length, "") }
focusManager.clearFocus()
}) {
Icon(
painter = painterResource(R.drawable.keyboard_arrow_left_24px),
contentDescription = null
)
}
} else {
IconButton(onClick = {
focusRequester.requestFocus()
}) {
Icon(
painter = painterResource(R.drawable.search_icon),
contentDescription = null
)
}
}
}
},
trailingIcon = {
Crossfade(
targetState = hasFocus,
label = "rightsearch",
) { value ->
if (value) {
IconButton(onClick = {
textFieldState.edit { replace(0, length, "") }
}) {
Icon(
painter = painterResource(R.drawable.close_24px),
contentDescription = null
)
}
}
}
},
)
val keyboardController = LocalSoftwareKeyboardController.current
DisposableEffect(Unit) {
onDispose {
keyboardController?.hide()
}
}
}
@Composable
fun SettingsTab(settingsTab: SettingsNavigation) {
TextPreferenceWidget(
title = stringResource(settingsTab.title),
icon = painterResource(settingsTab.icon),
// This can not be converted to joinToString due to stringResource being composable
subtitle =
@Suppress("SimplifiableCallChain")
settingsTab.subtitle.map { stringResource(it) }.joinToString(),
// Clear it if we have already set it but navigated back instantly
onPreferenceClick = {
SearchableSettings.highlightKey = null
activity?.navigate(settingsTab.navigation)
})
}
@Composable
fun BuildStamp() {
val (commitHash, buildTimestamp) = remember {
val commitHash = activity?.currentCommitHash() ?: ""
val buildTimestamp = SimpleDateFormat.getDateTimeInstance(
DateFormat.LONG, DateFormat.MEDIUM,
Locale.getDefault()
).apply {
timeZone = TimeZone.getTimeZone("UTC")
}.format(Date(BuildConfig.BUILD_DATE)).replace("UTC", "")
commitHash to buildTimestamp
}
Row(
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
.height(50.dp)
.focusOutline()
.clickable {
clipboardHelper(
txt(R.string.extension_version),
"${BuildConfig.VERSION_NAME} $commitHash $buildTimestamp"
)
},
) {
ProvideTextStyle(MaterialTheme.typography.bodyMedium) {
Text(text = BuildConfig.VERSION_NAME)
if (commitHash != "") {
Text("•")
Text(text = commitHash)
}
Text("•")
Text(text = buildTimestamp)
}
}
}
}
@PreviewLightDark
@Composable
fun Preview() {
CloudStreamPreviewTheme {
SettingsFragmentScreen.Content()
}
}

View file

@ -3,7 +3,6 @@ package com.lagradost.cloudstream3.ui.settings
import android.content.Context
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
@ -18,7 +17,6 @@ import com.lagradost.cloudstream3.CloudStreamApp
import com.lagradost.cloudstream3.CloudStreamApp.Companion.getKey
import com.lagradost.cloudstream3.CloudStreamApp.Companion.setKey
import com.lagradost.cloudstream3.CommonActivity
import com.lagradost.cloudstream3.CommonActivity.activity
import com.lagradost.cloudstream3.CommonActivity.showToast
import com.lagradost.cloudstream3.MainActivity
import com.lagradost.cloudstream3.R
@ -79,7 +77,6 @@ val appLanguages = arrayListOf(
Pair("Azərbaycan dili", "az"),
Pair("Bahasa Indonesia", "in"),
Pair("Bahasa Melayu", "ms"),
Pair("català", "ca"),
Pair("Deutsch", "de"),
Pair("English", "en"),
Pair("Español", "es"),
@ -100,7 +97,6 @@ val appLanguages = arrayListOf(
Pair("Português", "pt"),
Pair("Português (Brasil)", "pt-BR"),
Pair("Română", "ro"),
Pair("Shqip мова", "sq"),
Pair("Slovenčina", "sk"),
Pair("Soomaaliga", "so"),
Pair("Svenska", "sv"),
@ -110,7 +106,6 @@ val appLanguages = arrayListOf(
Pair("Wikang Filipino", "fil"),
Pair("Čeština", "cs"),
Pair("Ελληνικά", "el"),
Pair("беларуская мова", "be"),
Pair("български", "bg"),
Pair("македонски", "mk"),
Pair("русский", "ru"),
@ -130,7 +125,6 @@ val appLanguages = arrayListOf(
Pair("தமிழ்", "ta"),
Pair("ಕನ್ನಡ", "kn"),
Pair("മലയാളം", "ml"),
Pair("ພາສາລາວ", "lo"),
Pair("ဗမာစာ", "my"),
Pair("ትግርኛ", "ti"),
Pair("አማርኛ", "am"),
@ -178,96 +172,6 @@ class SettingsGeneral : BasePreferenceFragmentCompat() {
putString(context.getString(R.string.download_path_key_visual), visual)
}
}
fun getCurrent(): MutableList<CustomSite> {
return getKey<Array<CustomSite>>(USER_PROVIDER_API)?.toMutableList()
?: mutableListOf()
}
fun showAdd() {
val providers = allProviders.distinctBy { it::class }.sortedBy { it.name }
val context = activity
context?.showDialog(
providers.map { "${it.name} (${it.mainUrl})" },
-1,
context.getString(R.string.add_site_pref),
true,
{}) { selection ->
val provider = providers.getOrNull(selection) ?: return@showDialog
val binding : AddSiteInputBinding = AddSiteInputBinding.inflate(LayoutInflater.from(
context
),null,false)
val builder =
AlertDialog.Builder(context, R.style.AlertDialogCustom)
.setView(binding.root)
val dialog = builder.create()
dialog.show()
binding.text2.text = provider.name
binding.applyBtt.setOnClickListener {
val name = binding.siteNameInput.text?.toString()
val url = binding.siteUrlInput.text?.toString()
val lang = binding.siteLangInput.text?.toString()
val realLang = if (lang.isNullOrBlank()) provider.lang else lang
val simpleName = provider::class.simpleName
if (url.isNullOrBlank() || name.isNullOrBlank() || simpleName == null) {
showToast(R.string.error_invalid_data, Toast.LENGTH_SHORT)
return@setOnClickListener
}
val current = getCurrent()
val newSite = CustomSite(simpleName, name, url, realLang)
current.add(newSite)
setKey(USER_PROVIDER_API, current.toTypedArray())
// reload apis
MainActivity.afterPluginsLoadedEvent.invoke(false)
dialog.dismissSafe(activity)
}
binding.cancelBtt.setOnClickListener {
dialog.dismissSafe(activity)
}
}
}
fun showDelete() {
val current = getCurrent()
val context = activity
context?.showMultiDialog(
current.map { it.name },
listOf(),
context.getString(R.string.remove_site_pref),
{}) { indexes ->
current.removeAll(indexes.map { current[it] })
setKey(USER_PROVIDER_API, current.toTypedArray())
}
}
fun showAddOrDelete() {
val context = activity
val binding : AddRemoveSitesBinding = AddRemoveSitesBinding.inflate(
LayoutInflater.from(
context
),null,false)
val builder =
AlertDialog.Builder(context ?: return, R.style.AlertDialogCustom)
.setView(binding.root)
val dialog = builder.create()
dialog.show()
binding.addSite.setOnClickListener {
showAdd()
dialog.dismissSafe(activity)
}
binding.removeSite.setOnClickListener {
showDelete()
dialog.dismissSafe(activity)
}
}
}
private val pathPicker = getChooseFolderLauncher { uri, path ->
@ -279,6 +183,10 @@ class SettingsGeneral : BasePreferenceFragmentCompat() {
setPreferencesFromResource(R.xml.settings_general, rootKey)
val settingsManager = PreferenceManager.getDefaultSharedPreferences(requireContext())
fun getCurrent(): MutableList<CustomSite> {
return getKey<Array<CustomSite>>(USER_PROVIDER_API)?.toMutableList()
?: mutableListOf()
}
getPref(R.string.locale_key)?.setOnPreferenceClickListener { pref ->
val current = getCurrentLocale(pref.context)
@ -315,7 +223,83 @@ class SettingsGeneral : BasePreferenceFragmentCompat() {
true
}
fun showAdd() {
val providers = allProviders.distinctBy { it::class }.sortedBy { it.name }
activity?.showDialog(
providers.map { "${it.name} (${it.mainUrl})" },
-1,
context?.getString(R.string.add_site_pref) ?: return,
true,
{}) { selection ->
val provider = providers.getOrNull(selection) ?: return@showDialog
val binding : AddSiteInputBinding = AddSiteInputBinding.inflate(layoutInflater,null,false)
val builder =
AlertDialog.Builder(context ?: return@showDialog, R.style.AlertDialogCustom)
.setView(binding.root)
val dialog = builder.create()
dialog.show()
binding.text2.text = provider.name
binding.applyBtt.setOnClickListener {
val name = binding.siteNameInput.text?.toString()
val url = binding.siteUrlInput.text?.toString()
val lang = binding.siteLangInput.text?.toString()
val realLang = if (lang.isNullOrBlank()) provider.lang else lang
val simpleName = provider::class.simpleName
if (url.isNullOrBlank() || name.isNullOrBlank() || simpleName == null) {
showToast(R.string.error_invalid_data, Toast.LENGTH_SHORT)
return@setOnClickListener
}
val current = getCurrent()
val newSite = CustomSite(simpleName, name, url, realLang)
current.add(newSite)
setKey(USER_PROVIDER_API, current.toTypedArray())
// reload apis
MainActivity.afterPluginsLoadedEvent.invoke(false)
dialog.dismissSafe(activity)
}
binding.cancelBtt.setOnClickListener {
dialog.dismissSafe(activity)
}
}
}
fun showDelete() {
val current = getCurrent()
activity?.showMultiDialog(
current.map { it.name },
listOf(),
context?.getString(R.string.remove_site_pref) ?: return,
{}) { indexes ->
current.removeAll(indexes.map { current[it] })
setKey(USER_PROVIDER_API, current.toTypedArray())
}
}
fun showAddOrDelete() {
val binding : AddRemoveSitesBinding = AddRemoveSitesBinding.inflate(layoutInflater,null,false)
val builder =
AlertDialog.Builder(context ?: return, R.style.AlertDialogCustom)
.setView(binding.root)
val dialog = builder.create()
dialog.show()
binding.addSite.setOnClickListener {
showAdd()
dialog.dismissSafe(activity)
}
binding.removeSite.setOnClickListener {
showDelete()
dialog.dismissSafe(activity)
}
}
getPref(R.string.override_site_key)?.setOnPreferenceClickListener { _ ->
@ -342,7 +326,7 @@ class SettingsGeneral : BasePreferenceFragmentCompat() {
val prefValues = resources.getIntArray(R.array.dns_pref_values)
val currentDns =
settingsManager.getInt(getString(R.string.dns_key), 0)
settingsManager.getInt(getString(R.string.dns_pref), 0)
activity?.showBottomDialog(
prefNames.toList(),
@ -350,7 +334,7 @@ class SettingsGeneral : BasePreferenceFragmentCompat() {
getString(R.string.dns_pref),
true,
{}) {
settingsManager.edit { putInt(getString(R.string.dns_key), prefValues[it]) }
settingsManager.edit { putInt(getString(R.string.dns_pref), prefValues[it]) }
(context ?: CloudStreamApp.context)?.let { ctx -> app.initClient(ctx) }
}
return@setOnPreferenceClickListener true
@ -368,7 +352,7 @@ class SettingsGeneral : BasePreferenceFragmentCompat() {
(first +
ctx.getExternalFilesDirs("").mapNotNull { it.path } +
currentDir)
} catch (_: Exception) {
} catch (e: Exception) {
first
}).filterNotNull().distinct()
}

View file

@ -1,7 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import com.lagradost.cloudstream3.utils.BaseComposeFragment
import com.mihon.presentation.settings.SearchableSettings
/** Empty glue code to connect the old navigation graph to Compose */
class SettingsGeneral2 : BaseComposeFragment(), SearchableSettings by SettingsGeneralScreen

View file

@ -1,304 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import android.content.Intent
import android.net.Uri
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.integerArrayResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringArrayResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.PreviewLightDark
import com.lagradost.cloudstream3.APIHolder
import com.lagradost.cloudstream3.AllLanguagesName
import com.lagradost.cloudstream3.CloudStreamApp
import com.lagradost.cloudstream3.CommonActivity.activity
import com.lagradost.cloudstream3.CommonActivity.showToast
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.TvType
import com.lagradost.cloudstream3.UnsafeSSL
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.insecureApp
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.network.initClient
import com.lagradost.cloudstream3.ui.settings.SettingsProvidersScreen.toStringRes
import com.lagradost.cloudstream3.utils.BatteryOptimizationChecker.isAppRestricted
import com.lagradost.cloudstream3.utils.BatteryOptimizationChecker.showRequestIgnoreBatteryOptDialog
import com.lagradost.cloudstream3.utils.SubtitleHelper.fromTagToLanguageName
import com.lagradost.cloudstream3.utils.SubtitleHelper.getNameNextToFlagEmoji
import com.lagradost.cloudstream4.AppSettings
import com.lagradost.cloudstream4.compose.ActionDialog
import com.lagradost.cloudstream4.compose.PHONE
import com.lagradost.cloudstream4.compose.isLayout
import com.lagradost.cloudstream4.rememberAppSettings
import com.lagradost.cloudstream4.theme.CloudStreamPreviewTheme
import com.lagradost.safefile.SafeFile
import com.mihon.presentation.settings.Preference
import com.mihon.presentation.settings.SearchableSettings
import com.mihon.presentation.settings.collectAsState
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentMap
object SettingsGeneralScreen : SearchableSettings {
@Composable
override fun getTitleRes(): String = stringResource(R.string.category_general)
@Composable
override fun getPreferences(): List<Preference> {
val settings = rememberAppSettings()
// TODO Refactor entirely to use a different file path selector ect like QuickNovel
val selectFileSelector =
rememberLauncherForActivityResult(ActivityResultContracts.OpenDocumentTree()) { uri ->
// It lies, it can be null if file manager quits.
if (uri == null) return@rememberLauncherForActivityResult
val context = CloudStreamApp.context ?: return@rememberLauncherForActivityResult
try {
val settings = AppSettings(context)
// RW perms for the path
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
context.contentResolver.takePersistableUriPermission(uri, flags)
val filePath = SafeFile.fromUri(context, uri)?.filePath()
println("Selected URI path: $uri - Full path: $filePath")
// store the actual URI instead of the path due to permissions.
// filePath should only be used for cosmetic purposes.
val visual = filePath ?: uri.toString()
settings.general.downloadPath.set(uri.toString())
settings.general.downloadPathVisual.set(visual)
} catch (t: Throwable) {
logError(t)
}
}
val bananas by settings.general.bananas.collectAsState()
val downloadPathVisual by settings.general.downloadPathVisual.collectAsState()
//val downloadPath by settings.general.downloadPath.collectAsState()
var isBatteryShown by remember { mutableStateOf(false) }
val context = LocalContext.current
if (isBatteryShown) {
ActionDialog(
icon = painterResource(R.drawable.battery_alert_24px),
title = stringResource(R.string.battery_dialog_title),
text = stringResource(R.string.battery_dialog_message),
confirmText = stringResource(R.string.ok),
dismissText = stringResource(R.string.cancel),
dismiss = {
isBatteryShown = false
settings.general.batterOptimization.set(false)
},
confirm = {
isBatteryShown = false
// The og impl never modified it to true?
// settings.general.batterOptimization.set(true)
context.showRequestIgnoreBatteryOptDialog()
}
)
}
val default = AllLanguagesName to stringResource(R.string.all_languages_preference)
val languages = APIHolder.apis.withLock {
APIHolder.apis.map { api -> api.lang }.distinct()
}.sortedBy { fromTagToLanguageName(it) ?: it }
return persistentListOf(
Preference.PreferenceGroup(title = stringResource(R.string.extension_language), preferenceItems = persistentListOf(
Preference.PreferenceItem.ListPreference(
preference = settings.general.locale,
entries = appLanguages.associate { (name, code) -> (code to (name to code).nameNextToFlagEmoji()) },
title = stringResource(R.string.app_language),
icon = painterResource(R.drawable.language_korean_latin_24px),
onValueChanged = { value ->
settings.general.locale.set(value)
activity?.recreate()
return@ListPreference false
},
subtitleProvider = { v, e -> e[v] ?: getCurrentLocale(LocalContext.current) }
),
Preference.PreferenceItem.MultiSelectListPreference(
title = stringResource(R.string.provider_lang_settings),
icon = painterResource(R.drawable.plugin_lang),
entries = mapOf(default) + languages.associateWith { lang ->
(getNameNextToFlagEmoji(
lang
) ?: lang)
},
preference = settings.provider.extensionLanguages
),
Preference.PreferenceItem.MultiSelectListPreference(
title = stringResource(R.string.preferred_media_settings),
icon = painterResource(R.drawable.movie_edit_24px),
preference = settings.provider.preferredMedia,
entries = TvType.entries.associate {
it.ordinal.toString() to stringResource(it.toStringRes())
}
// Ok this looks strange af, but we do this to avoid double movie
.toPersistentMap().remove(TvType.AnimeMovie.ordinal.toString()), onValueChanged = { diff ->
if(diff.contains(TvType.Movie.ordinal.toString())) {
settings.provider.preferredMedia.set(diff + TvType.AnimeMovie.ordinal.toString())
} else {
settings.provider.preferredMedia.set(diff - TvType.AnimeMovie.ordinal.toString())
}
return@MultiSelectListPreference false
}),
)),
Preference.PreferenceGroup(
title = stringResource(R.string.title_downloads),
preferenceItems = persistentListOf(
Preference.PreferenceItem.TextPreference(
icon = painterResource(R.drawable.netflix_download),
subtitle = downloadPathVisual,
title = stringResource(R.string.download_path_pref),
onClick = {
// This is not a ListPreference because the old selection system is
// broken af. This needs to be refactored to QuickNovels download path
// system.
selectFileSelector.launch(Uri.EMPTY)
},
),
Preference.PreferenceItem.SliderPreference(
icon = painterResource(R.drawable.arrow_or_edge_24px),
preference = settings.general.parallelDownloads,
valueRange = 1..10,
title = stringResource(R.string.parallel_downloads),
subtitle = stringResource(R.string.download_parallel_settings_des),
),
Preference.PreferenceItem.SliderPreference(
icon = painterResource(R.drawable.arrow_and_edge_24px),
preference = settings.general.concurrentConnections,
valueRange = 1..10,
title = stringResource(R.string.concurrent_connections),
subtitle = stringResource(R.string.concurrent_connections_settings_des),
),
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.battery_dialog_title),
icon = painterResource(R.drawable.battery_alert_24px),
enabled = isLayout(PHONE),
onClick = {
if (isAppRestricted(context)) {
isBatteryShown = true
} else {
showToast(R.string.app_unrestricted_toast)
}
}
),
)
),
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_bypass),
preferenceItems = persistentListOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.add_site_pref),
subtitle = stringResource(R.string.add_site_summary),
icon = painterResource(R.drawable.copy_all_24px),
onClick = {
// TODO refactor into compose
if (SettingsGeneral.getCurrent().isEmpty()) {
SettingsGeneral.showAdd()
} else {
SettingsGeneral.showAddOrDelete()
}
}
),
Preference.PreferenceItem.ListPreference(
title = stringResource(R.string.dns_pref),
subtitle = stringResource(R.string.dns_pref_summary),
icon = painterResource(R.drawable.dns_24px),
preference = settings.general.dns,
entries = integerArrayResource(R.array.dns_pref_values).zip(
stringArrayResource(R.array.dns_pref)
).toMap(),
onValueChanged = {
(CloudStreamApp.context)?.let { ctx ->
app.initClient(ctx, ignoreSSL = false)
@OptIn(UnsafeSSL::class)
insecureApp.initClient(ctx, ignoreSSL = true)
}
return@ListPreference true
},
),
Preference.PreferenceItem.SwitchPreference(
title = stringResource(R.string.jsdelivr_proxy),
subtitle = stringResource(R.string.jsdelivr_proxy_summary),
icon = painterResource(R.drawable.wifi_proxy_24px),
preference = settings.general.jsdelivrProxy
)
)
),
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_links),
preferenceItems = persistentListOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.github),
subtitle = "https://github.com/recloudstream/cloudstream",
icon = painterResource(R.drawable.ic_github_logo),
onClick = {
CloudStreamApp.openBrowser("https://github.com/recloudstream/cloudstream")
}
),
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.lightnovel),
subtitle = "https://github.com/LagradOst/QuickNovel",
icon = painterResource(R.drawable.quick_novel_icon),
onClick = {
CloudStreamApp.openBrowser("https://github.com/LagradOst/QuickNovel")
}
),
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.discord),
subtitle = "https://discord.gg/5Hus6fM",
icon = painterResource(R.drawable.ic_baseline_discord_24),
onClick = {
CloudStreamApp.openBrowser("https://discord.gg/5Hus6fM")
}
),
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.cs3wiki),
subtitle = "https://cloudstream.miraheze.org/",
icon = painterResource(R.drawable.description_24px),
onClick = {
CloudStreamApp.openBrowser("https://cloudstream.miraheze.org/")
}
),
)
),
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.benene),
subtitle = if (bananas == 0) {
stringResource(R.string.benene_count_text_none)
} else {
stringResource(R.string.benene_count_text, bananas)
},
onClick = {
settings.general.bananas.set(bananas + 1)
},
icon = painterResource(R.drawable.benene),
),
Preference.PreferenceItem.InfoPreference(title = stringResource(R.string.legal_notice_text)),
)
}
}
@PreviewLightDark
@Composable
private fun SettingGeneralPreview() {
CloudStreamPreviewTheme {
SettingsGeneralScreen.Content()
}
}

View file

@ -1,7 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import com.lagradost.cloudstream3.utils.BaseComposeFragment
import com.mihon.presentation.settings.SearchableSettings
/** Empty glue code to connect the old navigation graph to Compose */
class SettingsPlayer2 : BaseComposeFragment(), SearchableSettings by SettingsPlayerScreen

View file

@ -1,351 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import android.text.format.Formatter.formatShortFileSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableLongStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.integerArrayResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringArrayResource
import androidx.compose.ui.res.stringResource
import com.lagradost.cloudstream3.CommonActivity.activity
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.actions.VideoClickActionHolder
import com.lagradost.cloudstream3.ui.player.source_priority.QualityProfileDialog
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getFolderSize
import com.lagradost.cloudstream3.ui.subtitles.ChromecastSubtitlesFragment
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
import com.lagradost.cloudstream4.compose.EMULATOR
import com.lagradost.cloudstream4.compose.PHONE
import com.lagradost.cloudstream4.compose.TV
import com.lagradost.cloudstream4.compose.isLayout
import com.lagradost.cloudstream4.rememberAppSettings
import com.mihon.presentation.settings.Preference
import com.mihon.presentation.settings.SearchableSettings
import kotlinx.collections.immutable.persistentListOf
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import kotlin.reflect.jvm.jvmName
object SettingsPlayerScreen : SearchableSettings {
@Composable
override fun getTitleRes(): String = stringResource(R.string.category_player)
@Composable
override fun getPreferences(): List<Preference> {
val settings = rememberAppSettings()
val context = LocalContext.current
val defaultPlayerName = stringResource(R.string.player_settings_play_in_app)
val players = remember(context) {
mapOf("" to defaultPlayerName) + VideoClickActionHolder.getPlayers()
.associate { player ->
player.uniqueId() to (player.name.asStringNull(context)
?: player::class.simpleName ?: player::class.jvmName)
}
}
var cacheSize by remember { mutableLongStateOf(0L) }
var cacheCleared by remember { mutableIntStateOf(0) }
val cacheDir = LocalContext.current.cacheDir
LaunchedEffect(cacheCleared) {
withContext(Dispatchers.IO) {
cacheSize = getFolderSize(cacheDir)
}
}
return persistentListOf(
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_subtitles),
preferenceItems = persistentListOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.player_subtitles_settings),
subtitle = stringResource(R.string.player_subtitles_settings_des),
icon = painterResource(R.drawable.subtitles_gear_24px),
onClick = {
SubtitlesFragment.push(activity, false)
}),
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.chromecast_subtitles_settings),
subtitle = stringResource(R.string.chromecast_subtitles_settings_des),
icon = painterResource(R.drawable.cast),
onClick = {
ChromecastSubtitlesFragment.push(activity, false)
}),
),
),
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_player_features),
preferenceItems = persistentListOf(
Preference.PreferenceItem.ListPreference(
title = stringResource(R.string.player_pref),
icon = painterResource(R.drawable.play_arrow_24px),
preference = settings.player.defaultPlayer,
entries = players,
),
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.source_priority),
subtitle = stringResource(R.string.source_priority_help),
icon = painterResource(R.drawable.ic_baseline_people_24),
onClick = {
ioSafe {
val defaultSources = QualityProfileDialog.getAllDefaultSources()
val activity = activity ?: return@ioSafe
activity.runOnUiThread {
QualityProfileDialog(
activity,
R.style.DialogFullscreenPlayer,
defaultSources,
).show()
}
}
}),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.pipEnabled,
title = stringResource(R.string.picture_in_picture),
subtitle = stringResource(R.string.picture_in_picture_des),
icon = painterResource(R.drawable.pip_24px),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.resizeEnabled,
title = stringResource(R.string.player_size_settings),
subtitle = stringResource(R.string.player_size_settings_des),
icon = painterResource(R.drawable.aspect_ratio_24px),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.speedEnabled,
title = stringResource(R.string.eigengraumode_settings),
subtitle = stringResource(R.string.speed_setting_summary),
icon = painterResource(R.drawable.ic_baseline_speed_24),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.tiktokEnabled,
title = stringResource(R.string.speedup_title),
subtitle = stringResource(R.string.speedup_summary),
icon = painterResource(R.drawable.speedup),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.autoPlayEnabled,
title = stringResource(R.string.autoplay_next_settings),
subtitle = stringResource(R.string.autoplay_next_settings_des),
icon = painterResource(R.drawable.skip_next_24px),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.startPaused,
title = stringResource(R.string.start_paused_settings),
subtitle = stringResource(R.string.start_paused_settings_des),
icon = painterResource(R.drawable.pause_24px),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.skipOpEnabled,
title = stringResource(R.string.video_skip_op),
subtitle = stringResource(R.string.enable_skip_op_from_database_des),
icon = painterResource(R.drawable.keyboard_double_arrow_right_24px),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.autoRotateEnabled,
title = stringResource(R.string.auto_rotate_video),
subtitle = stringResource(R.string.auto_rotate_video_desc),
icon = painterResource(R.drawable.screen_rotation_alt_24px),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.rotateButtonEnabled,
title = stringResource(R.string.rotate_video),
subtitle = stringResource(R.string.rotate_video_desc),
icon = painterResource(R.drawable.screen_rotation),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.previewBarEnabled,
enabled = isLayout(PHONE or EMULATOR),
title = stringResource(R.string.preview_seekbar),
subtitle = stringResource(R.string.preview_seekbar_desc),
icon = painterResource(R.drawable.picture_in_picture_center_24px),
),
Preference.PreferenceItem.ListPreference(
preference = settings.player.softwareDecoding,
title = stringResource(R.string.software_decoding),
subtitle = stringResource(R.string.software_decoding_desc),
icon = painterResource(R.drawable.memory_24px),
entries = integerArrayResource(R.array.software_decoding_switch_values).zip(
stringArrayResource(R.array.software_decoding_switch)
).toMap()
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.extraBrightnessEnabled,
title = stringResource(R.string.extra_brightness_settings),
subtitle = stringResource(R.string.extra_brightness_settings_des),
icon = painterResource(R.drawable.light_mode_24px),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.episodeSync,
title = stringResource(R.string.episode_sync_settings),
subtitle = stringResource(R.string.episode_sync_settings_des),
icon = painterResource(R.drawable.autorenew_24px)
),
),
),
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_gestures),
preferenceItems = persistentListOf(
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.swipeHorizontalEnabled,
title = stringResource(R.string.swipe_to_seek_settings),
subtitle = stringResource(R.string.swipe_to_seek_settings_des),
icon = painterResource(R.drawable.swipe_24px),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.swipeVerticalEnabled,
title = stringResource(R.string.swipe_to_change_settings),
subtitle = stringResource(R.string.swipe_to_change_settings_des),
icon = painterResource(R.drawable.swipe_vertical_24px),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.doubleTapToSeekEnabled,
title = stringResource(R.string.double_tap_to_seek_settings),
subtitle = stringResource(R.string.double_tap_to_seek_settings_des),
icon = painterResource(R.drawable.touch_double_24px),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.doubleTapToPauseEnabled,
title = stringResource(R.string.double_tap_to_pause_settings),
subtitle = stringResource(R.string.double_tap_to_pause_settings_des),
icon = painterResource(R.drawable.touch_double_24px),
),
Preference.PreferenceItem.SliderPreference(
preference = settings.player.doubleTapTime,
title = stringResource(R.string.double_tap_to_seek_amount_settings),
icon = painterResource(R.drawable.go_forward_30),
valueRange = 5..60,
//steps = 10,
),
)
),
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_android_tv),
enabled = isLayout(TV or EMULATOR),
preferenceItems = persistentListOf(
Preference.PreferenceItem.SliderPreference(
preference = settings.player.tvSeekOnTime,
title = stringResource(R.string.android_tv_interface_on_seek_settings),
subtitle = stringResource(R.string.android_tv_interface_on_seek_settings_summary),
icon = painterResource(R.drawable.go_forward_30),
valueRange = 5..60,
//steps = 10,
),
Preference.PreferenceItem.SliderPreference(
preference = settings.player.tvSeekOffTime,
title = stringResource(R.string.android_tv_interface_off_seek_settings),
subtitle = stringResource(R.string.android_tv_interface_off_seek_settings_summary),
icon = painterResource(R.drawable.go_forward_30),
valueRange = 5..60,
//steps = 10,
),
)
),
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_player_layout),
preferenceItems = persistentListOf(
Preference.PreferenceItem.ListPreference(
preference = settings.player.limitPlayerTitle,
title = stringResource(R.string.limit_title),
icon = painterResource(R.drawable.match_word_24px),
entries = integerArrayResource(R.array.limit_title_pref_values).zip(
stringArrayResource(R.array.limit_title_pref_names)
).toMap()
),
Preference.PreferenceItem.SwitchPreference(
enabled = isLayout(PHONE or EMULATOR),
preference = settings.player.hidePlayerControlNames,
icon = painterResource(R.drawable.visibility_off_24px),
title = stringResource(R.string.hide_player_control_names),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.showName,
icon = painterResource(R.drawable.label_24px),
title = stringResource(R.string.source_name),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.showMediaInfo,
icon = painterResource(R.drawable.movie_info_24px),
title = stringResource(R.string.video_info),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.player.showResolution,
title = stringResource(R.string.resolution),
icon = painterResource(R.drawable.high_res_24px),
),
// Unsure if we want to have MultiSelectListPreference or boolean
/*Preference.PreferenceItem.MultiSelectListPreference(
preference = settings.player.showPlayerInfo,
title = stringResource(R.string.limit_title_rez),
icon = painterResource(R.drawable.ic_baseline_text_format_24),
entries = persistentMapOf(
ShowPlayerInfo.Name to stringResource(R.string.source_name),
ShowPlayerInfo.Resolution to stringResource(R.string.resolution),
ShowPlayerInfo.VideoInfo to stringResource(R.string.video_info),
)
), */
)
),
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_cache),
preferenceItems = persistentListOf(
Preference.PreferenceItem.ListPreference(
preference = settings.player.bufferDiskMB,
title = stringResource(R.string.video_buffer_disk_settings),
subtitle = "%s\n" + stringResource(R.string.video_disk_description),
icon = painterResource(R.drawable.hard_drive_24px),
entries = integerArrayResource(R.array.video_buffer_size_values).zip(
stringArrayResource(R.array.video_buffer_size_names)
).toMap()
),
Preference.PreferenceItem.ListPreference(
preference = settings.player.bufferRamMB,
title = stringResource(R.string.video_buffer_size_settings),
subtitle = "%s\n" + stringResource(R.string.video_ram_description),
icon = painterResource(R.drawable.memory_alt_24px),
entries = integerArrayResource(R.array.video_buffer_size_values).zip(
stringArrayResource(R.array.video_buffer_size_names)
).toMap()
),
Preference.PreferenceItem.ListPreference(
preference = settings.player.bufferTimeSec,
title = stringResource(R.string.video_buffer_length_settings),
subtitle = "%s\n" + stringResource(R.string.video_ram_description),
icon = painterResource(R.drawable.history_toggle_off_24px),
entries = integerArrayResource(R.array.video_buffer_length_values).zip(
stringArrayResource(R.array.video_buffer_length_names)
).toMap()
),
Preference.PreferenceItem.TextPreference(
icon = painterResource(R.drawable.ic_baseline_delete_outline_24),
title = stringResource(R.string.video_buffer_clear_settings),
subtitle = formatShortFileSize(LocalContext.current, cacheSize),
onClick = {
ioSafe {
cacheDir.deleteRecursively()
cacheCleared += 1
}
})
)
),
)
}
}

View file

@ -109,8 +109,7 @@ class SettingsProviders : BasePreferenceFragmentCompat() {
return@setOnPreferenceClickListener true
}
getPref(R.string.
provider_lang_key)?.setOnPreferenceClickListener {
getPref(R.string.provider_lang_key)?.setOnPreferenceClickListener {
activity?.getApiProviderLangSettings()?.let { currentLangTags ->
val languagesTagName = APIHolder.apis.withLock {
listOf(Pair(AllLanguagesName, getString(R.string.all_languages_preference))) +

View file

@ -1,7 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import com.lagradost.cloudstream3.utils.BaseComposeFragment
import com.mihon.presentation.settings.SearchableSettings
/** Empty glue code to connect the old navigation graph to Compose */
@Deprecated("This setting was merged into other places")
class SettingsProviders2 : BaseComposeFragment(), SearchableSettings by SettingsProvidersScreen

View file

@ -1,89 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import com.lagradost.cloudstream3.APIHolder
import com.lagradost.cloudstream3.AllLanguagesName
import com.lagradost.cloudstream3.CommonActivity.activity
import com.lagradost.cloudstream3.DubStatus
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.TvType
import com.lagradost.cloudstream3.utils.SubtitleHelper.fromTagToLanguageName
import com.lagradost.cloudstream3.utils.SubtitleHelper.getNameNextToFlagEmoji
import com.lagradost.cloudstream3.utils.UIHelper.navigate
import com.lagradost.cloudstream4.rememberAppSettings
import com.mihon.presentation.settings.Preference
import com.mihon.presentation.settings.SearchableSettings
import kotlinx.collections.immutable.persistentListOf
@Deprecated("This setting was merged into other places")
object SettingsProvidersScreen : SearchableSettings {
@Composable
override fun getTitleRes(): String = stringResource(R.string.category_providers)
fun TvType.toStringRes() = when (this) {
TvType.TvSeries -> R.string.tv_series_singular
TvType.Anime -> R.string.anime_singular
TvType.OVA -> R.string.ova_singular
TvType.AnimeMovie -> R.string.movies_singular
TvType.Cartoon -> R.string.cartoons_singular
TvType.Documentary -> R.string.documentaries_singular
TvType.Movie -> R.string.movies_singular
TvType.Torrent -> R.string.torrent_singular
TvType.AsianDrama -> R.string.asian_drama_singular
TvType.Live -> R.string.live_singular
TvType.Others -> R.string.other_singular
TvType.NSFW -> R.string.nsfw_singular
TvType.Music -> R.string.music_singular
TvType.AudioBook -> R.string.audio_book_singular
TvType.CustomMedia -> R.string.custom_media_singular
TvType.Audio -> R.string.audio_singular
TvType.Podcast -> R.string.podcast_singular
TvType.Video -> R.string.video_singular
}
@Composable
override fun getPreferences(): List<Preference> {
val settings = rememberAppSettings()
val default = AllLanguagesName to stringResource(R.string.all_languages_preference)
val languages = APIHolder.apis.withLock {
APIHolder.apis.map { api -> api.lang }.distinct()
}.sortedBy { fromTagToLanguageName(it) ?: it }
return persistentListOf(
Preference.PreferenceItem.MultiSelectListPreference(
title = stringResource(R.string.provider_lang_settings),
icon = painterResource(R.drawable.plugin_lang),
entries = mapOf(default) + languages.associateWith { lang ->
(getNameNextToFlagEmoji(
lang
) ?: lang)
},
preference = settings.provider.extensionLanguages
), Preference.PreferenceItem.MultiSelectListPreference(
title = stringResource(R.string.preferred_media_settings),
icon = painterResource(R.drawable.movie_edit_24px),
preference = settings.provider.preferredMedia,
entries = TvType.entries.associate {
it.ordinal.toString() to stringResource(it.toStringRes())
}),
Preference.PreferenceItem.MultiSelectListPreference(
title = stringResource(R.string.display_subbed_dubbed_settings),
icon = painterResource(R.drawable.audio_capture_24px),
preference = settings.provider.displayDubSub,
entries = mapOf(
DubStatus.None.name to stringResource(R.string.none),
DubStatus.Dubbed.name to stringResource(R.string.app_dubbed_text),
DubStatus.Subbed.name to stringResource(R.string.app_subbed_text),
)
), Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.test_extensions),
subtitle = stringResource(R.string.test_extensions_summary),
icon = painterResource(R.drawable.baseline_network_ping_24),
onClick = {
activity?.navigate(R.id.navigation_test_providers)
}))
}
}

View file

@ -228,8 +228,6 @@ class SettingsUI : BasePreferenceFragmentCompat() {
return@setOnPreferenceClickListener true
}
getPref(R.string.tv_layout_clock_key)?.hideOn(PHONE or EMULATOR)
getPref(R.string.confirm_exit_key)?.setOnPreferenceClickListener {
val prefNames = resources.getStringArray(R.array.confirm_exit)
val prefValues = resources.getIntArray(R.array.confirm_exit_values)

View file

@ -1,7 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import com.lagradost.cloudstream3.utils.BaseComposeFragment
import com.mihon.presentation.settings.SearchableSettings
/** Empty glue code to connect the old navigation graph to Compose */
class SettingsUI2 : BaseComposeFragment(), SearchableSettings by SettingsUIScreen

View file

@ -1,303 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import android.os.Build
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.integerArrayResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringArrayResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.lagradost.cloudstream3.CommonActivity.activity
import com.lagradost.cloudstream3.DubStatus
import com.lagradost.cloudstream3.MainActivity
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.SearchQuality
import com.lagradost.cloudstream3.mvvm.safe
import com.lagradost.cloudstream3.ui.clear
import com.lagradost.cloudstream3.ui.home.HomeChildItemAdapter
import com.lagradost.cloudstream3.ui.home.ParentItemAdapter
import com.lagradost.cloudstream3.ui.search.SearchAdapter
import com.lagradost.cloudstream3.ui.settings.Globals.updateTv
import com.lagradost.cloudstream3.utils.UIHelper.toPx
import com.lagradost.cloudstream4.compose.TV
import com.lagradost.cloudstream4.compose.isLayout
import com.lagradost.cloudstream4.rememberAppSettings
import com.lagradost.cloudstream4.theme.CloudStreamPrimaryColor
import com.lagradost.cloudstream4.theme.modeToTheme
import com.lagradost.cloudstream4.theme.perfToColor
import com.lagradost.cloudstream4.theme.perfToMode
import com.mihon.presentation.settings.Preference
import com.mihon.presentation.settings.SearchableSettings
import kotlinx.collections.immutable.mutate
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentMap
object SettingsUIScreen : SearchableSettings {
@Composable
override fun getTitleRes(): String = stringResource(R.string.category_ui)
fun SearchQuality.toStringRes() = when (this) {
SearchQuality.BlueRay -> R.string.quality_blueray
SearchQuality.Cam -> R.string.quality_cam
SearchQuality.CamRip -> R.string.quality_cam_rip
SearchQuality.DVD -> R.string.quality_dvd
SearchQuality.HD -> R.string.quality_hd
SearchQuality.HQ -> R.string.quality_hq
SearchQuality.HdCam -> R.string.quality_cam_hd
SearchQuality.Telecine -> R.string.quality_tc
SearchQuality.Telesync -> R.string.quality_ts
SearchQuality.WorkPrint -> R.string.quality_workprint
SearchQuality.SD -> R.string.quality_sd
SearchQuality.FourK -> R.string.quality_4k
SearchQuality.UHD -> R.string.quality_uhd
SearchQuality.SDR -> R.string.quality_sdr
SearchQuality.HDR -> R.string.quality_hdr
SearchQuality.WebRip -> R.string.quality_webrip
}
@Composable
fun RoundColor(color: Color) {
Box(
modifier = Modifier
.padding(start = 15.dp)
.size(20.dp)
.border(width = 1.5.dp, shape = CircleShape, color = MaterialTheme.colorScheme.onBackground)
.background(color, CircleShape)
)
}
@Composable
override fun getPreferences(): List<Preference> {
val settings = rememberAppSettings()
return persistentListOf(
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_looks),
preferenceItems = persistentListOf(
Preference.PreferenceItem.ListPreference(
preference = settings.ui.primaryColor,
icon = painterResource(R.drawable.colors_24px),
title = stringResource(R.string.primary_color_settings),
entries = stringArrayResource(R.array.themes_overlay_names_values).zip(
stringArrayResource(R.array.themes_overlay_names)
).toMap().toPersistentMap().mutate { map ->
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) { // remove monet on android 11 and less
map.remove("Monet")
map.remove("Monet2")
}
},
iconProvider = { k, _ ->
val color = perfToColor(k)
RoundColor(color.color)
},
onValueChanged = { newValue ->
settings.ui.primaryColor.set(newValue) // We need to set before we recreate
safe {
activity?.recreate()
}
return@ListPreference false
}),
Preference.PreferenceItem.ListPreference(
preference = settings.ui.theme,
icon = painterResource(R.drawable.palette_24px),
title = stringResource(R.string.app_theme_settings),
entries = stringArrayResource(R.array.themes_names_values).zip(
stringArrayResource(R.array.themes_names)
).toMap().toPersistentMap().mutate { map ->
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) { // remove monet on android 11 and less
map.remove("Monet")
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { // Remove system on android 9 and less
map.remove("System")
}
},
iconProvider = { k, _ ->
val theme = modeToTheme(perfToMode(k), CloudStreamPrimaryColor.NORMAL)
RoundColor(theme.background)
},
onValueChanged = { newValue ->
settings.ui.theme.set(newValue) // We need to set before we recreate
safe {
activity?.recreate()
}
return@ListPreference false
}),
Preference.PreferenceItem.ListPreference(
preference = settings.ui.layout,
icon = painterResource(R.drawable.responsive_layout_24px),
title = stringResource(R.string.app_layout),
entries = integerArrayResource(R.array.app_layout_values).zip(
stringArrayResource(R.array.app_layout)
).toMap().toPersistentMap(),
onValueChanged = { newValue ->
settings.ui.layout.set(newValue) // We need to set before we recreate
safe {
activity?.updateTv()
activity?.recreate()
}
return@ListPreference false
}),
)
),
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_ui_features),
preferenceItems = persistentListOf(
Preference.PreferenceItem.SliderPreference(
preference = settings.ui.overscanDp,
title = stringResource(R.string.overscan_settings),
subtitle = stringResource(R.string.overscan_settings_des),
valueRange = 0..100,
icon = painterResource(R.drawable.arrows_input_24px),
enabled = isLayout(TV),
onValueChanged = { newValue ->
settings.ui.overscanDp.set(newValue)
val padding = newValue.toPx
(activity as? MainActivity)?.binding?.homeRoot?.setPadding(
padding, padding, padding, padding
)
return@SliderPreference false
}),
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.advancedSearch,
title = stringResource(R.string.advanced_search),
subtitle = stringResource(R.string.advanced_search_des),
icon = painterResource(R.drawable.search_icon)
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.searchSuggestions,
title = stringResource(R.string.search_suggestions),
subtitle = stringResource(R.string.search_suggestions_des),
icon = painterResource(R.drawable.tooltip_24px)
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.trailersEnabled,
title = stringResource(R.string.show_trailers_settings),
icon = painterResource(R.drawable.baseline_theaters_24)
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.kitsuPostersEnabled,
title = stringResource(R.string.kitsu_settings),
icon = painterResource(R.drawable.kitsu_icon)
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.castEnabled,
title = stringResource(R.string.show_cast_in_details),
icon = painterResource(R.drawable.face_24px)
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.fillersEnabled,
title = stringResource(R.string.show_fillers_settings),
icon = painterResource(R.drawable.skip_next_24px)
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.showMetadataOverlay,
title = stringResource(R.string.show_player_metadata_overlay),
icon = painterResource(R.drawable.metadata_overlay_icon)
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.showClock,
title = stringResource(R.string.tv_layout_clock_settings),
subtitle = stringResource(R.string.tv_layout_clock_settings_des),
icon = painterResource(R.drawable.ic_baseline_clock_24),
enabled = isLayout(TV),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.randomButtonEnabled,
title = stringResource(R.string.random_button_settings),
subtitle = stringResource(R.string.random_button_settings_desc),
icon = painterResource(R.drawable.shuffle_24px)
),
Preference.PreferenceItem.ListPreference(
preference = settings.ui.confirmExit,
title = stringResource(R.string.confirm_before_exiting_title),
subtitle = stringResource(R.string.confirm_before_exiting_desc),
icon = painterResource(R.drawable.ic_baseline_exit_24),
entries = integerArrayResource(R.array.confirm_exit_values).zip(
stringArrayResource(R.array.confirm_exit)
).toMap()
),
)
),
Preference.PreferenceGroup(
title = stringResource(R.string.search_poster_img_des),
preferenceItems = persistentListOf(
Preference.PreferenceItem.MultiSelectListPreference(
preference = settings.ui.filterQuality,
title = stringResource(R.string.pref_filter_search_quality),
icon = painterResource(R.drawable.filter_alt_24px),
entries = SearchQuality.entries.associateWith { stringResource(it.toStringRes()) }),
Preference.PreferenceItem.MultiSelectListPreference(
title = stringResource(R.string.display_subbed_dubbed_settings),
icon = painterResource(R.drawable.audio_capture_24px),
preference = settings.provider.displayDubSub,
entries = mapOf(
DubStatus.None.name to stringResource(R.string.none),
DubStatus.Dubbed.name to stringResource(R.string.app_dubbed_text),
DubStatus.Subbed.name to stringResource(R.string.app_subbed_text),
)),
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.bottomTitle,
title = stringResource(R.string.bottom_title_settings),
subtitle = stringResource(R.string.bottom_title_settings_des),
icon = painterResource(R.drawable.title_24px)
),
Preference.PreferenceItem.SliderPreference(
preference = settings.ui.posterSize,
title = stringResource(R.string.poster_size_settings),
subtitle = stringResource(R.string.poster_size_settings_des),
valueRange = 0..15,
icon = painterResource(R.drawable.baseline_grid_view_24),
onValueChanged = { newValue ->
HomeChildItemAdapter.sharedPool.clear()
ParentItemAdapter.sharedPool.clear()
SearchAdapter.sharedPool.clear()
activity?.let { HomeChildItemAdapter.updatePosterSize(it, newValue) }
settings.ui.posterSize.set(newValue)
return@SliderPreference false
}),
),
),
Preference.PreferenceGroup(
title = stringResource(R.string.poster_ui_settings),
preferenceItems = persistentListOf(
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.posterShowRating,
title = stringResource(R.string.show_rating),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.posterShowEpisode,
title = stringResource(R.string.show_episode_text),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.posterShowTitle,
title = stringResource(R.string.show_title),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.posterShowHd,
title = stringResource(R.string.show_hd),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.posterShowDub,
title = stringResource(R.string.show_dub),
),
Preference.PreferenceItem.SwitchPreference(
preference = settings.ui.posterShowSub,
title = stringResource(R.string.show_sub),
),
)
)
)
}
}

View file

@ -1,7 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import com.lagradost.cloudstream3.utils.BaseComposeFragment
import com.mihon.presentation.settings.SearchableSettings
/** Empty glue code to connect the old navigation graph to Compose */
class SettingsUpdates2 : BaseComposeFragment(), SearchableSettings by SettingsUpdatesScreen

View file

@ -1,230 +0,0 @@
package com.lagradost.cloudstream3.ui.settings
import android.content.Intent
import android.net.Uri
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.res.integerArrayResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringArrayResource
import androidx.compose.ui.res.stringResource
import com.lagradost.cloudstream3.AutoDownloadMode
import com.lagradost.cloudstream3.BuildConfig
import com.lagradost.cloudstream3.CloudStreamApp
import com.lagradost.cloudstream3.CommonActivity.activity
import com.lagradost.cloudstream3.MainActivityScreen
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.plugins.PluginManager
import com.lagradost.cloudstream3.utils.BackupUtils
import com.lagradost.cloudstream3.utils.BackupUtils.restorePrompt
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
import com.lagradost.cloudstream3.utils.InAppUpdater.installPreReleaseIfNeeded
import com.lagradost.cloudstream3.utils.UIHelper.navigate
import com.lagradost.cloudstream4.AppSettings
import com.lagradost.cloudstream4.rememberAppSettings
import com.lagradost.safefile.SafeFile
import com.mihon.presentation.settings.Preference
import com.mihon.presentation.settings.SearchableSettings
import com.mihon.presentation.settings.collectAsState
import kotlinx.collections.immutable.persistentListOf
object SettingsUpdatesScreen : SearchableSettings {
@Composable
override fun getTitleRes(): String = stringResource(R.string.category_updates)
@Composable
override fun getPreferences(): List<Preference> {
val settings = rememberAppSettings()
// TODO Refactor entirely to use a different file path selector ect like QuickNovel
val selectFileSelector =
rememberLauncherForActivityResult(ActivityResultContracts.OpenDocumentTree()) { uri ->
// It lies, it can be null if file manager quits.
if (uri == null) return@rememberLauncherForActivityResult
val context = CloudStreamApp.context ?: return@rememberLauncherForActivityResult
try {
val settings = AppSettings(context)
// RW perms for the path
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
context.contentResolver.takePersistableUriPermission(uri, flags)
val filePath = SafeFile.fromUri(context, uri)?.filePath()
println("Selected URI path: $uri - Full path: $filePath")
// store the actual URI instead of the path due to permissions.
// filePath should only be used for cosmetic purposes.
val visual = filePath ?: uri.toString()
settings.backup.path.set(uri.toString())
settings.backup.visualPath.set(visual)
} catch (t: Throwable) {
logError(t)
}
}
val visualBackupPath by settings.backup.visualPath.collectAsState()
var showDialog by remember { mutableStateOf(false) }
if (showDialog) {
com.lagradost.cloudstream3.ui.settings.logcat.LogcatDialog {
showDialog = false
}
}
val githubViewModel = MainActivityScreen.githubViewModel()
return persistentListOf(
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_app_updates),
preferenceItems = persistentListOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.check_for_update),
subtitle = BuildConfig.VERSION_NAME,
icon = painterResource(R.drawable.mobile_arrow_down_24px),
onClick = {
githubViewModel?.onAction(GithubAction.SearchForUpdate)
/*ioSafe {
if (activity?.runAutoUpdate(false) == false) {
activity?.runOnUiThread {
showToast(
R.string.no_update_found,
Toast.LENGTH_SHORT
)
}
}
}*/
}
),
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.install_prerelease),
icon = painterResource(R.drawable.mobile_code_24px),
enabled = BuildConfig.FLAVOR == "stable",
onClick = {
activity?.installPreReleaseIfNeeded()
}
),
Preference.PreferenceItem.ListPreference(
title = stringResource(R.string.apk_installer_settings),
subtitle = stringResource(R.string.apk_installer_settings_des),
icon = painterResource(R.drawable.mobile_wrench_24px),
entries = integerArrayResource(R.array.apk_installer_values).zip(
stringArrayResource(R.array.apk_installer_pref)
).toMap(),
preference = settings.updates.apkInstaller
),
Preference.PreferenceItem.SwitchPreference(
title = stringResource(R.string.updates_settings),
subtitle = stringResource(R.string.updates_settings_des),
icon = painterResource(R.drawable.notifications_active_24px),
preference = settings.updates.showAppUpdates
)
)
),
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_backup),
preferenceItems = persistentListOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.backup_settings),
icon = painterResource(R.drawable.save_as_24px),
onClick = {
BackupUtils.backup(activity)
}
),
Preference.PreferenceItem.ListPreference(
title = stringResource(R.string.backup_frequency),
icon = painterResource(R.drawable.save_clock_24px),
entries = integerArrayResource(R.array.periodic_work_values).zip(
stringArrayResource(R.array.periodic_work_names)
).toMap(),
preference = settings.backup.frequency
),
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.backup_path_title),
icon = painterResource(R.drawable.folder_24px),
subtitle = visualBackupPath,
onClick = {
// This is not a ListPreference because the old selection system is
// broken af. This needs to be refactored to QuickNovels download path
// system.
selectFileSelector.launch(Uri.EMPTY)
}
),
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.restore_settings),
icon = painterResource(R.drawable.restore_page_24px),
onClick = {
activity?.restorePrompt()
}
),
)
),
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_extensions),
preferenceItems = persistentListOf(
Preference.PreferenceItem.SwitchPreference(
title = stringResource(R.string.automatic_plugin_updates),
icon = painterResource(R.drawable.extension_24px),
preference = settings.plugins.autoUpdate,
),
Preference.PreferenceItem.ListPreference(
title = stringResource(R.string.automatic_plugin_download),
subtitle = "%s\n" + stringResource(R.string.automatic_plugin_download_summary),
icon = painterResource(R.drawable.extention_renew2),
entries = AutoDownloadMode.entries.map { it.value }.sorted()
.zip(stringArrayResource((R.array.auto_download_plugin))).toMap(),
preference = settings.plugins.autoDownload
),
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.update_plugins),
subtitle = stringResource(R.string.update_plugins_manually),
icon = painterResource(R.drawable.extention_download),
onClick = {
ioSafe {
PluginManager.___DO_NOT_CALL_FROM_A_PLUGIN_manuallyReloadAndUpdatePlugins(
activity ?: return@ioSafe
)
}
}
),
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.test_extensions),
subtitle = stringResource(R.string.test_extensions_summary),
icon = painterResource(R.drawable.baseline_network_ping_24),
onClick = {
activity?.navigate(R.id.navigation_test_providers)
})
)
),
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_actions),
preferenceItems = persistentListOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.show_log_cat),
icon = painterResource(R.drawable.article_24px),
onClick = {
showDialog = true
}
),
Preference.PreferenceItem.TextPreference(
title = stringResource(R.string.redo_setup_process),
icon = painterResource(R.drawable.construction_24px),
onClick = {
activity?.navigate(R.id.navigation_setup_language)
}
),
)
)
)
}
}

View file

@ -1,282 +0,0 @@
package com.lagradost.cloudstream3.ui.settings.logcat
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.LinearProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.FocusRequester.Companion.FocusRequesterFactory.component1
import androidx.compose.ui.focus.FocusRequester.Companion.FocusRequesterFactory.component2
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.DialogProperties
import com.lagradost.cloudstream3.CommonActivity.showToast
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.utils.UIHelper.clipboardHelper
import com.lagradost.cloudstream3.utils.downloader.VideoDownloadManager
import com.lagradost.cloudstream3.utils.txt
import com.lagradost.cloudstream4.compose.BlackButton
import com.lagradost.cloudstream4.compose.WhiteButton
import com.lagradost.cloudstream4.compose.circle
import com.lagradost.cloudstream4.compose.rounded
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.OutputStream
import java.lang.System.currentTimeMillis
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
@Composable
fun LogcatDialog(dismiss: () -> Unit) {
val list = remember { mutableStateOf(persistentListOf<LogcatItem>()) }
var isLoading by remember { mutableStateOf(true) }
LaunchedEffect(dismiss) {
try {
isLoading = true
// https://developer.android.com/studio/command-line/logcat
val process = Runtime.getRuntime().exec("logcat --binary -d")
val items = arrayListOf<LogcatItem>()
LogcatBinaryParser(process.inputStream).use { parser ->
while (true) {
val item = parser.parseItem() ?: break
items.add(item)
}
}
list.value = items.toPersistentList()
} catch (e: Exception) {
logError(e) // kinda ironic
} finally {
isLoading = false
}
}
val (dismissFocus, confirmFocus) = remember { FocusRequester.createRefs() }
val context = LocalContext.current
val scope = rememberCoroutineScope()
AlertDialog(
containerColor = MaterialTheme.colorScheme.background,
onDismissRequest = dismiss,
title = {
Text(text = stringResource(R.string.log_cat))
},
text = {
if (isLoading) {
LinearProgressIndicator(
modifier = Modifier.fillMaxWidth(),
color = MaterialTheme.colorScheme.onBackground,
trackColor = MaterialTheme.colorScheme.surfaceVariant,
)
}
LazyColumn(
modifier = Modifier.focusProperties {
start = dismissFocus
end = confirmFocus
}
) {
items(items = list.value) { item ->
LogcatItem(item, modifier = Modifier.focusProperties {
start = dismissFocus
end = confirmFocus
})
}
}
},
confirmButton = {
WhiteButton(
text = stringResource(R.string.sort_save),
modifier = Modifier.focusRequester(confirmFocus)
) {
scope.launch {
withContext(Dispatchers.IO) {
val date = SimpleDateFormat("yyyy_MM_dd_HH_mm", Locale.getDefault()).format(
Date(currentTimeMillis())
)
var fileStream: OutputStream?
try {
fileStream = VideoDownloadManager.setupStream(
context,
"logcat_${date}",
null,
"txt",
false
).openNew()
fileStream.bufferedWriter()
.use { writer ->
list.value.forEach {
writer.write(it.toString())
writer.write("\n\n")
}
}
dismiss()
} catch (t: Throwable) {
logError(t)
showToast(t.message)
}
/*try {
val date = SimpleDateFormat(
"yyyy_MM_dd_HH_mm",
Locale.getDefault()
).format(
Date(System.currentTimeMillis())
)
val file = FileHelper.logcat.createFile(context, "logcat_${date}")
?: throw ErrorLoadingException("Unable to create file")
val stream = file.openOutputStream(append = false)
?: throw ErrorLoadingException("Unable to create stream")
stream.bufferedWriter()
.use { writer ->
list.value.forEach {
writer.write(it.toString())
writer.write("\n\n")
}
}
dismiss()
showToast(
txt(
R.string.logcat_success,
file.absolutePath ?: file.uri.toString()
),
Toast.LENGTH_LONG
)
} catch (t: Throwable) {
logError(t)
showToast(t.message)
}*/
}
}
}
WhiteButton(text = stringResource(R.string.sort_copy)) {
clipboardHelper(
txt("Logcat"),
list.value.joinToString(separator = "\n\n") { it.toString() }
)
}
WhiteButton(text = stringResource(R.string.sort_clear)) {
try {
Runtime.getRuntime().exec("logcat -c")
} catch (t: Throwable) {
logError(t)
}
dismiss()
}
},
dismissButton = {
BlackButton(
text = stringResource(R.string.sort_close),
onClick = dismiss,
modifier = Modifier.focusRequester(dismissFocus)
)
},
properties = DialogProperties(usePlatformDefaultWidth = false)
)
}
@Composable
fun LogcatItem(item: LogcatItem, modifier: Modifier = Modifier) {
val color = when (item.level) {
LogcatLevel.Fatal -> Color.Magenta
LogcatLevel.Error -> Color.Red
LogcatLevel.Warning -> Color.Yellow
LogcatLevel.Info -> Color.White
LogcatLevel.Debug -> Color.Green
LogcatLevel.Verbose -> Color.Gray
null -> Color.Transparent
}
Row(modifier = Modifier.fillMaxWidth()) {
item.level?.identifier?.let { value ->
Text(
value,
modifier = Modifier
.padding(2.dp)
.rounded()
.background(MaterialTheme.colorScheme.onBackground)
.padding(4.dp),
color = MaterialTheme.colorScheme.surfaceVariant
)
}
Text(
item.date.toHumanReadable(),
modifier = Modifier
.padding(2.dp)
.rounded()
.background(MaterialTheme.colorScheme.surfaceVariant)
.padding(4.dp),
color = MaterialTheme.colorScheme.onBackground
)
Text(
item.tag,
modifier = Modifier
.padding(2.dp)
.rounded()
.background(MaterialTheme.colorScheme.surfaceVariant)
.padding(4.dp),
color = MaterialTheme.colorScheme.onBackground
)
}
Row(
modifier = modifier
.height(IntrinsicSize.Min)
.fillMaxWidth()
.rounded()
.clickable(
onClick = {
clipboardHelper(txt("Logcat"), item.toString())
})
.padding(5.dp)
) {
Box(
modifier = Modifier
.fillMaxHeight()
.width(4.dp)
.circle()
.background(color)
)
Spacer(modifier = Modifier.width(5.dp))
Text(
item.message,
color = MaterialTheme.colorScheme.onBackground,
fontSize = 14.sp,
lineHeight = 15.sp,
)
}
}

View file

@ -1,140 +0,0 @@
package com.lagradost.cloudstream3.ui.settings.logcat
import androidx.compose.runtime.Immutable
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.io.Closeable
import java.io.InputStream
import kotlin.time.Instant
import kotlinx.io.Buffer
import kotlinx.io.asSource
import kotlinx.io.readByteArray
import kotlinx.io.readIntLe
import kotlinx.io.readString
import kotlinx.io.readUShortLe
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import java.util.TimeZone
fun Instant.toHumanReadable(): String {
val formatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).apply {
timeZone = TimeZone.getDefault()
}
return formatter.format(Date(this.toEpochMilliseconds()))
}
@Immutable
data class LogcatItem(
val date: Instant,
val pid: Int,
val tid: Int,
val level: LogcatLevel?,
val tag: String,
val message: String,
) {
override fun toString(): String {
return "${date.toHumanReadable()} $pid-$tid $tag ${level?.identifier ?: "?"} $message"
}
}
enum class LogcatLevel(val identifier: String) {
Fatal("WTF"),
Error("E"),
Warning("W"),
Info("I"),
Debug("D"),
Verbose("V"),
}
/**https://github.com/brudaswen/android-logcat/blob/main/library/logcat-core/src/main/kotlin/de/brudaswen/android/logcat/core/parser/LogcatBinaryParser.kt */
class LogcatBinaryParser(
private val input: InputStream,
) : Closeable by input {
val source = input.asSource()
private val buffer = Buffer()
/**
* Parse one [LogcatItem] from the current [input] stream.
*
* @return The parsed [LogcatItem] or `null` if stream reached EOF.
*/
suspend fun parseItem(): LogcatItem? = withContext(Dispatchers.IO) {
val firstByte = input.read()
if (firstByte == -1) return@withContext null
// Read v1 header
buffer.writeByte(firstByte.toByte())
buffer.write(source = source, byteCount = 19)
val len = buffer.readUShortLe().toInt()
val headerSize = buffer.readUShortLe().toInt()
val pid = buffer.readIntLe()
val tid = buffer.readIntLe()
val sec = buffer.readIntLe()
val nsec = buffer.readIntLe()
// Read additional header fields
buffer.write(source = source, byteCount = headerSize - 20L)
val additionalHeaderBytes = (headerSize - 20).coerceAtLeast(0)
buffer.readByteArray(byteCount = additionalHeaderBytes)
// Read payload
buffer.write(source = source, byteCount = len.toLong())
val priority = buffer.readByte()
val payload = buffer.readString()
val texts = payload.split('\u0000', limit = 2)
val tag = texts.getOrNull(0).orEmpty()
val message = texts.getOrNull(1).orEmpty().removeSuffix("\u0000").trim()
// Clear buffer
buffer.clear()
// Convert raw values to item
LogcatItem(
sec = sec,
nsec = nsec,
priority = priority,
pid = pid,
tid = tid,
tag = tag,
message = message,
)
}
private fun LogcatItem(
sec: Int,
nsec: Int,
priority: Byte,
pid: Int,
tid: Int,
tag: String,
message: String,
): LogcatItem {
val date = Instant.fromEpochSeconds(
epochSeconds = sec.toLong(),
nanosecondAdjustment = nsec,
)
val level = when (priority) {
2.toByte() -> LogcatLevel.Verbose
3.toByte() -> LogcatLevel.Debug
4.toByte() -> LogcatLevel.Info
5.toByte() -> LogcatLevel.Warning
6.toByte() -> LogcatLevel.Error
7.toByte() -> LogcatLevel.Fatal
else -> null
}
return LogcatItem(
date = date,
pid = pid,
tid = tid,
level = level,
tag = tag,
message = message,
)
}
}

View file

@ -50,18 +50,18 @@ class SetupFragmentLanguage : BaseFragment<FragmentSetupLanguageBinding>(
appIconImage.setImageDrawable(ContextCompat.getDrawable(ctx, drawable))
}
val tags = appLanguages.map { it.second }
val current = getCurrentLocale(ctx).replace('_', '-')
val currentIndex = tags.indexOf(current).takeIf { it >= 0 }
?: tags.indexOf(current.substringBefore('-'))
val current = getCurrentLocale(ctx)
val languageTagsIETF = appLanguages.map { it.second }
val languageNames = appLanguages.map { it.nameNextToFlagEmoji() }
val currentIndex = languageTagsIETF.indexOf(current)
arrayAdapter.addAll(appLanguages.map { it.nameNextToFlagEmoji() })
arrayAdapter.addAll(languageNames)
listview1.adapter = arrayAdapter
listview1.choiceMode = AbsListView.CHOICE_MODE_SINGLE
if (currentIndex >= 0) listview1.setItemChecked(currentIndex, true)
listview1.setItemChecked(currentIndex, true)
listview1.setOnItemClickListener { _, _, selectedLangIndex, _ ->
val langTagIETF = tags[selectedLangIndex]
val langTagIETF = languageTagsIETF[selectedLangIndex]
CommonActivity.setLocale(activity, langTagIETF)
settingsManager.edit {
putString(getString(R.string.locale_key), langTagIETF)

View file

@ -4,6 +4,7 @@ import android.view.View
import android.widget.AbsListView
import android.widget.ArrayAdapter
import androidx.core.content.edit
import androidx.core.util.forEach
import androidx.navigation.fragment.findNavController
import androidx.preference.PreferenceManager
import com.lagradost.cloudstream3.R
@ -26,41 +27,40 @@ class SetupFragmentMedia : BaseFragment<FragmentSetupMediaBinding>(
safe {
val ctx = context ?: return@safe
val settingsManager = PreferenceManager.getDefaultSharedPreferences(ctx)
val prefKey = getString(R.string.prefer_media_type_key)
val arrayAdapter =
ArrayAdapter<String>(ctx, R.layout.sort_bottom_single_choice)
val sortedTypes = enumValues<TvType>().sorted()
val names = enumValues<TvType>().sorted().map { it.name }
val selected = mutableListOf<Int>()
arrayAdapter.addAll(sortedTypes.map { it.name })
arrayAdapter.addAll(names)
binding.apply {
listview1.let {
it.adapter = arrayAdapter
it.choiceMode = AbsListView.CHOICE_MODE_MULTIPLE
val stored = settingsManager.getStringSet(prefKey, null)
sortedTypes.forEachIndexed { index, type ->
// All media types except NSFW are checked by default
val isChecked = stored?.contains(type.ordinal.toString())
?: (type != TvType.NSFW)
it.setItemChecked(index, isChecked)
}
val saveSelection = {
val values = sortedTypes
.filterIndexed { index, _ -> it.isItemChecked(index) }
.map { type -> type.ordinal.toString() }
.toSet()
settingsManager.edit { putStringSet(prefKey, values) }
it.setOnItemClickListener { _, _, _, _ ->
it.checkedItemPositions?.forEach { key, value ->
if (value) {
selected.add(key)
} else {
selected.remove(key)
}
}
val prefValues = selected.mapNotNull { pos ->
val item =
it.getItemAtPosition(pos)?.toString() ?: return@mapNotNull null
val itemVal = TvType.valueOf(item)
itemVal.ordinal.toString()
}.toSet()
settingsManager.edit {
putStringSet(getString(R.string.prefer_media_type_key), prefValues)
}
// Regenerate set homepage
DataStoreHelper.currentHomePage = null
}
if (stored == null) saveSelection()
it.setOnItemClickListener { _, _, _, _ -> saveSelection() }
}
nextBtt.setOnClickListener {

View file

@ -11,8 +11,6 @@ import android.view.View
import android.widget.TextView
import android.widget.Toast
import androidx.annotation.OptIn
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.mutableStateOf
import androidx.media3.common.text.Cue
import androidx.media3.common.util.UnstableApi
import com.fasterxml.jackson.annotation.JsonProperty
@ -46,16 +44,15 @@ import kotlinx.serialization.Serializable
const val CHROME_SUBTITLE_KEY = "chome_subtitle_settings"
@Serializable
@Immutable
data class SaveChromeCaptionStyle(
@JsonProperty("fontFamily") @SerialName("fontFamily") val fontFamily: String? = null,
@JsonProperty("fontGenericFamily") @SerialName("fontGenericFamily") val fontGenericFamily: Int? = null,
@JsonProperty("backgroundColor") @SerialName("backgroundColor") val backgroundColor: Int = 0x00FFFFFF, // transparent
@JsonProperty("edgeColor") @SerialName("edgeColor") val edgeColor: Int = Color.BLACK, // BLACK
@JsonProperty("edgeType") @SerialName("edgeType") val edgeType: Int = EDGE_TYPE_OUTLINE,
@JsonProperty("foregroundColor") @SerialName("foregroundColor") val foregroundColor: Int = Color.WHITE,
@JsonProperty("fontScale") @SerialName("fontScale") val fontScale: Float = 1.05f,
@JsonProperty("windowColor") @SerialName("windowColor") val windowColor: Int = Color.TRANSPARENT,
@JsonProperty("fontFamily") @SerialName("fontFamily") var fontFamily: String? = null,
@JsonProperty("fontGenericFamily") @SerialName("fontGenericFamily") var fontGenericFamily: Int? = null,
@JsonProperty("backgroundColor") @SerialName("backgroundColor") var backgroundColor: Int = 0x00FFFFFF, // transparent
@JsonProperty("edgeColor") @SerialName("edgeColor") var edgeColor: Int = Color.BLACK, // BLACK
@JsonProperty("edgeType") @SerialName("edgeType") var edgeType: Int = EDGE_TYPE_OUTLINE,
@JsonProperty("foregroundColor") @SerialName("foregroundColor") var foregroundColor: Int = Color.WHITE,
@JsonProperty("fontScale") @SerialName("fontScale") var fontScale: Float = 1.05f,
@JsonProperty("windowColor") @SerialName("windowColor") var windowColor: Int = Color.TRANSPARENT,
)
class ChromecastSubtitlesFragment : BaseFragment<ChromecastSubtitleSettingsBinding>(
@ -95,9 +92,6 @@ class ChromecastSubtitlesFragment : BaseFragment<ChromecastSubtitleSettingsBindi
}
fun Context.saveStyle(style: SaveChromeCaptionStyle) {
if (chromeCastSubtitleState.value !== style) {
chromeCastSubtitleState.value = style
}
this.setKey(CHROME_SUBTITLE_KEY, style)
}
@ -107,13 +101,10 @@ class ChromecastSubtitlesFragment : BaseFragment<ChromecastSubtitleSettingsBindi
}
fun getCurrentSavedStyle(): SaveChromeCaptionStyle {
return chromeCastSubtitleState.value
return getKey<SaveChromeCaptionStyle>(CHROME_SUBTITLE_KEY) ?: defaultState
}
val defaultChromeCastSubtitleState = SaveChromeCaptionStyle()
val chromeCastSubtitleState = mutableStateOf(
getKey<SaveChromeCaptionStyle>(CHROME_SUBTITLE_KEY) ?: defaultChromeCastSubtitleState
)
private val defaultState = SaveChromeCaptionStyle()
}
private fun onColorSelected(stuff: Pair<Int, Int>) {
@ -143,10 +134,10 @@ class ChromecastSubtitlesFragment : BaseFragment<ChromecastSubtitleSettingsBindi
private fun setColor(id: Int, color: Int?) {
val realColor = color ?: getDefColor(id)
when (id) {
0 -> state = state.copy(foregroundColor = realColor)
1 -> state = state.copy(edgeColor = realColor)
2 -> state = state.copy(backgroundColor = realColor)
3 -> state = state.copy(windowColor = realColor)
0 -> state.foregroundColor = realColor
1 -> state.edgeColor = realColor
2 -> state.backgroundColor = realColor
3 -> state.windowColor = realColor
else -> Unit
}
@ -249,13 +240,13 @@ class ChromecastSubtitlesFragment : BaseFragment<ChromecastSubtitleSettingsBindi
false,
dismissCallback
) { index ->
state = state.copy(edgeType = edgeTypes.map { it.first }[index])
state.edgeType = edgeTypes.map { it.first }[index]
updateState()
}
}
binding.subsEdgeType.setOnLongClickListener {
state = state.copy(edgeType = defaultChromeCastSubtitleState.edgeType)
state.edgeType = defaultState.edgeType
updateState()
showToast(R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true
@ -290,13 +281,13 @@ class ChromecastSubtitlesFragment : BaseFragment<ChromecastSubtitleSettingsBindi
false,
dismissCallback
) { index ->
state = state.copy(fontScale = fontSizes.map { it.first }[index])
state.fontScale = fontSizes.map { it.first }[index]
//textView.context.updateState() // font size not changed
}
}
binding.subsFontSize.setOnLongClickListener { _ ->
state = state.copy(fontScale = defaultChromeCastSubtitleState.fontScale)
state.fontScale = defaultState.fontScale
//textView.context.updateState() // font size not changed
showToast(R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true
@ -323,12 +314,12 @@ class ChromecastSubtitlesFragment : BaseFragment<ChromecastSubtitleSettingsBindi
false,
dismissCallback
) { index ->
state = state.copy(fontFamily = fontTypes.map { it.first }[index])
state.fontFamily = fontTypes.map { it.first }[index]
updateState()
}
}
binding.subsFont.setOnLongClickListener { _ ->
state = state.copy(fontFamily = defaultChromeCastSubtitleState.fontFamily)
state.fontFamily = defaultState.fontFamily
updateState()
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true

View file

@ -1,6 +0,0 @@
package com.lagradost.cloudstream3.ui.subtitles
import com.lagradost.cloudstream3.utils.BaseComposeFragment
import com.lagradost.cloudstream4.compose.Screen
class ChromecastSubtitlesFragment2 : BaseComposeFragment(), Screen by ChromecastSubtitlesScreen

View file

@ -1,159 +0,0 @@
package com.lagradost.cloudstream3.ui.subtitles
import androidx.compose.foundation.layout.RowScope
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import com.google.android.gms.cast.TextTrackStyle.EDGE_TYPE_DEPRESSED
import com.google.android.gms.cast.TextTrackStyle.EDGE_TYPE_DROP_SHADOW
import com.google.android.gms.cast.TextTrackStyle.EDGE_TYPE_NONE
import com.google.android.gms.cast.TextTrackStyle.EDGE_TYPE_OUTLINE
import com.google.android.gms.cast.TextTrackStyle.EDGE_TYPE_RAISED
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.ui.subtitles.ChromecastSubtitlesFragment.Companion.applyStyleEvent
import com.lagradost.cloudstream3.ui.subtitles.ChromecastSubtitlesFragment.Companion.chromeCastSubtitleState
import com.lagradost.cloudstream3.ui.subtitles.ChromecastSubtitlesFragment.Companion.defaultChromeCastSubtitleState
import com.lagradost.cloudstream3.ui.subtitles.ChromecastSubtitlesFragment.Companion.saveStyle
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesScreen.SetUpUndoBar
import com.mihon.common.preference.StatePreferenceStore
import com.mihon.presentation.settings.Preference
import com.mihon.presentation.settings.SearchableSettings
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.persistentMapOf
import kotlin.math.roundToInt
object ChromecastSubtitlesScreen : SearchableSettings {
@Composable
override fun getTitleRes(): String = stringResource(R.string.chromecast_subtitles_settings)
// For ux purposes we also want to show a diff of what will be reset
private val diff = arrayOf<Pair<Int, (SaveChromeCaptionStyle) -> Any?>>(
R.string.subs_font to { style -> style.fontFamily },
R.string.subs_text_color to { state -> state.foregroundColor },
R.string.subs_font_size to { state -> state.fontScale },
R.string.subs_edge_type to { state -> state.edgeType },
R.string.subs_outline_color to { state -> state.edgeColor },
R.string.subs_window_color to { state -> state.windowColor },
R.string.subs_background_color to { state -> state.backgroundColor },
)
@Composable
override fun RowScope.AppBarAction() {
val initialState = remember { chromeCastSubtitleState.value }
var state by chromeCastSubtitleState
val context = LocalContext.current
SideEffect(state) {
// When we modify the state, we modify the stored data
context.saveStyle(state)
}
DisposableEffect(Unit) {
onDispose {
if (initialState != state) {
applyStyleEvent.invoke(state)
}
}
}
SetUpUndoBar(
diff = diff,
initialState = initialState,
currentState = chromeCastSubtitleState,
default = defaultChromeCastSubtitleState
)
}
@Composable
override fun getPreferences(): List<Preference> {
val store = StatePreferenceStore(chromeCastSubtitleState)
return persistentListOf(
Preference.PreferenceGroup(
title = stringResource(R.string.subs_font),
preferenceItems = persistentListOf(
Preference.PreferenceItem.ListPreference(
preference = store.field(SaveChromeCaptionStyle::fontFamily) { newValue ->
copy(fontFamily = newValue)
},
icon = painterResource(R.drawable.font_download_24px),
title = stringResource(R.string.subs_font),
entries = persistentMapOf(
null to stringResource(R.string.normal),
"Droid Sans" to "Droid Sans",
"Droid Sans Mono" to "Droid Sans Mono",
"Droid Serif Regular" to "Droid Serif Regular",
"Cutive Mono" to "Cutive Mono",
"Short Stack" to "Short Stack",
"Quintessential" to "Quintessential",
"Alegreya Sans SC" to "Alegreya Sans SC",
)
),
Preference.PreferenceItem.ColorPreference(
preference = store.field(SaveChromeCaptionStyle::foregroundColor) { newValue ->
copy(foregroundColor = newValue)
},
title = stringResource(R.string.subs_text_color),
icon = painterResource(R.drawable.format_color_text_24px),
),
Preference.PreferenceItem.SliderPreference(
preference = store.field(
get = { fontScale.times(100.0f).roundToInt() },
set = { newValue -> copy(fontScale = newValue.toFloat() * 0.01f) }),
icon = painterResource(R.drawable.text_fields_24px),
title = stringResource(R.string.subs_font_size),
valueRange = 75..150,
steps = 75 / 5 - 1,
)
)
), Preference.PreferenceGroup(
title = stringResource(R.string.subs_edge), preferenceItems = persistentListOf(
Preference.PreferenceItem.ListPreference(
preference = store.field(SaveChromeCaptionStyle::edgeType) { newValue ->
copy(edgeType = newValue)
},
icon = painterResource(R.drawable.shadow_24px),
title = stringResource(R.string.subs_edge_type),
entries = persistentMapOf(
EDGE_TYPE_NONE to stringResource(R.string.subtitles_none),
EDGE_TYPE_OUTLINE to stringResource(R.string.subtitles_outline),
EDGE_TYPE_DEPRESSED to stringResource(R.string.subtitles_depressed),
EDGE_TYPE_DROP_SHADOW to stringResource(R.string.subtitles_shadow),
EDGE_TYPE_RAISED to stringResource(R.string.subtitles_raised),
)
),
Preference.PreferenceItem.ColorPreference(
preference = store.field(SaveChromeCaptionStyle::edgeColor) { newValue ->
copy(edgeColor = newValue)
},
//enabled = state.edgeType != EDGE_TYPE_NONE,
title = stringResource(R.string.subs_outline_color),
icon = painterResource(R.drawable.border_color_24px),
),
)
), Preference.PreferenceGroup(
title = stringResource(R.string.background), preferenceItems = persistentListOf(
Preference.PreferenceItem.ColorPreference(
preference = store.field(SaveChromeCaptionStyle::windowColor) { newValue ->
copy(windowColor = newValue)
},
title = stringResource(R.string.subs_window_color),
icon = painterResource(R.drawable.imagesearch_roller_24px),
),
Preference.PreferenceItem.ColorPreference(
preference = store.field(SaveChromeCaptionStyle::backgroundColor) { newValue ->
copy(backgroundColor = newValue)
},
title = stringResource(R.string.subs_background_color),
icon = painterResource(R.drawable.format_color_fill_24px),
),
)
)
)
}
}

View file

@ -9,7 +9,6 @@ import android.os.Bundle
import android.text.Layout
import android.text.Spannable
import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.text.style.StyleSpan
import android.util.DisplayMetrics
import android.util.TypedValue
@ -19,8 +18,6 @@ import android.widget.Toast
import androidx.annotation.FontRes
import androidx.annotation.OptIn
import androidx.annotation.Px
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.mutableStateOf
import androidx.core.content.edit
import androidx.core.content.res.ResourcesCompat
import androidx.media3.common.text.Cue
@ -66,83 +63,30 @@ const val SUBTITLE_AUTO_SELECT_KEY = "subs_auto_select"
const val SUBTITLE_DOWNLOAD_KEY = "subs_auto_download"
@Serializable
enum class SubtitleFont(
@FontRes val resource: Int,
val label: String
) {
@JsonProperty("Trebuchet")
@SerialName("Trebuchet")
Trebuchet(R.font.trebuchet_ms, "Trebuchet MS"),
@JsonProperty("Netflix")
@SerialName("Netflix")
Netflix(R.font.netflix_sans, "Netflix Sans"),
@JsonProperty("Google")
@SerialName("Google")
Google(R.font.google_sans, "Google Sans"),
@JsonProperty("Open")
@SerialName("Open")
Open(R.font.open_sans, "Open Sans"),
@JsonProperty("Futura")
@SerialName("Futura")
Futura(R.font.futura, "Futura"),
@JsonProperty("Consola")
@SerialName("Consola")
Consola(R.font.consola, "Consola"),
@JsonProperty("Gotham")
@SerialName("Gotham")
Gotham(R.font.gotham, "Gotham"),
@JsonProperty("Lucida")
@SerialName("Lucida")
Lucida(R.font.lucida_grande, "Lucida Grande"),
@JsonProperty("STIX")
@SerialName("STIX")
STIX(R.font.stix_general, "STIX General"),
@JsonProperty("TimesNewRoman")
@SerialName("TimesNewRoman")
TimesNewRoman(R.font.times_new_roman, "Times New Roman"),
@JsonProperty("Verdana")
@SerialName("Verdana")
Verdana(R.font.verdana, "Verdana"),
@JsonProperty("Ubuntu")
@SerialName("Ubuntu")
Ubuntu(R.font.ubuntu_regular, "Ubuntu"),
@JsonProperty("Comic")
@SerialName("Comic")
Comic(R.font.comic_sans, "Comic Sans"),
@JsonProperty("Poppins")
@SerialName("Poppins")
Poppins(R.font.poppins_regular, "Poppins"),
@JsonProperty("Custom")
@SerialName("Custom")
Custom(0, "Custom"),
}
@Serializable
@Immutable
data class SaveCaptionStyle(
@JsonProperty("foregroundColor") @SerialName("foregroundColor") val foregroundColor: Int,
@JsonProperty("backgroundColor") @SerialName("backgroundColor") val backgroundColor: Int,
@JsonProperty("windowColor") @SerialName("windowColor") val windowColor: Int,
@JsonProperty("foregroundColor") @SerialName("foregroundColor") var foregroundColor: Int,
@JsonProperty("backgroundColor") @SerialName("backgroundColor") var backgroundColor: Int,
@JsonProperty("windowColor") @SerialName("windowColor") var windowColor: Int,
@OptIn(UnstableApi::class)
@JsonProperty("edgeType") @SerialName("edgeType") val edgeType: @CaptionStyleCompat.EdgeType Int,
@JsonProperty("edgeColor") @SerialName("edgeColor") val edgeColor: Int,
@JsonProperty("font") @SerialName("font") val font: SubtitleFont? = null,
@JsonProperty("typefaceFilePath") @SerialName("typefaceFilePath") val typefaceFilePath: String?,
@JsonProperty("elevation") @SerialName("elevation") val elevation: Int, // in dp
@JsonProperty("fixedTextSize") @SerialName("fixedTextSize") val fixedTextSize: Float?, // in sp
@Px @JsonProperty("edgeSize") @SerialName("edgeSize") val edgeSize: Float? = null,
@JsonProperty("removeCaptions") @SerialName("removeCaptions") val removeCaptions: Boolean = false,
@JsonProperty("removeBloat") @SerialName("removeBloat") val removeBloat: Boolean = true,
@JsonProperty("edgeType") @SerialName("edgeType") var edgeType: @CaptionStyleCompat.EdgeType Int,
@JsonProperty("edgeColor") @SerialName("edgeColor") var edgeColor: Int,
@FontRes @JsonProperty("typeface") @SerialName("typeface") var typeface: Int?,
@JsonProperty("typefaceFilePath") @SerialName("typefaceFilePath") var typefaceFilePath: String?,
@JsonProperty("elevation") @SerialName("elevation") var elevation: Int, // in dp
@JsonProperty("fixedTextSize") @SerialName("fixedTextSize") var fixedTextSize: Float?, // in sp
@Px @JsonProperty("edgeSize") @SerialName("edgeSize") var edgeSize: Float? = null,
@JsonProperty("removeCaptions") @SerialName("removeCaptions") var removeCaptions: Boolean = false,
@JsonProperty("removeBloat") @SerialName("removeBloat") var removeBloat: Boolean = true,
/** Apply caps lock to the text */
@JsonProperty("upperCase") @SerialName("upperCase") val upperCase: Boolean = false,
@JsonProperty("upperCase") @SerialName("upperCase") var upperCase: Boolean = false,
/** Apply bold to the text */
@JsonProperty("bold") @SerialName("bold") val bold: Boolean = false,
@JsonProperty("bold") @SerialName("bold") var bold: Boolean = false,
/** Apply italic to the text */
@JsonProperty("italic") @SerialName("italic") val italic: Boolean = false,
@JsonProperty("italic") @SerialName("italic") var italic: Boolean = false,
/** in px, background radius, aka how round the background (backgroundColor) on each row is */
@JsonProperty("backgroundRadius") @SerialName("backgroundRadius") val backgroundRadius: Float? = null,
@JsonProperty("backgroundRadius") @SerialName("backgroundRadius") var backgroundRadius: Float? = null,
/** The SSA_ALIGNMENT */
@JsonProperty("alignment") @SerialName("alignment") val alignment: Int? = null,
@JsonProperty("alignment") @SerialName("alignment") var alignment: Int? = null,
)
const val DEF_SUBS_ELEVATION = 20
@ -186,7 +130,7 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
}
fun Cue.Builder.applyStyle(style: SaveCaptionStyle): Cue.Builder {
val edgeSize = style.edgeSize ?: 0.0f
val edgeSize = style.edgeSize
/*
This is old code for only applying on non null
@ -204,18 +148,22 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
// instead we use the inherit size of the subtitle view
setTextSize(Cue.DIMEN_UNSET, Cue.TYPE_UNSET)
// 2. apply edge
text?.let { text ->
val textSpanBuilder = SpannableStringBuilder(text)
// 2. apply edge
if (edgeSize > 0.0f) {
textSpanBuilder.setSpan(
OutlineSpan(edgeSize), 0, textSpanBuilder.length,
val customSpan = SpannableString.valueOf(text)
if (edgeSize != null) {
customSpan.setSpan(
OutlineSpan(edgeSize), 0, customSpan.length,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
)
}
setText(customSpan)
}
// 3. apply bold + italic
text?.let { text ->
val customSpan = SpannableString.valueOf(text)
// 3. apply bold + italic
val typeface = when (style.bold to style.italic) {
(true to true) -> Typeface.BOLD_ITALIC
(true to false) -> Typeface.BOLD
@ -227,36 +175,39 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
}
if (typeface != Typeface.NORMAL) {
val styleSpan = StyleSpan(typeface)
textSpanBuilder.setSpan(
styleSpan, 0, textSpanBuilder.length,
customSpan.setSpan(
styleSpan, 0, customSpan.length,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
)
}
setText(customSpan)
}
// 4. apply radius
val radius = style.backgroundRadius ?: 0.0f
if (radius > 0.0f && style.backgroundColor != Color.TRANSPARENT) {
// 4. apply radius
text?.let { text ->
val customSpan = SpannableString.valueOf(text)
val radius = style.backgroundRadius
if (radius != null && style.backgroundColor != Color.TRANSPARENT) {
val styleSpan = RoundedBackgroundColorSpan(
style.backgroundColor,
this.textAlignment ?: Layout.Alignment.ALIGN_CENTER,
2.0F + radius * 0.5f,
radius
)
textSpanBuilder.setSpan(
styleSpan, 0, textSpanBuilder.length,
customSpan.setSpan(
styleSpan, 0, customSpan.length,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
)
}
setText(customSpan)
}
// 5. remove captions but ensure that styling is kept
// Just doing .replace removes all styling!
// 5. remove captions
text?.let { text ->
if (style.removeCaptions) {
for (match in captionRegex.findAll(text).toList().asReversed()) {
textSpanBuilder.delete(match.range.first, match.range.last + 1)
}
setText(text.replace(captionRegex, ""))
}
this.setText(textSpanBuilder)
}
// 6. set alignment
@ -266,31 +217,23 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
private fun Context.fromSaveToStyle(data: SaveCaptionStyle): CaptionStyleCompat {
return CaptionStyleCompat(
data.foregroundColor,
data.backgroundColor,
// we actually override with a custom span when backgroundRadius != null
if (data.backgroundRadius == null) data.backgroundColor else Color.TRANSPARENT,
data.windowColor,
data.edgeType,
data.edgeColor,
data.typefaceFilePath?.let {
try {
// RuntimeException: Font asset not found
// Fuck android, they have no good way to load a font from a uri without a copy
Typeface.createFromFile(File(it))
} catch (_: Exception) {
} catch (e: Exception) {
null
}
} ?: data.font?.let { font ->
if(font.resource != 0) {
try {
ResourcesCompat.getFont(
this,
font.resource
)
} catch (_ : Throwable) {
Typeface.SANS_SERIF
}
} else {
Typeface.SANS_SERIF
}
} ?: data.typeface?.let {
ResourcesCompat.getFont(
this,
it
)
}
?: Typeface.SANS_SERIF
)
@ -313,29 +256,25 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
}
}
private var cachedSubtitleStyle: SaveCaptionStyle? = null
fun Context.saveStyle(style: SaveCaptionStyle) {
if (subtitleStyleState.value !== style) {
subtitleStyleState.value = style
}
cachedSubtitleStyle = style
this.setKey(SUBTITLE_KEY, style)
}
val defaultSubtitleStyle = SaveCaptionStyle(
foregroundColor = getDefColor(0),
backgroundColor = getDefColor(2),
windowColor = getDefColor(3),
edgeType = CaptionStyleCompat.EDGE_TYPE_OUTLINE,
edgeColor = getDefColor(1),
font = null,
typefaceFilePath = null,
elevation = DEF_SUBS_ELEVATION,
fixedTextSize = null,
)
val subtitleStyleState =
mutableStateOf((getKey<SaveCaptionStyle>(SUBTITLE_KEY) ?: defaultSubtitleStyle))
fun getCurrentSavedStyle(): SaveCaptionStyle {
return subtitleStyleState.value
return cachedSubtitleStyle ?: (getKey<SaveCaptionStyle>(SUBTITLE_KEY) ?: SaveCaptionStyle(
foregroundColor = getDefColor(0),
backgroundColor = getDefColor(2),
windowColor = getDefColor(3),
edgeType = CaptionStyleCompat.EDGE_TYPE_OUTLINE,
edgeColor = getDefColor(1),
typeface = null,
typefaceFilePath = null,
elevation = DEF_SUBS_ELEVATION,
fixedTextSize = null,
)).also { cachedSubtitleStyle = it }
}
private fun Context.getSavedFonts(): List<File> {
@ -379,10 +318,10 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
private fun Context.setColor(id: Int, color: Int?) {
val realColor = color ?: getDefColor(id)
when (id) {
0 -> state = state.copy(foregroundColor = realColor)
1 -> state = state.copy(edgeColor = realColor)
2 -> state = state.copy(backgroundColor = realColor)
3 -> state = state.copy(windowColor = realColor)
0 -> state.foregroundColor = realColor
1 -> state.edgeColor = realColor
2 -> state.backgroundColor = realColor
3 -> state.windowColor = realColor
else -> Unit
}
@ -508,7 +447,7 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
false,
dismissCallback
) { index ->
state = state.copy(elevation = elevationTypes.map { it.first }[index])
state.elevation = elevationTypes.map { it.first }[index]
textView.context.updateState()
if (hide)
activity?.hideSystemUI()
@ -516,7 +455,7 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
}
subsSubtitleElevation.setOnLongClickListener {
state = state.copy(elevation = DEF_SUBS_ELEVATION)
state.elevation = DEF_SUBS_ELEVATION
it.context.updateState()
showToast(R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true
@ -539,14 +478,13 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
false,
dismissCallback
) { index ->
state =
state.copy(backgroundRadius = radiusTypes.map { it.first }[index]?.toFloat())
state.backgroundRadius = radiusTypes.map { it.first }[index]?.toFloat()
textView.context.updateState()
}
}
subsBackgroundRadius.setOnLongClickListener {
state = state.copy(backgroundRadius = null)
state.backgroundRadius = null
it.context.updateState()
showToast(R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true
@ -574,7 +512,7 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
false,
dismissCallback
) { index ->
state = state.copy(alignment = alignmentTypes.map { it.first }[index])
state.alignment = alignmentTypes.map { it.first }[index]
textView.context.updateState()
}
}
@ -602,13 +540,13 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
false,
dismissCallback
) { index ->
state = state.copy(edgeType = edgeTypes.map { it.first }[index])
state.edgeType = edgeTypes.map { it.first }[index]
textView.context.updateState()
}
}
subsEdgeType.setOnLongClickListener {
state = state.copy(edgeType = CaptionStyleCompat.EDGE_TYPE_OUTLINE)
state.edgeType = CaptionStyleCompat.EDGE_TYPE_OUTLINE
it.context.updateState()
showToast(R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true
@ -628,7 +566,7 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
false,
dismissCallback
) { index ->
state = state.copy(fixedTextSize = fontSizes.map { it.first }[index])
state.fixedTextSize = fontSizes.map { it.first }[index]
textView.context.updateState()
}
}
@ -647,47 +585,47 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
false,
dismissCallback
) { index ->
state = state.copy(edgeSize = fontSizes.map { it.first }[index])
state.edgeSize = fontSizes.map { it.first }[index]
textView.context.updateState()
}
}
subtitlesRemoveBloat.isChecked = state.removeBloat
subtitlesRemoveBloat.setOnCheckedChangeListener { _, b ->
state = state.copy(removeBloat = b)
state.removeBloat = b
}
subtitlesUppercase.isChecked = state.upperCase
subtitlesUppercase.setOnCheckedChangeListener { _, b ->
state = state.copy(upperCase = b)
state.upperCase = b
context?.updateState()
}
subtitlesRemoveCaptions.isChecked = state.removeCaptions
subtitlesRemoveCaptions.setOnCheckedChangeListener { _, b ->
state = state.copy(removeCaptions = b)
state.removeCaptions = b
}
subtitlesBold.isChecked = state.bold
subtitlesBold.setOnCheckedChangeListener { _, b ->
state = state.copy(bold = b)
state.bold = b
context?.updateState()
}
subtitlesItalic.isChecked = state.italic
subtitlesItalic.setOnCheckedChangeListener { _, b ->
state = state.copy(italic = b)
state.italic = b
context?.updateState()
}
subsFontSize.setOnLongClickListener { _ ->
state = state.copy(fixedTextSize = null)
state.fixedTextSize = null
context?.updateState()
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true
}
subsEdgeSize.setOnLongClickListener { _ ->
state = state.copy(edgeSize = null)
state.edgeSize = null
context?.updateState()
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true
@ -733,7 +671,7 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
savedFontTypes.indexOfFirst { it.absolutePath == state.typefaceFilePath }
.let { index ->
if (index == -1)
fontTypes.indexOfFirst { it.first == state.font?.resource }
fontTypes.indexOfFirst { it.first == state.typeface }
else index + fontTypes.size
}
@ -745,23 +683,20 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
false,
dismissCallback
) { index ->
state = if (index < fontTypes.size) {
state.copy(
font = SubtitleFont.entries.firstOrNull { it.resource == fontTypes[index].first },
typefaceFilePath = null
)
if (index < fontTypes.size) {
state.typeface = fontTypes[index].first
state.typefaceFilePath = null
} else {
state.copy(
typefaceFilePath = savedFontTypes[index - fontTypes.size].absolutePath,
font = null
)
state.typefaceFilePath = savedFontTypes[index - fontTypes.size].absolutePath
state.typeface = null
}
textView.context.updateState()
}
}
subsFont.setOnLongClickListener { textView ->
state = state.copy(font = null, typefaceFilePath = null)
state.typeface = null
state.typefaceFilePath = null
textView.context.updateState()
showToast(activity, R.string.subs_default_reset_toast, Toast.LENGTH_SHORT)
return@setOnLongClickListener true

View file

@ -1,8 +0,0 @@
package com.lagradost.cloudstream3.ui.subtitles
import com.lagradost.cloudstream3.utils.BaseComposeFragment
import com.lagradost.cloudstream3.utils.BaseDialogComposeFragment
import com.lagradost.cloudstream4.compose.Screen
class SubtitlesFragment2 : BaseComposeFragment(), Screen by SubtitlesScreen
class SubtitlesFragmentDialog2 : BaseDialogComposeFragment(), Screen by SubtitlesScreen

View file

@ -1,453 +0,0 @@
package com.lagradost.cloudstream3.ui.subtitles
import android.text.SpannableString
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.OptIn
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.SideEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.media3.common.text.Cue
import androidx.media3.common.util.UnstableApi
import androidx.media3.ui.CaptionStyleCompat
import androidx.media3.ui.SubtitleView
import coil3.compose.AsyncImage
import com.lagradost.cloudstream3.CloudStreamApp
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.ui.player.CustomDecoder
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.applyStyle
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.applyStyleEvent
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.defaultSubtitleStyle
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.saveStyle
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.setSubtitleViewStyle
import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.subtitleStyleState
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
import com.lagradost.cloudstream3.utils.AppUtils.toJsonLiteral
import com.lagradost.cloudstream3.utils.SubtitleHelper.languages
import com.lagradost.cloudstream4.compose.ActionDialog
import com.mihon.common.preference.AndroidPreferenceStore
import com.mihon.common.preference.DataPreferenceStore
import com.mihon.common.preference.StatePreferenceStore
import com.mihon.presentation.settings.Preference
import com.mihon.presentation.settings.SearchableSettings
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.persistentMapOf
import java.io.File
object SubtitlesScreen : SearchableSettings {
@Composable
override fun getTitleRes(): String = stringResource(R.string.subtitles_settings)
// For ux purposes we also want to show a diff of what will be reset
private val diff = arrayOf<Pair<Int, (SaveCaptionStyle) -> Any?>>(
R.string.subs_font to { style -> style.font },
R.string.subs_text_color to { state -> state.foregroundColor },
R.string.subs_font_size to { state -> state.fixedTextSize },
R.string.uppercase_all_subtitles to { state -> state.upperCase },
R.string.all_subtitles_bold to { state -> state.bold },
R.string.all_subtitles_italic to { state -> state.italic },
R.string.subs_edge_type to { state -> state.edgeType },
R.string.subs_outline_color to { state -> state.edgeColor },
R.string.subs_edge_size to { state -> state.edgeSize },
R.string.subs_window_color to { state -> state.windowColor },
R.string.subs_background_color to { state -> state.backgroundColor },
R.string.background_radius to { state -> state.backgroundRadius },
R.string.subs_subtitle_alignment to { state -> state.alignment },
R.string.subs_subtitle_elevation to { state -> state.elevation },
R.string.subtitles_remove_captions to { state -> state.removeCaptions },
R.string.subtitles_remove_bloat to { state -> state.removeBloat },
)
@Composable
fun <T> SetUpUndoBar(
diff: Array<Pair<Int, (T) -> Any?>>,
initialState: T,
currentState: MutableState<T>,
default: T
) {
var currentState by currentState
var dialogShown by remember { mutableStateOf(false) }
if (dialogShown) {
ActionDialog(
title = stringResource(R.string.subs_default_reset_toast),
// This can not be converted to joinToString due to stringResource being composable
text =
@Suppress("SimplifiableCallChain")
diff.filter { (_, f) -> f(default) != f(currentState) }
.map { (name, _) -> stringResource(name) }.joinToString(separator = "\n"),
confirmText = stringResource(R.string.reset_btn),
dismissText = stringResource(R.string.dismiss),
confirm = {
currentState = default
dialogShown = false
},
dismiss = {
dialogShown = false
})
}
// Undo, current -> initial last saved value
AnimatedVisibility(currentState != initialState) {
IconButton(onClick = {
currentState = initialState
}) {
Icon(
painter = painterResource(R.drawable.undo_24px),
contentDescription = stringResource(R.string.reset_btn),
tint = MaterialTheme.colorScheme.onBackground
)
}
}
// Reset, current -> default
AnimatedVisibility(currentState != default) {
IconButton(onClick = {
dialogShown = true
}) {
Icon(
painter = painterResource(R.drawable.reset_colors_24px),
contentDescription = stringResource(R.string.subs_default_reset_toast),
tint = MaterialTheme.colorScheme.onBackground
)
}
}
}
@Composable
override fun RowScope.AppBarAction() {
val initialState = remember { subtitleStyleState.value }
var state by subtitleStyleState
val context = LocalContext.current
SideEffect(state) {
// When we modify the state, we modify the stored data
context.saveStyle(state)
}
DisposableEffect(Unit) {
onDispose {
if (initialState != state) {
applyStyleEvent.invoke(state)
}
}
}
SetUpUndoBar(
diff = diff,
initialState = initialState,
currentState = subtitleStyleState,
default = defaultSubtitleStyle
)
}
private val sortedLanguages by lazy {
languages.map { it.IETF_tag to it.nameNextToFlagEmoji() }.sortedBy {
it.second.substringAfter("\u00a0").lowercase()
}.toMap()
}
@OptIn(UnstableApi::class)
@Composable
override fun getPreferences(): List<Preference> {
val store = StatePreferenceStore(subtitleStyleState)
val dataStore = DataPreferenceStore(LocalContext.current)
val androidStore = AndroidPreferenceStore(LocalContext.current)
val subtitlesFilterSubLang = androidStore.getBoolean("filter_sub_lang_key", false)
val autoSelectSubtitles = dataStore.getString(SUBTITLE_AUTO_SELECT_KEY, "en")
val downloadSubsLanguage =
dataStore.getObjectFromString(SUBTITLE_DOWNLOAD_KEY, setOf("en"), serializer = { obj ->
obj.toList().toJsonLiteral()
}, deserializer = { json ->
parseJson<List<String>>(json).toSet()
})
val subtitleFileSelector =
rememberLauncherForActivityResult(ActivityResultContracts.OpenDocument()) { uri ->
// It lies, it can be null if file manager quits.
if (uri == null) return@rememberLauncherForActivityResult
val context = CloudStreamApp.context ?: return@rememberLauncherForActivityResult
try {
val localFile = File(context.filesDir, "customfont.ttf")
localFile.delete()
localFile.createNewFile()
context.contentResolver?.openInputStream(uri)?.use { stream ->
stream.copyTo(localFile.outputStream())
}
store.state.value = store.state.value.copy(
font = SubtitleFont.Custom,
typefaceFilePath = localFile.absolutePath
)
} catch (t: Throwable) {
logError(t)
}
}
return persistentListOf(
Preference.PreferenceItem.CustomPreference(
title = stringResource(R.string.skip_type_preview), content = {
val state by store.state
val text = stringResource(R.string.subtitles_example_text)
val fixedText =
SpannableString.valueOf(if (state.upperCase) text.uppercase() else text)
Box(
modifier = Modifier
.fillMaxWidth()
.height(75.dp)
) {
AsyncImage(
contentDescription = stringResource(R.string.preview_background_img_des),
model = R.drawable.subtitles_preview_background,
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxSize()
)
AndroidView(modifier = Modifier.fillMaxSize(), factory = { context ->
SubtitleView(context).apply {
setSubtitleViewStyle(this, state, false)
this.setCues(
listOf(
Cue.Builder().setText(fixedText).applyStyle(state).build()
)
)
}
}, update = { view ->
setSubtitleViewStyle(view, state, false)
view.setCues(
listOf(
Cue.Builder().setText(fixedText).applyStyle(state).build()
)
)
})
}
}),
Preference.PreferenceGroup(
title = stringResource(R.string.subs_font),
preferenceItems = persistentListOf(
Preference.PreferenceItem.ListPreference(
preference = store.field(SaveCaptionStyle::font) { newValue -> copy(font = newValue, typefaceFilePath = null) },
icon = painterResource(R.drawable.font_download_24px),
title = stringResource(R.string.subs_font),
entries = mapOf(null to stringResource(R.string.normal)) + SubtitleFont.entries.associateWith { it.label },
onValueChanged = { value ->
if (value?.resource == 0) {
subtitleFileSelector.launch(
arrayOf(
"font/*",
)
)
false
} else {
true
}
}
),
Preference.PreferenceItem.ColorPreference(
preference = store.field(SaveCaptionStyle::foregroundColor) { newValue ->
copy(foregroundColor = newValue)
},
title = stringResource(R.string.subs_text_color),
icon = painterResource(R.drawable.format_color_text_24px),
),
Preference.PreferenceItem.SliderPreference(
preference = store.field(
get = { fixedTextSize?.toInt() ?: 25 },
set = { newValue -> copy(fixedTextSize = newValue.toFloat()) }
),
icon = painterResource(R.drawable.text_fields_24px),
title = stringResource(R.string.subs_font_size),
valueRange = 5..60
),
Preference.PreferenceItem.SwitchPreference(
preference = store.field(SaveCaptionStyle::upperCase) { newValue ->
copy(upperCase = newValue)
},
icon = painterResource(R.drawable.uppercase_24px),
title = stringResource(R.string.uppercase_all_subtitles),
),
Preference.PreferenceItem.SwitchPreference(
preference = store.field(SaveCaptionStyle::bold) { newValue -> copy(bold = newValue) },
icon = painterResource(R.drawable.format_bold_24px),
title = stringResource(R.string.all_subtitles_bold),
),
Preference.PreferenceItem.SwitchPreference(
preference = store.field(SaveCaptionStyle::italic) { newValue -> copy(italic = newValue) },
icon = painterResource(R.drawable.format_italic_24px),
title = stringResource(R.string.all_subtitles_italic),
),
)
),
Preference.PreferenceGroup(
title = stringResource(R.string.subs_edge),
preferenceItems = persistentListOf(
Preference.PreferenceItem.ListPreference(
icon = painterResource(R.drawable.shadow_24px),
title = stringResource(R.string.subs_edge_type),
preference = store.field(SaveCaptionStyle::edgeType) { newValue ->
copy(edgeType = newValue)
},
entries = persistentMapOf(
CaptionStyleCompat.EDGE_TYPE_NONE to stringResource(R.string.subtitles_none),
CaptionStyleCompat.EDGE_TYPE_OUTLINE to stringResource(R.string.subtitles_outline),
CaptionStyleCompat.EDGE_TYPE_DEPRESSED to stringResource(R.string.subtitles_depressed),
CaptionStyleCompat.EDGE_TYPE_DROP_SHADOW to stringResource(R.string.subtitles_shadow),
CaptionStyleCompat.EDGE_TYPE_RAISED to stringResource(R.string.subtitles_raised),
)
),
Preference.PreferenceItem.ColorPreference(
//enabled = state.edgeType != CaptionStyleCompat.EDGE_TYPE_NONE,
preference = store.field(SaveCaptionStyle::edgeColor) { newValue ->
copy(edgeColor = newValue)
},
title = stringResource(R.string.subs_outline_color),
icon = painterResource(R.drawable.border_color_24px),
),
Preference.PreferenceItem.SliderPreference(
preference = store.field(
get = { edgeSize?.toInt() ?: 0 },
set = { newValue -> copy(edgeSize = newValue.toFloat()) }
),
//enabled = state.edgeType == CaptionStyleCompat.EDGE_TYPE_OUTLINE,
icon = painterResource(R.drawable.shadow_add_24px),
title = stringResource(R.string.subs_edge_size),
valueRange = 0..60,
)
)
),
Preference.PreferenceGroup(
title = stringResource(R.string.background),
preferenceItems = persistentListOf(
Preference.PreferenceItem.ColorPreference(
preference = store.field(SaveCaptionStyle::windowColor) { newValue ->
copy(windowColor = newValue)
},
title = stringResource(R.string.subs_window_color),
icon = painterResource(R.drawable.imagesearch_roller_24px),
),
Preference.PreferenceItem.ColorPreference(
preference = store.field(SaveCaptionStyle::backgroundColor) { newValue ->
copy(backgroundColor = newValue)
},
title = stringResource(R.string.subs_background_color),
icon = painterResource(R.drawable.format_color_fill_24px),
),
Preference.PreferenceItem.SliderPreference(
preference = store.field(
get = { backgroundRadius?.toInt() ?: 0 },
set = { newValue -> copy(backgroundRadius = newValue.toFloat()) }
),
icon = painterResource(R.drawable.rounded_corner_24px),
title = stringResource(R.string.background_radius),
valueRange = 0..50,
steps = 9,
)
)
),
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_player_layout),
preferenceItems = persistentListOf(
Preference.PreferenceItem.ListPreference(
preference = store.field(SaveCaptionStyle::alignment) { newValue ->
copy(alignment = newValue)
},
icon = painterResource(R.drawable.format_align_center_24px),
title = stringResource(R.string.subs_subtitle_alignment),
entries = persistentMapOf(
null to stringResource(R.string.automatic),
CustomDecoder.SSA_ALIGNMENT_BOTTOM_LEFT to stringResource(R.string.bottom_left),
CustomDecoder.SSA_ALIGNMENT_BOTTOM_CENTER to stringResource(R.string.bottom_center),
CustomDecoder.SSA_ALIGNMENT_BOTTOM_RIGHT to stringResource(R.string.bottom_right),
CustomDecoder.SSA_ALIGNMENT_MIDDLE_LEFT to stringResource(R.string.middle_left),
CustomDecoder.SSA_ALIGNMENT_MIDDLE_CENTER to stringResource(R.string.middle_center),
CustomDecoder.SSA_ALIGNMENT_MIDDLE_RIGHT to stringResource(R.string.middle_right),
CustomDecoder.SSA_ALIGNMENT_TOP_LEFT to stringResource(R.string.top_left),
CustomDecoder.SSA_ALIGNMENT_TOP_CENTER to stringResource(R.string.top_center),
CustomDecoder.SSA_ALIGNMENT_TOP_RIGHT to stringResource(R.string.top_right),
)
),
Preference.PreferenceItem.SliderPreference(
preference = store.field(SaveCaptionStyle::elevation) { newValue ->
copy(elevation = newValue)
},
title = stringResource(R.string.subs_subtitle_elevation),
icon = painterResource(R.drawable.text_select_move_up_24px),
valueRange = 0..400,
steps = 39
),
)
),
Preference.PreferenceGroup(
title = stringResource(R.string.extension_language),
preferenceItems = persistentListOf(
Preference.PreferenceItem.ListPreference(
icon = painterResource(R.drawable.language_korean_latin_24px),
title = stringResource(R.string.subs_auto_select_language),
preference = autoSelectSubtitles,
entries = mapOf(
"None" to stringResource(R.string.none)
) + sortedLanguages,
),
Preference.PreferenceItem.MultiSelectListPreference(
icon = painterResource(R.drawable.language_download2),
title = stringResource(R.string.subs_download_languages),
preference = downloadSubsLanguage,
entries = mapOf(
"None" to stringResource(R.string.none)
) + sortedLanguages,
),
Preference.PreferenceItem.SwitchPreference(
preference = subtitlesFilterSubLang,
icon = painterResource(R.drawable.filter_alt_24px),
title = stringResource(R.string.subtitles_filter_lang),
),
)
),
Preference.PreferenceGroup(
title = stringResource(R.string.pref_category_ui_features),
preferenceItems = persistentListOf(
Preference.PreferenceItem.SwitchPreference(
preference = store.field(SaveCaptionStyle::removeCaptions) { newValue ->
copy(removeCaptions = newValue)
},
icon = painterResource(R.drawable.closed_caption_24px),
title = stringResource(R.string.subtitles_remove_captions),
subtitle = "[Knocking on door] Hello → Hello",
),
Preference.PreferenceItem.SwitchPreference(
preference = store.field(SaveCaptionStyle::removeBloat) { newValue ->
copy(removeBloat = newValue)
},
icon = painterResource(R.drawable.text_ad_off_24px),
title = stringResource(R.string.subtitles_remove_bloat),
),
)
),
)
}
}

View file

@ -86,7 +86,6 @@ import com.lagradost.cloudstream3.utils.FillerEpisodeCheck.toClassDir
import com.lagradost.cloudstream3.utils.JsUnpacker.Companion.load
import com.lagradost.cloudstream3.utils.UIHelper.navigate
import com.lagradost.cloudstream3.utils.downloader.DownloadObjects
import com.lagradost.cloudstream4.AppSettings
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import okhttp3.Cache
@ -482,14 +481,14 @@ object AppContextUtils {
fun Context.filterSearchResultByFilmQuality(data: List<SearchResponse>): List<SearchResponse> {
// Filter results omitting entries with certain quality
if (data.isNotEmpty()) {
val filteredSearchQuality = AppSettings(this).ui.filterQuality.get() /*PreferenceManager.getDefaultSharedPreferences(this)
val filteredSearchQuality = PreferenceManager.getDefaultSharedPreferences(this)
?.getStringSet(getString(R.string.pref_filter_search_quality_key), setOf())
?.mapNotNull { entry ->
entry.toIntOrNull() ?: return@mapNotNull null
} ?: listOf()*/
} ?: listOf()
if (filteredSearchQuality.isNotEmpty()) {
return data.filter { item ->
val searchQualVal = item.quality //?.ordinal ?: -1
val searchQualVal = item.quality?.ordinal ?: -1
//Log.i("filterSearch", "QuickSearch item => ${item.toJson()}")
!filteredSearchQuality.contains(searchQualVal)
}
@ -501,17 +500,17 @@ object AppContextUtils {
fun Context.filterHomePageListByFilmQuality(data: HomePageList): HomePageList {
// Filter results omitting entries with certain quality
if (data.list.isNotEmpty()) {
val filteredSearchQuality = AppSettings(this).ui.filterQuality.get() /*PreferenceManager.getDefaultSharedPreferences(this)
val filteredSearchQuality = PreferenceManager.getDefaultSharedPreferences(this)
?.getStringSet(getString(R.string.pref_filter_search_quality_key), setOf())
?.mapNotNull { entry ->
entry.toIntOrNull() ?: return@mapNotNull null
} ?: listOf()*/
} ?: listOf()
if (filteredSearchQuality.isNotEmpty()) {
return HomePageList(
name = data.name,
isHorizontalImages = data.isHorizontalImages,
list = data.list.filter { item ->
val searchQualVal = item.quality //?.ordinal ?: -1
val searchQualVal = item.quality?.ordinal ?: -1
//Log.i("filterSearch", "QuickSearch item => ${item.toJson()}")
!filteredSearchQuality.contains(searchQualVal)
}

View file

@ -1,6 +1,5 @@
package com.lagradost.cloudstream3.utils
import android.app.Activity
import android.content.Context
import android.net.Uri
import android.widget.Toast
@ -283,7 +282,7 @@ object BackupUtils {
}
}
fun Activity.restorePrompt() {
fun FragmentActivity.restorePrompt() {
runOnUiThread {
try {
restoreFileSelector?.launch(

View file

@ -1,86 +0,0 @@
package com.lagradost.cloudstream3.utils
import android.content.res.Configuration
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.ui.settings.Globals.EMULATOR
import com.lagradost.cloudstream3.ui.settings.Globals.TV
import com.lagradost.cloudstream3.ui.settings.Globals.isLandscape
import com.lagradost.cloudstream3.ui.settings.Globals.isLayout
import com.lagradost.cloudstream3.utils.UIHelper.fixSystemBarsPadding
import com.lagradost.cloudstream4.compose.Screen
import com.lagradost.cloudstream4.compose.createComposeView
abstract class BaseComposeFragment : Fragment(), Screen {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View = createComposeView(inflater, container, savedInstanceState)
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
this.view?.let { view ->
fixSystemBarsPadding(
view,
padLeft = isLayout(TV or EMULATOR),
padBottom = isLandscape()
)
}
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
fixSystemBarsPadding(
view,
padLeft = isLayout(TV or EMULATOR),
padBottom = isLandscape()
)
}
}
abstract class BaseDialogComposeFragment : DialogFragment(), Screen {
var systemBarsAddPadding = isLayout(TV or EMULATOR)
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View = createComposeView(inflater, container, savedInstanceState)
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
dialog?.window?.decorView?.let { view ->
fixSystemBarsPadding(
view,
padLeft = systemBarsAddPadding,
padBottom = systemBarsAddPadding || isLandscape()
)
}
}
override fun onStart() {
super.onStart()
dialog?.window?.setWindowAnimations(R.style.DialogFullscreenPlayer)
}
override fun getTheme(): Int {
return R.style.DialogFullscreenPlayer
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
dialog?.window?.decorView?.let { view ->
fixSystemBarsPadding(
view,
padLeft = systemBarsAddPadding,
padBottom = systemBarsAddPadding || isLandscape()
)
}
}
}

View file

@ -181,11 +181,11 @@ object DataStore {
}
fun <T : Any> Context.getKey(path: String, valueType: Class<T>): T? {
return try {
try {
val json: String = getSharedPrefs().getString(path, null) ?: return null
parseJson(json, valueType.kotlin)
} catch (_: Exception) {
null
return parseJson(json, valueType.kotlin)
} catch (e: Exception) {
return null
}
}
@ -193,37 +193,21 @@ object DataStore {
setKey(getFolderName(folder, path), value)
}
@Deprecated(
message = "Use parseJson<T>(this) directly instead.",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith(
expression = "parseJson<T>(this)",
imports = ["com.lagradost.cloudstream3.utils.AppUtils.parseJson"],
),
)
inline fun <reified T : Any> String.toKotlinObject(): T {
return parseJson(this)
}
@Deprecated(
message = "Use parseJson<T>(this) directly instead.",
level = DeprecationLevel.WARNING,
replaceWith = ReplaceWith(
expression = "parseJson<T>(this)",
imports = ["com.lagradost.cloudstream3.utils.AppUtils.parseJson"],
),
)
fun <T : Any> String.toKotlinObject(valueType: Class<T>): T {
return parseJson(this, valueType.kotlin)
}
// GET KEY GIVEN PATH AND DEFAULT VALUE, NULL IF ERROR
inline fun <reified T : Any> Context.getKey(path: String, defVal: T?): T? {
return try {
try {
val json: String = getSharedPrefs().getString(path, null) ?: return defVal
parseJson<T>(json)
} catch (_: Exception) {
null
return json.toKotlinObject()
} catch (e: Exception) {
return null
}
}

View file

@ -33,8 +33,6 @@ import com.lagradost.cloudstream3.ui.result.VideoWatchState
import com.lagradost.cloudstream3.utils.AppContextUtils.filterProviderByPreferredMedia
import com.lagradost.cloudstream3.utils.downloader.DownloadObjects
import com.lagradost.cloudstream3.utils.serializers.WriteOnlySerializer
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.KeepGeneratedSerializer
import kotlinx.serialization.SerialName
@ -182,10 +180,6 @@ object DataStoreHelper {
var selectedKeyIndex by PreferenceDelegate("$TAG/account_key_index", 0)
val currentAccount: String get() = selectedKeyIndex.toString()
private val _selectedAccountNumberFlow = MutableStateFlow(0)
/** What account instance we are on, this number changes whenever anything about local accounts changes */
val selectedAccountNumberFlow : StateFlow<Int> = _selectedAccountNumberFlow
/**
* Get or set the current account homepage.
* Setting this does not automatically reload the homepage.
@ -213,7 +207,6 @@ object DataStoreHelper {
// This is not a new account, and the homepage has changed, reload it
MainActivity.reloadHomeEvent(true)
}
_selectedAccountNumberFlow.value += 1
}
fun getDefaultAccount(context: Context): Account {

View file

@ -63,7 +63,7 @@ object BatteryOptimizationChecker {
return isRestricted && isOptimizedNotShown && isLayout(PHONE)
}
fun Context.showRequestIgnoreBatteryOptDialog() {
private fun Context.showRequestIgnoreBatteryOptDialog() {
try {
val intent = Intent().apply {
action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS

View file

@ -149,12 +149,10 @@ object TvChannelUtils {
.setInputId(inputId)
.build()
val channelUri = runCatching {
context.contentResolver.insert(
TvContractCompat.Channels.CONTENT_URI,
channel.toContentValues()
)
}.getOrNull()
val channelUri = context.contentResolver.insert(
TvContractCompat.Channels.CONTENT_URI,
channel.toContentValues()
)
channelUri?.let {
val channelId = ContentUris.parseId(it)

View file

@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.AnimeLoadResponse
import com.lagradost.cloudstream3.ErrorLoadingException
import com.lagradost.cloudstream3.LoadResponse
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.TvSeriesLoadResponse
import com.lagradost.cloudstream3.TvType
import com.lagradost.cloudstream3.app
@ -26,7 +25,6 @@ import java.security.MessageDigest
class AnimeSkipAuth : AuthAPI() {
override val name = "AnimeSkip"
override val icon: Int = R.drawable.animeskip
override val inAppLoginRequirement: AuthLoginRequirement =
AuthLoginRequirement(password = true, username = true)
override val idPrefix = "anime-skip"

View file

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:color="?attr/black"/>
<item android:color="?attr/textColor"/>
</selector>

View file

@ -1,11 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal"
android:autoMirrored="true">
<path
android:fillColor="@android:color/white"
android:pathData="M200,840Q167,840 143.5,816.5Q120,793 120,760L120,200Q120,167 143.5,143.5Q167,120 200,120L760,120Q793,120 816.5,143.5Q840,167 840,200L840,760Q840,793 816.5,816.5Q793,840 760,840L200,840ZM200,760L760,760Q760,760 760,760Q760,760 760,760L760,200Q760,200 760,200Q760,200 760,200L200,200Q200,200 200,200Q200,200 200,200L200,760Q200,760 200,760Q200,760 200,760ZM200,200L200,200Q200,200 200,200Q200,200 200,200L200,760Q200,760 200,760Q200,760 200,760L200,760Q200,760 200,760Q200,760 200,760L200,200Q200,200 200,200Q200,200 200,200ZM320,680L520,680Q537,680 548.5,668.5Q560,657 560,640Q560,623 548.5,611.5Q537,600 520,600L320,600Q303,600 291.5,611.5Q280,623 280,640Q280,657 291.5,668.5Q303,680 320,680ZM320,520L640,520Q657,520 668.5,508.5Q680,497 680,480Q680,463 668.5,451.5Q657,440 640,440L320,440Q303,440 291.5,451.5Q280,463 280,480Q280,497 291.5,508.5Q303,520 320,520ZM320,360L640,360Q657,360 668.5,348.5Q680,337 680,320Q680,303 668.5,291.5Q657,280 640,280L320,280Q303,280 291.5,291.5Q280,303 280,320Q280,337 291.5,348.5Q303,360 320,360Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M680,600L600,600Q583,600 571.5,611.5Q560,623 560,640Q560,657 571.5,668.5Q583,680 600,680L720,680Q737,680 748.5,668.5Q760,657 760,640L760,520Q760,503 748.5,491.5Q737,480 720,480Q703,480 691.5,491.5Q680,503 680,520L680,600ZM280,360L360,360Q377,360 388.5,348.5Q400,337 400,320Q400,303 388.5,291.5Q377,280 360,280L240,280Q223,280 211.5,291.5Q200,303 200,320L200,440Q200,457 211.5,468.5Q223,480 240,480Q257,480 268.5,468.5Q280,457 280,440L280,360ZM160,800Q127,800 103.5,776.5Q80,753 80,720L80,240Q80,207 103.5,183.5Q127,160 160,160L800,160Q833,160 856.5,183.5Q880,207 880,240L880,720Q880,753 856.5,776.5Q833,800 800,800L160,800ZM160,720L800,720Q800,720 800,720Q800,720 800,720L800,240Q800,240 800,240Q800,240 800,240L160,240Q160,240 160,240Q160,240 160,240L160,720Q160,720 160,720Q160,720 160,720ZM160,720Q160,720 160,720Q160,720 160,720L160,240Q160,240 160,240Q160,240 160,240L160,240Q160,240 160,240Q160,240 160,240L160,720Q160,720 160,720Q160,720 160,720Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M148,812Q129,831 104.5,820.5Q80,810 80,783L80,520Q80,503 91.5,491.5Q103,480 120,480Q137,480 148.5,491.5Q160,503 160,520L160,685L194,651Q199,646 206.5,643Q214,640 222,640L280,640Q297,640 308.5,651.5Q320,663 320,680Q320,697 308.5,708.5Q297,720 280,720L240,720L148,812ZM680,720Q663,720 651.5,708.5Q640,697 640,680Q640,663 651.5,651.5Q663,640 680,640L800,640Q800,640 800,640Q800,640 800,640L800,519Q800,502 811.5,491Q823,480 840,480Q857,480 868.5,491.5Q880,503 880,520L880,640Q880,673 856.5,696.5Q833,720 800,720L680,720ZM451.5,588.5Q440,577 440,560L440,240Q440,223 451.5,211.5Q463,200 480,200Q497,200 508.5,211.5Q520,223 520,240L520,560Q520,577 508.5,588.5Q497,600 480,600Q463,600 451.5,588.5ZM291.5,508.5Q280,497 280,480L280,320Q280,303 291.5,291.5Q303,280 320,280Q337,280 348.5,291.5Q360,303 360,320L360,480Q360,497 348.5,508.5Q337,520 320,520Q303,520 291.5,508.5ZM611.5,468.5Q600,457 600,440L600,360Q600,343 611.5,331.5Q623,320 640,320Q657,320 668.5,331.5Q680,343 680,360L680,440Q680,457 668.5,468.5Q657,480 640,480Q623,480 611.5,468.5ZM120,320Q103,320 91.5,308.5Q80,297 80,280L80,160Q80,127 103.5,103.5Q127,80 160,80L280,80Q297,80 308.5,91.5Q320,103 320,120Q320,137 308.5,148.5Q297,160 280,160L160,160Q160,160 160,160Q160,160 160,160L160,281Q160,298 148.5,309Q137,320 120,320ZM811.5,308.5Q800,297 800,280L800,160Q800,160 800,160Q800,160 800,160L680,160Q663,160 651.5,148.5Q640,137 640,120Q640,103 651.5,91.5Q663,80 680,80L800,80Q833,80 856.5,103.5Q880,127 880,160L880,281Q880,298 868.5,309Q857,320 840,320Q823,320 811.5,308.5Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M240,482Q240,498 242,513.5Q244,529 249,544Q254,561 248,576.5Q242,592 227,599Q211,607 195.5,600.5Q180,594 175,577Q167,554 163.5,530Q160,506 160,482Q160,348 253,254Q346,160 480,160L487,160L451,124Q440,113 440,96Q440,79 451,68Q462,57 479,57Q496,57 507,68L611,172Q623,184 623,200Q623,216 611,228L507,332Q496,343 479,343Q462,343 451,332Q440,321 440,304Q440,287 451,276L487,240L480,240Q380,240 310,310.5Q240,381 240,482ZM720,478Q720,462 718,446.5Q716,431 711,416Q706,399 712,383.5Q718,368 733,361Q749,353 764.5,359.5Q780,366 785,383Q793,406 796.5,430Q800,454 800,478Q800,612 707,706Q614,800 480,800L473,800L509,836Q520,847 520,864Q520,881 509,892Q498,903 481,903Q464,903 453,892L349,788Q337,776 337,760Q337,744 349,732L453,628Q464,617 481,617Q498,617 509,628Q520,639 520,656Q520,673 509,684L473,720L480,720Q580,720 650,649.5Q720,579 720,478Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M320,880Q303,880 291.5,868.5Q280,857 280,840L280,200Q280,183 291.5,171.5Q303,160 320,160L400,160L400,120Q400,103 411.5,91.5Q423,80 440,80L520,80Q537,80 548.5,91.5Q560,103 560,120L560,160L640,160Q657,160 668.5,171.5Q680,183 680,200L680,840Q680,857 668.5,868.5Q657,880 640,880L320,880ZM360,800L600,800L600,240L360,240L360,800ZM360,800L360,800L600,800L600,800L360,800ZM508.5,548.5Q520,537 520,520L520,360Q520,343 508.5,331.5Q497,320 480,320Q463,320 451.5,331.5Q440,343 440,360L440,520Q440,537 451.5,548.5Q463,560 480,560Q497,560 508.5,548.5ZM480,720Q497,720 508.5,708.5Q520,697 520,680Q520,663 508.5,651.5Q497,640 480,640Q463,640 451.5,651.5Q440,663 440,680Q440,697 451.5,708.5Q463,720 480,720Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M160,960Q127,960 103.5,936.5Q80,913 80,880Q80,847 103.5,823.5Q127,800 160,800L800,800Q833,800 856.5,823.5Q880,847 880,880Q880,913 856.5,936.5Q833,960 800,960L160,960ZM240,640L296,640L608,329L579,300L551,272L240,584L240,640ZM160,680L160,567Q160,559 163,551.5Q166,544 172,538L608,103Q619,92 633.5,86Q648,80 664,80Q680,80 695,86Q710,92 722,104L777,160Q789,171 794.5,186Q800,201 800,217Q800,232 794.5,246.5Q789,261 777,273L342,708Q336,714 328.5,717Q321,720 313,720L200,720Q183,720 171.5,708.5Q160,697 160,680ZM720,216L720,216L664,160L664,160L720,216ZM608,329L579,300L551,272L551,272L608,329Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M360,600Q260,600 190,530Q120,460 120,360Q120,340 123,320Q126,300 134,282Q139,272 146.5,267Q154,262 163,260Q172,258 181.5,260.5Q191,263 199,271L304,376L376,304L271,199Q263,191 260.5,181.5Q258,172 260,163Q262,154 267,146.5Q272,139 282,134Q300,126 320,123Q340,120 360,120Q460,120 530,190Q600,260 600,360Q600,383 596,403.5Q592,424 584,444L786,644Q815,673 815,715Q815,757 786,786Q757,815 715,815Q673,815 644,785L444,584Q424,592 403.5,596Q383,600 360,600ZM360,520Q386,520 412,512Q438,504 459,487L702,730Q707,735 715.5,734.5Q724,734 729,729Q734,724 734,715.5Q734,707 729,702L486,460Q504,440 512,413.5Q520,387 520,360Q520,300 481.5,255.5Q443,211 386,202L460,276Q472,288 472,304Q472,320 460,332L332,460Q320,472 304,472Q288,472 276,460L202,386Q211,443 255.5,481.5Q300,520 360,520ZM469,469Q469,469 469,469Q469,469 469,469L469,469Q469,469 469,469Q469,469 469,469L469,469Q469,469 469,469Q469,469 469,469L469,469Q469,469 469,469Q469,469 469,469Q469,469 469,469Q469,469 469,469L469,469Q469,469 469,469Q469,469 469,469Q469,469 469,469Q469,469 469,469L469,469Q469,469 469,469Q469,469 469,469Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480ZM880,240L880,720Q880,753 856.5,776.5Q833,800 800,800L638,800Q621,800 609.5,788.5Q598,777 598,760Q598,743 609.5,731.5Q621,720 638,720L800,720Q800,720 800,720Q800,720 800,720L800,240Q800,240 800,240Q800,240 800,240L160,240Q160,240 160,240Q160,240 160,240L160,246Q160,263 148.5,274.5Q137,286 120,286Q103,286 91.5,274.5Q80,263 80,246L80,240Q80,207 103.5,183.5Q127,160 160,160L800,160Q833,160 856.5,183.5Q880,207 880,240ZM320,800Q304,800 292,790.5Q280,781 277,765Q266,702 220.5,658Q175,614 112,603Q97,601 88.5,588.5Q80,576 80,560Q80,543 91,531.5Q102,520 117,522Q211,534 277.5,601Q344,668 357,762Q359,778 348,789Q337,800 320,800ZM480,800Q463,800 451.5,789Q440,778 438,761Q424,633 333.5,544Q243,455 115,442Q99,440 89.5,428Q80,416 80,400Q80,383 90.5,371Q101,359 116,361Q277,374 390,486Q503,598 518,759Q520,776 508.5,788Q497,800 480,800ZM130,800Q109,800 94.5,785.5Q80,771 80,750Q80,729 94.5,714.5Q109,700 130,700Q151,700 165.5,714.5Q180,729 180,750Q180,771 165.5,785.5Q151,800 130,800Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M480,536L284,732Q273,743 256,743Q239,743 228,732Q217,721 217,704Q217,687 228,676L424,480L228,284Q217,273 217,256Q217,239 228,228Q239,217 256,217Q273,217 284,228L480,424L676,228Q687,217 704,217Q721,217 732,228Q743,239 743,256Q743,273 732,284L536,480L732,676Q743,687 743,704Q743,721 732,732Q721,743 704,743Q687,743 676,732L480,536Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M200,800Q167,800 143.5,776.5Q120,753 120,720L120,240Q120,207 143.5,183.5Q167,160 200,160L760,160Q793,160 816.5,183.5Q840,207 840,240L840,720Q840,753 816.5,776.5Q793,800 760,800L200,800ZM200,720L760,720Q760,720 760,720Q760,720 760,720L760,240Q760,240 760,240Q760,240 760,240L200,240Q200,240 200,240Q200,240 200,240L200,720Q200,720 200,720Q200,720 200,720ZM280,600L400,600Q417,600 428.5,588.5Q440,577 440,560L440,540Q440,531 434,525Q428,519 419,519L401,519Q392,519 386,525Q380,531 380,540L380,540Q380,540 380,540Q380,540 380,540L300,540Q300,540 300,540Q300,540 300,540L300,420Q300,420 300,420Q300,420 300,420L380,420Q380,420 380,420Q380,420 380,420L380,420Q380,429 386,435Q392,441 401,441L419,441Q428,441 434,435Q440,429 440,420L440,400Q440,383 428.5,371.5Q417,360 400,360L280,360Q263,360 251.5,371.5Q240,383 240,400L240,560Q240,577 251.5,588.5Q263,600 280,600ZM680,360L560,360Q543,360 531.5,371.5Q520,383 520,400L520,560Q520,577 531.5,588.5Q543,600 560,600L680,600Q697,600 708.5,588.5Q720,577 720,560L720,540Q720,531 714,525Q708,519 699,519L681,519Q672,519 666,525Q660,531 660,540L660,540Q660,540 660,540Q660,540 660,540L580,540Q580,540 580,540Q580,540 580,540L580,420Q580,420 580,420Q580,420 580,420L660,420Q660,420 660,420Q660,420 660,420L660,420Q660,429 666,435Q672,441 681,441L699,441Q708,441 714,435Q720,429 720,420L720,400Q720,383 708.5,371.5Q697,360 680,360ZM200,720Q200,720 200,720Q200,720 200,720L200,240Q200,240 200,240Q200,240 200,240L200,240Q200,240 200,240Q200,240 200,240L200,720Q200,720 200,720Q200,720 200,720Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M346,820L100,574Q90,564 85,552Q80,540 80,527Q80,514 85,502Q90,490 100,480L330,251L255,176Q242,163 241.5,145Q241,127 254,113Q267,99 286,99Q305,99 319,113L686,480Q696,490 700.5,502Q705,514 705,527Q705,540 700.5,552Q696,564 686,574L440,820Q430,830 418,835Q406,840 393,840Q380,840 368,835Q356,830 346,820ZM393,314L179,528Q179,528 179,528Q179,528 179,528L607,528Q607,528 607,528Q607,528 607,528L393,314ZM792,840Q756,840 731,814.5Q706,789 706,752Q706,725 719.5,701Q733,677 750,654L769,630Q778,619 792.5,618.5Q807,618 816,629L836,654Q852,677 866,701Q880,725 880,752Q880,789 854,814.5Q828,840 792,840Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M714,798L537,621L621,537L798,714Q815,731 815,756Q815,781 798,798Q781,815 756,815Q731,815 714,798ZM145,756Q145,731 162,714L396,480L328,412L328,412Q317,423 300,423Q283,423 272,412L249,389L249,479Q249,493 237,498Q225,503 215,493L106,384Q96,374 101,362Q106,350 120,350L210,350L188,328Q176,316 176,300Q176,284 188,272L302,158Q322,138 345,129Q368,120 392,120Q412,120 429.5,126Q447,132 464,144Q472,149 472.5,158Q473,167 466,174L390,250L412,272Q423,283 423,300Q423,317 412,328L412,328L480,396L570,306Q566,295 563.5,283Q561,271 561,259Q561,200 601.5,159.5Q642,119 701,119Q709,119 716,119.5Q723,120 730,122Q739,125 741.5,134.5Q744,144 737,151L672,216Q666,222 666,230Q666,238 672,244L716,288Q722,294 730,294Q738,294 744,288L809,223Q816,216 825.5,218Q835,220 838,230Q840,237 840.5,244Q841,251 841,259Q841,318 800.5,358.5Q760,399 701,399Q689,399 677,397Q665,395 654,390L246,798Q229,815 204,815Q179,815 162,798Q145,781 145,756Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M360,720Q327,720 303.5,696.5Q280,673 280,640L280,160Q280,127 303.5,103.5Q327,80 360,80L720,80Q753,80 776.5,103.5Q800,127 800,160L800,640Q800,673 776.5,696.5Q753,720 720,720L360,720ZM360,640L720,640Q720,640 720,640Q720,640 720,640L720,160Q720,160 720,160Q720,160 720,160L360,160Q360,160 360,160Q360,160 360,160L360,640Q360,640 360,640Q360,640 360,640ZM540,400Q540,400 540,400Q540,400 540,400L540,400Q540,400 540,400Q540,400 540,400L540,400Q540,400 540,400Q540,400 540,400L540,400Q540,400 540,400Q540,400 540,400ZM131.5,308.5Q120,297 120,280Q120,263 131.5,251.5Q143,240 160,240Q177,240 188.5,251.5Q200,263 200,280Q200,297 188.5,308.5Q177,320 160,320Q143,320 131.5,308.5ZM131.5,448.5Q120,437 120,420Q120,403 131.5,391.5Q143,380 160,380Q177,380 188.5,391.5Q200,403 200,420Q200,437 188.5,448.5Q177,460 160,460Q143,460 131.5,448.5ZM131.5,588.5Q120,577 120,560Q120,543 131.5,531.5Q143,520 160,520Q177,520 188.5,531.5Q200,543 200,560Q200,577 188.5,588.5Q177,600 160,600Q143,600 131.5,588.5ZM131.5,728.5Q120,717 120,700Q120,683 131.5,671.5Q143,660 160,660Q177,660 188.5,671.5Q200,683 200,700Q200,717 188.5,728.5Q177,740 160,740Q143,740 131.5,728.5ZM131.5,868.5Q120,857 120,840Q120,823 131.5,811.5Q143,800 160,800Q177,800 188.5,811.5Q200,823 200,840Q200,857 188.5,868.5Q177,880 160,880Q143,880 131.5,868.5ZM271.5,868.5Q260,857 260,840Q260,823 271.5,811.5Q283,800 300,800Q317,800 328.5,811.5Q340,823 340,840Q340,857 328.5,868.5Q317,880 300,880Q283,880 271.5,868.5ZM411.5,868.5Q400,857 400,840Q400,823 411.5,811.5Q423,800 440,800Q457,800 468.5,811.5Q480,823 480,840Q480,857 468.5,868.5Q457,880 440,880Q423,880 411.5,868.5ZM551.5,868.5Q540,857 540,840Q540,823 551.5,811.5Q563,800 580,800Q597,800 608.5,811.5Q620,823 620,840Q620,857 608.5,868.5Q597,880 580,880Q563,880 551.5,868.5Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M280,840Q247,840 223.5,816.5Q200,793 200,760L200,240L200,240Q183,240 171.5,228.5Q160,217 160,200Q160,183 171.5,171.5Q183,160 200,160L360,160L360,160Q360,143 371.5,131.5Q383,120 400,120L560,120Q577,120 588.5,131.5Q600,143 600,160L600,160L760,160Q777,160 788.5,171.5Q800,183 800,200Q800,217 788.5,228.5Q777,240 760,240L760,240L760,760Q760,793 736.5,816.5Q713,840 680,840L280,840ZM680,240L280,240L280,760Q280,760 280,760Q280,760 280,760L680,760Q680,760 680,760Q680,760 680,760L680,240ZM428.5,668.5Q440,657 440,640L440,360Q440,343 428.5,331.5Q417,320 400,320Q383,320 371.5,331.5Q360,343 360,360L360,640Q360,657 371.5,668.5Q383,680 400,680Q417,680 428.5,668.5ZM588.5,668.5Q600,657 600,640L600,360Q600,343 588.5,331.5Q577,320 560,320Q543,320 531.5,331.5Q520,343 520,360L520,640Q520,657 531.5,668.5Q543,680 560,680Q577,680 588.5,668.5ZM280,240L280,240L280,760Q280,760 280,760Q280,760 280,760L280,760Q280,760 280,760Q280,760 280,760L280,240Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M360,720L600,720Q617,720 628.5,708.5Q640,697 640,680Q640,663 628.5,651.5Q617,640 600,640L360,640Q343,640 331.5,651.5Q320,663 320,680Q320,697 331.5,708.5Q343,720 360,720ZM360,560L600,560Q617,560 628.5,548.5Q640,537 640,520Q640,503 628.5,491.5Q617,480 600,480L360,480Q343,480 331.5,491.5Q320,503 320,520Q320,537 331.5,548.5Q343,560 360,560ZM240,880Q207,880 183.5,856.5Q160,833 160,800L160,160Q160,127 183.5,103.5Q207,80 240,80L527,80Q543,80 557.5,86Q572,92 583,103L777,297Q788,308 794,322.5Q800,337 800,353L800,800Q800,833 776.5,856.5Q753,880 720,880L240,880ZM520,320L520,160L240,160Q240,160 240,160Q240,160 240,160L240,800Q240,800 240,800Q240,800 240,800L720,800Q720,800 720,800Q720,800 720,800L720,360L560,360Q543,360 531.5,348.5Q520,337 520,320ZM240,160L240,160L240,320Q240,337 240,348.5Q240,360 240,360L240,360L240,160L240,320Q240,337 240,348.5Q240,360 240,360L240,360L240,800Q240,800 240,800Q240,800 240,800L240,800Q240,800 240,800Q240,800 240,800L240,160Q240,160 240,160Q240,160 240,160Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M300,240Q275,240 257.5,257.5Q240,275 240,300Q240,325 257.5,342.5Q275,360 300,360Q325,360 342.5,342.5Q360,325 360,300Q360,275 342.5,257.5Q325,240 300,240ZM300,640Q275,640 257.5,657.5Q240,675 240,700Q240,725 257.5,742.5Q275,760 300,760Q325,760 342.5,742.5Q360,725 360,700Q360,675 342.5,657.5Q325,640 300,640ZM160,120L800,120Q817,120 828.5,131.5Q840,143 840,160L840,440Q840,457 828.5,468.5Q817,480 800,480L160,480Q143,480 131.5,468.5Q120,457 120,440L120,160Q120,143 131.5,131.5Q143,120 160,120ZM200,200L200,400L760,400L760,200L200,200ZM160,520L800,520Q817,520 828.5,531.5Q840,543 840,560L840,840Q840,857 828.5,868.5Q817,880 800,880L160,880Q143,880 131.5,868.5Q120,857 120,840L120,560Q120,543 131.5,531.5Q143,520 160,520ZM200,600L200,800L760,800L760,600L200,600ZM200,200L200,200L200,400L200,400L200,200ZM200,600L200,600L200,800L200,800L200,600Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M444,600L516,600Q525,600 531.5,592.5Q538,585 536,576L517,471Q537,461 548.5,442Q560,423 560,400Q560,367 536.5,343.5Q513,320 480,320Q447,320 423.5,343.5Q400,367 400,400Q400,423 411.5,442Q423,461 443,471L424,576Q422,585 428.5,592.5Q435,600 444,600ZM467,875Q461,874 455,872Q320,827 240,705.5Q160,584 160,444L160,255Q160,230 174.5,210Q189,190 212,181L452,91Q466,86 480,86Q494,86 508,91L748,181Q771,190 785.5,210Q800,230 800,255L800,444Q800,584 720,705.5Q640,827 505,872Q499,874 493,875Q487,876 480,876Q473,876 467,875ZM480,796Q584,763 652,664Q720,565 720,444L720,255Q720,255 720,255Q720,255 720,255L480,165Q480,165 480,165Q480,165 480,165L240,255Q240,255 240,255Q240,255 240,255L240,444Q240,565 308,664Q376,763 480,796ZM480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480L480,480Q480,480 480,480Q480,480 480,480Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M200,760L720,760Q720,760 720,760Q720,760 720,760L720,601Q720,590 725.5,580Q731,570 742,565L765,554Q781,546 790.5,532Q800,518 800,500Q800,483 790.5,468.5Q781,454 765,446L743,436Q732,431 726,421.5Q720,412 720,400L720,240Q720,240 720,240Q720,240 720,240L563,240Q548,240 536.5,230.5Q525,221 523,206L518,172Q515,150 498.5,135Q482,120 460,120Q437,120 420.5,135Q404,150 401,172L396,206Q394,221 382.5,230.5Q371,240 356,240L200,240Q200,240 200,240Q200,240 200,240L200,326Q256,347 288,394Q320,441 320,500Q320,560 288,607Q256,654 200,675L200,760Q200,760 200,760Q200,760 200,760ZM200,840Q166,840 143,817Q120,794 120,760L120,635Q120,624 128,615.5Q136,607 147,605Q186,597 213,568.5Q240,540 240,500Q240,461 213,433Q186,405 147,396Q136,393 128,384.5Q120,376 120,365L120,240Q120,207 143.5,183.5Q167,160 200,160L322,160Q329,109 368,74.5Q407,40 460,40Q512,40 551,74.5Q590,109 598,160L720,160Q753,160 776.5,183.5Q800,207 800,240L800,374Q836,392 858,426Q880,460 880,500Q880,541 858,575Q836,609 800,626L800,760Q800,794 776.5,817Q753,840 720,840L200,840ZM500,500L500,500Q500,500 500,500Q500,500 500,500L500,500Q500,500 500,500Q500,500 500,500Q500,500 500,500Q500,500 500,500L500,500Q500,500 500,500Q500,500 500,500L500,500Q500,500 500,500Q500,500 500,500L500,500Q500,500 500,500Q500,500 500,500Q500,500 500,500Q500,500 500,500L500,500Q500,500 500,500Q500,500 500,500L500,500Q500,500 500,500Q500,500 500,500L500,500Q500,500 500,500Q500,500 500,500L500,500Q500,500 500,500Q500,500 500,500Q500,500 500,500Q500,500 500,500L500,500Q500,500 500,500Q500,500 500,500L500,500Q500,500 500,500Q500,500 500,500Z"/>
</vector>

View file

@ -1,14 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="512dp"
android:height="512dp"
android:viewportWidth="512"
android:viewportHeight="512">
<path
android:fillColor="#FF000000"
android:pathData="M334.49,359.62L334.49,217.46C334.49,211.35 336.74,206.11 341.24,201.76C345.74,197.41 351.15,195.24 357.48,195.24C363.8,195.24 369.22,197.41 373.72,201.76C378.22,206.11 380.47,211.35 380.47,217.46L380.47,359.62L437.77,304.24C442.38,299.77 447.86,297.54 454.18,297.54C460.51,297.54 465.98,299.77 470.61,304.24C474.98,308.71 477.17,314 477.17,320.11C477.17,326.23 474.86,331.52 470.24,335.99L373.9,429.11C371.71,431.23 369.16,432.88 366.24,434.05C363.32,435.23 360.4,435.82 357.48,435.82C354.56,435.82 351.64,435.23 348.73,434.05C345.8,432.88 343.25,431.23 341.06,429.11L244.36,335.63C239.73,331.17 237.42,325.93 237.42,319.94C237.42,313.94 239.73,308.71 244.36,304.24C248.98,299.77 254.45,297.54 260.78,297.54C267.1,297.54 272.58,299.77 277.2,304.24L334.49,359.62Z"
android:strokeWidth="1"/>
<path
android:fillColor="#FF000000"
android:pathData="M93.09,357.71L210.69,357.71L249.64,395.37L93.09,395.37C82.47,395.37 73.46,391.76 66.3,384.54C59.02,377.33 55.44,368.38 55.44,357.71L55.44,298.88C55.44,295.43 56.67,292.37 59.26,289.7C61.73,287.03 64.69,285.39 68.15,284.76C80.37,282.25 90.74,276.52 99.26,267.58C107.78,258.64 111.97,247.89 111.97,235.34C111.97,223.1 107.78,212.59 99.26,203.8C90.74,195.01 80.37,189.22 68.15,186.39C64.69,185.44 61.73,183.64 59.26,180.98C56.67,178.3 55.44,175.25 55.44,171.79L55.44,112.97C55.44,102.61 59.14,93.75 66.55,86.37C73.83,79 82.72,75.31 93.09,75.31L150.61,75.31C152.83,59.3 159.99,45.9 172.21,35.07C184.55,24.24 199,18.83 215.66,18.83C231.96,18.83 246.27,24.24 258.49,35.07C270.72,45.9 278.12,59.3 280.59,75.31L338.11,75.31C348.48,75.31 357.37,79 364.73,86.37C372.1,93.75 375.79,102.61 375.79,112.97L375.79,160.48C370.9,156.68 364.95,154.59 358.81,154.59C351.21,154.59 343.92,157.78 338.55,163.45C338.4,163.61 338.26,163.76 338.11,163.92L338.11,112.97L264.17,112.97C259.48,112.97 255.29,111.48 251.71,108.49C248,105.51 245.9,101.66 245.29,96.96L242.94,80.96C241.95,74.05 238.87,68.26 233.68,63.54C228.62,58.83 222.45,56.48 215.66,56.48C208.38,56.48 202.21,58.83 197.02,63.54C191.84,68.26 188.75,74.05 187.76,80.96L185.42,96.96C184.8,101.66 182.7,105.51 179.12,108.49C175.42,111.48 171.35,112.97 166.66,112.97L93.09,112.97L93.09,153.44C110.74,160.03 124.56,170.7 134.56,185.44C144.68,200.2 149.62,216.83 149.62,235.34C149.62,254.17 144.68,270.95 134.56,285.7C124.56,300.45 110.74,311.12 93.09,317.71Z"
android:strokeWidth="1"/>
</vector>

View file

@ -1,21 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="24dp"
android:height="24dp"
android:viewportWidth="512"
android:viewportHeight="512">
<path
android:fillColor="#000000"
android:pathData="M828.649 786.425C828.649 789.514 828.814 792.438 829.145 795.196C829.477 797.953 829.973 800.766 830.634 803.635C832.181 809.372 832.181 814.997 830.634 820.514C829.089 826.03 825.78 830.332 820.707 833.421C815.633 836.509 810.337 837.172 804.82 835.407C799.304 833.641 795.553 830.111 793.568 824.816C791.36 818.638 789.706 812.35 788.603 805.952C787.501 799.553 786.949 793.044 786.949 786.425C786.949 755.536 797.761 728.894 819.382 706.5C841.003 684.105 866.93 672.91 897.157 672.91L899.804 672.91L894.509 667.614C891.421 664.523 889.932 660.883 890.042 656.692C890.15 652.499 891.752 648.859 894.84 645.771C897.927 642.679 901.568 641.138 905.762 641.138C909.955 641.138 913.596 642.679 916.683 645.771L949.779 678.865C953.972 683.057 956.067 688.021 956.067 693.758C956.067 699.495 953.972 704.459 949.779 708.651L916.683 741.746C913.596 744.835 909.955 746.38 905.762 746.38C901.568 746.38 897.927 744.835 894.84 741.746C891.752 738.657 890.207 734.962 890.207 730.66C890.207 726.357 891.752 722.661 894.84 719.572L899.804 714.608L898.149 714.608C878.954 714.608 862.572 721.613 849.003 735.624C835.433 749.634 828.649 766.568 828.649 786.425ZM972.283 786.425C972.283 783.336 972.118 780.413 971.787 777.655C971.456 774.897 970.96 772.083 970.298 769.215C968.752 763.479 968.752 757.852 970.298 752.337C971.843 746.821 975.153 742.519 980.227 739.43C985.3 736.34 990.542 735.624 995.947 737.279C1001.35 738.933 1005.05 742.298 1007.03 747.373C1009.46 753.771 1011.23 760.169 1012.33 766.568C1013.43 772.966 1013.98 779.585 1013.98 786.425C1013.98 817.314 1003.17 844.011 981.55 866.517C959.929 889.021 934.001 900.274 903.776 900.274L901.128 900.274L906.093 905.238C909.18 908.327 910.726 911.968 910.726 916.16C910.726 920.351 909.18 923.992 906.093 927.081C903.005 930.17 899.308 931.714 895.005 931.714C890.703 931.714 887.006 930.17 883.918 927.081L850.823 893.985C846.63 889.793 844.592 884.884 844.701 879.258C844.81 873.632 846.852 868.723 850.823 864.531L884.249 831.435C887.337 828.346 891.034 826.746 895.336 826.636C899.639 826.525 903.336 828.015 906.424 831.104C909.511 834.193 911.057 837.889 911.057 842.191C911.057 846.493 909.511 850.189 906.424 853.278L901.128 858.573L902.783 858.573C921.978 858.573 938.36 851.513 951.93 837.392C965.499 823.272 972.283 806.283 972.283 786.425Z" />
<path
android:fillColor="#000000"
android:pathData="M130.425 375.105L242.731 375.105C244.138 386.796 246.964 398.225 251.107 409.155L130.425 409.155C120.778 409.155 112.692 405.892 106.164 399.366C99.639 392.839 96.375 384.752 96.375 375.105L96.375 321.903C96.375 318.781 97.511 316.015 99.78 313.604C102.053 311.192 104.747 309.701 107.867 309.135C118.934 306.864 128.297 301.686 135.958 293.599C143.62 285.513 147.451 275.794 147.451 264.444C147.451 253.378 143.62 243.873 135.958 235.928C128.297 227.983 118.934 222.734 107.867 220.18C104.747 219.329 102.053 217.697 99.78 215.285C97.511 212.874 96.375 210.107 96.375 206.986L96.375 153.783C96.375 144.419 99.712 136.404 106.377 129.738C113.046 123.07 121.061 119.732 130.425 119.732L182.35 119.732C184.337 105.267 190.863 93.133 201.93 83.344C212.996 73.555 226.05 68.661 241.087 68.661C255.845 68.661 268.753 73.555 279.82 83.344C290.887 93.133 297.556 105.267 299.82 119.732L351.747 119.732C361.107 119.732 369.129 123.07 375.798 129.738C382.466 136.404 385.797 144.419 385.797 153.783L385.797 207.371C375.371 204.086 363.868 202.111 351.747 201.76L351.747 153.783L284.926 153.783C280.67 153.783 276.911 152.436 273.648 149.74C270.385 147.044 268.468 143.569 267.904 139.313L265.77 124.844C264.92 118.597 262.153 113.35 257.469 109.094C252.792 104.838 247.334 102.711 241.087 102.711C234.562 102.711 228.956 104.838 224.274 109.094C219.593 113.35 216.827 118.597 215.976 124.844L213.847 139.313C213.281 143.569 211.366 147.044 208.101 149.74C204.837 152.436 201.078 153.783 196.822 153.783L130.425 153.783L130.425 190.387C146.316 196.345 158.8 205.993 167.88 219.329C176.96 232.665 181.499 247.703 181.499 264.444C181.499 281.47 176.96 296.649 167.88 309.986C158.8 323.321 146.316 332.968 130.425 338.928L130.425 375.105Z" />
<path
android:fillColor="#D8D8D8"
android:pathData="M362.193 643.11A0.726 2.177 0 0 1 360.741 643.11A0.726 2.177 0 0 1 362.193 643.11Z"
android:strokeWidth="1"
android:strokeColor="#000000" />
<path
android:fillColor="#000000"
android:pathData="M285.208 364.511C285.208 368.086 285.429 371.577 285.861 374.985C286.293 378.39 287.03 381.766 288.073 385.111C289.337 389.523 289.243 393.776 287.81 397.87C286.377 401.967 283.702 405.013 279.814 407.011C275.738 409.183 271.65 409.48 267.563 407.903C263.465 406.322 260.737 403.379 259.357 399.076C257.408 393.502 255.986 387.814 255.101 382.007C254.205 376.204 253.763 370.371 253.763 364.511C253.763 333.308 264.613 306.671 286.314 284.601C308.015 262.531 334.393 251.497 365.427 251.497L367.923 251.497L357.136 240.707C354.439 238.01 353.102 234.647 353.133 230.62C353.154 226.593 354.524 223.229 357.22 220.529C359.917 217.828 363.288 216.479 367.312 216.479C371.336 216.479 374.697 217.828 377.404 220.529L413.01 256.138C416.16 259.29 417.74 262.984 417.74 267.221C417.74 271.458 416.16 275.152 413.01 278.303L377.404 313.914C374.697 316.614 371.336 317.963 367.312 317.963C363.288 317.963 359.917 316.614 357.22 313.914C354.524 311.213 353.175 307.835 353.175 303.781C353.175 299.728 354.524 296.352 357.22 293.651L367.923 282.945L365.669 282.945C343.347 282.945 324.364 290.874 308.699 306.731C293.045 322.588 285.208 341.846 285.208 364.511ZM447.289 363.46C447.289 359.884 447.078 356.392 446.646 352.985C446.204 349.58 445.466 346.204 444.434 342.86C443.17 338.447 443.254 334.194 444.697 330.101C446.13 326.004 448.795 322.957 452.693 320.96C456.759 318.787 460.836 318.476 464.902 320.027C468.968 321.579 471.686 324.48 473.066 328.728C475.068 334.356 476.522 340.074 477.406 345.88C478.291 351.683 478.744 357.544 478.744 363.46C478.744 394.661 467.894 421.312 446.183 443.412C424.482 465.509 398.115 476.557 367.081 476.557L364.573 476.557L375.276 487.263C377.984 489.961 379.332 493.323 379.332 497.351C379.332 501.378 377.984 504.742 375.276 507.442C372.58 510.141 369.209 511.492 365.153 511.492C361.097 511.492 357.716 510.141 355.019 507.442L319.413 471.832C316.263 468.681 314.693 465 314.725 460.791C314.757 456.582 316.316 452.901 319.413 449.749L355.103 414.14C357.8 411.44 361.181 410.076 365.227 410.049C369.282 410.021 372.664 411.357 375.361 414.057C378.068 416.757 379.416 420.135 379.416 424.19C379.416 428.242 378.068 431.619 375.361 434.319L364.573 445.108L366.828 445.108C389.15 445.108 408.143 437.165 423.808 421.28C439.462 405.397 447.289 386.123 447.289 363.46Z" />
</vector>

View file

@ -1,11 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:viewportHeight="512" android:viewportWidth="512" android:width="24dp">
<path android:fillColor="#FF000000" android:pathData="M828.65,786.42C828.65,789.51 828.81,792.44 829.15,795.2C829.48,797.95 829.97,800.77 830.63,803.64C832.18,809.37 832.18,815 830.63,820.51C829.09,826.03 825.78,830.33 820.71,833.42C815.63,836.51 810.34,837.17 804.82,835.41C799.3,833.64 795.55,830.11 793.57,824.82C791.36,818.64 789.71,812.35 788.6,805.95C787.5,799.55 786.95,793.04 786.95,786.42C786.95,755.54 797.76,728.89 819.38,706.5C841,684.1 866.93,672.91 897.16,672.91L899.8,672.91L894.51,667.61C891.42,664.52 889.93,660.88 890.04,656.69C890.15,652.5 891.75,648.86 894.84,645.77C897.93,642.68 901.57,641.14 905.76,641.14C909.96,641.14 913.6,642.68 916.68,645.77L949.78,678.86C953.97,683.06 956.07,688.02 956.07,693.76C956.07,699.49 953.97,704.46 949.78,708.65L916.68,741.75C913.6,744.84 909.96,746.38 905.76,746.38C901.57,746.38 897.93,744.84 894.84,741.75C891.75,738.66 890.21,734.96 890.21,730.66C890.21,726.36 891.75,722.66 894.84,719.57L899.8,714.61L898.15,714.61C878.95,714.61 862.57,721.61 849,735.62C835.43,749.63 828.65,766.57 828.65,786.42ZM972.28,786.42C972.28,783.34 972.12,780.41 971.79,777.66C971.46,774.9 970.96,772.08 970.3,769.22C968.75,763.48 968.75,757.85 970.3,752.34C971.84,746.82 975.15,742.52 980.23,739.43C985.3,736.34 990.54,735.62 995.95,737.28C1001.35,738.93 1005.05,742.3 1007.03,747.37C1009.46,753.77 1011.23,760.17 1012.33,766.57C1013.43,772.97 1013.98,779.59 1013.98,786.42C1013.98,817.31 1003.17,844.01 981.55,866.52C959.93,889.02 934,900.27 903.78,900.27L901.13,900.27L906.09,905.24C909.18,908.33 910.73,911.97 910.73,916.16C910.73,920.35 909.18,923.99 906.09,927.08C903.01,930.17 899.31,931.71 895.01,931.71C890.7,931.71 887.01,930.17 883.92,927.08L850.82,893.98C846.63,889.79 844.59,884.88 844.7,879.26C844.81,873.63 846.85,868.72 850.82,864.53L884.25,831.43C887.34,828.35 891.03,826.75 895.34,826.64C899.64,826.53 903.34,828.02 906.42,831.1C909.51,834.19 911.06,837.89 911.06,842.19C911.06,846.49 909.51,850.19 906.42,853.28L901.13,858.57L902.78,858.57C921.98,858.57 938.36,851.51 951.93,837.39C965.5,823.27 972.28,806.28 972.28,786.42Z" android:strokeWidth="1"/>
<path android:fillColor="#FF000000" android:pathData="M93.03,360.46L191.68,360.46C191.41,364.54 191.28,368.65 191.28,372.8C191.28,381.4 191.86,389.87 192.99,398.17L93.03,398.17C82.34,398.17 73.39,394.55 66.16,387.33C58.93,380.1 55.32,371.14 55.32,360.46L55.32,301.55C55.32,298.09 56.58,295.03 59.09,292.36C61.61,289.69 64.59,288.04 68.05,287.41C80.3,284.89 90.67,279.16 99.15,270.2C107.64,261.25 111.88,250.49 111.88,237.92C111.88,225.66 107.64,215.14 99.15,206.34C90.67,197.54 80.3,191.73 68.05,188.9C64.59,187.96 61.61,186.15 59.09,183.48C56.58,180.81 55.32,177.75 55.32,174.29L55.32,115.38C55.32,105.01 59.01,96.13 66.4,88.75C73.78,81.36 82.66,77.67 93.03,77.67L150.53,77.67C152.73,61.65 159.95,48.21 172.21,37.37C184.46,26.53 198.92,21.11 215.57,21.11C231.91,21.11 246.21,26.53 258.46,37.37C270.72,48.21 278.1,61.65 280.61,77.67L338.11,77.67C348.48,77.67 357.36,81.36 364.74,88.75C372.13,96.13 375.82,105.01 375.82,115.38L375.82,151.01C364.09,147.13 351.61,145.03 338.67,145.03C338.49,145.03 338.3,145.03 338.11,145.03L338.11,115.38L264.12,115.38C259.4,115.38 255.24,113.88 251.63,110.9C248.01,107.91 245.89,104.07 245.27,99.35L242.9,83.33C241.96,76.41 238.9,70.6 233.71,65.89C228.53,61.17 222.49,58.82 215.57,58.82C208.34,58.82 202.14,61.17 196.95,65.89C191.77,70.6 188.71,76.41 187.76,83.33L185.4,99.35C184.78,104.07 182.66,107.91 179.04,110.9C175.43,113.88 171.26,115.38 166.55,115.38L93.03,115.38L93.03,155.91C110.62,162.51 124.45,173.19 134.5,187.96C144.56,202.73 149.58,219.38 149.58,237.92C149.58,256.77 144.56,273.58 134.5,288.35C124.45,303.12 110.62,313.8 93.03,320.4Z" android:strokeWidth="1"/>
<path android:fillColor="#D8D8D8" android:pathData="M360.74,643.11a0.73,2.18 0,1 0,1.45 0a0.73,2.18 0,1 0,-1.45 0z" android:strokeColor="#000000" android:strokeWidth="1"/>
<path android:fillColor="#FF000000" android:pathData="M264.43,348.73C264.43,352.69 264.67,356.55 265.15,360.33C265.63,364.1 266.45,367.84 267.6,371.54C269,376.43 268.9,381.14 267.31,385.67C265.72,390.21 262.76,393.58 258.45,395.79C253.94,398.2 249.41,398.53 244.89,396.78C240.35,395.03 237.33,391.77 235.8,387.01C233.64,380.83 232.07,374.54 231.09,368.1C230.1,361.68 229.61,355.22 229.61,348.73C229.61,314.18 241.62,284.68 265.65,260.24C289.68,235.8 318.89,223.58 353.26,223.58L356.02,223.58L344.08,211.63C341.09,208.65 339.61,204.92 339.65,200.46C339.67,196 341.19,192.28 344.17,189.29C347.16,186.3 350.89,184.8 355.35,184.8C359.8,184.8 363.52,186.3 366.52,189.29L405.95,228.72C409.44,232.21 411.19,236.3 411.19,240.99C411.19,245.68 409.44,249.78 405.95,253.26L366.52,292.7C363.52,295.69 359.8,297.18 355.35,297.18C350.89,297.18 347.16,295.69 344.17,292.7C341.19,289.71 339.69,285.97 339.69,281.48C339.69,276.99 341.19,273.25 344.17,270.26L356.02,258.41L353.53,258.41C328.81,258.41 307.79,267.19 290.44,284.75C273.11,302.3 264.43,323.63 264.43,348.73ZM443.91,347.57C443.91,343.61 443.68,339.74 443.2,335.97C442.71,332.2 441.89,328.46 440.75,324.75C439.35,319.87 439.44,315.16 441.04,310.63C442.63,306.09 445.58,302.71 449.9,300.5C454.4,298.1 458.91,297.75 463.42,299.47C467.92,301.19 470.93,304.4 472.46,309.1C474.67,315.34 476.28,321.67 477.26,328.1C478.24,334.52 478.74,341.01 478.74,347.57C478.74,382.12 466.73,411.63 442.69,436.1C418.66,460.57 389.46,472.81 355.09,472.81L352.31,472.81L364.17,484.66C367.17,487.65 368.66,491.37 368.66,495.83C368.66,500.29 367.17,504.02 364.17,507.01C361.18,510 357.45,511.49 352.96,511.49C348.46,511.49 344.72,510 341.73,507.01L302.3,467.57C298.82,464.08 297.08,460.01 297.11,455.35C297.15,450.69 298.88,446.61 302.3,443.12L341.83,403.69C344.81,400.7 348.56,399.19 353.04,399.16C357.53,399.13 361.27,400.61 364.26,403.6C367.26,406.58 368.75,410.33 368.75,414.82C368.75,419.3 367.26,423.04 364.26,426.03L352.31,437.98L354.81,437.98C379.53,437.98 400.56,429.18 417.91,411.59C435.24,394.01 443.91,372.66 443.91,347.57Z" android:strokeWidth="1"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M324.5,555.5Q310,541 310,520Q310,499 324.5,484.5Q339,470 360,470Q381,470 395.5,484.5Q410,499 410,520Q410,541 395.5,555.5Q381,570 360,570Q339,570 324.5,555.5ZM564.5,555.5Q550,541 550,520Q550,499 564.5,484.5Q579,470 600,470Q621,470 635.5,484.5Q650,499 650,520Q650,541 635.5,555.5Q621,570 600,570Q579,570 564.5,555.5ZM480,800Q614,800 707,707Q800,614 800,480Q800,456 797,433.5Q794,411 786,390Q765,395 744,397.5Q723,400 700,400Q609,400 528,361Q447,322 390,252Q358,330 298.5,387.5Q239,445 160,474Q160,476 160,477Q160,478 160,480Q160,614 253,707Q346,800 480,800ZM480,880Q397,880 324,848.5Q251,817 197,763Q143,709 111.5,636Q80,563 80,480Q80,397 111.5,324Q143,251 197,197Q251,143 324,111.5Q397,80 480,80Q563,80 636,111.5Q709,143 763,197Q817,251 848.5,324Q880,397 880,480Q880,563 848.5,636Q817,709 763,763Q709,817 636,848.5Q563,880 480,880ZM426,165Q468,235 540,277.5Q612,320 700,320Q714,320 727,318.5Q740,317 754,315Q712,245 640,202.5Q568,160 480,160Q466,160 453,161.5Q440,163 426,165ZM177,379Q228,350 266,304Q304,258 323,201Q272,230 234,276Q196,322 177,379ZM426,165Q426,165 426,165Q426,165 426,165Q426,165 426,165Q426,165 426,165Q426,165 426,165Q426,165 426,165Q426,165 426,165Q426,165 426,165ZM323,201Q323,201 323,201Q323,201 323,201Q323,201 323,201Q323,201 323,201Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M440,800Q423,800 411.5,788.5Q400,777 400,760L400,520L168,224Q153,204 163.5,182Q174,160 200,160L760,160Q786,160 796.5,182Q807,204 792,224L560,520L560,760Q560,777 548.5,788.5Q537,800 520,800L440,800ZM480,492L678,240L282,240L480,492ZM480,492L480,492L480,492Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M160,800Q127,800 103.5,776.5Q80,753 80,720L80,240Q80,207 103.5,183.5Q127,160 160,160L367,160Q383,160 397.5,166Q412,172 423,183L480,240L800,240Q833,240 856.5,263.5Q880,287 880,320L880,720Q880,753 856.5,776.5Q833,800 800,800L160,800ZM160,720L800,720Q800,720 800,720Q800,720 800,720L800,320Q800,320 800,320Q800,320 800,320L447,320L367,240Q367,240 367,240Q367,240 367,240L160,240Q160,240 160,240Q160,240 160,240L160,720Q160,720 160,720Q160,720 160,720ZM160,720Q160,720 160,720Q160,720 160,720L160,240Q160,240 160,240Q160,240 160,240L160,240Q160,240 160,240Q160,240 160,240L160,320L160,320Q160,320 160,320Q160,320 160,320L160,720Q160,720 160,720Q160,720 160,720Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M384,598L576,598L611,695Q615,706 625,713Q635,720 647,720Q667,720 679.5,703.5Q692,687 684,667L532,265Q527,254 517,247Q507,240 495,240L465,240Q453,240 443,247Q433,254 428,265L276,667Q268,686 280,703Q292,720 312,720Q325,720 334.5,713Q344,706 349,694L384,598ZM408,528L478,330L482,330L552,528L408,528ZM160,880Q127,880 103.5,856.5Q80,833 80,800L80,160Q80,127 103.5,103.5Q127,80 160,80L800,80Q833,80 856.5,103.5Q880,127 880,160L880,800Q880,833 856.5,856.5Q833,880 800,880L160,880ZM160,800L800,800Q800,800 800,800Q800,800 800,800L800,160Q800,160 800,160Q800,160 800,160L160,160Q160,160 160,160Q160,160 160,160L160,800Q160,800 160,800Q160,800 160,800ZM160,160L160,160Q160,160 160,160Q160,160 160,160L160,800Q160,800 160,800Q160,800 160,800L160,800Q160,800 160,800Q160,800 160,800L160,160Q160,160 160,160Q160,160 160,160Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M160,840Q143,840 131.5,828.5Q120,817 120,800Q120,783 131.5,771.5Q143,760 160,760L800,760Q817,760 828.5,771.5Q840,783 840,800Q840,817 828.5,828.5Q817,840 800,840L160,840ZM320,680Q303,680 291.5,668.5Q280,657 280,640Q280,623 291.5,611.5Q303,600 320,600L640,600Q657,600 668.5,611.5Q680,623 680,640Q680,657 668.5,668.5Q657,680 640,680L320,680ZM160,520Q143,520 131.5,508.5Q120,497 120,480Q120,463 131.5,451.5Q143,440 160,440L800,440Q817,440 828.5,451.5Q840,463 840,480Q840,497 828.5,508.5Q817,520 800,520L160,520ZM320,360Q303,360 291.5,348.5Q280,337 280,320Q280,303 291.5,291.5Q303,280 320,280L640,280Q657,280 668.5,291.5Q680,303 680,320Q680,337 668.5,348.5Q657,360 640,360L320,360ZM160,200Q143,200 131.5,188.5Q120,177 120,160Q120,143 131.5,131.5Q143,120 160,120L800,120Q817,120 828.5,131.5Q840,143 840,160Q840,177 828.5,188.5Q817,200 800,200L160,200Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M352,760Q319,760 295.5,736.5Q272,713 272,680L272,280Q272,247 295.5,223.5Q319,200 352,200L493,200Q558,200 613,240Q668,280 668,351Q668,402 645,429.5Q622,457 602,469L602,469Q627,480 657.5,510Q688,540 688,600Q688,689 623,724.5Q558,760 501,760L352,760ZM393,648L497,648Q545,648 555.5,623.5Q566,599 566,588Q566,577 555.5,552.5Q545,528 494,528L393,528L393,648ZM393,420L486,420Q519,420 534,403Q549,386 549,365Q549,341 532,326Q515,311 488,311L393,311L393,420Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M332,28L647,343Q670,366 670,400Q670,434 647,457L457,647Q434,670 400,670Q366,670 343,647L153,457Q130,434 130,400Q130,366 153,343L343,152L275,84Q263,72 263.5,56Q264,40 276,28Q288,17 304,16.5Q320,16 332,28ZM400,209L209,400Q209,400 209,400Q209,400 209,400L591,400Q591,400 591,400Q591,400 591,400L400,209ZM703.5,656.5Q680,633 680,600Q680,579 692.5,555Q705,531 720,510Q729,498 739,485Q749,472 760,460Q771,472 781,485Q791,498 800,510Q815,531 827.5,555Q840,579 840,600Q840,633 816.5,656.5Q793,680 760,680Q727,680 703.5,656.5ZM160,960Q127,960 103.5,936.5Q80,913 80,880Q80,847 103.5,823.5Q127,800 160,800L800,800Q833,800 856.5,823.5Q880,847 880,880Q880,913 856.5,936.5Q833,960 800,960L160,960Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M120,960Q103,960 91.5,948.5Q80,937 80,920L80,840Q80,823 91.5,811.5Q103,800 120,800L840,800Q857,800 868.5,811.5Q880,823 880,840L880,920Q880,937 868.5,948.5Q857,960 840,960L120,960ZM285,680Q262,680 248.5,660.5Q235,641 243,619L419,150Q424,136 436,128Q448,120 462,120L498,120Q513,120 524.5,128Q536,136 541,150L718,620Q726,642 712.5,661Q699,680 676,680Q662,680 650,672Q638,664 633,650L594,536L368,536L327,651Q322,665 310.5,672.5Q299,680 285,680ZM396,456L564,456L482,224L478,224L396,456Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M250,760Q229,760 214.5,745.5Q200,731 200,710Q200,689 214.5,674.5Q229,660 250,660L360,660L480,300L370,300Q349,300 334.5,285.5Q320,271 320,250Q320,229 334.5,214.5Q349,200 370,200L670,200Q691,200 705.5,214.5Q720,229 720,250Q720,271 705.5,285.5Q691,300 670,300L580,300L460,660L550,660Q571,660 585.5,674.5Q600,689 600,710Q600,731 585.5,745.5Q571,760 550,760L250,760Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M440,880Q407,880 383.5,856.5Q360,833 360,800L360,640L240,640Q207,640 183.5,616.5Q160,593 160,560L160,280Q160,214 207,167Q254,120 320,120L760,120Q777,120 788.5,131.5Q800,143 800,160L800,560Q800,593 776.5,616.5Q753,640 720,640L600,640L600,800Q600,833 576.5,856.5Q553,880 520,880L440,880ZM240,400L720,400L720,200L680,200L680,320Q680,337 668.5,348.5Q657,360 640,360Q623,360 611.5,348.5Q600,337 600,320L600,200L560,200L560,240Q560,257 548.5,268.5Q537,280 520,280Q503,280 491.5,268.5Q480,257 480,240L480,200L320,200Q287,200 263.5,223.5Q240,247 240,280L240,400ZM240,560L720,560Q720,560 720,560Q720,560 720,560L720,480L240,480L240,560Q240,560 240,560Q240,560 240,560ZM240,560Q240,560 240,560Q240,560 240,560L240,480L240,480L240,560Q240,560 240,560Q240,560 240,560Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M160,680L800,680Q800,680 800,680Q800,680 800,680L800,440L160,440L160,680Q160,680 160,680Q160,680 160,680ZM722.5,602.5Q740,585 740,560Q740,535 722.5,517.5Q705,500 680,500Q655,500 637.5,517.5Q620,535 620,560Q620,585 637.5,602.5Q655,620 680,620Q705,620 722.5,602.5ZM880,360L767,360L687,280L273,280L193,360L80,360L217,223Q228,212 242.5,206Q257,200 273,200L687,200Q703,200 717.5,206Q732,212 743,223L880,360ZM160,760Q127,760 103.5,736.5Q80,713 80,680L80,360L880,360L880,680Q880,713 856.5,736.5Q833,760 800,760L160,760Z"/>
</vector>

View file

@ -1,10 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M240,660L264,660L293,724Q296,732 303,736Q310,740 318,740Q333,740 341.5,728Q350,716 344,702L324,656Q339,647 349.5,632.5Q360,618 360,600L360,560Q360,535 342.5,517.5Q325,500 300,500L220,500Q203,500 191.5,511.5Q180,523 180,540L180,710Q180,723 188.5,731.5Q197,740 210,740Q223,740 231.5,731.5Q240,723 240,710L240,660ZM530,740Q543,740 551.5,731.5Q560,723 560,710Q560,697 551.5,688.5Q543,680 530,680L460,680L460,650L510,650Q523,650 531.5,641.5Q540,633 540,620Q540,607 531.5,598.5Q523,590 510,590L460,590L460,560L530,560Q543,560 551.5,551.5Q560,543 560,530Q560,517 551.5,508.5Q543,500 530,500L440,500Q423,500 411.5,511.5Q400,523 400,540L400,700Q400,717 411.5,728.5Q423,740 440,740L530,740ZM720,680L630,680Q617,680 608.5,688.5Q600,697 600,710Q600,723 608.5,731.5Q617,740 630,740L740,740Q757,740 768.5,728.5Q780,717 780,700L780,640Q780,623 768.5,611.5Q757,600 740,600L660,600L660,560L750,560Q763,560 771.5,551.5Q780,543 780,530Q780,517 771.5,508.5Q763,500 750,500L640,500Q623,500 611.5,511.5Q600,523 600,540L600,600Q600,617 611.5,628.5Q623,640 640,640L720,640L720,680ZM240,600L240,560L300,560Q300,560 300,560Q300,560 300,560L300,600Q300,600 300,600Q300,600 300,600L240,600ZM360,370L420,370L420,430Q420,443 428.5,451.5Q437,460 450,460Q463,460 471.5,451.5Q480,443 480,430L480,250Q480,237 471.5,228.5Q463,220 450,220Q437,220 428.5,228.5Q420,237 420,250L420,310L360,310L360,250Q360,237 351.5,228.5Q343,220 330,220Q317,220 308.5,228.5Q300,237 300,250L300,430Q300,443 308.5,451.5Q317,460 330,460Q343,460 351.5,451.5Q360,443 360,430L360,370ZM580,250L580,430Q580,443 588.5,451.5Q597,460 610,460Q623,460 631.5,451.5Q640,443 640,430L640,250Q640,237 631.5,228.5Q623,220 610,220Q597,220 588.5,228.5Q580,237 580,250ZM120,840Q87,840 63.5,816.5Q40,793 40,760L40,200Q40,167 63.5,143.5Q87,120 120,120L840,120Q873,120 896.5,143.5Q920,167 920,200L920,760Q920,793 896.5,816.5Q873,840 840,840L120,840ZM120,760L840,760Q840,760 840,760Q840,760 840,760L840,200Q840,200 840,200Q840,200 840,200L120,200Q120,200 120,200Q120,200 120,200L120,760Q120,760 120,760Q120,760 120,760ZM120,760Q120,760 120,760Q120,760 120,760L120,200Q120,200 120,200Q120,200 120,200L120,200Q120,200 120,200Q120,200 120,200L120,760Q120,760 120,760Q120,760 120,760Z"/>
</vector>

Some files were not shown because too many files have changed in this diff Show more