Files
ink-notes/src/lib.rs
T
haraldandClaude Opus 5.5 0be321837c feat(android): Java activity for keyboard text and the system file dialog (Issue #42)
InkActivity extends NativeActivity:
- An invisible view with its own input connection receives the soft
  keyboard's text (commitText, deleteSurroundingText), so characters
  without a key event (umlauts by long press, ...) arrive as well. The
  field is a visible-password field, so keyboards commit each character
  instead of composing words.
- Import and "insert image" open the system file dialog
  (ACTION_OPEN_DOCUMENT); the chosen file is copied to the cache folder
  and handed to Rust by path.

src/android_bridge.rs calls the activity through JNI and receives its
native calls; package-android.sh compiles the class with javac and d8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 21:23:52 +01:00

75 lines
1.8 KiB
Rust

//! ink-notes: Latenzoptimierte Inking-App für Linux.
#[cfg(target_os = "android")]
pub mod android_bridge;
pub mod app;
pub mod assets;
pub mod autosave;
pub mod background;
pub mod canvas;
pub mod disk_watch;
pub mod document;
pub mod export;
pub mod file_picker;
pub mod filter;
pub mod geometry;
pub mod history;
pub mod i18n;
pub mod image_layer;
pub mod import;
pub mod library;
pub mod osk;
pub mod page_export;
pub mod paths;
pub mod pdf_doc;
pub mod pdf_merge;
pub mod pdf_writer;
pub mod pen;
pub mod platform;
pub mod rnote;
pub mod ruler;
pub mod saber;
pub mod selection;
pub mod settings;
pub mod spline;
pub mod storage;
pub mod text;
pub mod ui;
pub mod updater;
pub mod viewport;
pub mod xopp;
/// Entry point on Android (Issue #42), called by the native activity.
///
/// `scripts/package-android.sh` builds the library and packs it into an APK.
#[cfg(target_os = "android")]
#[no_mangle]
fn android_main(app: winit::platform::android::activity::AndroidApp) {
use winit::platform::android::EventLoopBuilderExtAndroid;
android_logger::init_once(
android_logger::Config::default()
.with_max_level(log::LevelFilter::Info)
.with_tag("ink-notes"),
);
// Panics would otherwise only go to stderr, which Android discards
std::panic::set_hook(Box::new(|info| log::error!("{info}")));
platform::set_android_app(app.clone());
if let Some(dir) = app.internal_data_path() {
paths::set_app_dir(dir);
}
let event_loop = match winit::event_loop::EventLoopBuilder::new()
.with_android_app(app)
.build()
{
Ok(event_loop) => event_loop,
Err(err) => {
log::error!("event loop: {err}");
return;
}
};
if let Err(err) = app::run_with(event_loop) {
log::error!("{err}");
}
}