Added Upload feature. Database will be uploaded to Hetzner Server. Database already encrypted with AES256. Database will be deleted from the app after uploading database.
This commit is contained in:
@ -10,6 +10,7 @@ import kotlinx.coroutines.*
|
||||
import org.json.JSONArray
|
||||
import android.util.Log
|
||||
|
||||
|
||||
var INTEGRATION_INDEX_POINTS: Int? = null
|
||||
|
||||
class HandlerOpeningScreen(private val activity: MainActivity) {
|
||||
@ -22,6 +23,7 @@ class HandlerOpeningScreen(private val activity: MainActivity) {
|
||||
private lateinit var buttonLoad: Button
|
||||
private lateinit var saveButton: Button
|
||||
private lateinit var editButton: Button
|
||||
private lateinit var uploadButton: Button
|
||||
|
||||
private val dynamicButtons = mutableListOf<Button>()
|
||||
private val questionnaireFiles = mutableMapOf<Button, String>()
|
||||
@ -40,6 +42,7 @@ class HandlerOpeningScreen(private val activity: MainActivity) {
|
||||
setupLoadButton()
|
||||
setupSaveButton()
|
||||
setupEditButton()
|
||||
setupUploadButton()
|
||||
|
||||
if (!editText.text.isNullOrBlank()) {
|
||||
buttonLoad.performClick()
|
||||
@ -54,6 +57,7 @@ class HandlerOpeningScreen(private val activity: MainActivity) {
|
||||
buttonLoad = activity.findViewById(R.id.loadButton)
|
||||
saveButton = activity.findViewById(R.id.saveButton)
|
||||
editButton = activity.findViewById(R.id.editButton)
|
||||
uploadButton = activity.findViewById(R.id.uploadButton)
|
||||
|
||||
val tag = editText.tag as? String ?: ""
|
||||
editText.hint = LanguageManager.getText(languageID, tag)
|
||||
@ -233,7 +237,7 @@ class HandlerOpeningScreen(private val activity: MainActivity) {
|
||||
val conditionMet = when (condition.operator) {
|
||||
"!=" -> answerValue != condition.value
|
||||
"==" -> answerValue == condition.value
|
||||
else -> true // fallback: zeige Fragebogen
|
||||
else -> true
|
||||
}
|
||||
|
||||
if (conditionMet) break
|
||||
@ -488,26 +492,6 @@ class HandlerOpeningScreen(private val activity: MainActivity) {
|
||||
return y
|
||||
}
|
||||
|
||||
private fun enableCompletedQuestionnaireButtons(clientCode: String) {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val completedEntries = MyApp.database.completedQuestionnaireDao().getAllForClient(clientCode)
|
||||
|
||||
val completedFiles = completedEntries
|
||||
.filter { it.isDone }
|
||||
.map { it.questionnaireId.lowercase() }
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
questionnaireFiles.forEach { (button, fileName) ->
|
||||
val isCompleted = completedFiles.any { fileName.lowercase().contains(it) }
|
||||
if (isCompleted) {
|
||||
button.isEnabled = true
|
||||
button.alpha = 1.0f
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupSaveButton() {
|
||||
saveButton.text = LanguageManager.getText(languageID, "save")
|
||||
saveButton.setOnClickListener {
|
||||
@ -560,4 +544,17 @@ class HandlerOpeningScreen(private val activity: MainActivity) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupUploadButton() {
|
||||
uploadButton.text = "Upload"
|
||||
uploadButton.setOnClickListener {
|
||||
val clientCode = editText.text.toString().trim()
|
||||
|
||||
GlobalValues.LAST_CLIENT_CODE = clientCode
|
||||
|
||||
Toast.makeText(activity, "Datenbank wird verschlüsselt...", Toast.LENGTH_SHORT).show()
|
||||
DatabaseUploader.uploadEncryptedDatabase(activity)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user