From fdf748d9b1c6f7d5cd3c60c031c6eaae45e117b1 Mon Sep 17 00:00:00 2001
From: axelherbstreith <75120552+axelherbstreith@users.noreply.github.com>
Date: Mon, 25 Jan 2021 17:56:33 +0100
Subject: [PATCH] Buttons on Symptom-Screens scroll with the screen
 (EXPOSUREAPP-4595) #2178

* mounted navigation button to bottom on symptom screen

* mounted navigation button on symptom calender screen to bottom

* aligned button margins

* simplified margins

* removed unused code

* fixed instrumentation tests

Co-authored-by: harambasicluka <64483219+harambasicluka@users.noreply.github.com>
Co-authored-by: Ralf Gehrer <ralfgehrer@users.noreply.github.com>
---
 .../SubmissionSymptomIntroFragmentTest.kt     |  4 +-
 .../fragment_submission_symptom_calendar.xml  | 44 ++++++++++++------
 .../fragment_submission_symptom_intro.xml     | 45 ++++++++++++-------
 3 files changed, 61 insertions(+), 32 deletions(-)

diff --git a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionSymptomIntroFragmentTest.kt b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionSymptomIntroFragmentTest.kt
index c106e546b..abd982460 100644
--- a/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionSymptomIntroFragmentTest.kt
+++ b/Corona-Warn-App/src/androidTest/java/de/rki/coronawarnapp/ui/submission/SubmissionSymptomIntroFragmentTest.kt
@@ -76,9 +76,7 @@ class SubmissionSymptomIntroFragmentTest : BaseUITest() {
     fun testSymptomNextClicked() {
         val scenario = launchFragmentInContainer<SubmissionSymptomIntroductionFragment>()
         onView(withId(R.id.symptom_button_next))
-            .perform(scrollTo())
             .perform(click())
-
         // TODO verify result
     }
 
@@ -86,7 +84,7 @@ class SubmissionSymptomIntroFragmentTest : BaseUITest() {
     @Screenshot
     fun capture_fragment() {
         captureScreenshot<SubmissionSymptomIntroductionFragment>()
-        onView(withId(R.id.symptom_button_next))
+        onView(withId(R.id.target_button_verify))
             .perform(scrollTo())
         Thread.sleep(SCREENSHOT_DELAY_TIME)
         Screengrab.screenshot(SubmissionSymptomIntroductionFragment::class.simpleName.plus("2"))
diff --git a/Corona-Warn-App/src/main/res/layout/fragment_submission_symptom_calendar.xml b/Corona-Warn-App/src/main/res/layout/fragment_submission_symptom_calendar.xml
index f58fb7a89..d21f46391 100644
--- a/Corona-Warn-App/src/main/res/layout/fragment_submission_symptom_calendar.xml
+++ b/Corona-Warn-App/src/main/res/layout/fragment_submission_symptom_calendar.xml
@@ -7,22 +7,31 @@
         <import type="de.rki.coronawarnapp.submission.Symptoms.StartOf" />
     </data>
 
-    <LinearLayout
+    <androidx.constraintlayout.widget.ConstraintLayout
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:orientation="vertical">
+        android:layout_height="match_parent"
+        android:fillViewport="true">
 
         <include
             android:id="@+id/submission_symptom_calendar_header"
             layout="@layout/include_header"
             android:layout_width="match_parent"
+            app:layout_constraintBottom_toTopOf="@+id/scrollView"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent"
             android:layout_height="wrap_content"
             app:icon="@{@drawable/ic_close}"
             app:title="@{@string/submission_symptom_calendar_title}" />
 
         <ScrollView
-            android:layout_width="match_parent"
-            android:layout_height="match_parent">
+            android:id="@+id/scrollView"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            app:layout_constraintBottom_toTopOf="@+id/symptom_button_next"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/submission_symptom_calendar_header">
 
             <LinearLayout
                 android:layout_width="match_parent"
@@ -95,16 +104,23 @@
                     android:enabled="true"
                     android:text="@string/submission_symptom_verify" />
 
-                <Button
-                    android:id="@+id/symptom_button_next"
-                    style="@style/buttonPrimary"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:layout_marginBottom="@dimen/spacing_small"
-                    android:text="@string/submission_done_button_done" />
-
             </LinearLayout>
 
         </ScrollView>
-    </LinearLayout>
+
+        <Button
+            android:id="@+id/symptom_button_next"
+            style="@style/buttonPrimary"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginHorizontal="@dimen/spacing_normal"
+            android:layout_marginVertical="@dimen/spacing_small"
+            android:layout_marginBottom="@dimen/spacing_small"
+            android:text="@string/submission_done_button_done"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@id/scrollView"/>
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
 </layout>
diff --git a/Corona-Warn-App/src/main/res/layout/fragment_submission_symptom_intro.xml b/Corona-Warn-App/src/main/res/layout/fragment_submission_symptom_intro.xml
index fd16d800a..a2d759634 100644
--- a/Corona-Warn-App/src/main/res/layout/fragment_submission_symptom_intro.xml
+++ b/Corona-Warn-App/src/main/res/layout/fragment_submission_symptom_intro.xml
@@ -1,10 +1,12 @@
 <?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">
-    <LinearLayout
+
+
+    <androidx.constraintlayout.widget.ConstraintLayout
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:orientation="vertical">
+        android:layout_height="match_parent"
+        android:fillViewport="true">
 
         <include
             android:id="@+id/submission_symptom_header"
@@ -12,11 +14,20 @@
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             app:icon="@{@drawable/ic_close}"
+            app:layout_constraintBottom_toTopOf="@+id/scrollView"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent"
             app:title="@{@string/submission_symptom_title}" />
 
         <ScrollView
-            android:layout_width="match_parent"
-            android:layout_height="match_parent">
+            android:id="@+id/scrollView"
+            android:layout_width="0dp"
+            android:layout_height="0dp"
+            app:layout_constraintBottom_toTopOf="@+id/symptom_button_next"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@+id/submission_symptom_header">
 
             <LinearLayout
                 android:id="@+id/submission_symptom_container"
@@ -81,17 +92,21 @@
                     android:enabled="true"
                     android:text="@string/submission_symptom_no_information_button" />
 
-                <Button
-                    android:id="@+id/symptom_button_next"
-                    style="@style/buttonPrimary"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:layout_marginTop="@dimen/spacing_small"
-                    android:layout_marginBottom="@dimen/spacing_small"
-                    android:text="@string/submission_symptom_further_button" />
-
             </LinearLayout>
 
         </ScrollView>
-    </LinearLayout>
+
+        <Button
+            android:id="@+id/symptom_button_next"
+            style="@style/buttonPrimary"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginHorizontal="@dimen/spacing_normal"
+            android:layout_marginVertical="@dimen/spacing_small"
+            android:text="@string/submission_symptom_further_button"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toBottomOf="@id/scrollView" />
+    </androidx.constraintlayout.widget.ConstraintLayout>
 </layout>
-- 
GitLab