1.Bug fix(for latest PyTk)

2.Minor logic fix
This commit is contained in:
ZaneYork 2020-03-24 18:22:34 +08:00
parent 5734a01260
commit ebb36e9388
9 changed files with 43 additions and 16 deletions

View File

@ -10,8 +10,8 @@ android {
applicationId "com.zane.smapiinstaller" applicationId "com.zane.smapiinstaller"
minSdkVersion 19 minSdkVersion 19
targetSdkVersion 28 targetSdkVersion 28
versionCode 23 versionCode 24
versionName "1.3.6" versionName "1.3.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true multiDexEnabled true

View File

@ -1,5 +1,5 @@
{ {
"version": 6, "version": 7,
"contents": [ "contents": [
{ {
"type": "COMPAT", "type": "COMPAT",
@ -14,8 +14,8 @@
"name": "SMAPI for Galaxy Store", "name": "SMAPI for Galaxy Store",
"assetPath": "compat/samsung_138/", "assetPath": "compat/samsung_138/",
"description": "SMAPI compat package for game 1.4.4.138 - latest, SMAPI 3.4.0", "description": "SMAPI compat package for game 1.4.4.138 - latest, SMAPI 3.4.0",
"url": "http://zaneyork.cn/download/compat/smapi_samsung_138.zip", "url": "http://zaneyork.cn/download/compat/smapi_samsung_138_2.zip",
"hash": "4028512fb1ae048557b63495de6f76cc454510d488a76d35eb1330ef021ec4ec" "hash": "6302a881de93f45aebee8eadc44b69c3cd73cf957366ba8ef339b0d103e6ae64"
}, },
{ {
"type": "LOCALE", "type": "LOCALE",

View File

@ -1,5 +1,5 @@
{ {
"version": 6, "version": 7,
"contents": [ "contents": [
{ {
"type": "COMPAT", "type": "COMPAT",
@ -14,8 +14,8 @@
"name": "SMAPI for Galaxy Store", "name": "SMAPI for Galaxy Store",
"assetPath": "compat/samsung_138/", "assetPath": "compat/samsung_138/",
"description": "SMAPI compat package for game 1.4.4.138 - latest, SMAPI 3.4.0", "description": "SMAPI compat package for game 1.4.4.138 - latest, SMAPI 3.4.0",
"url": "http://zaneyork.cn/download/compat/smapi_samsung_138.zip", "url": "http://zaneyork.cn/download/compat/smapi_samsung_138_2.zip",
"hash": "4028512fb1ae048557b63495de6f76cc454510d488a76d35eb1330ef021ec4ec" "hash": "6302a881de93f45aebee8eadc44b69c3cd73cf957366ba8ef339b0d103e6ae64"
}, },
{ {
"type": "LOCALE", "type": "LOCALE",

View File

@ -1,5 +1,5 @@
{ {
"version": 6, "version": 7,
"contents": [ "contents": [
{ {
"type": "COMPAT", "type": "COMPAT",
@ -14,8 +14,8 @@
"name": "SMAPI三星商店兼容包", "name": "SMAPI三星商店兼容包",
"assetPath": "compat/samsung_138/", "assetPath": "compat/samsung_138/",
"description": "SMAPI三星商店兼容包 适用版本1.4.4.138至今, SMAPI 3.4.0", "description": "SMAPI三星商店兼容包 适用版本1.4.4.138至今, SMAPI 3.4.0",
"url": "http://zaneyork.cn/download/compat/smapi_samsung_138.zip", "url": "http://zaneyork.cn/download/compat/smapi_samsung_138_2.zip",
"hash": "4028512fb1ae048557b63495de6f76cc454510d488a76d35eb1330ef021ec4ec" "hash": "6302a881de93f45aebee8eadc44b69c3cd73cf957366ba8ef339b0d103e6ae64"
}, },
{ {
"type": "LOCALE", "type": "LOCALE",

View File

@ -40,6 +40,7 @@ import java.security.cert.X509Certificate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.zip.Deflater; import java.util.zip.Deflater;
@ -57,6 +58,8 @@ public class ApkPatcher {
private AtomicReference<String> errorMessage = new AtomicReference<>(); private AtomicReference<String> errorMessage = new AtomicReference<>();
private AtomicInteger switchAction = new AtomicInteger();
public ApkPatcher(Context context) { public ApkPatcher(Context context) {
this.context = context; this.context = context;
} }
@ -119,6 +122,7 @@ public class ApkPatcher {
byte[] modifiedManifest = modifyManifest(manifest, apkFilesManifests); byte[] modifiedManifest = modifyManifest(manifest, apkFilesManifests);
if(apkFilesManifests.size() == 0) { if(apkFilesManifests.size() == 0) {
errorMessage.set(context.getString(R.string.error_no_supported_game_version)); errorMessage.set(context.getString(R.string.error_no_supported_game_version));
switchAction.set(R.string.menu_download);
return false; return false;
} }
if(modifiedManifest == null) { if(modifiedManifest == null) {
@ -291,4 +295,8 @@ public class ApkPatcher {
public AtomicReference<String> getErrorMessage() { public AtomicReference<String> getErrorMessage() {
return errorMessage; return errorMessage;
} }
public AtomicInteger getSwitchAction() {
return switchAction;
}
} }

View File

@ -3,6 +3,8 @@ package com.zane.smapiinstaller.logic;
import android.view.View; import android.view.View;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.MutableClassToInstanceMap;
import com.hjq.language.LanguagesManager; import com.hjq.language.LanguagesManager;
import com.lzy.okgo.OkGo; import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback; import com.lzy.okgo.callback.StringCallback;
@ -15,13 +17,14 @@ import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* 在线列表更新管理器 * 在线列表更新管理器
* @param <T> 列表类型 * @param <T> 列表类型
*/ */
public class UpdatableListManager<T extends UpdatableList> { public class UpdatableListManager<T extends UpdatableList> {
private static boolean updateChecked = false; private static ConcurrentHashMap<Class<?>, Boolean> updateChecked = new ConcurrentHashMap<>();
private static UpdatableList updatableList = null; private static UpdatableList updatableList = null;
@ -35,8 +38,9 @@ public class UpdatableListManager<T extends UpdatableList> {
*/ */
public UpdatableListManager(View root, String filename, Class<T> tClass, String updateUrl) { public UpdatableListManager(View root, String filename, Class<T> tClass, String updateUrl) {
updatableList = FileUtils.getLocaledAssetJson(root.getContext(), filename, tClass); updatableList = FileUtils.getLocaledAssetJson(root.getContext(), filename, tClass);
if(!updateChecked) { Boolean updated = updateChecked.get(tClass);
updateChecked = true; if(updated == null || !updated) {
updateChecked.put(tClass, true);
String languageSuffix = '.' + LanguagesManager.getAppLanguage(root.getContext()).getLanguage(); String languageSuffix = '.' + LanguagesManager.getAppLanguage(root.getContext()).getLanguage();
updateList(root, tClass, updateUrl, filename, languageSuffix); updateList(root, tClass, updateUrl, filename, languageSuffix);
} }

View File

@ -21,6 +21,8 @@ import org.apache.commons.lang3.StringUtils;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
@ -88,7 +90,18 @@ public class InstallFragment extends Fragment {
modAssetsManager.installDefaultMods(); modAssetsManager.installDefaultMods();
DialogUtils.setProgressDialogState(root, dialog, R.string.patching_package, 25); DialogUtils.setProgressDialogState(root, dialog, R.string.patching_package, 25);
if (!patcher.patch(path)) { if (!patcher.patch(path)) {
DialogUtils.showAlertDialog(root, R.string.error, StringUtils.firstNonBlank(patcher.getErrorMessage().get(), context.getString(R.string.failed_to_patch_game))); int target = patcher.getSwitchAction().getAndSet(0);
if(target == R.string.menu_download) {
DialogUtils.showConfirmDialog(root, R.string.error, StringUtils.firstNonBlank(patcher.getErrorMessage().get(), context.getString(R.string.failed_to_patch_game)), R.string.menu_download, R.string.cancel, (d, which) -> {
if(which == DialogAction.POSITIVE) {
NavController controller = Navigation.findNavController(root);
controller.navigate(InstallFragmentDirections.actionNavInstallToNavDownload());
}
});
}
else {
DialogUtils.showAlertDialog(root, R.string.error, StringUtils.firstNonBlank(patcher.getErrorMessage().get(), context.getString(R.string.failed_to_patch_game)));
}
return; return;
} }
DialogUtils.setProgressDialogState(root, dialog, R.string.signing_package, 55); DialogUtils.setProgressDialogState(root, dialog, R.string.signing_package, 55);
@ -100,7 +113,6 @@ public class InstallFragment extends Fragment {
DialogUtils.setProgressDialogState(root, dialog, R.string.installing_package, 99); DialogUtils.setProgressDialogState(root, dialog, R.string.installing_package, 99);
patcher.install(signPath); patcher.install(signPath);
dialog.incrementProgress(1); dialog.incrementProgress(1);
} }
catch (Exception e) { catch (Exception e) {
Crashes.trackError(e); Crashes.trackError(e);

View File

@ -10,6 +10,9 @@
android:name="com.zane.smapiinstaller.ui.install.InstallFragment" android:name="com.zane.smapiinstaller.ui.install.InstallFragment"
android:label="@string/menu_install" android:label="@string/menu_install"
tools:layout="@layout/fragment_install"> tools:layout="@layout/fragment_install">
<action
android:id="@+id/action_nav_install_to_nav_download"
app:destination="@id/nav_download" />
</fragment> </fragment>
<fragment <fragment
android:id="@+id/config_edit_fragment" android:id="@+id/config_edit_fragment"