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

Commit

Permalink
Cannot delete tests older than 21 days - DE: Tests die älter als 21 T…
Browse files Browse the repository at this point in the history
…age sind, können nicht gelöscht werden (EXPOSUREAPP-2398) (#1481)

* Added new card to show redeemed tests on the home screen

Signed-off-by: Kolya Opahle <[email protected]>

* Fixed linting and unit tests

Signed-off-by: Kolya Opahle <[email protected]>

Co-authored-by: harambasicluka <[email protected]>
  • Loading branch information
kolyaopahle and harambasicluka authored Oct 26, 2020
1 parent e857ddd commit 21b7d77
Show file tree
Hide file tree
Showing 10 changed files with 273 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package de.rki.coronawarnapp.ui.main.home

import android.app.AlertDialog
import android.os.Bundle
import android.view.View
import android.view.accessibility.AccessibilityEvent
import androidx.fragment.app.Fragment
import de.rki.coronawarnapp.R
import de.rki.coronawarnapp.databinding.FragmentHomeBinding
import de.rki.coronawarnapp.util.DialogHelper
import de.rki.coronawarnapp.util.ExternalActionHelper
import de.rki.coronawarnapp.util.di.AutoInject
import de.rki.coronawarnapp.util.errors.RecoveryByResetDialogFactory
Expand Down Expand Up @@ -82,6 +84,9 @@ class HomeFragment : Fragment(R.layout.fragment_home), AutoInject {
onDismiss = { vm.errorResetDialogDismissed() }
)
}
HomeFragmentEvents.ShowDeleteTestDialog -> {
showRemoveTestDialog()
}
}
}
}
Expand All @@ -93,6 +98,23 @@ class HomeFragment : Fragment(R.layout.fragment_home), AutoInject {
binding.mainScrollview.sendAccessibilityEvent(AccessibilityEvent.TYPE_ANNOUNCEMENT)
}

private fun showRemoveTestDialog() {
val removeTestDialog = DialogHelper.DialogInstance(
requireActivity(),
R.string.submission_test_result_dialog_remove_test_title,
R.string.submission_test_result_dialog_remove_test_message,
R.string.submission_test_result_dialog_remove_test_button_positive,
R.string.submission_test_result_dialog_remove_test_button_negative,
positiveButtonFunction = {
vm.deregisterWarningAccepted()
}
)
DialogHelper.showDialog(removeTestDialog).apply {
getButton(AlertDialog.BUTTON_POSITIVE)
.setTextColor(context.getColor(R.color.colorTextSemanticRed))
}
}

