From 0d9e9aa2ea73f6052ecbc1b909d06c0ce360257b Mon Sep 17 00:00:00 2001 From: Harald Date: Thu, 5 Nov 2026 12:20:52 +0100 Subject: [PATCH] fix(input): remember "draw with the finger", on by default on Android (Issue #50) The setting was never saved and always started off, so one finger only moved the page after every start. On a phone without a pen nothing could be written until it was switched on again, and an update restarts the app. It is now saved with the other UI settings and starts on on Android, where phones usually have no pen. Co-Authored-By: Claude Opus 5.5 --- src/app.rs | 9 +++++++++ src/settings.rs | 5 +++++ src/ui.rs | 21 ++++++++++++++------- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/app.rs b/src/app.rs index 5b930e3..72463a5 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1471,6 +1471,7 @@ pub fn run_with( ui_state.stylus_buttons = ui_settings.stylus_buttons.clone(); ui_state.set_eraser_radius_mm(ui_settings.eraser_radius_mm); ui_state.math.set_enabled(ui_settings.math_assist); + ui_state.touch_draw_enabled = ui_settings.touch_draw; ui_state.select_pen(ui_settings.active_pen); ui_state.highlighter_colors = ui_settings.highlighter_colors; ui_state.select_highlighter_color(ui_settings.active_highlighter); @@ -5356,6 +5357,14 @@ pub fn run_with( &mut ui_state, ); } + UiAction::SetTouchDraw(on) => { + ui_settings.touch_draw = on; + save_ui_settings( + &ui_settings, + ui_settings_path.as_deref(), + &mut ui_state, + ); + } UiAction::SetSidebarSide(side) => { ui_settings.sidebar_side = side; save_ui_settings( diff --git a/src/settings.rs b/src/settings.rs index 2b483f4..2c05785 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -234,6 +234,9 @@ pub struct UiSettings { pub storage_dir: Option, /// Compute handwritten math after `=` (Issue #46) pub math_assist: bool, + /// One finger draws instead of moving the page. On by default on Android, where phones + /// usually have no pen (Issue #50) + pub touch_draw: bool, } impl Default for UiSettings { @@ -256,6 +259,7 @@ impl Default for UiSettings { eraser_radius_mm: 3.0, storage_dir: None, math_assist: false, + touch_draw: cfg!(target_os = "android"), } } } @@ -354,6 +358,7 @@ mod tests { eraser_radius_mm: 6.0, storage_dir: Some(PathBuf::from("/home/pia/Nextcloud/ink-notes")), math_assist: true, + touch_draw: true, }; settings.save_to(&path).unwrap(); assert_eq!(UiSettings::load_from(&path), settings); diff --git a/src/ui.rs b/src/ui.rs index 430e1c0..17f7e73 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -319,6 +319,8 @@ pub enum UiAction { SetSidebarSide(SidebarSide), /// Compute handwritten math after `=` on or off (Issue #46) SetMathAssist(bool), + /// One finger draws or moves the page (saved, Issue #50) + SetTouchDraw(bool), /// Sprache der Oberfläche; `None` = Sprache des Systems SetLanguage(Option), /// Papierfarbe der Anzeige und Aufhellen dunkler Tinte (wird gespeichert) @@ -4613,13 +4615,18 @@ pub fn render_ui( }); section(ui, t!("EINGABE")); - ui.checkbox( - &mut state.touch_draw_enabled, - t!("Mit dem Finger zeichnen"), - ) - .on_hover_text( - t!("Aus: ein Finger verschiebt, zwei Finger zoomen (empfohlen mit Stift).\nAn: ein Finger zeichnet."), - ); + if ui + .checkbox( + &mut state.touch_draw_enabled, + t!("Mit dem Finger zeichnen"), + ) + .on_hover_text( + t!("Aus: ein Finger verschiebt, zwei Finger zoomen (empfohlen mit Stift).\nAn: ein Finger zeichnet."), + ) + .changed() + { + actions.push(UiAction::SetTouchDraw(state.touch_draw_enabled)); + } let mut math = state.math.enabled; if ui .checkbox(&mut math, t!("Formeln nach „=“ ausrechnen"))