diff --git a/app/build.gradle b/app/build.gradle index 0d83360..eb18570 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -34,6 +34,11 @@ android { "default" { dimension "type" buildConfigField "boolean", "ENABLE_AUTO_UPDATER", "true" + buildConfigField( + "java.util.List", + "DISABLED_REPOS", + "java.util.Arrays.asList()", + ) } fdroid { @@ -44,6 +49,14 @@ android { // forbids downloading blobs from third-party websites (and F-Droid APK isn't signed // with our keys, so the APK wouldn't install anyways). buildConfigField "boolean", "ENABLE_AUTO_UPDATER", "false" + + // Repo with ads or tracking feature are disabled by default for the + // F-Droid flavor. + buildConfigField( + "java.util.List", + "DISABLED_REPOS", + "java.util.Arrays.asList(\"androidacy_repo\")", + ) } } @@ -100,4 +113,4 @@ dependencies { testImplementation 'junit:junit:4.+' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' -} \ No newline at end of file +} 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 fdffeba..8bb50a7 100644 --- a/app/src/main/java/com/fox2code/mmm/repo/RepoData.java +++ b/app/src/main/java/com/fox2code/mmm/repo/RepoData.java @@ -2,6 +2,7 @@ package com.fox2code.mmm.repo; import android.content.SharedPreferences; +import com.fox2code.mmm.BuildConfig; import com.fox2code.mmm.MainApplication; import com.fox2code.mmm.R; import com.fox2code.mmm.manager.ModuleInfo; @@ -42,7 +43,7 @@ public class RepoData { this.moduleHashMap = new HashMap<>(); this.name = this.url; // Set url as default name this.enabled = MainApplication.getSharedPreferences() - .getBoolean("pref_" + this.id + "_enabled", true); + .getBoolean("pref_" + this.id + "_enabled", this.isEnabledByDefault(this.id)); if (!this.cacheRoot.isDirectory()) { this.cacheRoot.mkdirs(); } else { @@ -134,6 +135,10 @@ public class RepoData { return newModules; } + protected boolean isEnabledByDefault(String id) { + return !BuildConfig.DISABLED_REPOS.contains(id); + } + public void storeMetadata(RepoModule repoModule,byte[] data) throws IOException { Files.write(new File(this.cacheRoot, repoModule.id + ".prop"), data); } @@ -176,6 +181,6 @@ public class RepoData { public void updateEnabledState() { this.enabled = MainApplication.getSharedPreferences() - .getBoolean("pref_" + this.id + "_enabled", true); + .getBoolean("pref_" + this.id + "_enabled", this.isEnabledByDefault(this.id)); } } 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 101f7d5..eb25c21 100644 --- a/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java +++ b/app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java @@ -10,6 +10,7 @@ import androidx.fragment.app.FragmentTransaction; import androidx.preference.ListPreference; import androidx.preference.Preference; import androidx.preference.PreferenceFragmentCompat; +import androidx.preference.TwoStatePreference; import com.fox2code.mmm.AppUpdateManager; import com.fox2code.mmm.BuildConfig; @@ -203,6 +204,7 @@ public class SettingsActivity extends CompatActivity { preference.setTitle(R.string.repo_disabled); preference.setEnabled(false); } else { + ((TwoStatePreference)preference).setChecked(repoData.isEnabled()); preference.setTitle(repoData.isEnabled() ? R.string.repo_enabled : R.string.repo_disabled); preference.setOnPreferenceChangeListener((p, newValue) -> { @@ -252,4 +254,4 @@ public class SettingsActivity extends CompatActivity { } } } -} \ No newline at end of file +} diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 052bd58..721da3d 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -93,4 +93,5 @@ Activer l\’effet de flou Dépôt activé Dépôt désactivé + Le dépôt Androidacy utilise des publicités et des pisteurs. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 590a0b3..93046bf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -93,4 +93,5 @@ Enable blur Repo enabled Repo disabled - \ No newline at end of file + Androidacy repo uses ads and trackers. + diff --git a/app/src/main/res/xml/repo_preferences.xml b/app/src/main/res/xml/repo_preferences.xml index 9907630..9bed0d6 100644 --- a/app/src/main/res/xml/repo_preferences.xml +++ b/app/src/main/res/xml/repo_preferences.xml @@ -4,7 +4,6 @@ app:key="pref_magisk_alt_repo" app:title="@string/loading"> + app:singleLineTitle="false" /> +