|
|
@ -72,30 +72,19 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ModuleInfo getMainModuleInfo() {
|
|
|
|
public ModuleInfo getMainModuleInfo() {
|
|
|
|
return this.repoModule != null && (this.moduleInfo == null ||
|
|
|
|
return this.repoModule != null && (this.moduleInfo == null || this.moduleInfo.versionCode < this.repoModule.moduleInfo.versionCode) ? this.repoModule.moduleInfo : this.moduleInfo;
|
|
|
|
this.moduleInfo.versionCode < this.repoModule.moduleInfo.versionCode)
|
|
|
|
|
|
|
|
? this.repoModule.moduleInfo : this.moduleInfo;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getUpdateZipUrl() {
|
|
|
|
public String getUpdateZipUrl() {
|
|
|
|
return this.moduleInfo == null || (this.repoModule != null &&
|
|
|
|
return this.moduleInfo == null || (this.repoModule != null && this.moduleInfo.updateVersionCode < this.repoModule.moduleInfo.versionCode) ? this.repoModule.zipUrl : this.moduleInfo.updateZipUrl;
|
|
|
|
this.moduleInfo.updateVersionCode <
|
|
|
|
|
|
|
|
this.repoModule.moduleInfo.versionCode) ?
|
|
|
|
|
|
|
|
this.repoModule.zipUrl : this.moduleInfo.updateZipUrl;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getUpdateZipRepo() {
|
|
|
|
public String getUpdateZipRepo() {
|
|
|
|
return this.moduleInfo == null || (this.repoModule != null &&
|
|
|
|
return this.moduleInfo == null || (this.repoModule != null && this.moduleInfo.updateVersionCode < this.repoModule.moduleInfo.versionCode) ? this.repoModule.repoData.id : "update_json";
|
|
|
|
this.moduleInfo.updateVersionCode <
|
|
|
|
|
|
|
|
this.repoModule.moduleInfo.versionCode) ?
|
|
|
|
|
|
|
|
this.repoModule.repoData.id : "update_json";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getUpdateZipChecksum() {
|
|
|
|
public String getUpdateZipChecksum() {
|
|
|
|
return this.moduleInfo == null || (this.repoModule != null &&
|
|
|
|
return this.moduleInfo == null || (this.repoModule != null && this.moduleInfo.updateVersionCode < this.repoModule.moduleInfo.versionCode) ? this.repoModule.checksum : this.moduleInfo.updateChecksum;
|
|
|
|
this.moduleInfo.updateVersionCode <
|
|
|
|
|
|
|
|
this.repoModule.moduleInfo.versionCode) ?
|
|
|
|
|
|
|
|
this.repoModule.checksum : this.moduleInfo.updateChecksum;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getMainModuleName() {
|
|
|
|
public String getMainModuleName() {
|
|
|
@ -121,8 +110,7 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
|
|
|
|
public String getUpdateTimeText() {
|
|
|
|
public String getUpdateTimeText() {
|
|
|
|
if (this.repoModule == null) return "";
|
|
|
|
if (this.repoModule == null) return "";
|
|
|
|
long timeStamp = this.repoModule.lastUpdated;
|
|
|
|
long timeStamp = this.repoModule.lastUpdated;
|
|
|
|
return timeStamp <= 0 ? "" :
|
|
|
|
return timeStamp <= 0 ? "" : MainApplication.formatTime(timeStamp);
|
|
|
|
MainApplication.formatTime(timeStamp);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getRepoName() {
|
|
|
|
public String getRepoName() {
|
|
|
@ -135,19 +123,19 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Type getType() {
|
|
|
|
public Type getType() {
|
|
|
|
Timber.d("Getting type for %s", this.moduleId);
|
|
|
|
|
|
|
|
if (this.footerPx != -1) {
|
|
|
|
if (this.footerPx != -1) {
|
|
|
|
|
|
|
|
Timber.i("Module %s is footer", this.moduleId);
|
|
|
|
return Type.FOOTER;
|
|
|
|
return Type.FOOTER;
|
|
|
|
} else if (this.separator != null) {
|
|
|
|
} else if (this.separator != null) {
|
|
|
|
|
|
|
|
Timber.i("Module %s is separator", this.moduleId);
|
|
|
|
|
|
|
|
Thread.dumpStack();
|
|
|
|
return Type.SEPARATOR;
|
|
|
|
return Type.SEPARATOR;
|
|
|
|
} else if (this.notificationType != null) {
|
|
|
|
} else if (this.notificationType != null) {
|
|
|
|
|
|
|
|
Timber.i("Module %s is notification", this.moduleId);
|
|
|
|
return Type.NOTIFICATION;
|
|
|
|
return Type.NOTIFICATION;
|
|
|
|
} else if (this.moduleInfo == null) {
|
|
|
|
} else if (this.moduleInfo == null) {
|
|
|
|
Timber.d("Module %s is not installed", this.moduleId);
|
|
|
|
|
|
|
|
return Type.INSTALLABLE;
|
|
|
|
return Type.INSTALLABLE;
|
|
|
|
} else if (this.moduleInfo.versionCode < this.moduleInfo.updateVersionCode ||
|
|
|
|
} else if (this.moduleInfo.versionCode < this.moduleInfo.updateVersionCode || (this.repoModule != null && this.moduleInfo.versionCode < this.repoModule.moduleInfo.versionCode)) {
|
|
|
|
(this.repoModule != null && this.moduleInfo.versionCode <
|
|
|
|
|
|
|
|
this.repoModule.moduleInfo.versionCode)) {
|
|
|
|
|
|
|
|
Timber.d("Module %s has update", this.moduleId);
|
|
|
|
Timber.d("Module %s has update", this.moduleId);
|
|
|
|
MainApplication.getINSTANCE().modulesHaveUpdates = true;
|
|
|
|
MainApplication.getINSTANCE().modulesHaveUpdates = true;
|
|
|
|
if (!MainApplication.getINSTANCE().updateModules.contains(this.moduleId)) {
|
|
|
|
if (!MainApplication.getINSTANCE().updateModules.contains(this.moduleId)) {
|
|
|
@ -158,7 +146,6 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
|
|
|
|
Timber.d("Module %s has update", this.moduleId);
|
|
|
|
Timber.d("Module %s has update", this.moduleId);
|
|
|
|
return Type.UPDATABLE;
|
|
|
|
return Type.UPDATABLE;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Timber.d("Module %s is installed", this.moduleId);
|
|
|
|
|
|
|
|
return Type.INSTALLED;
|
|
|
|
return Type.INSTALLED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -166,8 +153,7 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
|
|
|
|
public Type getCompareType(Type type) {
|
|
|
|
public Type getCompareType(Type type) {
|
|
|
|
if (this.separator != null) {
|
|
|
|
if (this.separator != null) {
|
|
|
|
return this.separator;
|
|
|
|
return this.separator;
|
|
|
|
} else if (this.notificationType != null &&
|
|
|
|
} else if (this.notificationType != null && this.notificationType.special) {
|
|
|
|
this.notificationType.special) {
|
|
|
|
|
|
|
|
return Type.SPECIAL_NOTIFICATIONS;
|
|
|
|
return Type.SPECIAL_NOTIFICATIONS;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return type;
|
|
|
|
return type;
|
|
|
@ -175,11 +161,12 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean shouldRemove() {
|
|
|
|
public boolean shouldRemove() {
|
|
|
|
return this.notificationType != null ? this.notificationType.shouldRemove() :
|
|
|
|
// okay so this is quite possibly the hackiest fucking piece of code i've ever written
|
|
|
|
this.footerPx == -1 && this.moduleInfo == null &&
|
|
|
|
// basically, if we have a repomodule that has moduleinfo but no update, remove it-
|
|
|
|
(this.repoModule == null || !this.repoModule.repoData.isEnabled() ||
|
|
|
|
if (this.repoModule != null && this.moduleInfo != null && !hasUpdate()) {
|
|
|
|
(PropUtils.isLowQualityModule(this.repoModule.moduleInfo) &&
|
|
|
|
return true;
|
|
|
|
!MainApplication.isDisableLowQualityModuleFilter()));
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.notificationType != null ? this.notificationType.shouldRemove() : this.footerPx == -1 && this.moduleInfo == null && (this.repoModule == null || !this.repoModule.repoData.isEnabled() || (PropUtils.isLowQualityModule(this.repoModule.moduleInfo) && !MainApplication.isDisableLowQualityModuleFilter()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void getButtons(Context context, List<ActionButtonType> buttonTypeList, boolean showcaseMode) {
|
|
|
|
public void getButtons(Context context, List<ActionButtonType> buttonTypeList, boolean showcaseMode) {
|
|
|
@ -195,8 +182,7 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
|
|
|
|
if (this.repoModule != null && this.repoModule.notesUrl != null) {
|
|
|
|
if (this.repoModule != null && this.repoModule.notesUrl != null) {
|
|
|
|
buttonTypeList.add(ActionButtonType.INFO);
|
|
|
|
buttonTypeList.add(ActionButtonType.INFO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((this.repoModule != null || (localModuleInfo != null &&
|
|
|
|
if ((this.repoModule != null || (localModuleInfo != null && localModuleInfo.updateZipUrl != null))) {
|
|
|
|
localModuleInfo.updateZipUrl != null))) {
|
|
|
|
|
|
|
|
buttonTypeList.add(ActionButtonType.UPDATE_INSTALL);
|
|
|
|
buttonTypeList.add(ActionButtonType.UPDATE_INSTALL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String config = this.getMainModuleConfig();
|
|
|
|
String config = this.getMainModuleConfig();
|
|
|
@ -209,8 +195,7 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
|
|
|
|
XHooks.checkConfigTargetExists(context, pkg, config);
|
|
|
|
XHooks.checkConfigTargetExists(context, pkg, config);
|
|
|
|
buttonTypeList.add(ActionButtonType.CONFIG);
|
|
|
|
buttonTypeList.add(ActionButtonType.CONFIG);
|
|
|
|
} catch (PackageManager.NameNotFoundException e) {
|
|
|
|
} catch (PackageManager.NameNotFoundException e) {
|
|
|
|
Timber.w("Config package \"" + pkg +
|
|
|
|
Timber.w("Config package \"" + pkg + "\" missing for module \"" + this.moduleId + "\"");
|
|
|
|
"\" missing for module \"" + this.moduleId + "\"");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -233,8 +218,7 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean hasUpdate() {
|
|
|
|
public boolean hasUpdate() {
|
|
|
|
return this.moduleInfo != null && this.repoModule != null &&
|
|
|
|
return this.moduleInfo != null && this.repoModule != null && this.moduleInfo.versionCode < this.repoModule.moduleInfo.versionCode;
|
|
|
|
this.moduleInfo.versionCode < this.repoModule.moduleInfo.versionCode;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -245,29 +229,30 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
|
|
|
|
Type selfType = this.getCompareType(selfTypeReal);
|
|
|
|
Type selfType = this.getCompareType(selfTypeReal);
|
|
|
|
Type otherType = o.getCompareType(otherTypeReal);
|
|
|
|
Type otherType = o.getCompareType(otherTypeReal);
|
|
|
|
int compare = selfType.compareTo(otherType);
|
|
|
|
int compare = selfType.compareTo(otherType);
|
|
|
|
return compare != 0 ? compare :
|
|
|
|
return compare != 0 ? compare : selfTypeReal == otherTypeReal ? selfTypeReal.compare(this, o) : selfTypeReal.compareTo(otherTypeReal);
|
|
|
|
selfTypeReal == otherTypeReal ?
|
|
|
|
}
|
|
|
|
selfTypeReal.compare(this, o) :
|
|
|
|
|
|
|
|
selfTypeReal.compareTo(otherTypeReal);
|
|
|
|
@NonNull
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
|
|
|
|
return "ModuleHolder{" + "moduleId='" + moduleId + '\'' + ", notificationType=" + notificationType + ", separator=" + separator + ", footerPx=" + footerPx + '}';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public enum Type implements Comparator<ModuleHolder> {
|
|
|
|
public enum Type implements Comparator<ModuleHolder> {
|
|
|
|
HEADER(R.string.loading, false, false),
|
|
|
|
HEADER(R.string.loading, false, false), SEPARATOR(R.string.loading, false, false) {
|
|
|
|
SEPARATOR(R.string.loading, false, false) {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@SuppressWarnings("ConstantConditions")
|
|
|
|
@SuppressWarnings("ConstantConditions")
|
|
|
|
public int compare(ModuleHolder o1, ModuleHolder o2) {
|
|
|
|
public int compare(ModuleHolder o1, ModuleHolder o2) {
|
|
|
|
return o1.separator.compareTo(o2.separator);
|
|
|
|
return o1.separator.compareTo(o2.separator);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}, NOTIFICATION(R.string.loading, true, false) {
|
|
|
|
NOTIFICATION(R.string.loading, true, false) {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@SuppressWarnings("ConstantConditions")
|
|
|
|
@SuppressWarnings("ConstantConditions")
|
|
|
|
public int compare(ModuleHolder o1, ModuleHolder o2) {
|
|
|
|
public int compare(ModuleHolder o1, ModuleHolder o2) {
|
|
|
|
|
|
|
|
Thread.dumpStack();
|
|
|
|
return o1.notificationType.compareTo(o2.notificationType);
|
|
|
|
return o1.notificationType.compareTo(o2.notificationType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}, UPDATABLE(R.string.updatable, true, true) {
|
|
|
|
UPDATABLE(R.string.updatable, true, true) {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int compare(ModuleHolder o1, ModuleHolder o2) {
|
|
|
|
public int compare(ModuleHolder o1, ModuleHolder o2) {
|
|
|
|
int cmp = Integer.compare(o1.filterLevel, o2.filterLevel);
|
|
|
|
int cmp = Integer.compare(o1.filterLevel, o2.filterLevel);
|
|
|
@ -278,18 +263,15 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
|
|
|
|
if (cmp != 0) return cmp;
|
|
|
|
if (cmp != 0) return cmp;
|
|
|
|
return o1.getMainModuleName().compareTo(o2.getMainModuleName());
|
|
|
|
return o1.getMainModuleName().compareTo(o2.getMainModuleName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}, INSTALLED(R.string.installed, true, true) {
|
|
|
|
INSTALLED(R.string.installed, true, true) {
|
|
|
|
// get stacktrace for debugging
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int compare(ModuleHolder o1, ModuleHolder o2) {
|
|
|
|
public int compare(ModuleHolder o1, ModuleHolder o2) {
|
|
|
|
int cmp = Integer.compare(o1.filterLevel, o2.filterLevel);
|
|
|
|
int cmp = Integer.compare(o1.filterLevel, o2.filterLevel);
|
|
|
|
if (cmp != 0) return cmp;
|
|
|
|
if (cmp != 0) return cmp;
|
|
|
|
return o1.getMainModuleNameLowercase()
|
|
|
|
return o1.getMainModuleNameLowercase().compareTo(o2.getMainModuleNameLowercase());
|
|
|
|
.compareTo(o2.getMainModuleNameLowercase());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}, SPECIAL_NOTIFICATIONS(R.string.loading, true, false), INSTALLABLE(R.string.online_repo, true, true) {
|
|
|
|
SPECIAL_NOTIFICATIONS(R.string.loading, true, false),
|
|
|
|
|
|
|
|
INSTALLABLE(R.string.online_repo, true, true) {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int compare(ModuleHolder o1, ModuleHolder o2) {
|
|
|
|
public int compare(ModuleHolder o1, ModuleHolder o2) {
|
|
|
|
int cmp = Integer.compare(o1.filterLevel, o2.filterLevel);
|
|
|
|
int cmp = Integer.compare(o1.filterLevel, o2.filterLevel);
|
|
|
@ -300,8 +282,7 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
|
|
|
|
if (cmp != 0) return cmp;
|
|
|
|
if (cmp != 0) return cmp;
|
|
|
|
return o1.getMainModuleName().compareTo(o2.getMainModuleName());
|
|
|
|
return o1.getMainModuleName().compareTo(o2.getMainModuleName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}, FOOTER(R.string.loading, false, false);
|
|
|
|
FOOTER(R.string.loading, false, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@StringRes
|
|
|
|
@StringRes
|
|
|
|
public final int title;
|
|
|
|
public final int title;
|
|
|
@ -328,15 +309,4 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
|
|
|
|
return "ModuleHolder{" +
|
|
|
|
|
|
|
|
"moduleId='" + moduleId + '\'' +
|
|
|
|
|
|
|
|
", notificationType=" + notificationType +
|
|
|
|
|
|
|
|
", separator=" + separator +
|
|
|
|
|
|
|
|
", footerPx=" + footerPx +
|
|
|
|
|
|
|
|
'}';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|