diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/notification/TestResultAvailableNotification.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/notification/TestResultAvailableNotification.kt index 07214c4d788a1295717b89940b7379dacb934abc..80cdfa7569c5c609e065ab47685e582a5607a4a3 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/notification/TestResultAvailableNotification.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/notification/TestResultAvailableNotification.kt @@ -35,6 +35,10 @@ class TestResultAvailableNotification @Inject constructor( ) } + fun cancelTestResultNotification() { + notificationHelper.cancelCurrentNotification(NotificationConstants.TEST_RESULT_AVAILABLE_NOTIFICATION_ID) + } + /** * The pending result fragment will forward to the correct screen * Because we can't save the test result at the moment (legal), diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/task/SubmissionTask.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/task/SubmissionTask.kt index 7b0deee24ba9b006478b63ad034bcd1c6627dcaf..645d931705e03c7a31ce17aa3a6e35a5b80371aa 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/task/SubmissionTask.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/submission/task/SubmissionTask.kt @@ -3,6 +3,7 @@ package de.rki.coronawarnapp.submission.task import com.google.android.gms.nearby.exposurenotification.TemporaryExposureKey import de.rki.coronawarnapp.appconfig.AppConfigProvider import de.rki.coronawarnapp.exception.NoRegistrationTokenSetException +import de.rki.coronawarnapp.notification.TestResultAvailableNotification import de.rki.coronawarnapp.notification.TestResultNotificationService import de.rki.coronawarnapp.playbook.Playbook import de.rki.coronawarnapp.storage.LocalData @@ -33,7 +34,8 @@ class SubmissionTask @Inject constructor( private val submissionSettings: SubmissionSettings, private val autoSubmission: AutoSubmission, private val timeStamper: TimeStamper, - private val testResultNotificationService: TestResultNotificationService + private val testResultNotificationService: TestResultNotificationService, + private val testResultAvailableNotification: TestResultAvailableNotification ) : Task<DefaultProgress, SubmissionTask.Result> { private val internalProgress = ConflatedBroadcastChannel<DefaultProgress>() @@ -154,6 +156,7 @@ class SubmissionTask @Inject constructor( LocalData.numberOfSuccessfulSubmissions(1) testResultNotificationService.cancelPositiveTestResultNotification() + testResultAvailableNotification.cancelTestResultNotification() } data class Arguments( diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/states/TracingState.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/states/TracingState.kt index 6dd893521e346fc312766a8f48d479a638aa7269..8b201929b5f2e2f3f8031991573e2fed2550d852 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/states/TracingState.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/tracing/states/TracingState.kt @@ -131,18 +131,13 @@ data class TracingFailed( val showRestartButton: Boolean = !isInDetailsMode - fun getTimeFetched(c: Context): String = when (riskState) { - RiskState.LOW_RISK, RiskState.INCREASED_RISK -> { - if (lastExposureDetectionTime != null) { - c.getString( - R.string.risk_card_body_time_fetched, - formatRelativeDateTimeString(c, lastExposureDetectionTime) - ) - } else { - c.getString(R.string.risk_card_body_not_yet_fetched) - } - } - else -> "" + fun getTimeFetched(context: Context): String = if (lastExposureDetectionTime != null) { + context.getString( + R.string.risk_card_body_time_fetched, + formatRelativeDateTimeString(context, lastExposureDetectionTime) + ) + } else { + context.getString(R.string.risk_card_body_not_yet_fetched) } fun getLastRiskState(c: Context): String { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/Country.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/Country.kt index 25c5d3f8ff24dc7536fa7efb0ff6208e59b50f1d..4c07b081e2ebfa4f2c584404c3642cbdc141e5e5 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/Country.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/Country.kt @@ -1,9 +1,9 @@ package de.rki.coronawarnapp.ui +import android.content.Context import androidx.annotation.DrawableRes import androidx.annotation.StringRes import de.rki.coronawarnapp.R -import de.rki.coronawarnapp.util.ui.CachedString enum class Country( val code: String, @@ -43,5 +43,7 @@ enum class Country( SI("si", R.string.country_name_si, R.drawable.ic_country_si), SK("sk", R.string.country_name_sk, R.drawable.ic_country_sk); - val label = CachedString { it.getString(labelRes) } + fun getLabel(context: Context): String { + return context.getString(labelRes) + } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/view/CountryListView.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/view/CountryListView.kt index ed93584ddf85f339b74c0cf3afdff10c77225200..8a5a0c171e4ccf0e32a7ec85370a9c54a440712d 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/view/CountryListView.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/view/CountryListView.kt @@ -25,10 +25,10 @@ class CountryListView(context: Context, attrs: AttributeSet) : LinearLayout(cont set(value) { field = value.sortedWith { a, b -> // Sort country list alphabetically - Collator.getInstance().compare(a.label.get(context), b.label.get(context)) + Collator.getInstance().compare(a.getLabel(context), b.getLabel(context)) }.also { countries -> adapterCountryFlags.countryList = countries - countryNames.text = countries.joinToString(", ") { it.label.get(context) } + countryNames.text = countries.joinToString(", ") { it.getLabel(context) } } } diff --git a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/submission/task/SubmissionTaskTest.kt b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/submission/task/SubmissionTaskTest.kt index 4e9905c86f3738ee388fdec1a118dbb7fbafe4da..596fb9a2450527fc7af19e2fab7b3bb2d1c093c7 100644 --- a/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/submission/task/SubmissionTaskTest.kt +++ b/Corona-Warn-App/src/test/java/de/rki/coronawarnapp/submission/task/SubmissionTaskTest.kt @@ -4,6 +4,7 @@ import com.google.android.gms.nearby.exposurenotification.TemporaryExposureKey import de.rki.coronawarnapp.appconfig.AppConfigProvider import de.rki.coronawarnapp.appconfig.ConfigData import de.rki.coronawarnapp.exception.NoRegistrationTokenSetException +import de.rki.coronawarnapp.notification.TestResultAvailableNotification import de.rki.coronawarnapp.notification.TestResultNotificationService import de.rki.coronawarnapp.playbook.Playbook import de.rki.coronawarnapp.server.protocols.external.exposurenotification.TemporaryExposureKeyExportOuterClass @@ -48,6 +49,7 @@ class SubmissionTaskTest : BaseTest() { @MockK lateinit var tekHistoryStorage: TEKHistoryStorage @MockK lateinit var submissionSettings: SubmissionSettings @MockK lateinit var testResultNotificationService: TestResultNotificationService + @MockK lateinit var testResultAvailableNotification: TestResultAvailableNotification @MockK lateinit var autoSubmission: AutoSubmission @MockK lateinit var tekBatch: TEKHistoryStorage.TEKBatch @@ -99,6 +101,7 @@ class SubmissionTaskTest : BaseTest() { coEvery { playbook.submit(any()) } just Runs every { testResultNotificationService.cancelPositiveTestResultNotification() } just Runs + every { testResultAvailableNotification.cancelTestResultNotification() } just Runs every { autoSubmission.updateMode(any()) } just Runs @@ -113,7 +116,8 @@ class SubmissionTaskTest : BaseTest() { submissionSettings = submissionSettings, testResultNotificationService = testResultNotificationService, timeStamper = timeStamper, - autoSubmission = autoSubmission + autoSubmission = autoSubmission, + testResultAvailableNotification = testResultAvailableNotification ) @Test @@ -152,6 +156,7 @@ class SubmissionTaskTest : BaseTest() { LocalData.numberOfSuccessfulSubmissions(1) testResultNotificationService.cancelPositiveTestResultNotification() + testResultAvailableNotification.cancelTestResultNotification() } }