diff --git a/app/src/main/java/com/fox2code/mmm/background/BackgroundUpdateChecker.java b/app/src/main/java/com/fox2code/mmm/background/BackgroundUpdateChecker.java index e6ca625..a6dbcb3 100644 --- a/app/src/main/java/com/fox2code/mmm/background/BackgroundUpdateChecker.java +++ b/app/src/main/java/com/fox2code/mmm/background/BackgroundUpdateChecker.java @@ -157,26 +157,28 @@ public class BackgroundUpdateChecker extends Worker { if (repoModule != null) { remoteVersionCode = String.valueOf(repoModule.moduleInfo.versionCode); } - int localVersionCode = Integer.parseInt(String.valueOf(localModuleInfo.versionCode)); - int remoteVersionCodeInt = Integer.parseInt(remoteVersionCode); - int wantsVersion = Integer.parseInt(version.split(":")[1].replaceAll("[^0-9]", "")); - // now find out if user wants up to and including this version, or this version and newer - // if it starts with ^, it's this version and newer, if it ends with $, it's this version and older - if (version.startsWith("^")) { - // this version and newer - if (wantsVersion <= remoteVersionCodeInt || wantsVersion <= localVersionCode) { + if (!version.isEmpty()) { + int localVersionCode = Integer.parseInt(String.valueOf(localModuleInfo.versionCode)); + int remoteVersionCodeInt = Integer.parseInt(remoteVersionCode); + int wantsVersion = Integer.parseInt(version.split(":")[1].replaceAll("[^0-9]", "")); + // now find out if user wants up to and including this version, or this version and newer + // if it starts with ^, it's this version and newer, if it ends with $, it's this version and older + if (version.startsWith("^")) { + // this version and newer + if (wantsVersion <= remoteVersionCodeInt || wantsVersion <= localVersionCode) { + // if it is, we skip it + continue; + } + } else if (version.endsWith("$")) { + // this version and older + if (wantsVersion >= remoteVersionCodeInt || wantsVersion >= localVersionCode) { + // if it is, we skip it + continue; + } + } else if (wantsVersion == remoteVersionCodeInt || wantsVersion == localVersionCode) { // if it is, we skip it continue; } - } else if (version.endsWith("$")) { - // this version and older - if (wantsVersion >= remoteVersionCodeInt || wantsVersion >= localVersionCode) { - // if it is, we skip it - continue; - } - } else if (wantsVersion == remoteVersionCodeInt || wantsVersion == localVersionCode) { - // if it is, we skip it - continue; } if (localModuleInfo.updateVersionCode > localModuleInfo.versionCode && !PropUtils.isNullString(localModuleInfo.updateVersion)) { moduleUpdateCount++; diff --git a/app/src/main/java/com/fox2code/mmm/module/ModuleHolder.java b/app/src/main/java/com/fox2code/mmm/module/ModuleHolder.java index 5bf9ec4..59edeaf 100644 --- a/app/src/main/java/com/fox2code/mmm/module/ModuleHolder.java +++ b/app/src/main/java/com/fox2code/mmm/module/ModuleHolder.java @@ -156,40 +156,43 @@ public final class ModuleHolder implements Comparable { if (repoModule != null) { remoteVersionCode = String.valueOf(repoModule.moduleInfo.versionCode); } - // now, coerce everything into an int - int localVersionCode = Integer.parseInt(String.valueOf(moduleInfo.versionCode)); - int remoteVersionCodeInt = Integer.parseInt(remoteVersionCode); - int wantsVersion = Integer.parseInt(version.split(":")[1].replaceAll("[^0-9]", "")); - // now find out if user wants up to and including this version, or this version and newer - // if it starts with ^, it's this version and newer, if it ends with $, it's this version and older - if (version.startsWith("^")) { - // this version and newer - if (wantsVersion <= remoteVersionCodeInt || wantsVersion <= localVersionCode) { + if (!version.isEmpty()) { + // now, coerce everything into an int + int localVersionCode = Integer.parseInt(String.valueOf(moduleInfo.versionCode)); + int remoteVersionCodeInt = Integer.parseInt(remoteVersionCode); + int wantsVersion = Integer.parseInt(version.split(":")[1].replaceAll("[^0-9]", "")); + // now find out if user wants up to and including this version, or this version and newer + // if it starts with ^, it's this version and newer, if it ends with $, it's this version and older + if (version.startsWith("^")) { + // this version and newer + if (wantsVersion <= remoteVersionCodeInt || wantsVersion <= localVersionCode) { + // if it is, we skip it + ignoreUpdate = true; + } + } else if (version.endsWith("$")) { + // this version and older + if (wantsVersion >= remoteVersionCodeInt || wantsVersion >= localVersionCode) { + // if it is, we skip it + ignoreUpdate = true; + } + } else if (wantsVersion == remoteVersionCodeInt || wantsVersion == localVersionCode) { // if it is, we skip it ignoreUpdate = true; } - } else if (version.endsWith("$")) { - // this version and older - if (wantsVersion >= remoteVersionCodeInt || wantsVersion >= localVersionCode) { - // if it is, we skip it - ignoreUpdate = true; - } - } else if (wantsVersion == remoteVersionCodeInt || wantsVersion == localVersionCode) { - // if it is, we skip it - ignoreUpdate = true; } - MainApplication.getINSTANCE().modulesHaveUpdates = true; - if (!MainApplication.getINSTANCE().updateModules.contains(this.moduleId)) { - MainApplication.getINSTANCE().updateModules.add(this.moduleId); - MainApplication.getINSTANCE().updateModuleCount++; - } - Timber.d("modulesHaveUpdates = %s, updateModuleCount = %s", MainApplication.getINSTANCE().modulesHaveUpdates, MainApplication.getINSTANCE().updateModuleCount); if (ignoreUpdate) { Timber.d("Module %s has update, but is ignored", this.moduleId); return Type.INSTALLABLE; + } else { + MainApplication.getINSTANCE().modulesHaveUpdates = true; + if (!MainApplication.getINSTANCE().updateModules.contains(this.moduleId)) { + MainApplication.getINSTANCE().updateModules.add(this.moduleId); + MainApplication.getINSTANCE().updateModuleCount++; + } + Timber.d("modulesHaveUpdates = %s, updateModuleCount = %s", MainApplication.getINSTANCE().modulesHaveUpdates, MainApplication.getINSTANCE().updateModuleCount); + Timber.d("Module %s has update", this.moduleId); + return Type.UPDATABLE; } - Timber.d("Module %s has update", this.moduleId); - return Type.UPDATABLE; } else { return Type.INSTALLED; } diff --git a/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java b/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java index 43db237..b5a5388 100644 --- a/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java +++ b/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java @@ -671,8 +671,9 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity { EditText editText = (EditText) layout.getChildAt(i); String text = editText.getText().toString(); if (!text.isEmpty()) { - // text can only contain numbers - text = text.replaceAll("[^0-9]", ""); + // text can only contain numbers and the characters ^ and $ + // so we remove all non-numbers and non ^ and $ + text = text.replaceAll("[^0-9^$]", ""); // we have to use module id even though we show name stringSetTemp.add(localModuleInfos.stream().filter(localModuleInfo -> localModuleInfo.name.equals(editText.getHint().toString())).findFirst().orElse(null).id + ":" + text); Timber.d("text is %s for %s", text, editText.getHint().toString());