Updated on 2026-08-14
This commit is contained in:
parent
aad21c7e0e
commit
746e915137
5 changed files with 61 additions and 1 deletions
|
|
@ -84,6 +84,7 @@ dependencies {
|
|||
implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0'
|
||||
implementation 'com.skyfishjy.ripplebackground:library:1.0.1'
|
||||
implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
|
||||
implementation "com.orhanobut:hawk:2.0.1"
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation 'org.bitcoinj:bitcoinj-parent:0.14.7'
|
||||
implementation 'org.bitcoinj:bitcoinj-core:0.14.7'
|
||||
|
|
@ -93,4 +94,5 @@ dependencies {
|
|||
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
|
||||
implementation 'io.reactivex.rxjava2:rxkotlin:2.3.0'
|
||||
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import com.tangem.data.local.PendingTransactionsStorage
|
|||
import com.tangem.card_android.android.data.Firmwares
|
||||
import com.tangem.card_android.android.data.PINStorage
|
||||
import com.tangem.card_common.data.Issuer
|
||||
import com.tangem.data.dp.PrefsManager
|
||||
import com.tangem.di.*
|
||||
import com.tangem.server_android.data.LocalStorage
|
||||
import java.io.InputStreamReader
|
||||
|
|
@ -42,6 +43,8 @@ class App : Application() {
|
|||
navigatorComponent = buildNavigatorComponent()
|
||||
toastHelperComponent = buildToastHelperComponent()
|
||||
|
||||
PrefsManager.getInstance().init(this)
|
||||
|
||||
// common init
|
||||
if (PINStorage.needInit())
|
||||
PINStorage.init(applicationContext)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@ object Constant {
|
|||
const val FLAVOR_TANGEM_ACCESS = "tangemAccess"
|
||||
const val FLAVOR_TANGEM_CARDANO = "tangemCardano"
|
||||
|
||||
|
||||
const val PREF_LAST_WALLET_ADDRESS = "last_wallet_address"
|
||||
|
||||
const val URL_TANGEM = "https://play.google.com/store/apps/details?id=com.tangem.wallet"
|
||||
|
||||
const val EXTRA_BLOCKCHAIN_DATA = "BLOCKCHAIN_DATA"
|
||||
|
|
|
|||
44
app/src/main/java/com/tangem/data/dp/PrefsManager.kt
Normal file
44
app/src/main/java/com/tangem/data/dp/PrefsManager.kt
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
package com.tangem.data.dp
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
|
||||
import com.orhanobut.hawk.Hawk
|
||||
import com.tangem.Constant
|
||||
|
||||
class PrefsManager {
|
||||
companion object {
|
||||
const val PREF_NAME = "tangem_access"
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private var instance: PrefsManager? = null
|
||||
|
||||
fun getInstance(): PrefsManager {
|
||||
if (instance == null) {
|
||||
instance = PrefsManager()
|
||||
}
|
||||
return instance as PrefsManager
|
||||
}
|
||||
}
|
||||
|
||||
private lateinit var context: Context
|
||||
private lateinit var preferences: SharedPreferences
|
||||
|
||||
fun init(context: Context) {
|
||||
this.context = context
|
||||
preferences = context.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
|
||||
Hawk.init(context).build()
|
||||
}
|
||||
|
||||
val lastWalletAddress: String
|
||||
get() = Hawk.get(Constant.PREF_LAST_WALLET_ADDRESS, "")
|
||||
|
||||
fun saveLastWalletAddress(value: String) {
|
||||
Hawk.put(Constant.PREF_LAST_WALLET_ADDRESS, value)
|
||||
}
|
||||
|
||||
fun clearLastWalletAddress() {
|
||||
Hawk.delete(Constant.PREF_LAST_WALLET_ADDRESS)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@ import com.tangem.Constant
|
|||
import com.tangem.card_android.android.nfc.NfcLifecycleObserver
|
||||
import com.tangem.card_android.android.reader.NfcManager
|
||||
import com.tangem.data.Blockchain
|
||||
import com.tangem.data.dp.PrefsManager
|
||||
import com.tangem.di.Navigator
|
||||
import com.tangem.domain.wallet.CoinEngineFactory
|
||||
import com.tangem.domain.wallet.TangemContext
|
||||
|
|
@ -80,6 +81,8 @@ class PrepareTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallbac
|
|||
// limit number of symbols after comma
|
||||
etAmount.filters = engine.amountInputFilters
|
||||
|
||||
etWallet.setText(PrefsManager.getInstance().lastWalletAddress)
|
||||
|
||||
// set listeners
|
||||
etAmount.setOnEditorActionListener { lv, actionId, _ ->
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE) {
|
||||
|
|
@ -134,9 +137,14 @@ class PrepareTransactionActivity : AppCompatActivity(), NfcAdapter.ReaderCallbac
|
|||
intent.putExtra(Constant.EXTRA_AMOUNT, strAmount)
|
||||
intent.putExtra(Constant.EXTRA_AMOUNT_CURRENCY, tvCurrency.text.toString())
|
||||
startActivityForResult(intent, Constant.REQUEST_CODE_SEND_TRANSACTION__)
|
||||
|
||||
PrefsManager.getInstance().saveLastWalletAddress(etWallet.text.toString())
|
||||
}
|
||||
|
||||
ivCamera.setOnClickListener { navigator.showQrScanActivity(this, Constant.REQUEST_CODE_SCAN_QR) }
|
||||
ivCamera.setOnClickListener {
|
||||
navigator.showQrScanActivity(this, Constant.REQUEST_CODE_SCAN_QR)
|
||||
etWallet.text.clear()
|
||||
}
|
||||
|
||||
etWallet.setOnTouchListener(OnTouchListener { _, event ->
|
||||
if (event.action == MotionEvent.ACTION_UP) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue