Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

fix(android): Back closes the sheet on top and leaves the editor for the launch screen, and the project is saved when Android ends the window

Jareer0aa1a5023e29
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rs
index 63b352b4..f85efe8f 100644
--- a/src/crates/concat/src/lib.rs
+++ b/src/crates/concat/src/lib.rs
@@ -2481,6 +2481,20 @@ fn start(project: Option<std::path::PathBuf>, smoke: bool) -> Result<(), slint::
std::mem::forget(startup_mark);
leave(1);
}
+ // Android ends the loop when it destroys the activity - Back on the
+ // launch screen, or the system taking it back - with no close request
+ // first, and the process then left without a save: the edits since the
+ // last autosave were lost and the project's lock was left behind. A
+ // desktop's every way out closes the project before the loop ends.
+ #[cfg(target_os = "android")]
+ Shell::with(|shell, _| {
+ let mut studio = shell.studio.borrow_mut();
+ if studio.session.is_some()
+ && let Err(error) = studio.close_project()
+ {
+ log::warn!("close: the activity ended and the project could not be saved: {error}");
+ }
+ });
stop_exports();
drop(startup_mark);
leave(0);
diff --git a/src/crates/concat/ui/app.slint b/src/crates/concat/ui/app.slint
index 947ea9eb..43ee13ac 100644
--- a/src/crates/concat/ui/app.slint
+++ b/src/crates/concat/ui/app.slint
@@ -506,7 +506,10 @@ export component App inherits Window {
// Escape closes the sheet on top, as its × does. A sheet busy
// with a job keeps itself - its × is gone then too - and the
// key is spent on it, not passed to the editor underneath.
- if (event.text == Key.Escape) {
+ // Android's Back is the same key on a phone: unhandled, Slint
+ // finishes the activity, so Back with Export or a sheet open
+ // quit the app, a running export with it.
+ if (event.text == Key.Escape || event.text == Key.Back) {
if (root.confirm.open) { root.confirm-dismissed(); return accept; }
if (root.relink.open) { root.relink-dismiss(); return accept; }
if (root.project-sheet.open) { root.project-closed(); return accept; }
@@ -532,6 +535,17 @@ export component App inherits Window {
return accept;
}
}
+ // Back with nothing on top: the editor saves and goes back to
+ // the launch screen, as a phone editor's Back returns to its
+ // projects. On the launch screen it goes on up, and Android
+ // leaves the app.
+ if (event.text == Key.Back) {
+ if (!root.on-start) {
+ root.app-menu-selected("close-project");
+ return accept;
+ }
+ return reject;
+ }
if (Editor.key-chord(event.text, event.modifiers.shift, event.modifiers.alt,
event.modifiers.control, event.modifiers.meta, root.on-start)) {
return accept;