1.Auto extract when advanced mode is enabled

This commit is contained in:
ZaneYork 2020-05-28 18:00:23 +08:00
parent 9f642d9462
commit d2809d099e
4 changed files with 20 additions and 2 deletions

View File

@ -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;
}
}

View File

@ -78,4 +78,6 @@
<string name="privacy_policy">隱私權條款</string>
<string name="settings_advanced_mode">高級安裝模式</string>
<string name="button_initial">初始化</string>
<string name="error_directory_exists_with_same_filename">%1$s不是一個文件夾, 請手動刪除該文件</string>
<string name="error_patch_crc_incorrect">增量更新%1$s失敗: CRC (%2$s))</string>
</resources>

View File

@ -78,4 +78,6 @@
<string name="privacy_policy">隐私权政策</string>
<string name="settings_advanced_mode">高级安装模式</string>
<string name="button_initial">初始化</string>
<string name="error_directory_exists_with_same_filename">%1$s不是一个文件夹, 请手动删除该文件</string>
<string name="error_patch_crc_incorrect">增量更新%1$s失败: CRC (%2$s))</string>
</resources>

View File

@ -82,4 +82,6 @@
<string name="privacy_policy">Privacy Policy</string>
<string name="settings_advanced_mode">Advanced Patch Mode</string>
<string name="button_initial">Initial</string>
<string name="error_directory_exists_with_same_filename">%1$s is not a directory, please delete it manually.</string>
<string name="error_patch_crc_incorrect">Patch %1$s failed: CRC (%2$s))</string>
</resources>