Skip to content

Commit

Permalink
Merge pull request #6429 from grzesiek2010/COLLECT-6347
Browse files Browse the repository at this point in the history
Reworked the banner in Ready to send screen using card view
  • Loading branch information
grzesiek2010 authored Oct 1, 2024
2 parents 878fbb0 + 3e163b3 commit 9ac6831
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ package org.odk.collect.android.instancemanagement.send
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import android.widget.FrameLayout
import org.odk.collect.android.databinding.ReadyToSendBannerBinding
import org.odk.collect.shared.TimeInMs
import org.odk.collect.strings.R

class ReadyToSendBanner(context: Context, attrs: AttributeSet?) : ConstraintLayout(context, attrs) {
constructor(context: Context) : this(context, null)
class ReadyToSendBanner @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyle: Int = 0
) : FrameLayout(context, attrs, defStyle) {

private val binding = ReadyToSendBannerBinding.inflate(LayoutInflater.from(context), this, true)

Expand Down
3 changes: 3 additions & 0 deletions collect_app/src/main/res/layout/instance_uploader_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
android:id="@+id/ready_to_send_banner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/margin_standard"
android:layout_marginTop="@dimen/margin_extra_small"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
Expand All @@ -26,6 +28,7 @@
android:layout_height="0dp"
android:nestedScrollingEnabled="true"
android:divider="@drawable/list_item_divider"
android:layout_marginTop="@dimen/margin_extra_small"
app:layout_constraintBottom_toTopOf="@id/buttonholder"
app:layout_constraintTop_toBottomOf="@id/ready_to_send_banner" />

Expand Down
79 changes: 45 additions & 34 deletions collect_app/src/main/res/layout/ready_to_send_banner.xml
Original file line number Diff line number Diff line change
@@ -1,46 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout 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:id="@+id/banner"
android:background="?colorSurface"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?colorSurfaceContainerLow"
android:paddingVertical="@dimen/margin_standard"
android:visibility="gone"
tools:visibility="visible">

<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_large"
app:srcCompat="@drawable/ic_send_24"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="?colorPrimary"/>
<com.google.android.material.card.MaterialCardView
style="@style/Widget.Material3.CardView.Filled"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<com.google.android.material.textview.MaterialTextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_large"
android:layout_marginEnd="@dimen/margin_standard"
android:textAppearance="?textAppearanceTitleMedium"
android:textColor="?colorPrimary"
app:layout_constraintStart_toEndOf="@id/icon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/icon"
tools:text="Last sent: 2 days ago"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="@dimen/margin_standard">

<com.google.android.material.textview.MaterialTextView
android:id="@+id/subtext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?textAppearanceBodyMedium"
app:layout_constraintStart_toStartOf="@id/title"
app:layout_constraintEnd_toEndOf="@id/title"
app:layout_constraintTop_toBottomOf="@id/title"
tools:text="4 forms ready to send"/>
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_standard"
app:srcCompat="@drawable/ic_send_24"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tint="?colorPrimary"/>

</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_standard"
android:layout_marginEnd="@dimen/margin_standard"
android:textAppearance="?textAppearanceTitleMedium"
android:textColor="?colorPrimary"
app:layout_constraintStart_toEndOf="@id/icon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/icon"
tools:text="Last sent: 2 days ago"/>

<com.google.android.material.textview.MaterialTextView
android:id="@+id/subtext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?textAppearanceBodyMedium"
app:layout_constraintStart_toStartOf="@id/title"
app:layout_constraintEnd_toEndOf="@id/title"
app:layout_constraintTop_toBottomOf="@id/title"
tools:text="4 forms ready to send"/>

</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</FrameLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.odk.collect.android.instancemanagement.send

import android.app.Application
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import android.widget.FrameLayout
import androidx.test.core.app.ApplicationProvider
import androidx.test.espresso.matcher.ViewMatchers.assertThat
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand All @@ -27,7 +27,7 @@ class ReadyToSendBannerTest {
it.setData(data)
}

assertThat(view.findViewById<ConstraintLayout>(R.id.banner).visibility, equalTo(View.GONE))
assertThat(view.findViewById<FrameLayout>(R.id.banner).visibility, equalTo(View.GONE))
}

@Test
Expand All @@ -37,12 +37,12 @@ class ReadyToSendBannerTest {
it.setData(data)
}

assertThat(view.findViewById<ConstraintLayout>(R.id.banner).visibility, equalTo(View.GONE))
assertThat(view.findViewById<FrameLayout>(R.id.banner).visibility, equalTo(View.GONE))

data = ReadyToSendViewModel.Data(1, 1, 0)
view.setData(data)

assertThat(view.findViewById<ConstraintLayout>(R.id.banner).visibility, equalTo(View.VISIBLE))
assertThat(view.findViewById<FrameLayout>(R.id.banner).visibility, equalTo(View.VISIBLE))
}

@Test
Expand All @@ -52,12 +52,12 @@ class ReadyToSendBannerTest {
it.setData(data)
}

assertThat(view.findViewById<ConstraintLayout>(R.id.banner).visibility, equalTo(View.VISIBLE))
assertThat(view.findViewById<FrameLayout>(R.id.banner).visibility, equalTo(View.VISIBLE))

data = ReadyToSendViewModel.Data(0, 0, 0)
view.setData(data)

assertThat(view.findViewById<ConstraintLayout>(R.id.banner).visibility, equalTo(View.GONE))
assertThat(view.findViewById<FrameLayout>(R.id.banner).visibility, equalTo(View.GONE))
}

@Test
Expand All @@ -67,7 +67,7 @@ class ReadyToSendBannerTest {
it.setData(data)
}

assertThat(view.findViewById<ConstraintLayout>(R.id.banner).visibility, equalTo(View.GONE))
assertThat(view.findViewById<FrameLayout>(R.id.banner).visibility, equalTo(View.GONE))
}

@Test
Expand All @@ -77,7 +77,7 @@ class ReadyToSendBannerTest {
it.setData(data)
}

assertThat(view.findViewById<ConstraintLayout>(R.id.banner).visibility, equalTo(View.GONE))
assertThat(view.findViewById<FrameLayout>(R.id.banner).visibility, equalTo(View.GONE))
}

@Test
Expand All @@ -88,7 +88,7 @@ class ReadyToSendBannerTest {
}

assertThat(
view.findViewById<ConstraintLayout>(R.id.banner).visibility,
view.findViewById<FrameLayout>(R.id.banner).visibility,
equalTo(View.VISIBLE)
)
}
Expand Down

0 comments on commit 9ac6831

Please sign in to comment.