1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-02 14:50:03 -04:00

Add CI for android (#1900)

* Add CI for android

* Don't use arboard on Android

* Fix Android support for eframe
This commit is contained in:
Zoxc
2022-08-15 10:19:59 +02:00
committed by GitHub
parent 923b67ef9c
commit 48e7f219a3
4 changed files with 32 additions and 13 deletions

View File

@@ -49,7 +49,6 @@ tracing = { version = "0.1", default-features = false, features = ["std"] }
winit = "0.27.2"
#! ### Optional dependencies
arboard = { version = "2.1", optional = true, default-features = false }
## Enable this when generating docs.
document-features = { version = "0.2", optional = true }
@@ -64,3 +63,6 @@ webbrowser = { version = "0.7", optional = true }
[target.'cfg(any(target_os="linux", target_os="dragonfly", target_os="freebsd", target_os="netbsd", target_os="openbsd"))'.dependencies]
smithay-clipboard = { version = "0.6.3", optional = true }
[target.'cfg(not(target_os = "android"))'.dependencies]
arboard = { version = "2.1", optional = true, default-features = false }

View File

@@ -5,7 +5,7 @@ use std::os::raw::c_void;
/// If the "clipboard" feature is off, or we cannot connect to the OS clipboard,
/// then a fallback clipboard that just works works within the same app is used instead.
pub struct Clipboard {
#[cfg(feature = "arboard")]
#[cfg(all(feature = "arboard", not(target_os = "android")))]
arboard: Option<arboard::Clipboard>,
#[cfg(all(
@@ -28,7 +28,7 @@ impl Clipboard {
#[allow(unused_variables)]
pub fn new(#[allow(unused_variables)] wayland_display: Option<*mut c_void>) -> Self {
Self {
#[cfg(feature = "arboard")]
#[cfg(all(feature = "arboard", not(target_os = "android")))]
arboard: init_arboard(),
#[cfg(all(
any(
@@ -66,7 +66,7 @@ impl Clipboard {
};
}
#[cfg(feature = "arboard")]
#[cfg(all(feature = "arboard", not(target_os = "android")))]
if let Some(clipboard) = &mut self.arboard {
return match clipboard.get_text() {
Ok(text) => Some(text),
@@ -96,7 +96,7 @@ impl Clipboard {
return;
}
#[cfg(feature = "arboard")]
#[cfg(all(feature = "arboard", not(target_os = "android")))]
if let Some(clipboard) = &mut self.arboard {
if let Err(err) = clipboard.set_text(text) {
tracing::error!("Copy/Cut error: {}", err);
@@ -108,7 +108,7 @@ impl Clipboard {
}
}
#[cfg(feature = "arboard")]
#[cfg(all(feature = "arboard", not(target_os = "android")))]
fn init_arboard() -> Option<arboard::Clipboard> {
match arboard::Clipboard::new() {
Ok(clipboard) => Some(clipboard),