feat: -fullscreen

This commit is contained in:
neoapps-dev 2026-08-12 19:45:50 +03:00
parent b74b954396
commit ab7ed4d6a4
3 changed files with 23 additions and 5 deletions

@ -1 +1 @@
Subproject commit 54ee94d6d6ebed6d14c39217e02d2ce8872996df
Subproject commit da115452a9f96d6cea2e7ae1904737e4474c09e6

View file

@ -4,7 +4,11 @@ pub enum BridgeAction {
OpenSettings,
}
pub fn launch_bridge(instance_path: String, action: BridgeAction) -> Result<(), String> {
pub fn launch_bridge(
instance_path: String,
action: BridgeAction,
extra_args: Vec<String>,
) -> Result<(), String> {
#[cfg(target_os = "android")]
{
use jni::objects::{JObject, JValue};
@ -16,6 +20,7 @@ pub fn launch_bridge(instance_path: String, action: BridgeAction) -> Result<(),
activity: &JObject,
action: &str,
instance_path: &str,
extra_args: &[String],
) -> jni::errors::Result<()> {
let bridge_class =
find_class(env, activity, "dev.lcehub.emerald.LauncherBridgeActivity".to_string())?;
@ -44,6 +49,16 @@ pub fn launch_bridge(instance_path: String, action: BridgeAction) -> Result<(),
&[(&extra_path).into(), (&path_str).into()],
)?;
let extra_args_key = env.new_string("extra_args")?;
let extra_args_json =
env.new_string(&serde_json::to_string(extra_args).unwrap_or_else(|_| "[]".into()))?;
env.call_method(
&intent,
"putExtra",
"(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;",
&[(&extra_args_key).into(), (&extra_args_json).into()],
)?;
env.call_method(
&intent,
"addFlags",
@ -68,7 +83,7 @@ pub fn launch_bridge(instance_path: String, action: BridgeAction) -> Result<(),
}
.to_string();
dispatch(move |env, activity, _webview| {
if let Err(e) = start_bridge(env, activity, &action_str, &instance_path) {
if let Err(e) = start_bridge(env, activity, &action_str, &instance_path, &extra_args) {
eprintln!("[android_bridge] failed to start activity: {e}");
}
});
@ -77,7 +92,7 @@ pub fn launch_bridge(instance_path: String, action: BridgeAction) -> Result<(),
}
#[cfg(not(target_os = "android"))]
{
let _ = (instance_path, action);
let _ = (instance_path, action, extra_args);
Err("Only supported on Android".into())
}
}

View file

@ -32,7 +32,7 @@ pub async fn launch_game(
) -> Result<(), String> {
#[cfg(target_os = "android")]
{
let _ = (state, extra_args);
let _ = state;
let mut servers = servers;
let working_dir = util::get_instance_working_dir(&app, &instance_id);
if !working_dir.join("Minecraft.Client.exe").exists() {
@ -56,6 +56,7 @@ pub async fn launch_game(
crate::android_runtime::launch_bridge(
working_dir.to_string_lossy().to_string(),
crate::android_runtime::BridgeAction::Play,
extra_args,
)
}
#[cfg(not(target_os = "android"))]
@ -341,6 +342,7 @@ pub fn open_instance_folder(app: AppHandle, instance_id: String) {
let _ = crate::android_runtime::launch_bridge(
folder.to_string_lossy().to_string(),
crate::android_runtime::BridgeAction::OpenContainer,
Vec::new(),
);
}
#[cfg(not(target_os = "android"))]
@ -360,6 +362,7 @@ pub fn open_container_settings(app: AppHandle, instance_id: String) -> Result<()
crate::android_runtime::launch_bridge(
folder.to_string_lossy().to_string(),
crate::android_runtime::BridgeAction::OpenSettings,
Vec::new(),
)
}
#[cfg(not(target_os = "android"))]