From 2f4b0c82bda8eccfb51cb14b78dcca9601f71d12 Mon Sep 17 00:00:00 2001 From: Rituraj Sambherao <54317407+ritsam@users.noreply.github.com> Date: Mon, 17 Aug 2020 22:00:40 +0100 Subject: [PATCH] Alternative contact possiblity (EXPOSUREAPP-1654) (#1013) * initial commit : feature / fix complete 1. Formatter Added 2. include layout added 3. visilbity logic based on default device language has been added 4. links for english and german forms are added based on device language 5. phone number has been removed * simplified logic * logic improved - more robust null check * reverted unnecessary string changes & added "information_legal_subtitle_contact_form_non_en_de" to german as non translatable Co-authored-by: Luka Harambasic <luka.harambasic@sap.com> Co-authored-by: harambasicluka <64483219+harambasicluka@users.noreply.github.com> --- .../information/InformationLegalFragment.kt | 12 +++++ .../FormatterInformationLegalHelper.kt | 34 ++++++++++++ .../res/layout/fragment_information_legal.xml | 11 +++- .../main/res/layout/include_contact_form.xml | 53 +++++++++++++++++++ .../src/main/res/values-de/strings.xml | 6 ++- .../src/main/res/values/strings.xml | 6 ++- 6 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/formatter/FormatterInformationLegalHelper.kt create mode 100644 Corona-Warn-App/src/main/res/layout/include_contact_form.xml diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/information/InformationLegalFragment.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/information/InformationLegalFragment.kt index 053d1bb2f..4d5b127d0 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/information/InformationLegalFragment.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/information/InformationLegalFragment.kt @@ -1,6 +1,7 @@ package de.rki.coronawarnapp.ui.information import android.os.Bundle +import android.text.method.LinkMovementMethod import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -37,6 +38,17 @@ class InformationLegalFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) setButtonOnClickListener() + setUpContactFormLinks() + } + + /** + * Make the links clickable + */ + private fun setUpContactFormLinks() { + binding.informationLegalContactForm.informationLegalContactForm + .movementMethod = LinkMovementMethod.getInstance() + binding.informationLegalContactForm.informationLegalContactFormNonEnDe + .movementMethod = LinkMovementMethod.getInstance() } override fun onResume() { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/formatter/FormatterInformationLegalHelper.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/formatter/FormatterInformationLegalHelper.kt new file mode 100644 index 000000000..37d044477 --- /dev/null +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/formatter/FormatterInformationLegalHelper.kt @@ -0,0 +1,34 @@ +@file:JvmName("FormatterInformationLegalHelper") + +package de.rki.coronawarnapp.util.formatter +import android.view.View +import java.util.Locale + +/** + * Language based format visibility + * + * @param defaultLanguageEnglishOrGerman + * @param isContactFormView + * @return + */ +fun formatVisibilityLanguageBased(defaultLanguageEnglishOrGerman: Boolean, isContactFormView: Boolean?): Int { + if (defaultLanguageEnglishOrGerman) { + return if (isContactFormView == true) { + View.VISIBLE + } else View.GONE + } + return if (isContactFormView == false) { + View.VISIBLE + } else View.GONE +} + +/** + * checks the default language of the device and formats the visibility + * Returns visibility value + * + * @param isContactFormView + * @return + */ +fun formatContactForm(isContactFormView: Boolean?): Int = + formatVisibilityLanguageBased(Locale.getDefault().language == Locale.ENGLISH.language || + Locale.getDefault().language == Locale.GERMAN.language, isContactFormView) diff --git a/Corona-Warn-App/src/main/res/layout/fragment_information_legal.xml b/Corona-Warn-App/src/main/res/layout/fragment_information_legal.xml index ceace17bf..0cbf75aee 100644 --- a/Corona-Warn-App/src/main/res/layout/fragment_information_legal.xml +++ b/Corona-Warn-App/src/main/res/layout/fragment_information_legal.xml @@ -105,6 +105,15 @@ app:layout_constraintStart_toEndOf="@+id/guideline_start" app:layout_constraintTop_toBottomOf="@+id/information_legal_headline_contact" /> + <include + android:id="@+id/information_legal_contact_form" + layout="@layout/include_contact_form" + android:layout_width="@dimen/match_constraint" + android:layout_height="wrap_content" + app:layout_constraintEnd_toStartOf="@+id/guideline_end" + app:layout_constraintStart_toEndOf="@+id/guideline_start" + app:layout_constraintTop_toBottomOf="@+id/information_legal_subtitle_contact" /> + <include android:id="@+id/information_legal_divider_taxid" layout="@layout/include_divider" @@ -113,7 +122,7 @@ android:layout_marginTop="@dimen/spacing_medium" app:layout_constraintEnd_toEndOf="@+id/guideline_end" app:layout_constraintStart_toStartOf="@+id/guideline_start" - app:layout_constraintTop_toBottomOf="@+id/information_legal_subtitle_contact" /> + app:layout_constraintTop_toBottomOf="@+id/information_legal_contact_form" /> <TextView android:id="@+id/information_legal_headline_taxid" diff --git a/Corona-Warn-App/src/main/res/layout/include_contact_form.xml b/Corona-Warn-App/src/main/res/layout/include_contact_form.xml new file mode 100644 index 000000000..3369e7d09 --- /dev/null +++ b/Corona-Warn-App/src/main/res/layout/include_contact_form.xml @@ -0,0 +1,53 @@ +<?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.FormatterInformationLegalHelper" /> + + <import type="de.rki.coronawarnapp.util.formatter.FormatterHelper" /> + </data> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="wrap_content"> + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + app:layout_constraintTop_toTopOf="parent"> + + <TextView + android:id="@+id/information_legal_contact_form" + style="@style/subtitle" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:clickable="true" + android:focusable="true" + android:linksClickable="true" + android:text="@string/information_legal_subtitle_contact_form" + android:textColorLink="@color/colorTextTint" + android:visibility="@{FormatterInformationLegalHelper.formatContactForm(true)}" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <TextView + android:id="@+id/information_legal_contact_form_non_en_de" + style="@style/subtitle" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:clickable="true" + android:focusable="true" + android:linksClickable="true" + android:text="@string/information_legal_subtitle_contact_form_non_en_de" + android:textColorLink="@color/colorTextTint" + android:visibility="@{FormatterInformationLegalHelper.formatContactForm(false)}" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/information_legal_contact_form" /> + + </androidx.constraintlayout.widget.ConstraintLayout> + </androidx.constraintlayout.widget.ConstraintLayout> + +</layout> \ No newline at end of file diff --git a/Corona-Warn-App/src/main/res/values-de/strings.xml b/Corona-Warn-App/src/main/res/values-de/strings.xml index aacf67310..90431f6e4 100644 --- a/Corona-Warn-App/src/main/res/values-de/strings.xml +++ b/Corona-Warn-App/src/main/res/values-de/strings.xml @@ -689,7 +689,11 @@ <!-- XHED: Headline for legal information page, contact section --> <string name="information_legal_headline_contact">"Kontakt"</string> <!-- YTXT: subtitle for legal information page, contact section --> - <string name="information_legal_subtitle_contact">"E-Mail: CoronaWarnApp@rki.de"<xliff:g id="line_break">"\n"</xliff:g>"Telefon: +49 30 18754 5100"</string> + <string name="information_legal_subtitle_contact">"E-Mail: CoronaWarnApp@rki.de"</string> + <!-- YTXT: subtitle for legal information page, open contact form --> + <string name="information_legal_subtitle_contact_form"><a href="https://www.rki.de/SharedDocs/Kontaktformulare/weitere/Corona-Warn-App/Corona-Warn-App_Integrator.html">Kontaktformular</a></string> + <!-- NOTR: subtitle for legal information page, open contact form for languages other than English and German --> + <string name="information_legal_subtitle_contact_form_non_en_de">Contact Form in <a href="https://www.rki.de/SharedDocs/Kontaktformulare/en/Kontaktformulare/weitere/Corona-Warn-App/Corona-Warn-App_Integrator.html">English</a> or <a href="https://www.rki.de/SharedDocs/Kontaktformulare/weitere/Corona-Warn-App/Corona-Warn-App_Integrator.html">German</a></string> <!-- XHED: Headline for legal information page, tax section --> <string name="information_legal_headline_taxid">"Umsatzsteueridentifikationsnummer"</string> <!-- YTXT: subtitle for legal information page, tax section --> diff --git a/Corona-Warn-App/src/main/res/values/strings.xml b/Corona-Warn-App/src/main/res/values/strings.xml index 0a2b46bee..2fd04e08a 100644 --- a/Corona-Warn-App/src/main/res/values/strings.xml +++ b/Corona-Warn-App/src/main/res/values/strings.xml @@ -691,7 +691,11 @@ <!-- XHED: Headline for legal information page, contact section --> <string name="information_legal_headline_contact">"Contact"</string> <!-- YTXT: subtitle for legal information page, contact section --> - <string name="information_legal_subtitle_contact">"E-Mail: CoronaWarnApp@rki.de"<xliff:g id="line_break">"\n"</xliff:g>"Telephone: +49 30 18754 5100"</string> + <string name="information_legal_subtitle_contact">"E-Mail: CoronaWarnApp@rki.de"</string> + <!-- YTXT: subtitle for legal information page, open contact form --> + <string name="information_legal_subtitle_contact_form"><a href="https://www.rki.de/SharedDocs/Kontaktformulare/en/Kontaktformulare/weitere/Corona-Warn-App/Corona-Warn-App_Integrator.html">Contact Form</a></string> + <!-- NOTR: subtitle for legal information page, open contact form for languages other than English and German --> + <string name="information_legal_subtitle_contact_form_non_en_de">Contact Form in <a href="https://www.rki.de/SharedDocs/Kontaktformulare/en/Kontaktformulare/weitere/Corona-Warn-App/Corona-Warn-App_Integrator.html">English</a> or <a href="https://www.rki.de/SharedDocs/Kontaktformulare/weitere/Corona-Warn-App/Corona-Warn-App_Integrator.html">German</a></string> <!-- XHED: Headline for legal information page, tax section --> <string name="information_legal_headline_taxid">"VAT identification number"</string> <!-- YTXT: subtitle for legal information page, tax section --> -- GitLab