fix url input for android

This commit is contained in:
Gregory Terzian 2018-05-24 09:38:23 +08:00
parent 2812b3cf4a
commit a5dc1b6764
2 changed files with 13 additions and 1 deletions

View file

@ -99,7 +99,7 @@ impl Browser {
String::from("") String::from("")
}; };
let title = "URL or search query"; let title = "URL or search query";
if let Some(input) = tinyfiledialogs::input_box(title, title, &url) { if let Some(input) = get_url_input(title, &url) {
if let Some(url) = sanitize_url(&input) { if let Some(url) = sanitize_url(&input) {
self.event_queue.push(WindowEvent::LoadUrl(id, url)); self.event_queue.push(WindowEvent::LoadUrl(id, url));
} }
@ -351,6 +351,17 @@ fn display_alert_dialog(_message: String) {
// tinyfiledialogs not supported on Android // tinyfiledialogs not supported on Android
} }
#[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))]
fn get_url_input(_title: &str, _url: &str) -> Option<String> {
// tinyfiledialogs not supported on Android
None
}
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
fn get_url_input(title: &str, url: &str) -> Option<String> {
tinyfiledialogs::input_box(title, title, url)
}
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
fn platform_get_selected_devices(devices: Vec<String>) -> Option<String> { fn platform_get_selected_devices(devices: Vec<String>) -> Option<String> {
let picker_name = "Choose a device"; let picker_name = "Choose a device";

View file

@ -34,6 +34,7 @@ extern crate servo;
#[cfg(all(feature = "unstable", not(target_os = "android")))] #[cfg(all(feature = "unstable", not(target_os = "android")))]
#[macro_use] #[macro_use]
extern crate sig; extern crate sig;
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
extern crate tinyfiledialogs; extern crate tinyfiledialogs;
extern crate winit; extern crate winit;
#[cfg(target_os = "windows")] extern crate winapi; #[cfg(target_os = "windows")] extern crate winapi;