@@ -72,30 +72,19 @@ public boolean isModuleHolder() {
7272 }
7373
7474 public ModuleInfo getMainModuleInfo () {
75- return this .repoModule != null && (this .moduleInfo == null ||
76- this .moduleInfo .versionCode < this .repoModule .moduleInfo .versionCode )
77- ? this .repoModule .moduleInfo : this .moduleInfo ;
75+ return this .repoModule != null && (this .moduleInfo == null || this .moduleInfo .versionCode < this .repoModule .moduleInfo .versionCode ) ? this .repoModule .moduleInfo : this .moduleInfo ;
7876 }
7977
8078 public String getUpdateZipUrl () {
81- return this .moduleInfo == null || (this .repoModule != null &&
82- this .moduleInfo .updateVersionCode <
83- this .repoModule .moduleInfo .versionCode ) ?
84- this .repoModule .zipUrl : this .moduleInfo .updateZipUrl ;
79+ return this .moduleInfo == null || (this .repoModule != null && this .moduleInfo .updateVersionCode < this .repoModule .moduleInfo .versionCode ) ? this .repoModule .zipUrl : this .moduleInfo .updateZipUrl ;
8580 }
8681
8782 public String getUpdateZipRepo () {
88- return this .moduleInfo == null || (this .repoModule != null &&
89- this .moduleInfo .updateVersionCode <
90- this .repoModule .moduleInfo .versionCode ) ?
91- this .repoModule .repoData .id : "update_json" ;
83+ return this .moduleInfo == null || (this .repoModule != null && this .moduleInfo .updateVersionCode < this .repoModule .moduleInfo .versionCode ) ? this .repoModule .repoData .id : "update_json" ;
9284 }
9385
9486 public String getUpdateZipChecksum () {
95- return this .moduleInfo == null || (this .repoModule != null &&
96- this .moduleInfo .updateVersionCode <
97- this .repoModule .moduleInfo .versionCode ) ?
98- this .repoModule .checksum : this .moduleInfo .updateChecksum ;
87+ return this .moduleInfo == null || (this .repoModule != null && this .moduleInfo .updateVersionCode < this .repoModule .moduleInfo .versionCode ) ? this .repoModule .checksum : this .moduleInfo .updateChecksum ;
9988 }
10089
10190 public String getMainModuleName () {
@@ -121,8 +110,7 @@ public String getMainModuleConfig() {
121110 public String getUpdateTimeText () {
122111 if (this .repoModule == null ) return "" ;
123112 long timeStamp = this .repoModule .lastUpdated ;
124- return timeStamp <= 0 ? "" :
125- MainApplication .formatTime (timeStamp );
113+ return timeStamp <= 0 ? "" : MainApplication .formatTime (timeStamp );
126114 }
127115
128116 public String getRepoName () {
@@ -135,19 +123,19 @@ public boolean hasFlag(int flag) {
135123 }
136124
137125 public Type getType () {
138- Timber .d ("Getting type for %s" , this .moduleId );
139126 if (this .footerPx != -1 ) {
127+ Timber .i ("Module %s is footer" , this .moduleId );
140128 return Type .FOOTER ;
141129 } else if (this .separator != null ) {
130+ Timber .i ("Module %s is separator" , this .moduleId );
131+ Thread .dumpStack ();
142132 return Type .SEPARATOR ;
143133 } else if (this .notificationType != null ) {
134+ Timber .i ("Module %s is notification" , this .moduleId );
144135 return Type .NOTIFICATION ;
145136 } else if (this .moduleInfo == null ) {
146- Timber .d ("Module %s is not installed" , this .moduleId );
147137 return Type .INSTALLABLE ;
148- } else if (this .moduleInfo .versionCode < this .moduleInfo .updateVersionCode ||
149- (this .repoModule != null && this .moduleInfo .versionCode <
150- this .repoModule .moduleInfo .versionCode )) {
138+ } else if (this .moduleInfo .versionCode < this .moduleInfo .updateVersionCode || (this .repoModule != null && this .moduleInfo .versionCode < this .repoModule .moduleInfo .versionCode )) {
151139 Timber .d ("Module %s has update" , this .moduleId );
152140 MainApplication .getINSTANCE ().modulesHaveUpdates = true ;
153141 if (!MainApplication .getINSTANCE ().updateModules .contains (this .moduleId )) {
@@ -158,28 +146,27 @@ public Type getType() {
158146 Timber .d ("Module %s has update" , this .moduleId );
159147 return Type .UPDATABLE ;
160148 } else {
161- Timber .d ("Module %s is installed" , this .moduleId );
162149 return Type .INSTALLED ;
163150 }
164151 }
165152
166153 public Type getCompareType (Type type ) {
167154 if (this .separator != null ) {
168155 return this .separator ;
169- } else if (this .notificationType != null &&
170- this .notificationType .special ) {
156+ } else if (this .notificationType != null && this .notificationType .special ) {
171157 return Type .SPECIAL_NOTIFICATIONS ;
172158 } else {
173159 return type ;
174160 }
175161 }
176162
177163 public boolean shouldRemove () {
178- return this .notificationType != null ? this .notificationType .shouldRemove () :
179- this .footerPx == -1 && this .moduleInfo == null &&
180- (this .repoModule == null || !this .repoModule .repoData .isEnabled () ||
181- (PropUtils .isLowQualityModule (this .repoModule .moduleInfo ) &&
182- !MainApplication .isDisableLowQualityModuleFilter ()));
164+ // okay so this is quite possibly the hackiest fucking piece of code i've ever written
165+ // basically, if we have a repomodule that has moduleinfo but no update, remove it-
166+ if (this .repoModule != null && this .moduleInfo != null && !hasUpdate ()) {
167+ return true ;
168+ }
169+ 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 ()));
183170 }
184171
185172 public void getButtons (Context context , List <ActionButtonType > buttonTypeList , boolean showcaseMode ) {
@@ -195,8 +182,7 @@ public void getButtons(Context context, List<ActionButtonType> buttonTypeList, b
195182 if (this .repoModule != null && this .repoModule .notesUrl != null ) {
196183 buttonTypeList .add (ActionButtonType .INFO );
197184 }
198- if ((this .repoModule != null || (localModuleInfo != null &&
199- localModuleInfo .updateZipUrl != null ))) {
185+ if ((this .repoModule != null || (localModuleInfo != null && localModuleInfo .updateZipUrl != null ))) {
200186 buttonTypeList .add (ActionButtonType .UPDATE_INSTALL );
201187 }
202188 String config = this .getMainModuleConfig ();
@@ -209,8 +195,7 @@ public void getButtons(Context context, List<ActionButtonType> buttonTypeList, b
209195 XHooks .checkConfigTargetExists (context , pkg , config );
210196 buttonTypeList .add (ActionButtonType .CONFIG );
211197 } catch (PackageManager .NameNotFoundException e ) {
212- Timber .w ("Config package \" " + pkg +
213- "\" missing for module \" " + this .moduleId + "\" " );
198+ Timber .w ("Config package \" " + pkg + "\" missing for module \" " + this .moduleId + "\" " );
214199 }
215200 }
216201 }
@@ -233,8 +218,7 @@ public void getButtons(Context context, List<ActionButtonType> buttonTypeList, b
233218 }
234219
235220 public boolean hasUpdate () {
236- return this .moduleInfo != null && this .repoModule != null &&
237- this .moduleInfo .versionCode < this .repoModule .moduleInfo .versionCode ;
221+ return this .moduleInfo != null && this .repoModule != null && this .moduleInfo .versionCode < this .repoModule .moduleInfo .versionCode ;
238222 }
239223
240224 @ Override
@@ -245,29 +229,30 @@ public int compareTo(ModuleHolder o) {
245229 Type selfType = this .getCompareType (selfTypeReal );
246230 Type otherType = o .getCompareType (otherTypeReal );
247231 int compare = selfType .compareTo (otherType );
248- return compare != 0 ? compare :
249- selfTypeReal == otherTypeReal ?
250- selfTypeReal .compare (this , o ) :
251- selfTypeReal .compareTo (otherTypeReal );
232+ return compare != 0 ? compare : selfTypeReal == otherTypeReal ? selfTypeReal .compare (this , o ) : selfTypeReal .compareTo (otherTypeReal );
233+ }
234+
235+ @ NonNull
236+ @ Override
237+ public String toString () {
238+ return "ModuleHolder{" + "moduleId='" + moduleId + '\'' + ", notificationType=" + notificationType + ", separator=" + separator + ", footerPx=" + footerPx + '}' ;
252239 }
253240
254241 public enum Type implements Comparator <ModuleHolder > {
255- HEADER (R .string .loading , false , false ),
256- SEPARATOR (R .string .loading , false , false ) {
242+ HEADER (R .string .loading , false , false ), SEPARATOR (R .string .loading , false , false ) {
257243 @ Override
258244 @ SuppressWarnings ("ConstantConditions" )
259245 public int compare (ModuleHolder o1 , ModuleHolder o2 ) {
260246 return o1 .separator .compareTo (o2 .separator );
261247 }
262- },
263- NOTIFICATION (R .string .loading , true , false ) {
248+ }, NOTIFICATION (R .string .loading , true , false ) {
264249 @ Override
265250 @ SuppressWarnings ("ConstantConditions" )
266251 public int compare (ModuleHolder o1 , ModuleHolder o2 ) {
252+ Thread .dumpStack ();
267253 return o1 .notificationType .compareTo (o2 .notificationType );
268254 }
269- },
270- UPDATABLE (R .string .updatable , true , true ) {
255+ }, UPDATABLE (R .string .updatable , true , true ) {
271256 @ Override
272257 public int compare (ModuleHolder o1 , ModuleHolder o2 ) {
273258 int cmp = Integer .compare (o1 .filterLevel , o2 .filterLevel );
@@ -278,18 +263,15 @@ public int compare(ModuleHolder o1, ModuleHolder o2) {
278263 if (cmp != 0 ) return cmp ;
279264 return o1 .getMainModuleName ().compareTo (o2 .getMainModuleName ());
280265 }
281- },
282- INSTALLED ( R . string . installed , true , true ) {
266+ }, INSTALLED ( R . string . installed , true , true ) {
267+ // get stacktrace for debugging
283268 @ Override
284269 public int compare (ModuleHolder o1 , ModuleHolder o2 ) {
285270 int cmp = Integer .compare (o1 .filterLevel , o2 .filterLevel );
286271 if (cmp != 0 ) return cmp ;
287- return o1 .getMainModuleNameLowercase ()
288- .compareTo (o2 .getMainModuleNameLowercase ());
272+ return o1 .getMainModuleNameLowercase ().compareTo (o2 .getMainModuleNameLowercase ());
289273 }
290- },
291- SPECIAL_NOTIFICATIONS (R .string .loading , true , false ),
292- INSTALLABLE (R .string .online_repo , true , true ) {
274+ }, SPECIAL_NOTIFICATIONS (R .string .loading , true , false ), INSTALLABLE (R .string .online_repo , true , true ) {
293275 @ Override
294276 public int compare (ModuleHolder o1 , ModuleHolder o2 ) {
295277 int cmp = Integer .compare (o1 .filterLevel , o2 .filterLevel );
@@ -300,8 +282,7 @@ public int compare(ModuleHolder o1, ModuleHolder o2) {
300282 if (cmp != 0 ) return cmp ;
301283 return o1 .getMainModuleName ().compareTo (o2 .getMainModuleName ());
302284 }
303- },
304- FOOTER (R .string .loading , false , false );
285+ }, FOOTER (R .string .loading , false , false );
305286
306287 @ StringRes
307288 public final int title ;
@@ -328,15 +309,4 @@ public int compare(ModuleHolder o1, ModuleHolder o2) {
328309 }
329310 }
330311 }
331-
332- @ NonNull
333- @ Override
334- public String toString () {
335- return "ModuleHolder{" +
336- "moduleId='" + moduleId + '\'' +
337- ", notificationType=" + notificationType +
338- ", separator=" + separator +
339- ", footerPx=" + footerPx +
340- '}' ;
341- }
342312}
0 commit comments