Upload via GUI (8346 Dateien)

This commit is contained in:
2026-10-21 16:54:40 +00:00
parent bb8ffee10d
commit 7fb620e7ca
5 changed files with 348 additions and 201 deletions
+36 -47
View File
@@ -1,47 +1,36 @@
param() <#
.SYNOPSIS
$ErrorActionPreference = 'Stop' Baut die signierte Release-App: AAB für den Play Store und APK für direkte Installation.
$required = @( .DESCRIPTION
'DESKHUB_RELEASE_STORE_FILE', Fragt Keystore-Datei und Passwort ab (oder nimmt DESKHUB_RELEASE_* aus der Umgebung). Das Passwort bleibt nur in diesem Prozess.
'DESKHUB_RELEASE_STORE_PASSWORD', Ergebnis: artifacts\deskhub-release.aab (Play Store) und artifacts\deskhub-employee-release.apk. Vorher versionCode in build.gradle.kts erhöhen.
'DESKHUB_RELEASE_KEY_ALIAS', #>
'DESKHUB_RELEASE_KEY_PASSWORD' param([string]$StoreFile = (Join-Path $env:USERPROFILE 'deskhub-keys\deskhub-release.jks'), [string]$Alias = 'deskhub')
) $ErrorActionPreference = 'Stop'
$missing = @($required | Where-Object { [string]::IsNullOrWhiteSpace([Environment]::GetEnvironmentVariable($_)) }) if ([string]::IsNullOrWhiteSpace($env:DESKHUB_RELEASE_STORE_FILE)) { $env:DESKHUB_RELEASE_STORE_FILE = $StoreFile }
if ($missing.Count -gt 0) { if ([string]::IsNullOrWhiteSpace($env:DESKHUB_RELEASE_KEY_ALIAS)) { $env:DESKHUB_RELEASE_KEY_ALIAS = $Alias }
throw "Fehlende Umgebungsvariablen: $($missing -join ', ')" if (-not (Test-Path -LiteralPath $env:DESKHUB_RELEASE_STORE_FILE -PathType Leaf)) { throw "Keystore nicht gefunden: $($env:DESKHUB_RELEASE_STORE_FILE). Erst .\new-keystore.ps1 ausführen." }
} if ([string]::IsNullOrWhiteSpace($env:DESKHUB_RELEASE_STORE_PASSWORD)) {
$s = Read-Host 'Keystore-Passwort' -AsSecureString
$storeFile = [Environment]::GetEnvironmentVariable('DESKHUB_RELEASE_STORE_FILE') $env:DESKHUB_RELEASE_STORE_PASSWORD = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($s))
if (-not (Test-Path -LiteralPath $storeFile -PathType Leaf)) { }
throw "Keystore nicht gefunden: $storeFile" if ([string]::IsNullOrWhiteSpace($env:DESKHUB_RELEASE_KEY_PASSWORD)) { $env:DESKHUB_RELEASE_KEY_PASSWORD = $env:DESKHUB_RELEASE_STORE_PASSWORD }
} if (-not (Test-Path (Join-Path $PSScriptRoot 'google-services.json'))) { throw 'google-services.json fehlt im Ordner mobile (aus der Firebase-Konsole).' }
$projectRoot = $PSScriptRoot Push-Location $PSScriptRoot
$javaHome = [Environment]::GetEnvironmentVariable('JAVA_HOME') try {
if ([string]::IsNullOrWhiteSpace($javaHome)) { & "$PSScriptRoot\gradlew.bat" clean bundleRelease assembleRelease --no-daemon --console=plain
throw 'JAVA_HOME muss auf ein JDK 17 zeigen.' if ($LASTEXITCODE -ne 0) { throw "Release-Build fehlgeschlagen (Exitcode $LASTEXITCODE)." }
} New-Item -ItemType Directory -Path artifacts -Force | Out-Null
$aab = Get-ChildItem -Recurse -Filter '*.aab' build\outputs\bundle\release | Select-Object -First 1
Push-Location $projectRoot $apk = "$PSScriptRoot\build\outputs\apk\release\DeskHubMobile-release.apk"
try { if (-not $aab -or -not (Test-Path $apk)) { throw 'AAB oder APK wurde nicht erzeugt.' }
& "$projectRoot\gradlew.bat" clean assembleRelease --no-daemon --console=plain Copy-Item $aab.FullName artifacts\deskhub-release.aab -Force
if ($LASTEXITCODE -ne 0) { Copy-Item $apk artifacts\deskhub-employee-release.apk -Force
throw "Release-Build fehlgeschlagen (Exitcode $LASTEXITCODE)." Get-FileHash -Algorithm SHA256 artifacts\deskhub-release.aab, artifacts\deskhub-employee-release.apk
} } finally {
Pop-Location
$source = "$projectRoot\build\outputs\apk\release\DeskHubMobile-release.apk" Remove-Item Env:\DESKHUB_RELEASE_STORE_PASSWORD, Env:\DESKHUB_RELEASE_KEY_PASSWORD -ErrorAction SilentlyContinue
if (-not (Test-Path -LiteralPath $source -PathType Leaf)) { }
throw 'Signierte Release-APK wurde nicht erzeugt.'
}
$artifactDirectory = "$projectRoot\artifacts"
New-Item -ItemType Directory -Path $artifactDirectory -Force | Out-Null
$target = "$artifactDirectory\deskhub-employee-release.apk"
Copy-Item -LiteralPath $source -Destination $target -Force
Get-FileHash -Algorithm SHA256 -LiteralPath $target
} finally {
Pop-Location
}
+157 -154
View File
@@ -1,154 +1,157 @@
plugins { plugins {
id("com.android.application") version "8.4.2" id("com.android.application") version "8.4.2"
id("org.jetbrains.kotlin.android") version "1.9.24" id("org.jetbrains.kotlin.android") version "1.9.24"
} id("com.google.gms.google-services") version "4.4.4"
}
extra["author"] = "M_Viper"
extra["productName"] = "deskhub" extra["author"] = "M_Viper"
extra["productName"] = "deskhub"
val releaseStoreFile = providers.environmentVariable("DESKHUB_RELEASE_STORE_FILE").orNull
val releaseStorePassword = providers.environmentVariable("DESKHUB_RELEASE_STORE_PASSWORD").orNull val releaseStoreFile = providers.environmentVariable("DESKHUB_RELEASE_STORE_FILE").orNull
val releaseKeyAlias = providers.environmentVariable("DESKHUB_RELEASE_KEY_ALIAS").orNull val releaseStorePassword = providers.environmentVariable("DESKHUB_RELEASE_STORE_PASSWORD").orNull
val releaseKeyPassword = providers.environmentVariable("DESKHUB_RELEASE_KEY_PASSWORD").orNull val releaseKeyAlias = providers.environmentVariable("DESKHUB_RELEASE_KEY_ALIAS").orNull
val releaseSigningConfigured = listOf( val releaseKeyPassword = providers.environmentVariable("DESKHUB_RELEASE_KEY_PASSWORD").orNull
releaseStoreFile, val releaseSigningConfigured = listOf(
releaseStorePassword, releaseStoreFile,
releaseKeyAlias, releaseStorePassword,
releaseKeyPassword, releaseKeyAlias,
).all { !it.isNullOrBlank() } releaseKeyPassword,
).all { !it.isNullOrBlank() }
android {
namespace = "de.deskhub.staff" android {
compileSdk = 34 namespace = "de.deskhub.staff"
compileSdk = 35
defaultConfig {
applicationId = "de.deskhub.staff" defaultConfig {
minSdk = 26 applicationId = "de.deskhub.staff"
targetSdk = 34 minSdk = 26
// WICHTIG: Bei jedem neuen Debug-Build erhöhen. Android erkennt eine APK mit targetSdk = 35
// unverändertem versionCode (+ gleicher Signatur) auf manchen Geräten nicht // WICHTIG: Bei jedem neuen Debug-Build erhöhen. Android erkennt eine APK mit
// zuverlässig als Update, wodurch eine Neuinstallation still fehlschlagen kann. // unverändertem versionCode (+ gleicher Signatur) auf manchen Geräten nicht
versionCode = 19 // zuverlässig als Update, wodurch eine Neuinstallation still fehlschlagen kann.
versionName = "2.1.0" versionCode = 26
versionName = "2.5.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
} testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildFeatures {
compose = true buildFeatures {
buildConfig = true compose = true
} buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.14" composeOptions {
} kotlinCompilerExtensionVersion = "1.5.14"
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17 compileOptions {
targetCompatibility = JavaVersion.VERSION_17 sourceCompatibility = JavaVersion.VERSION_17
} targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17" kotlinOptions {
} jvmTarget = "17"
}
signingConfigs {
if (releaseSigningConfigured) { signingConfigs {
create("release") { if (releaseSigningConfigured) {
storeFile = file(requireNotNull(releaseStoreFile)) create("release") {
storePassword = requireNotNull(releaseStorePassword) storeFile = file(requireNotNull(releaseStoreFile))
keyAlias = requireNotNull(releaseKeyAlias) storePassword = requireNotNull(releaseStorePassword)
keyPassword = requireNotNull(releaseKeyPassword) keyAlias = requireNotNull(releaseKeyAlias)
} keyPassword = requireNotNull(releaseKeyPassword)
} }
} }
}
buildTypes {
release { buildTypes {
isMinifyEnabled = true release {
if (releaseSigningConfigured) { isMinifyEnabled = true
signingConfig = signingConfigs.getByName("release") if (releaseSigningConfigured) {
} signingConfig = signingConfigs.getByName("release")
proguardFiles( }
getDefaultProguardFile("proguard-android-optimize.txt"), proguardFiles(
"proguard-rules.pro", getDefaultProguardFile("proguard-android-optimize.txt"),
) "proguard-rules.pro",
} )
} }
}
testOptions {
unitTests.isIncludeAndroidResources = true testOptions {
} unitTests.isIncludeAndroidResources = true
}
packaging {
resources.excludes += "/META-INF/{AL2.0,LGPL2.1}" packaging {
} resources.excludes += "/META-INF/{AL2.0,LGPL2.1}"
} }
}
dependencies {
val composeBom = platform("androidx.compose:compose-bom:2024.09.00") dependencies {
implementation(composeBom) val composeBom = platform("androidx.compose:compose-bom:2024.09.00")
androidTestImplementation(composeBom) implementation(composeBom)
androidTestImplementation(composeBom)
implementation("androidx.activity:activity-compose:1.9.2")
implementation("androidx.compose.ui:ui") implementation("androidx.activity:activity-compose:1.9.2")
implementation("androidx.compose.ui:ui-tooling-preview") implementation("androidx.compose.ui:ui")
implementation("androidx.compose.material3:material3") implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material:material-icons-extended") implementation("androidx.compose.material3:material3")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.3") implementation("androidx.compose.material:material-icons-extended")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.3") implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.3")
implementation("androidx.navigation:navigation-compose:2.7.7") implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.8.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0") implementation("androidx.navigation:navigation-compose:2.7.7")
implementation("com.squareup.okhttp3:okhttp:4.12.0") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0")
implementation("com.google.code.gson:gson:2.11.0") implementation("com.squareup.okhttp3:okhttp:4.12.0")
implementation("com.google.code.gson:gson:2.11.0")
testImplementation("junit:junit:4.13.2") // Push-Benachrichtigungen (Firebase Cloud Messaging)
testImplementation("org.robolectric:robolectric:4.13") implementation("com.google.firebase:firebase-messaging:25.0.1")
testImplementation(composeBom)
testImplementation("androidx.compose.ui:ui-test-junit4") testImplementation("junit:junit:4.13.2")
testImplementation("androidx.test.ext:junit:1.2.1") testImplementation("org.robolectric:robolectric:4.13")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") testImplementation(composeBom)
androidTestImplementation("androidx.test.ext:junit:1.2.1") testImplementation("androidx.compose.ui:ui-test-junit4")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1") testImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.compose.ui:ui-test-junit4") testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0")
debugImplementation("androidx.compose.ui:ui-tooling") androidTestImplementation("androidx.test.ext:junit:1.2.1")
debugImplementation("androidx.compose.ui:ui-test-manifest") androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
} androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
val verifyBranding by tasks.registering { debugImplementation("androidx.compose.ui:ui-test-manifest")
doLast { }
val strings = layout.projectDirectory
.file("src/main/res/values/strings.xml") val verifyBranding by tasks.registering {
.asFile doLast {
.readText() val strings = layout.projectDirectory
check("<string name=\"app_name\">deskhub</string>" in strings) { .file("src/main/res/values/strings.xml")
"app_name muss exakt deskhub lauten." .asFile
} .readText()
val readme = layout.projectDirectory.file("README.md").asFile.readText() check("<string name=\"app_name\">deskhub</string>" in strings) {
check("Ersteller: M_Viper" in readme) { "app_name muss exakt deskhub lauten."
"README.md muss das Feld Ersteller: M_Viper enthalten." }
} val readme = layout.projectDirectory.file("README.md").asFile.readText()
check(project.extra["author"] == "M_Viper") { check("Ersteller: M_Viper" in readme) {
"Gradle-Projektmetadatum author muss M_Viper sein." "README.md muss das Feld Ersteller: M_Viper enthalten."
} }
} check(project.extra["author"] == "M_Viper") {
} "Gradle-Projektmetadatum author muss M_Viper sein."
}
val exportDebugApk by tasks.registering { }
doLast { }
val source = layout.buildDirectory.file("outputs/apk/debug/DeskHubMobile-debug.apk").get().asFile
check(source.isFile) { "Debug-APK wurde nicht erzeugt: $source" } val exportDebugApk by tasks.registering {
val target = layout.projectDirectory.file("artifacts/deskhub-employee-debug.apk").asFile doLast {
target.parentFile.mkdirs() val source = layout.buildDirectory.file("outputs/apk/debug/DeskHubMobile-debug.apk").get().asFile
source.copyTo(target, overwrite = true) check(source.isFile) { "Debug-APK wurde nicht erzeugt: $source" }
} val target = layout.projectDirectory.file("artifacts/deskhub-employee-debug.apk").asFile
} target.parentFile.mkdirs()
source.copyTo(target, overwrite = true)
tasks.configureEach { }
if (name == "preBuild") { }
dependsOn(verifyBranding)
} tasks.configureEach {
if (name == "assembleDebug") { if (name == "preBuild") {
finalizedBy(exportDebugApk) dependsOn(verifyBranding)
} }
} if (name == "assembleDebug") {
finalizedBy(exportDebugApk)
}
}
+29
View File
@@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "436755419487",
"project_id": "deskhub-96d3f",
"storage_bucket": "deskhub-96d3f.firebasestorage.app"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:436755419487:android:8bad822266b61db37466ea",
"android_client_info": {
"package_name": "de.deskhub.staff"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyBN6ud1flyG_aFJdv25fsFQpHpxpESiDlk"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
+1
View File
@@ -1,3 +1,4 @@
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true android.useAndroidX=true
kotlin.code.style=official kotlin.code.style=official
android.suppressUnsupportedCompileSdk=35
@@ -0,0 +1,125 @@
package de.deskhub.staff.push
import android.app.Application
import android.app.NotificationManager
import android.content.Context
import androidx.test.core.app.ApplicationProvider
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
/** Benachrichtigungen der Push-Nachrichten (auf der JVM mit Robolectric). */
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [34])
class DeskHubPushTest {
private val context: Application get() = ApplicationProvider.getApplicationContext()
private fun grantPermission() = shadowOf(context).grantPermissions(android.Manifest.permission.POST_NOTIFICATIONS)
private fun manager() = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
@Test
fun createsHighImportanceChannel() {
DeskHubPush.ensureChannel(context)
val channel = manager().getNotificationChannel(DeskHubPush.CHANNEL_TICKETS)
assertNotNull(channel)
assertEquals(NotificationManager.IMPORTANCE_HIGH, channel.importance)
}
@Test
fun showsNotificationWithTitleTextAndOpensTicket() {
grantPermission()
val shown = DeskHubPush.show(context, mapOf("type" to "ticket_new", "ticket" to "T-123", "title" to "Neues Ticket", "body" to "#T-123"))
assertTrue(shown)
val posted = shadowOf(manager()).allNotifications
assertEquals(1, posted.size)
val n = posted[0]
assertEquals("Neues Ticket", n.extras.getCharSequence("android.title").toString())
assertEquals("#T-123", n.extras.getCharSequence("android.text").toString())
// Tipp öffnet die App mit der Ticketnummer
val intent = shadowOf(n.contentIntent).savedIntent
assertEquals("T-123", intent.getStringExtra(DeskHubPush.EXTRA_TICKET))
}
@Test
fun sameTicketReplacesEarlierNotification() {
grantPermission()
val data = mapOf("type" to "ticket_reply", "ticket" to "T-7", "title" to "Neue Antwort", "body" to "#T-7")
DeskHubPush.show(context, data)
DeskHubPush.show(context, data)
assertEquals(1, shadowOf(manager()).allNotifications.size)
DeskHubPush.show(context, data + ("ticket" to "T-8"))
assertEquals(2, shadowOf(manager()).allNotifications.size)
}
@Test
fun ignoresUnknownOrEmptyMessages() {
grantPermission()
assertFalse(DeskHubPush.show(context, mapOf("type" to "irgendwas", "title" to "x")))
assertFalse(DeskHubPush.show(context, mapOf("type" to "ticket_new", "title" to " ")))
assertFalse(DeskHubPush.show(context, emptyMap()))
assertEquals(0, shadowOf(manager()).allNotifications.size)
}
@Test
fun showsNothingWithoutPermission() {
shadowOf(context).denyPermissions(android.Manifest.permission.POST_NOTIFICATIONS)
assertFalse(DeskHubPush.canNotify(context))
assertFalse(DeskHubPush.show(context, mapOf("type" to "ticket_new", "ticket" to "T-1", "title" to "Neues Ticket")))
assertEquals(0, shadowOf(manager()).allNotifications.size)
}
@Test
fun customerReplyHasQuickReplyActionOthersDoNot() {
grantPermission()
DeskHubPush.show(context, mapOf("type" to "ticket_reply", "ticket" to "T-5", "title" to "Neue Antwort", "body" to "#T-5"))
DeskHubPush.show(context, mapOf("type" to "ticket_new", "ticket" to "T-6", "title" to "Neues Ticket", "body" to "#T-6"))
val all = shadowOf(manager()).allNotifications
val reply = all.first { it.extras.getCharSequence("android.text").toString() == "#T-5" }
val other = all.first { it.extras.getCharSequence("android.text").toString() == "#T-6" }
assertEquals(1, reply.actions.size)
assertEquals("Antworten", reply.actions[0].title.toString())
assertNotNull(reply.actions[0].remoteInputs)
assertEquals(PushReplyReceiver.KEY_REPLY, reply.actions[0].remoteInputs[0].resultKey)
assertTrue(other.actions == null || other.actions.isEmpty())
}
@Test
fun newEventTypesAreShown() {
grantPermission()
assertTrue(DeskHubPush.show(context, mapOf("type" to "ticket_sla", "ticket" to "T-9", "title" to "SLA überschritten", "body" to "#T-9")))
assertTrue(DeskHubPush.show(context, mapOf("type" to "ticket_mention", "ticket" to "T-9", "title" to "Erwähnung", "body" to "#T-9")))
assertEquals(2, shadowOf(manager()).allNotifications.size)
}
@Test
fun brandNameShowsNextToAppName() {
grantPermission()
DeskHubPush.show(context, mapOf("type" to "ticket_new", "ticket" to "T-20", "title" to "Neues Ticket", "body" to "#T-20", "brand" to "Windel Support"))
DeskHubPush.show(context, mapOf("type" to "ticket_new", "ticket" to "T-21", "title" to "Neues Ticket", "body" to "#T-21"))
val all = shadowOf(manager()).allNotifications
val withBrand = all.first { it.extras.getCharSequence("android.text").toString() == "#T-20" }
val without = all.first { it.extras.getCharSequence("android.text").toString() == "#T-21" }
assertEquals("Windel Support", withBrand.extras.getCharSequence("android.subText").toString())
assertTrue(without.extras.getCharSequence("android.subText") == null)
}
@Test
fun quickReplyTextIsEscapedForHtml() {
assertEquals("a &lt;b&gt; &amp; c<br>d", PushReplyReceiver.toHtml("a <b> & c\nd"))
}
@Test
fun notificationIdsDifferPerTicketAndType() {
assertTrue(DeskHubPush.notificationId("ticket_new", "T-1") != DeskHubPush.notificationId("ticket_new", "T-2"))
assertTrue(DeskHubPush.notificationId("ticket_new", "T-1") != DeskHubPush.notificationId("ticket_reply", "T-1"))
assertEquals(DeskHubPush.notificationId("ticket_new", "T-1"), DeskHubPush.notificationId("ticket_new", "T-1"))
assertTrue(DeskHubPush.notificationId("ticket_new", "T-1") >= 0)
}
}