Updated on 2026-08-14
This commit is contained in:
parent
aad21c7e0e
commit
746e915137
5 changed files with 61 additions and 1 deletions
|
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue