feat: rebuild cross-extension sharing and queue controls

Co-authored-by: Amonoman <musaauron87@gmail.com>
This commit is contained in:
zarzet
2026-05-31 21:59:39 +07:00
parent f52527a41b
commit ffdaf14ba5
38 changed files with 1850 additions and 122 deletions
@@ -690,7 +690,8 @@ class DownloadService : Service() {
request.itemId,
request.requestJson,
request.itemJson,
result
result,
settingsJson
) {
nativeWorkerCancelRequested ||
nativeWorkerPaused ||
@@ -3157,6 +3157,17 @@ class MainActivity: FlutterFragmentActivity() {
}
result.success(response)
}
"findCollectionAcrossExtensions" -> {
val requestJson = call.arguments as? String ?: "{}"
val response: String = withContext(Dispatchers.IO) {
val method = Gobackend::class.java.getMethod(
"findCollectionAcrossExtensionsJSON",
String::class.java
)
method.invoke(null, requestJson) as? String ?: "[]"
}
result.success(response)
}
"enrichTrackWithExtension" -> {
val extensionId = call.argument<String>("extension_id") ?: ""
val trackJson = call.argument<String>("track") ?: "{}"
@@ -146,6 +146,7 @@ object NativeDownloadFinalizer {
requestJson: String,
itemJson: String,
result: JSONObject,
settingsJson: String = "{}",
shouldCancel: () -> Boolean = { false },
): JSONObject {
if (!result.optBoolean("success", false)) return result
@@ -217,15 +218,20 @@ object NativeDownloadFinalizer {
refreshFinalAudioQualityMetadata(context, result, state)
}
val history = buildHistoryRow(effectiveInput, state)
upsertHistory(context, history)
val saveDownloadHistory = parseObject(settingsJson)
.optBoolean("save_download_history", true)
val history = if (saveDownloadHistory) {
buildHistoryRow(effectiveInput, state).also { upsertHistory(context, it) }
} else {
null
}
result.put("file_path", state.filePath)
if (state.fileName.isNotBlank()) result.put("file_name", state.fileName)
if (state.quality.isNotBlank()) result.put("quality", state.quality)
result.put("native_finalized", true)
result.put("history_written", true)
result.put("history_item", historyToJson(history))
result.put("history_written", history != null)
if (history != null) result.put("history_item", historyToJson(history))
} catch (e: CancellationException) {
cleanupFailedFinalizationOutput(context, result, initialPath, state.filePath)
result.put("success", false)