mirror of
https://github.com/FluxaMedia/fluxa.git
synced 2026-08-09 08:27:32 +00:00
Add torrent speed/Wi-Fi-only settings rows and thread Wi-Fi-only into the torrent effect
Adds the missing torrentSpeedPreset settings row (the field already controlled preload size) and a new Wi-Fi-only toggle. The Android-side gating for Wi-Fi-only lives in TorrentStreamManager.startStream (see the next commit); this piece wires the active profile's torrentWifiOnly flag through the startTorrentStream headless effect. torrentMaxConnections and torrentCachePreset are intentionally left unexposed: the underlying rqbit torrent engine has no per-torrent connection-count cap or disk-cache-size knob to back them, so a toggle for either would be a no-op.
This commit is contained in:
parent
cffda2dad9
commit
5a96828bed
7 changed files with 75 additions and 2 deletions
|
|
@ -497,6 +497,8 @@ class FluxaAndroidHeadlessEnvironment @Inject constructor(
|
|||
val payload = effect.payload
|
||||
val url = payload.string("url")
|
||||
val stream = payload.objectValue("stream")?.let { gson.fromJson(gson.toJsonTree(it), Stream::class.java) }
|
||||
val activeProfile = profileManager.getLastActiveProfileId()
|
||||
?.let { id -> profileManager.getProfiles().firstOrNull { it.id == id } }
|
||||
val result = suspendCancellableCoroutine<TorrentStreamResult> { continuation ->
|
||||
TorrentStreamManager.getInstance(context).startStream(
|
||||
link = url,
|
||||
|
|
@ -506,7 +508,8 @@ class FluxaAndroidHeadlessEnvironment @Inject constructor(
|
|||
preferredFilename = payload.stringOrNull("preferredFilename") ?: stream?.effectiveFilename,
|
||||
sources = payload.list("sources").mapNotNull { it?.toString() }.ifEmpty { stream?.sources.orEmpty() },
|
||||
fileSizeBytes = stream?.effectiveVideoSize ?: stream?.videoSize ?: 0L,
|
||||
durationMs = payload.number("durationMs")?.toLong() ?: 0L
|
||||
durationMs = payload.number("durationMs")?.toLong() ?: 0L,
|
||||
wifiOnly = activeProfile?.safeTorrentWifiOnly == true
|
||||
) { torrentResult ->
|
||||
if (continuation.isActive) continuation.resume(torrentResult)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,17 @@ internal fun downloadSubtitleLabel(value: String, lang: String): String {
|
|||
?: AppStrings.t(lang, "settings.download_subtitle_preferred")
|
||||
}
|
||||
|
||||
internal fun torrentSpeedPresetOptions(lang: String): List<ChoiceOption> = listOf(
|
||||
ChoiceOption("default", AppStrings.t(lang, "settings.torrent_speed_default")),
|
||||
ChoiceOption("fast", AppStrings.t(lang, "settings.torrent_speed_fast")),
|
||||
ChoiceOption("ultra_fast", AppStrings.t(lang, "settings.torrent_speed_ultra_fast"))
|
||||
)
|
||||
|
||||
internal fun torrentSpeedPresetLabel(value: String, lang: String): String {
|
||||
return torrentSpeedPresetOptions(lang).firstOrNull { it.value == value }?.label
|
||||
?: AppStrings.t(lang, "settings.torrent_speed_default")
|
||||
}
|
||||
|
||||
internal fun selectStreamIndex(
|
||||
streams: List<Stream>,
|
||||
currentVideoId: String?,
|
||||
|
|
|
|||
|
|
@ -164,6 +164,19 @@ internal fun AddonSettings(profile: UserProfile, lang: String, onManageAddons: (
|
|||
icon = FluxaIcons.Extension,
|
||||
onClick = onManageAddons
|
||||
)
|
||||
SettingsChoiceTile(
|
||||
title = AppStrings.t(lang, "auto.torrent_speed"),
|
||||
subtitle = AppStrings.t(lang, "settings.torrent_speed_desc"),
|
||||
options = torrentSpeedPresetOptions(lang),
|
||||
selected = profile.safeTorrentSpeedPreset,
|
||||
onSelect = { onUpdateProfile(profile.sanitizedUpdate(torrentSpeedPreset = it)) }
|
||||
)
|
||||
SettingsToggleTile(
|
||||
title = AppStrings.t(lang, "settings.torrent_wifi_only"),
|
||||
subtitle = AppStrings.t(lang, "settings.torrent_wifi_only_desc"),
|
||||
checked = profile.safeTorrentWifiOnly,
|
||||
onToggle = { onUpdateProfile(profile.copy(torrentWifiOnly = it)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ internal fun MobileCategoryDetail(
|
|||
"appearance_home" -> AppStrings.t(lang, "settings.appearance_home_screen")
|
||||
"appearance_detail" -> AppStrings.t(lang, "settings.appearance_detail_screen")
|
||||
"content" -> AppStrings.t(lang, "auto.catalogs")
|
||||
"addons" -> AppStrings.t(lang, "auto.add_ons")
|
||||
"downloads" -> AppStrings.t(lang, "auto.downloads")
|
||||
"playback" -> AppStrings.t(lang, "auto.playback")
|
||||
"subtitles" -> AppStrings.t(lang, "auto.subtitles")
|
||||
|
|
@ -870,6 +871,39 @@ internal fun MobileCategoryDetail(
|
|||
MobileDeveloperSettings(lang)
|
||||
}
|
||||
}
|
||||
"addons" -> {
|
||||
item {
|
||||
MobileSettingsGroup(AppStrings.t(lang, "auto.add_ons")) {
|
||||
MobileActionRow(
|
||||
title = AppStrings.t(lang, "auto.manage_add_ons"),
|
||||
onClick = onManageAddons
|
||||
)
|
||||
}
|
||||
}
|
||||
item {
|
||||
MobileSettingsGroup(AppStrings.t(lang, "auto.torrent_speed")) {
|
||||
MobileChoiceRow(
|
||||
title = AppStrings.t(lang, "auto.torrent_speed"),
|
||||
value = torrentSpeedPresetLabel(profile.safeTorrentSpeedPreset, lang),
|
||||
subtitle = AppStrings.t(lang, "settings.torrent_speed_desc"),
|
||||
onClick = {
|
||||
choiceDialog = MobileChoiceDialogState(
|
||||
title = AppStrings.t(lang, "auto.torrent_speed"),
|
||||
options = torrentSpeedPresetOptions(lang),
|
||||
selected = profile.safeTorrentSpeedPreset,
|
||||
onSelect = { onUpdateProfile(profile.sanitizedUpdate(torrentSpeedPreset = it)) }
|
||||
)
|
||||
}
|
||||
)
|
||||
MobileToggleRow(
|
||||
title = AppStrings.t(lang, "settings.torrent_wifi_only"),
|
||||
subtitle = AppStrings.t(lang, "settings.torrent_wifi_only_desc"),
|
||||
checked = profile.safeTorrentWifiOnly,
|
||||
onToggle = { onUpdateProfile(profile.copy(torrentWifiOnly = !profile.safeTorrentWifiOnly)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
"downloads" -> {
|
||||
item {
|
||||
LaunchedEffect(Unit) {
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ internal fun MobileSettingsHub(
|
|||
icon = category.icon,
|
||||
onClick = {
|
||||
when (category.id) {
|
||||
"addons" -> onManageAddons()
|
||||
"addons" -> onNavigate("addons")
|
||||
"subtitles" -> onNavigate("subtitles")
|
||||
"advanced_settings" -> onNavigate("advanced_settings")
|
||||
"developer" -> onNavigate("developer")
|
||||
|
|
|
|||
|
|
@ -263,6 +263,12 @@
|
|||
"auto.add_ons_and_torrent": "Add-ons and Torrent",
|
||||
"auto.sources_and_stream_engine_preferences": "Sources and stream engine preferences.",
|
||||
"auto.torrent_speed": "Torrent Speed",
|
||||
"settings.torrent_speed_desc": "Controls how much of the file is preloaded before playback starts.",
|
||||
"settings.torrent_speed_default": "Default",
|
||||
"settings.torrent_speed_fast": "Fast",
|
||||
"settings.torrent_speed_ultra_fast": "Ultra Fast",
|
||||
"settings.torrent_wifi_only": "Wi-Fi Only",
|
||||
"settings.torrent_wifi_only_desc": "Only stream torrents when connected to Wi-Fi.",
|
||||
"auto.stremio_like_speed_presets": "Stremio-like speed presets.",
|
||||
"auto.default": "Default",
|
||||
"auto.fast": "Fast",
|
||||
|
|
|
|||
|
|
@ -263,6 +263,12 @@
|
|||
"auto.add_ons_and_torrent": "Eklentiler ve Torrent",
|
||||
"auto.sources_and_stream_engine_preferences": "Kaynaklar ve akış ayarları.",
|
||||
"auto.torrent_speed": "Torrent Hızı",
|
||||
"settings.torrent_speed_desc": "Oynatma başlamadan önce dosyanın ne kadarının önceden yükleneceğini denetler.",
|
||||
"settings.torrent_speed_default": "Varsayılan",
|
||||
"settings.torrent_speed_fast": "Hızlı",
|
||||
"settings.torrent_speed_ultra_fast": "Ultra Hızlı",
|
||||
"settings.torrent_wifi_only": "Yalnızca Wi-Fi",
|
||||
"settings.torrent_wifi_only_desc": "Yalnızca Wi-Fi'ye bağlıyken torrent akışı yapar.",
|
||||
"auto.stremio_like_speed_presets": "Stremio benzeri hazır hız profilleri.",
|
||||
"auto.default": "Varsayılan",
|
||||
"auto.fast": "Hızlı",
|
||||
|
|
|
|||
Loading…
Reference in a new issue