2021-09-03 07:07:05 +00:00
|
|
|
plugins {
|
|
|
|
id 'com.android.application'
|
|
|
|
id 'kotlin-android'
|
|
|
|
id 'kotlin-kapt'
|
2023-04-14 08:43:10 +00:00
|
|
|
id 'org.jlleitschuh.gradle.ktlint' version '11.3.1'
|
2023-02-07 15:09:28 +00:00
|
|
|
id 'org.jetbrains.kotlin.android'
|
2021-09-03 07:07:05 +00:00
|
|
|
}
|
2021-02-10 15:52:11 +00:00
|
|
|
|
2024-04-16 11:26:43 +00:00
|
|
|
def appVersionName = "1.0.1"
|
|
|
|
def appVersionCode = 52001
|
2021-11-23 13:23:27 +00:00
|
|
|
|
2024-02-27 09:28:25 +00:00
|
|
|
def packageName = "org.difusephone"
|
2018-11-15 12:06:12 +00:00
|
|
|
|
2023-03-02 15:14:35 +00:00
|
|
|
def firebaseAvailable = new File(projectDir.absolutePath +'/google-services.json').exists()
|
2021-09-03 07:07:05 +00:00
|
|
|
|
2023-03-02 15:14:35 +00:00
|
|
|
def crashlyticsAvailable = 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
|
|
|
|
2023-07-31 07:34:16 +00:00
|
|
|
def extractNativeLibs = false
|
|
|
|
|
2023-03-02 15:14:35 +00:00
|
|
|
if (firebaseAvailable) {
|
2021-07-09 08:27:20 +00:00
|
|
|
apply plugin: 'com.google.gms.google-services'
|
|
|
|
}
|
|
|
|
|
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 {
|
2023-04-14 08:43:10 +00:00
|
|
|
compileOptions {
|
|
|
|
sourceCompatibility = 17
|
|
|
|
targetCompatibility = 17
|
|
|
|
}
|
|
|
|
|
2023-06-08 09:38:21 +00:00
|
|
|
compileSdkVersion 34
|
2018-11-15 12:06:12 +00:00
|
|
|
defaultConfig {
|
2020-06-24 08:09:12 +00:00
|
|
|
minSdkVersion 23
|
2023-06-08 09:38:21 +00:00
|
|
|
targetSdkVersion 34
|
2021-11-23 13:23:27 +00:00
|
|
|
versionCode appVersionCode
|
2019-05-16 10:18:57 +00:00
|
|
|
versionName "${project.version}"
|
2023-07-31 07:34:16 +00:00
|
|
|
applicationId packageName
|
2018-11-15 12:06:12 +00:00
|
|
|
}
|
2020-10-16 08:41:05 +00:00
|
|
|
|
2018-11-19 10:59:12 +00:00
|
|
|
applicationVariants.all { variant ->
|
|
|
|
variant.outputs.all {
|
2024-04-04 09:53:23 +00:00
|
|
|
outputFileName = "difuse-phone-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"
|
2023-03-02 15:14:35 +00:00
|
|
|
if (firebaseAvailable) {
|
2022-02-24 10:11:39 +00:00
|
|
|
enableFirebaseService = "true"
|
|
|
|
}
|
2023-07-31 07:34:16 +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
|
2021-11-16 12:52:46 +00:00
|
|
|
if (variant.buildType.name == "release" || variant.buildType.name == "releaseWithCrashlytics") {
|
2023-07-31 07:34:16 +00:00
|
|
|
variant.getMergedFlavor().manifestPlaceholders = [linphone_address_mime_type: "vnd.android.cursor.item/vnd." + packageName + ".provider.sip_address",
|
|
|
|
linphone_file_provider: packageName + ".fileprovider",
|
2022-02-24 10:11:39 +00:00
|
|
|
appLabel: "@string/app_name",
|
2023-07-31 07:34:16 +00:00
|
|
|
firebaseServiceEnabled: enableFirebaseService]
|
2019-10-17 08:22:41 +00:00
|
|
|
} else {
|
2023-07-31 07:34:16 +00:00
|
|
|
variant.getMergedFlavor().manifestPlaceholders = [linphone_address_mime_type: "vnd.android.cursor.item/vnd." + packageName + ".provider.sip_address",
|
|
|
|
linphone_file_provider: packageName + ".debug.fileprovider",
|
2022-02-24 10:11:39 +00:00
|
|
|
appLabel: "@string/app_name_debug",
|
2023-07-31 07:34:16 +00:00
|
|
|
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()
|
2023-07-31 07:34:16 +00:00
|
|
|
resValue "string", "sync_account_type", packageName + ".sync"
|
|
|
|
resValue "string", "file_provider", packageName + ".fileprovider"
|
|
|
|
resValue "string", "linphone_address_mime_type", "vnd.android.cursor.item/vnd." + packageName + ".provider.sip_address"
|
2019-02-19 09:49:25 +00:00
|
|
|
|
2023-03-02 15:14:35 +00:00
|
|
|
if (!firebaseAvailable) {
|
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
|
|
|
|
2023-03-02 15:14:35 +00:00
|
|
|
resValue "bool", "crashlytics_enabled", crashlyticsAvailable.toString()
|
|
|
|
|
|
|
|
if (crashlyticsAvailable) {
|
|
|
|
apply plugin: 'com.google.firebase.crashlytics'
|
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()
|
2023-07-31 07:34:16 +00:00
|
|
|
resValue "string", "sync_account_type", packageName + ".sync"
|
|
|
|
resValue "string", "file_provider", packageName + ".debug.fileprovider"
|
|
|
|
resValue "string", "linphone_address_mime_type", "vnd.android.cursor.item/vnd." + packageName + ".provider.sip_address"
|
2023-03-02 15:14:35 +00:00
|
|
|
resValue "bool", "crashlytics_enabled", crashlyticsAvailable.toString()
|
2019-02-19 09:49:25 +00:00
|
|
|
|
2023-03-02 15:14:35 +00:00
|
|
|
if (!firebaseAvailable) {
|
2019-02-19 09:49:25 +00:00
|
|
|
resValue "string", "gcm_defaultSenderId", "none"
|
|
|
|
}
|
2021-02-10 15:52:11 +00:00
|
|
|
|
2023-03-02 15:14:35 +00:00
|
|
|
if (crashlyticsAvailable) {
|
|
|
|
apply plugin: 'com.google.firebase.crashlytics'
|
|
|
|
|
2021-02-10 15:52:11 +00:00
|
|
|
firebaseCrashlytics {
|
2023-01-16 14:59:28 +00:00
|
|
|
nativeSymbolUploadEnabled false
|
2021-02-10 15:52:11 +00:00
|
|
|
}
|
|
|
|
}
|
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'
|
2023-07-31 07:34:16 +00:00
|
|
|
packagingOptions {
|
|
|
|
jniLibs {
|
|
|
|
useLegacyPackaging extractNativeLibs
|
|
|
|
}
|
|
|
|
}
|
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'])
|
2023-02-10 09:37:59 +00:00
|
|
|
implementation 'androidx.appcompat:appcompat:1.6.1'
|
2023-11-27 09:05:56 +00:00
|
|
|
implementation 'androidx.core:core-ktx:1.12.0'
|
2023-04-20 08:05:50 +00:00
|
|
|
implementation 'androidx.core:core-splashscreen:1.0.1'
|
2023-09-11 14:32:01 +00:00
|
|
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
|
2022-06-28 09:40:27 +00:00
|
|
|
implementation 'androidx.media:media:1.6.0'
|
2023-05-05 08:44:52 +00:00
|
|
|
implementation "androidx.security:security-crypto-ktx:1.1.0-alpha06"
|
2023-11-27 09:05:56 +00:00
|
|
|
implementation "androidx.window:window:1.2.0"
|
2021-04-22 08:37:31 +00:00
|
|
|
|
2023-09-06 07:28:02 +00:00
|
|
|
def emoji_version = "1.4.0"
|
2023-05-25 08:46:00 +00:00
|
|
|
implementation "androidx.emoji2:emoji2:$emoji_version"
|
|
|
|
implementation "androidx.emoji2:emoji2-emojipicker:$emoji_version"
|
2021-04-22 08:37:31 +00:00
|
|
|
|
2023-11-27 09:05:56 +00:00
|
|
|
def nav_version = "2.7.5"
|
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"
|
2023-11-27 09:05:56 +00:00
|
|
|
implementation 'androidx.recyclerview:recyclerview:1.3.2'
|
2023-03-23 16:08:52 +00:00
|
|
|
implementation 'androidx.drawerlayout:drawerlayout:1.2.0'
|
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
|
2023-11-27 09:05:56 +00:00
|
|
|
implementation 'com.google.android.material:material:1.10.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-04-20 10:56:31 +00:00
|
|
|
// https://github.com/coil-kt/coil/blob/main/LICENSE.txt Apache v2.0
|
2023-05-25 08:46:00 +00:00
|
|
|
def coil_version = "2.4.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'
|
|
|
|
|
2023-11-27 09:05:56 +00:00
|
|
|
implementation platform('com.google.firebase:firebase-bom:32.5.0')
|
2023-03-02 15:14:35 +00:00
|
|
|
if (crashlyticsAvailable) {
|
|
|
|
debugImplementation 'com.google.firebase:firebase-crashlytics-ndk'
|
|
|
|
releaseWithCrashlyticsImplementation 'com.google.firebase:firebase-crashlytics-ndk'
|
|
|
|
releaseCompileOnly '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
|
|
|
}
|
2023-03-02 15:14:35 +00:00
|
|
|
if (firebaseAvailable) {
|
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
|
|
|
|
2024-01-18 15:08:57 +00:00
|
|
|
implementation 'org.linphone:linphone-sdk-android:5.4+'
|
2020-09-09 13:05:38 +00:00
|
|
|
|
|
|
|
// Only enable leak canary prior to release
|
2023-05-16 07:42:11 +00:00
|
|
|
// debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
|
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 !')
|
2023-07-31 07:34:16 +00:00
|
|
|
.replaceAll('%%PACKAGE_NAME%%', packageName)
|
2018-12-07 15:28:24 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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'
|
|
|
|
|
2023-03-02 15:14:35 +00:00
|
|
|
if (crashlyticsAvailable) {
|
2021-02-24 09:51:01 +00:00
|
|
|
afterEvaluate {
|
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
|
|
|
}
|