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
|
|
|
|
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()
|
|
|
|
|
|
|
|
def crashlyticsEnabled = new File(projectDir.absolutePath +'/google-services.json').exists() && new File(LinphoneSdkBuildDir + '/libs/').exists() && new File(LinphoneSdkBuildDir + '/libs-debug/').exists()
|
2018-11-15 12:06:12 +00:00
|
|
|
|
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-06-04 15:03:55 +00:00
|
|
|
def gitVersion = "4.6.0"
|
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()
|
|
|
|
}
|
2019-05-16 10:18:57 +00:00
|
|
|
println("Git version: " + gitVersion)
|
2020-06-01 10:28:24 +00:00
|
|
|
} catch (ignored) {
|
2019-05-16 10:18:57 +00:00
|
|
|
println("Git not found")
|
|
|
|
}
|
|
|
|
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 {
|
2021-09-03 07:38:33 +00:00
|
|
|
compileSdkVersion 31
|
|
|
|
buildToolsVersion '31.0.0'
|
2018-11-15 12:06:12 +00:00
|
|
|
defaultConfig {
|
2020-06-24 08:09:12 +00:00
|
|
|
minSdkVersion 23
|
2021-09-03 07:38:33 +00:00
|
|
|
targetSdkVersion 31
|
2021-07-15 09:44:54 +00:00
|
|
|
versionCode 4600
|
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
|
|
|
|
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
|
2020-10-16 08:41:05 +00:00
|
|
|
if (variant.buildType.name == "release" || variant.buildType.name == "releaseAppBundle") {
|
2019-10-17 08:22:41 +00:00
|
|
|
variant.getMergedFlavor().manifestPlaceholders = [linphone_address_mime_type: "vnd.android.cursor.item/vnd." + getPackageName() + ".provider.sip_address",
|
2020-06-03 08:27:05 +00:00
|
|
|
linphone_file_provider: getPackageName() + ".fileprovider",
|
2020-09-09 08:53:36 +00:00
|
|
|
appLabel: "@string/app_name",
|
|
|
|
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",
|
2020-06-03 08:27:05 +00:00
|
|
|
linphone_file_provider: getPackageName() + ".debug.fileprovider",
|
2020-09-09 08:53:36 +00:00
|
|
|
appLabel: "@string/app_name_debug",
|
|
|
|
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()
|
|
|
|
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"
|
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
|
|
|
resValue "bool", "crashlytics_enabled", crashlyticsEnabled.toString()
|
|
|
|
if (crashlyticsEnabled) {
|
2021-02-25 08:24:57 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
compileOptions {
|
|
|
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
|
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
|
|
}
|
|
|
|
|
|
|
|
kotlinOptions {
|
|
|
|
jvmTarget = "1.8"
|
|
|
|
}
|
2020-03-29 12:14:04 +00:00
|
|
|
}
|
2018-11-19 10:59:12 +00:00
|
|
|
|
2020-03-29 12:14:04 +00:00
|
|
|
repositories {
|
|
|
|
maven {
|
2021-01-08 10:49:58 +00:00
|
|
|
name "local linphone-sdk maven repository"
|
2020-03-29 12:14:04 +00:00
|
|
|
url file(LinphoneSdkBuildDir + '/maven_repository/')
|
2020-07-16 09:15:19 +00:00
|
|
|
content {
|
|
|
|
includeGroup "org.linphone"
|
|
|
|
}
|
2018-11-15 12:06:12 +00:00
|
|
|
}
|
2020-03-29 12:14:04 +00:00
|
|
|
|
2020-06-17 08:49:33 +00:00
|
|
|
maven {
|
2021-01-08 10:49:58 +00:00
|
|
|
name "linphone.org maven repository"
|
2020-03-29 12:14:04 +00:00
|
|
|
url "https://linphone.org/maven_repository"
|
2020-07-16 09:15:19 +00:00
|
|
|
content {
|
|
|
|
includeGroup "org.linphone"
|
|
|
|
}
|
2020-06-17 08:49:33 +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'])
|
|
|
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
2020-10-15 08:22:06 +00:00
|
|
|
|
2021-09-09 08:03:41 +00:00
|
|
|
implementation 'androidx.appcompat:appcompat:1.3.1'
|
|
|
|
implementation 'androidx.media:media:1.4.1'
|
|
|
|
implementation 'androidx.fragment:fragment-ktx:1.4.0-alpha08'
|
|
|
|
implementation 'androidx.core:core-ktx:1.7.0-alpha02'
|
2021-04-22 08:37:31 +00:00
|
|
|
|
2021-09-09 09:58:38 +00:00
|
|
|
def nav_version = "2.4.0-alpha08"
|
2021-04-22 08:37:31 +00:00
|
|
|
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
|
|
|
|
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
|
|
|
|
|
2021-09-09 08:03:41 +00:00
|
|
|
implementation "androidx.slidingpanelayout:slidingpanelayout:1.2.0-beta01"
|
|
|
|
implementation "androidx.window:window:1.0.0-beta02"
|
2021-06-17 12:28:24 +00:00
|
|
|
|
2021-09-09 08:03:41 +00:00
|
|
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
|
2020-03-29 12:14:04 +00:00
|
|
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
2021-03-29 14:51:53 +00:00
|
|
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
|
2021-09-09 08:03:41 +00:00
|
|
|
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
2021-07-09 08:27:20 +00:00
|
|
|
implementation "androidx.security:security-crypto-ktx:1.1.0-alpha03"
|
2020-10-15 08:22:06 +00:00
|
|
|
|
2021-07-09 08:27:20 +00:00
|
|
|
implementation 'com.google.android.material:material:1.4.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
|
|
|
|
2020-12-01 10:03:10 +00:00
|
|
|
implementation 'androidx.emoji:emoji:1.1.0'
|
|
|
|
implementation 'androidx.emoji:emoji-bundled:1.1.0'
|
|
|
|
|
2021-02-02 10:55:48 +00:00
|
|
|
implementation 'com.github.bumptech.glide:glide:4.12.0'
|
|
|
|
kapt 'com.github.bumptech.glide:compiler:4.12.0'
|
2020-03-29 12:14:04 +00:00
|
|
|
|
2021-04-01 11:40:37 +00:00
|
|
|
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
|
|
|
|
|
2021-02-10 15:52:11 +00:00
|
|
|
implementation platform('com.google.firebase:firebase-bom:26.4.0')
|
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-06-04 15:03:55 +00:00
|
|
|
implementation 'org.linphone:linphone-sdk-android:5.1+'
|
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
|
|
|
}
|