1.Log parser website button

2.Bump version
This commit is contained in:
ZaneYork 2020-03-31 18:33:20 +08:00
parent 5cec14c4cb
commit bcb17bb3cc
8 changed files with 43 additions and 19 deletions

View File

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

View File

@ -121,26 +121,24 @@ public class MainActivity extends AppCompatActivity {
public void onSuccess(Response<AppUpdateCheckResultDto> 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);

View File

@ -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<List<ModUpdateCheckResponseDto>> callback) {
if(checkUpdating.get()) {
if (checkUpdating.get()) {
return;
}
List<ModUpdateCheckRequestDto.ModInfo> 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));

View File

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

View File

@ -27,6 +27,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/button_log_parser"
android:text="@string/parser"
android:visibility="invisible"
app:layout_constraintStart_toEndOf="@id/guideline_v1"
app:layout_constraintTop_toBottomOf="@id/guideline_h2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/button_config_cancel"
android:text="@string/cancel"

View File

@ -69,4 +69,6 @@
<string name="open_with">打開為</string>
<string name="no_update_text">所有MOD已是最新狀態</string>
<string name="app_update_detected">檢測到新版本: %1$s</string>
<string name="parser">格式化</string>
<string name="mod_version_update_checking">正在檢查MOD更新</string>
</resources>

View File

@ -69,4 +69,6 @@
<string name="open_with">打开为</string>
<string name="no_update_text">所有MOD已是最新状态</string>
<string name="app_update_detected">检测到新版本: %1$s</string>
<string name="parser">格式化</string>
<string name="mod_version_update_checking">正在检查MOD更新</string>
</resources>

View File

@ -73,4 +73,6 @@
<string name="open_with">Open With</string>
<string name="no_update_text">All mods are up to date</string>
<string name="app_update_detected">New version detected: %1$s</string>
<string name="parser">Parser</string>
<string name="mod_version_update_checking">Checking for mod updates</string>
</resources>