From dae5177ac493a3a3f72dd53d8df68f9a4a5af377 Mon Sep 17 00:00:00 2001 From: Philipp Woessner <64482866+pwoessner@users.noreply.github.com> Date: Wed, 8 Jul 2020 13:58:34 +0200 Subject: [PATCH] fixed test api permission dialog bug and display the latest available key date (#844) --- .../de.rki.coronawarnapp/TestForAPIFragment.kt | 16 +++++++++++++--- .../res/layout/fragment_test_for_a_p_i.xml | 6 ++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Corona-Warn-App/src/deviceForTesters/java/de.rki.coronawarnapp/TestForAPIFragment.kt b/Corona-Warn-App/src/deviceForTesters/java/de.rki.coronawarnapp/TestForAPIFragment.kt index e69110730..e2ed3fd8a 100644 --- a/Corona-Warn-App/src/deviceForTesters/java/de.rki.coronawarnapp/TestForAPIFragment.kt +++ b/Corona-Warn-App/src/deviceForTesters/java/de.rki.coronawarnapp/TestForAPIFragment.kt @@ -68,6 +68,7 @@ import kotlinx.android.synthetic.deviceForTesters.fragment_test_for_a_p_i.label_ import kotlinx.android.synthetic.deviceForTesters.fragment_test_for_a_p_i.label_exposure_summary_maximumRiskScore import kotlinx.android.synthetic.deviceForTesters.fragment_test_for_a_p_i.label_exposure_summary_summationRiskScore import kotlinx.android.synthetic.deviceForTesters.fragment_test_for_a_p_i.label_googlePlayServices_version +import kotlinx.android.synthetic.deviceForTesters.fragment_test_for_a_p_i.label_latest_key_date import kotlinx.android.synthetic.deviceForTesters.fragment_test_for_a_p_i.label_my_keys import kotlinx.android.synthetic.deviceForTesters.fragment_test_for_a_p_i.qr_code_viewpager import kotlinx.android.synthetic.deviceForTesters.fragment_test_for_a_p_i.test_api_switch_last_three_hours_from_server @@ -76,6 +77,8 @@ import kotlinx.android.synthetic.deviceForTesters.fragment_test_for_a_p_i.text_s import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import kotlinx.coroutines.withContext +import org.joda.time.DateTime +import org.joda.time.DateTimeZone import timber.log.Timber import java.io.File import java.lang.reflect.Type @@ -156,6 +159,8 @@ class TestForAPIFragment : Fragment(), InternalExposureNotificationPermissionHel internalExposureNotificationPermissionHelper = InternalExposureNotificationPermissionHelper(this, this) + getExposureKeys() + qrPager = qr_code_viewpager qrPagerAdapter = QRPagerAdapter() qrPager.adapter = qrPagerAdapter @@ -267,7 +272,6 @@ class TestForAPIFragment : Fragment(), InternalExposureNotificationPermissionHel super.onResume() updateExposureSummaryDisplay(null) - getExposureKeys() } private val prettyKey = { key: AppleLegacyKeyExchange.Key -> @@ -437,6 +441,13 @@ class TestForAPIFragment : Fragment(), InternalExposureNotificationPermissionHel ) label_my_keys.text = myKeysLabelAndCount text_my_keys.text = myExposureKeysJSON + + myKeys?.maxBy { it.rollingStartIntervalNumber }?.rollingStartIntervalNumber?.toLong()?.let { + val ms = it * 60L * 10L * 1000L + val dateString = DateTime(ms, DateTimeZone.UTC) + + label_latest_key_date.text = "Latest key is from: $dateString" + } } private fun showToast(message: String) { @@ -453,8 +464,7 @@ class TestForAPIFragment : Fragment(), InternalExposureNotificationPermissionHel } override fun onKeySharePermissionGranted(keys: List<TemporaryExposureKey>) { - myExposureKeysJSON = - keysToJson(keys) + myExposureKeysJSON = keysToJson(keys) myExposureKeys = keys qrPagerAdapter.notifyDataSetChanged() diff --git a/Corona-Warn-App/src/deviceForTesters/res/layout/fragment_test_for_a_p_i.xml b/Corona-Warn-App/src/deviceForTesters/res/layout/fragment_test_for_a_p_i.xml index 67aac4b5a..d53fe72b0 100644 --- a/Corona-Warn-App/src/deviceForTesters/res/layout/fragment_test_for_a_p_i.xml +++ b/Corona-Warn-App/src/deviceForTesters/res/layout/fragment_test_for_a_p_i.xml @@ -104,6 +104,12 @@ android:layout_marginTop="@dimen/spacing_normal" android:text="@string/test_api_body_my_keys" /> + <TextView + android:id="@+id/label_latest_key_date" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Latest key is from: -" /> + <TextView android:id="@+id/text_my_keys" android:layout_width="match_parent" -- GitLab