Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: Constrain task layouts to avoid overlap. #2582

Merged
merged 9 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ground/src/main/res/layout/multiple_choice_task_frag.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
android:divider="@null"
android:dividerHeight="0dp"
android:orientation="vertical"
android:paddingBottom="10dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />

</layout>
5 changes: 3 additions & 2 deletions ground/src/main/res/layout/task_frag_with_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@
<FrameLayout
android:id="@+id/task_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/data_collection_header" />
app:layout_constraintTop_toBottomOf="@+id/data_collection_header"
app:layout_constraintBottom_toTopOf="@+id/action_buttons" />

<include
android:id="@+id/action_buttons"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.google.android.ground.ui.datacollection.tasks.date

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
Expand Down Expand Up @@ -76,10 +78,17 @@ class DateTaskFragmentTest : BaseTaskFragmentTest<DateTaskFragment, DateTaskView
@Test
fun testResponse_onUserInput() {
setupTaskFragment<DateTaskFragment>(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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -75,6 +77,12 @@ class TimeTaskFragmentTest : BaseTaskFragmentTest<TimeTaskFragment, TimeTaskView
@Test
fun testResponse_onUserInput() {
setupTaskFragment<TimeTaskFragment>(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())
Expand Down