Commit feccce0c authored by Harri Kirik's avatar Harri Kirik
Browse files

COVAPP-462: Update Contact screen

parent 2c64bfbb
......@@ -69,11 +69,35 @@ fun TextView.addUrlSpans() {
fun TextView.setTextWithClickableSpan(source: String, clickablePart: String, clickListener: () -> Unit) {
val spannable = SpannableString(source)
addClickableSpan(spannable, clickablePart, clickListener)
this.text = spannable
movementMethod = LinkMovementMethod.getInstance()
}
fun TextView.setTextWithTwoClickableSpans(
source: String,
clickablePart1: String,
clickListener1: () -> Unit,
clickablePart2: String,
clickListener2: () -> Unit
) {
val spannable = SpannableString(source)
addClickableSpan(spannable, clickablePart1, clickListener1)
addClickableSpan(spannable, clickablePart2, clickListener2)
this.text = spannable
movementMethod = LinkMovementMethod.getInstance()
}
private fun TextView.addClickableSpan(
spannable: SpannableString,
clickablePart1: String,
clickListener1: () -> Unit
) {
spannable.addSpan(
clickablePart,
clickablePart1,
object : ClickableSpan() {
override fun onClick(widget: View) {
clickListener.invoke()
clickListener1.invoke()
}
override fun updateDrawState(paint: TextPaint) {
......@@ -82,8 +106,6 @@ fun TextView.setTextWithClickableSpan(source: String, clickablePart: String, cli
}
}
)
this.text = spannable
movementMethod = LinkMovementMethod.getInstance()
}
private fun updateDrawStateWithPaint(paint: TextPaint, context: Context) {
......
......@@ -17,7 +17,8 @@ import org.dpppt.android.app.common.util.ViewBindingHolder
import org.dpppt.android.app.common.util.ViewModelFactory
import org.dpppt.android.app.common.util.addUrlSpans
import org.dpppt.android.app.common.util.exhaustive
import org.dpppt.android.app.common.util.setTextWithClickableSpan
import org.dpppt.android.app.common.util.setTextWithBoldSpans
import org.dpppt.android.app.common.util.setTextWithTwoClickableSpans
import org.dpppt.android.app.databinding.FragmentContactsBinding
import org.dpppt.android.app.di.Injector
import org.dpppt.android.app.main.model.InfectedStatus
......@@ -80,20 +81,26 @@ class ContactsFragment : MvvmFragment(R.layout.fragment_contacts), ViewBindingHo
}
requireBinding {
titleView.text = resources.getQuantityString(R.plurals.contacts_detected_title, contacts.num, contacts.num)
descriptionStayHomeView.text =
getString(R.string.contacts_detected_text_stay_home, DateUtils.getFormattedLocalDate(contacts.stayHomeUntilDate))
setupStayHomeText(contacts)
}
}
private fun FragmentContactsBinding.setupStayHomeText(contacts: InfectedStatus.HasContacts) {
val dateString = DateUtils.getFormattedLocalDate(contacts.stayHomeUntilDate)
val message = getString(R.string.contacts_detected_text_stay_home, dateString)
descriptionStayHomeView.setTextWithBoldSpans(message, dateString)
}
private fun initClickableText() {
requireBinding {
descriptionCallView.addUrlSpans()
healthBoardRecommendationsView.setTextWithClickableSpan(
healthBoardRecommendationsView.setTextWithTwoClickableSpans(
getString(R.string.contacts_health_board_recommendations_link),
getString(R.string.contacts_health_board_recommendations_link_clickable_part)
) {
viewModel.healthBoardRecommendationsClicked()
}
getString(R.string.contacts_health_board_recommendations_link_clickable_part_1),
{ viewModel.healthBoardRecommendationsClicked() },
getString(R.string.contacts_health_board_recommendations_link_clickable_part_2),
{ viewModel.healthBoardRecommendationsClicked() },
)
}
}
}
......@@ -34,6 +34,7 @@
<com.google.android.material.card.MaterialCardView
style="@style/AppTheme.CardView"
android:id="@+id/cardContactInfo"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/size_16"
......@@ -148,41 +149,42 @@
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_6"
app:layout_constraintStart_toStartOf="@+id/startGuideline"
app:layout_constraintTop_toTopOf="@+id/descriptionMonitorHealthView"
app:layout_constraintTop_toTopOf="@+id/healthBoardRecommendationsView"
app:srcCompat="@drawable/ic_point"
android:importantForAccessibility="no" />
<TextView
android:id="@+id/descriptionMonitorHealthView"
android:id="@+id/healthBoardRecommendationsView"
style="@style/AppTheme.Paragraph.Black"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_16"
android:text="@string/contacts_detected_text_monitor_health"
android:text="@string/contacts_health_board_recommendations_link"
app:layout_constraintEnd_toStartOf="@+id/endGuideline"
app:layout_constraintStart_toStartOf="@+id/listStartGuidline"
app:layout_constraintTop_toBottomOf="@+id/descriptionStayHomeView" />
<ImageView
android:id="@+id/bulletView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_6"
app:layout_constraintStart_toStartOf="@+id/startGuideline"
app:layout_constraintTop_toTopOf="@+id/healthBoardRecommendationsView"
app:layout_constraintTop_toTopOf="@+id/descriptionMonitorHealthView"
app:srcCompat="@drawable/ic_point"
android:importantForAccessibility="no" />
<TextView
android:id="@+id/healthBoardRecommendationsView"
android:id="@+id/descriptionMonitorHealthView"
style="@style/AppTheme.Paragraph.Black"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_16"
android:text="@string/contacts_health_board_recommendations_link"
android:text="@string/contacts_detected_text_monitor_health"
app:layout_constraintEnd_toStartOf="@+id/endGuideline"
app:layout_constraintStart_toStartOf="@+id/listStartGuidline"
app:layout_constraintTop_toBottomOf="@+id/descriptionMonitorHealthView" />
app:layout_constraintTop_toBottomOf="@+id/healthBoardRecommendationsView" />
<ImageView
android:id="@+id/bulletView4"
......@@ -195,15 +197,27 @@
android:importantForAccessibility="no" />
<TextView
android:id="@+id/descriptionCallView"
style="@style/AppTheme.Paragraph.Black"
android:id="@+id/descriptionCallView"
style="@style/AppTheme.Paragraph.Black"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_16"
android:text="@string/contacts_detected_text_call"
app:layout_constraintEnd_toStartOf="@+id/endGuideline"
app:layout_constraintStart_toStartOf="@+id/listStartGuidline"
app:layout_constraintTop_toBottomOf="@+id/descriptionMonitorHealthView" />
<TextView
android:id="@+id/descriptionHealthBoardThanksYou"
style="@style/AppTheme.Paragraph.Black.Bold"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_16"
android:text="@string/contacts_detected_text_call"
android:layout_marginTop="@dimen/size_24"
android:gravity="center_horizontal"
android:text="@string/contacts_detected_text_health_board_thanks_you"
app:layout_constraintEnd_toStartOf="@+id/endGuideline"
app:layout_constraintStart_toStartOf="@+id/listStartGuidline"
app:layout_constraintTop_toBottomOf="@+id/healthBoardRecommendationsView" />
app:layout_constraintTop_toBottomOf="@+id/descriptionCallView" />
<com.google.android.material.button.MaterialButton
android:id="@+id/buttonBackHome"
......@@ -211,26 +225,29 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_16"
android:layout_marginBottom="@dimen/text_size_32"
android:text="@string/nav_back_home"
app:layout_constraintEnd_toStartOf="@+id/endGuideline"
app:layout_constraintStart_toStartOf="@+id/startGuideline"
app:layout_constraintTop_toBottomOf="@+id/descriptionCallView" />
<TextView
android:id="@+id/learnMoreView"
style="@style/AppTheme.LinkButtonText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_8"
app:layout_constraintEnd_toStartOf="@+id/endGuideline"
app:layout_constraintStart_toStartOf="@+id/startGuideline"
app:layout_constraintTop_toBottomOf="@+id/buttonBackHome"
app:layout_constraintBottom_toTopOf="@+id/bottomGuideline"
android:gravity="center"
android:text="@string/contacts_info_page_link" />
app:layout_constraintTop_toBottomOf="@+id/descriptionHealthBoardThanksYou"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<TextView
android:id="@+id/learnMoreView"
style="@style/AppTheme.LinkButtonText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/size_8"
android:layout_marginBottom="@dimen/size_8"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/cardContactInfo"
app:layout_constraintBottom_toBottomOf="parent"
android:gravity="center_horizontal"
android:text="@string/contacts_info_page_link" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</LinearLayout>
......@@ -83,7 +83,7 @@ Aitäh, et hoiad lähedasi."</string>
<string name="home_infection_description_infected_blue_part">"koduse ravi juhendiga"</string>
<string name="contacts_no_contacts">"Teadaolevad lähikontaktid puuduvad"</string>
<string name="contacts_detected_description_home">"Viiruse leviku riski vähendamiseks püsi kodus kuni %s."</string>
<string name="contacts_detected_description_general">"Lähikontakt ei tähenda veel, et sul on kindlasti viirus. Selleks, et ennast ja teisi hoida, palume sul teha järgnevat:"</string>
<string name="contacts_detected_description_general">"Lähikontakt ei tähenda veel, et sul on kindlasti viirus. Et tagada sinu ja teiste anonüümsus, ei näita HOIA rakendus lähikontakti tekkimise täpset aega ega kohta. Selleks, et ennast ja teisi hoida:"</string>
<string name="contacts_detected_text_stay_home">"Püsi kodus kuni %s"</string>
<string name="contacts_info_page_link">"Kuidas tekib lähikontakt?"</string>
<string name="contacts_detected_text_monitor_health">"Jälgi oma tervist. Sümptomite ilmnemisel võta ühendust perearstiga."</string>
......@@ -92,6 +92,7 @@ Aitäh, et hoiad lähedasi."</string>
<item quantity="one">"Sul on olnud %d lähikontakt COVID-19 haigega"</item>
<item quantity="other">"Sul on olnud %d lähikontakti COVID-19 haigega"</item>
</plurals>
<string name="contacts_detected_text_health_board_thanks_you">"Terviseamet tänab sind panuse eest!"</string>
<string name="settings_title">"Seaded"</string>
<string name="settings_battery_optimization_label">"Luban rakendusel taustal töötada"</string>
<string name="settings_battery_optimization_description">"Taustal töötamine on vajalik lähikontaktide teavitustes viivituse vähendamiseks."</string>
......@@ -167,8 +168,9 @@ Aitäh, et hoiad lähedasi."</string>
<string name="dp3t_sdk_service_notification_error_sync_api">"Esines sünkroniseerimisviga. Nakatunud võtmete laadimine ebaõnnestus. Kui viga kordub siis kontakteeru kasutajatoega."</string>
<string name="dp3t_sdk_service_notification_error_gaen_not_available">"Google kontaktiteavitus ei tööta praegu sellel seadmel. Palun kontrolli, et seade ja rakendused oleks ajakohased ning et Google Play Services teek oleks installitud. Kui viga kordub siis kontakteeru kasutajatoega."</string>
<string name="dp3t_sdk_service_notification_error_gaen_unexpectedly_disabled">"Google kontaktiteavitus on väljalülitatud. Palun lülita see sisse Seaded -&gt; Google -&gt; COVID-19-ga kokkupuute märguanded. Kui viga kordub siis kontakteeru kasutajatoega."</string>
<string name="contacts_health_board_recommendations_link">"Tutvu Terviseameti soovitustega"</string>
<string name="contacts_health_board_recommendations_link_clickable_part">"Terviseameti soovitustega"</string>
<string name="contacts_health_board_recommendations_link">"Tutvu Eneseisolatsiooni reeglite ja Terviseameti soovitustega"</string>
<string name="contacts_health_board_recommendations_link_clickable_part_1">"Eneseisolatsiooni reeglite"</string>
<string name="contacts_health_board_recommendations_link_clickable_part_2">"Terviseameti soovitustega"</string>
<string name="debug_state_show_pre_share_screen">"Võtmete jagamise eelne ekraan"</string>
<string name="confirm_infection_pre_share_info_title">"Anonüümsete koodide jagamine"</string>
<string name="confirm_infection_pre_share_info_subtitle">"Anna luba oma telefonil jagada anonüümseid koode HOIA rakendusega, vajutades “Jaga”, “Отправить” või “Share” nupule."</string>
......
......@@ -81,7 +81,7 @@
<string name="home_infection_description_infected_blue_part">"инструкцией о домашнем лечении"</string>
<string name="contacts_no_contacts">"Известных близких контактов не было"</string>
<string name="contacts_detected_description_home">"Для снижения риска распространения вируса, оставайтесь дома до %s."</string>
<string name="contacts_detected_description_general">"Близкий контакт еще не означает, что Вы заразились вирусом. Чтобы защитить себя и других, просим сделать следующее:"</string>
<string name="contacts_detected_text_stay_home">"Оставайтесь дома до %s"</string>
<string name="contacts_info_page_link">"Как происходит близкий контакт?"</string>
<string name="contacts_detected_text_monitor_health">"Следите за своим здоровьем. При появлении симптомов свяжитесь с семейным врачом."</string>
......@@ -167,8 +167,7 @@
<string name="dp3t_sdk_service_notification_error_sync_api">"Произошла ошибка внутренней синхронизации. Не удалось загрузить новые данные о заражении.Если проблема останется, свяжитесь с технической поддержкой."</string>
<string name="dp3t_sdk_service_notification_error_gaen_not_available">"Google Exposure Notification API в настоящее время недоступен на этом устройстве. Пожалуйста, проверьте, обновлены ли ваше устройство и приложения и установлены ли сервисы Google Play. . Если проблема останется, свяжитесь с технической поддержкой."</string>
<string name="dp3t_sdk_service_notification_error_gaen_unexpectedly_disabled">"Google Exposure Notification API в настоящее время отключён. Пожалуйста, включите его зайдя в Настройки -&gt; Google -&gt; Уведомления о заражении COVID-19. Если проблема останется, свяжитесь с технической поддержкой."</string>
<string name="contacts_health_board_recommendations_link">"Pекомендации на сайте Департамента здоровья"</string>
<string name="contacts_health_board_recommendations_link_clickable_part">"Pекомендации"</string>
<string name="debug_state_show_pre_share_screen">"Предшествующий обмену ключами экран"</string>
<string name="confirm_infection_pre_share_info_title">"Уведомить близлежащие контакты"</string>
<string name="confirm_infection_pre_share_info_subtitle">"Разрешите вашему телефону передавать анонимные коды приложению HOIA, нажав кнопку “Отправить”, “Jaga” или “Share” в следующем диалоговом окне."</string>
......
......@@ -83,7 +83,7 @@ Aitäh, et hoiad lähedasi."</string>
<string name="home_infection_description_infected_blue_part">"our home care guide"</string>
<string name="contacts_no_contacts">"No known exposures"</string>
<string name="contacts_detected_description_home">"To minimize the risk of viral spread, please stay at home until %s."</string>
<string name="contacts_detected_description_general">"A close contact does not guarantee you have been infected. To care for yourself and others, please do the following:"</string>
<string name="contacts_detected_description_general">"Lähikontakt ei tähenda veel, et sul on kindlasti viirus. Et tagada sinu ja teiste anonüümsus, ei näita HOIA rakendus lähikontakti tekkimise täpset aega ega kohta. Selleks, et ennast ja teisi hoida:"</string>
<string name="contacts_detected_text_stay_home">"Stay home until %s"</string>
<string name="contacts_info_page_link">"What is counted as a close contact?"</string>
<string name="contacts_detected_text_monitor_health">"Monitor your health. In case of symptoms, contact your family doctor."</string>
......@@ -92,6 +92,7 @@ Aitäh, et hoiad lähedasi."</string>
<item quantity="one">"You have had %d close contact with COVID-19 patients"</item>
<item quantity="other">"You have had %d close contacts with cases of COVID-19"</item>
</plurals>
<string name="contacts_detected_text_health_board_thanks_you">"Terviseamet tänab sind panuse eest!"</string>
<string name="settings_title">"Settings"</string>
<string name="settings_battery_optimization_label">"Allow app to work in background"</string>
<string name="settings_battery_optimization_description">"Hoia app requires permission to work in the background for the quickest results."</string>
......@@ -167,8 +168,9 @@ Aitäh, et hoiad lähedasi."</string>
<string name="dp3t_sdk_service_notification_error_sync_api">"A backend synchronisation error has occurred. Failed to load new infection data. If the problem persists, contact support."</string>
<string name="dp3t_sdk_service_notification_error_gaen_not_available">"Google Exposure Notification API is currently not available on this device. Please check that your device and applications are up to date and that Google Play Services is installed. If the problem persists, contact support."</string>
<string name="dp3t_sdk_service_notification_error_gaen_unexpectedly_disabled">"Google Exposure Notification API is currently disabled. Please enable it from Settings -&gt; Google -&gt; COVID-19 Exposure Notifications. If the problem persists, contact support."</string>
<string name="contacts_health_board_recommendations_link">"Read the recommendations of the Health Board"</string>
<string name="contacts_health_board_recommendations_link_clickable_part">"recommendations"</string>
<string name="contacts_health_board_recommendations_link">"Tutvu Eneseisolatsiooni reeglite ja Terviseameti soovitustega"</string>
<string name="contacts_health_board_recommendations_link_clickable_part_1">"Eneseisolatsiooni reeglite"</string>
<string name="contacts_health_board_recommendations_link_clickable_part_2">"Terviseameti soovitustega"</string>
<string name="debug_state_show_pre_share_screen">"Share keys intro screen"</string>
<string name="confirm_infection_pre_share_info_title">"Share anonymous codes"</string>
<string name="confirm_infection_pre_share_info_subtitle">"Anna luba oma telefonil jagada anonüümseid koode HOIA rakendusega, vajutades “Jaga”, “Отправить” või “Share” nupule."</string>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment