-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into feature/play_billing
# Conflicts: # android/app/src/main/java/updated/mysterium/vpn/ui/top/up/card/currency/CardCurrencyActivity.kt # android/app/src/main/java/updated/mysterium/vpn/ui/top/up/coingate/amount/TopUpAmountActivity.kt
- Loading branch information
Showing
30 changed files
with
543 additions
and
220 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
42 changes: 42 additions & 0 deletions
42
android/app/src/main/java/updated/mysterium/vpn/model/payment/GatewayCardItem.kt
This file contains 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,42 @@ | ||
package updated.mysterium.vpn.model.payment | ||
|
||
import androidx.annotation.ColorRes | ||
import androidx.annotation.DrawableRes | ||
import androidx.annotation.StringRes | ||
import network.mysterium.vpn.R | ||
|
||
data class GatewayCardItem( | ||
@StringRes val titleId: Int, | ||
@DrawableRes val iconId: Int, | ||
@ColorRes val backgroundId: Int, | ||
@ColorRes val textColorId: Int, | ||
@ColorRes val iconColorId: Int | ||
) { | ||
companion object { | ||
fun from(value: Gateway): GatewayCardItem { | ||
return when (value) { | ||
Gateway.COINGATE -> GatewayCardItem( | ||
R.string.crypto, | ||
R.drawable.icon_crypto, | ||
R.color.payment_method_crypto_background, | ||
R.color.payment_method_crypto_text_color, | ||
R.color.payment_method_crypto_icon_color | ||
) | ||
Gateway.CARDINITY -> GatewayCardItem( | ||
R.string.credit_card, | ||
R.drawable.icon_top_up_now, | ||
R.color.payment_method_card_background, | ||
R.color.payment_method_card_text_color, | ||
R.color.payment_method_card_icon_color | ||
) | ||
Gateway.PAYPAL -> GatewayCardItem( | ||
R.string.paypal, | ||
R.drawable.icon_paypal, | ||
R.color.payment_method_paypal_background, | ||
R.color.payment_method_paypal_text_color, | ||
R.color.payment_method_paypal_icon_color | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
52 changes: 52 additions & 0 deletions
52
android/app/src/main/java/updated/mysterium/vpn/ui/payment/method/PaymentMethodAdapter.kt
This file contains 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,52 @@ | ||
package updated.mysterium.vpn.ui.payment.method | ||
|
||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.core.content.ContextCompat | ||
import androidx.recyclerview.widget.RecyclerView | ||
import network.mysterium.vpn.R | ||
import network.mysterium.vpn.databinding.ItemPaymentMethodBinding | ||
import updated.mysterium.vpn.common.adapters.ContentListAdapter | ||
import updated.mysterium.vpn.model.payment.Gateway | ||
import updated.mysterium.vpn.model.payment.GatewayCardItem | ||
|
||
class PaymentMethodAdapter : | ||
ContentListAdapter<Gateway, PaymentMethodAdapter.PaymentMethodViewHolder>() { | ||
|
||
var onItemSelected: ((Gateway) -> Unit)? = null | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = PaymentMethodViewHolder( | ||
LayoutInflater.from(parent.context).inflate(R.layout.item_payment_method, parent, false) | ||
) | ||
|
||
override fun onBindViewHolder(holder: PaymentMethodViewHolder, position: Int) { | ||
holder.bind(items[position]) | ||
} | ||
|
||
override fun getItemCount() = items.size | ||
|
||
inner class PaymentMethodViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
val binding = ItemPaymentMethodBinding.bind(itemView) | ||
fun bind(item: Gateway) { | ||
val gatewayCardItem = GatewayCardItem.from(item) | ||
val backgroundColor = | ||
ContextCompat.getDrawable(itemView.context, gatewayCardItem.backgroundId) | ||
val iconColor = ContextCompat.getColor(itemView.context, gatewayCardItem.iconColorId) | ||
val textColor = ContextCompat.getColor(itemView.context, gatewayCardItem.textColorId) | ||
val text = itemView.context.getString(gatewayCardItem.titleId) | ||
|
||
binding.paymentMethodItemCard.background = backgroundColor | ||
binding.paymentMethodIcon.setBackgroundResource(gatewayCardItem.iconId) | ||
binding.arrowImageView.setColorFilter(iconColor) | ||
binding.paymentMethodName.setTextColor(textColor) | ||
binding.paymentMethodName.text = text | ||
|
||
binding.paymentMethodItemCard.setOnClickListener { | ||
onItemSelected?.invoke(item) | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
This file contains 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
This file contains 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
This file contains 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.