55
66import androidx .annotation .NonNull ;
77
8+ import com .fox2code .mmm .AppUpdateManager ;
89import com .fox2code .mmm .BuildConfig ;
910import com .fox2code .mmm .MainApplication ;
1011import com .fox2code .mmm .R ;
@@ -38,7 +39,7 @@ public class RepoData extends XRepo {
3839 protected String defaultName , defaultWebsite ,
3940 defaultSupport , defaultDonate , defaultSubmitModule ;
4041 public String name , website , support , donate , submitModule ;
41- private boolean enabled ; // Cache for speed
42+ private boolean forceHide , enabled ; // Cache for speed
4243
4344 protected RepoData (String url , File cacheRoot , SharedPreferences cachedPreferences ) {
4445 this .url = url ;
@@ -48,7 +49,8 @@ protected RepoData(String url, File cacheRoot, SharedPreferences cachedPreferenc
4849 this .metaDataCache = new File (cacheRoot , "modules.json" );
4950 this .moduleHashMap = new HashMap <>();
5051 this .defaultName = url ; // Set url as default name
51- this .enabled = !this .isLimited () && MainApplication .getSharedPreferences ()
52+ this .forceHide = AppUpdateManager .shouldForceHide (this .id );
53+ this .enabled = (!this .forceHide ) && MainApplication .getSharedPreferences ()
5254 .getBoolean ("pref_" + this .id + "_enabled" , this .isEnabledByDefault ());
5355 this .defaultWebsite = "https://" + Uri .parse (url ).getHost () + "/" ;
5456 if (!this .cacheRoot .isDirectory ()) {
@@ -189,13 +191,14 @@ public boolean isEnabled() {
189191
190192 @ Override
191193 public void setEnabled (boolean enabled ) {
192- this .enabled = enabled ;
194+ this .enabled = enabled && ! this . forceHide ;
193195 MainApplication .getSharedPreferences ().edit ()
194196 .putBoolean ("pref_" + this .getPreferenceId () + "_enabled" , enabled ).apply ();
195197 }
196198
197199 public void updateEnabledState () {
198- this .enabled = MainApplication .getSharedPreferences ()
200+ this .forceHide = AppUpdateManager .shouldForceHide (this .id );
201+ this .enabled = (!this .forceHide ) && MainApplication .getSharedPreferences ()
199202 .getBoolean ("pref_" + this .getPreferenceId () + "_enabled" , this .isEnabledByDefault ());
200203 }
201204
@@ -251,4 +254,8 @@ public String getSubmitModule() {
251254 return this .submitModule ;
252255 return this .defaultSubmitModule ;
253256 }
257+
258+ public final boolean isForceHide () {
259+ return this .forceHide ;
260+ }
254261}
0 commit comments