Skip to content

Commit 800159d

Browse files
committed
Integrate KtorMonitor in desktop app menu
1 parent c8fc922 commit 800159d

File tree

14 files changed

+101
-10
lines changed

14 files changed

+101
-10
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: ©️ Generate credits for ':tasks-app-desktop'
4747
id: check_desktop_app_credits
4848
run: |
49-
./gradlew --no-daemon :tasks-app-desktop:exportLibraryDefinitions
49+
./gradlew --no-daemon :tasks-app-desktop:exportLibraryDefinitions -Pci=true
5050
stale_credits=$(git diff tasks-app-desktop/src/main/resources/licenses_desktop.json)
5151
if [ -n "${stale_credits}" ]; then
5252
{
@@ -79,7 +79,7 @@ jobs:
7979
- name: ©️ Generate credits for ':tasks-app-android'
8080
id: check_android_app_credits
8181
run: |
82-
./gradlew --no-daemon :tasks-app-android:exportLibraryDefinitions
82+
./gradlew --no-daemon :tasks-app-android:exportLibraryDefinitions -Pci=true
8383
stale_credits=$(git diff tasks-app-android/src/main/assets/licenses_android.json)
8484
if [ -n "${stale_credits}" ]; then
8585
{

_ci/generate_github_comment_stale_credits.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ set -euo pipefail
88
case "$1" in
99
":tasks-app-android")
1010
diff=$(git diff tasks-app-android/src/main/assets/licenses_android.json | awk '{printf "%s\\n", $0}')
11-
update_cmd="./gradlew :tasks-app-android:exportLibraryDefinitions"
11+
update_cmd="./gradlew :tasks-app-android:exportLibraryDefinitions -Pci=true"
1212
;;
1313
":tasks-app-desktop")
1414
diff=$(git diff tasks-app-desktop/src/main/resources/licenses_desktop.json | awk '{printf "%s\\n", $0}')
15-
update_cmd="./gradlew :tasks-app-desktop:exportLibraryDefinitions"
15+
update_cmd="./gradlew :tasks-app-desktop:exportLibraryDefinitions -Pci=true"
1616
;;
1717
*)
1818
echo "Unsupported app module"

_ci/update_credits_json.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ origin=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) || exit
77
cd "${origin}/.."
88

99
find . -name "licenses*.json" -delete
10-
./gradlew "exportLibraryDefinitions"
10+
./gradlew "exportLibraryDefinitions" -Pci=true

