Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Debug Log Confirmation Dialog (DEV) (#2565)
Browse files Browse the repository at this point in the history
* added new confirmation alert

* linting
  • Loading branch information
axelherbstreith authored Mar 10, 2021
1 parent 5321f2d commit c9036df
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ class DebugLogFragment : Fragment(R.layout.bugreporting_debuglog_fragment), Auto

vm.events.observe2(this) {
when (it) {
DebugLogViewModel.Event.ShowLogDeletedConfirmation -> {
showLogDeletionConfirmation()
DebugLogViewModel.Event.ShowLogDeletionRequest -> {
showLogDeletionRequest()
}
DebugLogViewModel.Event.NavigateToPrivacyFragment -> {
doNavigate(
Expand Down Expand Up @@ -151,10 +151,14 @@ class DebugLogFragment : Fragment(R.layout.bugreporting_debuglog_fragment), Auto
)
}

private fun showLogDeletionConfirmation() {
private fun showLogDeletionRequest() {
MaterialAlertDialogBuilder(requireContext()).apply {
setTitle(R.string.debugging_debuglog_stop_confirmation_title)
setMessage(R.string.debugging_debuglog_stop_confirmation_message)
setPositiveButton(android.R.string.yes) { _, _ -> }
setPositiveButton(R.string.debugging_debuglog_stop_confirmation_confirmation_button) { _, _ ->
vm.stopAndDeleteDebugLog()
}
setNegativeButton(R.string.debugging_debuglog_stop_confirmation_discard_button) { _, _ -> /* dismiss */ }
}.show()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ class DebugLogViewModel @AssistedInject constructor(

fun onToggleRecording() = launchWithProgress {
if (debugLogger.isLogging.value) {
debugLogger.stop()
events.postValue(Event.ShowLogDeletedConfirmation)
events.postValue(Event.ShowLogDeletionRequest)
} else {
if (debugLogger.storageCheck.isLowStorage(forceCheck = true)) {
Timber.d("Low storage, not starting logger.")
Expand All @@ -86,6 +85,14 @@ class DebugLogViewModel @AssistedInject constructor(
}
}

fun stopAndDeleteDebugLog() {
launchWithProgress {
if (debugLogger.isLogging.value) {
debugLogger.stop()
}
}
}

fun onStoreLog() = launchWithProgress(finishProgressAction = false) {
Timber.d("storeLog()")
val snapshot = logSnapshotter.snapshot()
Expand Down Expand Up @@ -147,7 +154,7 @@ class DebugLogViewModel @AssistedInject constructor(
object NavigateToPrivacyFragment : Event()
object NavigateToUploadFragment : Event()
object NavigateToUploadHistory : Event()
object ShowLogDeletedConfirmation : Event()
object ShowLogDeletionRequest : Event()
object ShowLowStorageDialog : Event()
data class ShowLocalExportError(val error: Throwable) : Event()
data class Error(val error: Throwable) : Event()
Expand Down
11 changes: 9 additions & 2 deletions Corona-Warn-App/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -905,8 +905,16 @@
<string name="debugging_debuglog_status_not_recording">"Inaktiv"</string>
<!-- YTXT: Describtion for current logging status text if a debug log is not being recorded -->
<string name="debugging_debuglog_status_additional_infos">"Derzeitige Größe: %1$s (unkomprimiert)"</string>


<!-- YTXT: Dialog title if the log recording is stopped, and thus deleted. -->
<string name="debugging_debuglog_stop_confirmation_title">"Wollen Sie die Fehleranalyse wirklich stoppen?"</string>
<!-- YTXT: Dialog message if the log recording is stopped, and thus deleted. -->
<string name="debugging_debuglog_stop_confirmation_message">"Der Fehlerbericht wurde gelöscht. Wenn Sie eine lokale Kopie des Fehlerberichts gespeichert haben, wurde diese nicht gelöscht."</string>
<string name="debugging_debuglog_stop_confirmation_message">"Hierbei werden alle bereits aufgezeichneten Daten gelöscht. Wenn Sie eine lokale Kopie des Fehlerberichts gespeichert haben, wird diese nicht gelöscht."</string>
<!-- YTXT: Dialog confirmation button if the log recording is stopped, and thus deleted. -->
<string name="debugging_debuglog_stop_confirmation_confirmation_button">"Analyse stoppen"</string>
<!-- YTXT: Dialog discard button if the log recording is stopped, and thus deleted. -->
<string name="debugging_debuglog_stop_confirmation_discard_button">"Analyse fortführen"</string>
<!-- YTXT: Dialog message if there is not enough free storage to start a debug log -->
<string name="debugging_debuglog_start_low_storage_error">"Sie brauchen mindestens 200 MB Speicherplatz, um die Fehleranalyse zu starten. Bitte geben Sie Speicherplatz frei."</string>
<!-- XHED: Dialog title if a user has stored a debug log locally -->
Expand All @@ -915,7 +923,6 @@
<string name="debugging_debuglog_localexport_message">"Die Fehleranalyse wurde lokal gespeichert."</string>
<!-- YTXT: Dialog message if local export has failed -->
<string name="debugging_debuglog_localexport_error_message">"Das Speichern des Fehlerberichts ist fehlgeschlagen. Bitte überprüfen Sie, ob genügend Speicherplatz zur Verfügung steht."</string>

<!-- XHED: Title for debug legal screen -->
<string name="debugging_debuglog_legal_dialog_title">"Ausführliche Informationen zur Übersendung der Fehlerberichte"</string>
<!-- YTXT: Section Title for debug legal screen -->
Expand Down
8 changes: 7 additions & 1 deletion Corona-Warn-App/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,14 @@
<string name="debugging_debuglog_status_additional_infos">"Current size: %1$s (uncompressed)"</string>
<!-- XHED: Title for native sharing dialog -->
<string name="debugging_debuglog_sharing_dialog_title">"Share CWA Error Report"</string>
<!-- YTXT: Dialog title if the log recording is stopped, and thus deleted. -->
<string name="debugging_debuglog_stop_confirmation_title">"Wollen Sie die Fehleranalyse wirklich stoppen?"</string>
<!-- YTXT: Dialog message if the log recording is stopped, and thus deleted. -->
<string name="debugging_debuglog_stop_confirmation_message">"Der Fehlerbericht wurde gelöscht. Wenn Sie eine lokale Kopie des Fehlerberichts gespeichert haben, wurde diese nicht gelöscht."</string>
<string name="debugging_debuglog_stop_confirmation_message">"Hierbei werden alle bereits aufgezeichneten Daten gelöscht. Wenn Sie eine lokale Kopie des Fehlerberichts gespeichert haben, wird diese nicht gelöscht."</string>
<!-- YTXT: Dialog confirmation button if the log recording is stopped, and thus deleted. -->
<string name="debugging_debuglog_stop_confirmation_confirmation_button">"Analyse stoppen"</string>
<!-- YTXT: Dialog discard button if the log recording is stopped, and thus deleted. -->
<string name="debugging_debuglog_stop_confirmation_discard_button">"Analyse fortführen"</string>
<!-- YTXT: Dialog message if there is not enough free storage to start a debug log -->
<string name="debugging_debuglog_start_low_storage_error">Sie brauchen mindestens 200 MB Speicherplatz, um die Fehleranalyse zu starten. Bitte geben Sie Speicherplatz frei.</string>
<!-- XHED: Dialog title if a user has stored a debug log locally -->
Expand Down

0 comments on commit c9036df

Please sign in to comment.