Added app version (git describe) to troubleshooting view

This commit is contained in:
Sylvain Berfini 2023-12-01 16:38:45 +01:00
parent b30f44a0a1
commit f5d141d59f
4 changed files with 100 additions and 11 deletions

View file

@ -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 {

View file

@ -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<String>()
val appVersion = MutableLiveData<String>()
val sdkVersion = MutableLiveData<String>()
val debugModeEnabled = MutableLiveData<Boolean>()
@ -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 ->

View file

@ -129,42 +129,81 @@
app:layout_constraintTop_toBottomOf="@id/debug_subtitle"/>
<ImageView
android:id="@+id/version_icon"
android:id="@+id/app_version_icon"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginStart="16dp"
android:src="@drawable/info"
app:tint="?attr/color_main1_500"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/version_title"
app:layout_constraintTop_toTopOf="@id/version_title"
app:layout_constraintBottom_toBottomOf="@id/version_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"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/header_style"
android:id="@+id/version_title"
android:id="@+id/app_version_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="24dp"
android:text="@string/help_troubleshooting_app_version_title"
app:layout_constraintTop_toBottomOf="@id/send_logs"
app:layout_constraintStart_toEndOf="@id/app_version_icon"
app:layout_constraintEnd_toEndOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/app_version_subtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@{viewModel.appVersion, default=`6.0.0 (master)`}"
android:textSize="14sp"
android:textColor="@color/gray_main2_600"
app:layout_constraintTop_toBottomOf="@id/app_version_title"
app:layout_constraintStart_toEndOf="@id/app_version_icon"
app:layout_constraintEnd_toEndOf="parent" />
<ImageView
android:id="@+id/sdk_version_icon"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginStart="16dp"
android:src="@drawable/info"
app:tint="?attr/color_main1_500"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/sdk_version_title"
app:layout_constraintTop_toTopOf="@id/sdk_version_title"
app:layout_constraintBottom_toBottomOf="@id/sdk_version_subtitle"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/header_style"
android:id="@+id/sdk_version_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="24dp"
android:text="@string/help_troubleshooting_sdk_version_title"
app:layout_constraintTop_toBottomOf="@id/send_logs"
app:layout_constraintStart_toEndOf="@id/version_icon"
app:layout_constraintTop_toBottomOf="@id/app_version_icon"
app:layout_constraintStart_toEndOf="@id/sdk_version_icon"
app:layout_constraintEnd_toEndOf="parent"/>
<androidx.appcompat.widget.AppCompatTextView
style="@style/default_text_style"
android:id="@+id/version_subtitle"
android:id="@+id/sdk_version_subtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:text="@{viewModel.sdkVersion, default=`5.3.0`}"
android:text="@{viewModel.sdkVersion, default=`5.4.0 (master)`}"
android:textSize="14sp"
android:textColor="@color/gray_main2_600"
app:layout_constraintTop_toBottomOf="@id/version_title"
app:layout_constraintStart_toEndOf="@id/version_icon"
app:layout_constraintTop_toBottomOf="@id/sdk_version_title"
app:layout_constraintStart_toEndOf="@id/sdk_version_icon"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -232,6 +232,7 @@
<string name="help_troubleshooting_debug_subtitle">Blah</string> <!-- TODO -->
<string name="help_troubleshooting_clean_logs">Clean logs</string>
<string name="help_troubleshooting_share_logs">Share logs</string>
<string name="help_troubleshooting_app_version_title">Linphone app version</string>
<string name="help_troubleshooting_sdk_version_title">Linphone SDK version</string>
<string name="help_troubleshooting_share_logs_dialog_title">Share debug logs link using…</string>
<string name="help_troubleshooting_debug_logs_cleaned_toast_message">Debug logs have been cleaned</string>