android: 0.30.0 game activity

still no text input, at least it's not crashing

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-01-28 15:23:02 -08:00
parent b33346a25d
commit da9b2bcd46
5 changed files with 88 additions and 211 deletions

View File

@@ -46,9 +46,9 @@ debug-interactive-widgets = []
[target.'cfg(target_os = "android")'.dependencies]
tracing-logcat = "0.1.0"
log = { workspace = true }
android-activity = { version = "0.4", features = [ "game-activity" ] }
winit = { version = "0.30.5", features = [ "android-game-activity" ] }
#log = { workspace = true }
#android-activity = { version = "0.6", features = [ "game-activity" ] }
egui-winit.workspace = true
[package.metadata.bundle]
name = "Notedeck"

View File

@@ -23,6 +23,7 @@ public class MainActivity extends GameActivity {
protected void onCreate(Bundle savedInstanceState) {
// Shrink view so it does not get covered by insets.
/*
View content = getWindow().getDecorView().findViewById(android.R.id.content);
ViewCompat.setOnApplyWindowInsetsListener(content, (v, windowInsets) -> {
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
@@ -38,6 +39,7 @@ public class MainActivity extends GameActivity {
});
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
*/
super.onCreate(savedInstanceState);
}
@@ -46,9 +48,11 @@ public class MainActivity extends GameActivity {
public boolean onTouchEvent(MotionEvent event) {
// Offset the location so it fits the view with margins caused by insets.
/*
int[] location = new int[2];
findViewById(android.R.id.content).getLocationOnScreen(location);
event.offsetLocation(-location[0], -location[1]);
*/
return super.onTouchEvent(event);
}
}

View File

@@ -1,9 +1,8 @@
//#[cfg(target_os = "android")]
//use egui_android::run_android;
use egui_winit::winit::platform::android::activity::AndroidApp;
use notedeck_columns::Damus;
use winit::platform::android::activity::AndroidApp;
use winit::platform::android::EventLoopBuilderExtAndroid;
use crate::setup::setup_chrome;
use notedeck::Notedeck;
@@ -18,10 +17,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",
"enostr=debug,notedeck_columns=debug,notedeck_chrome=debug",
);
std::env::set_var("RUST_LOG", "egui=trace");
//std::env::set_var(
// "RUST_LOG",
// "enostr=debug,notedeck_columns=debug,notedeck_chrome=debug",
//);
let writer =
LogcatMakeWriter::new(LogcatTag::Target).expect("Failed to initialize logcat writer");
@@ -44,10 +45,12 @@ pub async fn android_main(app: AndroidApp) {
let mut options = eframe::NativeOptions::default();
options.renderer = eframe::Renderer::Wgpu;
// Clone `app` to use it both in the closure and later in the function
let app_clone_for_event_loop = app.clone();
options.event_loop_builder = Some(Box::new(move |builder| {
builder.with_android_app(app_clone_for_event_loop);
}));
//let app_clone_for_event_loop = app.clone();
//options.event_loop_builder = Some(Box::new(move |builder| {
// builder.with_android_app(app_clone_for_event_loop);
//}));
options.android_app = Some(app.clone());
let app_args = get_app_args(app);