-
-
Notifications
You must be signed in to change notification settings - Fork 49
CCCT-2535 Show Payment Unit Cards On The Delivery Visits Tab #3883
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7bd8513
Show payment unit cards on the delivery visits tab [AI]
Jignesh-dimagi 93d9a05
Add Robolectric coverage for the delivery visits tab [AI]
Jignesh-dimagi e59c3e4
Made color and dimen changes as per feedback
Jignesh-dimagi 1ffdaf5
Renaming as per comment
Jignesh-dimagi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
|
conroy-ricketts marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| xmlns:tools="http://schemas.android.com/tools" | ||
| android:id="@+id/rootView" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:layout_margin="@dimen/connect_space_md" | ||
| android:clickable="true" | ||
| android:focusable="true" | ||
| android:foreground="?android:attr/selectableItemBackground" | ||
| app:cardBackgroundColor="?attr/colorSurface" | ||
| app:cardCornerRadius="@dimen/connect_radius_lg" | ||
| app:cardElevation="10dp"> | ||
|
|
||
| <androidx.constraintlayout.widget.ConstraintLayout | ||
| android:layout_width="match_parent" | ||
| android:layout_height="wrap_content" | ||
| android:padding="@dimen/connect_space_lg"> | ||
|
|
||
| <TextView | ||
| android:id="@+id/tvDeliveryTitle" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:textColor="?attr/connectOnSurfaceEmphasis" | ||
| android:textSize="@dimen/connect_text_body" | ||
| android:textStyle="bold" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toTopOf="parent" | ||
| tools:text="Household visit" /> | ||
|
|
||
| <ImageView | ||
| android:id="@+id/imgApproved" | ||
| android:layout_width="13dp" | ||
| android:layout_height="13dp" | ||
| android:layout_marginStart="@dimen/connect_space_xs" | ||
| android:layout_marginTop="@dimen/connect_space_sm" | ||
| android:contentDescription="@null" | ||
| android:src="@drawable/ic_connect_thumb_up" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toBottomOf="@id/tvDeliveryTitle" /> | ||
|
|
||
| <LinearLayout | ||
| android:id="@+id/approvedStats" | ||
| android:layout_width="0dp" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginStart="@dimen/connect_space_sm" | ||
| android:orientation="vertical" | ||
| app:layout_constraintEnd_toStartOf="@id/centerGuideline" | ||
| app:layout_constraintStart_toEndOf="@id/imgApproved" | ||
| app:layout_constraintTop_toTopOf="@id/imgApproved"> | ||
|
|
||
| <TextView | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:text="@string/connect_results_summary_approved" | ||
| android:textColor="?attr/connectOnSurfaceMuted" | ||
| android:textSize="@dimen/connect_text_caption" | ||
| android:textStyle="bold" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/tvApproved" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="@dimen/connect_space_xs" | ||
| android:textColor="?attr/connectStatusPositive" | ||
| android:textSize="@dimen/connect_text_caption" | ||
| android:textStyle="bold" | ||
| tools:text="10" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/tvDeliveryTotalAmount" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="@dimen/connect_space_xs" | ||
| android:textColor="?attr/connectStatusPositive" | ||
| android:textSize="@dimen/connect_text_caption" | ||
| android:textStyle="bold" | ||
| tools:text="10,000 MWK" /> | ||
| </LinearLayout> | ||
|
|
||
| <ImageView | ||
| android:id="@+id/imgRemaining" | ||
| android:layout_width="13dp" | ||
| android:layout_height="13dp" | ||
| android:layout_marginStart="@dimen/connect_space_xs" | ||
| android:contentDescription="@null" | ||
| android:src="@drawable/ic_connect_delivery_check_circle" | ||
| app:layout_constraintStart_toStartOf="@id/centerGuideline" | ||
| app:layout_constraintTop_toTopOf="@id/imgApproved" /> | ||
|
|
||
| <LinearLayout | ||
| android:id="@+id/remainingStats" | ||
| android:layout_width="0dp" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginStart="@dimen/connect_space_sm" | ||
| android:orientation="vertical" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintStart_toEndOf="@id/imgRemaining" | ||
| app:layout_constraintTop_toTopOf="@id/imgRemaining"> | ||
|
|
||
| <TextView | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:text="@string/connect_results_summary_remaining" | ||
| android:textColor="?attr/connectOnSurfaceMuted" | ||
| android:textSize="@dimen/connect_text_caption" | ||
| android:textStyle="bold" /> | ||
|
|
||
| <TextView | ||
| android:id="@+id/tvRemaining" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:layout_marginTop="@dimen/connect_space_xs" | ||
| android:textColor="?attr/colorPrimary" | ||
| android:textSize="@dimen/connect_text_caption" | ||
| android:textStyle="bold" | ||
| tools:text="6 in 3 days" /> | ||
| </LinearLayout> | ||
|
|
||
| <androidx.constraintlayout.widget.Barrier | ||
| android:id="@+id/statsBottomBarrier" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| app:barrierDirection="bottom" | ||
| app:constraint_referenced_ids="approvedStats, remainingStats" /> | ||
|
|
||
| <org.commcare.views.connect.LinearProgressBar | ||
| android:id="@+id/linearProgressBar" | ||
| android:layout_width="0dp" | ||
| android:layout_height="@dimen/connect_progress_card_bar_height" | ||
| android:layout_marginTop="@dimen/connect_space_sm" | ||
| app:layout_constraintEnd_toStartOf="@id/progressEndGuideline" | ||
| app:layout_constraintStart_toStartOf="parent" | ||
| app:layout_constraintTop_toBottomOf="@id/statsBottomBarrier" /> | ||
|
|
||
| <ImageView | ||
| android:id="@+id/imgArrowForward" | ||
| android:layout_width="15dp" | ||
| android:layout_height="15dp" | ||
| android:layout_marginEnd="@dimen/connect_space_sm" | ||
| android:contentDescription="@null" | ||
| android:src="@drawable/ic_connect_arrow_forward" | ||
| app:layout_constraintBottom_toBottomOf="parent" | ||
| app:layout_constraintEnd_toEndOf="parent" | ||
| app:layout_constraintTop_toBottomOf="@id/linearProgressBar" /> | ||
|
|
||
| <androidx.constraintlayout.widget.Guideline | ||
| android:id="@+id/centerGuideline" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:orientation="vertical" | ||
| app:layout_constraintGuide_percent="0.5" /> | ||
|
|
||
| <androidx.constraintlayout.widget.Guideline | ||
| android:id="@+id/progressEndGuideline" | ||
| android:layout_width="wrap_content" | ||
| android:layout_height="wrap_content" | ||
| android:orientation="vertical" | ||
| app:layout_constraintGuide_percent="0.75" /> | ||
| </androidx.constraintlayout.widget.ConstraintLayout> | ||
| </androidx.cardview.widget.CardView> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,10 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
| <androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" | ||
| xmlns:tools="http://schemas.android.com/tools" | ||
| android:id="@+id/rvPaymentUnits" | ||
| android:layout_width="match_parent" | ||
| android:layout_height="match_parent" | ||
| android:background="@color/connect_background_color" /> | ||
| android:background="@color/connect_background_color" | ||
| android:clipToPadding="false" | ||
| android:paddingVertical="6dp" | ||
| tools:listitem="@layout/connect_delivery_progress_item" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
app/src/org/commcare/adapters/ConnectDeliveryPaymentUnitAdapter.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| package org.commcare.adapters | ||
|
|
||
| import android.content.Context | ||
| import android.view.LayoutInflater | ||
| import android.view.ViewGroup | ||
| import androidx.recyclerview.widget.RecyclerView | ||
| import com.google.android.material.color.MaterialColors | ||
| import org.commcare.dalvik.R | ||
| import org.commcare.dalvik.databinding.ConnectDeliveryProgressItemBinding | ||
| import org.commcare.models.connect.ConnectDeliveryDetails | ||
|
|
||
| class ConnectDeliveryPaymentUnitAdapter( | ||
| private val onPaymentUnitClicked: (ConnectDeliveryDetails) -> Unit, | ||
| ) : RecyclerView.Adapter<ConnectDeliveryPaymentUnitAdapter.PaymentUnitViewHolder>() { | ||
| private val paymentUnits = mutableListOf<ConnectDeliveryDetails>() | ||
|
|
||
| class PaymentUnitViewHolder( | ||
| val binding: ConnectDeliveryProgressItemBinding, | ||
| ) : RecyclerView.ViewHolder(binding.root) | ||
|
|
||
| override fun onCreateViewHolder( | ||
| parent: ViewGroup, | ||
| viewType: Int, | ||
| ): PaymentUnitViewHolder { | ||
| val binding = | ||
| ConnectDeliveryProgressItemBinding.inflate( | ||
| LayoutInflater.from(parent.context), | ||
| parent, | ||
| false, | ||
| ) | ||
| return PaymentUnitViewHolder(binding) | ||
| } | ||
|
|
||
| override fun onBindViewHolder( | ||
| holder: PaymentUnitViewHolder, | ||
| position: Int, | ||
| ) { | ||
| val details = paymentUnits[position] | ||
| val context = holder.itemView.context | ||
| with(holder.binding) { | ||
| linearProgressBar.setProgress(details.approvedPercentage.toFloat()) | ||
| linearProgressBar.setProgressColor( | ||
| MaterialColors.getColor(holder.itemView, R.attr.connectStatusPositive), | ||
| ) | ||
| tvDeliveryTitle.text = details.deliveryName | ||
| tvApproved.text = details.approvedCount.toString() | ||
| tvDeliveryTotalAmount.text = details.totalAmount | ||
| tvRemaining.text = remainingText(context, details) | ||
| rootView.setOnClickListener { onPaymentUnitClicked(details) } | ||
| } | ||
| } | ||
|
|
||
| private fun remainingText( | ||
| context: Context, | ||
| details: ConnectDeliveryDetails, | ||
| ): String { | ||
| if (details.pendingCount <= 0) { | ||
| return context.getString(R.string.connect_results_summary_visits_done) | ||
| } | ||
| return when (details.remainingDays) { | ||
| 0 -> { | ||
| context.getString(R.string.connect_results_summary_days_over) | ||
| } | ||
|
|
||
| 1 -> { | ||
| context.getString(R.string.connect_results_summary_remaining_today, details.pendingCount) | ||
| } | ||
|
|
||
| 2 -> { | ||
| context.getString(R.string.connect_results_summary_remaining_tomorrow, details.pendingCount) | ||
| } | ||
|
|
||
| else -> { | ||
| context.getString( | ||
| R.string.connect_results_summary_remaining_days, | ||
| details.pendingCount, | ||
| details.remainingDays, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| override fun getItemCount(): Int = paymentUnits.size | ||
|
|
||
| fun updateData(newData: List<ConnectDeliveryDetails>) { | ||
| paymentUnits.clear() | ||
| paymentUnits.addAll(newData) | ||
| notifyDataSetChanged() | ||
|
conroy-ricketts marked this conversation as resolved.
|
||
| } | ||
| } | ||
|
conroy-ricketts marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.