Skip to content

Commit 3d35612

Browse files
committed
Add UIBackend, currently only for soft keyboard
1 parent 1e9bd1c commit 3d35612

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ mod java;
44
mod keycodes;
55
mod navigator;
66
mod trace;
7+
mod ui;
78

89
use custom_event::RuffleEvent;
910

@@ -269,6 +270,7 @@ async fn run(app: AndroidApp) {
269270
.with_storage(Box::new(DiskStorageBackend::new(android_storage_dir.clone())))
270271
.with_navigator(navigator)
271272
.with_log(FileLogBackend::new(trace_output.as_deref()))
273+
.with_ui(ui::AndroidUiBackend::new(app.clone()))
272274
.with_video(
273275
ruffle_video_software::backend::SoftwareVideoBackend::new(),
274276
)

src/ui.rs

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
use std::str::FromStr;
2+
3+
use android_activity::AndroidApp;
4+
use ruffle_core::backend::ui::{LanguageIdentifier, UiBackend};
5+
use url::Url;
6+
7+
#[derive(Clone)]
8+
pub struct AndroidUiBackend {
9+
app: AndroidApp,
10+
}
11+
12+
impl AndroidUiBackend {
13+
pub fn new(app: AndroidApp) -> Self {
14+
Self { app }
15+
}
16+
}
17+
18+
impl UiBackend for AndroidUiBackend {
19+
fn mouse_visible(&self) -> bool {
20+
false
21+
}
22+
23+
fn set_mouse_visible(&mut self, visible: bool) {}
24+
25+
fn set_mouse_cursor(&mut self, cursor: ruffle_core::backend::ui::MouseCursor) {}
26+
27+
fn clipboard_content(&mut self) -> String {
28+
"".into()
29+
}
30+
31+
fn set_clipboard_content(&mut self, content: String) {}
32+
33+
fn set_fullscreen(
34+
&mut self,
35+
is_full: bool,
36+
) -> Result<(), ruffle_core::backend::ui::FullscreenError> {
37+
Ok(())
38+
}
39+
40+
fn display_root_movie_download_failed_message(
41+
&self,
42+
_invalid_swf: bool,
43+
_fetched_error: String,
44+
) {
45+
}
46+
47+
fn message(&self, message: &str) {}
48+
49+
fn open_virtual_keyboard(&self) {
50+
self.app.show_soft_input(false);
51+
}
52+
53+
fn close_virtual_keyboard(&self) {
54+
self.app.hide_soft_input(false);
55+
}
56+
57+
fn language(&self) -> ruffle_core::backend::ui::LanguageIdentifier {
58+
LanguageIdentifier::from_str("en-US").unwrap()
59+
}
60+
61+
fn display_unsupported_video(&self, url: Url) {}
62+
63+
fn load_device_font(
64+
&self,
65+
query: &ruffle_core::FontQuery,
66+
register: &mut dyn FnMut(ruffle_core::backend::ui::FontDefinition),
67+
) {
68+
}
69+
70+
fn sort_device_fonts(
71+
&self,
72+
query: &ruffle_core::FontQuery,
73+
register: &mut dyn FnMut(ruffle_core::backend::ui::FontDefinition),
74+
) -> Vec<ruffle_core::FontQuery> {
75+
Vec::new()
76+
}
77+
78+
fn display_file_open_dialog(
79+
&mut self,
80+
filters: Vec<ruffle_core::backend::ui::FileFilter>,
81+
) -> Option<ruffle_core::backend::ui::DialogResultFuture> {
82+
None
83+
}
84+
85+
fn display_file_save_dialog(
86+
&mut self,
87+
file_name: String,
88+
title: String,
89+
) -> Option<ruffle_core::backend::ui::DialogResultFuture> {
90+
None
91+
}
92+
93+
fn close_file_dialog(&mut self) {}
94+
}

0 commit comments

Comments
 (0)