mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-07-20 11:01:05 +02:00
feat: rebuild cross-extension sharing and queue controls
Co-authored-by: Amonoman <musaauron87@gmail.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user