From e4313e20818fef834d9c2d524e6b0572f2dc1f1d Mon Sep 17 00:00:00 2001 From: Gilbert Gilb's Date: Sat, 2 Apr 2022 12:43:30 +0200 Subject: [PATCH 1/2] Disable Androidacy repo by default in F-Droid build flavor. See https://gitlab.com/fdroid/fdroiddata/-/merge_requests/10830#note_898237184 --- app/build.gradle | 15 ++++++++++++++- .../main/java/com/fox2code/mmm/repo/RepoData.java | 9 +++++++-- .../fox2code/mmm/settings/SettingsActivity.java | 4 +++- app/src/main/res/xml/repo_preferences.xml | 2 -- 4 files changed, 24 insertions(+), 6 deletions(-) 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/xml/repo_preferences.xml b/app/src/main/res/xml/repo_preferences.xml index 9907630..cd89c81 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"> Date: Sat, 2 Apr 2022 12:44:27 +0200 Subject: [PATCH 2/2] Add disclaimer about Androidacy using ads and trackers. See https://gitlab.com/fdroid/fdroiddata/-/merge_requests/10830#note_898354128 --- app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values/strings.xml | 3 ++- app/src/main/res/xml/repo_preferences.xml | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) 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 cd89c81..9bed0d6 100644 --- a/app/src/main/res/xml/repo_preferences.xml +++ b/app/src/main/res/xml/repo_preferences.xml @@ -48,6 +48,12 @@ app:key="pref_androidacy_repo_submit" app:icon="@drawable/ic_baseline_upload_file_24" app:title="@string/submit_modules" - app:singleLineTitle="false" /> + app:singleLineTitle="false" /> +