Updated on 2026-08-14

This commit is contained in:
Tangem 2020-03-26 19:35:36 +03:00
parent a99df301b1
commit 0f003aafcc
12 changed files with 307 additions and 201 deletions

View file

@ -1,20 +1,22 @@
{
"releaseVersion": false,
"issuerData": null,
"issuerName": "TANGEM SDK",
"series": "DB",
"startNumber": 300000000,
"count": 20,
"numberFormat": "",
"PIN": "000000",
"PIN2": "000",
"PIN3": "",
"hexCrExKey": "",
"CVC": "000",
"pauseBeforePIN2": 15000,
"smartSecurityDelay": true,
"curveID": "ed25519",
"ndef": "com.tangem.wallet",
"startNumber": 300000000,
"count": 20,
"SigningMethod": 0,
"MaxSignatures": 1000000,
"pauseBeforePIN2": 15000,
"smartSecurityDelay": true,
"releaseVersion": false,
"isReusable": true,
"allowSwapPIN": false,
"allowSwapPIN2": true,
@ -38,18 +40,13 @@
"requireTerminalTxSignature": false,
"requireTerminalCertSignature": false,
"checkPIN3onCard": false,
"ndef": {
"type": "AAR",
"value": "com.tangem.wallet"
},
"cardData": {
"date": "2020-02-17",
"batch": "FF87",
"blockchain": "IROHA",
"blockchain": "XLM",
"product_note": true,
"product_tag": false,
"product_id_card": false
},
"createWallet": 1,
"issuerData": null
"createWallet": true
}

View file

