1
0
forked from GRIN/grim

goblin: return to the calling app after a successful sign-in or authorize (Build 151)

This commit is contained in:
2ro
2026-07-06 10:30:00 -04:00
parent 98cd32f15e
commit f773e0144d
4 changed files with 31 additions and 0 deletions
@@ -402,6 +402,15 @@ public class MainActivity extends GameActivity {
finishAndRemoveTask();
}
// Called from native code after a successful same-device sign-in/authorize
// to hand focus back to the app that deep-linked into us (the browser tab
// that is polling the callback). Backgrounds our task so the OS surfaces the
// previous app; keeps the process alive (unlike exit()) so the callback POST
// finishes and the success toast shows on next foreground.
public void returnToCaller() {
moveTaskToBack(true);
}
@Override
protected void onDestroy() {
unregisterReceiver(mBroadcastReceiver);
+6
View File
@@ -286,6 +286,12 @@ impl PlatformCallbacks for Android {
fn vibrate_copy(&self) {
let _ = self.call_java_method("vibrateCopy", "()V", &[]);
}
fn return_to_caller(&self) {
// Background our task (Activity.moveTaskToBack(true), wrapped Java-side)
// so the OS brings the app that deep-linked into us back to the front.
let _ = self.call_java_method("returnToCaller", "()V", &[]);
}
}
lazy_static! {
+8
View File
@@ -76,4 +76,12 @@ pub trait PlatformCallbacks {
/// Play a tiny "tick" haptic confirming a successful copy. No-op off Android.
fn vibrate_copy(&self) {}
/// Return the user to the app that deep-linked into Goblin (the same-device
/// app-switch flow: a browser hands off a `goblin:login`/`goblin:authorize`
/// URI, we sign, then hand focus back). On Android this backgrounds our task
/// so the OS surfaces the previous app (the polling browser tab). Best-effort
/// and a no-op off Android, where there is no clean "return focus" primitive
/// (egui/winit); desktop leaves the window where it is.
fn return_to_caller(&self) {}
}
+8
View File
@@ -6379,6 +6379,10 @@ impl GoblinWalletView {
*slot.lock().unwrap() = Some(res);
});
Modal::close();
// Signed and handed to the POST worker: return the user to
// the app that deep-linked in (the polling browser tab),
// without waiting on the HTTP response. Success path only.
cb.return_to_caller();
}
Err(e) => {
// Signing failed (never expected): consume the request and
@@ -6799,6 +6803,10 @@ impl GoblinWalletView {
*slot.lock().unwrap() = Some(res);
});
Modal::close();
// Signed and handed to the POST worker: return the user to
// the app that deep-linked in (the polling browser tab),
// without waiting on the HTTP response. Success path only.
cb.return_to_caller();
}
Err(e) => {
// Signing failed (never expected): consume the request and