android: fix build

wip android keyboard fixes

wip 4.0.0 game-activity

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-03-11 16:08:07 -07:00
parent 7b558f8f58
commit 505083998d
9 changed files with 101 additions and 36 deletions

1
.envrc
View File

@@ -1,6 +1,7 @@
# set to false if you don't care to include android stuff # set to false if you don't care to include android stuff
export use_android=true export use_android=true
export android_emulator=false export android_emulator=false
export ANDROID_DIR=crates/notedeck_chrome/android
use nix --arg use_android $use_android --arg android_emulator $android_emulator use nix --arg use_android $use_android --arg android_emulator $android_emulator

94
Cargo.lock generated
View File

@@ -102,8 +102,7 @@ checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
[[package]] [[package]]
name = "android-activity" name = "android-activity"
version = "0.6.0" version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "git+https://github.com/damus-io/android-activity?rev=a8948332c7c551303d32eb26a59d0abd676e47a5#a8948332c7c551303d32eb26a59d0abd676e47a5"
checksum = "ef6978589202a00cd7e118380c448a08b6ed394c3a8df3a430d0898e3a42d046"
dependencies = [ dependencies = [
"android-properties", "android-properties",
"bitflags 2.9.0", "bitflags 2.9.0",
@@ -1331,10 +1330,15 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53" checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53"
[[package]]
name = "dpi"
version = "0.1.1"
source = "git+https://github.com/damus-io/winit?rev=14d61a74bee0c9863abe7ef28efae2c4d8bd3743#14d61a74bee0c9863abe7ef28efae2c4d8bd3743"
[[package]] [[package]]
name = "ecolor" name = "ecolor"
version = "0.31.1" version = "0.31.1"
source = "git+https://github.com/damus-io/egui?rev=93cd1cedc1e8eed2b055e317226838e37a845aad#93cd1cedc1e8eed2b055e317226838e37a845aad" source = "git+https://github.com/damus-io/egui?rev=05beb0354c293a0e6cf4fac414b6c3b5f59adf51#05beb0354c293a0e6cf4fac414b6c3b5f59adf51"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"emath", "emath",
@@ -1344,7 +1348,7 @@ dependencies = [
[[package]] [[package]]
name = "eframe" name = "eframe"
version = "0.31.1" version = "0.31.1"
source = "git+https://github.com/damus-io/egui?rev=93cd1cedc1e8eed2b055e317226838e37a845aad#93cd1cedc1e8eed2b055e317226838e37a845aad" source = "git+https://github.com/damus-io/egui?rev=05beb0354c293a0e6cf4fac414b6c3b5f59adf51#05beb0354c293a0e6cf4fac414b6c3b5f59adf51"
dependencies = [ dependencies = [
"ahash", "ahash",
"bytemuck", "bytemuck",
@@ -1374,13 +1378,13 @@ dependencies = [
"wgpu", "wgpu",
"winapi", "winapi",
"windows-sys 0.59.0", "windows-sys 0.59.0",
"winit", "winit 0.30.8",
] ]
[[package]] [[package]]
name = "egui" name = "egui"
version = "0.31.1" version = "0.31.1"
source = "git+https://github.com/damus-io/egui?rev=93cd1cedc1e8eed2b055e317226838e37a845aad#93cd1cedc1e8eed2b055e317226838e37a845aad" source = "git+https://github.com/damus-io/egui?rev=05beb0354c293a0e6cf4fac414b6c3b5f59adf51#05beb0354c293a0e6cf4fac414b6c3b5f59adf51"
dependencies = [ dependencies = [
"accesskit", "accesskit",
"ahash", "ahash",
@@ -1397,7 +1401,7 @@ dependencies = [
[[package]] [[package]]
name = "egui-wgpu" name = "egui-wgpu"
version = "0.31.1" version = "0.31.1"
source = "git+https://github.com/damus-io/egui?rev=93cd1cedc1e8eed2b055e317226838e37a845aad#93cd1cedc1e8eed2b055e317226838e37a845aad" source = "git+https://github.com/damus-io/egui?rev=05beb0354c293a0e6cf4fac414b6c3b5f59adf51#05beb0354c293a0e6cf4fac414b6c3b5f59adf51"
dependencies = [ dependencies = [
"ahash", "ahash",
"bytemuck", "bytemuck",
@@ -1410,13 +1414,13 @@ dependencies = [
"type-map", "type-map",
"web-time 1.1.0", "web-time 1.1.0",
"wgpu", "wgpu",
"winit", "winit 0.30.8",
] ]
[[package]] [[package]]
name = "egui-winit" name = "egui-winit"
version = "0.31.1" version = "0.31.1"
source = "git+https://github.com/damus-io/egui?rev=93cd1cedc1e8eed2b055e317226838e37a845aad#93cd1cedc1e8eed2b055e317226838e37a845aad" source = "git+https://github.com/damus-io/egui?rev=05beb0354c293a0e6cf4fac414b6c3b5f59adf51#05beb0354c293a0e6cf4fac414b6c3b5f59adf51"
dependencies = [ dependencies = [
"ahash", "ahash",
"arboard", "arboard",
@@ -1428,13 +1432,13 @@ dependencies = [
"smithay-clipboard", "smithay-clipboard",
"web-time 1.1.0", "web-time 1.1.0",
"webbrowser", "webbrowser",
"winit", "winit 0.30.8",
] ]
[[package]] [[package]]
name = "egui_extras" name = "egui_extras"
version = "0.31.1" version = "0.31.1"
source = "git+https://github.com/damus-io/egui?rev=93cd1cedc1e8eed2b055e317226838e37a845aad#93cd1cedc1e8eed2b055e317226838e37a845aad" source = "git+https://github.com/damus-io/egui?rev=05beb0354c293a0e6cf4fac414b6c3b5f59adf51#05beb0354c293a0e6cf4fac414b6c3b5f59adf51"
dependencies = [ dependencies = [
"ahash", "ahash",
"egui", "egui",
@@ -1451,7 +1455,7 @@ dependencies = [
[[package]] [[package]]
name = "egui_glow" name = "egui_glow"
version = "0.31.1" version = "0.31.1"
source = "git+https://github.com/damus-io/egui?rev=93cd1cedc1e8eed2b055e317226838e37a845aad#93cd1cedc1e8eed2b055e317226838e37a845aad" source = "git+https://github.com/damus-io/egui?rev=05beb0354c293a0e6cf4fac414b6c3b5f59adf51#05beb0354c293a0e6cf4fac414b6c3b5f59adf51"
dependencies = [ dependencies = [
"ahash", "ahash",
"bytemuck", "bytemuck",
@@ -1462,7 +1466,7 @@ dependencies = [
"profiling", "profiling",
"wasm-bindgen", "wasm-bindgen",
"web-sys", "web-sys",
"winit", "winit 0.30.8",
] ]
[[package]] [[package]]
@@ -1515,7 +1519,7 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
[[package]] [[package]]
name = "emath" name = "emath"
version = "0.31.1" version = "0.31.1"
source = "git+https://github.com/damus-io/egui?rev=93cd1cedc1e8eed2b055e317226838e37a845aad#93cd1cedc1e8eed2b055e317226838e37a845aad" source = "git+https://github.com/damus-io/egui?rev=05beb0354c293a0e6cf4fac414b6c3b5f59adf51#05beb0354c293a0e6cf4fac414b6c3b5f59adf51"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"serde", "serde",
@@ -1603,7 +1607,7 @@ dependencies = [
[[package]] [[package]]
name = "epaint" name = "epaint"
version = "0.31.1" version = "0.31.1"
source = "git+https://github.com/damus-io/egui?rev=93cd1cedc1e8eed2b055e317226838e37a845aad#93cd1cedc1e8eed2b055e317226838e37a845aad" source = "git+https://github.com/damus-io/egui?rev=05beb0354c293a0e6cf4fac414b6c3b5f59adf51#05beb0354c293a0e6cf4fac414b6c3b5f59adf51"
dependencies = [ dependencies = [
"ab_glyph", "ab_glyph",
"ahash", "ahash",
@@ -1621,7 +1625,7 @@ dependencies = [
[[package]] [[package]]
name = "epaint_default_fonts" name = "epaint_default_fonts"
version = "0.31.1" version = "0.31.1"
source = "git+https://github.com/damus-io/egui?rev=93cd1cedc1e8eed2b055e317226838e37a845aad#93cd1cedc1e8eed2b055e317226838e37a845aad" source = "git+https://github.com/damus-io/egui?rev=05beb0354c293a0e6cf4fac414b6c3b5f59adf51#05beb0354c293a0e6cf4fac414b6c3b5f59adf51"
[[package]] [[package]]
name = "equivalent" name = "equivalent"
@@ -2042,7 +2046,7 @@ dependencies = [
"cfg_aliases", "cfg_aliases",
"glutin", "glutin",
"raw-window-handle", "raw-window-handle",
"winit", "winit 0.30.9",
] ]
[[package]] [[package]]
@@ -2278,6 +2282,7 @@ dependencies = [
"tokio", "tokio",
"tokio-rustls", "tokio-rustls",
"tower-service", "tower-service",
"webpki-roots",
] ]
[[package]] [[package]]
@@ -4397,6 +4402,7 @@ dependencies = [
"wasm-bindgen-futures", "wasm-bindgen-futures",
"wasm-streams", "wasm-streams",
"web-sys", "web-sys",
"webpki-roots",
"windows-registry", "windows-registry",
] ]
@@ -6620,6 +6626,57 @@ version = "0.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486"
[[package]]
name = "winit"
version = "0.30.8"
source = "git+https://github.com/damus-io/winit?rev=14d61a74bee0c9863abe7ef28efae2c4d8bd3743#14d61a74bee0c9863abe7ef28efae2c4d8bd3743"
dependencies = [
"ahash",
"android-activity",
"atomic-waker",
"bitflags 2.9.0",
"block2 0.5.1",
"bytemuck",
"calloop",
"cfg_aliases",
"concurrent-queue",
"core-foundation 0.9.4",
"core-graphics",
"cursor-icon",
"dpi 0.1.1 (git+https://github.com/damus-io/winit?rev=14d61a74bee0c9863abe7ef28efae2c4d8bd3743)",
"js-sys",
"libc",
"memmap2",
"ndk",
"objc2 0.5.2",
"objc2-app-kit 0.2.2",
"objc2-foundation 0.2.2",
"objc2-ui-kit",
"orbclient",
"percent-encoding",
"pin-project",
"raw-window-handle",
"redox_syscall 0.4.1",
"rustix 0.38.44",
"sctk-adwaita",
"smithay-client-toolkit",
"smol_str",
"tracing",
"unicode-segmentation",
"wasm-bindgen",
"wasm-bindgen-futures",
"wayland-backend",
"wayland-client",
"wayland-protocols",
"wayland-protocols-plasma",
"web-sys",
"web-time 1.1.0",
"windows-sys 0.52.0",
"x11-dl",
"x11rb",
"xkbcommon-dl",
]
[[package]] [[package]]
name = "winit" name = "winit"
version = "0.30.9" version = "0.30.9"
@@ -6638,7 +6695,7 @@ dependencies = [
"core-foundation 0.9.4", "core-foundation 0.9.4",
"core-graphics", "core-graphics",
"cursor-icon", "cursor-icon",
"dpi", "dpi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"js-sys", "js-sys",
"libc", "libc",
"memmap2", "memmap2",
@@ -6653,7 +6710,6 @@ dependencies = [
"raw-window-handle", "raw-window-handle",
"redox_syscall 0.4.1", "redox_syscall 0.4.1",
"rustix 0.38.44", "rustix 0.38.44",
"sctk-adwaita",
"smithay-client-toolkit", "smithay-client-toolkit",
"smol_str", "smol_str",
"tracing", "tracing",

View File

@@ -90,15 +90,15 @@ strip = true # Strip symbols from binary*
#egui_extras = { path = "/home/jb55/dev/github/emilk/egui/crates/egui_extras" } #egui_extras = { path = "/home/jb55/dev/github/emilk/egui/crates/egui_extras" }
#epaint = { path = "/home/jb55/dev/github/emilk/egui/crates/epaint" } #epaint = { path = "/home/jb55/dev/github/emilk/egui/crates/epaint" }
egui = { git = "https://github.com/damus-io/egui", rev = "93cd1cedc1e8eed2b055e317226838e37a845aad" } egui = { git = "https://github.com/damus-io/egui", rev = "05beb0354c293a0e6cf4fac414b6c3b5f59adf51" }
eframe = { git = "https://github.com/damus-io/egui", rev = "93cd1cedc1e8eed2b055e317226838e37a845aad" } eframe = { git = "https://github.com/damus-io/egui", rev = "05beb0354c293a0e6cf4fac414b6c3b5f59adf51" }
egui-winit = { git = "https://github.com/damus-io/egui", rev = "93cd1cedc1e8eed2b055e317226838e37a845aad" } egui-winit = { git = "https://github.com/damus-io/egui", rev = "05beb0354c293a0e6cf4fac414b6c3b5f59adf51" }
egui-wgpu = { git = "https://github.com/damus-io/egui", rev = "93cd1cedc1e8eed2b055e317226838e37a845aad" } egui-wgpu = { git = "https://github.com/damus-io/egui", rev = "05beb0354c293a0e6cf4fac414b6c3b5f59adf51" }
egui_extras = { git = "https://github.com/damus-io/egui", rev = "93cd1cedc1e8eed2b055e317226838e37a845aad" } egui_extras = { git = "https://github.com/damus-io/egui", rev = "05beb0354c293a0e6cf4fac414b6c3b5f59adf51" }
epaint = { git = "https://github.com/damus-io/egui", rev = "93cd1cedc1e8eed2b055e317226838e37a845aad" } epaint = { git = "https://github.com/damus-io/egui", rev = "05beb0354c293a0e6cf4fac414b6c3b5f59adf51" }
puffin = { git = "https://github.com/jb55/puffin", package = "puffin", rev = "c6a6242adaf90b6292c0f462d2acd34d96d224d2" } puffin = { git = "https://github.com/jb55/puffin", package = "puffin", rev = "c6a6242adaf90b6292c0f462d2acd34d96d224d2" }
puffin_egui = { git = "https://github.com/jb55/puffin", package = "puffin_egui", rev = "c6a6242adaf90b6292c0f462d2acd34d96d224d2" } puffin_egui = { git = "https://github.com/jb55/puffin", package = "puffin_egui", rev = "c6a6242adaf90b6292c0f462d2acd34d96d224d2" }
#winit = { git = "https://github.com/damus-io/winit", rev = "14d61a74bee0c9863abe7ef28efae2c4d8bd3743" } #winit = { git = "https://github.com/damus-io/winit", rev = "14d61a74bee0c9863abe7ef28efae2c4d8bd3743" }
#winit = { path = "/home/jb55/dev/github/rust-windowing/winit" } #winit = { path = "/home/jb55/dev/github/rust-windowing/winit" }
#android-activity = { git = "https://github.com/damus-io/android-activity", rev = "da17773852312a58c3445422dfe477162f2f1265" } android-activity = { git = "https://github.com/damus-io/android-activity", rev = "a8948332c7c551303d32eb26a59d0abd676e47a5" }
#android-activity = { path = "/home/jb55/dev/github/rust-mobile/android-activity/android-activity" } #android-activity = { path = "/home/jb55/dev/github/rust-mobile/android-activity/android-activity" }

View File

@@ -13,7 +13,7 @@ jni: fake
cargo ndk --target arm64-v8a -o $(ANDROID_DIR)/app/src/main/jniLibs/ build --profile release cargo ndk --target arm64-v8a -o $(ANDROID_DIR)/app/src/main/jniLibs/ build --profile release
jni-check: fake jni-check: fake
cargo ndk --target arm64-v8a -o $(ANDROID_DIR)/app/src/main/jniLibs/ check --profile release cargo ndk --target arm64-v8a -o $(ANDROID_DIR)/app/src/main/jniLibs/ check
apk: jni apk: jni
cd $(ANDROID_DIR) && ./gradlew build cd $(ANDROID_DIR) && ./gradlew build
@@ -27,4 +27,4 @@ push-android-config:
android: jni android: jni
cd $(ANDROID_DIR) && ./gradlew installDebug cd $(ANDROID_DIR) && ./gradlew installDebug
adb shell am start -n com.damus.notedeck/.MainActivity adb shell am start -n com.damus.notedeck/.MainActivity
adb logcat -v color -s RustStdoutStderr | tee logcat.txt adb logcat -v color -s RustStdoutStderr -s threaded_app | tee logcat.txt

View File

@@ -24,5 +24,5 @@ android {
dependencies { dependencies {
implementation "com.google.android.material:material:1.5.0" implementation "com.google.android.material:material:1.5.0"
implementation "androidx.games:games-activity:2.0.2" implementation "androidx.games:games-activity:4.0.0"
} }

View File

@@ -5,7 +5,7 @@ use egui_winit::winit::platform::android::activity::AndroidApp;
use notedeck_columns::Damus; use notedeck_columns::Damus;
use notedeck_dave::Dave; use notedeck_dave::Dave;
use crate::{chrome::Chrome, setup::setup_chrome}; use crate::{app::NotedeckApp, chrome::Chrome, setup::setup_chrome};
use notedeck::Notedeck; use notedeck::Notedeck;
use serde_json::Value; use serde_json::Value;
use std::fs; use std::fs;
@@ -18,7 +18,12 @@ pub async fn android_main(app: AndroidApp) {
use tracing_subscriber::{prelude::*, EnvFilter}; use tracing_subscriber::{prelude::*, EnvFilter};
std::env::set_var("RUST_BACKTRACE", "full"); std::env::set_var("RUST_BACKTRACE", "full");
std::env::set_var("RUST_LOG", "egui=debug,egui-winit=debug,notedeck=debug,notedeck_columns=debug,notedeck_chrome=debug,enostr=debug,android_activity=debug"); //std::env::set_var("DAVE_ENDPOINT", "http://ollama.jb55.com/v1");
//std::env::set_var("DAVE_MODEL", "hhao/qwen2.5-coder-tools:latest");
std::env::set_var(
"RUST_LOG",
"egui=debug,egui-winit=debug,notedeck=debug,notedeck_columns=debug,notedeck_chrome=debug,enostr=debug,android_activity=debug",
);
//std::env::set_var( //std::env::set_var(
// "RUST_LOG", // "RUST_LOG",
@@ -84,8 +89,8 @@ pub async fn android_main(app: AndroidApp) {
completely_unrecognized completely_unrecognized
); );
chrome.add_app(columns); chrome.add_app(NotedeckApp::Columns(columns));
chrome.add_app(dave); chrome.add_app(NotedeckApp::Dave(dave));
// test dav // test dav
chrome.set_active(1); chrome.set_active(1);

View File

@@ -34,7 +34,9 @@ pub fn setup_chrome(ctx: &egui::Context, args: &notedeck::Args, theme: ThemePref
pub fn setup_cc(ctx: &egui::Context, is_mobile: bool) { pub fn setup_cc(ctx: &egui::Context, is_mobile: bool) {
fonts::setup_fonts(ctx); fonts::setup_fonts(ctx);
//ctx.set_pixels_per_point(ctx.pixels_per_point() + UI_SCALE_FACTOR); if notedeck::ui::is_compiled_as_mobile() {
ctx.set_pixels_per_point(ctx.pixels_per_point() + 0.2);
}
//ctx.set_pixels_per_point(1.0); //ctx.set_pixels_per_point(1.0);
// //
// //
@@ -45,8 +47,6 @@ pub fn setup_cc(ctx: &egui::Context, is_mobile: bool) {
ctx.all_styles_mut(|style| theme::add_custom_style(is_mobile, style)); ctx.all_styles_mut(|style| theme::add_custom_style(is_mobile, style));
} }
//pub const UI_SCALE_FACTOR: f32 = 0.2;
pub fn generate_native_options(paths: DataPath) -> NativeOptions { pub fn generate_native_options(paths: DataPath) -> NativeOptions {
let window_builder = Box::new(move |builder: egui::ViewportBuilder| { let window_builder = Box::new(move |builder: egui::ViewportBuilder| {
let builder = builder let builder = builder

View File

@@ -1,3 +1,5 @@
#![cfg_attr(target_os = "android", allow(dead_code, unused_variables))]
use std::path::PathBuf; use std::path::PathBuf;
use base64::{prelude::BASE64_URL_SAFE, Engine}; use base64::{prelude::BASE64_URL_SAFE, Engine};

View File

@@ -1,4 +1,5 @@
use crate::draft::{Draft, Drafts, MentionHint}; use crate::draft::{Draft, Drafts, MentionHint};
#[cfg(not(target_os = "android"))]
use crate::media_upload::{nostrbuild_nip96_upload, MediaPath}; use crate::media_upload::{nostrbuild_nip96_upload, MediaPath};
use crate::post::{downcast_post_buffer, MentionType, NewPost}; use crate::post::{downcast_post_buffer, MentionType, NewPost};
use crate::ui::search_results::SearchResultsView; use crate::ui::search_results::SearchResultsView;