Updated on 2026-08-14

This commit is contained in:
Tangem 2019-03-20 15:35:20 +03:00
parent 6d74c1b7a5
commit 72e25805e9
4 changed files with 33 additions and 23 deletions

View file

@ -4,6 +4,8 @@ import android.app.Activity
object Constant {
const val URL_TANGEM = "https://play.google.com/store/apps/details?id=com.tangem.wallet"
const val EXTRA_BLOCKCHAIN_DATA = "BLOCKCHAIN_DATA"
const val EXTRA_MESSAGE = "message"

View file

@ -2,10 +2,13 @@ package com.tangem.ui.activity
import android.Manifest
import android.app.Activity
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.content.pm.ActivityInfo
import android.content.pm.PackageManager
import android.graphics.Color
import android.net.Uri
import android.nfc.NfcAdapter
import android.nfc.Tag
import android.nfc.tech.IsoDep
@ -18,6 +21,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.PopupMenu
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import com.google.android.material.snackbar.Snackbar
import com.scottyab.rootbeer.RootBeer
import com.tangem.App
import com.tangem.Constant
@ -128,16 +132,29 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
val apiHelper = ServerApiCommon()
apiHelper.setLastVersionListener { response ->
try {
if (response.isNullOrEmpty()) return@setLastVersionListener
if (response.isNullOrEmpty())
return@setLastVersionListener
val responseVersionName = response.trim(' ', '\n', '\r', '\t')
val responseBuildVersion = responseVersionName.split('.').last()
val appBuildVersion = BuildConfig.VERSION_NAME.split('.').last()
if (responseBuildVersion.toInt() > appBuildVersion.toInt()) Toast.makeText(this, "There is a new application version: $responseVersionName", Toast.LENGTH_LONG).show()
if (responseBuildVersion.toInt() > appBuildVersion.toInt())
Snackbar.make(cl, String.format(getString(R.string.new_app_version), responseVersionName), Snackbar.LENGTH_INDEFINITE)
.setAction(R.string.update) {
try {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(Constant.URL_TANGEM)
startActivity(intent)
} catch (e: ActivityNotFoundException) {
e.printStackTrace()
}
}.show()
} catch (E: Exception) {
E.printStackTrace()
}
}
apiHelper.requestLastVersion()
}
private fun verifyPermissions() {
@ -275,7 +292,7 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
cardInfo.putBundle(EXTRA_TANGEM_CARD, bCard)
cardProtocol.card.saveToBundle(bCard)
val uid = cardInfo.getString("UID")
val uid = cardInfo.getString(EXTRA_TANGEM_CARD_UID)
val card = TangemCard(uid)
cardInfo.getBundle(EXTRA_TANGEM_CARD)?.let { card.loadFromBundle(it) }
@ -288,7 +305,6 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
navigator.showLoadedWallet(this, it, ctx)
}
}
// ?: throw CardProtocol.TangemException("Can't create CoinEngine!")
card.status == TangemCard.Status.Empty -> navigator.showEmptyWallet(this, ctx)
card.status == TangemCard.Status.Purged -> Toast.makeText(this, R.string.erased_wallet, Toast.LENGTH_SHORT).show()
card.status == TangemCard.Status.NotPersonalized -> Toast.makeText(this, R.string.not_personalized, Toast.LENGTH_SHORT).show()

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/cl"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.tangem.ui.activity.MainActivity"
@ -45,24 +45,14 @@
</LinearLayout>
<FrameLayout
android:id="@+id/frameFAB"
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center|start"
android:layout_margin="@dimen/fab_margin"
android:elevation="3dp"
android:visibility="visible">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:src="@drawable/ic_show_menu"
app:backgroundTint="@color/colorPrimary"
app:fabSize="normal" />
</FrameLayout>
android:layout_gravity="bottom|start"
android:layout_margin="10dp"
android:src="@drawable/ic_show_menu"
app:backgroundTint="@color/colorPrimary"
app:fabSize="normal" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View file

@ -91,6 +91,8 @@
<string name="last_unspent">Last unspent</string>
<string name="erased_wallet">Wallet was erased</string>
<string name="not_personalized">Not personalized</string>
<string name="new_app_version">There is a new application version: %1$s</string>
<string name="update">Update</string>
<!-- LoadedWalletActivity, LoadedWallet -->
<string name="wallet_empty">The wallet is empty</string>