Skip to content

Commit

Permalink
Merge branch 'dev' into rajkumar921989-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
rajkumar921989 authored Dec 17, 2024
2 parents b584c42 + 39ff04c commit 963e3fb
Show file tree
Hide file tree
Showing 35 changed files with 347 additions and 24 deletions.
10 changes: 8 additions & 2 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@
# ---------------- END AlgoSDK -------------------


# ---------------- BEGIN BouncyCastle -------------------
-keep class org.bouncycastle.jcajce.provider.** { *; }
-keep class org.bouncycastle.jce.provider.** { *; }

-dontwarn javax.naming.**
# ---------------- END BouncyCastle -------------------


# ---------------- BEGIN WALLET CONNECT -------------------
-keep class org.walletconnect.** { *; }
-keep interface org.walletconnect.** { *; }
Expand All @@ -176,8 +184,6 @@


# ---------------- BEGIN OTHERS -------------------
-keep class com.google.gson.examples.android.model.** { <fields>; }

# Prevent R8 from leaving Data object members always null
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class BannerTypeDecider @Inject constructor() {
fun getBannerType(bannerTypeResponse: BannerTypeResponse?): BannerType {
return when (bannerTypeResponse) {
BannerTypeResponse.GOVERNANCE -> BannerType.GOVERNANCE
BannerTypeResponse.STAKING -> BannerType.STAKING
BannerTypeResponse.GENERIC -> BannerType.GENERIC
BannerTypeResponse.OTHER -> BannerType.GENERIC
else -> BannerType.GENERIC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,8 @@ enum class BannerTypeResponse {
@SerializedName("governance")
GOVERNANCE,

@SerializedName("staking")
STAKING,

OTHER
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ class BannerMapper @Inject constructor() {
)
}

fun mapToStakingBanner(bannerDetailDTO: BannerDetailDTO): BaseBanner.StakingBanner {
return BaseBanner.StakingBanner(
bannerId = bannerDetailDTO.bannerId,
title = bannerDetailDTO.title,
description = bannerDetailDTO.description,
buttonTitle = bannerDetailDTO.buttonText,
buttonUrl = bannerDetailDTO.buttonUrl
)
}

fun mapToGenericBanner(bannerDetailDTO: BannerDetailDTO): BaseBanner.GenericBanner {
return BaseBanner.GenericBanner(
bannerId = bannerDetailDTO.bannerId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ package com.algorand.android.banner.domain.model

enum class BannerType {
GENERIC,
GOVERNANCE
GOVERNANCE,
STAKING
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ sealed class BaseBanner {
abstract val buttonTitle: String?
abstract val buttonUrl: String?

data class StakingBanner(
override val bannerId: Long,
override val title: String?,
override val description: String?,
override val buttonTitle: String?,
override val buttonUrl: String?
) : BaseBanner()

data class GovernanceBanner(
override val bannerId: Long,
override val title: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class BannersUseCase @Inject constructor(
private fun getMappedAndFilteredBanner(bannerDto: BannerDetailDTO): BaseBanner {
return when (bannerDto.type) {
BannerType.GOVERNANCE -> bannerMapper.mapToGovernanceBanner(bannerDto)
BannerType.STAKING -> bannerMapper.mapToStakingBanner(bannerDto)
BannerType.GENERIC -> bannerMapper.mapToGenericBanner(bannerDto)
else -> bannerMapper.mapToGenericBanner(bannerDto)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ class BaseBannerItemMapper @Inject constructor() {
)
}

fun mapToStakingBannerItem(
stakingBanner: BaseBanner.StakingBanner,
isButtonVisible: Boolean,
isTitleVisible: Boolean,
isDescriptionVisible: Boolean
): BaseAccountListItem.BaseBannerItem.StakingBannerItem {
return BaseAccountListItem.BaseBannerItem.StakingBannerItem(
bannerId = stakingBanner.bannerId,
title = stakingBanner.title,
description = stakingBanner.description,
buttonText = stakingBanner.buttonTitle,
buttonUrl = stakingBanner.buttonUrl,
isButtonVisible = isButtonVisible,
isTitleVisible = isTitleVisible,
isDescriptionVisible = isDescriptionVisible
)
}

fun mapToGenericBannerItem(
genericBanner: BaseBanner.GenericBanner,
isButtonVisible: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.core.view.isVisible
import com.algorand.android.banner.domain.model.BannerType
import com.algorand.android.models.BaseViewHolder
import com.algorand.android.modules.accounts.domain.model.BaseAccountListItem
import com.google.android.material.button.MaterialButton

abstract class BaseBannerViewHolder(
private val listener: BannerListener,
protected val listener: BannerListener,
itemView: View
) : BaseViewHolder<BaseAccountListItem>(itemView) {

Expand All @@ -38,9 +39,11 @@ abstract class BaseBannerViewHolder(
initDescriptionTextView(item)
}

private fun initActionButton(item: BaseAccountListItem.BaseBannerItem) {
abstract fun initActionButton(item: BaseAccountListItem.BaseBannerItem)

protected fun initActionButton(item: BaseAccountListItem.BaseBannerItem, bannerType: BannerType) {
actionButton?.apply {
setOnClickListener { listener.onActionButtonClick(item.buttonUrl.orEmpty()) }
setOnClickListener { listener.onActionButtonClick(item.buttonUrl.orEmpty(), bannerType) }
text = item.buttonText
isVisible = item.isButtonVisible
}
Expand All @@ -66,7 +69,7 @@ abstract class BaseBannerViewHolder(

interface BannerListener {
fun onCloseBannerClick(bannerId: Long) {}
fun onActionButtonClick(url: String) {}
fun onActionButtonClick(url: String, bannerType: BannerType) {}
}

protected interface BannerViewHolderCreator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ package com.algorand.android.banner.ui.viewholder
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView
import com.algorand.android.banner.domain.model.BannerType
import com.algorand.android.databinding.ItemGenericBannerBinding
import com.algorand.android.modules.accounts.domain.model.BaseAccountListItem
import com.google.android.material.button.MaterialButton

class GenericBannerViewHolder(
Expand All @@ -32,6 +34,10 @@ class GenericBannerViewHolder(
override val descriptionTextView: TextView
get() = binding.bannerDescriptionTextView

override fun initActionButton(item: BaseAccountListItem.BaseBannerItem) {
initActionButton(item, BannerType.GENERIC)
}

companion object : BannerViewHolderCreator {
override fun create(listener: BannerListener, parent: ViewGroup): BaseBannerViewHolder {
val binding = ItemGenericBannerBinding.inflate(LayoutInflater.from(parent.context), parent, false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ package com.algorand.android.banner.ui.viewholder
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView
import com.algorand.android.banner.domain.model.BannerType
import com.algorand.android.databinding.ItemGovernanceBannerBinding
import com.algorand.android.modules.accounts.domain.model.BaseAccountListItem
import com.google.android.material.button.MaterialButton

class GovernanceBannerViewHolder(
Expand All @@ -32,6 +34,9 @@ class GovernanceBannerViewHolder(
override val descriptionTextView: TextView
get() = binding.bannerDescriptionTextView

override fun initActionButton(item: BaseAccountListItem.BaseBannerItem) {
initActionButton(item, BannerType.GOVERNANCE)
}
companion object : BannerViewHolderCreator {
override fun create(listener: BannerListener, parent: ViewGroup): BaseBannerViewHolder {
val binding = ItemGovernanceBannerBinding.inflate(LayoutInflater.from(parent.context), parent, false)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2022 Pera Wallet, LDA
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/

package com.algorand.android.banner.ui.viewholder

import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView
import com.algorand.android.banner.domain.model.BannerType
import com.algorand.android.databinding.ItemStakingBannerBinding
import com.algorand.android.modules.accounts.domain.model.BaseAccountListItem
import com.google.android.material.button.MaterialButton

class StakingBannerViewHolder(
private val binding: ItemStakingBannerBinding,
listener: BannerListener
) : BaseBannerViewHolder(listener, binding.root) {

override val actionButton: MaterialButton
get() = binding.bannerActionButton
override val closeButton: MaterialButton
get() = binding.bannerCloseButton
override val titleTextView: TextView
get() = binding.bannerTitleTextView
override val descriptionTextView: TextView
get() = binding.bannerDescriptionTextView

override fun initActionButton(item: BaseAccountListItem.BaseBannerItem) {
initActionButton(item, BannerType.STAKING)
}

companion object : BannerViewHolderCreator {
override fun create(listener: BannerListener, parent: ViewGroup): BaseBannerViewHolder {
val binding = ItemStakingBannerBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return StakingBannerViewHolder(binding, listener)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ sealed class BaseAccountListItem : RecyclerListItem {
HEADER,
QUICK_ACTIONS,
GOVERNANCE_BANNER,
STAKING_BANNER,
GENERIC_BANNER,
BACKUP_BANNER
}
Expand Down Expand Up @@ -84,6 +85,28 @@ sealed class BaseAccountListItem : RecyclerListItem {
}
}

data class StakingBannerItem(
override val bannerId: Long,
override val buttonText: String?,
override val buttonUrl: String?,
override val isButtonVisible: Boolean,
override val title: String?,
override val isTitleVisible: Boolean,
override val description: String?,
override val isDescriptionVisible: Boolean
) : BaseBannerItem() {

override val itemType: ItemType = ItemType.STAKING_BANNER

override fun areItemsTheSame(other: RecyclerListItem): Boolean {
return other is StakingBannerItem && other.bannerId == bannerId
}

override fun areContentsTheSame(other: RecyclerListItem): Boolean {
return other is StakingBannerItem && other == this
}
}

data class GenericBannerItem(
override val bannerId: Long,
override val buttonText: String?,
Expand Down Expand Up @@ -182,6 +205,7 @@ sealed class BaseAccountListItem : RecyclerListItem {
companion object {
val bannerItemTypes = listOf(
ItemType.GOVERNANCE_BANNER.ordinal,
ItemType.STAKING_BANNER.ordinal,
ItemType.GENERIC_BANNER.ordinal,
ItemType.BACKUP_BANNER.ordinal
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.algorand.android.R
import com.algorand.android.banner.domain.model.BaseBanner
import com.algorand.android.banner.domain.model.BaseBanner.GenericBanner
import com.algorand.android.banner.domain.model.BaseBanner.GovernanceBanner
import com.algorand.android.banner.domain.model.BaseBanner.StakingBanner
import com.algorand.android.banner.domain.usecase.BannersUseCase
import com.algorand.android.banner.ui.mapper.BaseBannerItemMapper
import com.algorand.android.core.AccountManager
Expand Down Expand Up @@ -347,6 +348,10 @@ class AccountsPreviewUseCase @Inject constructor(
mapToGovernanceBannerItem(banner, isButtonVisible, isTitleVisible, isDescriptionVisible)
}

is StakingBanner -> {
mapToStakingBannerItem(banner, isButtonVisible, isTitleVisible, isDescriptionVisible)
}

is GenericBanner -> {
mapToGenericBannerItem(banner, isButtonVisible, isTitleVisible, isDescriptionVisible)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.algorand.android.HomeNavigationDirections
import com.algorand.android.MainActivity
import com.algorand.android.MainNavigationDirections
import com.algorand.android.R
import com.algorand.android.banner.domain.model.BannerType
import com.algorand.android.core.DaggerBaseFragment
import com.algorand.android.databinding.FragmentAccountsBinding
import com.algorand.android.models.AnnotatedString
Expand Down Expand Up @@ -104,9 +105,13 @@ class AccountsFragment : DaggerBaseFragment(R.layout.fragment_accounts),
navToBackupPassphraseInfoNavigation()
}

override fun onBannerActionButtonClick(url: String, isGovernance: Boolean) {
accountsViewModel.onBannerActionButtonClick(isGovernance)
nav(AccountsFragmentDirections.actionAccountsFragmentToBannerFragment(url))
override fun onBannerActionButtonClick(url: String, bannerType: BannerType) {
accountsViewModel.onBannerActionButtonClick(bannerType)
if (bannerType == BannerType.STAKING) {
nav(AccountsFragmentDirections.actionAccountsFragmentToStakingFragment())
} else {
nav(AccountsFragmentDirections.actionAccountsFragmentToBannerFragment(url))
}
}

override fun onBuySellClick() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package com.algorand.android.modules.accounts.ui

import androidx.lifecycle.viewModelScope
import com.algorand.android.banner.domain.model.BannerType
import com.algorand.android.core.BaseViewModel
import com.algorand.android.modules.accounts.domain.model.AccountPreview
import com.algorand.android.modules.accounts.domain.usecase.AccountsPreviewUseCase
Expand Down Expand Up @@ -83,10 +84,12 @@ class AccountsViewModel @Inject constructor(
}
}

fun onBannerActionButtonClick(isGovernance: Boolean) {
if (isGovernance) {
viewModelScope.launch {
accountsEventTracker.logVisitGovernanceEvent()
fun onBannerActionButtonClick(bannerType: BannerType) {
viewModelScope.launch {
when (bannerType) {
BannerType.GOVERNANCE -> accountsEventTracker.logVisitGovernanceEvent()
BannerType.STAKING -> accountsEventTracker.logVisitStakingEvent()
BannerType.GENERIC -> {}
}
}
}
Expand Down
Loading

0 comments on commit 963e3fb

Please sign in to comment.