make sure it's still working on android

This commit is contained in:
William Casarin
2023-07-09 12:17:54 -07:00
parent 6232a8429e
commit 2526f8001c
5 changed files with 26 additions and 18 deletions

10
Cargo.lock generated
View File

@@ -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",
]
@@ -2052,6 +2056,12 @@ dependencies = [
"static_assertions",
]
[[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"

View File

@@ -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]

View File

@@ -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,
}

View File

@@ -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;
})
}))

View File

@@ -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())),