@@ -116,7 +116,7 @@ class ModuleHolder : Comparable<ModuleHolder?> {
116
116
Type .NOTIFICATION
117
117
} else if (moduleInfo == null && repoModule != null ) {
118
118
Type .INSTALLABLE
119
- } else if (moduleInfo!! .versionCode < moduleInfo!! .updateVersionCode || repoModule != null && moduleInfo!! .versionCode < repoModule!! .moduleInfo.versionCode) {
119
+ } else if (moduleInfo != = null && moduleInfo !! .versionCode < moduleInfo!! .updateVersionCode || repoModule != null && moduleInfo!! .versionCode < repoModule!! .moduleInfo.versionCode) {
120
120
if (MainApplication .forceDebugLogging) Timber .i(" Module %s is updateable" , moduleId)
121
121
var ignoreUpdate = false
122
122
try {
@@ -188,17 +188,21 @@ class ModuleHolder : Comparable<ModuleHolder?> {
188
188
if (MainApplication .forceDebugLogging) Timber .d(" Module %s has update, but is ignored" , moduleId)
189
189
Type .INSTALLABLE
190
190
} else {
191
- INSTANCE !! .modulesHaveUpdates = true
192
- if (! INSTANCE !! .updateModules.contains(moduleId)) {
193
- INSTANCE !! .updateModules + = moduleId
194
- INSTANCE !! .updateModuleCount++
191
+ if (hasUpdate()) {
192
+ INSTANCE !! .modulesHaveUpdates = true
193
+ if (! INSTANCE !! .updateModules.contains(moduleId)) {
194
+ INSTANCE !! .updateModules + = moduleId
195
+ INSTANCE !! .updateModuleCount++
196
+ }
197
+ if (MainApplication .forceDebugLogging) Timber .d(
198
+ " modulesHaveUpdates = %s, updateModuleCount = %s" ,
199
+ INSTANCE !! .modulesHaveUpdates,
200
+ INSTANCE !! .updateModuleCount
201
+ )
202
+ Type .UPDATABLE
203
+ } else {
204
+ Type .INSTALLED
195
205
}
196
- if (MainApplication .forceDebugLogging) Timber .d(
197
- " modulesHaveUpdates = %s, updateModuleCount = %s" ,
198
- INSTANCE !! .modulesHaveUpdates,
199
- INSTANCE !! .updateModuleCount
200
- )
201
- Type .UPDATABLE
202
206
}
203
207
} else {
204
208
Type .INSTALLED
@@ -214,13 +218,40 @@ class ModuleHolder : Comparable<ModuleHolder?> {
214
218
}
215
219
216
220
fun shouldRemove (): Boolean {
217
- if (repoModule != null && moduleInfo != null && ! hasUpdate()) {
221
+ // if type is not installable or updatable and we have repoModule, we should remove
222
+ if (type != = Type .INSTALLABLE && type != = Type .UPDATABLE && repoModule != null ) {
223
+ Timber .d(" Removing %s because type is %s and repoModule is not null" , moduleId, type.name)
224
+ return true
225
+ }
226
+ // if type is updatable but we don't have an update, remove
227
+ if (type == = Type .UPDATABLE && ! hasUpdate()) {
228
+ Timber .d(" Removing %s because type is %s and has no update" , moduleId, type.name)
229
+ return true
230
+ }
231
+ // if type is installed we have an update, remove
232
+ if (type == = Type .INSTALLED && repoModule != null && hasUpdate()) {
233
+ Timber .d(" Removing %s because type is %s and has update and repoModule is not null" , moduleId, type.name)
234
+ return true
235
+ }
236
+ // if type is installed but repomodule is not null, we should remove
237
+ if (type == = Type .INSTALLED && repoModule != null ) {
238
+ Timber .d(" Removing %s because type is %s and repoModule is not null" , moduleId, type.name)
218
239
return true
219
240
}
241
+ // if lowqualitymodulefilter is enabled and module is low quality, remove
242
+ if (! isDisableLowQualityModuleFilter) {
243
+ if (repoModule != null && isLowQualityModule(repoModule!! .moduleInfo)) {
244
+ Timber .d(" Removing %s because repoModule is not null and is low quality" , moduleId)
245
+ return true
246
+ }
247
+ if (moduleInfo != null && isLowQualityModule(moduleInfo!! )) {
248
+ Timber .d(" Removing %s because moduleInfo is not null and is low quality" , moduleId)
249
+ return true
250
+ }
251
+ }
252
+ // if type is installed but
220
253
return notificationType?.shouldRemove()
221
- ? : (footerPx == - 1 && moduleInfo == null && (repoModule == null || ! repoModule!! .repoData.isEnabled || isLowQualityModule(
222
- repoModule!! .moduleInfo
223
- ) && ! isDisableLowQualityModuleFilter))
254
+ ? : (footerPx == - 1 && moduleInfo == null && (repoModule == null || ! repoModule!! .repoData.isEnabled))
224
255
}
225
256
226
257
fun getButtons (
@@ -295,7 +326,21 @@ class ModuleHolder : Comparable<ModuleHolder?> {
295
326
}
296
327
297
328
fun hasUpdate (): Boolean {
298
- return moduleInfo != null && repoModule != null && moduleInfo!! .versionCode < repoModule!! .moduleInfo.versionCode
329
+ if (moduleInfo == null ) {
330
+ Timber .w(" Module %s has no moduleInfo" , moduleId)
331
+ return false
332
+ }
333
+ if (repoModule == null && ! INSTANCE !! .repoModules.containsKey(moduleId)) {
334
+ if (moduleInfo!! .updateVersionCode > moduleInfo!! .versionCode) {
335
+ Timber .d(" Module %s has update from %s to %s" , moduleId, moduleInfo!! .versionCode, moduleInfo!! .updateVersionCode)
336
+ return true
337
+ }
338
+ } else if (repoModule != null && repoModule!! .moduleInfo.versionCode > moduleInfo!! .versionCode) {
339
+ Timber .d(" Module %s has update from repo from %s to %s" , moduleId, moduleInfo!! .versionCode, repoModule!! .moduleInfo.versionCode)
340
+ return true
341
+ }
342
+ Timber .d(" Module %s has no update" , moduleId)
343
+ return false
299
344
}
300
345
301
346
override operator fun compareTo (other : ModuleHolder ? ): Int {
0 commit comments