mirror of
https://github.com/jwinterm/grim.git
synced 2026-11-11 16:23:53 +01:00
android: fix exit on background
This commit is contained in:
+27
-1
@@ -15,9 +15,10 @@
|
||||
use egui::{Context, Stroke};
|
||||
use egui::os::OperatingSystem;
|
||||
|
||||
use crate::gui::Colors;
|
||||
use crate::gui::{Colors, Navigator};
|
||||
use crate::gui::platform::PlatformCallbacks;
|
||||
use crate::gui::screens::Root;
|
||||
use crate::node::Node;
|
||||
|
||||
pub struct PlatformApp<Platform> {
|
||||
pub(crate) app: App,
|
||||
@@ -132,3 +133,28 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[cfg(target_os = "android")]
|
||||
#[allow(non_snake_case)]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Java_mw_gri_android_MainActivity_onBackButtonPress(
|
||||
_env: jni::JNIEnv,
|
||||
_class: jni::objects::JObject,
|
||||
_activity: jni::objects::JObject,
|
||||
) {
|
||||
Navigator::back();
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[cfg(target_os = "android")]
|
||||
#[allow(non_snake_case)]
|
||||
#[no_mangle]
|
||||
/// Calling on unexpected Android application termination (removal from recent apps).
|
||||
pub extern "C" fn Java_mw_gri_android_MainActivity_onTermination(
|
||||
_env: jni::JNIEnv,
|
||||
_class: jni::objects::JObject,
|
||||
_activity: jni::objects::JObject,
|
||||
) {
|
||||
Node::stop(false);
|
||||
}
|
||||
|
||||
|
||||
+6
-21
@@ -80,12 +80,9 @@ impl Root {
|
||||
}
|
||||
ui.add_space(16.0);
|
||||
ui.vertical_centered(|ui| {
|
||||
Spinner::new().size(48.0).color(Colors::GRAY).ui(ui);
|
||||
Spinner::new().size(48.0).color(Colors::GOLD).ui(ui);
|
||||
ui.add_space(12.0);
|
||||
ui.label(RichText::new(t!("sync_status.shutdown"))
|
||||
.size(17.0)
|
||||
.color(Colors::TEXT)
|
||||
);
|
||||
ui.label(t!("sync_status.shutdown"));
|
||||
});
|
||||
ui.add_space(10.0);
|
||||
} else {
|
||||
@@ -103,7 +100,7 @@ impl Root {
|
||||
App::exit(frame, cb);
|
||||
modal.close();
|
||||
} else {
|
||||
Node::stop();
|
||||
Node::stop(true);
|
||||
modal.disable_closing();
|
||||
self.show_exit_progress = true;
|
||||
}
|
||||
@@ -123,9 +120,9 @@ impl Root {
|
||||
}
|
||||
|
||||
fn show_current_screen(&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
ui: &mut egui::Ui,
|
||||
frame: &mut eframe::Frame,
|
||||
cb: &dyn PlatformCallbacks) {
|
||||
let Self { screens, .. } = self;
|
||||
for screen in screens.iter_mut() {
|
||||
if Navigator::is_current(&screen.id()) {
|
||||
@@ -146,16 +143,4 @@ impl Root {
|
||||
};
|
||||
(is_panel_open, panel_width)
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[cfg(target_os = "android")]
|
||||
#[allow(non_snake_case)]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Java_mw_gri_android_MainActivity_onBackButtonPress(
|
||||
_env: jni::JNIEnv,
|
||||
_class: jni::objects::JObject,
|
||||
_activity: jni::objects::JObject,
|
||||
) {
|
||||
Navigator::back();
|
||||
}
|
||||
Reference in New Issue
Block a user