Skip to content

Commit

Permalink
Merge pull request #1090 from soramitsu/staging
Browse files Browse the repository at this point in the history
staging
  • Loading branch information
PankraSerg authored Jan 31, 2024
2 parents 6732e4c + 4d75d3e commit c307b36
Show file tree
Hide file tree
Showing 91 changed files with 1,525 additions and 522 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package jp.co.soramitsu.app.root.domain

import com.walletconnect.web3.wallet.client.Web3Wallet
import jp.co.soramitsu.account.api.domain.PendulumPreInstalledAccountsScenario
import jp.co.soramitsu.common.data.storage.Preferences
import jp.co.soramitsu.common.data.storage.appConfig
Expand Down Expand Up @@ -48,4 +49,6 @@ class RootInteractor(
fun chainRegistrySyncUp() = walletRepository.chainRegistrySyncUp()

suspend fun fetchFeatureToggle() = pendulumPreInstalledAccountsScenario.fetchFeatureToggle()

fun getPendingListOfSessionRequests(topic: String) = Web3Wallet.getPendingListOfSessionRequests(topic)
}
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,8 @@ class Navigator :
navController?.navigate(R.id.action_mainFragment_to_filterFragment)
}

override fun openSendConfirm(transferDraft: TransferDraft, phishingType: PhishingType?, overrides: Map<String, Any?>, transferComment: String?) {
val bundle = ConfirmSendFragment.getBundle(transferDraft, phishingType, overrides, transferComment)
override fun openSendConfirm(transferDraft: TransferDraft, phishingType: PhishingType?, overrides: Map<String, Any?>, transferComment: String?, skipEdValidation: Boolean) {
val bundle = ConfirmSendFragment.getBundle(transferDraft, phishingType, overrides, transferComment, skipEdValidation)

navController?.navigate(R.id.confirmSendFragment, bundle)
}
Expand Down Expand Up @@ -1102,8 +1102,8 @@ class Navigator :
navController?.navigate(R.id.backupWalletDialog, extras)
}

