notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 2526f8001c566cf6e28ee3e091dd16059532a7c3
parent 6232a8429e9ac2764b5a245ed2595ff607d0d7f4
Author: William Casarin <jb55@jb55.com>
Date:   Sun,  9 Jul 2023 12:17:54 -0700

make sure it's still working on android

Diffstat:
MCargo.lock | 10++++++++++
MCargo.toml | 9+++++----
Menostr/src/note.rs | 12++++--------
Mshell.nix | 7+++----
Msrc/lib.rs | 6++++--
5 files changed, 26 insertions(+), 18 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -601,6 +601,7 @@ dependencies = [ name = "damus" version = "0.1.0" dependencies = [ + "android-activity", "android_logger", "console_error_panic_hook", "eframe", @@ -623,6 +624,7 @@ dependencies = [ "tracing-subscriber", "tracing-wasm", "wasm-bindgen-futures", + "winit", ] [[package]] @@ -691,12 +693,14 @@ dependencies = [ "log", "objc", "percent-encoding", + "pollster", "puffin 0.15.0", "raw-window-handle", "thiserror", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", + "wgpu", "winapi", "winit", ] @@ -2053,6 +2057,12 @@ dependencies = [ ] [[package]] +name = "pollster" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" + +[[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml @@ -13,7 +13,7 @@ crate-type = ["lib", "cdylib"] [dependencies] #egui-android = { git = "https://github.com/jb55/egui-android.git" } egui = "0.22.0" -eframe = { version = "0.22.0", default-features = false, features = [ "glow" ] } +eframe = { version = "0.22.0", default-features = false, features = [ "glow", "wgpu", "android-native-activity" ] } #eframe = "0.22.0" egui_extras = { version = "0.22.0", features = ["image", "svg"] } ehttp = "0.2.0" @@ -46,11 +46,12 @@ wasm-bindgen-futures = "0.4" tokio = { version = "1.16", features = ["macros", "rt-multi-thread"] } tracing-subscriber = "0.3" + [target.'cfg(target_os = "android")'.dependencies] android_logger = "0.11.1" -#android-activity = "0.4.0" -#winit = "0.27.5" -#winit = { version = "0.28", features = [ "android-native-activity" ] } +android-activity = { version = "0.4", features = [ "native-activity" ] } +#winit = "0.28.6" +winit = { version = "0.28", features = [ "android-native-activity" ] } #winit = { git="https://github.com/rust-windowing/winit.git", rev = "2a58b785fed2a3746f7c7eebce95bce67ddfd27c", features = ["android-native-activity"] } [package.metadata.android] diff --git a/enostr/src/note.rs b/enostr/src/note.rs @@ -75,17 +75,13 @@ struct EventRefs { refs: Vec<EventRef>, } -struct TextNote { - event: Event, - shards: Shards, - refs: EventRefs, -} - struct DM { decrypted: Option<String>, shards: Shards, } -enum Note { - Text(TextNote), +struct Note { + event: NostrEvent, + shards: Shards, + refs: EventRef, } diff --git a/shell.nix b/shell.nix @@ -1,4 +1,4 @@ -{ pkgs ? import <nixpkgs> {} }: +{ pkgs ? import <nixpkgs> {}, use_android ? true }: with pkgs; let x11libs = lib.makeLibraryPath [ xorg.libX11 xorg.libXcursor xorg.libXrandr xorg.libXi libglvnd vulkan-loader vulkan-validation-layers ]; @@ -16,10 +16,9 @@ let androidsdk = androidComposition.androidsdk; android-home = "${androidsdk}/libexec/android-sdk"; ndk-home = "${android-home}/ndk/${ndk-version}"; - use_android = true; in -mkShell { +mkShell ({ nativeBuildInputs = [ cargo-udeps cargo-edit cargo-watch rustup rustfmt libiconv pkgconfig cmake fontconfig brotli wabt @@ -32,4 +31,4 @@ mkShell { } // (if !use_android then {} else { ANDROID_HOME = android-home; NDK_HOME = ndk-home; -}) +})) diff --git a/src/lib.rs b/src/lib.rs @@ -12,6 +12,7 @@ mod ui; pub use app::Damus; pub use error::Error; +use winit::platform::android::EventLoopBuilderExtAndroid; pub type Result<T> = std::result::Result<T, error::Error>; @@ -23,7 +24,8 @@ use winit::platform::android::activity::AndroidApp; #[cfg(target_os = "android")] #[no_mangle] -pub fn android_main(app: AndroidApp) { +#[tokio::main] +pub async fn android_main(app: AndroidApp) { std::env::set_var("RUST_BACKTRACE", "full"); android_logger::init_once(android_logger::Config::default().with_min_level(log::Level::Info)); @@ -33,7 +35,7 @@ pub fn android_main(app: AndroidApp) { builder.with_android_app(app); })); - eframe::run_native( + let res_ = eframe::run_native( "Damus NoteDeck", options, Box::new(|_cc| Box::new(Damus::new())),