tasks-app-android/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ android {
105105
manifestPlaceholders["crashlyticsEnabled"] = true
106106

107107
// we allow dev signing config in release build when not in CI to allow release builds on dev machine
108-
val ciBuild = (findProperty("ci") as? String)?.toBoolean() ?: false
108+
val ciBuild = (findProperty("ci") as? String).toBoolean()
109109
signingConfig = if (signingConfigs.getByName("store").storeFile == null && !ciBuild) {
110110
signingConfigs.getByName("dev")
111111
} else {
@@ -175,7 +175,7 @@ dependencies {
175175

176176
aboutLibraries {
177177
// - If the automatic registered android tasks are disabled, a similar thing can be achieved manually
178-
// - `./gradlew :tasks-app-android:exportLibraryDefinitions`
178+
// - `./gradlew :tasks-app-android:exportLibraryDefinitions -Pci=true`
179179
// - the resulting file can for example be added as part of the SCM
180180
collect {
181181
configPath = file("$rootDir/license_config")

tasks-app-android/src/main/AndroidManifest.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!--
3-
Copyright (c) 2024 Olivier Patry
3+
Copyright (c) 2025 Olivier Patry
44
55
Permission is hereby granted, free of charge, to any person obtaining
66
a copy of this software and associated documentation files (the "Software"),
@@ -21,10 +21,13 @@
2121
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2222
-->
2323

24-
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
24+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
25+
xmlns:tools="http://schemas.android.com/tools">
2526

2627
<uses-permission android:name="android.permission.INTERNET" />
2728

29+
<uses-sdk tools:overrideLibrary="ro.cosminmihu.ktor.monitor" />
30+
2831
<application
2932
android:allowBackup="true"
3033
android:icon="@mipmap/ic_launcher"

tasks-app-android/src/main/assets/licenses_android.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2999,6 +2999,20 @@
29992999
"organization": {
30003000
"name": "QOS.ch"
30013001
}
3002+
},
3003+
{
3004+
"uniqueId": "ro.cosminmihu.ktor:ktor-monitor-logging-no-op",
3005+
"developers": [
3006+
{
3007+
"name": "Cosmin Mihu"
3008+
}
3009+
],
3010+
"artifactVersion": "1.7.1",
3011+
"description": "Powerful tools to log Ktor Client requests and responses, making it easier to debug and analyze network communication.",
3012+
"name": "Ktor Monitor",
3013+
"licenses": [
3014+
"Apache-2.0"
3015+
]
30023016
}
30033017
],
30043018
"licenses": {

tasks-app-desktop/build.gradle.kts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ plugins {
3838
val appName = "Taskfolio"
3939
val appVersion = libs.versions.tasksApp.name.get()
4040
val appVersionCode = System.getenv("CI_BUILD_NUMBER")?.toIntOrNull() ?: 1
41+
val ciBuild = (findProperty("ci") as? String).toBoolean()
4142

4243
compose.resources {
4344
publicResClass = false
@@ -69,6 +70,12 @@ kotlin {
6970
implementation(projects.google.tasks)
7071
implementation(projects.tasksAppShared)
7172

73+
if (ciBuild) {
74+
implementation(libs.ktor.monitor.logging.no.op)
75+
} else {
76+
implementation(libs.ktor.monitor.logging)
77+
}
78+
7279
testImplementation(kotlin("test"))
7380
testImplementation(libs.koin.test)
7481
testImplementation(libs.ktor.client.core) {
@@ -95,6 +102,7 @@ compose.desktop {
95102
"-Dapp.name=$appName",
96103
"-Dapp.version=$appVersion",
97104
"-Dapp.version.full=${appVersion}.${appVersionCode}",
105+
"-Dbuild.release=$ciBuild"
98106
)
99107

100108
nativeDistributions {
@@ -161,7 +169,7 @@ compose.desktop {
161169

162170
aboutLibraries {
163171
// - If the automatic registered android tasks are disabled, a similar thing can be achieved manually
164-
// - `./gradlew :tasks-app-desktop:exportLibraryDefinitions`
172+
// - `./gradlew :tasks-app-desktop:exportLibraryDefinitions -Pci=true`
165173
// - the resulting file can for example be added as part of the SCM
166174
collect {
167175
configPath = file("$rootDir/license_config")

tasks-app-desktop/src/main/composeResources/values-fr/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@
2424
<string name="app_menu_edit">Édition</string>
2525
<string name="app_menu_edit_new_task_list">Nouvelle liste de tâches…</string>
2626
<string name="app_menu_edit_new_task">Nouvelle tâche…</string>
27+
<string name="app_menu_tools">Outils</string>
28+
<string name="app_menu_tools_show_network_logs">Afficher les logs réseau</string>
2729
</resources>

tasks-app-desktop/src/main/composeResources/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@
2424
<string name="app_menu_edit">Edit</string>
2525
<string name="app_menu_edit_new_task_list">New task list…</string>
2626
<string name="app_menu_edit_new_task">New task…</string>
27+
<string name="app_menu_tools">Tools</string>
28+
<string name="app_menu_tools_show_network_logs">Show network logs</string>
2729
</resources>

tasks-app-desktop/src/main/kotlin/mainApp.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import net.opatry.tasks.app.ui.screen.AuthorizationScreen
6060
import net.opatry.tasks.app.ui.theme.TaskfolioTheme
6161
import org.koin.compose.KoinApplication
6262
import org.koin.compose.viewmodel.koinViewModel
63+
import ro.cosminmihu.ktor.monitor.KtorMonitorWindow
6364
import java.awt.Dimension
6465
import java.awt.Toolkit
6566
import javax.swing.UIManager
@@ -75,6 +76,7 @@ fun main() {
7576
val appName = System.getProperty("app.name") ?: "Taskfolio"
7677
val fullVersion = System.getProperty("app.version.full") ?: "0.0.0.0"
7778
val versionLabel = System.getProperty("app.version")?.let { " v$it" } ?: ""
79+
val releaseBuild = System.getProperty("build.release").toBoolean()
7880
application {
7981
val screenSize by remember {
8082
mutableStateOf(Toolkit.getDefaultToolkit().screenSize)
@@ -90,6 +92,13 @@ fun main() {
9092
var showNewTaskListDialog by remember { mutableStateOf(false) }
9193
var showNewTaskEditorSheet by remember { mutableStateOf(false) }
9294
var selectedTaskList by remember { mutableStateOf<TaskListUIModel?>(null) }
95+
var showKtorMonitor by remember { mutableStateOf(false) }
96+
if (!releaseBuild) {
97+
KtorMonitorWindow(
98+
show = showKtorMonitor,
99+
onCloseRequest = { showKtorMonitor = false }
100+
)
101+
}
93102

94103
Window(
95104
onCloseRequest = ::exitApplication,
@@ -117,9 +126,11 @@ fun main() {
117126
}
118127

119128
AppMenuBar(
129+
showDevelopmentTools = !releaseBuild,
120130
onNewTaskListClick = { showNewTaskListDialog = true },
121131
canCreateTask = selectedTaskList != null,
122132
onNewTaskClick = { showNewTaskEditorSheet = true },
133+
onNetworkLogClick = { showKtorMonitor = true },
123134
)
124135

125136
KoinApplication(application = {

0 commit comments

Comments
 (0)