diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/formatter/FormatterRiskHelper.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/formatter/FormatterRiskHelper.kt index 079c4db1f46181c1a8a8fd76feb519d1b688c0b4..ea3495421bf2368f00c7fdeff389dddc53150420 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/formatter/FormatterRiskHelper.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/formatter/FormatterRiskHelper.kt @@ -211,6 +211,29 @@ fun formatRiskActiveTracingDaysInRetentionPeriod( } } +/** + * Formats the risk card text display of tracing active duration in days depending on risk level + * Special case for increased risk as it is then only displayed on risk detail view + * + * @param riskLevelScore + * @param showDetails + * @param activeTracingDaysInRetentionPeriod + * @return + */ +fun formatRiskActiveTracingDaysInRetentionPeriodLogged( + riskLevelScore: Int?, + activeTracingDaysInRetentionPeriod: Long +): String { + val appContext = CoronaWarnApplication.getAppContext() + var periodLoggedString :String ="" + if (riskLevelScore == RiskLevelConstants.LOW_LEVEL_RISK || riskLevelScore == RiskLevelConstants.INCREASED_RISK) { + periodLoggedString = appContext.getString( + R.string.risk_details_information_body_period_logged_assessment + ).format(activeTracingDaysInRetentionPeriod) + } + return periodLoggedString +} + fun formatRelativeDateTimeString(appContext: Context, date: Date): CharSequence? = DateUtils.getRelativeDateTimeString( appContext, @@ -526,6 +549,16 @@ fun formatVisibilityBehavior(riskLevelScore: Int?): Int = fun formatVisibilityBehaviorIncreasedRisk(riskLevelScore: Int?): Int = formatVisibility(riskLevelScore == RiskLevelConstants.INCREASED_RISK) +/** + * Format the risk details include display for suggested behavior depending on risk level + * Only applied in special case for increased risk + * + * @param riskLevelScore + * @return + */ +fun formatVisibilityBehaviorPeriodLogged(riskLevelScore: Int?): Int = + formatVisibility(riskLevelScore == RiskLevelConstants.INCREASED_RISK || riskLevelScore == RiskLevelConstants.LOW_LEVEL_RISK) + /** * Formats the risk details suggested behavior icon color depending on risk level * This special handling is required due to light / dark mode differences and switches diff --git a/Corona-Warn-App/src/main/res/layout/fragment_risk_details.xml b/Corona-Warn-App/src/main/res/layout/fragment_risk_details.xml index 0cfb4d8f442bf43a51251bdda27219865c71ec95..89674ce6ab5bcdee18b567703f61d61762ee85a0 100644 --- a/Corona-Warn-App/src/main/res/layout/fragment_risk_details.xml +++ b/Corona-Warn-App/src/main/res/layout/fragment_risk_details.xml @@ -120,13 +120,14 @@ <TextView android:id="@+id/risk_details_behavior_headline" style="@style/headline5" - android:accessibilityHeading="true" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/spacing_medium" - android:text="@string/risk_details_headline_behavior" + android:layout_marginTop="28dp" + android:accessibilityHeading="true" android:focusable="true" + android:text="@string/risk_details_headline_behavior" app:layout_constraintEnd_toStartOf="@+id/guideline_end" + app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="@+id/guideline_start" app:layout_constraintTop_toBottomOf="@+id/risk_details_risk_card" /> @@ -179,6 +180,19 @@ </androidx.constraintlayout.widget.ConstraintLayout> + <include + android:id="@+id/risk_details_behavior_increased_risk_3" + layout="@layout/include_risk_details_period_logged_card" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/spacing_normal" + android:focusable="true" + android:visibility="@{FormatterRiskHelper.formatVisibilityBehaviorPeriodLogged(tracingViewModel.riskLevel)}" + app:layout_constraintEnd_toStartOf="@+id/guideline_end" + app:layout_constraintStart_toStartOf="@+id/guideline_start" + app:layout_constraintTop_toBottomOf="@id/risk_details_behavior_wrapper" + app:tracingViewModel="@{tracingViewModel}" /> + <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/risk_details_body" style="@style/greyBodyBackground" @@ -186,7 +200,7 @@ android:layout_height="wrap_content" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/risk_details_behavior_wrapper"> + app:layout_constraintTop_toTopOf="parent"> <TextView android:id="@+id/risk_details_information_headline" diff --git a/Corona-Warn-App/src/main/res/layout/fragment_settings_tracing.xml b/Corona-Warn-App/src/main/res/layout/fragment_settings_tracing.xml index a177b0e9eb52050b02501edd759d9b5143d20ce2..61493b1d7e3e3faef6e38637a3ec24ef01462be7 100644 --- a/Corona-Warn-App/src/main/res/layout/fragment_settings_tracing.xml +++ b/Corona-Warn-App/src/main/res/layout/fragment_settings_tracing.xml @@ -113,40 +113,18 @@ app:layout_constraintStart_toStartOf="@+id/guideline_card_start" app:layout_constraintTop_toTopOf="parent" /> - <androidx.constraintlayout.widget.ConstraintLayout + <include android:id="@+id/settings_tracing_status_tracing" - android:layout_width="@dimen/match_constraint" + layout="@layout/include_risk_details_period_logged_progress" + android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginTop="@dimen/spacing_tiny" - android:visibility="@{FormatterSettingsHelper.formatTracingStatusVisibilityTracing(tracingViewModel.isTracingEnabled(), settingsViewModel.isBluetoothEnabled(), settingsViewModel.isConnectionEnabled())}" android:focusable="true" + android:visibility="@{FormatterSettingsHelper.formatTracingStatusVisibilityTracing(tracingViewModel.isTracingEnabled(), settingsViewModel.isBluetoothEnabled(), settingsViewModel.isConnectionEnabled())}" app:layout_constraintEnd_toStartOf="@+id/guideline_end" app:layout_constraintStart_toEndOf="@+id/guideline_start" - app:layout_constraintTop_toTopOf="parent"> - - <TextView - android:id="@+id/settings_tracing_status_tracing_body" - style="@style/body2Medium" - android:layout_width="@dimen/match_constraint" - android:layout_height="wrap_content" - android:layout_marginEnd="@dimen/spacing_small" - android:text="@{FormatterSettingsHelper.formatTracingStatusBody(tracingViewModel.activeTracingDaysInRetentionPeriod)}" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toStartOf="@+id/settings_tracing_status_tracing_circle_progress" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> - - <de.rki.coronawarnapp.ui.view.CircleProgress - android:id="@+id/settings_tracing_status_tracing_circle_progress" - android:layout_width="@dimen/spacing_huge" - android:layout_height="@dimen/spacing_huge" - android:importantForAccessibility="no" - app:circleWidth="@dimen/circle_large_width" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toTopOf="parent" - app:progress="@{tracingViewModel.activeTracingDaysInRetentionPeriod}" /> - - </androidx.constraintlayout.widget.ConstraintLayout> + app:layout_constraintTop_toTopOf="parent" + app:tracingViewModel="@{tracingViewModel}" + app:riskLevel="@{tracingViewModel.riskLevel}" /> <include layout="@layout/merge_guidelines_card" /> diff --git a/Corona-Warn-App/src/main/res/layout/include_risk_details_period_logged_card.xml b/Corona-Warn-App/src/main/res/layout/include_risk_details_period_logged_card.xml new file mode 100644 index 0000000000000000000000000000000000000000..8708442d1a6f8760e437605d7de87a797d9b64a7 --- /dev/null +++ b/Corona-Warn-App/src/main/res/layout/include_risk_details_period_logged_card.xml @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="utf-8"?> +<layout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> + + <data> + + <import type="de.rki.coronawarnapp.util.formatter.FormatterHelper" /> + + <import type="de.rki.coronawarnapp.util.formatter.FormatterRiskHelper" /> + + <variable + name="tracingViewModel" + type="de.rki.coronawarnapp.ui.viewmodel.TracingViewModel" /> + + </data> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="match_parent" + android:focusable="true"> + + + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/risk_details_period_logged_layout" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/spacing_tiny" + android:focusable="true" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + <TextView + android:id="@+id/risk_details_period_logged_headline" + style="@style/headline5" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/spacing_normal" + android:focusable="false" + android:text="@string/risk_details_headline_period_logged" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <TextView + android:id="@+id/risk_details_period_logged_subtitle" + style="@style/subtitle" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/spacing_tiny" + android:focusable="false" + android:text="@string/risk_details_subtitle_period_logged" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/risk_details_period_logged_headline" /> + + <TextView + android:id="@+id/risk_details_period_logged_body_notice" + style="@style/body1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/spacing_normal" + android:focusable="true" + android:text="@string/risk_details_information_body_period_logged" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/risk_details_period_logged_subtitle" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + + <include + android:id="@+id/risk_details_period_logged_progress" + layout="@layout/include_risk_details_period_logged_progress" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:focusable="true" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/risk_details_period_logged_layout" + app:riskLevel="@{tracingViewModel.riskLevel}" + app:tracingViewModel="@{tracingViewModel}" /> + </androidx.constraintlayout.widget.ConstraintLayout> +</layout> \ No newline at end of file diff --git a/Corona-Warn-App/src/main/res/layout/include_risk_details_period_logged_progress.xml b/Corona-Warn-App/src/main/res/layout/include_risk_details_period_logged_progress.xml new file mode 100644 index 0000000000000000000000000000000000000000..5f84e87a42658c8a01936a7ce07c0ead42a87419 --- /dev/null +++ b/Corona-Warn-App/src/main/res/layout/include_risk_details_period_logged_progress.xml @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="utf-8"?> +<layout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto"> + + <data> + + <import type="de.rki.coronawarnapp.util.formatter.FormatterRiskHelper" /> + + <variable + name="riskLevel" + type="Integer" /> + + <variable + name="tracingViewModel" + type="de.rki.coronawarnapp.ui.viewmodel.TracingViewModel" /> + + </data> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <TextView + android:id="@+id/risk_details_period_logged_body_notice" + style="@style/body1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/spacing_normal" + android:focusable="true" + android:text="@string/risk_details_information_body_period_logged" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:focusable="true" + android:layout_marginTop="@dimen/spacing_normal" + app:layout_constraintTop_toBottomOf="@id/risk_details_period_logged_body_notice"> + + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/risk_details_behavior_icon" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + <de.rki.coronawarnapp.ui.view.CircleProgress + android:id="@+id/risk_details_investigation_period_circle_progress" + android:layout_width="@dimen/spacing_huge" + android:layout_height="@dimen/spacing_huge" + android:importantForAccessibility="no" + app:circleWidth="@dimen/circle_large_width" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:progress="@{tracingViewModel.activeTracingDaysInRetentionPeriod}" /> + </androidx.constraintlayout.widget.ConstraintLayout> + + <TextView + style="@style/subtitle" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginStart="@dimen/spacing_small" + android:text="@{FormatterRiskHelper.formatRiskActiveTracingDaysInRetentionPeriodLogged(tracingViewModel.riskLevel, tracingViewModel.activeTracingDaysInRetentionPeriod)}" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toEndOf="@+id/risk_details_behavior_icon" + app:layout_constraintTop_toTopOf="parent" /> + </androidx.constraintlayout.widget.ConstraintLayout> + </androidx.constraintlayout.widget.ConstraintLayout> +</layout> \ No newline at end of file