mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-10 15:17:57 -05:00
app: fix broken android build
This commit is contained in:
@@ -75,7 +75,7 @@ static GLOBALS: LazyLock<SyncMutex<GlobalData>> =
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Java_darkfi_darkfi_1app_MainActivity_onInitEdit(
|
||||
env: *mut ndk_sys::JNIEnv,
|
||||
_env: *mut ndk_sys::JNIEnv,
|
||||
_: ndk_sys::jobject,
|
||||
id: ndk_sys::jint,
|
||||
) {
|
||||
@@ -86,7 +86,7 @@ pub unsafe extern "C" fn Java_darkfi_darkfi_1app_MainActivity_onInitEdit(
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Java_autosuggest_InvisibleInputView_onCreateInputConnect(
|
||||
env: *mut ndk_sys::JNIEnv,
|
||||
_env: *mut ndk_sys::JNIEnv,
|
||||
_: ndk_sys::jobject,
|
||||
id: ndk_sys::jint,
|
||||
) {
|
||||
@@ -118,7 +118,7 @@ pub unsafe extern "C" fn Java_autosuggest_CustomInputConnection_onCompose(
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Java_autosuggest_CustomInputConnection_onSetComposeRegion(
|
||||
env: *mut ndk_sys::JNIEnv,
|
||||
_env: *mut ndk_sys::JNIEnv,
|
||||
_: ndk_sys::jobject,
|
||||
id: ndk_sys::jint,
|
||||
start: ndk_sys::jint,
|
||||
@@ -130,7 +130,7 @@ pub unsafe extern "C" fn Java_autosuggest_CustomInputConnection_onSetComposeRegi
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Java_autosuggest_CustomInputConnection_onFinishCompose(
|
||||
env: *mut ndk_sys::JNIEnv,
|
||||
_env: *mut ndk_sys::JNIEnv,
|
||||
_: ndk_sys::jobject,
|
||||
id: ndk_sys::jint,
|
||||
) {
|
||||
@@ -140,7 +140,7 @@ pub unsafe extern "C" fn Java_autosuggest_CustomInputConnection_onFinishCompose(
|
||||
}
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Java_autosuggest_CustomInputConnection_onDeleteSurroundingText(
|
||||
env: *mut ndk_sys::JNIEnv,
|
||||
_env: *mut ndk_sys::JNIEnv,
|
||||
_: ndk_sys::jobject,
|
||||
id: ndk_sys::jint,
|
||||
left: ndk_sys::jint,
|
||||
|
||||
@@ -98,12 +98,12 @@ impl App {
|
||||
sled_tree: settings_tree,
|
||||
});
|
||||
|
||||
let window_scale = 1.;
|
||||
#[cfg(target_os = "android")]
|
||||
{
|
||||
window_scale = android::get_screen_density() / 2.625;
|
||||
d!("Setting window_scale to {window_scale}");
|
||||
}
|
||||
let window_scale = android::get_screen_density() / 2.625;
|
||||
#[cfg(not(target_os = "android"))]
|
||||
let window_scale = 1.;
|
||||
|
||||
d!("Setting window_scale to {window_scale}");
|
||||
|
||||
settings.add_setting("scale", PropertyValue::Float32(window_scale));
|
||||
//settings.load_settings();
|
||||
|
||||
@@ -172,6 +172,7 @@ fn android_keyboard_height() -> f32 {
|
||||
#[cfg(target_os = "android")]
|
||||
return crate::android::get_keyboard_height() as f32;
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
unreachable!()
|
||||
}
|
||||
|
||||
|
||||
@@ -42,8 +42,8 @@ const COLOR_SCHEME: ColorScheme = ColorScheme::DarkMode;
|
||||
|
||||
#[cfg(any(target_os = "android", feature = "emulate-android"))]
|
||||
mod android_ui_consts {
|
||||
pub const SETTINGS_ICON_SIZE: f32 = 140.;
|
||||
pub const NETSTATUS_ICON_SIZE: f32 = 140.;
|
||||
pub const SETTINGS_ICON_SIZE: f32 = 140.;
|
||||
pub const NETLOGO_SCALE: f32 = 50.;
|
||||
pub const EMOJI_PICKER_ICON_SIZE: f32 = 100.;
|
||||
}
|
||||
@@ -107,6 +107,7 @@ mod ui_consts {
|
||||
))]
|
||||
mod ui_consts {
|
||||
pub const NETSTATUS_ICON_SIZE: f32 = 60.;
|
||||
pub const SETTINGS_ICON_SIZE: f32 = 60.;
|
||||
pub const NETLOGO_SCALE: f32 = 25.;
|
||||
pub const EMOJI_PICKER_ICON_SIZE: f32 = 40.;
|
||||
pub use super::desktop_paths::*;
|
||||
@@ -126,7 +127,7 @@ enum ColorScheme {
|
||||
pub async fn make(app: &App, window: SceneNodePtr) {
|
||||
let mut cc = Compiler::new();
|
||||
cc.add_const_f32("NETSTATUS_ICON_SIZE", NETSTATUS_ICON_SIZE);
|
||||
cc.add_const_f32("SETTINGS_ICON_SIZE", NETSTATUS_ICON_SIZE);
|
||||
cc.add_const_f32("SETTINGS_ICON_SIZE", SETTINGS_ICON_SIZE);
|
||||
|
||||
let atom = &mut PropertyAtomicGuard::new();
|
||||
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
*/
|
||||
|
||||
use log::{LevelFilter, Log, Metadata, Record};
|
||||
use simplelog::{
|
||||
ColorChoice, CombinedLogger, Config, ConfigBuilder, SharedLogger, TermLogger, TerminalMode,
|
||||
};
|
||||
use simplelog::{CombinedLogger, Config, ConfigBuilder, SharedLogger};
|
||||
|
||||
#[cfg(feature = "enable-filelog")]
|
||||
use {
|
||||
@@ -128,6 +126,7 @@ mod android {
|
||||
#[cfg(not(target_os = "android"))]
|
||||
mod desktop {
|
||||
use super::*;
|
||||
use simplelog::{ColorChoice, TermLogger, TerminalMode};
|
||||
|
||||
/// Implements a wrapper around the android logger so it's compatible with simplelog.
|
||||
pub struct CustomTermLogger {
|
||||
|
||||
@@ -75,10 +75,10 @@ pub struct ZeroMQAdapter {
|
||||
slot_recvr: Option<mpsc::Receiver<(Vec<u8>, Vec<u8>)>>,
|
||||
*/
|
||||
sg_root: SceneNodePtr,
|
||||
ex: ExecutorPtr,
|
||||
_ex: ExecutorPtr,
|
||||
|
||||
zmq_rep: Mutex<zeromq::RepSocket>,
|
||||
zmq_pub: Mutex<zeromq::PubSocket>,
|
||||
_zmq_pub: Mutex<zeromq::PubSocket>,
|
||||
}
|
||||
|
||||
impl ZeroMQAdapter {
|
||||
@@ -89,7 +89,12 @@ impl ZeroMQAdapter {
|
||||
let mut zmq_pub = zeromq::PubSocket::new();
|
||||
zmq_pub.bind("tcp://0.0.0.0:9485").await.unwrap();
|
||||
|
||||
Arc::new(Self { sg_root, ex, zmq_rep: Mutex::new(zmq_rep), zmq_pub: Mutex::new(zmq_pub) })
|
||||
Arc::new(Self {
|
||||
sg_root,
|
||||
_ex: ex,
|
||||
zmq_rep: Mutex::new(zmq_rep),
|
||||
_zmq_pub: Mutex::new(zmq_pub),
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn run(self: Arc<Self>) {
|
||||
|
||||
@@ -20,7 +20,9 @@ use sled_overlay::sled;
|
||||
use std::{array::TryFromSliceError, string::FromUtf8Error, sync::Arc};
|
||||
|
||||
pub mod darkirc;
|
||||
pub use darkirc::{DarkIrc, DarkIrcPtr};
|
||||
#[cfg(feature = "enable-plugins")]
|
||||
pub use darkirc::DarkIrc;
|
||||
pub use darkirc::DarkIrcPtr;
|
||||
|
||||
use darkfi::net::Settings as NetSettings;
|
||||
|
||||
|
||||
@@ -24,13 +24,9 @@ use crate::{
|
||||
text2::{TextContext, TEXT_CTX},
|
||||
AndroidSuggestEvent,
|
||||
};
|
||||
use std::sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
Arc,
|
||||
};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
macro_rules! t { ($($arg:tt)*) => { trace!(target: "text::editor::android", $($arg)*); } }
|
||||
macro_rules! w { ($($arg:tt)*) => { warn!(target: "text::editor::android", $($arg)*) } }
|
||||
|
||||
// You must be careful working with string indexes in Java. They are UTF16 string indexs, not UTF8
|
||||
fn char16_to_byte_index(s: &str, char_idx: usize) -> Option<usize> {
|
||||
@@ -167,7 +163,7 @@ impl Editor {
|
||||
|
||||
let compose_start = char16_to_byte_index(&edit.buffer, compose_start).unwrap();
|
||||
let compose_end = char16_to_byte_index(&edit.buffer, compose_end).unwrap();
|
||||
underlines.push((compose_start..compose_end));
|
||||
underlines.push(compose_start..compose_end);
|
||||
}
|
||||
|
||||
let mut txt_ctx = TEXT_CTX.get().await;
|
||||
@@ -233,7 +229,7 @@ impl Editor {
|
||||
|
||||
pub fn driver<'a>(
|
||||
&'a mut self,
|
||||
txt_ctx: &'a mut TextContext,
|
||||
_txt_ctx: &'a mut TextContext,
|
||||
) -> Option<parley::PlainEditorDriver<'a, Color>> {
|
||||
None
|
||||
}
|
||||
@@ -279,6 +275,7 @@ impl Editor {
|
||||
android::set_selection(self.composer_id, select_start, select_end);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn buffer(&self) -> String {
|
||||
let edit = android::get_editable(self.composer_id).unwrap();
|
||||
edit.buffer
|
||||
|
||||
@@ -91,6 +91,7 @@ impl TextContext {
|
||||
Self { font_ctx, layout_ctx }
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "android"))]
|
||||
pub fn borrow(&mut self) -> (&mut parley::FontContext, &mut parley::LayoutContext<Color>) {
|
||||
(&mut self.font_ctx, &mut self.layout_ctx)
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@ use parking_lot::Mutex as SyncMutex;
|
||||
use rand::{rngs::OsRng, Rng};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
use crate::AndroidSuggestEvent;
|
||||
use crate::{
|
||||
gfx::{GfxDrawCall, GfxDrawInstruction, Point, Rectangle, RenderApi},
|
||||
prop::{PropertyAtomicGuard, PropertyBool, PropertyRect, PropertyUint32, Role},
|
||||
|
||||
@@ -21,8 +21,6 @@ use futures::stream::{FuturesUnordered, StreamExt};
|
||||
use miniquad::{KeyCode, KeyMods, MouseButton, TouchPhase};
|
||||
use std::sync::{Arc, Weak};
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
use crate::AndroidSuggestEvent;
|
||||
use crate::{
|
||||
gfx::{GfxDrawCall, Point, Rectangle},
|
||||
prop::{ModifyAction, PropertyAtomicGuard, PropertyPtr, Role},
|
||||
|
||||
@@ -20,8 +20,6 @@ use miniquad::{KeyCode, KeyMods, MouseButton, TouchPhase};
|
||||
use parking_lot::Mutex as SyncMutex;
|
||||
use std::sync::{Arc, Weak};
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
use crate::AndroidSuggestEvent;
|
||||
use crate::{
|
||||
gfx::{
|
||||
GfxDrawCall, GfxDrawInstruction, GraphicsEventCharSub, GraphicsEventKeyDownSub,
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
use colored::Colorize;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
@@ -45,13 +46,10 @@ pub fn ansi_texture(width: usize, height: usize, data: &Vec<u8>) -> String {
|
||||
for j in 0..width {
|
||||
let idx = 4 * (i * width + j);
|
||||
|
||||
let r = data[idx];
|
||||
let g = data[idx + 1];
|
||||
let b = data[idx + 2];
|
||||
let a = data[idx + 3];
|
||||
|
||||
#[cfg(target_os = "android")]
|
||||
{
|
||||
let a = data[idx + 3];
|
||||
|
||||
if a > 204 {
|
||||
out.push('█');
|
||||
} else if a > 153 {
|
||||
@@ -67,6 +65,11 @@ pub fn ansi_texture(width: usize, height: usize, data: &Vec<u8>) -> String {
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
let r = data[idx];
|
||||
let g = data[idx + 1];
|
||||
let b = data[idx + 2];
|
||||
let a = data[idx + 3];
|
||||
|
||||
let r = ((a as f32 * r as f32) / 255.) as u8;
|
||||
let g = ((a as f32 * g as f32) / 255.) as u8;
|
||||
let b = ((a as f32 * b as f32) / 255.) as u8;
|
||||
|
||||
Reference in New Issue
Block a user