2021-09-03 07:07:05 +00:00
|
|
|
plugins {
|
|
|
|
id 'com.android.application'
|
|
|
|
id 'kotlin-android'
|
|
|
|
id 'kotlin-kapt'
|
|
|
|
id 'org.jlleitschuh.gradle.ktlint'
|
|
|
|
}
|
2021-02-10 15:52:11 +00:00
|
|
|
|
2022-02-09 14:09:03 +00:00
|
|
|
def appVersionName = "4.7.0"
|
2022-12-05 14:15:17 +00:00
|
|
|
def appVersionCode = 40705
|
2021-11-23 13:23:27 +00:00
|
|
|
|
2018-12-05 12:35:05 +00:00
|
|
|
static def getPackageName() {
|
2018-11-15 12:06:12 +00:00
|
|
|
return "org.linphone"
|
|
|
|
}
|
|
|
|
|
2021-09-03 07:07:05 +00:00
|
|
|
def firebaseEnabled = new File(projectDir.absolutePath +'/google-services.json').exists()
|
|
|
|
|
2022-12-05 09:43:36 +00:00
|
|
|
def crashlyticsEnabled = new File(projectDir.absolutePath +'/google-services.json').exists() && new File(LinphoneSdkBuildDir + '/libs/').exists() && new File(LinphoneSdkBuildDir + '/libs-debug/').exists()
|
2021-02-10 15:52:11 +00:00
|
|
|
|
2021-09-03 07:07:05 +00:00
|
|
|
if (firebaseEnabled) {
|
2021-07-09 08:27:20 +00:00
|
|
|
apply plugin: 'com.google.gms.google-services'
|
|
|
|
}
|
|
|
|
|
2021-09-03 07:07:05 +00:00
|
|
|
if (crashlyticsEnabled) {
|
2021-02-10 15:52:11 +00:00
|
|
|
apply plugin: 'com.google.firebase.crashlytics'
|
|
|
|
}
|
|
|
|
|
2021-02-03 14:27:55 +00:00
|
|
|
def gitBranch = new ByteArrayOutputStream()
|
2019-05-16 10:18:57 +00:00
|
|
|
task getGitVersion() {
|
2021-11-23 13:23:27 +00:00
|
|
|
def gitVersion = appVersionName
|
2019-05-16 10:18:57 +00:00
|
|
|
def gitVersionStream = new ByteArrayOutputStream()
|
2019-10-14 09:22:44 +00:00
|
|
|
def gitCommitsCount = new ByteArrayOutputStream()
|
|
|
|
def gitCommitHash = new ByteArrayOutputStream()
|
2019-05-16 10:18:57 +00:00
|
|
|
|
2019-05-17 11:53:04 +00:00
|
|
|
try {
|
|
|
|
exec {
|
2019-10-14 09:22:44 +00:00
|
|
|
executable "git" args "describe", "--abbrev=0"
|
2019-05-17 11:53:04 +00:00
|
|
|
standardOutput = gitVersionStream
|
|
|
|
}
|
2019-10-14 09:22:44 +00:00
|
|
|
exec {
|
|
|
|
executable "git" args "rev-list", gitVersionStream.toString().trim() + "..HEAD", "--count"
|
|
|
|
standardOutput = gitCommitsCount
|
|
|
|
}
|
|
|
|
exec {
|
|
|
|
executable "git" args "rev-parse", "--short", "HEAD"
|
|
|
|
standardOutput = gitCommitHash
|
|
|
|
}
|
2021-02-03 14:27:55 +00:00
|
|
|
exec {
|
|
|
|
executable "git" args "name-rev", "--name-only", "HEAD"
|
|
|
|
standardOutput = gitBranch
|
|
|
|
}
|
2019-10-14 09:22:44 +00:00
|
|
|
|
2020-01-13 09:30:22 +00:00
|
|
|
if (gitCommitsCount.toString().toInteger() == 0) {
|
|
|
|
gitVersion = gitVersionStream.toString().trim()
|
|
|
|
} else {
|
|
|
|
gitVersion = gitVersionStream.toString().trim() + "." + gitCommitsCount.toString().trim() + "+" + gitCommitHash.toString().trim()
|
|
|
|
}
|
2021-11-23 13:23:27 +00:00
|
|
|
println("Git version: " + gitVersion + " (" + appVersionCode + ")")
|
2020-06-01 10:28:24 +00:00
|
|
|
} catch (ignored) {
|
2021-11-23 13:23:27 +00:00
|
|
|
println("Git not found, using " + gitVersion + " (" + appVersionCode + ")")
|
2019-05-16 10:18:57 +00:00
|
|
|
}
|
|
|
|
project.version = gitVersion
|
|
|
|
}
|
|
|
|
|
2021-01-27 10:00:05 +00:00
|
|
|
configurations {
|
2021-01-28 09:35:02 +00:00
|
|
|
customImplementation.extendsFrom implementation
|
2021-01-27 10:00:05 +00:00
|
|
|
}
|
|
|
|
|
2021-01-08 10:49:58 +00:00
|
|
|
task linphoneSdkSource() {
|
|
|
|
doLast {
|
2021-01-27 10:00:05 +00:00
|
|
|
configurations.customImplementation.getIncoming().each {
|
2021-01-08 10:49:58 +00:00
|
|
|
it.getResolutionResult().allComponents.each {
|
|
|
|
if (it.id.getDisplayName().contains("linphone-sdk-android")) {
|
|
|
|
println 'Linphone SDK used is ' + it.moduleVersion.version + ' from ' + it.properties["repositoryName"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-16 10:18:57 +00:00
|
|
|
project.tasks['preBuild'].dependsOn 'getGitVersion'
|
2021-01-08 11:18:46 +00:00
|
|
|
project.tasks['preBuild'].dependsOn 'linphoneSdkSource'
|
2019-05-16 10:18:57 +00:00
|
|
|
|
2018-11-15 12:06:12 +00:00
|
|
|
android {
|
2022-06-09 12:02:03 +00:00
|
|
|
compileSdkVersion 33
|
|
|
|
buildToolsVersion '33.0.0'
|
2018-11-15 12:06:12 +00:00
|
|
|
defaultConfig {
|
2020-06-24 08:09:12 +00:00
|
|
|
minSdkVersion 23
|
2022-06-09 12:02:03 +00:00
|
|
|
targetSdkVersion 33
|
2021-11-23 13:23:27 +00:00
|
|
|
versionCode appVersionCode
|
2019-05-16 10:18:57 +00:00
|
|
|
versionName "${project.version}"
|
2018-11-15 12:06:12 +00:00
|
|
|
applicationId getPackageName()
|
|
|
|
}
|
2020-10-16 08:41:05 +00:00
|
|
|
|
2018-11-19 10:59:12 +00:00
|
|
|
applicationVariants.all { variant ->
|
|
|
|
variant.outputs.all {
|
2019-05-16 10:18:57 +00:00
|
|
|
outputFileName = "linphone-android-${variant.buildType.name}-${project.version}.apk"
|
2018-11-19 10:59:12 +00:00
|
|
|
}
|
2019-10-17 08:22:41 +00:00
|
|
|
|
2022-02-24 10:11:39 +00:00
|
|
|
var enableFirebaseService = "false"
|
|
|
|
if (firebaseEnabled) {
|
|
|
|
enableFirebaseService = "true"
|
|
|
|
}
|
2020-09-09 08:53:36 +00:00
|
|
|
// See https://developer.android.com/studio/releases/gradle-plugin#3-6-0-behavior for why extractNativeLibs is set to true in debug flavor
|
2021-11-16 12:52:46 +00:00
|
|
|
if (variant.buildType.name == "release" || variant.buildType.name == "releaseWithCrashlytics") {
|
2019-10-17 08:22:41 +00:00
|
|
|
variant.getMergedFlavor().manifestPlaceholders = [linphone_address_mime_type: "vnd.android.cursor.item/vnd." + getPackageName() + ".provider.sip_address",
|
2022-02-24 10:11:39 +00:00
|
|
|
linphone_file_provider: getPackageName() + ".fileprovider",
|
|
|
|
appLabel: "@string/app_name",
|
|
|
|
firebaseServiceEnabled: enableFirebaseService,
|
|
|
|
extractNativeLibs: "false"]
|
2019-10-17 08:22:41 +00:00
|
|
|
} else {
|
|
|
|
variant.getMergedFlavor().manifestPlaceholders = [linphone_address_mime_type: "vnd.android.cursor.item/vnd." + getPackageName() + ".provider.sip_address",
|
2022-02-24 10:11:39 +00:00
|
|
|
linphone_file_provider: getPackageName() + ".debug.fileprovider",
|
|
|
|
appLabel: "@string/app_name_debug",
|
|
|
|
firebaseServiceEnabled: enableFirebaseService,
|
|
|
|
extractNativeLibs: "true"]
|
2019-10-17 08:22:41 +00:00
|
|
|
}
|
2018-11-19 10:59:12 +00:00
|
|
|
}
|
|
|
|
|
2018-11-19 09:42:14 +00:00
|
|
|
def keystorePropertiesFile = rootProject.file("keystore.properties")
|
|
|
|
def keystoreProperties = new Properties()
|
|
|
|
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
|
|
|
|
2018-11-15 12:06:12 +00:00
|
|
|
signingConfigs {
|
|
|
|
release {
|
2018-11-19 09:42:14 +00:00
|
|
|
storeFile file(keystoreProperties['storeFile'])
|
|
|
|
storePassword keystoreProperties['storePassword']
|
|
|
|
keyAlias keystoreProperties['keyAlias']
|
|
|
|
keyPassword keystoreProperties['keyPassword']
|
2018-11-15 12:06:12 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-19 09:14:43 +00:00
|
|
|
|
2018-11-15 12:06:12 +00:00
|
|
|
buildTypes {
|
|
|
|
release {
|
|
|
|
minifyEnabled true
|
|
|
|
signingConfig signingConfigs.release
|
2018-11-19 09:27:25 +00:00
|
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
2018-12-06 16:49:08 +00:00
|
|
|
|
2021-02-03 14:27:55 +00:00
|
|
|
resValue "string", "linphone_app_branch", gitBranch.toString().trim()
|
2018-12-06 16:49:08 +00:00
|
|
|
resValue "string", "sync_account_type", getPackageName() + ".sync"
|
2020-03-29 12:14:04 +00:00
|
|
|
resValue "string", "file_provider", getPackageName() + ".fileprovider"
|
2018-12-07 14:10:06 +00:00
|
|
|
resValue "string", "linphone_address_mime_type", "vnd.android.cursor.item/vnd." + getPackageName() + ".provider.sip_address"
|
2019-02-19 09:49:25 +00:00
|
|
|
|
2021-09-03 07:07:05 +00:00
|
|
|
if (!firebaseEnabled) {
|
2019-02-19 09:49:25 +00:00
|
|
|
resValue "string", "gcm_defaultSenderId", "none"
|
|
|
|
}
|
2021-02-25 08:24:57 +00:00
|
|
|
|
|
|
|
resValue "bool", "crashlytics_enabled", "false"
|
2018-11-15 12:06:12 +00:00
|
|
|
}
|
2020-03-29 12:14:04 +00:00
|
|
|
|
2021-07-09 08:27:20 +00:00
|
|
|
releaseWithCrashlytics {
|
2020-10-16 08:41:05 +00:00
|
|
|
initWith release
|
2021-04-27 08:25:13 +00:00
|
|
|
|
2021-09-03 07:07:05 +00:00
|
|
|
resValue "bool", "crashlytics_enabled", crashlyticsEnabled.toString()
|
2021-04-27 08:25:13 +00:00
|
|
|
|
2021-11-16 12:29:02 +00:00
|
|
|
if (crashlyticsEnabled) {
|
2021-04-27 08:25:13 +00:00
|
|
|
firebaseCrashlytics {
|
|
|
|
nativeSymbolUploadEnabled true
|
|
|
|
unstrippedNativeLibsDir file(LinphoneSdkBuildDir + '/libs-debug/').toString()
|
|
|
|
}
|
|
|
|
}
|
2020-10-16 08:41:05 +00:00
|
|
|
}
|
|
|
|
|
2018-11-15 12:06:12 +00:00
|
|
|
debug {
|
|
|
|
applicationIdSuffix ".debug"
|
|
|
|
debuggable true
|
|
|
|
jniDebuggable true
|
2018-12-06 16:49:08 +00:00
|
|
|
|
2021-02-03 14:27:55 +00:00
|
|
|
resValue "string", "linphone_app_branch", gitBranch.toString().trim()
|
2018-12-06 16:49:08 +00:00
|
|
|
resValue "string", "sync_account_type", getPackageName() + ".sync"
|
2020-03-29 12:14:04 +00:00
|
|
|
resValue "string", "file_provider", getPackageName() + ".debug.fileprovider"
|
2018-12-07 14:10:06 +00:00
|
|
|
resValue "string", "linphone_address_mime_type", "vnd.android.cursor.item/vnd." + getPackageName() + ".provider.sip_address"
|
2021-11-16 12:29:02 +00:00
|
|
|
resValue "bool", "crashlytics_enabled", crashlyticsEnabled.toString()
|
2019-02-19 09:49:25 +00:00
|
|
|
|
2021-09-03 07:07:05 +00:00
|
|
|
if (!firebaseEnabled) {
|
2019-02-19 09:49:25 +00:00
|
|
|
resValue "string", "gcm_defaultSenderId", "none"
|
|
|
|
}
|
2021-02-10 15:52:11 +00:00
|
|
|
|
2021-09-03 07:07:05 +00:00
|
|
|
if (crashlyticsEnabled) {
|
2021-02-10 15:52:11 +00:00
|
|
|
firebaseCrashlytics {
|
|
|
|
nativeSymbolUploadEnabled true
|
|
|
|
unstrippedNativeLibsDir file(LinphoneSdkBuildDir + '/libs-debug/').toString()
|
|
|
|
}
|
|
|
|
}
|
2018-11-15 12:06:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-29 07:58:37 +00:00
|
|
|
buildFeatures {
|
|
|
|
dataBinding = true
|
2018-11-15 12:06:12 +00:00
|
|
|
}
|
2020-06-11 08:46:15 +00:00
|
|
|
|
2022-05-12 09:42:16 +00:00
|
|
|
namespace 'org.linphone'
|
2020-03-29 12:14:04 +00:00
|
|
|
}
|
2018-11-19 10:59:12 +00:00
|
|
|
|
2018-11-15 13:36:05 +00:00
|
|
|
dependencies {
|
2020-03-29 12:14:04 +00:00
|
|
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
2022-09-08 08:08:26 +00:00
|
|
|
implementation 'androidx.appcompat:appcompat:1.6.0-rc01'
|
|
|
|
implementation 'androidx.core:core-ktx:1.9.0'
|
2022-08-22 07:53:34 +00:00
|
|
|
implementation 'androidx.core:core-splashscreen:1.0.0'
|
2022-07-28 10:28:07 +00:00
|
|
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
|
2022-06-28 09:40:27 +00:00
|
|
|
implementation 'androidx.media:media:1.6.0'
|
|
|
|
implementation "androidx.security:security-crypto-ktx:1.1.0-alpha03"
|
|
|
|
implementation "androidx.window:window:1.0.0"
|
2021-04-22 08:37:31 +00:00
|
|
|
|
2022-10-28 08:28:50 +00:00
|
|
|
def nav_version = "2.5.3"
|
2021-04-22 08:37:31 +00:00
|
|
|
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
|
|
|
|
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
|
|
|
|
|
2022-01-27 08:58:08 +00:00
|
|
|
implementation "androidx.slidingpanelayout:slidingpanelayout:1.2.0"
|
2022-09-07 11:52:37 +00:00
|
|
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
2022-04-29 07:34:51 +00:00
|
|
|
implementation "androidx.gridlayout:gridlayout:1.0.0"
|
2022-09-29 09:15:43 +00:00
|
|
|
implementation 'androidx.recyclerview:recyclerview:1.3.0-rc01'
|
2022-05-13 14:57:48 +00:00
|
|
|
|
2022-04-20 11:22:47 +00:00
|
|
|
// https://github.com/material-components/material-components-android/blob/master/LICENSE Apache v2.0
|
2022-10-24 12:19:16 +00:00
|
|
|
implementation 'com.google.android.material:material:1.7.0'
|
2022-04-20 07:33:22 +00:00
|
|
|
// https://github.com/google/flexbox-layout/blob/main/LICENSE Apache v2.0
|
2021-09-03 07:07:05 +00:00
|
|
|
implementation 'com.google.android.flexbox:flexbox:3.0.0'
|
2020-10-15 08:22:06 +00:00
|
|
|
|
2022-06-28 09:40:27 +00:00
|
|
|
implementation 'androidx.emoji:emoji:1.1.0'
|
|
|
|
implementation 'androidx.emoji:emoji-bundled:1.1.0'
|
|
|
|
|
2022-04-20 10:56:31 +00:00
|
|
|
// https://github.com/coil-kt/coil/blob/main/LICENSE.txt Apache v2.0
|
2022-07-15 15:29:07 +00:00
|
|
|
def coil_version = "2.1.0"
|
2022-04-20 10:56:31 +00:00
|
|
|
implementation("io.coil-kt:coil:$coil_version")
|
|
|
|
implementation("io.coil-kt:coil-gif:$coil_version")
|
|
|
|
implementation("io.coil-kt:coil-svg:$coil_version")
|
2022-04-20 13:47:29 +00:00
|
|
|
implementation("io.coil-kt:coil-video:$coil_version")
|
2020-03-29 12:14:04 +00:00
|
|
|
|
2022-04-20 07:33:22 +00:00
|
|
|
// https://github.com/Baseflow/PhotoView/blob/master/LICENSE Apache v2.0
|
2021-04-01 11:40:37 +00:00
|
|
|
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
|
|
|
|
|
2022-11-14 09:08:51 +00:00
|
|
|
implementation platform('com.google.firebase:firebase-bom:31.0.3')
|
2021-09-03 07:07:05 +00:00
|
|
|
if (crashlyticsEnabled) {
|
2021-02-10 15:52:11 +00:00
|
|
|
implementation 'com.google.firebase:firebase-crashlytics-ndk'
|
2021-02-25 08:24:57 +00:00
|
|
|
} else {
|
|
|
|
compileOnly 'com.google.firebase:firebase-crashlytics-ndk'
|
2021-02-10 15:52:11 +00:00
|
|
|
}
|
2021-09-03 07:07:05 +00:00
|
|
|
if (firebaseEnabled) {
|
2021-02-10 15:52:11 +00:00
|
|
|
implementation 'com.google.firebase:firebase-messaging'
|
2019-02-22 10:04:02 +00:00
|
|
|
}
|
2020-03-29 12:14:04 +00:00
|
|
|
|
2021-09-15 09:44:23 +00:00
|
|
|
implementation 'org.linphone:linphone-sdk-android:5.2+'
|
2020-09-09 13:05:38 +00:00
|
|
|
|
|
|
|
// Only enable leak canary prior to release
|
|
|
|
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.4'
|
2018-11-24 08:46:31 +00:00
|
|
|
}
|
2020-03-29 12:14:04 +00:00
|
|
|
|
2018-12-07 15:28:24 +00:00
|
|
|
task generateContactsXml(type: Copy) {
|
|
|
|
from 'contacts.xml'
|
|
|
|
into "src/main/res/xml/"
|
2020-06-17 14:31:49 +00:00
|
|
|
outputs.upToDateWhen { file('src/main/res/xml/contacts.xml').exists() }
|
2018-12-07 15:28:24 +00:00
|
|
|
filter {
|
|
|
|
line -> line
|
|
|
|
.replaceAll('%%AUTO_GENERATED%%', 'This file has been automatically generated, do not edit or commit !')
|
|
|
|
.replaceAll('%%PACKAGE_NAME%%', getPackageName())
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
project.tasks['preBuild'].dependsOn 'generateContactsXml'
|
|
|
|
|
2020-03-29 12:14:04 +00:00
|
|
|
ktlint {
|
|
|
|
android = true
|
|
|
|
ignoreFailures = true
|
2018-11-26 10:40:45 +00:00
|
|
|
}
|
2020-03-29 12:14:04 +00:00
|
|
|
|
2021-02-24 09:51:01 +00:00
|
|
|
project.tasks['preBuild'].dependsOn 'ktlintFormat'
|
|
|
|
|
2021-09-03 07:07:05 +00:00
|
|
|
if (crashlyticsEnabled) {
|
2021-02-24 09:51:01 +00:00
|
|
|
afterEvaluate {
|
|
|
|
assembleDebug.finalizedBy(uploadCrashlyticsSymbolFileDebug)
|
|
|
|
packageDebugBundle.finalizedBy(uploadCrashlyticsSymbolFileDebug)
|
2021-04-27 08:25:13 +00:00
|
|
|
|
2021-07-09 08:27:20 +00:00
|
|
|
assembleReleaseWithCrashlytics.finalizedBy(uploadCrashlyticsSymbolFileReleaseWithCrashlytics)
|
|
|
|
packageReleaseWithCrashlytics.finalizedBy(uploadCrashlyticsSymbolFileReleaseWithCrashlytics)
|
2021-02-24 09:51:01 +00:00
|
|
|
}
|
2020-07-16 09:15:19 +00:00
|
|
|
}
|