Skip to content
New issue

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

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

Already on GitHub? # to your account

Reworked the banner in Ready to send screen using card view #6429

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
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_small"
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_small"
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_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"/>

<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
25 changes: 18 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
#You can override this in ~/.gradle/gradle.properties
android.useAndroidX=true
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. For more details, visit
# https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
# org.gradle.parallel=true
#Thu Sep 26 09:59:52 CEST 2024
android.enableJetifier=true
#https://issuetracker.google.com/issues/283715193
android.jetifier.ignorelist = jackson-core
org.gradle.jvmargs=-Xmx1536m
android.injected.androidTest.leaveApksInstalledAfterRun=true
android.jetifier.ignorelist=jackson-core
android.nonTransitiveRClass=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
org.gradle.parallel=true
test.heap.max=1g
android.nonTransitiveRClass=true
android.injected.androidTest.leaveApksInstalledAfterRun=true