diff --git a/app/build.gradle b/app/build.gradle index 05ff555bb..fd3eb536f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,6 +14,42 @@ configurations { customImplementation.extendsFrom implementation } +def gitBranch = new ByteArrayOutputStream() +def gitVersion = new ByteArrayOutputStream() +task getGitVersion() { + def gitVersionStream = new ByteArrayOutputStream() + def gitCommitsCount = new ByteArrayOutputStream() + def gitCommitHash = new ByteArrayOutputStream() + + try { + exec { + executable "git" args "describe", "--abbrev=0" + standardOutput = gitVersionStream + } + exec { + executable "git" args "rev-list", gitVersionStream.toString().trim() + "..HEAD", "--count" + standardOutput = gitCommitsCount + } + exec { + executable "git" args "rev-parse", "--short", "HEAD" + standardOutput = gitCommitHash + } + exec { + executable "git" args "name-rev", "--name-only", "HEAD" + standardOutput = gitBranch + } + + if (gitCommitsCount.toString().toInteger() == 0) { + gitVersion = gitVersionStream.toString().trim() + } else { + gitVersion = gitVersionStream.toString().trim() + "." + gitCommitsCount.toString().trim() + "+" + gitCommitHash.toString().trim() + } + println("Git version: " + gitVersion) + } catch (ignored) { + println("Git not found [" + ignored + "], using " + gitVersion) + } +} + task linphoneSdkSource() { doLast { configurations.customImplementation.getIncoming().each { @@ -25,6 +61,8 @@ task linphoneSdkSource() { } } } + +project.tasks['preBuild'].dependsOn 'getGitVersion' project.tasks['preBuild'].dependsOn 'linphoneSdkSource' android { @@ -51,6 +89,8 @@ android { jniDebuggable true resValue "string", "file_provider", packageName + ".fileprovider" + resValue "string", "linphone_app_version", gitVersion.toString().trim() + resValue "string", "linphone_app_branch", gitBranch.toString().trim() } release { @@ -58,6 +98,8 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' resValue "string", "file_provider", packageName + ".fileprovider" + resValue "string", "linphone_app_version", gitVersion.toString().trim() + resValue "string", "linphone_app_branch", gitBranch.toString().trim() } } compileOptions { diff --git a/app/src/main/java/org/linphone/ui/main/help/viewmodel/HelpViewModel.kt b/app/src/main/java/org/linphone/ui/main/help/viewmodel/HelpViewModel.kt index 2f83d5d84..b59fe2928 100644 --- a/app/src/main/java/org/linphone/ui/main/help/viewmodel/HelpViewModel.kt +++ b/app/src/main/java/org/linphone/ui/main/help/viewmodel/HelpViewModel.kt @@ -26,12 +26,14 @@ import androidx.lifecycle.ViewModel import org.linphone.BuildConfig import org.linphone.LinphoneApplication.Companion.coreContext import org.linphone.LinphoneApplication.Companion.corePreferences +import org.linphone.R import org.linphone.core.Core import org.linphone.core.CoreListenerStub import org.linphone.core.Factory import org.linphone.core.LogLevel import org.linphone.core.VersionUpdateCheckResult import org.linphone.core.tools.Log +import org.linphone.utils.AppUtils import org.linphone.utils.Event class HelpViewModel @UiThread constructor() : ViewModel() { @@ -41,6 +43,8 @@ class HelpViewModel @UiThread constructor() : ViewModel() { val version = MutableLiveData() + val appVersion = MutableLiveData() + val sdkVersion = MutableLiveData() val debugModeEnabled = MutableLiveData() @@ -113,6 +117,9 @@ class HelpViewModel @UiThread constructor() : ViewModel() { init { val currentVersion = BuildConfig.VERSION_NAME version.value = currentVersion + appVersion.value = "${AppUtils.getString(R.string.linphone_app_version)} (${AppUtils.getString( + R.string.linphone_app_branch + )})" sdkVersion.value = coreContext.sdkVersion coreContext.postOnCoreThread { core -> diff --git a/app/src/main/res/layout/help_debug_fragment.xml b/app/src/main/res/layout/help_debug_fragment.xml index c5577b2f9..53939daf0 100644 --- a/app/src/main/res/layout/help_debug_fragment.xml +++ b/app/src/main/res/layout/help_debug_fragment.xml @@ -129,42 +129,81 @@ app:layout_constraintTop_toBottomOf="@id/debug_subtitle"/> + app:layout_constraintEnd_toStartOf="@id/app_version_title" + app:layout_constraintTop_toTopOf="@id/app_version_title" + app:layout_constraintBottom_toBottomOf="@id/app_version_subtitle"/> + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7abd76927..14760e5ed 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -232,6 +232,7 @@ Blah Clean logs Share logs + Linphone app version Linphone SDK version Share debug logs link using… Debug logs have been cleaned