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

Commit e1cc030

Browse files
committed
Add F-Droid build flavor.
We need a different build flavor for F-Droid because they forbid auto-updaters as they download blobs from the internet (and it wouldn't be possible to install the downloaded APK anyways because of the signatures mismatch). I chose to implement this using a build config field instead of using a per-build-flavor source directory because I thought it introduces less maintenance burden. In particular, per-build-flavor source directories would require an interface in the main source directory for the update manager, which would be implemented for each build flavor in a specific source directory. Considering this project doesn't have CI builds yet, I think it wouldn't be wise. Still we might reconsider should we need more complex setup (such as different dependencies for the two build flavors). The main downside of the build config field for now is that it may be more prone to silent regressions. Fixes #41
1 parent 7fb2daa commit e1cc030

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

app/build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,25 @@ android {
2828
debuggable true
2929
}
3030
}
31+
32+
flavorDimensions "type"
33+
productFlavors {
34+
"default" {
35+
dimension "type"
36+
buildConfigField "boolean", "ENABLE_AUTO_UPDATER", "true"
37+
}
38+
39+
fdroid {
40+
dimension "type"
41+
applicationIdSuffix ".fdroid"
42+
43+
// Need to disable auto-updater for F-Droid flavor because their inclusion policy
44+
// forbids downloading blobs from third-party websites (and F-Droid APK isn't signed
45+
// with our keys, so the APK wouldn't install anyways).
46+
buildConfigField "boolean", "ENABLE_AUTO_UPDATER", "false"
47+
}
48+
}
49+
3150
compileOptions {
3251
sourceCompatibility JavaVersion.VERSION_1_8
3352
targetCompatibility JavaVersion.VERSION_1_8

app/src/main/java/com/fox2code/mmm/AppUpdateManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ private AppUpdateManager() {
6363

6464
// Return true if should show a notification
6565
public boolean checkUpdate(boolean force) {
66+
if (!BuildConfig.ENABLE_AUTO_UPDATER)
67+
return false;
6668
if (!force && this.peekShouldUpdate())
6769
return true;
6870
long lastChecked = this.lastChecked;

0 commit comments

Comments
 (0)