Skip to content

Commit

Permalink
Add proprietary and foss product flavors
Browse files Browse the repository at this point in the history
The introduction of the proprietary PhotoEditor SDK prevented this app from
being truly free and open source, and so F-Droid could no longer build the app.
By adding a licensing flavor dimension, we segregate the non-FOSS code to a
separate version, while providing a FOSS version without the editor.

To build the proprietary version, select one of the proprietary build variants
from Build Variants pane in Android Studio (on the left side of the window).

Fixes SimpleMobileTools#1706.
  • Loading branch information
Leo Pham authored and nnn1590 committed Mar 20, 2020
1 parent e7f4a97 commit 9d6a530
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 27 deletions.
48 changes: 30 additions & 18 deletions app/build.gradle
Expand Up @@ -53,6 +53,16 @@ android {
main.java.srcDirs += 'src/main/kotlin'
}

flavorDimensions "licensing"
productFlavors {
proprietary { }
foss {
// We're not using PhotoEditor here, so changing the name is fine.
applicationIdSuffix ".foss"
versionNameSuffix "-foss"
}
}

lintOptions {
checkReleaseBuilds false
abortOnError false
Expand Down Expand Up @@ -92,28 +102,30 @@ dependencies {
}

// Apply the PESDKPlugin
apply plugin: 'ly.img.android.sdk'
if (is_proprietary) {
apply plugin: 'ly.img.android.sdk'

imglyConfig {
pesdk {
enabled true
licencePath 'pesdk_license'
}
imglyConfig {
pesdk {
enabled true
licencePath 'pesdk_license'
}

supportLibVersion "28.0.0"
supportLibVersion "28.0.0"

modules {
include 'ui:core'
include 'ui:text'
include 'ui:focus'
include 'ui:brush'
include 'ui:filter'
include 'ui:transform'
include 'ui:adjustment'
modules {
include 'ui:core'
include 'ui:text'
include 'ui:focus'
include 'ui:brush'
include 'ui:filter'
include 'ui:transform'
include 'ui:adjustment'

include 'backend:serializer'
include 'backend:serializer'

include 'assets:font-basic'
include 'assets:filter-basic'
include 'assets:font-basic'
include 'assets:filter-basic'
}
}
}
12 changes: 5 additions & 7 deletions app/src/main/AndroidManifest.xml
Expand Up @@ -201,20 +201,18 @@
</activity>

<activity
android:name=".activities.NewEditActivity"
android:name=".activities.EditActivity"
android:label="@string/editor">
<intent-filter>

<intent-filter
android:name="foss-editor">

<action android:name="android.intent.action.EDIT"/>

<category android:name="android.intent.category.DEFAULT"/>

<data android:mimeType="image/*"/>
</intent-filter>
</activity>

<activity
android:name=".activities.EditActivity"
android:label="@string/editor">

<intent-filter>
<action android:name="com.android.camera.action.CROP"/>
Expand Down
39 changes: 39 additions & 0 deletions app/src/proprietary/AndroidManifest.xml
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.simplemobiletools.gallery.pro"
android:installLocation="auto">

<application
android:name=".App">

<activity
android:name=".activities.EditActivity">

<intent-filter
android:name="foss-editor"
tools:node="remove">

<action android:name="android.intent.action.EDIT"/>

<category android:name="android.intent.category.DEFAULT"/>

<data android:mimeType="image/*"/>
</intent-filter>
</activity>

<activity
android:name=".activities.NewEditActivity"
android:label="@string/editor">

<intent-filter>
<action android:name="android.intent.action.EDIT"/>

<category android:name="android.intent.category.DEFAULT"/>

<data android:mimeType="image/*"/>
</intent-filter>
</activity>
</application>
</manifest>
File renamed without changes.
9 changes: 7 additions & 2 deletions build.gradle
Expand Up @@ -2,17 +2,22 @@

buildscript {
ext.kotlin_version = '1.3.61'
ext.is_proprietary = gradle.startParameter.taskNames.any { task -> task.contains("Proprietary") }

repositories {
google()
jcenter()
maven { url 'https://artifactory.img.ly/artifactory/imgly' }
if (is_proprietary) {
maven { url 'https://artifactory.img.ly/artifactory/imgly' }
}
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'ly.img.android.pesdk:plugin:7.0.10'
if (is_proprietary) {
classpath 'ly.img.android.pesdk:plugin:7.0.10'
}

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down

0 comments on commit 9d6a530

Please sign in to comment.