@ -13,6 +13,7 @@ typealias SafeValueChange<V> = (V) -> Unit
interface ItemViewModel<D> : Payload {
val viewState: ViewState
var data: D?
var defaultData: D?
var onDataUpdated: ValueChange<D>?
fun updateDataByView(data: D?)
@ -23,19 +24,32 @@ open class BaseItemViewModel<D> : ItemViewModel<D> {
override val viewState: ViewState = ViewState()
override val payload: MutableMap<String, Any?> = mutableMapOf()
// Don't update it directly from a View. Use for it updateDataByView()
override var data: D? = null
set(value) {
if (handleDataUpdates(value)) field = value
}
// Data for restoring initial value
override var defaultData: D? = null
set(value) {
field = value
data = value
}
// Use it for handling data updates in View
override var onDataUpdated: ValueChange<D>? = null
// When data updates directly it invokes onDataUpdated
// return true = data will update
// return false = data won't update
protected open fun handleDataUpdates(value: D?): Boolean {
ILog.d(this, "handleDateUpdates: $value")
onDataUpdated?.invoke(value)
return true
}
// Use it to update the data from a View. It disables onDataUpdated to prevent a callback loop
override fun updateDataByView(data: D?) {
ILog.d(this, "data changed: $data")
val callback = onDataUpdated

View file

@ -7,7 +7,7 @@ import com.tangem.tangemtest._arch.structure.abstraction.BaseItemViewModel
*/
open class TransitiveViewModel<D>(value: D?) : BaseItemViewModel<D>() {
init {
data = value
defaultData = value
}
}
@ -21,8 +21,7 @@ class ListViewModel(value: ListValueWrapper? = null) : TransitiveViewModel<ListV
val newValue = value ?: return false
if (newValue.selectedItem == data?.selectedItem) return false
onDataUpdated?.invoke(value)
return true
return super.handleDataUpdates(value)
}
}

View file

@ -1,12 +1,18 @@
package com.tangem.tangemtest.ucase.variants.personalize.converter
import com.tangem.tangemtest._arch.structure.abstraction.Block
import com.tangem.tangemtest.ucase.variants.personalize.dto.TestJsonDto
import com.tangem.tangemtest.ucase.variants.personalize.dto.PersonalizeConfig
import ru.dev.gbixahue.eu4d.lib.kotlin.common.Converter
/**
[REDACTED_AUTHOR]
*/
class BlockToJsonConverter : Converter<List<Block>, TestJsonDto> {
override fun convert(from: List<Block>): TestJsonDto = TestJsonDto()
class BlockToJsonConverter(
private val valueMapper: ValueMapper,
private val config: PersonalizeConfig
) : Converter<List<Block>, PersonalizeConfig> {
override fun convert(from: List<Block>): PersonalizeConfig {
return valueMapper.mapOnObject(from, config)
}
}

View file

@ -1,22 +0,0 @@
package com.tangem.tangemtest.ucase.variants.personalize.converter
import com.tangem.tangemtest._arch.structure.abstraction.Block
import com.tangem.tangemtest.ucase.variants.personalize.dto.TestJsonDto
/**
[REDACTED_AUTHOR]
*/
interface EncodeDecode<A, B> {
fun decode(from: A): B
fun encode(from: B): A
}
class JsonBlockEnDe(
private val jsonToBlock: JsonToBlockConverter,
private val blockToJson: BlockToJsonConverter
) : EncodeDecode<TestJsonDto, List<Block>> {
override fun encode(from: List<Block>): TestJsonDto = blockToJson.convert(from)
override fun decode(from: TestJsonDto): List<Block> = jsonToBlock.convert(from)
}

View file

@ -2,26 +2,33 @@ package com.tangem.tangemtest.ucase.variants.personalize.converter
import com.tangem.tangemtest._arch.structure.*
import com.tangem.tangemtest._arch.structure.impl.KeyValue
import com.tangem.tangemtest.ucase.variants.personalize.dto.TestJsonDto
import com.tangem.tangemtest.ucase.variants.personalize.dto.PersonalizeConfig
import ru.dev.gbixahue.eu4d.lib.kotlin.common.BaseTypedHolder
/**
[REDACTED_AUTHOR]
*/
class Value(
val value: Any? = null,
private var value: Any? = null,
val list: List<KeyValue>? = mutableListOf()
)
) {
fun get(): Any? = value
fun set(newValue: Any?) {
value = newValue
}
}
class IdToJsonValues : BaseTypedHolder<Id, Value>() {
fun init(from: TestJsonDto) {
class IdToValueAssociations : BaseTypedHolder<Id, Value>() {
// All registered association values can't be objects
fun init(from: PersonalizeConfig) {
register(CardNumber.SERIES, Value(from.series))
register(CardNumber.NUMBER, Value(from.startNumber))
register(Common.CURVE, Value(from.curveID, Helper.listOfCurves()))
register(Common.BLOCKCHAIN, Value(from.blockchain.name, Helper.listOfBlockchain()))
register(Common.BLOCKCHAIN_CUSTOM, Value(from.blockchain.customName))
register(Common.BLOCKCHAIN, Value(from.blockchain, Helper.listOfBlockchain()))
register(Common.BLOCKCHAIN_CUSTOM, Value(""))
register(Common.MAX_SIGNATURES, Value(from.MaxSignatures))
register(Common.CREATE_WALLET, Value(from.createWalletB))
register(Common.CREATE_WALLET, Value(from.createWallet))
register(SigningMethod.SIGN_TX, Value(from.SigningMethod0))
register(SigningMethod.SIGN_TX_RAW, Value(from.SigningMethod1))
register(SigningMethod.SIGN_VALIDATED_TX, Value(from.SigningMethod2))
@ -64,7 +71,7 @@ class IdToJsonValues : BaseTypedHolder<Id, Value>() {
register(SettingsMaskNdef.USE_NDEF, Value(from.useNDEF))
register(SettingsMaskNdef.DYNAMIC_NDEF, Value(from.useDynamicNDEF))
register(SettingsMaskNdef.DISABLE_PRECOMPUTED_NDEF, Value(from.disablePrecomputedNDEF))
register(SettingsMaskNdef.AAR, Value(from.NDEF[0].type, Helper.aarList()))
register(SettingsMaskNdef.AAR, Value(from.NDEF, Helper.aarList()))
register(Pins.PIN, Value(from.PIN))
register(Pins.PIN2, Value(from.PIN2))
register(Pins.PIN3, Value(from.PIN3))
@ -111,13 +118,13 @@ internal class Helper {
fun pauseBeforePin(): List<KeyValue> {
return mutableListOf(
KeyValue("immediately", 0),
KeyValue("2 seconds", 2000),
KeyValue("5 seconds", 5000),
KeyValue("15 seconds", 15000),
KeyValue("30 seconds", 30000),
KeyValue("1 minute", 60000),
KeyValue("2 minute", 120000)
KeyValue("immediately", 0L),
KeyValue("2 seconds", 2000L),
KeyValue("5 seconds", 5000L),
KeyValue("15 seconds", 15000L),
KeyValue("30 seconds", 30000L),
KeyValue("1 minute", 60000L),
KeyValue("2 minute", 120000L)
)
}
}

View file

@ -4,18 +4,18 @@ import com.tangem.tangemtest._arch.structure.*
import com.tangem.tangemtest._arch.structure.abstraction.Block
import com.tangem.tangemtest._arch.structure.abstraction.ListItemBlock
import com.tangem.tangemtest._arch.structure.impl.*
import com.tangem.tangemtest.ucase.variants.personalize.dto.TestJsonDto
import com.tangem.tangemtest.ucase.variants.personalize.dto.PersonalizeConfig
import ru.dev.gbixahue.eu4d.lib.kotlin.common.Converter
/**
[REDACTED_AUTHOR]
*/
class JsonToBlockConverter(
private val valuesHolder: IdToJsonValues
) : Converter<TestJsonDto, List<Block>> {
class JsonToBlockConverter : Converter<PersonalizeConfig, List<Block>> {
override fun convert(from: TestJsonDto): List<Block> {
valuesHolder.init(from)
private val associations: IdToValueAssociations = IdToValueAssociations()
override fun convert(from: PersonalizeConfig): List<Block> {
associations.init(from)
val blocList = mutableListOf<Block>()
blocList.add(cardNumber())
blocList.add(common())
@ -164,25 +164,18 @@ class JsonToBlockConverter(
return ListItemBlock(id).apply { createItem(this, id) }
}
private fun addPayload(block: Block, from: TestJsonDto) {
private fun addPayload(block: Block, from: PersonalizeConfig) {
block.payload[Additional.JSON_INCOMING.name] = from
block.payload[Additional.JSON_TAILS.name] = JsonTails(
from.count,
from.numberFormat,
from.issuerData,
from.releaseVersion,
from.issuerName
)
}
private fun createItem(block: ListItemBlock, id: Id) {
val holder = valuesHolder.get(id) ?: return
val holder = associations.get(id) ?: return
val item = when {
IdItemHelper.blockIdList.contains(id) -> TextItem(id, holder.value as? String)
IdItemHelper.listItemList.contains(id) -> ListItem(id, holder.list as List<KeyValue>, holder.value)
IdItemHelper.boolList.contains(id) -> BoolItem(id, holder.value as? Boolean)
IdItemHelper.editTextList.contains(id) -> EditTextItem(id, holder.value as? String)
IdItemHelper.numberList.contains(id) -> NumberItem(id, holder.value as? Number)
IdItemHelper.blockIdList.contains(id) -> TextItem(id, holder.get() as? String)
IdItemHelper.listItemList.contains(id) -> ListItem(id, holder.list as List<KeyValue>, holder.get())
IdItemHelper.boolList.contains(id) -> BoolItem(id, holder.get() as? Boolean)
IdItemHelper.editTextList.contains(id) -> EditTextItem(id, holder.get() as? String)
IdItemHelper.numberList.contains(id) -> NumberItem(id, holder.get() as? Number)
else -> ListItemBlock(Additional.UNDEFINED)
}
block.addItem(item)

View file

@ -0,0 +1,115 @@
package com.tangem.tangemtest.ucase.variants.personalize.converter
import com.tangem.tangemtest._arch.structure.*
import com.tangem.tangemtest._arch.structure.abstraction.BaseItem
import com.tangem.tangemtest._arch.structure.abstraction.Block
import com.tangem.tangemtest._arch.structure.abstraction.Item
import com.tangem.tangemtest._arch.structure.impl.KeyValue
import com.tangem.tangemtest._arch.structure.impl.ListValueWrapper
import com.tangem.tangemtest.ucase.variants.personalize.dto.PersonalizeConfig
import ru.dev.gbixahue.eu4d.lib.android.global.log.Log
/**
[REDACTED_AUTHOR]
*/
class ValueMapper {
private val default: IdToValueAssociations = IdToValueAssociations()
private val updatedByItemList: IdToValueAssociations = IdToValueAssociations()
fun mapOnObject(itemList: List<Item>, defaultValues: PersonalizeConfig): PersonalizeConfig {
default.init(defaultValues)
updatedByItemList.init(defaultValues)
startMapping(itemList)
return createJson(defaultValues)
}
private fun startMapping(itemList: List<Item>) {
itemList.forEach { item -> mapItem(item) }
}
private fun mapItem(item: Item) {
when (item) {
is Block -> startMapping(item.itemList)
is BaseItem<*> -> {
val value = updatedByItemList.get(item.id) ?: return
value.set(item.viewModel.data)
}
}
}
private fun createJson(defaultConfig: PersonalizeConfig): PersonalizeConfig {
val export = PersonalizeConfig()
export.series = getTyped(CardNumber.SERIES, defaultConfig.series)
export.startNumber = getTyped(CardNumber.NUMBER, defaultConfig.startNumber)
export.curveID = getTyped(Common.CURVE, defaultConfig.curveID)
export.blockchain = getTyped(Common.BLOCKCHAIN, defaultConfig.blockchain)
export.blockchainCustom = getTyped(Common.BLOCKCHAIN_CUSTOM, defaultConfig.blockchainCustom)
export.MaxSignatures = getTyped(Common.MAX_SIGNATURES, defaultConfig.MaxSignatures)
export.createWallet = getTyped(Common.CREATE_WALLET, defaultConfig.createWallet)
export.SigningMethod0 = getTyped(SigningMethod.SIGN_TX, defaultConfig.SigningMethod0)
export.SigningMethod1 = getTyped(SigningMethod.SIGN_TX_RAW, defaultConfig.SigningMethod1)
export.SigningMethod2 = getTyped(SigningMethod.SIGN_VALIDATED_TX, defaultConfig.SigningMethod2)
export.SigningMethod3 = getTyped(SigningMethod.SIGN_VALIDATED_TX_RAW, defaultConfig.SigningMethod3)
export.SigningMethod4 = getTyped(SigningMethod.SIGN_VALIDATED_TX_ISSUER, defaultConfig.SigningMethod4)
export.SigningMethod5 = getTyped(SigningMethod.SIGN_VALIDATED_TX_RAW_ISSUER, defaultConfig.SigningMethod5)
export.SigningMethod6 = getTyped(SigningMethod.SIGN_EXTERNAL, defaultConfig.SigningMethod6)
export.pinLessFloorLimit = getTyped(SignHashExProp.PIN_LESS_FLOOR_LIMIT, defaultConfig.pinLessFloorLimit)
export.hexCrExKey = getTyped(SignHashExProp.CRYPTO_EXTRACT_KEY, defaultConfig.hexCrExKey)
export.requireTerminalCertSignature = getTyped(SignHashExProp.REQUIRE_TERMINAL_CERT_SIG, defaultConfig.requireTerminalCertSignature)
export.requireTerminalTxSignature = getTyped(SignHashExProp.REQUIRE_TERMINAL_TX_SIG, defaultConfig.requireTerminalTxSignature)
export.checkPIN3onCard = getTyped(SignHashExProp.CHECK_PIN3, defaultConfig.checkPIN3onCard)
export.writeOnPersonalization = getTyped(Denomination.WRITE_ON_PERSONALIZE, defaultConfig.writeOnPersonalization)
export.denomination = getTyped(Denomination.DENOMINATION, defaultConfig.denomination)
export.itsToken = getTyped(Token.ITS_TOKEN, defaultConfig.itsToken)
export.symbol = getTyped(Token.SYMBOL, defaultConfig.symbol)
export.contractAddress = getTyped(Token.CONTRACT_ADDRESS, defaultConfig.contractAddress)
export.decimal = getTyped(Token.DECIMAL, defaultConfig.decimal)
export.cardData = export.cardData.apply { this.product_note = getTyped(ProductMask.NOTE, defaultConfig.cardData.product_note) }
export.cardData = export.cardData.apply { this.product_tag = getTyped(ProductMask.TAG, defaultConfig.cardData.product_tag) }
export.cardData = export.cardData.apply { this.product_id_card = getTyped(ProductMask.ID_CARD, defaultConfig.cardData.product_id_card) }
export.isReusable = getTyped(SettingsMask.IS_REUSABLE, defaultConfig.isReusable)
export.useActivation = getTyped(SettingsMask.NEED_ACTIVATION, defaultConfig.useActivation)
export.forbidPurgeWallet = getTyped(SettingsMask.FORBID_PURGE, defaultConfig.forbidPurgeWallet)
export.allowSelectBlockchain = getTyped(SettingsMask.ALLOW_SELECT_BLOCKCHAIN, defaultConfig.allowSelectBlockchain)
export.useBlock = getTyped(SettingsMask.USE_BLOCK, defaultConfig.useBlock)
export.useOneCommandAtTime = getTyped(SettingsMask.ONE_APDU, defaultConfig.useOneCommandAtTime)
export.useCVC = getTyped(SettingsMask.USE_CVC, defaultConfig.useCVC)
export.allowSwapPIN = getTyped(SettingsMask.ALLOW_SWAP_PIN, defaultConfig.allowSwapPIN)
export.allowSwapPIN2 = getTyped(SettingsMask.ALLOW_SWAP_PIN2, defaultConfig.allowSwapPIN2)
export.forbidDefaultPIN = getTyped(SettingsMask.FORBID_DEFAULT_PIN, defaultConfig.forbidDefaultPIN)
export.smartSecurityDelay = getTyped(SettingsMask.SMART_SECURITY_DELAY, defaultConfig.smartSecurityDelay)
export.protectIssuerDataAgainstReplay = getTyped(SettingsMask.PROTECT_ISSUER_DATA_AGAINST_REPLAY, defaultConfig.protectIssuerDataAgainstReplay)
export.skipSecurityDelayIfValidatedByIssuer = getTyped(SettingsMask.SKIP_SECURITY_DELAY_IF_VALIDATED, defaultConfig.skipSecurityDelayIfValidatedByIssuer)
export.skipCheckPIN2andCVCIfValidatedByIssuer = getTyped(SettingsMask.SKIP_PIN2_CVC_IF_VALIDATED, defaultConfig.skipCheckPIN2andCVCIfValidatedByIssuer)
export.skipSecurityDelayIfValidatedByLinkedTerminal = getTyped(SettingsMask.SKIP_SECURITY_DELAY_ON_LINKED_TERMINAL, defaultConfig.skipSecurityDelayIfValidatedByLinkedTerminal)
export.restrictOverwriteIssuerDataEx = getTyped(SettingsMask.RESTRICT_OVERWRITE_EXTRA_ISSUER_DATA, defaultConfig.restrictOverwriteIssuerDataEx)
export.protocolAllowUnencrypted = getTyped(SettingsMaskProtocolEnc.ALLOW_UNENCRYPTED, defaultConfig.protocolAllowUnencrypted)
export.allowFastEncryption = getTyped(SettingsMaskProtocolEnc.ALLOW_FAST_ENCRYPTION, defaultConfig.protocolAllowStaticEncryption)
export.useNDEF = getTyped(SettingsMaskNdef.USE_NDEF, defaultConfig.useNDEF)
export.useDynamicNDEF = getTyped(SettingsMaskNdef.DYNAMIC_NDEF, defaultConfig.useDynamicNDEF)
export.disablePrecomputedNDEF = getTyped(SettingsMaskNdef.DISABLE_PRECOMPUTED_NDEF, defaultConfig.disablePrecomputedNDEF)
export.NDEF = getTyped(SettingsMaskNdef.AAR, defaultConfig.NDEF)
export.PIN = getTyped(Pins.PIN, defaultConfig.PIN)
export.PIN2 = getTyped(Pins.PIN2, defaultConfig.PIN2)
export.PIN3 = getTyped(Pins.PIN3, defaultConfig.PIN3)
export.CVC = getTyped(Pins.CVC, defaultConfig.CVC)
export.pauseBeforePIN2 = getTyped(Pins.PAUSE_BEFORE_PIN2, defaultConfig.pauseBeforePIN2)
return export
}
private inline fun <reified Type> getTyped(id: Id, def: Type): Type {
return getTypedBy<Type>(updatedByItemList, id) ?: getTypedBy<Type>(default, id)!!
}
private inline fun <reified Type> getTypedBy(associations: IdToValueAssociations, id: Id): Type? {
Log.d(this, "getTyped for id: $id")
var typedValue = associations.get(id)?.get()
typedValue = when (typedValue) {
is ListValueWrapper -> (typedValue.selectedItem as KeyValue).value as Type
else -> typedValue as? Type ?: null
}
return typedValue
}
}

View file

@ -0,0 +1,107 @@
package com.tangem.tangemtest.ucase.variants.personalize.dto
/**
[REDACTED_AUTHOR]
*/
class PersonalizeConfig {
// Card number
var series = "DB"
var startNumber: Long = 300000000000
// Common
var curveID = "ed25519"
var blockchain = "btc"
var blockchainCustom = "custom"
var MaxSignatures: Long = 1000000
var createWallet = true
// Signing method
var SigningMethod0 = false
var SigningMethod1 = false
var SigningMethod2 = false
var SigningMethod3 = false
var SigningMethod4 = false
var SigningMethod5 = false
var SigningMethod6 = false
// Sign hash external properties
var pinLessFloorLimit: Long = 0
var hexCrExKey = ""
var requireTerminalTxSignature = false
var requireTerminalCertSignature = false
var checkPIN3onCard = false
// Denomination
var writeOnPersonalization = false
var denomination: Long = 0
// Token
var itsToken = true
var symbol = "token symbol"
var contractAddress = "contact adress"
var decimal: Long = 1
var cardData = CardData()
// Settings mask
var isReusable = true
var useActivation = false
var forbidPurgeWallet = false
var allowSelectBlockchain = false
var useBlock = false
var useOneCommandAtTime = false
var useCVC = false
var allowSwapPIN = false
var allowSwapPIN2 = true
var forbidDefaultPIN = false
var smartSecurityDelay = true
var protectIssuerDataAgainstReplay = true
var skipSecurityDelayIfValidatedByIssuer = false
var skipCheckPIN2andCVCIfValidatedByIssuer = false
var skipSecurityDelayIfValidatedByLinkedTerminal = true
var restrictOverwriteIssuerDataEx = false
// Settings mask - protocol encryption
var protocolAllowUnencrypted = true
var allowFastEncryption = false
var protocolAllowStaticEncryption = true
var useNDEF = true
var useDynamicNDEF = true
var disablePrecomputedNDEF = false
var NDEF = "com.tangem.wallet"
// Pins
var PIN = "000000"
var PIN2 = "000"
var PIN3 = ""
var CVC = "000"
var pauseBeforePIN2: Long = 15000
// not used
// var count: Long = 20
// var numberFormat = ""
// var issuerData = null
// var releaseVersion = false
// var issuerName = "TANGEM SDK"
}
class CardData {
var date = "2020-02-17"
var batch = "FF87"
var blockchain = "IROHA"
var product_note = true
var product_tag = false
var product_id_card = false
}

View file

@ -1,114 +0,0 @@
package com.tangem.tangemtest.ucase.variants.personalize.dto
/**
[REDACTED_AUTHOR]
*/
class TestJsonDto {
// Card number
val series = "DB"
val startNumber = 300000000000
// Common
val curveID = "ed25519"
val blockchain = Blockchain() // новое поле
val MaxSignatures = 1000000
val createWallet = 1
val createWalletB = createWallet == 1
// Signing method
val SigningMethod0 = false
val SigningMethod1 = false
val SigningMethod2 = false
val SigningMethod3 = false
val SigningMethod4 = false
val SigningMethod5 = false
val SigningMethod6 = false
// Sign hash external properties
val pinLessFloorLimit = 0 // новое поле
val hexCrExKey = ""
val requireTerminalTxSignature = false
val requireTerminalCertSignature = false
val checkPIN3onCard = false
// Denomination
val writeOnPersonalization = false // новое поле
val denomination = 0 // новое поле
// Token
val itsToken = true // новое поле
val symbol = "token symbol" // новое поле
val contractAddress = "contact adress" // новое поле
val decimal = 1 // новое поле
val cardData = CardData()
// Settings mask
val isReusable = true
val useActivation = false
val forbidPurgeWallet = false
val allowSelectBlockchain = false
val useBlock = false
val useOneCommandAtTime = false
val useCVC = false
val allowSwapPIN = false
val allowSwapPIN2 = true
val forbidDefaultPIN = false
val smartSecurityDelay = true
val protectIssuerDataAgainstReplay = true
val skipSecurityDelayIfValidatedByIssuer = false
val skipCheckPIN2andCVCIfValidatedByIssuer = false
val skipSecurityDelayIfValidatedByLinkedTerminal = true
val restrictOverwriteIssuerDataEx = false
// Settings mask - protocol encryption
val protocolAllowUnencrypted = true
val protocolAllowStaticEncryption = true
val useNDEF = true
val useDynamicNDEF = true
val disablePrecomputedNDEF = false
val NDEF: MutableList<Ndef> = mutableListOf(Ndef("AAR", "com.tangem.wallet")) // aar, customAAR package
// Pins
val PIN = "000000"
val PIN2 = "000"
val PIN3 = ""
val CVC = "000"
val pauseBeforePIN2 = 15000
// not used
val count = 20
val numberFormat = ""
val issuerData = null
val releaseVersion = false
val issuerName = "TANGEM SDK"
}
class CardData {
val date = "2020-02-17"
val batch = "FF87"
val blockchain = "IROHA"
val product_note = true
val product_tag = false
val product_id_card = false
}
class Blockchain {
val customName: String? = null
val name = "BTC"
}
class Ndef(val type: String, val value: String)

View file

@ -8,10 +8,9 @@ import com.google.gson.Gson
import com.tangem.tangemtest._arch.structure.abstraction.BaseItem
import com.tangem.tangemtest._arch.structure.abstraction.Block
import com.tangem.tangemtest.ucase.variants.personalize.converter.BlockToJsonConverter
import com.tangem.tangemtest.ucase.variants.personalize.converter.IdToJsonValues
import com.tangem.tangemtest.ucase.variants.personalize.converter.JsonBlockEnDe
import com.tangem.tangemtest.ucase.variants.personalize.converter.JsonToBlockConverter
import com.tangem.tangemtest.ucase.variants.personalize.dto.TestJsonDto
import com.tangem.tangemtest.ucase.variants.personalize.converter.ValueMapper
import com.tangem.tangemtest.ucase.variants.personalize.dto.PersonalizeConfig
/**
[REDACTED_AUTHOR]
@ -22,13 +21,18 @@ class PersonalizeViewModelFactory(private val jsonPersonalizeString: String) : V
class PersonalizeViewModel(private val jsonPersonalizeString: String) : ViewModel() {
val ldBlockList: MutableLiveData<List<Block>> by lazy { MutableLiveData(readJson()) }
val ldBlockList: MutableLiveData<List<Block>> by lazy { MutableLiveData(initBlockList()) }
private fun readJson(): List<Block> {
val idToJsonValues = IdToJsonValues()
val enDe = JsonBlockEnDe(JsonToBlockConverter(idToJsonValues), BlockToJsonConverter())
val jsonDto = Gson().fromJson(jsonPersonalizeString, TestJsonDto::class.java)
return enDe.decode(jsonDto)
private fun initBlockList(): List<Block> = parseJsonToBlockList(jsonPersonalizeString)
fun parseJsonToBlockList(jsonString: String): List<Block> {
val config = Gson().fromJson(jsonString, PersonalizeConfig::class.java)
return JsonToBlockConverter().convert(config)
}
fun prepareJson(blocList: List<Block>): String {
val jsonDto = BlockToJsonConverter(ValueMapper(), PersonalizeConfig()).convert(blocList)
return Gson().toJson(jsonDto)
}
fun toggleDescriptionVisibility(state: Boolean) {

View file

@ -39,8 +39,8 @@ class NumberWidget(parent: ViewGroup, data: NumberItem) : DescriptionWidget<Numb
}
}
private fun getIntValue(value: String): Number? {
return if (value.isEmpty()) null else value.toInt()
private fun getIntValue(value: String): Long {
return if (value.isEmpty()) 0L else value.toLong()
}
}