From b93123572171f134909232dd85b5fea1ec28d63e Mon Sep 17 00:00:00 2001 From: Anton Zhilenkov Date: Wed, 15 Dec 2021 19:11:33 +0300 Subject: [PATCH 01/42] CSK-271 fixed progressBar color for the nightMode by replacing it with CircularProgressIndicator --- .../tangem/tangem_sdk_new/extensions/View.kt | 10 + .../tangem_sdk_new/ui/widget/StateWidget.kt | 7 +- .../widget/progressBar/ProgressStateWidget.kt | 292 ++++++++---------- .../src/main/res/anim/linear_interpolator.xml | 2 - .../main/res/anim/trim_end_interpolator.xml | 3 - .../main/res/anim/trim_start_interpolator.xml | 3 - .../progress_indeterminate_animator.xml | 27 -- ...ogress_indeterminate_rotation_animator.xml | 9 - .../src/main/res/drawable/progress_bar.xml | 24 -- .../drawable/progress_bar_indeterminate.xml | 27 -- .../progress_bar_indeterminate_anim.xml | 50 --- .../main/res/layout/bottom_sheet_layout.xml | 2 + .../main/res/layout/progress_bar_layout.xml | 103 +++--- .../src/main/res/values-night/colors.xml | 2 +- 14 files changed, 203 insertions(+), 358 deletions(-) delete mode 100644 tangem-sdk-android/src/main/res/anim/linear_interpolator.xml delete mode 100644 tangem-sdk-android/src/main/res/anim/trim_end_interpolator.xml delete mode 100644 tangem-sdk-android/src/main/res/anim/trim_start_interpolator.xml delete mode 100644 tangem-sdk-android/src/main/res/animator/progress_indeterminate_animator.xml delete mode 100644 tangem-sdk-android/src/main/res/animator/progress_indeterminate_rotation_animator.xml delete mode 100644 tangem-sdk-android/src/main/res/drawable/progress_bar.xml delete mode 100644 tangem-sdk-android/src/main/res/drawable/progress_bar_indeterminate.xml delete mode 100644 tangem-sdk-android/src/main/res/drawable/progress_bar_indeterminate_anim.xml diff --git a/tangem-sdk-android/src/main/java/com/tangem/tangem_sdk_new/extensions/View.kt b/tangem-sdk-android/src/main/java/com/tangem/tangem_sdk_new/extensions/View.kt index 5a56e58d..4c2d5159 100644 --- a/tangem-sdk-android/src/main/java/com/tangem/tangem_sdk_new/extensions/View.kt +++ b/tangem-sdk-android/src/main/java/com/tangem/tangem_sdk_new/extensions/View.kt @@ -5,6 +5,8 @@ import android.view.View import android.view.animation.AccelerateDecelerateInterpolator import android.view.animation.AccelerateInterpolator import android.view.inputmethod.InputMethodManager +import androidx.annotation.ColorRes +import androidx.core.content.ContextCompat internal fun View.show() { this.show(true) @@ -55,4 +57,12 @@ fun View.showSoftKeyboard() { fun View.hideSoftKeyboard() { val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager imm.hideSoftInputFromWindow(this.windowToken, 0) +} + +fun View.parseColor(@ColorRes color: Int): Int { + return context.parseColor(color) +} + +fun Context.parseColor(@ColorRes color: Int): Int { + return ContextCompat.getColor(this, color) } \ No newline at end of file diff --git a/tangem-sdk-android/src/main/java/com/tangem/tangem_sdk_new/ui/widget/StateWidget.kt b/tangem-sdk-android/src/main/java/com/tangem/tangem_sdk_new/ui/widget/StateWidget.kt index 2db83f77..ff3d4313 100644 --- a/tangem-sdk-android/src/main/java/com/tangem/tangem_sdk_new/ui/widget/StateWidget.kt +++ b/tangem-sdk-android/src/main/java/com/tangem/tangem_sdk_new/ui/widget/StateWidget.kt @@ -4,10 +4,13 @@ import android.view.View import com.tangem.tangem_sdk_new.SessionViewDelegateState import com.tangem.tangem_sdk_new.extensions.show -interface StateWidget { +interface StateConsumer{ + fun setState(params: T) +} + +interface StateWidget :StateConsumer{ fun isVisible(): Boolean fun showWidget(show: Boolean, withAnimation: Boolean = true) - fun setState(params: T) fun onBottomSheetDismiss() } diff --git a/tangem-sdk-android/src/main/java/com/tangem/tangem_sdk_new/ui/widget/progressBar/ProgressStateWidget.kt b/tangem-sdk-android/src/main/java/com/tangem/tangem_sdk_new/ui/widget/progressBar/ProgressStateWidget.kt index addeb05b..7c581369 100644 --- a/tangem-sdk-android/src/main/java/com/tangem/tangem_sdk_new/ui/widget/progressBar/ProgressStateWidget.kt +++ b/tangem-sdk-android/src/main/java/com/tangem/tangem_sdk_new/ui/widget/progressBar/ProgressStateWidget.kt @@ -4,11 +4,14 @@ import android.graphics.drawable.Animatable import android.view.View import android.widget.ImageView import android.widget.TextView -import androidx.core.content.ContextCompat +import androidx.annotation.ColorRes +import com.google.android.material.progressindicator.CircularProgressIndicator import com.tangem.tangem_sdk_new.R import com.tangem.tangem_sdk_new.SessionViewDelegateState import com.tangem.tangem_sdk_new.extensions.hide +import com.tangem.tangem_sdk_new.extensions.parseColor import com.tangem.tangem_sdk_new.extensions.show +import com.tangem.tangem_sdk_new.postUI import com.tangem.tangem_sdk_new.ui.widget.BaseSessionDelegateStateWidget /** @@ -17,205 +20,178 @@ import com.tangem.tangem_sdk_new.ui.widget.BaseSessionDelegateStateWidget class ProgressbarStateWidget(mainView: View) : BaseSessionDelegateStateWidget(mainView) { + private val progressIndicator: CircularProgressIndicator = mainView.findViewById(R.id.progressBar) + private val tvProgressValue: TextView = mainView.findViewById(R.id.tvProgressValue) + private val doneView: ImageView = mainView.findViewById(R.id.imvSuccess) + private val exclamationView: ImageView = mainView.findViewById(R.id.imvExclamation) + + private var isSdCountDownActive: Boolean = false + init { - NoneState(mainView) + hideViews(tvProgressValue, progressIndicator, doneView, exclamationView) + progressIndicator.applyProgressColor(R.color.sdk_progress_bar_primary) } + private var prevState: SessionViewDelegateState? = null + override fun setState(params: SessionViewDelegateState) { - val viewState = when (params) { - is SessionViewDelegateState.SecurityDelay -> SecurityDelayState(mainView) - is SessionViewDelegateState.Delay -> DelayState(mainView) - is SessionViewDelegateState.Success -> SuccessState(mainView) - is SessionViewDelegateState.Error -> ErrorState(mainView) - is SessionViewDelegateState.WrongCard -> ErrorState(mainView) - is SessionViewDelegateState.PinRequested -> WarningState(mainView) - is SessionViewDelegateState.TagConnected -> IndeterminateProgressState(mainView) - else -> NoneState(mainView) + when (params) { + is SessionViewDelegateState.TagConnected -> handleTagConnected() + is SessionViewDelegateState.Success -> handleSuccessState() + is SessionViewDelegateState.WrongCard -> handleErrorState() + is SessionViewDelegateState.Error -> handleErrorState() + is SessionViewDelegateState.SecurityDelay -> handleSecurityDelayState(params) + is SessionViewDelegateState.Delay -> handleDelayState(params) + is SessionViewDelegateState.PinRequested -> handleWarningState() // it's never used + else -> handleNoneState() } - viewState.setState(params) + prevState = params } - override fun onBottomSheetDismiss() { - NoneState(mainView) + private fun handleTagConnected() { + hideViews(progressIndicator, tvProgressValue, doneView, exclamationView) + progressIndicator.isIndeterminate = true + progressIndicator.applyProgressColor(R.color.sdk_progress_bar_primary) + showViews(progressIndicator) } -} -abstract class BaseProgressState(mainView: View) : BaseSessionDelegateStateWidget(mainView) { - protected val progressBar: SdkProgressBar = mainView.findViewById(R.id.progressBar) - protected val tvProgressValue: TextView = mainView.findViewById(R.id.tvProgressValue) - - protected val doneView: ImageView = mainView.findViewById(R.id.imvSuccess) - protected val exclamationView: ImageView = mainView.findViewById(R.id.imvExclamation) - - - init { - hideViews(tvProgressValue, progressBar, doneView, exclamationView) + private fun handleSuccessState() { + upadteWidgetIntonation(R.color.sdk_progress_bar_success, doneView, exclamationView) } - protected fun setMaxProgress() { - setProgress(progressBar.progressMax) + private fun handleWarningState() { + upadteWidgetIntonation(R.color.sdk_progress_bar_warning, exclamationView, doneView) } - protected fun setProgress(progress: Float, withAnimation: Boolean = true) { - if (progressBar.isIndeterminate) progressBar.isIndeterminate = false - - if (withAnimation) progressBar.setProgressWithAnimation(progress) - else progressBar.progress = progress + private fun handleErrorState() { + val delay = if (prevState is SessionViewDelegateState.TagConnected) 500L else 0L + postUI(delay) { + upadteWidgetIntonation(R.color.sdk_progress_bar_error, exclamationView, doneView) + } } - protected fun changeProgressColor(color: Int, withAnimation: Boolean = true) { - val parsedColor = ContextCompat.getColor(progressBar.context, color) - - if (withAnimation) progressBar.setProgressBarColorWithAnimation(parsedColor) - else progressBar.progressBarColor = parsedColor + private fun upadteWidgetIntonation(@ColorRes color: Int, toShow: ImageView, toHide: ImageView) { + hideViews(tvProgressValue, progressIndicator, toHide) - } + progressIndicator.applyProgressColor(color) + exclamationView.drawable.setTint(exclamationView.parseColor(color)) - protected fun changeExclamationColor(color: Int) { - exclamationView.drawable.setTint(ContextCompat.getColor(progressBar.context, color)) + setMaxProgress() + showViews(progressIndicator) + showAndAnimateDrawable(toShow) } - protected fun showViews(vararg views: View) { - views.forEach { it.show() } - } + private fun handleSecurityDelayState(params: SessionViewDelegateState.SecurityDelay) { + val delay = params as? SessionViewDelegateState.SecurityDelay ?: return - protected fun hideViews(vararg views: View) { - views.forEach { it.hide() } - } + fun standardSD(delay: SessionViewDelegateState.SecurityDelay) { + val seconds = delay.ms.div(100) + if (seconds == 0) { + isSdCountDownActive = false + progressIndicator.disableTrackColor() + hideViews(tvProgressValue) + } else if (!isSdCountDownActive) { + isSdCountDownActive = true + setProgress(0, false) + progressIndicator.applyTrackColor() + progressIndicator.max = seconds + } - protected fun showAndAnimateDrawable(view: ImageView) { - view.show() - (view.drawable as? Animatable)?.start() - } -} + setProgress(progressIndicator.max - seconds) + tvProgressValue.text = seconds.toString() + } -class NoneState(mainView: View) : BaseProgressState(mainView) { - override fun setState(params: SessionViewDelegateState) { - hideViews(progressBar, tvProgressValue, doneView, exclamationView) + fun userCodesFailsSD(delay: SessionViewDelegateState.SecurityDelay) { + fun isSingleTick(seconds: Int): Boolean = !isSdCountDownActive && seconds == 0 + fun isCountDownFinished(seconds: Int): Boolean = isSdCountDownActive && seconds == 0 + + val seconds = delay.ms.div(100) + when { + isSingleTick(seconds) -> { + setProgress(progressIndicator.max) + showAndAnimateDrawable(doneView) + return + } + !isSdCountDownActive -> { + isSdCountDownActive = true + setProgress(0, false) + progressIndicator.applyTrackColor() + progressIndicator.max = seconds + } + isCountDownFinished(seconds) -> { + isSdCountDownActive = false + progressIndicator.disableTrackColor() + hideViews(tvProgressValue) + showAndAnimateDrawable(doneView) + } + } + if (isCountDownFinished(seconds)) return - changeProgressColor(R.color.sdk_progress_bar_secondary, false) - setProgress(0f, false) - } -} + val progress = progressIndicator.max - seconds + setProgress(progress) + tvProgressValue.text = delay.ms.div(100).toString() + } -class SuccessState(mainView: View) : BaseProgressState(mainView) { - override fun setState(params: SessionViewDelegateState) { - hideViews(tvProgressValue, progressBar, exclamationView) - showViews(progressBar) + hideViews(doneView, exclamationView) + showViews(progressIndicator, tvProgressValue) - changeProgressColor(R.color.sdk_progress_bar_success) - setMaxProgress() - showAndAnimateDrawable(doneView) + if (delay.totalDurationSeconds != 0) { + standardSD(delay) + } else { + userCodesFailsSD(delay) + } } -} - -class ErrorState(mainView: View) : BaseProgressState(mainView) { - override fun setState(params: SessionViewDelegateState) { - hideViews(tvProgressValue, doneView) - showViews(progressBar) - - val color = R.color.sdk_progress_bar_error - changeProgressColor(color) - setMaxProgress() - changeExclamationColor(color) - showAndAnimateDrawable(exclamationView) + private fun handleDelayState(params: SessionViewDelegateState.Delay) { + hideViews(progressIndicator, tvProgressValue, doneView, exclamationView) + progressIndicator.isIndeterminate = true + progressIndicator.applyProgressColor(R.color.sdk_progress_bar_primary) + showViews(progressIndicator) } -} - -class WarningState(mainView: View) : BaseProgressState(mainView) { - override fun setState(params: SessionViewDelegateState) { - hideViews(tvProgressValue, doneView) - showViews(progressBar) - val color = R.color.sdk_progress_bar_warning - changeProgressColor(color) - setMaxProgress() - changeExclamationColor(color) - showAndAnimateDrawable(exclamationView) + private fun handleNoneState() { + hideViews(progressIndicator, tvProgressValue, doneView, exclamationView) + setProgress(0, false) + progressIndicator.applyProgressColor(R.color.sdk_progress_bar_primary) } -} - -class IndeterminateProgressState(mainView: View) : BaseProgressState(mainView) { - override fun setState(params: SessionViewDelegateState) { - changeProgressColor(R.color.sdk_progress_bar_primary, false) - hideViews(tvProgressValue, doneView, exclamationView) - showViews(progressBar) - - progressBar.isIndeterminate = true + private fun setMaxProgress() { + val max = progressIndicator.max + val current = progressIndicator.progress + val nearOfMax = ((max * 0.8).toInt()..max).contains(current) + setProgress(progressIndicator.max, nearOfMax) } -} - -class SecurityDelayState(mainView: View) : BaseProgressState(mainView) { - override fun setState(params: SessionViewDelegateState) { - val delay = params as? SessionViewDelegateState.SecurityDelay ?: return - - changeProgressColor(R.color.sdk_progress_bar_primary, false) - hideViews(doneView, exclamationView) - showViews(progressBar, tvProgressValue) - - if (delay.totalDurationSeconds == 0) { - pin1FailsSd(delay) - } else { - otherSd(delay) - } + private fun setProgress(progress: Int, withAnimation: Boolean = true) { + progressIndicator.setProgressCompat(progress, withAnimation) } - private fun pin1FailsSd(delay: SessionViewDelegateState.SecurityDelay) { - fun isCountDownInActiveState(): Boolean = progressBar.isCountDownActive - fun isCountDownFinished(seconds: Int): Boolean = isCountDownInActiveState() && seconds == 0 + private fun showViews(vararg views: View) { + views.forEach { it.show() } + } - val seconds = delay.ms.div(100) - when { - !isCountDownInActiveState() && seconds == 0 -> { - // handle the single tick of starting count down SD - setProgress(progressBar.progressMax) - showViews(progressBar) - showAndAnimateDrawable(doneView) - return - } - !isCountDownInActiveState() -> { - setProgress(0f, false) - progressBar.isCountDownActive = true - progressBar.progressMax = seconds.toFloat() - } - isCountDownFinished(seconds) -> { - progressBar.isCountDownActive = false - hideViews(tvProgressValue) - showViews(progressBar) - showAndAnimateDrawable(doneView) - } - } - if (isCountDownFinished(seconds)) return + private fun hideViews(vararg views: View) { + views.forEach { it.hide() } + } - val progress = progressBar.progressMax - seconds - setProgress(progress) - tvProgressValue.text = delay.ms.div(100).toString() + private fun showAndAnimateDrawable(view: ImageView) { + view.show() + (view.drawable as? Animatable)?.start() } - private fun otherSd(delay: SessionViewDelegateState.SecurityDelay) { - val seconds = delay.ms.div(100).toFloat() - if (seconds == 0f) { - progressBar.isCountDownActive = false - hideViews(tvProgressValue) - } else if (!progressBar.isCountDownActive) { - progressBar.isCountDownActive = true - progressBar.progressMax = seconds - } - setProgress(progressBar.progressMax - seconds) - tvProgressValue.text = seconds.toInt().toString() + override fun onBottomSheetDismiss() { + handleNoneState() } } -class DelayState(mainView: View) : BaseProgressState(mainView) { - override fun setState(params: SessionViewDelegateState) { - changeProgressColor(R.color.sdk_progress_bar_primary, false) +private fun CircularProgressIndicator.applyProgressColor(@ColorRes color: Int) { + setIndicatorColor(parseColor(color)) +} - hideViews(tvProgressValue, doneView, exclamationView) - showViews(progressBar) +private fun CircularProgressIndicator.applyTrackColor() { + trackColor = parseColor(R.color.sdk_progress_bar_secondary) +} - progressBar.isIndeterminate = true - } +private fun CircularProgressIndicator.disableTrackColor() { + trackColor = parseColor(android.R.color.transparent) } \ No newline at end of file diff --git a/tangem-sdk-android/src/main/res/anim/linear_interpolator.xml b/tangem-sdk-android/src/main/res/anim/linear_interpolator.xml deleted file mode 100644 index d9686f65..00000000 --- a/tangem-sdk-android/src/main/res/anim/linear_interpolator.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/tangem-sdk-android/src/main/res/anim/trim_end_interpolator.xml b/tangem-sdk-android/src/main/res/anim/trim_end_interpolator.xml deleted file mode 100644 index 2014cf82..00000000 --- a/tangem-sdk-android/src/main/res/anim/trim_end_interpolator.xml +++ /dev/null @@ -1,3 +0,0 @@ - - \ No newline at end of file diff --git a/tangem-sdk-android/src/main/res/anim/trim_start_interpolator.xml b/tangem-sdk-android/src/main/res/anim/trim_start_interpolator.xml deleted file mode 100644 index 65298d0a..00000000 --- a/tangem-sdk-android/src/main/res/anim/trim_start_interpolator.xml +++ /dev/null @@ -1,3 +0,0 @@ - - \ No newline at end of file diff --git a/tangem-sdk-android/src/main/res/animator/progress_indeterminate_animator.xml b/tangem-sdk-android/src/main/res/animator/progress_indeterminate_animator.xml deleted file mode 100644 index cd0d6b62..00000000 --- a/tangem-sdk-android/src/main/res/animator/progress_indeterminate_animator.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/tangem-sdk-android/src/main/res/animator/progress_indeterminate_rotation_animator.xml b/tangem-sdk-android/src/main/res/animator/progress_indeterminate_rotation_animator.xml deleted file mode 100644 index daa192b9..00000000 --- a/tangem-sdk-android/src/main/res/animator/progress_indeterminate_rotation_animator.xml +++ /dev/null @@ -1,9 +0,0 @@ - - \ No newline at end of file diff --git a/tangem-sdk-android/src/main/res/drawable/progress_bar.xml b/tangem-sdk-android/src/main/res/drawable/progress_bar.xml deleted file mode 100644 index ffd758b1..00000000 --- a/tangem-sdk-android/src/main/res/drawable/progress_bar.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/tangem-sdk-android/src/main/res/drawable/progress_bar_indeterminate.xml b/tangem-sdk-android/src/main/res/drawable/progress_bar_indeterminate.xml deleted file mode 100644 index e4cc085a..00000000 --- a/tangem-sdk-android/src/main/res/drawable/progress_bar_indeterminate.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/tangem-sdk-android/src/main/res/drawable/progress_bar_indeterminate_anim.xml b/tangem-sdk-android/src/main/res/drawable/progress_bar_indeterminate_anim.xml deleted file mode 100644 index 275ca247..00000000 --- a/tangem-sdk-android/src/main/res/drawable/progress_bar_indeterminate_anim.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tangem-sdk-android/src/main/res/layout/bottom_sheet_layout.xml b/tangem-sdk-android/src/main/res/layout/bottom_sheet_layout.xml index 66836063..6cf0e8c4 100644 --- a/tangem-sdk-android/src/main/res/layout/bottom_sheet_layout.xml +++ b/tangem-sdk-android/src/main/res/layout/bottom_sheet_layout.xml @@ -25,6 +25,7 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/clProgress" + android:layout_width="@dimen/progress_bar_state_width" + android:layout_height="@dimen/bottom_sheet_top_container_height" + android:clipChildren="false"> - + + android:id="@+id/imvSuccess" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:srcCompat="@drawable/ic_success_anim" + app:tint="@color/sdk_drawable_icon_blue" /> + android:id="@+id/imvExclamation" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:visibility="gone" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:srcCompat="@drawable/ic_exclamation_anim" /> + android:id="@+id/tvProgressValue" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:paddingBottom="5dp" + android:textColor="@color/sdk_drawable_icon_blue" + android:textSize="@dimen/progress_bar_state_text_size" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + tools:text="22" /> \ No newline at end of file diff --git a/tangem-sdk-android/src/main/res/values-night/colors.xml b/tangem-sdk-android/src/main/res/values-night/colors.xml index ce4b010f..637a7c4c 100644 --- a/tangem-sdk-android/src/main/res/values-night/colors.xml +++ b/tangem-sdk-android/src/main/res/values-night/colors.xml @@ -25,8 +25,8 @@ @color/sdk_text #ffffff + #33515151 #ffffff - #B37C7C7C #C7C7CC #ffffff From 5986833ae8b0df958a44679ad1a5f22f482c2204 Mon Sep 17 00:00:00 2001 From: Anton Zhilenkov Date: Wed, 15 Dec 2021 19:13:04 +0300 Subject: [PATCH 02/42] CSK-271 added a rescan delay to better show how the viewDelegate works --- .../java/com/tangem/tangem_demo/Commons.kt | 24 +++++--- .../com/tangem/tangem_demo/ui/BaseFragment.kt | 55 +++++++++---------- .../ui/tasksLogger/CommandsTesterFragment.kt | 4 +- 3 files changed, 46 insertions(+), 37 deletions(-) diff --git a/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/Commons.kt b/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/Commons.kt index c0c75994..1315c2a7 100644 --- a/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/Commons.kt +++ b/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/Commons.kt @@ -15,19 +15,29 @@ import kotlinx.coroutines.flow.callbackFlow /** * Created by Anton Zhilenkov on 24/12/2020. */ -private val uiThread = Handler(Looper.getMainLooper()) -private val workerThread = Handler(HandlerThread("DemoWorkerThread").apply { start() }.looper) +private val uiHandler = Handler(Looper.getMainLooper()) +private val backgroundHandler = Handler(HandlerThread("DemoWorkerThread").apply { start() }.looper) -fun postUi(ms: Long = 0, func: Runnable) { - if (ms == 0L) uiThread.post { func.run() } else uiThread.postDelayed(func, ms) +internal fun postUi(ms: Long = 0, func: Runnable) { + if (ms == 0L) uiHandler.post { func.run() } else uiHandler.postDelayed(func, ms) } -fun postWorker(ms: Long = 0, func: Runnable) { - if (ms == 0L) workerThread.post { func.run() } else workerThread.postDelayed(func, ms) +internal fun postBackground(ms: Long = 0, func: Runnable) { + if (ms == 0L) backgroundHandler.post { func.run() } else backgroundHandler.postDelayed(func, ms) +} + +fun post(ms: Long = 0, func: Runnable) { + val currentLooper = Looper.myLooper() ?: return + val handler = Handler(currentLooper) + if (ms == 0L) { + handler.post { func.run() } + } else { + handler.postDelayed(func, ms) + } } fun ViewGroup.inflate(@LayoutRes resId: Int, attach: Boolean = false): T = - LayoutInflater.from(context).inflate(resId, this, attach) as T + LayoutInflater.from(context).inflate(resId, this, attach) as T fun String.splitCamelCase(): String { return replace(String.format("%s|%s|%s", diff --git a/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/BaseFragment.kt b/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/BaseFragment.kt index 486c9427..227b15a6 100644 --- a/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/BaseFragment.kt +++ b/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/BaseFragment.kt @@ -15,6 +15,7 @@ import com.tangem.TangemSdkLogger import com.tangem.common.CompletionResult import com.tangem.common.card.Card import com.tangem.common.card.EllipticCurve +import com.tangem.common.extensions.VoidCallback import com.tangem.common.extensions.guard import com.tangem.common.extensions.hexToBytes import com.tangem.common.extensions.toByteArray @@ -57,8 +58,6 @@ abstract class BaseFragment : Fragment() { return card.wallets[selectedIndexOfWallet].publicKey } - private var needRescanCard = true - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) shPrefs = (requireContext().applicationContext as DemoApplication).shPrefs @@ -94,10 +93,7 @@ abstract class BaseFragment : Fragment() { } protected fun scanCard() { - sdk.scanCard(initialMessage) { - needRescanCard = false - handleResult(it) - } + sdk.scanCard(initialMessage) { handleResult(it) } } protected fun personalize(config: CardConfig) { @@ -179,10 +175,7 @@ abstract class BaseFragment : Fragment() { showToast("CardId & walletPublicKey required. Scan your card before proceeding") return } - sdk.createWallet(curve, cardId, initialMessage) { - needRescanCard = it is CompletionResult.Success - handleResult(it) - } + sdk.createWallet(curve, cardId, initialMessage) { handleResult(it, it is CompletionResult.Success) } } protected fun purgeWallet() { @@ -194,10 +187,7 @@ abstract class BaseFragment : Fragment() { showToast("Wallet publicKey is null") return } - sdk.purgeWallet(publicKey, cardId, initialMessage) { - needRescanCard = it is CompletionResult.Success - handleResult(it) - } + sdk.purgeWallet(publicKey, cardId, initialMessage) { handleResult(it, it is CompletionResult.Success) } } protected fun readIssuerData() { @@ -310,26 +300,35 @@ abstract class BaseFragment : Fragment() { sdk.changeFileSettings(listOf(change), card?.cardId, initialMessage) { handleResult(it) } } - private fun handleResult(result: CompletionResult<*>) { - setCard(result) - postUi { handleCommandResult(result) } + private fun handleResult(result: CompletionResult<*>, rescan: Boolean = false) { + when (result) { + is CompletionResult.Success -> postUi() { setCard(result, rescan) { handleCommandResult(result) } } + is CompletionResult.Failure -> handleCommandResult(result) + } } - private fun setCard(completionResult: CompletionResult<*>) { - if (completionResult is CompletionResult.Success) { - when { - needRescanCard -> { + private fun setCard( + result: CompletionResult<*>, + rescan: Boolean = false, + delay: Long = 1500, + callback: VoidCallback + ) { + when { + rescan -> { + showToast("Need rescan the card after Create/Purge wallet") + post(delay) { val command = PreflightReadTask(PreflightReadMode.FullCardRead, card?.cardId) sdk.startSessionWithRunnable(command) { - needRescanCard = false - setCard(it) + postUi() { setCard(it, false, callback = callback) } } } - completionResult.data is Card -> { - card = completionResult.data as Card - onCardChanged(card) - } } + result is CompletionResult.Success && result.data is Card -> { + card = result.data as Card + onCardChanged(card) + post(delay) { callback() } + } + else -> post(delay) { callback() } } } @@ -345,7 +344,7 @@ abstract class BaseFragment : Fragment() { } protected fun showToast(message: String) { - activity?.let { Toast.makeText(it, message, Toast.LENGTH_LONG).show() } + postUi() { activity?.let { Toast.makeText(it, message, Toast.LENGTH_LONG).show() } } } protected fun prepareHashesToSign(count: Int): Array { diff --git a/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/tasksLogger/CommandsTesterFragment.kt b/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/tasksLogger/CommandsTesterFragment.kt index 9f0479b2..7744ee47 100644 --- a/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/tasksLogger/CommandsTesterFragment.kt +++ b/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/tasksLogger/CommandsTesterFragment.kt @@ -57,7 +57,7 @@ class SdkTaskSpinnerFragment : BaseFragment() { private fun initSpinner() { spCommandSelector.adapter = CommandSpinnerAdapter(CommandType.values().toList()) nfcManager.addTagDiscoveredListener(tagDiscoveredListener) - postWorker { + postBackground { spCommandSelector.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { // close the session from a previous command @@ -99,7 +99,7 @@ class SdkTaskSpinnerFragment : BaseFragment() { commandState.canBeReactivated = false // if don't use the workerThread then fragments is stuck during first initialization - postWorker { + postBackground { when (type) { CommandType.Scan -> scanCard() CommandType.Sign -> signHashes(prepareHashesToSign(11)) From 8305d925b6588b784fb4f34e836ab6b4692db469 Mon Sep 17 00:00:00 2001 From: Anton Zhilenkov Date: Thu, 13 Jan 2022 03:43:28 +0300 Subject: [PATCH 03/42] CSK-241 update files --- .../com/tangem/tangem_demo/ui/BaseFragment.kt | 109 +++++++--- .../separtedCommands/CommandListFragment.kt | 14 +- .../ui/tasksLogger/CommandsTesterFragment.kt | 20 +- .../src/main/res/layout/file_data.xml | 8 +- .../src/main/java/com/tangem/TangemSdk.kt | 35 ++- .../deserialization/WalletDataDeserializer.kt | 22 +- .../com/tangem/common/extensions/IfNotNull.kt | 64 ++++++ .../java/com/tangem/common/extensions/Int.kt | 5 + .../java/com/tangem/common/extensions/Set.kt | 15 -- .../com/tangem/common/files/DataToWrite.kt | 80 ------- .../main/java/com/tangem/common/files/File.kt | 37 ---- .../com/tangem/common/files/FileSettings.kt | 19 -- .../java/com/tangem/common/json/Handlers.kt | 18 +- .../tangem/common/json/JSONRPCConverter.kt | 3 +- .../tangem/common/json/MoshiJsonConverter.kt | 125 +++++------ .../java/com/tangem/common/tlv/TlvDecoder.kt | 14 +- .../java/com/tangem/common/tlv/TlvEncoder.kt | 7 +- .../main/java/com/tangem/common/tlv/TlvTag.kt | 2 - .../files/ChangeFileSettingsCommand.kt | 30 +-- .../files/ChangeFileSettingsTask.kt | 30 +-- .../operations/files/DeleteAllFilesTask.kt | 2 +- .../operations/files/DeleteFileCommand.kt | 5 +- .../operations/files/DeleteFilesTask.kt | 44 ++-- .../java/com/tangem/operations/files/File.kt | 184 ++++++++++++++++ .../files/FileDataMode.kt | 2 +- .../files/FileHashData.kt | 2 +- .../files/FileHashHelper.kt | 4 +- .../tangem/operations/files/FileSettings.kt | 77 +++++++ .../files/ReadFileChecksumCommand.kt | 35 ++- .../operations/files/ReadFileCommand.kt | 85 +++++--- .../tangem/operations/files/ReadFilesTask.kt | 72 ++---- .../operations/files/WriteFileCommand.kt | 205 +++++++++++++----- .../tangem/operations/files/WriteFilesTask.kt | 47 ++-- .../files/settings/FileWriteSettings.kt | 21 -- .../files/settings/FirmwareRestrictable.kt | 11 - .../java/com/tangem/common/JSONRPCTests.kt | 29 +-- .../java/com/tangem/common/tlv/TlvTest.kt | 40 ++-- .../jsonRpc/files/ChangeFileSettings.json | 14 +- .../resources/jsonRpc/files/DeleteFiles.json | 6 +- .../resources/jsonRpc/files/ReadFiles.json | 17 +- .../jsonRpc/files/ReadFilesByIndex.json | 32 --- .../resources/jsonRpc/files/WriteFiles.json | 1 - .../java/com/tangem/jvm/demo/TangemSdkCli.kt | 21 +- 43 files changed, 895 insertions(+), 718 deletions(-) create mode 100644 tangem-sdk-core/src/main/java/com/tangem/common/extensions/IfNotNull.kt delete mode 100644 tangem-sdk-core/src/main/java/com/tangem/common/extensions/Set.kt delete mode 100644 tangem-sdk-core/src/main/java/com/tangem/common/files/DataToWrite.kt delete mode 100644 tangem-sdk-core/src/main/java/com/tangem/common/files/File.kt delete mode 100644 tangem-sdk-core/src/main/java/com/tangem/common/files/FileSettings.kt create mode 100644 tangem-sdk-core/src/main/java/com/tangem/operations/files/File.kt rename tangem-sdk-core/src/main/java/com/tangem/{common => operations}/files/FileDataMode.kt (91%) rename tangem-sdk-core/src/main/java/com/tangem/{common => operations}/files/FileHashData.kt (97%) rename tangem-sdk-core/src/main/java/com/tangem/{common => operations}/files/FileHashHelper.kt (93%) create mode 100644 tangem-sdk-core/src/main/java/com/tangem/operations/files/FileSettings.kt delete mode 100644 tangem-sdk-core/src/main/java/com/tangem/operations/files/settings/FileWriteSettings.kt delete mode 100644 tangem-sdk-core/src/main/java/com/tangem/operations/files/settings/FirmwareRestrictable.kt delete mode 100644 tangem-sdk-core/src/test/resources/jsonRpc/files/ReadFilesByIndex.json diff --git a/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/BaseFragment.kt b/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/BaseFragment.kt index 7b2562c6..2e6ff45a 100644 --- a/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/BaseFragment.kt +++ b/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/BaseFragment.kt @@ -7,6 +7,7 @@ import android.view.View import android.view.ViewGroup import android.widget.TextView import android.widget.Toast +import androidx.annotation.UiThread import androidx.fragment.app.Fragment import com.google.android.material.bottomsheet.BottomSheetDialog import com.tangem.Message @@ -15,20 +16,22 @@ import com.tangem.TangemSdkLogger import com.tangem.common.CompletionResult import com.tangem.common.card.Card import com.tangem.common.card.EllipticCurve -import com.tangem.common.extensions.guard -import com.tangem.common.extensions.hexToBytes -import com.tangem.common.extensions.toByteArray -import com.tangem.common.files.FileDataProtectedByPasscode -import com.tangem.common.files.FileDataProtectedBySignature -import com.tangem.common.files.FileHashHelper -import com.tangem.common.files.FileSettingsChange +import com.tangem.common.core.TangemSdkError +import com.tangem.common.deserialization.WalletDataDeserializer +import com.tangem.common.extensions.* import com.tangem.common.hdWallet.DerivationPath import com.tangem.common.json.MoshiJsonConverter +import com.tangem.common.tlv.Tlv +import com.tangem.common.tlv.TlvDecoder import com.tangem.crypto.CryptoUtils import com.tangem.crypto.sign import com.tangem.operations.PreflightReadMode import com.tangem.operations.PreflightReadTask import com.tangem.operations.attestation.AttestationTask +import com.tangem.operations.files.FileHashHelper +import com.tangem.operations.files.FileToWrite +import com.tangem.operations.files.FileVisibility +import com.tangem.operations.files.NamedFile import com.tangem.operations.issuerAndUserData.WriteIssuerExtraDataCommand import com.tangem.operations.personalization.entities.CardConfig import com.tangem.tangem_demo.* @@ -286,30 +289,84 @@ abstract class BaseFragment : Fragment() { } protected fun readFiles(readPrivateFiles: Boolean) { - sdk.readFiles(readPrivateFiles, null, card?.cardId, initialMessage) { handleResult(it) } + sdk.readFiles(readPrivateFiles, null, null, card?.cardId, initialMessage) { result -> + setCard(result) + when (result) { + is CompletionResult.Success -> { + val filesDetailInfo = mutableListOf>() + result.data.forEach { + val namedFile = NamedFile(it.fileData) ?: return@forEach + val detailInfo = mutableMapOf() + detailInfo["fileIndex"] = it.fileIndex + detailInfo["name"] = namedFile.name + detailInfo["fileData"] = namedFile.payload.toHexString() + Tlv.deserialize(namedFile.payload)?.let { + val decoder = TlvDecoder(it) + WalletDataDeserializer.deserialize(decoder)?.let { walletData -> + detailInfo["walletData"] = jsonConverter.toMap(walletData) + } + } + filesDetailInfo.add(detailInfo) + + } + val builder = StringBuilder().apply { + append(jsonConverter.prettyPrint(result.data)) + append("\n\n\nDetails:\n") + append(jsonConverter.prettyPrint(filesDetailInfo)) + } + postUi { showDialog(builder.toString()) } + } + is CompletionResult.Failure -> { + if (result.error is TangemSdkError.UserCancelled) { + showToast("${result.error.customMessage}: User was cancelled the operation") + } else { + showToast(result.error.customMessage) + } + } + } + } + } + + protected fun writeUserFile() { + val demoPayload = Utils.randomString(Utils.randomInt(15, 30)).toByteArray() + val demoData = NamedFile("User file", demoPayload).serialize() + val visibility: FileVisibility = FileVisibility.Private + //let walletPublicKey = Data(hexString: "40D2D7CFEF2436C159CCC918B7833FCAC5CB6037A7C60C481E8CA50AF9EDC70B") + val file: FileToWrite = FileToWrite.ByUser(demoData, visibility, null) + + sdk.writeFiles(listOf(file), card?.cardId, initialMessage) { + handleResult(it) + } } - protected fun writeFilesSigned() { + protected fun writeOwnerFile() { val cardId = card?.cardId.guard { showToast("CardId required. Scan your card before proceeding") return } - val file = prepareSignedData(cardId) - sdk.writeFiles(listOf(file), card?.cardId, initialMessage) { handleResult(it) } - } - protected fun writeFilesWithPassCode() { - val issuerData = CryptoUtils.generateRandomBytes(WriteIssuerExtraDataCommand.SINGLE_WRITE_SIZE * 5) - val files = listOf(FileDataProtectedByPasscode(issuerData), FileDataProtectedByPasscode(issuerData)) - sdk.writeFiles(files, card?.cardId, initialMessage) { handleResult(it) } + val demoPayload = Utils.randomString(Utils.randomInt(15, 30)).toByteArray() + val demoData = NamedFile("Ownerfile", demoPayload).serialize() + val visibility: FileVisibility = FileVisibility.Private + val counter = 1 + //let walletPublicKey = Data(hexString: "40D2D7CFEF2436C159CCC918B7833FCAC5CB6037A7C60C481E8CA50AF9EDC70B") + val issuer = Personalization.issuer() + val fileHash = FileHashHelper.prepareHashes(cardId, demoData, counter, issuer.dataKeyPair.privateKey) + + ifNotNullOr(fileHash.startingSignature, fileHash.finalizingSignature, { sSignature, fSignature -> + val file = FileToWrite.ByFileOwner(demoData, sSignature, fSignature, counter, visibility, null) + sdk.writeFiles(listOf(file)) { handleResult(it) } + }, { + showToast("Failed to sign data with issuer signature") + }) } protected fun deleteFiles(indices: List? = null) { sdk.deleteFiles(indices, card?.cardId, initialMessage) { handleResult(it) } } - protected fun changeFilesSettings(change: FileSettingsChange) { - sdk.changeFileSettings(listOf(change), card?.cardId, initialMessage) { handleResult(it) } + protected fun changeFilesSettings(changes: Map) { + sdk.changeFileSettings(changes, card?.cardId, initialMessage) { handleResult(it) } } private fun handleResult(result: CompletionResult<*>) { @@ -335,6 +392,7 @@ abstract class BaseFragment : Fragment() { } } + @UiThread protected fun showDialog(message: String) { val dlg = bshDlg ?: BottomSheetDialog(requireActivity()) if (dlg.isShowing) dlg.hide() @@ -357,21 +415,6 @@ abstract class BaseFragment : Fragment() { return listOfHashes.toTypedArray() } - protected fun prepareSignedData(cardId: String): FileDataProtectedBySignature { - val counter = 1 - val issuer = Personalization.issuer() - val issuerData = CryptoUtils.generateRandomBytes(WriteIssuerExtraDataCommand.SINGLE_WRITE_SIZE * 5) - val signatures = FileHashHelper.prepareHashes( - cardId, issuerData, counter, issuer.dataKeyPair.privateKey - ) - return FileDataProtectedBySignature( - issuerData, - signatures.startingSignature!!, - signatures.finalizingSignature!!, - counter, - ) - } - private fun createDerivationPath(): DerivationPath? { val hdPath = derivationPath ?: return null if (hdPath.isEmpty() || hdPath.isBlank()) return null diff --git a/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/separtedCommands/CommandListFragment.kt b/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/separtedCommands/CommandListFragment.kt index 86f15028..6aeae669 100644 --- a/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/separtedCommands/CommandListFragment.kt +++ b/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/separtedCommands/CommandListFragment.kt @@ -15,14 +15,14 @@ import com.tangem.common.core.CardSessionRunnable import com.tangem.common.core.CompletionCallback import com.tangem.common.core.TangemSdkError import com.tangem.common.extensions.guard -import com.tangem.common.files.FileSettings -import com.tangem.common.files.FileSettingsChange import com.tangem.operations.PreflightReadMode import com.tangem.operations.PreflightReadTask import com.tangem.operations.attestation.AttestationTask +import com.tangem.operations.files.FileVisibility import com.tangem.operations.sign.SignHashResponse import com.tangem.tangem_demo.Personalization import com.tangem.tangem_demo.R +import com.tangem.tangem_demo.postUi import com.tangem.tangem_demo.ui.BaseFragment import com.tangem.tangem_demo.ui.backup.BackupActivity import com.tangem.tangem_demo.ui.extension.fitChipsByGroupWidth @@ -108,12 +108,12 @@ class CommandListFragment : BaseFragment() { btnReadAllFiles.setOnClickListener { readFiles(true) } btnReadPublicFiles.setOnClickListener { readFiles(false) } - btnWriteSignedFile.setOnClickListener { writeFilesSigned() } - btnWriteFilesWithPasscode.setOnClickListener { writeFilesWithPassCode() } + btnWriteUserFile.setOnClickListener { writeUserFile() } + btnWriteOwnerFile.setOnClickListener { writeOwnerFile() } btnDeleteAll.setOnClickListener { deleteFiles() } btnDeleteFirst.setOnClickListener { deleteFiles(listOf(0)) } - btnMakeFilePublic.setOnClickListener { changeFilesSettings(FileSettingsChange(0, FileSettings.Public)) } - btnMakeFilePrivate.setOnClickListener { changeFilesSettings(FileSettingsChange(0, FileSettings.Private)) } + btnMakeFilePublic.setOnClickListener { changeFilesSettings(mapOf(0 to FileVisibility.Public)) } + btnMakeFilePrivate.setOnClickListener { changeFilesSettings(mapOf(0 to FileVisibility.Private)) } etJsonRpc.setText(jsonRpcSingleCommandTemplate) btnSingleJsonRpc.setOnClickListener { etJsonRpc.setText(jsonRpcSingleCommandTemplate) } @@ -145,7 +145,7 @@ class CommandListFragment : BaseFragment() { } override fun onCardChanged(card: Card?) { - updateWalletsSlider() + postUi { updateWalletsSlider() } } private fun updateWalletsSlider() { diff --git a/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/tasksLogger/CommandsTesterFragment.kt b/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/tasksLogger/CommandsTesterFragment.kt index 9f0479b2..131cddad 100644 --- a/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/tasksLogger/CommandsTesterFragment.kt +++ b/tangem-sdk-android-demo/src/main/java/com/tangem/tangem_demo/ui/tasksLogger/CommandsTesterFragment.kt @@ -14,14 +14,14 @@ import com.tangem.common.core.Config import com.tangem.common.core.TangemError import com.tangem.common.core.TangemSdkError import com.tangem.common.extensions.VoidCallback -import com.tangem.common.files.FileSettings -import com.tangem.common.files.FileSettingsChange +import com.tangem.operations.files.FileVisibility import com.tangem.tangem_demo.* import com.tangem.tangem_demo.ui.BaseFragment import com.tangem.tangem_demo.ui.tasksLogger.adapter.CommandSpinnerAdapter import com.tangem.tangem_demo.ui.tasksLogger.adapter.RvConsoleAdapter import com.tangem.tangem_sdk_new.nfc.NfcManager import kotlinx.android.synthetic.main.fg_commands_tester.* +import kotlinx.android.synthetic.main.file_data.* /** * Created by Anton Zhilenkov on 23/12/2020. @@ -113,18 +113,14 @@ class SdkTaskSpinnerFragment : BaseFragment() { CommandType.UserDataWrite -> writeUserData() CommandType.SetPin1 -> setAccessCode() CommandType.SetPin2 -> setPasscode() - CommandType.FilesWriteSigned -> writeFilesSigned() - CommandType.FilesWriteWithPassCode -> writeFilesWithPassCode() + CommandType.FilesWriteUser -> writeUserFile() + CommandType.FilesWriteWithOwner -> writeOwnerFile() CommandType.FilesReadAll -> readFiles(true) CommandType.FilesReadPublic -> readFiles(false) CommandType.FilesDeleteAll -> deleteFiles() CommandType.FilesDeleteFirst -> deleteFiles(listOf(0)) - CommandType.FilesChangeSettingsFirstPublic -> { - changeFilesSettings(FileSettingsChange(0, FileSettings.Public)) - } - CommandType.FilesChangeSettingsFirstPrivate -> { - changeFilesSettings(FileSettingsChange(0, FileSettings.Private)) - } + CommandType.FilesChangeSettingsFirstPublic -> changeFilesSettings(mapOf(0 to FileVisibility.Public)) + CommandType.FilesChangeSettingsFirstPrivate -> changeFilesSettings(mapOf(0 to FileVisibility.Private)) } } } @@ -199,8 +195,8 @@ enum class CommandType { UserDataWrite, SetPin1, SetPin2, - FilesWriteSigned, - FilesWriteWithPassCode, + FilesWriteUser, + FilesWriteWithOwner, FilesReadAll, FilesReadPublic, FilesDeleteAll, diff --git a/tangem-sdk-android-demo/src/main/res/layout/file_data.xml b/tangem-sdk-android-demo/src/main/res/layout/file_data.xml index 53f63cbe..e9d9acb8 100644 --- a/tangem-sdk-android-demo/src/main/res/layout/file_data.xml +++ b/tangem-sdk-android-demo/src/main/res/layout/file_data.xml @@ -50,18 +50,18 @@ android:text="Read public files" />