implemented donwload upload handling with username

This commit is contained in:
oxidiert
2025-09-23 16:49:59 +02:00
parent 5f5c766133
commit bf33501b69
6 changed files with 189 additions and 53 deletions

View File

@ -434,17 +434,25 @@ class HandlerOpeningScreen(private val activity: MainActivity) {
private fun setupUploadButton() {
uploadButton.text = t("upload")
uploadButton.setOnClickListener {
// Token aus dem Login (MainActivity speichert es in TokenStore)
val token = TokenStore.getToken(activity)
if (token.isNullOrBlank()) {
Toast.makeText(
activity,
t("login_required") ?: "Bitte zuerst einloggen",
Toast.LENGTH_LONG
).show()
return@setOnClickListener
}
// wie gewohnt: Client-Code merken, dann direkt hochladen
GlobalValues.LAST_CLIENT_CODE = editText.text.toString().trim()
promptCredentials(
title = t("login_required") ?: "Login erforderlich",
onOk = { user, pass ->
// Login -> Upload
DatabaseUploader.uploadDatabaseWithLogin(activity, user, pass)
}
)
DatabaseUploader.uploadDatabaseWithToken(activity, token)
// Hinweis: Nach erfolgreichem Upload schließt sich die App (exitProcess(0)) wie bisher.
}
}
private fun setupDownloadButton() {
downloadButton.text = t("download")
downloadButton.setOnClickListener {