diff --git a/app/build.gradle b/app/build.gradle index e9cb941..f4275e1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,8 +12,8 @@ android { applicationId "com.zane.smapiinstaller" minSdkVersion 19 targetSdkVersion 28 - versionCode 28 - versionName "1.3.11" + versionCode 29 + versionName "1.4.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true diff --git a/app/src/main/java/com/zane/smapiinstaller/MainActivity.java b/app/src/main/java/com/zane/smapiinstaller/MainActivity.java index 1d4485d..661d924 100644 --- a/app/src/main/java/com/zane/smapiinstaller/MainActivity.java +++ b/app/src/main/java/com/zane/smapiinstaller/MainActivity.java @@ -121,26 +121,24 @@ public class MainActivity extends AppCompatActivity { public void onSuccess(Response response) { AppUpdateCheckResultDto dto = response.body(); if (dto != null && CommonLogic.getVersionCode(MainActivity.this) < dto.getVersionCode()) { - if(appConfig != null && StringUtils.equals(appConfig.getValue(), String.valueOf(dto.getVersionCode()))) { + if (appConfig != null && StringUtils.equals(appConfig.getValue(), String.valueOf(dto.getVersionCode()))) { return; } DialogUtils.showConfirmDialog(toolbar, R.string.settings_check_for_updates, MainActivity.this.getString(R.string.app_update_detected, dto.getVersionName()), (dialog, which) -> { - if (which == DialogAction.POSITIVE) { - CommonLogic.openInPlayStore(MainActivity.this); - } - else { - AppConfig config; - if(appConfig != null) { - config = appConfig; - config.setValue(String.valueOf(dto.getVersionCode())); - } - else { - config = new AppConfig(null, AppConfigKey.IGNORE_UPDATE_VERSION_CODE, String.valueOf(dto.getVersionCode())); - } - appConfigDao.insertOrReplace(config); - } - }); + if (which == DialogAction.POSITIVE) { + CommonLogic.openInPlayStore(MainActivity.this); + } else { + AppConfig config; + if (appConfig != null) { + config = appConfig; + config.setValue(String.valueOf(dto.getVersionCode())); + } else { + config = new AppConfig(null, AppConfigKey.IGNORE_UPDATE_VERSION_CODE, String.valueOf(dto.getVersionCode())); + } + appConfigDao.insertOrReplace(config); + } + }); } } }); @@ -319,6 +317,7 @@ public class MainActivity extends AppCompatActivity { modAssetsManager.checkModUpdate((list) -> { if (list.isEmpty()) { CommonLogic.runOnUiThread(this, (activity) -> Toast.makeText(activity, R.string.no_update_text, Toast.LENGTH_SHORT).show()); + return; } try { NavController controller = Navigation.findNavController(this, R.id.nav_host_fragment); diff --git a/app/src/main/java/com/zane/smapiinstaller/logic/ModAssetsManager.java b/app/src/main/java/com/zane/smapiinstaller/logic/ModAssetsManager.java index 5193913..5962134 100644 --- a/app/src/main/java/com/zane/smapiinstaller/logic/ModAssetsManager.java +++ b/app/src/main/java/com/zane/smapiinstaller/logic/ModAssetsManager.java @@ -5,6 +5,7 @@ import android.content.pm.PackageInfo; import android.os.Environment; import android.util.Log; import android.view.View; +import android.widget.Toast; import com.fasterxml.jackson.core.type.TypeReference; import com.google.common.base.Joiner; @@ -295,7 +296,7 @@ public class ModAssetsManager { } public void checkModUpdate(Consumer> callback) { - if(checkUpdating.get()) { + if (checkUpdating.get()) { return; } List list = StreamSupport.stream(findAllInstalledMods(false)) @@ -309,6 +310,7 @@ public class ModAssetsManager { if (gamePackageInfo == null) { return; } + context.runOnUiThread(() -> Toast.makeText(context, R.string.mod_version_update_checking, Toast.LENGTH_SHORT).show()); checkUpdating.set(true); try { ModUpdateCheckRequestDto requestDto = new ModUpdateCheckRequestDto(list, new ModUpdateCheckRequestDto.SemanticVersion(gamePackageInfo.versionName)); diff --git a/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigEditFragment.java b/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigEditFragment.java index ab6d2e0..399ce70 100644 --- a/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigEditFragment.java +++ b/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigEditFragment.java @@ -43,6 +43,8 @@ public class ConfigEditFragment extends Fragment { Button buttonConfigSave; @BindView(R.id.button_config_cancel) Button buttonConfigCancel; + @BindView(R.id.button_log_parser) + Button buttonLogParser; @Override public View onCreateView(@NonNull LayoutInflater inflater, @@ -56,6 +58,7 @@ public class ConfigEditFragment extends Fragment { editText.setKeyListener(null); buttonConfigSave.setVisibility(View.INVISIBLE); buttonConfigCancel.setVisibility(View.INVISIBLE); + buttonLogParser.setVisibility(View.VISIBLE); } configPath = args.getConfigPath(); File file = new File(configPath); @@ -108,4 +111,9 @@ public class ConfigEditFragment extends Fragment { void onConfigCancel() { CommonLogic.doOnNonNull(getView(), view -> Navigation.findNavController(view).popBackStack()); } + + @OnClick(R.id.button_log_parser) + void onLogParser() { + CommonLogic.doOnNonNull(getContext(), context -> CommonLogic.openUrl(context, "https://smapi.io/log")); + } } diff --git a/app/src/main/res/layout/fragment_config_edit.xml b/app/src/main/res/layout/fragment_config_edit.xml index 4b9d069..3d38a29 100644 --- a/app/src/main/res/layout/fragment_config_edit.xml +++ b/app/src/main/res/layout/fragment_config_edit.xml @@ -27,6 +27,15 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" /> +