diff --git a/.claude/skills/gpui-mobile/SKILL.md b/.claude/skills/gpui-mobile/SKILL.md index 7ce3078..f712dbf 100644 --- a/.claude/skills/gpui-mobile/SKILL.md +++ b/.claude/skills/gpui-mobile/SKILL.md @@ -127,7 +127,7 @@ These come from bugs actually hit in this stack. Activity pointers. Load app classes with `find_app_class`, since `FindClass` on a native thread can't see them. 6. **If the Activity handles `uiMode` in `configChanges`, call - `host::configuration_changed()` from `onConfigurationChanged`**, or dark + `host::configuration_changed(newConfig.uiMode)` from `onConfigurationChanged`**, or dark mode never updates. 7. **`window.request_animation_frame()` only inside `render`.** Called from a click handler it panics. diff --git a/.claude/skills/gpui-mobile/references/gotchas.md b/.claude/skills/gpui-mobile/references/gotchas.md index 966505f..4303587 100644 --- a/.claude/skills/gpui-mobile/references/gotchas.md +++ b/.claude/skills/gpui-mobile/references/gotchas.md @@ -10,7 +10,7 @@ anything newer. | Blank screen on start | `host::on_open_window` registered after the first `surface_created`, or not at all. | | Icons and SVGs missing | `host::start` instead of `host::start_with_assets(gpui_kit::assets::AllAssets, …)`. | | Emoji show as boxes | Android 13+ ships a COLRv1 emoji font that swash can't draw. Bundle `assets/fonts/NotoColorEmoji.ttf` (CBDT) and call `host::set_activity` (or `set_host_activity`) before `host::start`. Flags and ❤️ with VS16 still don't render. | -| Dark mode doesn't follow the system | The Activity lists `uiMode` in `configChanges` but doesn't call `host::configuration_changed()` from `onConfigurationChanged`. | +| Dark mode doesn't follow the system | The Activity lists `uiMode` in `configChanges` but doesn't call `host::configuration_changed(newConfig.uiMode)` from `onConfigurationChanged`. | | Text white on white in a dark chat bubble; shimmer invisible | Kit bugs kit#3326, kit#3327; not Android-specific. | | Bold/italic look regular | Roboto is a variable font; weights aren't applied. | | Popover or submenu off screen | Not clamped to the viewport yet. | diff --git a/.claude/skills/gpui-mobile/references/new-app.md b/.claude/skills/gpui-mobile/references/new-app.md index 8c32857..7a2a994 100644 --- a/.claude/skills/gpui-mobile/references/new-app.md +++ b/.claude/skills/gpui-mobile/references/new-app.md @@ -101,7 +101,7 @@ API: | `host::surface_destroyed(host)` | `surfaceDestroyed`; blocks up to 2 s until the renderer lets go | | `host::resumed(host)` / `host::paused(host)` | `onResume` / `onPause` | | `host::host_destroyed(host)` | `onDestroy`, only when `isFinishing()` | -| `host::configuration_changed()` | `onConfigurationChanged` | +| `host::configuration_changed(ui_mode)` | `onConfigurationChanged`, with `newConfig.uiMode` | | `host::motion_event(action, index, &[Pointer { id, x, y }]) -> bool` | touch listener; physical px relative to the SurfaceView | | `host::key(code, action, meta)` | `dispatchKeyEvent` | | `host::ime_event(session, kind, text, start, end)` | from the IME proxy; kinds: 0 composing, 1 commit, 2 delete surrounding, 3 delete code points, 4 done, 5 keyboard hidden by Back, 6 action key (`IME_ACTION_*` in `start`) | @@ -130,7 +130,7 @@ Copy `LabActivity.java` and rename. What it must do: Copy it as is. - `onNewIntent`: `setIntent(intent)`, then forward the data URI to `deeplink::handle_link` and any `screen` extra. -- `onConfigurationChanged`: call the native `configuration_changed`. +- `onConfigurationChanged`: call the native `configuration_changed` with `newConfig.uiMode`. ## Manifest and Gradle diff --git a/Cargo.lock b/Cargo.lock index 04ec263..3092516 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2728,7 +2728,7 @@ dependencies = [ [[package]] name = "gpui-pre-mobile" version = "0.1.0" -source = "git+https://github.com/Bombatomica64/gpui-mobile?rev=c45635642cf6c1e7718c40e113ba2c925878f998#c45635642cf6c1e7718c40e113ba2c925878f998" +source = "git+https://github.com/Bombatomica64/gpui-mobile?rev=e12e14d7ef503258e949b37d9d6aff1da8ebd28d#e12e14d7ef503258e949b37d9d6aff1da8ebd28d" dependencies = [ "accesskit_android", "android-activity", diff --git a/Cargo.toml b/Cargo.toml index 9e09e76..c233a35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ crate-type = ["cdylib"] # (see MOBILE_PATCHES.md for what each carries on top of upstream). gpui = { package = "gpui-pre", version = "=0.3.8", default-features = false } gpui-kit = { git = "https://github.com/Bombatomica64/gpui-kit", rev = "e8b28164ac7fa7e1f7d393d441beb738c286bbc8", default-features = false, features = ["component", "assets"] } -gpui-mobile = { package = "gpui-pre-mobile", git = "https://github.com/Bombatomica64/gpui-mobile", rev = "c45635642cf6c1e7718c40e113ba2c925878f998", default-features = false, features = [ +gpui-mobile = { package = "gpui-pre-mobile", git = "https://github.com/Bombatomica64/gpui-mobile", rev = "e12e14d7ef503258e949b37d9d6aff1da8ebd28d", default-features = false, features = [ "clipboard", "share", # Exercised by the Platform APIs screen; build.sh copies their Java helpers from this checkout. "file_selector", "image_picker", "local_auth", "permission_handler", "calendar", "contacts", diff --git a/MOBILE_PATCHES.md b/MOBILE_PATCHES.md index 1b0effd..e13811a 100644 --- a/MOBILE_PATCHES.md +++ b/MOBILE_PATCHES.md @@ -60,10 +60,14 @@ like back. `show_soft_keyboard` / `hide_soft_keyboard` are implemented, so Without `android-activity`, night mode was never read, so the window stayed Light (and `Platform::window_appearance` always said Dark). It is now read -from the application context's configuration, which the first -`set_host_activity` keeps, and applied to each window when it opens, -re-attaches and resumes. An Activity that handles `uiMode` itself must call -the new `host::configuration_changed()`, which updates every host's window. +from the current host Activity's Resources, so an app-local night mode +counts too, and applied by the platform whenever a window opens or gets a +new surface, and on resume. An Activity that handles `uiMode` itself must +call the new `host::configuration_changed(newConfig.uiMode)`, which updates +every host's window. `window_appearance` answers the value last applied. +Review fixes pushed and replied to, see +[docs/upstream/replies](docs/upstream/replies/gpui-mobile-30.md); merged into +`main` with fork PR #14. ### Load the bundled emoji font on the host path — branch `android-host-emoji-font`, [#29](https://github.com/longbridge/gpui-mobile/pull/29) diff --git a/android/app/src/main/java/dev/gpui/mobile/lab/LabActivity.java b/android/app/src/main/java/dev/gpui/mobile/lab/LabActivity.java index ce364bb..608ec21 100644 --- a/android/app/src/main/java/dev/gpui/mobile/lab/LabActivity.java +++ b/android/app/src/main/java/dev/gpui/mobile/lab/LabActivity.java @@ -96,7 +96,7 @@ protected void onCreate(Bundle state) { @Override public void onConfigurationChanged(android.content.res.Configuration config) { super.onConfigurationChanged(config); - nativeConfigurationChanged(); + nativeConfigurationChanged(config.uiMode); } // Testing aid: `adb shell am start -n dev.gpui.mobile.lab/.LabActivity --es screen "Charts"` @@ -437,7 +437,7 @@ private void endEdit() { private static native void nativeOnCreate(Activity activity, long host, int apiLevel); private static native void nativeOpenScreen(String screen); private static native void nativeDeepLink(String url); - private static native void nativeConfigurationChanged(); + private static native void nativeConfigurationChanged(int uiMode); private static native void nativeSurfaceChanged(long host, android.view.Surface surface, float scale); private static native void nativeSurfaceDestroyed(long host); private static native void nativeHostDestroyed(long host); diff --git a/src/host.rs b/src/host.rs index 3268761..cccd804 100644 --- a/src/host.rs +++ b/src/host.rs @@ -120,9 +120,10 @@ pub extern "system" fn Java_dev_gpui_mobile_lab_LabActivity_nativeDeepLink<'loca pub extern "system" fn Java_dev_gpui_mobile_lab_LabActivity_nativeConfigurationChanged<'local>( _env: EnvUnowned<'local>, _this: JObject<'local>, + ui_mode: i32, ) { log::info!("configuration changed"); - host::configuration_changed(); + host::configuration_changed(ui_mode); } #[unsafe(no_mangle)]