diff --git a/AM2RPortHelperCLI/Program.cs b/AM2RPortHelperCLI/Program.cs index 80b4d31..952c011 100644 --- a/AM2RPortHelperCLI/Program.cs +++ b/AM2RPortHelperCLI/Program.cs @@ -20,7 +20,7 @@ internal static class Program var linuxOption = new Option(new[] { "-l", "--linux" }, "The output file path for the Linux mod. None given equals to no Linux port."); var androidOption = new Option(new[] { "-a", "--android" }, "The output file path for the Android mod. None given equals to no Android port."); var macOption = new Option(new[] { "-m", "--mac" }, "The output file path for the Mac mod. None given equals to no Mac port."); - var nameOption = new Option(new[] { "-n", "--name" }, "The name used for the Mac mod. Required for the Mac option, has no effect on anything else."); + var nameOption = new Option(new[] { "-n", "--name" }, "The name used for the Mac or Android mod. Required for the Mac option, and optional for the Android version. Has no effect on anything else."); RootCommand rootCommand = new RootCommand { @@ -62,7 +62,7 @@ internal static class Program } if (androidPath is not null) { - PortHelper.PortWindowsToAndroid(inputModPath.FullName, androidPath.FullName); + PortHelper.PortWindowsToAndroid(inputModPath.FullName, androidPath.FullName, string.IsNullOrWhiteSpace(modName) ? null : modName); } if (macPath is not null) { @@ -73,7 +73,7 @@ internal static class Program } PortHelper.PortWindowsToMac(inputModPath.FullName, macPath.FullName, modName); } - Console.WriteLine("Done"); + Console.WriteLine("Done."); } private static void RunInteractive() { diff --git a/AM2RPortHelperGUI/AM2RPortHelperGUI/MainForm.cs b/AM2RPortHelperGUI/AM2RPortHelperGUI/MainForm.cs index a4f4fc2..e3c02c0 100644 --- a/AM2RPortHelperGUI/AM2RPortHelperGUI/MainForm.cs +++ b/AM2RPortHelperGUI/AM2RPortHelperGUI/MainForm.cs @@ -88,7 +88,7 @@ public partial class MainForm : Form if (checkboxLinux.Checked.Value) await Task.Run(() => PortHelper.PortWindowsToLinux(modZipPath,linuxPath, OutputHandlerDelegate)); if (checkboxAndroid.Checked.Value) - await Task.Run(() =>PortHelper.PortWindowsToAndroid(modZipPath, androidPath, OutputHandlerDelegate)); + await Task.Run(() =>PortHelper.PortWindowsToAndroid(modZipPath, androidPath, null, OutputHandlerDelegate)); if (checkboxMac.Checked.Value) { MessageBox.Show(this, "Currently the mod name is set as \"foo\", you need to manually correct that later! (Search for the files yoyorunner.config and Info.plist"); diff --git a/AM2RPortHelperLib/PortHelper.cs b/AM2RPortHelperLib/PortHelper.cs index a08e6b3..68e67e2 100644 --- a/AM2RPortHelperLib/PortHelper.cs +++ b/AM2RPortHelperLib/PortHelper.cs @@ -199,7 +199,7 @@ public static partial class PortHelper Directory.Delete(assetsDir, true); } - public static void PortWindowsToAndroid(string inputRawZipPath, string outputRawApkPath, OutputHandlerDelegate outputDelegate = null) + public static void PortWindowsToAndroid(string inputRawZipPath, string outputRawApkPath, string modName = null, OutputHandlerDelegate outputDelegate = null) { outputHandler = outputDelegate; string extractDirectory = tmp + "/" + Path.GetFileNameWithoutExtension(inputRawZipPath); @@ -265,6 +265,15 @@ public static partial class PortHelper SaveAndroidIcon(orig, 144, resPath + "/drawable-xxhdpi-v4/icon.png"); SaveAndroidIcon(orig, 192, resPath + "/drawable-xxxhdpi-v4/icon.png"); + // If a custom name was given, replace it. + //TODO: handle errors + if (modName != null) + { + string manifestFile = File.ReadAllText(apkDir + "/AndroidManifest.xml"); + manifestFile = manifestFile.Replace("com.companyname.AM2RWrapper", "com.companyname." + modName); + File.WriteAllText(apkDir + "/AndroidManifest.xml", manifestFile); + } + // Run APKTOOL and build the apk SendOutput("Rebuild apk..."); pStartInfo = new ProcessStartInfo