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

Commit ea48ada

Browse files
authored
Merge pull request #115 from gilbsgilbs/fdroid-disable-androidacy
Moving towards F-Droid inclusion
2 parents 5a21c64 + 0d380a0 commit ea48ada

File tree

6 files changed

+34
-8
lines changed

6 files changed

+34
-8
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/values-fr/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,5 @@
9393
<string name="enable_blur_pref">Activer l\’effet de flou</string>
9494
<string name="repo_enabled">Dépôt activé</string>
9595
<string name="repo_disabled">Dépôt désactivé</string>
96+
<string name="androidacy_repo_info">Le dépôt Androidacy utilise des publicités et des pisteurs.</string>
9697
</resources>

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,5 @@
9393
<string name="enable_blur_pref">Enable blur</string>
9494
<string name="repo_enabled">Repo enabled</string>
9595
<string name="repo_disabled">Repo disabled</string>
96-
</resources>
96+
<string name="androidacy_repo_info">Androidacy repo uses ads and trackers.</string>
97+
</resources>

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

Lines changed: 7 additions & 3 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"
@@ -50,6 +48,12 @@
5048
app:key="pref_androidacy_repo_submit"
5149
app:icon="@drawable/ic_baseline_upload_file_24"
5250
app:title="@string/submit_modules"
53-
app:singleLineTitle="false" />
51+
app:singleLineTitle="false" />
52+
<Preference
53+
app:key="pref_androidacy_ads_disclaimer"
54+
app:icon="@drawable/ic_baseline_info_24"
55+
app:enabled="false"
56+
app:summary="@string/androidacy_repo_info"
57+
app:singleLineTitle="false" />
5458
</PreferenceCategory>
5559
</PreferenceScreen>

0 commit comments

Comments
 (0)