Disable Androidacy repo by default in F-Droid build flavor.

See https://gitlab.com/fdroid/fdroiddata/-/merge_requests/10830#note_898237184
pull/27/head
Gilbert Gilb's 3 years ago
parent 5a21c64074
commit e4313e2081

@ -34,6 +34,11 @@ android {
"default" {
dimension "type"
buildConfigField "boolean", "ENABLE_AUTO_UPDATER", "true"
buildConfigField(
"java.util.List<String>",
"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<String>",
"DISABLED_REPOS",
"java.util.Arrays.asList(\"androidacy_repo\")",
)
}
}

@ -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));
}
}

@ -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) -> {

@ -4,7 +4,6 @@
app:key="pref_magisk_alt_repo"
app:title="@string/loading">
<SwitchPreferenceCompat
app:defaultValue="true"
app:key="pref_magisk_alt_repo_enabled"
app:icon="@drawable/ic_baseline_extension_24"
app:switchTextOn="@string/repo_enabled"
@ -25,7 +24,6 @@
app:key="pref_androidacy_repo"
app:title="@string/loading">
<SwitchPreferenceCompat
app:defaultValue="true"
app:key="pref_androidacy_repo_enabled"
app:icon="@drawable/ic_baseline_extension_24"
app:switchTextOn="@string/repo_enabled"

Loading…
Cancel
Save