Skip to content

Commit d1752a6

Browse files
committed
feat: add About dialog with version and commit hash to note list menu
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
1 parent a646f6c commit d1752a6

3 files changed

Lines changed: 64 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
99

1010
### Added
1111

12+
- An **About** menu item in the note list account menu shows the version number and short git
13+
commit hash. Both values link to the project's GitHub releases and commit page respectively.
1214
- Renaming a note can optionally update the first Markdown heading to match the new file name.
1315
The rename dialog includes an **Update heading 1** checkbox that is enabled by default.
1416

‎app/build.gradle.kts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ android {
2727
?: releaseVersionCode
2828
versionName = releaseVersionName
2929
testInstrumentationRunner = "org.qownnotes.mobile.QOwnNotesTestRunner"
30+
31+
val gitCommitHash = providers.exec {
32+
commandLine("git", "rev-parse", "--short", "HEAD")
33+
}.standardOutput.asText.get().trim()
34+
buildConfigField("String", "GIT_COMMIT", "\"$gitCommitHash\"")
3035
}
3136

3237
signingConfigs {
@@ -61,7 +66,10 @@ android {
6166
}
6267
}
6368

64-
buildFeatures { compose = true }
69+
buildFeatures {
70+
compose = true
71+
buildConfig = true
72+
}
6573
compileOptions {
6674
isCoreLibraryDesugaringEnabled = true
6775
sourceCompatibility = JavaVersion.VERSION_17

‎app/src/main/kotlin/org/qownnotes/mobile/MainActivity.kt‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package org.qownnotes.mobile
33
import android.content.ClipData
44
import android.content.ClipboardManager
55
import android.content.Intent
6+
import android.net.Uri
7+
import android.os.Build
68
import android.os.Bundle
79
import android.util.TypedValue
810
import androidx.activity.ComponentActivity
@@ -124,6 +126,7 @@ import kotlin.math.roundToInt
124126
import kotlinx.coroutines.delay
125127
import kotlinx.coroutines.flow.flowOf
126128
import kotlinx.coroutines.launch
129+
import org.qownnotes.mobile.BuildConfig
127130
import org.qownnotes.mobile.core.Account
128131
import org.qownnotes.mobile.core.Note
129132
import org.qownnotes.mobile.core.NoteExcerpt
@@ -466,6 +469,7 @@ private fun NoteListScreen(
466469
var query by rememberSaveable { mutableStateOf("") }
467470
var showRemoveConfirmation by rememberSaveable(accountId) { mutableStateOf(false) }
468471
var showAccountChooser by rememberSaveable(accountId) { mutableStateOf(false) }
472+
var showAbout by rememberSaveable(accountId) { mutableStateOf(false) }
469473
var accountMenuOpen by rememberSaveable(accountId) { mutableStateOf(false) }
470474
var selectionMenuOpen by rememberSaveable(accountId) { mutableStateOf(false) }
471475
var selectedNoteIds by rememberSaveable(accountId) { mutableStateOf(emptyList<String>()) }
@@ -646,6 +650,15 @@ private fun NoteListScreen(
646650
},
647651
modifier = Modifier.testTag("remove-account")
648652
)
653+
Spacer(modifier = Modifier.height(4.dp))
654+
DropdownMenuItem(
655+
text = { Text("About") },
656+
onClick = {
657+
accountMenuOpen = false
658+
showAbout = true
659+
},
660+
modifier = Modifier.testTag("about")
661+
)
649662
}
650663
}
651664
}
@@ -891,6 +904,46 @@ private fun NoteListScreen(
891904
}
892905
)
893906
}
907+
if (showAbout) {
908+
val context = LocalContext.current
909+
val packageInfo = remember {
910+
context.packageManager.getPackageInfo(context.packageName, 0)
911+
}
912+
val repoUrl = "https://github.com/qownnotes/qownnotes-android"
913+
AlertDialog(
914+
onDismissRequest = { showAbout = false },
915+
title = { Text("About QOwnNotes") },
916+
text = {
917+
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
918+
Text(
919+
"Version: ${packageInfo.versionName}",
920+
modifier = Modifier.clickable {
921+
context.startActivity(
922+
Intent(
923+
Intent.ACTION_VIEW,
924+
Uri.parse("$repoUrl/releases/tag/v${packageInfo.versionName}")
925+
)
926+
)
927+
}
928+
)
929+
Text(
930+
"Commit: ${BuildConfig.GIT_COMMIT}",
931+
modifier = Modifier.clickable {
932+
context.startActivity(
933+
Intent(
934+
Intent.ACTION_VIEW,
935+
Uri.parse("$repoUrl/commit/${BuildConfig.GIT_COMMIT}")
936+
)
937+
)
938+
}
939+
)
940+
}
941+
},
942+
confirmButton = {
943+
TextButton(onClick = { showAbout = false }) { Text("Close") }
944+
}
945+
)
946+
}
894947
if (trashToRestore == null) {
895948
when (val state = trashState) {
896949
ArchiveLoadState.Idle -> Unit

0 commit comments

Comments
 (0)