private fun setupRiskCard() {
binding.mainRisk.apply {
riskCard.setOnClickListener {
Expand Down Expand Up @@ -133,6 +155,12 @@ class HomeFragment : Fragment(R.layout.fragment_home), AutoInject {
submissionStatusCardPositive.setOnClickListener { toSubmissionResult() }
submissionStatusCardPositiveButton.setOnClickListener { toSubmissionResult() }
}

mainTestFailed.apply {
setOnClickListener {
vm.removeTestPushed()
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ sealed class HomeFragmentEvents {
) : HomeFragmentEvents()

object ShowErrorResetDialog : HomeFragmentEvents()

object ShowDeleteTestDialog : HomeFragmentEvents()
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.asLiveData
import com.squareup.inject.assisted.AssistedInject
import de.rki.coronawarnapp.risk.TimeVariables
import de.rki.coronawarnapp.service.submission.SubmissionService
import de.rki.coronawarnapp.storage.LocalData
import de.rki.coronawarnapp.storage.SubmissionRepository
import de.rki.coronawarnapp.storage.TracingRepository
Expand Down Expand Up @@ -94,6 +95,18 @@ class HomeFragmentViewModel @AssistedInject constructor(
tracingRepository.refreshDiagnosisKeys()
}

fun removeTestPushed() {
popupEvents.postValue(HomeFragmentEvents.ShowDeleteTestDialog)
}

fun deregisterWarningAccepted() {
SubmissionService.deleteTestGUID()
SubmissionService.deleteRegistrationToken()
LocalData.isAllowedToSubmitDiagnosisKeys(false)
LocalData.initialTestResultReceivedTimestamp(0L)
SubmissionRepository.refreshDeviceUIState()
}

@AssistedInject.Factory
interface Factory : SimpleCWAViewModelFactory<HomeFragmentViewModel>
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,23 @@ data class SubmissionCardState(

fun isUnregisteredCardVisible(): Boolean = !isDeviceRegistered

fun isFetchingCardVisible(): Boolean = isDeviceRegistered &&
(uiStateState == ApiRequestState.STARTED || uiStateState == ApiRequestState.FAILED)
fun isFetchingCardVisible(): Boolean =
isDeviceRegistered && (uiStateState == ApiRequestState.STARTED || uiStateState == ApiRequestState.FAILED)

fun isPositiveSubmissionCardVisible(): Boolean = deviceUiState == PAIRED_POSITIVE ||
deviceUiState == PAIRED_POSITIVE_TELETAN
fun isFailedCardVisible(): Boolean =
isDeviceRegistered && uiStateState == ApiRequestState.SUCCESS && deviceUiState == PAIRED_REDEEMED

fun isSubmissionDoneCardVisible(): Boolean = deviceUiState == SUBMITTED_FINAL
fun isPositiveSubmissionCardVisible(): Boolean = uiStateState == ApiRequestState.SUCCESS &&
(deviceUiState == PAIRED_POSITIVE ||
deviceUiState == PAIRED_POSITIVE_TELETAN)

fun isContentCardVisible(): Boolean = deviceUiState == PAIRED_ERROR ||
deviceUiState == PAIRED_NEGATIVE ||
deviceUiState == PAIRED_NO_RESULT ||
deviceUiState == PAIRED_REDEEMED
fun isSubmissionDoneCardVisible(): Boolean =
uiStateState == ApiRequestState.SUCCESS && deviceUiState == SUBMITTED_FINAL

fun isContentCardVisible(): Boolean =
uiStateState == ApiRequestState.SUCCESS && (deviceUiState == PAIRED_ERROR ||
deviceUiState == PAIRED_NEGATIVE ||
deviceUiState == PAIRED_NO_RESULT)

fun getContentCardTitleText(c: Context): String = when (deviceUiState) {
PAIRED_ERROR, PAIRED_REDEEMED, PAIRED_NEGATIVE -> R.string.submission_status_card_title_available
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package de.rki.coronawarnapp.ui.view

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import de.rki.coronawarnapp.databinding.ViewSubmissionStatusCardFetchFailedBinding

class TestResultCardFetchFailed(context: Context, attrs: AttributeSet) :
ConstraintLayout(context, attrs) {
private val inflater = LayoutInflater.from(context)
private val binding = ViewSubmissionStatusCardFetchFailedBinding.inflate(inflater, this)

override fun setOnClickListener(l: OnClickListener?) {
super.setOnClickListener(l)
binding.submissionStatusCardFetchFailedButton.setOnClickListener(l)
}
}
13 changes: 12 additions & 1 deletion Corona-Warn-App/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@
app:layout_constraintStart_toStartOf="@+id/guideline_card_start"
app:layout_constraintTop_toBottomOf="@id/main_test_result" />

<de.rki.coronawarnapp.ui.view.TestResultCardFetchFailed
android:id="@+id/main_test_failed"
style="@style/cardNoPadding"
gone="@{submissionCard == null || !submissionCard.isFailedCardVisible()}"
android:layout_width="@dimen/match_constraint"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_small"
app:layout_constraintEnd_toStartOf="@+id/guideline_card_end"
app:layout_constraintStart_toStartOf="@+id/guideline_card_start"
app:layout_constraintTop_toBottomOf="@id/main_test_fetching" />

<include
android:id="@+id/main_test_positive"
layout="@layout/include_submission_status_card_positive"
Expand All @@ -182,7 +193,7 @@
gone="@{submissionCard == null || !submissionCard.isPositiveSubmissionCardVisible()}"
app:layout_constraintEnd_toStartOf="@+id/guideline_card_end"
app:layout_constraintStart_toStartOf="@+id/guideline_card_start"
app:layout_constraintTop_toBottomOf="@+id/main_test_fetching" />
app:layout_constraintTop_toBottomOf="@+id/main_test_failed" />

<include
android:id="@+id/main_test_done"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<TextView
android:id="@+id/submission_status_card_fetch_failed_title"
style="@style/headline5"
android:layout_width="@dimen/match_constraint"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/card_padding"
android:layout_marginTop="@dimen/card_padding"
android:layout_marginEnd="@dimen/spacing_small"
android:accessibilityHeading="true"
android:focusable="false"
android:text="@string/submission_status_card_title_failed"
app:layout_constraintEnd_toStartOf="@+id/submission_status_card_fetch_failed_icon"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />


<TextView
android:id="@+id/submission_status_card_fetch_failed_body"
style="@style/subtitleMedium"
android:layout_width="@dimen/match_constraint"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/card_padding"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginEnd="@dimen/spacing_small"
android:focusable="false"
android:text="@string/submission_status_card_body_failed"
app:layout_constraintEnd_toStartOf="@+id/submission_status_card_fetch_failed_icon"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/submission_status_card_fetch_failed_title" />

<Button
android:id="@+id/submission_status_card_fetch_failed_button"
style="@style/buttonPrimary"
android:layout_width="@dimen/match_constraint"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/card_padding"
android:layout_marginTop="@dimen/spacing_normal"
android:layout_marginEnd="@dimen/card_padding"
android:layout_marginBottom="@dimen/card_padding"
android:text="@string/submission_status_card_button_failed"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/submission_status_card_unregistered_barrier" />

<ImageView
android:id="@+id/submission_status_card_fetch_failed_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:importantForAccessibility="no"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/submission_status_card_fetch_failed_title"
app:srcCompat="@drawable/ic_main_illustration_invalid" />

<androidx.constraintlayout.widget.Barrier
android:id="@+id/submission_status_card_unregistered_barrier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="submission_status_card_fetch_failed_icon,submission_status_card_fetch_failed_body" />
</merge>
6 changes: 6 additions & 0 deletions Corona-Warn-App/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,8 @@
<string name="submission_status_card_title_available">"Ihr Ergebnis liegt vor"</string>
<!-- XHED: Page title for the various submission status: positive -->
<string name="submission_status_card_title_positive">"Befund positiv"</string>
<!-- XHED: Page title for the various submission status fetch failed -->
<string name="submission_status_card_title_failed">"Test nicht mehr gültig"</string>
<!-- XHED: Subtitle for the submission status card: invalid -->
<string name="submission_status_card_subtitle_invalid">"Fehlerhafter Test"</string>
<!-- XHED: Subtitle for the submission status card: negative -->
Expand All @@ -1105,10 +1107,14 @@
<string name="submission_status_card_body_positive">"Sie wurden positiv auf SARS-CoV-2 getestet."</string>
<!-- YTXT: Body text for submission status: negative -->
<string name="submission_status_card_body_negative">"Sie wurden negativ auf SARS-CoV-2 getestet."</string>
<!-- YTXT: Body text for submission status fetch failed -->
<string name="submission_status_card_body_failed">"Ihr Test liegt länger als 21 Tage zurück und ist daher nicht länger relevant. Bitte löschen Sie den Test. Danach können Sie einen neuen Test hinzufügen."</string>
<!-- XBUT: submission status card unregistered button -->
<string name="submission_status_card_button_unregistered">"Informieren &amp; helfen"</string>
<!-- XBUT: submission status card show results button -->
<string name="submission_status_card_button_show_results">"Test anzeigen"</string>
<!-- XBUT: submission status card fetch failed button -->
<string name="submission_status_card_button_failed">"Test löschen"</string>
<!-- XHED: submission status card positive result subtitle -->
<string name="submission_status_card_positive_result_subtitle">"Bitte beachten Sie:"</string>
<!-- YTXT: text for contagious card -->
Expand Down
6 changes: 6 additions & 0 deletions Corona-Warn-App/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,8 @@
<string name="submission_status_card_title_available">"Your result is available"</string>
<!-- XHED: Page title for the various submission status: positive -->
<string name="submission_status_card_title_positive">"Positive Diagnosis"</string>
<!-- XHED: Page title for the various submission status fetch failed -->
<string name="submission_status_card_title_failed"></string>
<!-- XHED: Subtitle for the submission status card: invalid -->
<string name="submission_status_card_subtitle_invalid">"Invalid test"</string>
<!-- XHED: Subtitle for the submission status card: negative -->
Expand All @@ -1111,10 +1113,14 @@
<string name="submission_status_card_body_positive">"You have been diagnosed positive for SARS-CoV-2."</string>
<!-- YTXT: Body text for submission status: negative -->
<string name="submission_status_card_body_negative">"You have been diagnosed negative for SARS-CoV-2."</string>
<!-- YTXT: Body text for submission status fetch failed -->
<string name="submission_status_card_body_failed"></string>
<!-- XBUT: submission status card unregistered button -->
<string name="submission_status_card_button_unregistered">"Learn More and Help"</string>
<!-- XBUT: submission status card show results button -->
<string name="submission_status_card_button_show_results">"Display Test"</string>
<!-- XBUT: submission status card fetch failed button -->
<string name="submission_status_card_button_failed"></string>
<!-- XHED: submission status card positive result subtitle -->
<string name="submission_status_card_positive_result_subtitle">"Please note:"</string>
<!-- YTXT: text for contagious card -->
Expand Down
Loading

0 comments on commit 21b7d77

Please sign in to comment.