From d2809d099edc23a152bfce170f5e061484b06a23 Mon Sep 17 00:00:00 2001 From: ZaneYork Date: Thu, 28 May 2020 18:00:23 +0800 Subject: [PATCH] 1.Auto extract when advanced mode is enabled --- .../zane/smapiinstaller/logic/ApkPatcher.java | 16 ++++++++++++++-- app/src/main/res/values-zh-rTW/strings.xml | 2 ++ app/src/main/res/values-zh/strings.xml | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/zane/smapiinstaller/logic/ApkPatcher.java b/app/src/main/java/com/zane/smapiinstaller/logic/ApkPatcher.java index 6dfb6f7..7e7f84d 100644 --- a/app/src/main/java/com/zane/smapiinstaller/logic/ApkPatcher.java +++ b/app/src/main/java/com/zane/smapiinstaller/logic/ApkPatcher.java @@ -125,6 +125,16 @@ public class ApkPatcher { }); return distFile.getAbsolutePath(); } else if (advancedStage == 1) { + File contentFolder = new File(externalFilesDir.getAbsolutePath() + "/StardewValley/Content"); + if(contentFolder.exists()) { + if(!contentFolder.isDirectory()) { + errorMessage.set(context.getString(R.string.error_directory_exists_with_same_filename, contentFolder.getAbsolutePath())); + return null; + } + } + else { + extract(0); + } ZipUtils.removeEntries(sourceDir, "assets/Content", distFile.getAbsolutePath(), (progress) -> emitProgress((int) (progress * 0.05))); } else { Files.copy(apkFile, distFile); @@ -195,7 +205,8 @@ public class ApkPatcher { if (StringUtils.equals(crc, entry.getPatchCrc())) { bytes = FileUtils.patchFile(originBytes, bytes); if (bytes == null) { - errorMessage.set(StringUtils.stripToEmpty(errorMessage.get()) + "\nPatch " + entry.getTargetPath() + " failed"); + String errorMsg = context.getString(R.string.error_patch_crc_incorrect, entry.getTargetPath(), crc); + errorMessage.set(StringUtils.stripToEmpty(errorMessage.get()) + "\n" + errorMsg); return null; } } @@ -203,7 +214,8 @@ public class ApkPatcher { bytes = originBytes; } else { - errorMessage.set(StringUtils.stripToEmpty(errorMessage.get()) + "\nPatch " + entry.getTargetPath() + " failed: CRC (" + crc + ")"); + String errorMsg = context.getString(R.string.error_patch_crc_incorrect, entry.getTargetPath(), crc); + errorMessage.set(StringUtils.stripToEmpty(errorMessage.get()) + "\n" + errorMsg); return null; } } diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 4426cad..fb66564 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -78,4 +78,6 @@ 隱私權條款 高級安裝模式 初始化 + %1$s不是一個文件夾, 請手動刪除該文件 + 增量更新%1$s失敗: CRC (%2$s)) diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index e40bad6..afdbd1b 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -78,4 +78,6 @@ 隐私权政策 高级安装模式 初始化 + %1$s不是一个文件夹, 请手动删除该文件 + 增量更新%1$s失败: CRC (%2$s)) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index db653fd..37c7e7d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -82,4 +82,6 @@ Privacy Policy Advanced Patch Mode Initial + %1$s is not a directory, please delete it manually. + Patch %1$s failed: CRC (%2$s))