Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SES1628 - Add git commit details to version info #1459

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)")
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<string name="ban">مسدود</string>
<string name="save">ذخیره</string>
<string name="note_to_self">یادداشت به خود</string>
<string name="version_s">نسخه</string>
<string name="version_s">%s نسخه</string>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how did you spot this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android wouldn't format the string with %s substitutions, so I looked through the translations until I found one that was missing the substitution token - after adding it substitution was allowed. No idea how the code in dev worked without it - but git history of this line says the last modifications was in 2022...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might just be a setting in Android Studio, or a feature of some version of Android Studio?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might just be a setting in Android Studio, or a feature of some version of Android Studio?

Ah, yeah - I did upgrade to Android Studio 2023.3.1 RC 2 the other day to play w/ the Gemini AI while it's in preview (i.e. free) - perhaps that picked it up while previous AS versions won't complain about it.

<!-- AbstractNotificationBuilder -->
<string name="AbstractNotificationBuilder_new_message">پیام جدید</string>
<!-- AlbumThumbnailView -->
Expand Down