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
export use_android=true
export android_emulator=false
export ANDROID_DIR=crates/notedeck_chrome/android
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]]
name = "android-activity"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef6978589202a00cd7e118380c448a08b6ed394c3a8df3a430d0898e3a42d046"
source = "git+https://github.com/damus-io/android-activity?rev=a8948332c7c551303d32eb26a59d0abd676e47a5#a8948332c7c551303d32eb26a59d0abd676e47a5"
dependencies = [
"android-properties",
"bitflags 2.9.0",
@@ -1331,10 +1330,15 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f25c0e292a7ca6d6498557ff1df68f32c99850012b6ea401cf8daf771f22ff53"
[[package]]
name = "dpi"
version = "0.1.1"
source = "git+https://github.com/damus-io/winit?rev=14d61a74bee0c9863abe7ef28efae2c4d8bd3743#14d61a74bee0c9863abe7ef28efae2c4d8bd3743"
[[package]]
name = "ecolor"
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 = [
"bytemuck",
"emath",
@@ -1344,7 +1348,7 @@ dependencies = [
[[package]]
name = "eframe"
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 = [
"ahash",
"bytemuck",
@@ -1374,13 +1378,13 @@ dependencies = [
"wgpu",
"winapi",
"windows-sys 0.59.0",
"winit",
"winit 0.30.8",
]
[[package]]
name = "egui"
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 = [
"accesskit",
"ahash",
@@ -1397,7 +1401,7 @@ dependencies = [
[[package]]
name = "egui-wgpu"
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 = [
"ahash",
"bytemuck",
@@ -1410,13 +1414,13 @@ dependencies = [
"type-map",
"web-time 1.1.0",
"wgpu",
"winit",
"winit 0.30.8",
]
[[package]]
name = "egui-winit"
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 = [
"ahash",
"arboard",
@@ -1428,13 +1432,13 @@ dependencies = [
"smithay-clipboard",
"web-time 1.1.0",
"webbrowser",
"winit",
"winit 0.30.8",
]
[[package]]
name = "egui_extras"
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 = [
"ahash",
"egui",
@@ -1451,7 +1455,7 @@ dependencies = [
[[package]]
name = "egui_glow"
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 = [
"ahash",
"bytemuck",
@@ -1462,7 +1466,7 @@ dependencies = [
"profiling",
"wasm-bindgen",
"web-sys",
"winit",
"winit 0.30.8",
]
[[package]]
@@ -1515,7 +1519,7 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
[[package]]
name = "emath"
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 = [
"bytemuck",
"serde",
@@ -1603,7 +1607,7 @@ dependencies = [
[[package]]
name = "epaint"
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 = [
"ab_glyph",
"ahash",
@@ -1621,7 +1625,7 @@ dependencies = [
[[package]]
name = "epaint_default_fonts"
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]]
name = "equivalent"
@@ -2042,7 +2046,7 @@ dependencies = [
"cfg_aliases",
"glutin",
"raw-window-handle",
"winit",
"winit 0.30.9",
]
[[package]]
@@ -2278,6 +2282,7 @@ dependencies = [
"tokio",
"tokio-rustls",
"tower-service",
"webpki-roots",
]
[[package]]
@@ -4397,6 +4402,7 @@ dependencies = [
"wasm-bindgen-futures",
"wasm-streams",
"web-sys",
"webpki-roots",
"windows-registry",
]
@@ -6620,6 +6626,57 @@ version = "0.53.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
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]]
name = "winit"
version = "0.30.9"
@@ -6638,7 +6695,7 @@ dependencies = [
"core-foundation 0.9.4",
"core-graphics",
"cursor-icon",
"dpi",
"dpi 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"js-sys",
"libc",
"memmap2",
@@ -6653,7 +6710,6 @@ dependencies = [
"raw-window-handle",
"redox_syscall 0.4.1",
"rustix 0.38.44",
"sctk-adwaita",
"smithay-client-toolkit",
"smol_str",
"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" }
#epaint = { path = "/home/jb55/dev/github/emilk/egui/crates/epaint" }
egui = { git = "https://github.com/damus-io/egui", rev = "93cd1cedc1e8eed2b055e317226838e37a845aad" }
eframe = { git = "https://github.com/damus-io/egui", rev = "93cd1cedc1e8eed2b055e317226838e37a845aad" }
egui-winit = { git = "https://github.com/damus-io/egui", rev = "93cd1cedc1e8eed2b055e317226838e37a845aad" }
egui-wgpu = { git = "https://github.com/damus-io/egui", rev = "93cd1cedc1e8eed2b055e317226838e37a845aad" }
egui_extras = { git = "https://github.com/damus-io/egui", rev = "93cd1cedc1e8eed2b055e317226838e37a845aad" }
epaint = { 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 = "05beb0354c293a0e6cf4fac414b6c3b5f59adf51" }
egui-winit = { git = "https://github.com/damus-io/egui", rev = "05beb0354c293a0e6cf4fac414b6c3b5f59adf51" }
egui-wgpu = { git = "https://github.com/damus-io/egui", rev = "05beb0354c293a0e6cf4fac414b6c3b5f59adf51" }
egui_extras = { git = "https://github.com/damus-io/egui", rev = "05beb0354c293a0e6cf4fac414b6c3b5f59adf51" }
epaint = { git = "https://github.com/damus-io/egui", rev = "05beb0354c293a0e6cf4fac414b6c3b5f59adf51" }
puffin = { git = "https://github.com/jb55/puffin", package = "puffin", 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 = { 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" }

View File

@@ -13,7 +13,7 @@ jni: fake
cargo ndk --target arm64-v8a -o $(ANDROID_DIR)/app/src/main/jniLibs/ build --profile release
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
cd $(ANDROID_DIR) && ./gradlew build
@@ -27,4 +27,4 @@ push-android-config:
android: jni
cd $(ANDROID_DIR) && ./gradlew installDebug
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 {
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_dave::Dave;
use crate::{chrome::Chrome, setup::setup_chrome};
use crate::{app::NotedeckApp, chrome::Chrome, setup::setup_chrome};
use notedeck::Notedeck;
use serde_json::Value;
use std::fs;
@@ -18,7 +18,12 @@ pub async fn android_main(app: AndroidApp) {
use tracing_subscriber::{prelude::*, EnvFilter};
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(
// "RUST_LOG",
@@ -84,8 +89,8 @@ pub async fn android_main(app: AndroidApp) {
completely_unrecognized
);
chrome.add_app(columns);
chrome.add_app(dave);
chrome.add_app(NotedeckApp::Columns(columns));
chrome.add_app(NotedeckApp::Dave(dave));
// test dav
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) {
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);
//
//
@@ -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));
}
//pub const UI_SCALE_FACTOR: f32 = 0.2;
pub fn generate_native_options(paths: DataPath) -> NativeOptions {
let window_builder = Box::new(move |builder: egui::ViewportBuilder| {
let builder = builder

View File

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

View File

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