Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit e4313e2

Browse files
committed
Disable Androidacy repo by default in F-Droid build flavor.
See https://gitlab.com/fdroid/fdroiddata/-/merge_requests/10830#note_898237184
1 parent 5a21c64 commit e4313e2

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

app/build.gradle

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ android {
3434
"default" {
3535
dimension "type"
3636
buildConfigField "boolean", "ENABLE_AUTO_UPDATER", "true"
37+
buildConfigField(
38+
"java.util.List<String>",
39+
"DISABLED_REPOS",
40+
"java.util.Arrays.asList()",
41+
)
3742
}
3843

3944
fdroid {
@@ -44,6 +49,14 @@ android {
4449
// forbids downloading blobs from third-party websites (and F-Droid APK isn't signed
4550
// with our keys, so the APK wouldn't install anyways).
4651
buildConfigField "boolean", "ENABLE_AUTO_UPDATER", "false"
52+
53+
// Repo with ads or tracking feature are disabled by default for the
54+
// F-Droid flavor.
55+
buildConfigField(
56+
"java.util.List<String>",
57+
"DISABLED_REPOS",
58+
"java.util.Arrays.asList(\"androidacy_repo\")",
59+
)
4760
}
4861
}
4962

@@ -100,4 +113,4 @@ dependencies {
100113
testImplementation 'junit:junit:4.+'
101114
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
102115
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
103-
}
116+
}

app/src/main/java/com/fox2code/mmm/repo/RepoData.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.content.SharedPreferences;
44

5+
import com.fox2code.mmm.BuildConfig;
56
import com.fox2code.mmm.MainApplication;
67
import com.fox2code.mmm.R;
78
import com.fox2code.mmm.manager.ModuleInfo;
@@ -42,7 +43,7 @@ protected RepoData(String url, File cacheRoot, SharedPreferences cachedPreferenc
4243
this.moduleHashMap = new HashMap<>();
4344
this.name = this.url; // Set url as default name
4445
this.enabled = MainApplication.getSharedPreferences()
45-
.getBoolean("pref_" + this.id + "_enabled", true);
46+
.getBoolean("pref_" + this.id + "_enabled", this.isEnabledByDefault(this.id));
4647
if (!this.cacheRoot.isDirectory()) {
4748
this.cacheRoot.mkdirs();
4849
} else {
@@ -134,6 +135,10 @@ protected List<RepoModule> populate(JSONObject jsonObject) throws JSONException
134135
return newModules;
135136
}
136137

138+
protected boolean isEnabledByDefault(String id) {
139+
return !BuildConfig.DISABLED_REPOS.contains(id);
140+
}
141+
137142
public void storeMetadata(RepoModule repoModule,byte[] data) throws IOException {
138143
Files.write(new File(this.cacheRoot, repoModule.id + ".prop"), data);
139144
}
@@ -176,6 +181,6 @@ public void setEnabled(boolean enabled) {
176181

177182
public void updateEnabledState() {
178183
this.enabled = MainApplication.getSharedPreferences()
179-
.getBoolean("pref_" + this.id + "_enabled", true);
184+
.getBoolean("pref_" + this.id + "_enabled", this.isEnabledByDefault(this.id));
180185
}
181186
}

app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import androidx.preference.ListPreference;
1111
import androidx.preference.Preference;
1212
import androidx.preference.PreferenceFragmentCompat;
13+
import androidx.preference.TwoStatePreference;
1314

1415
import com.fox2code.mmm.AppUpdateManager;
1516
import com.fox2code.mmm.BuildConfig;
@@ -203,6 +204,7 @@ private void setRepoData(String url,
203204
preference.setTitle(R.string.repo_disabled);
204205
preference.setEnabled(false);
205206
} else {
207+
((TwoStatePreference)preference).setChecked(repoData.isEnabled());
206208
preference.setTitle(repoData.isEnabled() ?
207209
R.string.repo_enabled : R.string.repo_disabled);
208210
preference.setOnPreferenceChangeListener((p, newValue) -> {
@@ -252,4 +254,4 @@ private void setRepoData(String url,
252254
}
253255
}
254256
}
255-
}
257+
}

app/src/main/res/xml/repo_preferences.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
app:key="pref_magisk_alt_repo"
55
app:title="@string/loading">
66
<SwitchPreferenceCompat
7-
app:defaultValue="true"
87
app:key="pref_magisk_alt_repo_enabled"
98
app:icon="@drawable/ic_baseline_extension_24"
109
app:switchTextOn="@string/repo_enabled"
@@ -25,7 +24,6 @@
2524
app:key="pref_androidacy_repo"
2625
app:title="@string/loading">
2726
<SwitchPreferenceCompat
28-
app:defaultValue="true"
2927
app:key="pref_androidacy_repo_enabled"
3028
app:icon="@drawable/ic_baseline_extension_24"
3129
app:switchTextOn="@string/repo_enabled"

0 commit comments

Comments
 (0)