diff --git a/CHANGELOG.md b/CHANGELOG.md index 1773395..7ce655a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ Sizzletracker for Android (`cc.tiredsysadmin.android.sizzle`). One entry per version in `versions.properties`; versions before 0.28.0 are described in the git log (one commit per version). +## 0.36.0 (versionCode 68) + +- **One-tap transfer from Mikro Seq:** a song sent by Mikro Seq's "Current to + Sizzle" button (the `extra.REPLACE` intent) loads straight away, without the + "replace song?" question. Only Mikro Seq can do this: the URI must come from + its own content provider. The replaced song is saved first as "Before Mikro Seq + import" in the project list, and a toast says so. Every other app still gets + the question. + ## 0.35.1 (versionCode 67) - **Fix:** knobs, switches, EQ faders and the envelope/filter/LFO drawings in the diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 05ddb8d..2dc24f4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -22,6 +22,12 @@ + + + + + ` for the provider lookup to see it. + */ + fun isTrustedReplace(context: Context, intent: Intent): Boolean { + if (intent.action != Intent.ACTION_VIEW) return false + if (!intent.getBooleanExtra(EXTRA_REPLACE, false)) return false + val uri = intent.data ?: return false + if (uri.scheme != "content") return false + val authority = uri.authority ?: return false + val owner = runCatching { context.packageManager.resolveContentProvider(authority, 0)?.packageName }.getOrNull() + return owner == MIKROSEQ_PACKAGE + } + fun read(context: Context, intent: Intent): IncomingSong { val uri: Uri? = when (intent.action) { Intent.ACTION_VIEW -> intent.data @@ -55,7 +85,7 @@ object SongIntents { } ?: return IncomingSong(name, null, "Couldn't read $name.") val text = String(bytes, Charsets.UTF_8) if (!SngFormat.looksLikeSng(text)) return IncomingSong(name, null, NOT_A_SONG) - return IncomingSong(name, text) + return IncomingSong(name, text, replaceNow = isTrustedReplace(context, intent)) } private const val NOT_A_SONG = "This doesn't look like a Sizzle .sng song, so nothing was imported." diff --git a/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/AppViewModel.kt b/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/AppViewModel.kt index b654050..b5059a9 100644 --- a/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/AppViewModel.kt +++ b/app/src/main/java/cc/tiredsysadmin/android/sizzle/ui/AppViewModel.kt @@ -163,12 +163,29 @@ class AppViewModel( // ----- A song opened from another app (VIEW / SEND intent) ----- /** Waiting for the user to confirm replacing the current song, or to read why * it can't be opened. */ + private val BEFORE_MIKROSEQ = "Before Mikro Seq import" + var incomingSong by mutableStateOf(null); private set fun offerIncomingSong(song: cc.tiredsysadmin.android.sizzle.io.IncomingSong) { incomingSong = song } fun dismissIncomingSong() { incomingSong = null } + /** + * Mikro Seq's one-tap transfer ([cc.tiredsysadmin.android.sizzle.io.SongIntents.isTrustedReplace]): + * nothing asks first, so the current song is saved in full to the library as + * [BEFORE_MIKROSEQ] (overwriting the previous such backup), then replaced. + */ + fun replaceFromMikroSeq(song: cc.tiredsysadmin.android.sizzle.io.IncomingSong) { + val backedUp = runCatching { songLibrary.save(BEFORE_MIKROSEQ, saveProjectText()) }.isSuccess + incomingSong = song + if (acceptIncomingSong()) { + val msg = if (backedUp) "Loaded ${song.name}. Previous song saved as \"$BEFORE_MIKROSEQ\"." + else "Loaded ${song.name}. Couldn't back up the previous song." + android.widget.Toast.makeText(appContext, msg, android.widget.Toast.LENGTH_LONG).show() + } + } + /** Replace the current song with the offered one. Stops playback first so the * audio thread isn't reading the model while it is rewritten. Returns false * (leaving the song as it was parsed so far) if the import fails. */ diff --git a/docs/DEVELOPER_HANDOVER.md b/docs/DEVELOPER_HANDOVER.md index c07600a..b9d0365 100644 --- a/docs/DEVELOPER_HANDOVER.md +++ b/docs/DEVELOPER_HANDOVER.md @@ -473,6 +473,20 @@ than songs. The ViewModel then holds an `incomingSong`, and `App.kt` asks before stay); the intent is consumed so a rotation can't offer it twice. Mikro Seq's "Open in Sizzle" sends its exported `.sng` this way with a FileProvider URI. +**One-tap transfer from Mikro Seq (0.36.0).** Mikro Seq's "Current to Sizzle" +button sends the same `ACTION_VIEW` plus the boolean extra +`cc.tiredsysadmin.android.sizzle.extra.REPLACE`. `SongIntents.isTrustedReplace` +skips the dialog only when the action is `ACTION_VIEW`, the extra is true, the URI +is `content:`, and `PackageManager.resolveContentProvider(authority)` belongs to +`cc.tiredsysadmin.android.mikroseq`. Mikro Seq's provider isn't exported, so only +Mikro Seq can grant us such a URI; any other sender, extra or not, gets the +dialog. The lookup needs Mikro Seq in the manifest's `` (package +visibility, Android 11+). Because nothing asks first, `replaceFromMikroSeq` saves +the current song in full to the library as "Before Mikro Seq import" (one rolling +backup, overwritten on every transfer), then imports and shows a toast. Checked on +the emulator: the Mikro Seq button replaces without a dialog; the same intent from +Sizzle's own FileProvider still asks. + ### 5.7 The Morph Pad (FRASIL port, MPL-2.0) The **Morph Pad** instrument (`ToolboxType.MORPH_PAD`) is the drone voice of diff --git a/docs/USER_GUIDE.md b/docs/USER_GUIDE.md index a445d6c..a289140 100644 --- a/docs/USER_GUIDE.md +++ b/docs/USER_GUIDE.md @@ -423,7 +423,10 @@ One‑shot actions (play, stop, tab switch, note/clear) still fire once even if Projects auto‑save, so a crash or process death resumes where you left off. Other apps can hand Sizzle a `.sng` directly (Mikro Seq's **Open in Sizzle**, a file manager's **Open with**, the share sheet); Sizzle asks before it replaces -the current song's notes and arrangement. +the current song's notes and arrangement. Mikro Seq's one-tap **Current to +Sizzle** button replaces it without asking; the song it replaced is saved first as +**Before Mikro Seq import** (Setup → Project), so you can load it back. Each +transfer overwrites that backup. Export a `.sng` before wiping data if you want a portable copy of the song. --- diff --git a/versions.properties b/versions.properties index 16a1f49..914dbcb 100644 --- a/versions.properties +++ b/versions.properties @@ -8,8 +8,8 @@ # or polish. android.versionCode is monotonic and bumps by 1 on every release, # because F-Droid and the Android package manager order installs by it alone. -android.versionName = 0.35.1 -android.versionCode = 67 +android.versionName = 0.36.0 +android.versionCode = 68 # No desktop builds exist yet. These lines are the agreed slots so a port starts # with a version instead of inventing one; `-` means "not built on this