Updated on 2026-08-14
This commit is contained in:
commit
177a05dce3
24 changed files with 150 additions and 70 deletions
|
|
@ -89,7 +89,7 @@ public class BinanceAssetEngine extends CoinEngine {
|
|||
|
||||
@Override
|
||||
public String getBalanceHTML() {
|
||||
Amount balance = getBalance();
|
||||
Amount balance = coinData.getBalance();
|
||||
Amount assetBalance = coinData.getAssetBalance();
|
||||
if (balance != null) {
|
||||
if (assetBalance != null) {
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ public class BinanceEngine extends CoinEngine {
|
|||
@Override
|
||||
public boolean hasBalanceInfo() {
|
||||
if (coinData == null) return false;
|
||||
return coinData.hasBalanceInfo();
|
||||
return coinData.hasBalanceInfo() || coinData.isError404();
|
||||
}
|
||||
|
||||
public boolean isExtractPossible() {
|
||||
|
|
|
|||
|
|
@ -166,6 +166,8 @@ class CardSession(
|
|||
* @param error An error that will be shown.
|
||||
*/
|
||||
private fun stopWithError(error: Exception) {
|
||||
if (!isBusy) return
|
||||
|
||||
reader.closeSession()
|
||||
isBusy = false
|
||||
|
||||
|
|
@ -175,9 +177,12 @@ class CardSession(
|
|||
error.localizedMessage
|
||||
}
|
||||
if (error !is TangemSdkError.UserCancelled) {
|
||||
Log.e("tag", "Finishing with error: $errorMessage")
|
||||
Log.e(tag, "Finishing with error: $errorMessage")
|
||||
viewDelegate.onError(errorMessage)
|
||||
} else {
|
||||
Log.i(tag, "User cancelled NFC session")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun send(apdu: CommandApdu, callback: (result: CompletionResult<ResponseApdu>) -> Unit) {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ abstract class Command<T : CommandResponse> : CardSessionRunnable<T> {
|
|||
abstract fun deserialize(environment: SessionEnvironment, apdu: ResponseApdu): T
|
||||
|
||||
override fun run(session: CardSession, callback: (result: CompletionResult<T>) -> Unit) {
|
||||
Log.i("Command", "Sending ${this::class.java.simpleName}")
|
||||
Log.i("Command", "Initializing ${this::class.java.simpleName}")
|
||||
if (session.environment.handleErrors) {
|
||||
if (performPreCheck(session, callback)) return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class TlvBuilder {
|
|||
|
||||
fun serialize(): ByteArray {
|
||||
Log.v("TLV",
|
||||
"List of encoded TLVs:\n${tlvs.joinToString("\n")}")
|
||||
"Data encoded to TLVs:\n${tlvs.joinToString("\n")}")
|
||||
return tlvs.serialize()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class TlvDecoder(val tlvList: List<Tlv>) {
|
|||
|
||||
init {
|
||||
Log.v("TLV",
|
||||
"List of decoded TLVs:\n${tlvList.joinToString("\n")}")
|
||||
"Decoding data from TLV:\n${tlvList.joinToString("\n")}")
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -33,7 +33,7 @@ class TlvDecoder(val tlvList: List<Tlv>) {
|
|||
*/
|
||||
inline fun <reified T> decodeOptional(tag: TlvTag): T? =
|
||||
try {
|
||||
decode<T>(tag)
|
||||
decode<T>(tag, false)
|
||||
} catch (exception: TangemSdkError.DecodingFailedMissingTag) {
|
||||
null
|
||||
}
|
||||
|
|
@ -47,14 +47,18 @@ class TlvDecoder(val tlvList: List<Tlv>) {
|
|||
*
|
||||
* @return [Tlv] value converted to a nullable type [T].
|
||||
*
|
||||
* @throws [TaskError.MissingTag] exception if no [Tlv] is found by the Tag.
|
||||
* @throws [TangemSdkError.DecodingFailedMissingTag] exception if no [Tlv] is found by the Tag.
|
||||
*/
|
||||
inline fun <reified T> decode(tag: TlvTag): T {
|
||||
inline fun <reified T> decode(tag: TlvTag, logError: Boolean = true): T {
|
||||
val tlvValue: ByteArray = tlvList.find { it.tag == tag }?.value
|
||||
?: if (tag.valueType() == TlvValueType.BoolValue && T::class == Boolean::class) {
|
||||
return false as T
|
||||
} else {
|
||||
Log.e(this::class.simpleName!!, "Tag $tag not found")
|
||||
if (logError) {
|
||||
Log.e(this::class.simpleName!!, "TLV $tag not found")
|
||||
} else {
|
||||
Log.v(this::class.simpleName!!, "TLV $tag not found, but it is not required")
|
||||
}
|
||||
throw TangemSdkError.DecodingFailedMissingTag()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import android.content.ClipData
|
|||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
|
||||
/**
|
||||
|
|
@ -17,11 +16,7 @@ fun Context.copyToClipboard(value: Any, label: String = "") {
|
|||
clipboard.setPrimaryClip(clip)
|
||||
}
|
||||
|
||||
fun Fragment.shareText(text: String) {
|
||||
requireActivity().shareText(text)
|
||||
}
|
||||
|
||||
fun ComponentActivity.shareText(text: String) {
|
||||
fun Context.shareText(text: String) {
|
||||
val sendIntent: Intent = Intent().apply {
|
||||
action = Intent.ACTION_SEND
|
||||
putExtra(Intent.EXTRA_TEXT, text)
|
||||
|
|
@ -29,4 +24,8 @@ fun ComponentActivity.shareText(text: String) {
|
|||
}
|
||||
val shareIntent = Intent.createChooser(sendIntent, null)
|
||||
startActivity(shareIntent)
|
||||
}
|
||||
|
||||
fun Fragment.shareText(text: String) {
|
||||
requireContext().shareText(text)
|
||||
}
|
||||
|
|
@ -7,10 +7,7 @@ import com.tangem.devkit.commons.Store
|
|||
import com.tangem.devkit.ucase.domain.actions.PersonalizeAction
|
||||
import com.tangem.devkit.ucase.domain.paramsManager.ActionCallback
|
||||
import com.tangem.devkit.ucase.variants.personalize.converter.PersonalizationConfigConverter
|
||||
import com.tangem.devkit.ucase.variants.personalize.converter.PersonalizationJsonConverter
|
||||
import com.tangem.devkit.ucase.variants.personalize.dto.PersonalizationConfig
|
||||
import com.tangem.devkit.ucase.variants.personalize.dto.PersonalizationJson
|
||||
import ru.dev.gbixahue.eu4d.lib.android.global.log.Log
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
|
|
@ -30,27 +27,6 @@ class PersonalizationItemsManager(
|
|||
action.executeMainAction(this, getAttrsForAction(tangemSdk), callback)
|
||||
}
|
||||
|
||||
fun importJsonConfig(jsonString: String) {
|
||||
if (jsonString.isEmpty()) return
|
||||
|
||||
val jsonDto = try {
|
||||
PersonalizationJson.getJsonConverter().fromJson(jsonString, PersonalizationJson::class.java)
|
||||
} catch (ex: Exception) {
|
||||
Log.e(this, "Can't convert imported string to Json object. Error: $ex")
|
||||
return
|
||||
}
|
||||
|
||||
val config = PersonalizationJsonConverter().aToB(jsonDto)
|
||||
updateByItemList(converter.convert(config))
|
||||
}
|
||||
|
||||
fun exportJsonConfig(): String {
|
||||
val config = converter.convert(itemList, PersonalizationConfig.default())
|
||||
val jsonDto = PersonalizationJsonConverter().bToA(config)
|
||||
val jsonString = PersonalizationJson.getJsonConverter().toJson(jsonDto)
|
||||
return jsonString
|
||||
}
|
||||
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
||||
fun onDestroy() {
|
||||
val config = converter.convert(itemList, PersonalizationConfig.default())
|
||||
|
|
|
|||
|
|
@ -106,8 +106,8 @@ internal class Helper {
|
|||
KeyValue("RSK", "RSK"),
|
||||
KeyValue("XPR", "XPR"),
|
||||
KeyValue("CARDANO", "CARDANO"),
|
||||
KeyValue("BNB", "BNB"),
|
||||
KeyValue("XTZ", "XTZ"),
|
||||
KeyValue("BNB", "BINANCE"),
|
||||
KeyValue("XTZ", "TEZOS"),
|
||||
KeyValue("DUC", "DUC")
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,9 +71,9 @@ class ItemsToPersonalizationConfig : ItemsToModel<PersonalizationConfig> {
|
|||
export.requireTerminalTxSignature = getTyped(SignHashExPropId.RequireTerminalTxSig)
|
||||
export.checkPIN3onCard = getTyped(SignHashExPropId.CheckPin3)
|
||||
export.itsToken = getTyped(TokenId.ItsToken)
|
||||
export.cardData.token_symbol = getTyped(TokenId.Symbol)
|
||||
export.cardData.token_contract_address = getTyped(TokenId.ContractAddress)
|
||||
export.cardData.token_decimal = getTyped(TokenId.Decimal)
|
||||
export.cardData.token_symbol = getTypedUnsafe(TokenId.Symbol)
|
||||
export.cardData.token_contract_address = getTypedUnsafe(TokenId.ContractAddress)
|
||||
export.cardData.token_decimal = getTypedUnsafe(TokenId.Decimal)
|
||||
export.cardData = export.cardData.apply { this.product_note = getTyped(ProductMaskId.Note) }
|
||||
export.cardData = export.cardData.apply { this.product_tag = getTyped(ProductMaskId.Tag) }
|
||||
export.cardData = export.cardData.apply { this.product_id_card = getTyped(ProductMaskId.IdCard) }
|
||||
|
|
@ -114,6 +114,10 @@ class ItemsToPersonalizationConfig : ItemsToModel<PersonalizationConfig> {
|
|||
return getTypedBy<Type>(valuesHolder, id)!!
|
||||
}
|
||||
|
||||
private inline fun <reified Type> getTypedUnsafe(id: Id): Type? {
|
||||
return getTypedBy<Type>(valuesHolder, id)
|
||||
}
|
||||
|
||||
private inline fun <reified Type> getTypedBy(holder: ConfigValuesHolder, id: Id): Type? {
|
||||
Log.d(this, "getTyped for id: $id")
|
||||
var typedValue = holder.get(id)?.get()
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import androidx.recyclerview.widget.DividerItemDecoration
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.transition.Fade
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import com.tangem.commands.Card
|
||||
import com.tangem.devkit.R
|
||||
import com.tangem.devkit._arch.structure.Id
|
||||
|
|
@ -25,6 +26,7 @@ import com.tangem.devkit.commons.DialogController
|
|||
import com.tangem.devkit.commons.view.MultiActionView
|
||||
import com.tangem.devkit.commons.view.ViewAction
|
||||
import com.tangem.devkit.extensions.copyToClipboard
|
||||
import com.tangem.devkit.extensions.shareText
|
||||
import com.tangem.devkit.extensions.view.beginDelayedTransition
|
||||
import com.tangem.devkit.ucase.domain.paramsManager.ItemsManager
|
||||
import com.tangem.devkit.ucase.domain.paramsManager.PayloadKey
|
||||
|
|
@ -132,6 +134,7 @@ class PersonalizationFragment : BaseCardActionFragment(), PersonalizationPresetV
|
|||
fun initImportExportJson(parent: ViewGroup) {
|
||||
val tvJsonExport = parent.findViewById<EditText>(R.id.et_json_export)
|
||||
val btnExportJson = parent.findViewById<Button>(R.id.btn_export_json)
|
||||
val presetManager = PersonalizationPresetManager(itemsManager, this)
|
||||
|
||||
tvJsonExport.setOnClickListener {
|
||||
val jsonString = tvJsonExport.text
|
||||
|
|
@ -139,13 +142,13 @@ class PersonalizationFragment : BaseCardActionFragment(), PersonalizationPresetV
|
|||
requireContext().copyToClipboard(jsonString, "Exported Json")
|
||||
}
|
||||
btnExportJson.setOnClickListener {
|
||||
tvJsonExport.setText(personalizationItemsManager.exportJsonConfig())
|
||||
tvJsonExport.setText(presetManager.exportJsonConfig())
|
||||
}
|
||||
|
||||
val tvJsonImport = parent.findViewById<EditText>(R.id.et_json_import)
|
||||
val btnImportJson = parent.findViewById<Button>(R.id.btn_import_json)
|
||||
btnImportJson.setOnClickListener {
|
||||
personalizationItemsManager.importJsonConfig(tvJsonImport.text.toString().trim())
|
||||
presetManager.importJsonConfig(tvJsonImport.text.toString().trim())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -168,11 +171,13 @@ class PersonalizationFragment : BaseCardActionFragment(), PersonalizationPresetV
|
|||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
val store = PersonalizationConfigStore(requireContext())
|
||||
val presetManager = PersonalizationPresetManager(itemsManager, store, this)
|
||||
val presetManager = PersonalizationPresetManager(itemsManager, this)
|
||||
val result = when (item.itemId) {
|
||||
R.id.action_reset -> presetManager.resetToDefault()
|
||||
R.id.action_save -> presetManager.savePreset()
|
||||
R.id.action_load -> presetManager.loadPreset()
|
||||
R.id.action_import_preset -> showImportPresetDialog(presetManager)
|
||||
R.id.action_share_preset -> shareText(presetManager.exportJsonConfig())
|
||||
R.id.action_reset -> presetManager.resetToDefault(store)
|
||||
R.id.action_save -> presetManager.savePreset(store)
|
||||
R.id.action_load -> presetManager.loadPreset(store)
|
||||
else -> null
|
||||
}
|
||||
return if (result == null) super.onOptionsItemSelected(item) else true
|
||||
|
|
@ -191,13 +196,16 @@ class PersonalizationFragment : BaseCardActionFragment(), PersonalizationPresetV
|
|||
override fun showSavePresetDialog(onOk: SafeValueChanged<String>) {
|
||||
val dlgController = DialogController()
|
||||
val dlg = dlgController.createAlert(requireActivity(), R.layout.dlg_personalization_preset_save)
|
||||
dlgController.view?.findViewById<TextInputLayout>(R.id.til_item)?.let {
|
||||
it.hint = getString(R.string.hint_enter_preset_name)
|
||||
}
|
||||
dlg.setTitle(R.string.menu_personalization_preset_save)
|
||||
dlg.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.btn_cancel)) { dialog, which -> }
|
||||
dlg.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.btn_ok)) { dialog, which ->
|
||||
val tvName = dlgController.view?.findViewById<EditText>(R.id.et_item)
|
||||
?: return@setButton
|
||||
val name = tvName.text.toString()
|
||||
if (name.isEmpty()) showSnackbar("Not saved")
|
||||
if (name.isEmpty()) showSnackbar(R.string.error_not_saved)
|
||||
else onOk.invoke(name)
|
||||
}
|
||||
dlgController.onShowCallback = {
|
||||
|
|
@ -235,4 +243,30 @@ class PersonalizationFragment : BaseCardActionFragment(), PersonalizationPresetV
|
|||
rvPresetNames.adapter = adapter
|
||||
dlgController.show()
|
||||
}
|
||||
|
||||
private fun showImportPresetDialog(presetManager: PersonalizationPresetManager) {
|
||||
val dlgController = DialogController()
|
||||
val dlg = dlgController.createAlert(requireActivity(), R.layout.dlg_personalization_preset_save)
|
||||
dlgController.view?.findViewById<TextInputLayout>(R.id.til_item)?.let {
|
||||
it.hint = getString(R.string.hint_paste)
|
||||
}
|
||||
dlg.setTitle(R.string.menu_personalization_preset_import)
|
||||
dlg.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.btn_cancel)) { dialog, which -> }
|
||||
dlg.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.btn_ok)) { dialog, which ->
|
||||
val tvName = dlgController.view?.findViewById<EditText>(R.id.et_item) ?: return@setButton
|
||||
val name = tvName.text.toString()
|
||||
if (name.isEmpty()) showSnackbar(R.string.error_nothing_to_import)
|
||||
else presetManager.importJsonConfig(name)
|
||||
}
|
||||
dlgController.onShowCallback = {
|
||||
dlgController.view?.findViewById<TextView>(R.id.et_item)?.let {
|
||||
post(150) {
|
||||
it.requestFocus()
|
||||
val imm = getSystemService(requireContext(), InputMethodManager::class.java)
|
||||
imm?.showSoftInput(it, InputMethodManager.SHOW_IMPLICIT)
|
||||
}
|
||||
}
|
||||
}
|
||||
dlgController.show()
|
||||
}
|
||||
}
|
||||
|
|
@ -4,22 +4,23 @@ import com.tangem.devkit.R
|
|||
import com.tangem.devkit.ucase.domain.paramsManager.ItemsManager
|
||||
import com.tangem.devkit.ucase.variants.personalize.PersonalizationConfigStore
|
||||
import com.tangem.devkit.ucase.variants.personalize.converter.PersonalizationConfigConverter
|
||||
import com.tangem.devkit.ucase.variants.personalize.converter.PersonalizationJsonConverter
|
||||
import com.tangem.devkit.ucase.variants.personalize.dto.PersonalizationConfig
|
||||
import com.tangem.devkit.ucase.variants.personalize.dto.PersonalizationJson
|
||||
|
||||
class PersonalizationPresetManager(
|
||||
private val itemsManager: ItemsManager,
|
||||
private val store: PersonalizationConfigStore,
|
||||
private val view: PersonalizationPresetView
|
||||
) {
|
||||
|
||||
fun resetToDefault() {
|
||||
fun resetToDefault(store: PersonalizationConfigStore) {
|
||||
val config = PersonalizationConfig.default()
|
||||
val converter = PersonalizationConfigConverter()
|
||||
itemsManager.updateByItemList(converter.convert(config))
|
||||
store.save(config)
|
||||
}
|
||||
|
||||
fun loadPreset() {
|
||||
fun loadPreset(store: PersonalizationConfigStore) {
|
||||
val presets = store.restoreAll()
|
||||
presets.remove(PersonalizationConfigStore.defaultKey)
|
||||
val namesList = presets.map { it.key }.toMutableList()
|
||||
|
|
@ -37,11 +38,34 @@ class PersonalizationPresetManager(
|
|||
})
|
||||
}
|
||||
|
||||
fun savePreset() {
|
||||
fun savePreset(store: PersonalizationConfigStore) {
|
||||
view.showSavePresetDialog { name ->
|
||||
val converter = PersonalizationConfigConverter()
|
||||
val config = converter.convert(itemsManager.getItems(), PersonalizationConfig.default())
|
||||
store.save(name, config)
|
||||
}
|
||||
}
|
||||
|
||||
fun importJsonConfig(jsonString: String) {
|
||||
if (jsonString.isEmpty()) return
|
||||
|
||||
val jsonDto = try {
|
||||
PersonalizationJson.getJsonConverter().fromJson(jsonString, PersonalizationJson::class.java)
|
||||
} catch (ex: Exception) {
|
||||
view.showSnackbar("Can't convert imported string to Json object. Error: $ex")
|
||||
return
|
||||
}
|
||||
|
||||
val config = PersonalizationJsonConverter().aToB(jsonDto)
|
||||
val converter = PersonalizationConfigConverter()
|
||||
itemsManager.updateByItemList(converter.convert(config))
|
||||
}
|
||||
|
||||
fun exportJsonConfig(): String {
|
||||
val converter = PersonalizationConfigConverter()
|
||||
val config = converter.convert(itemsManager.getItems(), PersonalizationConfig.default())
|
||||
val jsonDto = PersonalizationJsonConverter().bToA(config)
|
||||
val jsonString = PersonalizationJson.getJsonConverter().toJson(jsonDto)
|
||||
return jsonString
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ import com.tangem.devkit._arch.structure.impl.TextItem
|
|||
import com.tangem.devkit.ucase.variants.responses.CardDataId
|
||||
import com.tangem.devkit.ucase.variants.responses.CardId
|
||||
import com.tangem.devkit.ucase.variants.responses.item.TextHeaderItem
|
||||
import ru.dev.gbixahue.eu4d.lib.kotlin.stringOf
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
|
|
@ -75,7 +76,7 @@ class CardConverter : BaseResponseConverter<Card>() {
|
|||
group.addItem(TextItem(CardDataId.manufacturerSignature, fieldConverter.byteArrayToHex(data.manufacturerSignature)))
|
||||
group.addItem(TextItem(CardDataId.tokenSymbol, data.tokenSymbol))
|
||||
group.addItem(TextItem(CardDataId.tokenContractAddress, data.tokenContractAddress))
|
||||
group.addItem(TextItem(CardDataId.tokenDecimal, data.tokenSymbol))
|
||||
group.addItem(TextItem(CardDataId.tokenDecimal, stringOf(data.tokenDecimal)))
|
||||
|
||||
val productMask = data.productMask ?: return
|
||||
|
||||
|
|
|
|||
12
tangem-devkit/src/main/res/drawable/ic_import.xml
Normal file
12
tangem-devkit/src/main/res/drawable/ic_import.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="20dp"
|
||||
android:height="20dp"
|
||||
android:viewportWidth="1000"
|
||||
android:viewportHeight="1000">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M881.1,10h-490C331,10 282.2,58.8 282.2,118.9v81.6H118.9C58.8,200.6 10,249.3 10,309.5v571.6C10,941.2 58.8,990 118.9,990h571.7c60.1,0 108.9,-48.8 108.9,-108.9V717.8h81.7c60.1,0 108.9,-48.8 108.9,-108.9v-490C990,58.8 941.2,10 881.1,10zM935.6,608.9c0,30.1 -24.4,54.5 -54.4,54.5h-81.7V380.1L745,434.5v446.6c0,30.1 -24.4,54.5 -54.4,54.5H118.9c-30.1,0 -54.4,-24.4 -54.4,-54.5V309.4c0,-30.1 24.4,-54.4 54.4,-54.4h446.5l54.5,-54.4H336.7v-81.7c0,-30.1 24.4,-54.4 54.4,-54.4h490c30.1,0 54.4,24.4 54.4,54.4V608.9z" />
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M753.4,209L310.2,652.1l0.9,-185.5c0,-15.1 -12.2,-27.2 -27.3,-27.2c-15.1,0 -27.2,12.2 -27.2,27.2l-1.3,250.7c0,15.1 12.2,27.3 27.3,27.3c3,0 5.8,-0.6 8.5,-1.6l242,0.1c14.9,0.1 26.9,-11.9 26.8,-26.8c-0.1,-14.9 -12.2,-27 -27.1,-27.1l-182.4,0l441.6,-441.6c10.6,-10.6 10.6,-27.9 0,-38.5C781.2,198.4 764,198.4 753.4,209z" />
|
||||
</vector>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="18dp"
|
||||
android:height="18dp"
|
||||
android:width="20dp"
|
||||
android:height="20dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="@dimen/def_indent"
|
||||
android:paddingBottom="@dimen/def_half_indent">
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<include
|
||||
layout="@layout/m_divider_h"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp" />
|
||||
android:layout_height="1.5dp" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
app:boxBackgroundColor="@android:color/transparent"
|
||||
android:hint="Enter a preset name"
|
||||
tools:hint="Field name">
|
||||
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
|
|
|
|||
|
|
@ -1,11 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<group android:id="@+id/menu_group_personalization_preset">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_reset"
|
||||
android:title="@string/menu_personalization_preset_reset" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_import_preset"
|
||||
android:icon="@drawable/ic_import"
|
||||
android:title="@string/menu_import"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_share_preset"
|
||||
android:icon="@drawable/ic_share_white_18dp"
|
||||
android:title="@string/menu_share"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_save"
|
||||
android:title="@string/menu_personalization_preset_save" />
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<item
|
||||
android:id="@+id/action_share"
|
||||
android:icon="@drawable/ic_share_white_18dp"
|
||||
android:title="@string/menu_response_share"
|
||||
android:title="@string/menu_share"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
<string name="app_name">Tangem DevKit</string>
|
||||
|
||||
<string name="menu_main_description">Description</string>
|
||||
<string name="menu_share">Share</string>
|
||||
<string name="menu_import">Import</string>
|
||||
|
||||
<string name="copy_to_clipboard">Copy to clipboard</string>
|
||||
<string name="btn_delete">Delete</string>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,13 @@
|
|||
<string name="menu_personalization_preset_reset">Reset to default</string>
|
||||
<string name="menu_personalization_preset_save">Save configuration</string>
|
||||
<string name="menu_personalization_preset_load">Load configuration</string>
|
||||
<string name="menu_personalization_preset_import">Import configuration</string>
|
||||
|
||||
<string name="hint_enter_preset_name">Enter a preset name</string>
|
||||
<string name="hint_paste">Paste</string>
|
||||
|
||||
<string name="error_nothing_to_import">Nothing to import</string>
|
||||
<string name="error_not_saved">Not saved</string>
|
||||
|
||||
<string name="personalize">Personalize</string>
|
||||
<string name="depersonalize">Depersonalize</string>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string name="menu_response_share">Share</string>
|
||||
|
||||
<!-- Field names - Response: Card -->
|
||||
<string name="response_card_cid">CID</string>
|
||||
<string name="response_card_manufacturer_name">Manufacturer_Name</string>
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ class DefaultSessionViewDelegate(private val reader: NfcReader) : SessionViewDel
|
|||
readingDialog?.setOnCancelListener {
|
||||
reader.readingCancelled = true
|
||||
reader.closeSession()
|
||||
Log.i(this::class.simpleName!!, "readingCancelled is set to true")
|
||||
}
|
||||
readingDialog?.show()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class NfcReader : CardReader {
|
|||
if (field == null) {
|
||||
field = value
|
||||
// if tag is received, call connect first before transceiving data
|
||||
connect()
|
||||
if (value != null) connect()
|
||||
}
|
||||
if (value == null) field = value
|
||||
}
|
||||
|
|
@ -46,6 +46,7 @@ class NfcReader : CardReader {
|
|||
private var callback: ((response: CompletionResult<ResponseApdu>) -> Unit)? = null
|
||||
|
||||
override fun openSession() {
|
||||
Log.i(this::class.simpleName!!, "NFC reader is starting NFC session")
|
||||
readingActive = true
|
||||
readingCancelled = false
|
||||
manager?.disableReaderMode()
|
||||
|
|
@ -74,6 +75,7 @@ class NfcReader : CardReader {
|
|||
|
||||
val rawResponse: ByteArray?
|
||||
try {
|
||||
Log.i(this::class.simpleName!!, "Sending data to the card")
|
||||
rawResponse = isoDep?.transceive(data)
|
||||
} catch (exception: TagLostException) {
|
||||
callback?.invoke(CompletionResult.Failure(TangemSdkError.TagLost()))
|
||||
|
|
@ -85,7 +87,7 @@ class NfcReader : CardReader {
|
|||
return
|
||||
}
|
||||
if (rawResponse != null) {
|
||||
Log.i(this::class.simpleName!!, "Nfc response is received")
|
||||
Log.i(this::class.simpleName!!, "Data from the card was received")
|
||||
data = null
|
||||
}
|
||||
rawResponse?.let { callback?.invoke(CompletionResult.Success(ResponseApdu(it))) }
|
||||
|
|
@ -103,7 +105,7 @@ class NfcReader : CardReader {
|
|||
isoDep?.close()
|
||||
isoDep?.connect()
|
||||
isoDep?.timeout = 240000
|
||||
Log.i(this::class.simpleName!!, "Nfc session is started")
|
||||
Log.i(this::class.simpleName!!, "NFC tag is connected")
|
||||
}
|
||||
|
||||
private fun onNfcVDiscovered(nfcV: NfcV) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue