From fbc82d783184cbe24eae53dffc7199a5889f28bf Mon Sep 17 00:00:00 2001
From: AL-Session <160798022+AL-Session@users.noreply.github.com>
Date: Thu, 2 May 2024 12:55:24 +1000
Subject: [PATCH] SES1628 - Add git commit details to version info (#1459)
* Fixes #1458
* Addressed PR feedback
---
app/build.gradle | 12 ++++++++++++
.../securesms/preferences/SettingsActivity.kt | 5 ++++-
app/src/main/res/values-fa/strings.xml | 2 +-
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/app/build.gradle b/app/build.gradle
index ac1b68ae6c..5016a1fded 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -41,6 +41,17 @@ def abiPostFix = ['armeabi-v7a' : 1,
'x86_64' : 4,
'universal' : 5]
+// Function to get the current git commit hash so we can embed it along w/ the build version.
+// Note: This is visible in the SettingsActivity, right at the bottom (R.id.versionTextView).
+def getGitHash = { ->
+ def stdout = new ByteArrayOutputStream()
+ exec {
+ commandLine "git", "rev-parse", "--short", "HEAD"
+ standardOutput = stdout
+ }
+ return stdout.toString().trim()
+}
+
android {
compileSdkVersion androidCompileSdkVersion
namespace 'network.loki.messenger'
@@ -94,6 +105,7 @@ android {
project.ext.set("archivesBaseName", "session")
buildConfigField "long", "BUILD_TIMESTAMP", getLastCommitTimestamp() + "L"
+ buildConfigField "String", "GIT_HASH", "\"$getGitHash\""
buildConfigField "String", "CONTENT_PROXY_HOST", "\"contentproxy.signal.org\""
buildConfigField "int", "CONTENT_PROXY_PORT", "443"
buildConfigField "String", "USER_AGENT", "\"OWA\""
diff --git a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt
index 2a45d596d6..b66df5d255 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/preferences/SettingsActivity.kt
@@ -37,6 +37,7 @@ import org.session.libsession.snode.SnodeAPI
import org.session.libsession.utilities.*
import org.session.libsession.utilities.SSKEnvironment.ProfileManagerProtocol
import org.session.libsession.utilities.recipients.Recipient
+import org.session.libsignal.utilities.getProperty
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
import org.thoughtcrime.securesms.avatar.AvatarSelection
import org.thoughtcrime.securesms.components.ProfilePictureView
@@ -107,7 +108,9 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
helpButton.setOnClickListener { showHelp() }
seedButton.setOnClickListener { showSeed() }
clearAllDataButton.setOnClickListener { clearAllData() }
- versionTextView.text = String.format(getString(R.string.version_s), "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})")
+
+ val gitCommitFirstSixChars = BuildConfig.GIT_HASH.take(6)
+ versionTextView.text = String.format(getString(R.string.version_s), "${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE} - $gitCommitFirstSixChars)")
}
}
diff --git a/app/src/main/res/values-fa/strings.xml b/app/src/main/res/values-fa/strings.xml
index 0aa6b5a88d..d9d26e6625 100644
--- a/app/src/main/res/values-fa/strings.xml
+++ b/app/src/main/res/values-fa/strings.xml
@@ -7,7 +7,7 @@
مسدود
ذخیره
یادداشت به خود
- نسخه
+ %s نسخه
پیام جدید