diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 04c600b..d143063 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -16,8 +16,6 @@
-
{
public boolean shouldRemove() {
return this.notificationType != null ? this.notificationType.shouldRemove() :
- this.footerPx == 0 && this.moduleInfo == null && (this.repoModule == null ||
- (PropUtils.isLowQualityModule(this.repoModule.moduleInfo) &&
- !MainApplication.isDisableLowQualityModuleFilter()));
+ this.footerPx == 0 && this.moduleInfo == null &&
+ (this.repoModule == null || !this.repoModule.repoData.isEnabled() ||
+ (PropUtils.isLowQualityModule(this.repoModule.moduleInfo) &&
+ !MainApplication.isDisableLowQualityModuleFilter()));
}
public void getButtons(Context context, List buttonTypeList, boolean showcaseMode) {
diff --git a/app/src/main/java/com/fox2code/mmm/ModuleViewListBuilder.java b/app/src/main/java/com/fox2code/mmm/ModuleViewListBuilder.java
index 4102461..b5a5b1b 100644
--- a/app/src/main/java/com/fox2code/mmm/ModuleViewListBuilder.java
+++ b/app/src/main/java/com/fox2code/mmm/ModuleViewListBuilder.java
@@ -73,6 +73,7 @@ public class ModuleViewListBuilder {
repoManager.runAfterUpdate(() -> {
Log.i(TAG, "A2: " + repoManager.getModules().size());
for (RepoModule repoModule : repoManager.getModules().values()) {
+ if (!repoModule.repoData.isEnabled()) continue;
ModuleInfo moduleInfo = repoModule.moduleInfo;
if (!showIncompatible && (moduleInfo.minApi > Build.VERSION.SDK_INT ||
(moduleInfo.maxApi != 0 && moduleInfo.maxApi < Build.VERSION.SDK_INT) ||
diff --git a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java
index ddd991e..c191c15 100644
--- a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java
+++ b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java
@@ -111,7 +111,7 @@ public class AndroidacyRepoData extends RepoData {
lastLastUpdate = Math.max(lastLastUpdate, lastUpdate);
RepoModule repoModule = this.moduleHashMap.get(moduleId);
if (repoModule == null) {
- repoModule = new RepoModule(moduleId);
+ repoModule = new RepoModule(this, moduleId);
repoModule.moduleInfo.flags = 0;
this.moduleHashMap.put(moduleId, repoModule);
newModules.add(repoModule);
diff --git a/app/src/main/java/com/fox2code/mmm/repo/RepoData.java b/app/src/main/java/com/fox2code/mmm/repo/RepoData.java
index 1f26ea9..5620344 100644
--- a/app/src/main/java/com/fox2code/mmm/repo/RepoData.java
+++ b/app/src/main/java/com/fox2code/mmm/repo/RepoData.java
@@ -6,6 +6,7 @@ import android.util.Log;
import androidx.annotation.NonNull;
+import com.fox2code.mmm.MainApplication;
import com.fox2code.mmm.R;
import com.fox2code.mmm.manager.ModuleInfo;
import com.fox2code.mmm.utils.Files;
@@ -33,6 +34,7 @@ public class RepoData {
private static final String TAG = "RepoData";
private final Object populateLock = new Object();
public final String url;
+ public final String id;
public final File cacheRoot;
public final SharedPreferences cachedPreferences;
public final File metaDataCache;
@@ -40,6 +42,7 @@ public class RepoData {
public final HashMap moduleHashMap;
public long lastUpdate;
public String name;
+ private boolean enabled; // Cache for speed
private final Map specialData;
private long specialLastUpdate;
@@ -49,12 +52,15 @@ public class RepoData {
RepoData(String url, File cacheRoot, SharedPreferences cachedPreferences,boolean special) {
this.url = url;
+ this.id = RepoManager.internalIdOfUrl(url);
this.cacheRoot = cacheRoot;
this.cachedPreferences = cachedPreferences;
this.metaDataCache = new File(cacheRoot, "modules.json");
this.special = special;
this.moduleHashMap = new HashMap<>();
this.name = this.url; // Set url as default name
+ this.enabled = MainApplication.getSharedPreferences()
+ .getBoolean("pref_" + this.id + "_enabled", true);
this.specialData = special ? new HashMap<>() : Collections.emptyMap();
if (!this.cacheRoot.isDirectory()) {
this.cacheRoot.mkdirs();
@@ -141,7 +147,7 @@ public class RepoData {
}
RepoModule repoModule = this.moduleHashMap.get(moduleId);
if (repoModule == null) {
- repoModule = new RepoModule(moduleId);
+ repoModule = new RepoModule(this, moduleId);
this.moduleHashMap.put(moduleId, repoModule);
newModules.add(repoModule);
} else {
@@ -254,6 +260,21 @@ public class RepoData {
fallback : this.name;
}
+ public boolean isEnabled() {
+ return this.enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ MainApplication.getSharedPreferences().edit()
+ .putBoolean("pref_" + this.id + "_enabled", enabled).apply();
+ }
+
+ public void updateEnabledState() {
+ this.enabled = MainApplication.getSharedPreferences()
+ .getBoolean("pref_" + this.id + "_enabled", true);
+ }
+
private static class SpecialData {
SpecialData(long time, int stars) {
this.time = time; this.stars = stars;
diff --git a/app/src/main/java/com/fox2code/mmm/repo/RepoManager.java b/app/src/main/java/com/fox2code/mmm/repo/RepoManager.java
index 6b93af8..54583ff 100644
--- a/app/src/main/java/com/fox2code/mmm/repo/RepoManager.java
+++ b/app/src/main/java/com/fox2code/mmm/repo/RepoManager.java
@@ -228,6 +228,11 @@ public final class RepoManager {
return hasInternet;
}
+ public void updateEnabledStates() {
+ for (RepoData repoData:this.repoData.values())
+ repoData.updateEnabledState();
+ }
+
public HashMap getModules() {
this.afterUpdate();
return this.modules;
diff --git a/app/src/main/java/com/fox2code/mmm/repo/RepoModule.java b/app/src/main/java/com/fox2code/mmm/repo/RepoModule.java
index a374da6..86fc84b 100644
--- a/app/src/main/java/com/fox2code/mmm/repo/RepoModule.java
+++ b/app/src/main/java/com/fox2code/mmm/repo/RepoModule.java
@@ -5,6 +5,7 @@ import androidx.annotation.StringRes;
import com.fox2code.mmm.manager.ModuleInfo;
public class RepoModule {
+ public final RepoData repoData;
public final ModuleInfo moduleInfo;
public final String id;
public String repoName;
@@ -18,7 +19,8 @@ public class RepoModule {
public int qualityText;
public int qualityValue;
- public RepoModule(String id) {
+ public RepoModule(RepoData repoData, String id) {
+ this.repoData = repoData;
this.moduleInfo = new ModuleInfo(id);
this.id = id;
this.moduleInfo.flags |=
diff --git a/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java b/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java
index 492b48f..691ae1f 100644
--- a/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java
+++ b/app/src/main/java/com/fox2code/mmm/repo/RepoUpdater.java
@@ -26,6 +26,12 @@ public class RepoUpdater {
}
public int fetchIndex() {
+ if (!this.repoData.isEnabled()) {
+ this.indexRaw = null;
+ this.toUpdate = Collections.emptyList();
+ this.toApply = Collections.emptySet();
+ return 0;
+ }
try {
if (!this.repoData.prepare()) {
return 0;
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 574e9a7..6b05af5 100644
--- a/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java
+++ b/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java
@@ -3,12 +3,15 @@ package com.fox2code.mmm.settings;
import android.os.Bundle;
import android.widget.Toast;
+import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
+import androidx.preference.SwitchPreference;
+import androidx.preference.SwitchPreferenceCompat;
import com.fox2code.mmm.AppUpdateManager;
import com.fox2code.mmm.BuildConfig;
@@ -158,16 +161,15 @@ public class SettingsActivity extends CompatActivity {
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
getPreferenceManager().setSharedPreferencesName("mmm");
setPreferencesFromResource(R.xml.repo_preferences, rootKey);
- setRepoData("pref_repo_main", RepoManager.MAGISK_REPO,
+ setRepoData(RepoManager.MAGISK_REPO,
"Magisk Modules Repo (Official)", RepoManager.MAGISK_REPO_HOMEPAGE,
null, null,null);
- setRepoData("pref_repo_alt", RepoManager.MAGISK_ALT_REPO,
+ setRepoData(RepoManager.MAGISK_ALT_REPO,
"Magisk Modules Alt Repo", RepoManager.MAGISK_ALT_REPO_HOMEPAGE,
null, null,
"https://github.com/Magisk-Modules-Alt-Repo/submission/issues");
// Androidacy backend not yet implemented!
- setRepoData("pref_repo_androidacy",
- RepoManager.ANDROIDACY_MAGISK_REPO_ENDPOINT,
+ setRepoData(RepoManager.ANDROIDACY_MAGISK_REPO_ENDPOINT,
"Androidacy Modules Repo",
RepoManager.ANDROIDACY_MAGISK_REPO_HOMEPAGE,
"https://t.me/androidacy_discussions",
@@ -175,15 +177,31 @@ public class SettingsActivity extends CompatActivity {
"https://www.androidacy.com/module-repository-applications/");
}
- private void setRepoData(String preferenceName, String url,
+ private void setRepoData(String url,
String fallbackTitle, String homepage,
String supportUrl, String donateUrl,
String submissionUrl) {
+ String preferenceName = "pref_" + RepoManager.internalIdOfUrl(url);
Preference preference = findPreference(preferenceName);
if (preference == null) return;
- RepoData repoData = RepoManager.getINSTANCE().get(url);
+ final RepoData repoData = RepoManager.getINSTANCE().get(url);
preference.setTitle(repoData == null ? fallbackTitle :
repoData.getNameOrFallback(fallbackTitle));
+ preference = findPreference(preferenceName + "_enabled");
+ if (preference != null) {
+ if (repoData == null) {
+ preference.setTitle(R.string.repo_disabled);
+ preference.setEnabled(false);
+ } else {
+ preference.setTitle(repoData.isEnabled() ?
+ R.string.repo_enabled : R.string.repo_disabled);
+ preference.setOnPreferenceChangeListener((p, newValue) -> {
+ p.setTitle(((Boolean) newValue) ?
+ R.string.repo_enabled : R.string.repo_disabled);
+ return true;
+ });
+ }
+ }
preference = findPreference(preferenceName + "_website");
if (preference != null && homepage != null) {
preference.setOnPreferenceClickListener(p -> {
diff --git a/app/src/main/res/xml/repo_preferences.xml b/app/src/main/res/xml/repo_preferences.xml
index 03f0d25..a7629f4 100644
--- a/app/src/main/res/xml/repo_preferences.xml
+++ b/app/src/main/res/xml/repo_preferences.xml
@@ -1,48 +1,69 @@
+
+
+