From fd197fc8a5fc28ba7fa9334b8551f9525863c253 Mon Sep 17 00:00:00 2001 From: Scott Olsen Date: Thu, 1 Aug 2024 12:20:29 -0400 Subject: [PATCH] UI: Constrain task layouts to avoid overlap. (#2582) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * UI: Constrain task layouts to avoid overlap. Fixes #2516 by constraining our task container to the position of the action button dock. This ensures long multiple choice tasks aren't covered by the action buttons—the scroll region is limited to viewable area above the action button drawer. * UI: Fix date/time task tests The previous change (setting the task container layout to 0dp) causes espresso actions to fail in our tests on these views. Normally, android computes the height correctly given view constraints, but this doesn't appear to take place in our tests. For now, fix this by forcing the view to have a height of 1, so that the action may be performed. * addedd test cases (#2591) * Create codecov.yml * Update codecov.yml * Upgrade versioner plugin (#2595) * Upgrade versioner plugin * Fix gitversioner path * Reenable codecov reports and PR comments (#2593) * Rename unit test target * Always generate code coverage report * Run tests against devDebug * Update path of report * Upgrade versioner version * Upgrade versioner plugin * Fix gitversioner path * Add unit tests for AboutFragment (#2587) --------- Co-authored-by: Akshay Nandwana Co-authored-by: Gino Miceli <228050+gino-m@users.noreply.github.com> --- .../src/main/res/layout/multiple_choice_task_frag.xml | 1 + ground/src/main/res/layout/task_frag_with_header.xml | 5 +++-- .../datacollection/tasks/date/DateTaskFragmentTest.kt | 11 ++++++++++- .../datacollection/tasks/time/TimeTaskFragmentTest.kt | 8 ++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ground/src/main/res/layout/multiple_choice_task_frag.xml b/ground/src/main/res/layout/multiple_choice_task_frag.xml index 8a7ac51dd5..2f1f95cba9 100644 --- a/ground/src/main/res/layout/multiple_choice_task_frag.xml +++ b/ground/src/main/res/layout/multiple_choice_task_frag.xml @@ -26,6 +26,7 @@ android:divider="@null" android:dividerHeight="0dp" android:orientation="vertical" + android:paddingBottom="10dp" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> \ No newline at end of file diff --git a/ground/src/main/res/layout/task_frag_with_header.xml b/ground/src/main/res/layout/task_frag_with_header.xml index 4153a05204..76cf0c8203 100644 --- a/ground/src/main/res/layout/task_frag_with_header.xml +++ b/ground/src/main/res/layout/task_frag_with_header.xml @@ -47,11 +47,12 @@ + app:layout_constraintTop_toBottomOf="@+id/data_collection_header" + app:layout_constraintBottom_toTopOf="@+id/action_buttons" /> (job, task) + // NOTE: The task container layout is given 0dp height to allow Android's constraint system to + // determine the appropriate height. Unfortunately, Espresso does not perform actions on views + // with height zero, and it doesn't seem to repro constraint calculations. Force the view to + // have a height of 1 to ensure the action performed below actually takes place. + val view: View? = fragment.view?.findViewById(R.id.task_container) + view?.layoutParams = ViewGroup.LayoutParams(0, 1) assertThat(fragment.getDatePickerDialog()).isNull() onView(withId(R.id.user_response_text)).perform(click()) - assertThat(fragment.getDatePickerDialog()!!.isShowing).isTrue() + assertThat(fragment.getDatePickerDialog()).isNotNull() + assertThat(fragment.getDatePickerDialog()?.isShowing).isTrue() } @Test diff --git a/ground/src/test/java/com/google/android/ground/ui/datacollection/tasks/time/TimeTaskFragmentTest.kt b/ground/src/test/java/com/google/android/ground/ui/datacollection/tasks/time/TimeTaskFragmentTest.kt index 56a48bbcae..54858cb349 100644 --- a/ground/src/test/java/com/google/android/ground/ui/datacollection/tasks/time/TimeTaskFragmentTest.kt +++ b/ground/src/test/java/com/google/android/ground/ui/datacollection/tasks/time/TimeTaskFragmentTest.kt @@ -15,6 +15,8 @@ */ package com.google.android.ground.ui.datacollection.tasks.time +import android.view.View +import android.view.ViewGroup import androidx.test.espresso.Espresso.onView import androidx.test.espresso.action.ViewActions.click import androidx.test.espresso.assertion.ViewAssertions.matches @@ -75,6 +77,12 @@ class TimeTaskFragmentTest : BaseTaskFragmentTest(job, task) + // NOTE: The task container layout is given 0dp height to allow Android's constraint system to + // determine the appropriate height. Unfortunately, Espresso does not perform actions on views + // with height zero, and it doesn't seem to repro constraint calculations. Force the view to + // have a height of 1 to ensure the action performed below actually takes place. + val view: View? = fragment.view?.findViewById(R.id.task_container) + view?.layoutParams = ViewGroup.LayoutParams(0, 1) assertThat(fragment.getTimePickerDialog()).isNull() onView(withId(R.id.user_response_text)).perform(click())