Updated on 2026-08-14
This commit is contained in:
parent
2af8d5dc82
commit
9d36a97fd9
8 changed files with 67 additions and 34 deletions
|
|
@ -54,7 +54,7 @@ dependencies {
|
|||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
implementation 'com.madgag.spongycastle:core:1.56.0.0'
|
||||
implementation 'com.madgag.spongycastle:prov:1.56.0.0'
|
||||
implementation 'com.scottyab:rootbeer-lib:0.0.6'
|
||||
implementation 'com.scottyab:rootbeer-lib:0.0.7'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
package com.tangem.di;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.tangem.presentation.activity.MainActivity;
|
||||
|
||||
public class Navigator {
|
||||
|
||||
public void showMain(Context context) {
|
||||
context.startActivity(MainActivity.Companion.callingIntent(context));
|
||||
}
|
||||
|
||||
}
|
||||
36
app/src/main/java/com/tangem/di/Navigator.kt
Normal file
36
app/src/main/java/com/tangem/di/Navigator.kt
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package com.tangem.di
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
import com.tangem.presentation.activity.EmptyWalletActivity
|
||||
import com.tangem.presentation.activity.LoadedWalletActivity
|
||||
|
||||
import com.tangem.presentation.activity.MainActivity
|
||||
|
||||
class Navigator {
|
||||
|
||||
fun showMain(context: Context) {
|
||||
context.startActivity(MainActivity.callingIntent(context))
|
||||
}
|
||||
|
||||
fun showLoadedWallet(context: Activity, lastTag: Tag, cardInfo: Bundle) {
|
||||
context.startActivityForResult(LoadedWalletActivity.callingIntent(context, lastTag, cardInfo), MainActivity.REQUEST_CODE_SHOW_CARD_ACTIVITY)
|
||||
}
|
||||
|
||||
fun showEmptyWallet(context: Activity) {
|
||||
context.startActivity(EmptyWalletActivity.callingIntent(context))
|
||||
}
|
||||
|
||||
fun showVerifyCard(context: Context) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun showCreateNewWallet(context: Context) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.di;
|
||||
|
||||
import com.tangem.presentation.activity.EmptyWalletActivity;
|
||||
import com.tangem.presentation.activity.LogoActivity;
|
||||
import com.tangem.presentation.activity.MainActivity;
|
||||
|
||||
|
|
@ -17,4 +18,6 @@ public interface NavigatorComponent {
|
|||
|
||||
void inject(MainActivity activity);
|
||||
|
||||
void inject(EmptyWalletActivity activity);
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.presentation.activity
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
|
|
@ -31,6 +32,8 @@ class EmptyWalletActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, Card
|
|||
private const val REQUEST_CODE_CREATE_NEW_WALLET_ACTIVITY = 2
|
||||
private const val REQUEST_CODE_REQUEST_PIN2 = 3
|
||||
private const val REQUEST_CODE_VERIFY_CARD = 4
|
||||
|
||||
fun callingIntent(context: Context) = Intent(context, EmptyWalletActivity::class.java)
|
||||
}
|
||||
|
||||
private var nfcManager: NfcManager? = null
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.tangem.presentation.activity
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.nfc.NfcAdapter
|
||||
import android.nfc.Tag
|
||||
import android.os.Bundle
|
||||
|
|
@ -10,7 +12,12 @@ import com.tangem.wallet.R
|
|||
class LoadedWalletActivity : AppCompatActivity() {
|
||||
|
||||
companion object {
|
||||
const val EXTRA_MODIFICATION = "modification"
|
||||
fun callingIntent(context: Context, lastTag: Tag, cardInfo: Bundle): Intent {
|
||||
val intent = Intent(context, LoadedWalletActivity::class.java)
|
||||
intent.putExtra(MainActivity.EXTRA_LAST_DISCOVERED_TAG, lastTag)
|
||||
intent.putExtras(cardInfo)
|
||||
return intent
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
|
|
|||
|
|
@ -24,11 +24,13 @@ import android.view.animation.Transformation
|
|||
import android.widget.RelativeLayout
|
||||
import android.widget.Toast
|
||||
import com.scottyab.rootbeer.RootBeer
|
||||
import com.tangem.App
|
||||
import com.tangem.data.Logger
|
||||
import com.tangem.data.db.PINStorage
|
||||
import com.tangem.data.network.ServerApiCommon
|
||||
import com.tangem.data.nfc.DeviceNFCAntennaLocation
|
||||
import com.tangem.data.nfc.ReadCardInfoTask
|
||||
import com.tangem.di.Navigator
|
||||
import com.tangem.domain.cardReader.CardProtocol
|
||||
import com.tangem.domain.cardReader.FW
|
||||
import com.tangem.domain.cardReader.NfcManager
|
||||
|
|
@ -43,6 +45,7 @@ import com.tangem.wallet.R
|
|||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtocol.Notifications, PopupMenu.OnMenuItemClickListener {
|
||||
|
||||
|
|
@ -51,7 +54,7 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
|
||||
private const val REQUEST_CODE_SEND_EMAIL = 3
|
||||
private const val REQUEST_CODE_ENTER_PIN_ACTIVITY = 2
|
||||
private const val REQUEST_CODE_SHOW_CARD_ACTIVITY = 1
|
||||
const val REQUEST_CODE_SHOW_CARD_ACTIVITY = 1
|
||||
private const val REQUEST_CODE_REQUEST_CAMERA_PERMISSIONS = 3
|
||||
|
||||
const val EXTRA_LAST_DISCOVERED_TAG = "extra_last_tag"
|
||||
|
|
@ -78,6 +81,9 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
private var readCardInfoTask: ReadCardInfoTask? = null
|
||||
private var onNfcReaderCallback: NfcAdapter.ReaderCallback? = null
|
||||
|
||||
@Inject
|
||||
internal lateinit var navigator: Navigator
|
||||
|
||||
override fun onNewIntent(intent: Intent?) {
|
||||
super.onNewIntent(intent)
|
||||
if (intent != null && (NfcAdapter.ACTION_TECH_DISCOVERED == intent.action || NfcAdapter.ACTION_NDEF_DISCOVERED == intent.action)) {
|
||||
|
|
@ -91,6 +97,8 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
App.getNavigatorComponent().inject(this)
|
||||
|
||||
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
|
||||
nfcManager = NfcManager(this, this)
|
||||
|
|
@ -322,24 +330,13 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
|
|||
val card = TangemCard(uid)
|
||||
card.loadFromBundle(cardInfo.getBundle("Card"))
|
||||
|
||||
val intent: Intent
|
||||
intent = when {
|
||||
card.status == TangemCard.Status.Empty -> Intent(this, EmptyWalletActivity::class.java)
|
||||
card.status == TangemCard.Status.Loaded -> Intent(this, LoadedWalletActivity::class.java)
|
||||
card.status == TangemCard.Status.Purged -> {
|
||||
Toast.makeText(this, R.string.erased_wallet, Toast.LENGTH_SHORT).show()
|
||||
return@post
|
||||
}
|
||||
card.status == TangemCard.Status.NotPersonalized -> {
|
||||
Toast.makeText(this, R.string.not_personalized, Toast.LENGTH_SHORT).show()
|
||||
return@post
|
||||
}
|
||||
else -> Intent(this, LoadedWalletActivity::class.java)
|
||||
when {
|
||||
card.status == TangemCard.Status.Loaded -> lastTag?.let { navigator.showLoadedWallet(this, it, cardInfo) }
|
||||
card.status == TangemCard.Status.Empty -> navigator.showEmptyWallet(this)
|
||||
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()
|
||||
else -> lastTag?.let { navigator.showLoadedWallet(this, it, cardInfo) }
|
||||
}
|
||||
|
||||
intent.putExtra(EXTRA_LAST_DISCOVERED_TAG, lastTag)
|
||||
intent.putExtras(cardInfo)
|
||||
startActivityForResult(intent, REQUEST_CODE_SHOW_CARD_ACTIVITY)
|
||||
}
|
||||
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ object UtilHelper {
|
|||
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
val netInfo: NetworkInfo?
|
||||
netInfo = cm.activeNetworkInfo
|
||||
netInfo != null && netInfo.isConnectedOrConnecting
|
||||
netInfo != null && netInfo.isConnected
|
||||
} catch (e: NullPointerException) {
|
||||
e.printStackTrace()
|
||||
false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue