Skip to content

Commit

Permalink
small changes to mobile, and desktop
Browse files Browse the repository at this point in the history
  • Loading branch information
marci1175 committed Aug 30, 2024
1 parent 085ff5b commit fa4df61
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 63 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
/Installer/MatthiasSetup/Debug
/Installer/MatthiasSetup/Release
/Installer/.vs/
build_info.szechat_build
build_info.szechat_build
/mobile/target
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion desktop/build_info.matthias_build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.08.29. 21:11
2024.08.30. 16:15
1 change: 1 addition & 0 deletions desktop/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ impl eframe::App for backend::Application
/* TODOS:
TODO: Restructure files
TODO: Sound effects
TODO: Recode regsiter page
TODO: Add AI (Neural network) powered hand drawing recognition
TODO: Recode audio file playbacking
Expand Down
20 changes: 20 additions & 0 deletions desktop/src/app/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3094,6 +3094,26 @@ where
}
}

///Display Error message with a messagebox
pub fn display_info_message<T>(display: T, toasts: Arc<Mutex<Toasts>>)
where
T: ToString + std::marker::Send + 'static,
{
match toasts.lock() {
Ok(mut toasts) => {
let mut toast = Toast::info(display.to_string());

toast.set_duration(Some(Duration::from_secs(4)));
toast.set_show_progress_bar(true);

toasts.add(toast);
},
Err(_err) => {
tracing::error!("{}", _err);
},
}
}

/// This function fetches the incoming full message's lenght (it reads the 4 bytes and creates an u32 number from them, which it returns)
/// afaik this function blocks until it can read the first 4 bytes out of the ```reader```
pub async fn fetch_incoming_message_lenght<T>(reader: &mut T) -> anyhow::Result<u32>
Expand Down
4 changes: 3 additions & 1 deletion desktop/src/app/ui/register.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{env, fs, io::Cursor, path::PathBuf};

use crate::app::backend::{display_error_message, register, Application, ProfileImage, Register};
use crate::app::backend::{display_error_message, display_info_message, register, Application, ProfileImage, Register};
use anyhow::bail;
use egui::{
vec2, Area, Color32, Id, Image, ImageButton, LayerId, Pos2, Rect, RichText, Slider, Stroke,
Expand Down Expand Up @@ -206,6 +206,8 @@ impl Application
//Avoid panicking when trying to display a Notification
//This is very rare but can still happen
display_error_message(err, self.toasts.clone());
} else {
display_info_message("File selected successfully!", self.toasts.clone());
};
}
});
Expand Down
16 changes: 8 additions & 8 deletions mobile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ sha256 = "1.5.0"
phf = {version = "0.11.2", features = ["macros"]}
mlua = {version = "0.9.9", features = ["luajit", "async", "vendored"]}
mlua_proc_macro = "0.1.12"
mlua-sys = {version = "0.6.1", features = ["luajit", "vendored"]}
# mlua-sys = {version = "0.6.1", features = ["luajit", "vendored"]}
num-traits = "0.2.19"
opus = "0.3.0"
egui-notify = "0.15.0"
Expand All @@ -64,13 +64,13 @@ opencv = "0.92.2"
version = "1.6.1"
features = ["v4", "fast-rng", "macro-diagnostics", "serde"]

[dependencies.windows-sys]
version = "0.52.0"
features = [
"Win32_Foundation",
"Win32_UI_WindowsAndMessaging",
"Win32_UI_Input_KeyboardAndMouse",
]
# [dependencies.windows-sys]
# version = "0.52.0"
# features = [
# "Win32_Foundation",
# "Win32_UI_WindowsAndMessaging",
# "Win32_UI_Input_KeyboardAndMouse",
# ]

[build-dependencies]
chrono = "0.4.31"
Expand Down
14 changes: 11 additions & 3 deletions mobile/build.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@

echo $OPENCV_INCLUDE_PATHS
echo $OPENSSL_DIR

read

echo "Building Android application. . . "

ANDROID_HOME="C:\Users\marci\AppData\Local\Android\Sdk"
NDK_HOME="$ANDROID_HOME/ndk/27.0.12077973"

APK_TARGET_DIR="target/apk"
RUST_TARGET="armv7-linux-androideabi"
RUST_TARGET="x86_64-linux-android"
ARCH="armeabi-v7a"

cargo build --release
cargo build --release --target x86_64-linux-android

rm -rf $APK_TARGET_DIR/compiled $APK_TARGET_DIR/root/lib

Expand Down Expand Up @@ -38,4 +44,6 @@ cd -

# generate keystore with
# keytool -genkey -v -keystore test.keystore -alias test -keyalg RSA -keysize 2048 -validity 10000
$ANDROID_HOME/build-tools/34.0.0/apksigner.bat sign --ks test.keystore --ks-pass pass:test00 --min-sdk-version 34 --out $APK_TARGET_DIR/apk-signed.apk $APK_TARGET_DIR/apk-aligned.apk
$ANDROID_HOME/build-tools/34.0.0/apksigner.bat sign --ks test.keystore --ks-pass pass:test00 --min-sdk-version 34 --out $APK_TARGET_DIR/apk-signed.apk $APK_TARGET_DIR/apk-aligned.apk

read
2 changes: 1 addition & 1 deletion mobile/build_info.matthias_build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.08.29. 21:11
2024.08.30. 16:15
47 changes: 1 addition & 46 deletions mobile/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ use std::env::args;

use egui::{Style, ViewportBuilder, Visuals};
use tokio::fs;
use windows_sys::{
w,
Win32::UI::WindowsAndMessaging::{MessageBoxW, MB_ICONERROR},
};
#[tokio::main]
async fn main() -> eframe::Result<()>
{
Expand All @@ -29,31 +25,7 @@ async fn main() -> eframe::Result<()>
//set custom panic hook
#[cfg(not(debug_assertions))]
std::panic::set_hook(Box::new(|info| {
let appdata_path = std::env!("APPDATA");
// Write error message
std::fs::write(
format!("{appdata_path}/matthias/error.log"),
format!(
"[DATE]\n{:?}\n[PANIC]\n{:?}\n[STACK_BACKTRACE]\n{}\n",
chrono::Local::now(),
info.to_string(),
std::backtrace::Backtrace::force_capture().to_string()
),
)
.unwrap();

//Display error message
display_panic_message(format!("A panic! has occured the error is logged in %appdata%. Please send the generated file or this message to the developer!\nPanic: \n{:?}\nLocation: \n{:?}", {
match info.payload().downcast_ref::<&str>() {
Some(msg) => msg,
None => {
match info.payload().downcast_ref::<String>() {
Some(msg) => msg,
None => "Failed to display panic message",
}
},
}
}, info.location()));

}));

let native_options = eframe::NativeOptions {
Expand Down Expand Up @@ -92,23 +64,6 @@ async fn main() -> eframe::Result<()>
)
}

pub fn display_panic_message<T>(display: T)
where
T: ToString + std::marker::Send + 'static,
{
unsafe {
MessageBoxW(
0,
str::encode_utf16(display.to_string().as_str())
.chain(std::iter::once(0))
.collect::<Vec<_>>()
.as_ptr(),
w!("Panic!"),
MB_ICONERROR,
)
};
}

/* Gulyásleves recept
Heat the oil or lard in a large pot (preferably a Dutch oven). Add the onions along with a few spoonfuls of water (so they don’t brown) and a pinch of the salt. Cook slowly over very low heat for about 15 to 20 minutes, or until the onions are clear and glassy.
Expand Down

0 comments on commit fa4df61

Please sign in to comment.