Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,10 @@ internal class DefaultUPIDelegate(
environment: Environment,
selectedUPIIntentItem: UPIIntentItem?,
): List<UPIIntentItem> {
val paymentApps = upiApps.mapToPaymentApp(
return upiApps.mapToPaymentApp(
environment = environment,
selectedAppId = (selectedUPIIntentItem as? UPIIntentItem.PaymentApp)?.id,
)

val genericApp = UPIIntentItem.GenericApp(
isSelected = selectedUPIIntentItem is UPIIntentItem.GenericApp,
)

return mutableListOf<UPIIntentItem>().apply {
addAll(paymentApps)
add(genericApp)
}
}

private fun validateVirtualPaymentAddress(virtualPaymentAddress: String): FieldState<String> =
Expand Down Expand Up @@ -230,10 +221,6 @@ internal class DefaultUPIDelegate(
PaymentMethodTypes.UPI_INTENT
}

is UPIIntentItem.GenericApp -> {
PaymentMethodTypes.UPI_INTENT
}

null -> null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,4 @@ internal sealed class UPIIntentItem {

override fun getChangePayload(newItem: UPIIntentItem) = null
}

data class GenericApp(
override val isSelected: Boolean = false
) : UPIIntentItem() {
override fun areItemsTheSame(newItem: UPIIntentItem) = newItem is GenericApp
override fun areContentsTheSame(newItem: UPIIntentItem) =
newItem is GenericApp &&
this == newItem

override fun getChangePayload(newItem: UPIIntentItem) = null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ internal class UPIOutputData(
get() = when (selectedMode) {
UPISelectedMode.INTENT -> {
when (selectedUPIIntentItem) {
is UPIIntentItem.PaymentApp,
is UPIIntentItem.GenericApp -> true

is UPIIntentItem.PaymentApp -> true
null -> false
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,17 @@ import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import com.adyen.checkout.upi.databinding.UpiAppBinding
import com.adyen.checkout.upi.databinding.UpiAppGenericBinding
import com.adyen.checkout.upi.internal.ui.model.UPIIntentItem
import com.adyen.checkout.upi.internal.ui.view.UPIAppsAdapter.UPIViewType.VIEW_TYPE_GENERIC_APP
import com.adyen.checkout.upi.internal.ui.view.UPIAppsAdapter.UPIViewType.VIEW_TYPE_PAYMENT_APP

internal class UPIAppsAdapter(
private val context: Context,
private val paymentMethod: String,
private val onItemClickListener: (UPIIntentItem) -> Unit,
) : ListAdapter<UPIIntentItem, UPIIntentItemViewHolder>(UPIAppsDiffCallback) {

override fun getItemViewType(position: Int) = when (getItem(position)) {
is UPIIntentItem.PaymentApp -> VIEW_TYPE_PAYMENT_APP.id
is UPIIntentItem.GenericApp -> VIEW_TYPE_GENERIC_APP.id
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): UPIIntentItemViewHolder {
val upiViewType = UPIViewType.entries[viewType]
return when (upiViewType) {
VIEW_TYPE_PAYMENT_APP -> {
val binding = UpiAppBinding.inflate(LayoutInflater.from(context), parent, false)
UPIIntentPaymentAppViewHolder(binding, paymentMethod)
}

VIEW_TYPE_GENERIC_APP -> {
val binding = UpiAppGenericBinding.inflate(LayoutInflater.from(context), parent, false)
UPIIntentGenericAppViewHolder(binding)
}
}
val binding = UpiAppBinding.inflate(LayoutInflater.from(context), parent, false)
return UPIIntentPaymentAppViewHolder(binding, paymentMethod)
}

override fun onBindViewHolder(holder: UPIIntentItemViewHolder, position: Int) = with(holder) {
Expand All @@ -59,9 +41,4 @@ internal class UPIAppsAdapter(
override fun getChangePayload(oldItem: UPIIntentItem, newItem: UPIIntentItem) =
oldItem.getChangePayload(newItem)
}

enum class UPIViewType(val id: Int) {
VIEW_TYPE_PAYMENT_APP(0),
VIEW_TYPE_GENERIC_APP(1),
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package com.adyen.checkout.upi.internal.ui.view

import androidx.core.view.isVisible
import com.adyen.checkout.core.AdyenLogLevel
import com.adyen.checkout.core.internal.util.adyenLog
import com.adyen.checkout.ui.core.internal.ui.loadLogo
Expand Down Expand Up @@ -41,7 +42,7 @@ internal class UPIIntentPaymentAppViewHolder(
paymentApp: UPIIntentItem.PaymentApp,
isChecked: Boolean,
) = with(binding) {
radioButtonUpiApp.isChecked = isChecked
imageViewUpiAppChecked.isVisible = isChecked
textViewUpiAppName.text = paymentApp.name
imageViewUpiLogo.loadLogo(
environment = paymentApp.environment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.view.View.OnFocusChangeListener
import android.widget.LinearLayout
import androidx.autofill.HintConstants
import androidx.core.view.isVisible
Expand Down Expand Up @@ -166,6 +165,9 @@

private fun updateUpiIntentViews(isChecked: Boolean) {
binding.textViewIntentInstruction.isVisible = isChecked
binding.textViewListTitle.isVisible = isChecked
// TODO - Add translations and change text dynamically

Check warning on line 169 in upi/src/main/java/com/adyen/checkout/upi/internal/ui/view/UPIView.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this TODO comment.

See more on https://sonarcloud.io/project/issues?id=Adyen_adyen-android&issues=AZ0_WndSDTD6mRRbfXOS&open=AZ0_WndSDTD6mRRbfXOS&pullRequest=2659
binding.textViewListTitle.text = "On your device"

Check warning on line 170 in upi/src/main/java/com/adyen/checkout/upi/internal/ui/view/UPIView.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

String literal in `setText` can not be translated. Use Android resources instead.

See more on https://sonarcloud.io/project/issues?id=Adyen_adyen-android&issues=AZ0_WndSDTD6mRRbfXOT&open=AZ0_WndSDTD6mRRbfXOT&pullRequest=2659
Comment thread
OscarSpruit marked this conversation as resolved.
binding.recyclerViewUpiIntent.isVisible = isChecked
if (isChecked) {
binding.editTextVpa.clearFocus()
Expand Down
9 changes: 9 additions & 0 deletions upi/src/main/res/drawable/ic_upi_checkmark.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M20.5,6.41L8.5,18.41L3,12.91L4.41,11.5L8.5,15.58L19.09,5L20.5,6.41Z"
android:fillColor="#1A73E8"/>
</vector>
49 changes: 18 additions & 31 deletions upi/src/main/res/layout/upi_app.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,40 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_upi_app"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:paddingTop="@dimen/standard_three_quarters_margin"
android:paddingBottom="@dimen/standard_three_quarters_margin">

<com.adyen.checkout.ui.core.internal.ui.view.RoundCornerImageView
android:id="@+id/imageView_upi_logo"
style="@style/AdyenCheckout.UPI.Intent.Icon"
app:layout_constraintBottom_toTopOf="@+id/barrier_divider"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/textView_upi_app_name"
style="@style/AdyenCheckout.UPI.Intent.AppIdTextView"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/barrier_divider"
app:layout_constraintEnd_toStartOf="@+id/radioButton_upi_app"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/imageView_upi_app_checked"
app:layout_constraintStart_toEndOf="@+id/imageView_upi_logo"
app:layout_constraintTop_toTopOf="parent"
tools:text="GooglePay" />

<com.google.android.material.radiobutton.MaterialRadioButton
android:id="@+id/radioButton_upi_app"
style="@style/AdyenCheckout.UPI.Intent.RadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
app:layout_constraintBottom_toTopOf="@+id/barrier_divider"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<androidx.constraintlayout.widget.Barrier
android:id="@+id/barrier_divider"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:barrierMargin="@dimen/standard_half_margin"
app:constraint_referenced_ids="imageView_upi_logo, textView_upi_app_name, radioButton_upi_app" />

<View
android:id="@+id/divider_upi_app"
style="@style/AdyenCheckout.UPI.Intent.Divider"
android:layout_width="0dp"
android:layout_height="1dp"
<!-- TODO - Add translations for contentDescription -->

Check warning on line 36 in upi/src/main/res/layout/upi_app.xml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=Adyen_adyen-android&issues=AZ0_WnY1DTD6mRRbfXOQ&open=AZ0_WnY1DTD6mRRbfXOQ&pullRequest=2659
Comment thread
OscarSpruit marked this conversation as resolved.
<ImageView
android:id="@+id/imageView_upi_app_checked"
android:layout_width="@dimen/logo_small_width"
android:layout_height="@dimen/logo_small_width"
android:contentDescription="Selected"

Check warning on line 41 in upi/src/main/res/layout/upi_app.xml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Hardcoded string "Selected", should use `@string` resource

See more on https://sonarcloud.io/project/issues?id=Adyen_adyen-android&issues=AZ0_WnY1DTD6mRRbfXOR&open=AZ0_WnY1DTD6mRRbfXOR&pullRequest=2659
android:src="@drawable/ic_upi_checkmark"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/barrier_divider" />
app:layout_constraintTop_toTopOf="parent"
app:tint="?android:attr/colorPrimary"
tools:visibility="visible" />

</androidx.constraintlayout.widget.ConstraintLayout>
63 changes: 0 additions & 63 deletions upi/src/main/res/layout/upi_app_generic.xml

This file was deleted.

11 changes: 10 additions & 1 deletion upi/src/main/res/layout/upi_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@
android:visibility="gone"
tools:visibility="visible" />

<TextView
android:id="@+id/textView_listTitle"
style="@style/AdyenCheckout.UPI.Intent.ListTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
tools:text="On your device"
tools:visibility="visible" />

<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView_upiIntent"
android:layout_width="match_parent"
Expand All @@ -78,7 +87,7 @@
android:focusable="false"
android:focusableInTouchMode="false"
android:overScrollMode="never"
android:paddingBottom="@dimen/standard_one_half_margin"
android:paddingBottom="@dimen/standard_half_margin"
android:visibility="gone"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:visibility="visible" />
Expand Down
20 changes: 9 additions & 11 deletions upi/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@
<style name="AdyenCheckout.UPI.Intent.AppIdTextView" parent="AdyenCheckout.ListItemText">
<item name="android:layout_marginStart">@dimen/standard_three_quarters_margin</item>
<item name="android:layout_marginEnd">@dimen/standard_three_quarters_margin</item>
<item name="android:text">@string/checkout_address_form_country_hint</item>
<item name="android:textStyle">bold</item>
</style>

<style name="AdyenCheckout.UPI.Intent.AppIdTextView.Generic" parent="AdyenCheckout.UPI.Intent.AppIdTextView">
Expand All @@ -89,16 +87,16 @@
<!-- {@deprecated This resource is no longer in use.} -->
<style name="AdyenCheckout.UPI.Intent.Icon.ManualInput" parent="AdyenCheckout.UPI.Intent.Icon" />

<style name="AdyenCheckout.UPI.Intent.Divider">
<item name="android:background">@color/stroke_color</item>
</style>
<!-- {@deprecated This resource is no longer in use.} -->
<style name="AdyenCheckout.UPI.Intent.Divider" />

<style name="AdyenCheckout.UPI.Intent.RadioButton" parent="AdyenCheckout.RadioButton">
<item name="android:layout_marginEnd">0dp</item>
<item name="android:layout_marginRight">0dp</item>
<item name="android:paddingEnd">0dp</item>
<item name="android:paddingRight">0dp</item>
<item name="android:background">@android:color/transparent</item>
<!-- {@deprecated This resource is no longer in use.} -->
<style name="AdyenCheckout.UPI.Intent.RadioButton" parent="AdyenCheckout.RadioButton" />

<style name="AdyenCheckout.UPI.Intent.ListTitle" parent="AdyenCheckout.TextAppearance.Secondary">
<item name="android:textStyle">bold</item>
<item name="android:layout_marginTop">@dimen/standard_margin</item>
<item name="android:layout_marginBottom">@dimen/standard_three_quarters_margin</item>
</style>

</resources>
Loading
Loading