override fun openRenameWallet(metaAccountId: Long) {
val extras = RenameAccountDialog.getBundle(metaAccountId)
override fun openRenameWallet(metaAccountId: Long, name: String?) {
val extras = RenameAccountDialog.getBundle(metaAccountId, name)

navController?.navigate(R.id.renameAccountDialog, extras)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,14 @@ class RootViewModel @Inject constructor(
}

private fun handleSessionRequest(sessionRequest: Wallet.Model.SessionRequest) {
return rootRouter.openWalletConnectSessionRequest(sessionRequest.topic)
val pendingListOfSessionRequests = interactor.getPendingListOfSessionRequests(sessionRequest.topic)
if (pendingListOfSessionRequests.isEmpty()) {
return
}
rootRouter.openWalletConnectSessionRequest(sessionRequest.topic)
}

private fun handleSessionProposal(sessionProposal: Wallet.Model.SessionProposal) {
return rootRouter.openWalletConnectSessionProposal(sessionProposal.pairingTopic)
rootRouter.openWalletConnectSessionProposal(sessionProposal.pairingTopic)
}
}
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ apply plugin: "org.sonarqube"
buildscript {
ext {
// App version
versionName = '3.2.1'
versionCode = 140
versionName = '3.2.2'
versionCode = 152

// SDK and tools
compileSdkVersion = 34
Expand Down Expand Up @@ -83,7 +83,7 @@ buildscript {
minifyRelease = true
beaconVersion = "3.2.4"

sharedFeaturesVersion = "1.1.1.17-FLW"
sharedFeaturesVersion = "1.1.1.20-FLW"

coilDep = "io.coil-kt:coil:$coilVersion"
coilSvg = "io.coil-kt:coil-svg:$coilVersion"
Expand Down
2 changes: 2 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ android {
buildConfigField "String", "ETHERSCAN_API_KEY", readSecretInQuotes("FL_ANDROID_ETHERSCAN_API_KEY")
buildConfigField "String", "BSCSCAN_API_KEY", readSecretInQuotes("FL_ANDROID_BSCSCAN_API_KEY")
buildConfigField "String", "POLYGONSCAN_API_KEY", readSecretInQuotes("FL_ANDROID_POLYGONSCAN_API_KEY")
buildConfigField "String", "OKLINK_API_KEY", readSecretInQuotes("FL_ANDROID_OKLINK_API_KEY")
buildConfigField "String", "OPMAINNET_API_KEY", readSecretInQuotes("FL_ANDROID_OPMAINNET_API_KEY")
buildConfigField "String", "WALLET_CONNECT_PROJECT_ID", readSecretInQuotes("FL_WALLET_CONNECT_PROJECT_ID")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ open class ValidationWarning(
message: String,
explanation: String,
val positiveButtonText: String,
val negativeButtonText: String
val negativeButtonText: String,
val secondPositiveButtonText: String?
) : ValidationException(message, explanation) {
operator fun component3() = positiveButtonText
operator fun component4() = negativeButtonText
operator fun component5() = secondPositiveButtonText
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ package jp.co.soramitsu.common.compose.component

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.IntrinsicSize
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
Expand All @@ -12,6 +15,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material.Card
import androidx.compose.material.Divider
import androidx.compose.material.Icon
Expand Down Expand Up @@ -43,6 +47,7 @@ import jp.co.soramitsu.common.compose.theme.white64
import jp.co.soramitsu.common.compose.viewstate.AssetListItemShimmerViewState
import jp.co.soramitsu.common.compose.viewstate.AssetListItemViewState

@OptIn(ExperimentalLayoutApi::class)
@Composable
fun AssetListItem(
state: AssetListItemViewState,
Expand Down Expand Up @@ -147,32 +152,38 @@ fun AssetListItem(
)
}
}
Row {
Text(
text = state.assetTokenFiat.orEmpty(),
style = MaterialTheme.customTypography.body1,
modifier = Modifier
.alpha(0.64f)
.testTag("AssetListItem_${state.assetSymbol}_change_fiat")
)
Text(
text = state.assetTokenRate.orEmpty(),
style = MaterialTheme.customTypography.body1.copy(
color = assetRateColor
),
Row(
modifier = Modifier
.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceAround
) {
FlowRow(
modifier = Modifier
.padding(start = 4.dp)
.testTag("AssetListItem_${state.assetSymbol}_change_percent")
)
Spacer(
modifier = Modifier
.height(1.dp)
.weight(1.0f)
)
.weight(1f)
) {
Text(
text = state.assetTokenFiat.orEmpty(),
style = MaterialTheme.customTypography.body1,
modifier = Modifier
.alpha(0.64f)
.testTag("AssetListItem_${state.assetSymbol}_change_fiat")
)

Text(
text = state.assetTokenRate.orEmpty(),
style = MaterialTheme.customTypography.body1.copy(
color = assetRateColor
),
modifier = Modifier
.padding(start = 4.dp)
.testTag("AssetListItem_${state.assetSymbol}_change_percent")
)
}
Text(
text = state.assetTransferableBalanceFiat.orEmpty(),
style = MaterialTheme.customTypography.body1,
style = MaterialTheme.customTypography.body1.copy(textAlign = TextAlign.End),
modifier = Modifier
.wrapContentWidth()
.alpha(0.64f)
.padding(start = 4.dp)
.testTag("AssetListItem_${state.assetSymbol}_transferable_fiat")
Expand Down Expand Up @@ -326,14 +337,15 @@ private fun PreviewAssetListItem() {
)

val state = AssetListItemViewState(
index = 0,
assetIconUrl = assetIconUrl,
assetName = "Karura asset",
assetChainName = "Karura",
assetSymbol = "KSM",
assetTokenFiat = "$73.22",
assetTokenFiat = "$73.22000003242342",
assetTokenRate = "+5.67%",
assetTransferableBalance = "444.3",
assetTransferableBalanceFiat = "$2345.32",
assetTransferableBalance = "444.30",
assetTransferableBalanceFiat = "$2345.3233434334",
assetChainUrls = assetChainUrlsMap,
chainId = "",
chainAssetId = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ import jp.co.soramitsu.common.compose.theme.white64
import jp.co.soramitsu.common.utils.onSingleClick
import jp.co.soramitsu.common.utils.rememberLastClickTime

private const val DISABLE_CLICK_TIME = 1000L

data class ButtonViewState(
val text: String,
val enabled: Boolean = true
Expand All @@ -60,7 +58,7 @@ fun AccentButton(state: ButtonViewState, modifier: Modifier = Modifier, onClick:
TextButton(
text = state.text,
enabled = state.enabled,
colors = accentButtonColors,
colors = accentDarkButtonColors,
modifier = modifier,
onClick = onClick
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,15 @@ private fun AssetItemSwipeBoxPreview() {
)

val assetListItemViewState = AssetListItemViewState(
index = 0,
assetIconUrl = "https://raw.githubusercontent.com/soramitsu/fearless-utils/master/icons/chains/white/Polkadot.svg",
assetChainName = "Karura",
assetName = "Karura asset",
assetSymbol = "KSM",
assetTokenFiat = "$73.22",
assetTokenFiat = "$73.2200000003",
assetTokenRate = "+5.67%",
assetTransferableBalance = "444.3",
assetTransferableBalanceFiat = "$2345.32",
assetTransferableBalanceFiat = "$2345.30000002",
assetChainUrls = assetChainUrlsMap,
chainId = "",
chainAssetId = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ val accentDarkButtonColors = object : ButtonColors {
val accentDarkDisabledButtonColors = object : ButtonColors {
@Composable
override fun backgroundColor(enabled: Boolean): State<Color> {
return rememberUpdatedState(if (enabled) colorAccent else white08)
return rememberUpdatedState(if (enabled) colorAccentDark else white08)
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package jp.co.soramitsu.common.compose.viewstate

data class AssetListItemViewState(
val index: Int?,
val assetIconUrl: String,
val assetName: String,
val assetChainName: String,
Expand All @@ -17,5 +18,5 @@ data class AssetListItemViewState(
val priceId: String?,
val isTestnet: Boolean
) {
val key = listOf(chainAssetId, chainId, isHidden).joinToString()
val key = listOf(index ?: 0, chainAssetId, chainId, isHidden).joinToString()
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ class ErrorDialog(
private val title: String?,
private val message: String,
private val positiveButtonText: String? = null,
private val secondPositiveButtonText: String? = null,
private val negativeButtonText: String? = null,
private val textSize: Int = 13,
@DrawableRes private val iconRes: Int = R.drawable.ic_status_warning_16,
private val isHideable: Boolean = true,
private val buttonsOrientation: Int = LinearLayout.VERTICAL,
private val onBackClick: () -> Unit = emptyClick,
private val positiveClick: () -> Unit = emptyClick,
private val secondPositiveClick: () -> Unit = emptyClick,
private val negativeClick: () -> Unit = emptyClick
) : BottomSheetDialogFragment() {

Expand All @@ -68,7 +70,7 @@ class ErrorDialog(

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NO_TITLE, R.style.CustomBottomSheetDialogTheme)
setStyle(STYLE_NO_TITLE, R.style.CustomBottomSheetDialogThemeNoIme)
}

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
Expand Down Expand Up @@ -149,6 +151,18 @@ class ErrorDialog(
}
MarginVertical(margin = 12.dp)
}
secondPositiveButtonText?.let {
GrayButton(
text = it,
modifier = Modifier
.fillMaxWidth()
.height(52.dp)
) {
secondPositiveClick()
dismiss()
}
MarginVertical(margin = 12.dp)
}
negativeButtonText?.let {
GrayButton(
text = it,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ import jp.co.soramitsu.common.utils.formatting.NumberAbbreviation
import java.math.BigDecimal
import java.math.RoundingMode
import java.text.DecimalFormat
import java.text.DecimalFormatSymbols
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import java.util.concurrent.TimeUnit
import jp.co.soramitsu.common.utils.formatting.FiatSmallFormatter

const val DOLLAR_SIGN = "$"
private const val DECIMAL_PATTERN_BASE = "#,##0"
Expand All @@ -24,6 +27,7 @@ private const val MAX_DECIMALS_3 = 3
const val MAX_DECIMALS_8 = 8

private val fiatAmountFormatter = FiatFormatter()
private val fiatSmallAmountFormatter = FiatSmallFormatter()
private val percentAmountFormatter = FixedPrecisionFormatter(MAX_DECIMALS_2)
private val cryptoAmountShortFormatter = FixedPrecisionFormatter(MAX_DECIMALS_3)
private val cryptoAmountDetailFormatter = FixedPrecisionFormatter(MAX_DECIMALS_8)
Expand Down Expand Up @@ -105,7 +109,7 @@ fun decimalFormatterFor(pattern: String) = DecimalFormat(pattern).apply {

fun fiatAbbreviatedFormatter() = CompoundNumberFormatter(
abbreviations = listOf(
NumberAbbreviation(BigDecimal.ZERO, BigDecimal.ONE, "", fiatAmountFormatter),
NumberAbbreviation(BigDecimal.ZERO, BigDecimal.ONE, "", fiatSmallAmountFormatter),
NumberAbbreviation(BigDecimal.ONE, BigDecimal.ONE, "", fiatAmountFormatter),
NumberAbbreviation(BigDecimal("1E+3"), BigDecimal.ONE, "", fiatAmountFormatter),
NumberAbbreviation(BigDecimal("1E+6"), BigDecimal("1E+6"), "M", fiatAmountFormatter),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,44 @@ package jp.co.soramitsu.common.utils.formatting

import jp.co.soramitsu.common.utils.decimalFormatterFor
import java.math.BigDecimal
import java.text.DecimalFormatSymbols
import java.util.Locale

class FiatFormatter : NumberFormatter {
class FiatFormatter(
private val locale: Locale? = null
) : NumberFormatter {
companion object {
private const val FIAT_DECIMAL_PATTERN = "#,##0.00"
}

override fun format(number: BigDecimal): String {
val delegate = decimalFormatterFor(FIAT_DECIMAL_PATTERN)
locale?.let {
delegate.decimalFormatSymbols = DecimalFormatSymbols(locale)
}
val decimalSeparator = delegate.decimalFormatSymbols.decimalSeparator
val leadingZeros = Regex(decimalSeparator + "00$")
return delegate.format(number).replace(leadingZeros, "")
}
}

class FiatSmallFormatter(
private val locale: Locale? = null
) : NumberFormatter {
companion object {
private const val FIAT_DECIMAL_PATTERN = "#.###E0"
}

override fun format(number: BigDecimal): String {
val delegate = decimalFormatterFor(FIAT_DECIMAL_PATTERN)
locale?.let {
delegate.decimalFormatSymbols = DecimalFormatSymbols(locale)
}
val formattedValue = try {
delegate.format(number).replace(',', '.').toBigDecimal()
} catch (e: NumberFormatException) {
number
}
return FullPrecisionFormatter(locale).format(formattedValue)
}
}
Loading

0 comments on commit c307b36

Please sign in to comment.