Skip to content

Commit

Permalink
fix (OONI Run v2) : Hidden ExpandableListView section (#706)
Browse files Browse the repository at this point in the history
## Proposed Changes

- Update layouts to properly show `ExpandableListView` in
`ResultDetailActivity` and `RunTestsActivity`
  • Loading branch information
aanorbel authored Mar 26, 2024
1 parent e943572 commit 7c9876c
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,16 @@ class ResultDetailExpandableListAdapter(
is Measurement -> bindMeasurement(groupItem, root)

else -> {
root.findViewById<TextView>(R.id.text).text = groupItem.toString()
val groupMeasurement = (items[groupPosition] as MeasurementGroup)

groupMeasurement.measurements.firstOrNull()?.let {
root.findViewById<TextView>(R.id.text).setText(it.getTest().labelResId)
} ?: run {
root.findViewById<TextView>(R.id.text).text = groupMeasurement.title
}
root.findViewById<TextView>(R.id.indicator).apply {
visibility = View.VISIBLE
text = "${(items[groupPosition] as MeasurementGroup).measurements.size} Inputs"
text = "${groupMeasurement.measurements.size} Inputs"
setCompoundDrawablesRelativeWithIntrinsicBounds(
null,
null,
Expand All @@ -115,6 +121,7 @@ class ResultDetailExpandableListAdapter(
) {
view.tag = measurement
view.setOnClickListener(onClickListener)
view.findViewById<TextView>(R.id.indicator).visibility = View.GONE
view.findViewById<TextView>(R.id.text).also { textView ->

val test: AbstractTest = measurement.getTest()
Expand Down
129 changes: 67 additions & 62 deletions app/src/main/res/layout/activity_result_detail.xml
Original file line number Diff line number Diff line change
@@ -1,73 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.ResultDetailActivity">

<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:titleEnabled="false"
app:layout_scrollFlags="scroll|snap|exitUntilCollapsed">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|snap|exitUntilCollapsed"
app:titleEnabled="false">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize"
android:orientation="vertical"
app:layout_collapseMode="parallax">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize"
android:orientation="vertical"
app:layout_collapseMode="parallax">

<androidx.viewpager2.widget.ViewPager2
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="90dp" />
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="90dp" />

<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:tabGravity="center"
app:tabIndicatorHeight="0dp"
app:tabPadding="0dp"
app:tabSelectedTextColor="@android:color/white"
app:tabTextAppearance="@style/TextAppearance.AppCompat.Medium"
app:tabTextColor="#55ffffff" />
</LinearLayout>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
app:tabGravity="center"
app:tabIndicatorHeight="0dp"
app:tabPadding="0dp"
app:tabSelectedTextColor="@android:color/white"
app:tabTextAppearance="@style/TextAppearance.AppCompat.Medium"
app:tabTextColor="#55ffffff" />
</LinearLayout>

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_marginEnd="-18dp"
android:layout_marginBottom="-18dp"
android:src="@drawable/ooni_bw" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_marginEnd="-18dp"
android:layout_marginBottom="-18dp"
android:src="@drawable/ooni_bw" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>

<ExpandableListView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:groupIndicator="@android:color/transparent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

<View
android:id="@+id/snackbarAnchor"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout> <!-- app:layout_scrollFlags="scroll|exitUntilCollapsed|snap" -->
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<org.openobservatory.ooniprobe.common.views.CustomExpandableListView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:groupIndicator="@android:color/transparent"
android:nestedScrollingEnabled="true" />
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
177 changes: 100 additions & 77 deletions app/src/main/res/layout/activity_run_tests.xml
Original file line number Diff line number Diff line change
@@ -1,90 +1,113 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.runtests.RunTestsActivity">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.runtests.RunTestsActivity">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_white"
app:layout_constraintTop_toTopOf="parent"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp" />
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color_white"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp"
app:layout_constraintTop_toTopOf="parent" />

<LinearLayout
android:id="@+id/control_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginStart="@dimen/item_padding_large"
android:paddingTop="@dimen/item_padding_small"
android:paddingBottom="@dimen/item_padding_large"
app:layout_constraintTop_toBottomOf="@id/toolbar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<LinearLayout
android:id="@+id/control_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/item_padding_large"
android:orientation="vertical"
android:paddingTop="@dimen/item_padding_small"
android:paddingBottom="@dimen/item_padding_large"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select the tests to run"
android:paddingBottom="@dimen/item_padding_small"
style="?attr/textAppearanceHeadline6"/>
<TextView
style="?attr/textAppearanceHeadline6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/item_padding_small"
android:text="Select the tests to run" />

<Button
android:id="@+id/select_all"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select all tests"
android:textAllCaps="false"
app:cornerRadius="24dp"
app:rippleColor="@color/ripple_material_dark"
app:strokeColor="@color/color_base" />
<Button
android:id="@+id/select_all"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select all tests"
android:textAllCaps="false"
app:cornerRadius="24dp"
app:rippleColor="@color/ripple_material_dark"
app:strokeColor="@color/color_base" />

<Button
android:id="@+id/select_none"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Deselect all tests"
android:textAllCaps="false"
app:cornerRadius="24dp"
app:rippleColor="@color/ripple_material_dark"
app:strokeColor="@color/color_base" />
<Button
android:id="@+id/select_none"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Deselect all tests"
android:textAllCaps="false"
app:cornerRadius="24dp"
app:rippleColor="@color/ripple_material_dark"
app:strokeColor="@color/color_base" />

</LinearLayout>
</LinearLayout>

<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:fillViewport="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/control_layout">

<ExpandableListView
android:id="@+id/expandable_list_view"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:groupIndicator="@null"
android:childDivider="@android:color/transparent"
android:divider="@android:color/transparent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/control_layout"
app:layout_constraintBottom_toBottomOf="parent"
tools:listitem="@layout/run_tests_group_list_item" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/fab_run_tests"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Run Tests"
android:layout_marginBottom="@dimen/item_padding_large"
android:backgroundTint="@color/color_base"
android:textColor="@android:color/white"
android:textAllCaps="false"
app:icon="@drawable/outline_timer"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:iconTint="@android:color/white"/>
<org.openobservatory.ooniprobe.common.views.CustomExpandableListView
android:id="@+id/expandable_list_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:childDivider="@android:color/transparent"
android:divider="@android:color/transparent"
android:groupIndicator="@null"
android:nestedScrollingEnabled="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent"
app:layout_constraintBottom_toTopOf="@id/spacer"
tools:listitem="@layout/run_tests_group_list_item" />

<View
android:id="@+id/spacer"
android:layout_width="match_parent"
android:layout_height="80dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/expandable_list_view" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>

<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/fab_run_tests"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/item_padding_large"
android:backgroundTint="@color/color_base"
android:text="Run Tests"
android:textAllCaps="false"
android:textColor="@android:color/white"
app:icon="@drawable/outline_timer"
app:iconTint="@android:color/white"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 7c9876c

Please sign in to comment.