This commit is contained in:
@@ -106,6 +106,71 @@ class CredentialStore(context: Context) {
|
||||
.apply()
|
||||
}
|
||||
|
||||
data class MibUserProfile(
|
||||
val fullName: String,
|
||||
val username: String,
|
||||
val email: String,
|
||||
val mobile: String,
|
||||
val enrolled: String
|
||||
)
|
||||
|
||||
data class BmlUserProfile(
|
||||
val fullName: String,
|
||||
val email: String,
|
||||
val mobile: String,
|
||||
val customerId: String,
|
||||
val idCard: String,
|
||||
val birthdate: String
|
||||
)
|
||||
|
||||
fun saveMibFullName(name: String) = prefs.edit().putString("mib_full_name", name).apply()
|
||||
fun loadMibFullName(): String? = prefs.getString("mib_full_name", null)
|
||||
|
||||
fun saveBmlFullName(name: String) = prefs.edit().putString("bml_full_name", name).apply()
|
||||
fun loadBmlFullName(): String? = prefs.getString("bml_full_name", null)
|
||||
|
||||
fun saveMibUserProfile(p: MibUserProfile) {
|
||||
prefs.edit().putString("mib_full_name", p.fullName)
|
||||
.putString("mib_profile_username", p.username)
|
||||
.putString("mib_profile_email", p.email)
|
||||
.putString("mib_profile_mobile", p.mobile)
|
||||
.putString("mib_profile_enrolled", p.enrolled)
|
||||
.apply()
|
||||
}
|
||||
|
||||
fun loadMibUserProfile(): MibUserProfile? {
|
||||
val name = prefs.getString("mib_full_name", null) ?: return null
|
||||
return MibUserProfile(
|
||||
fullName = name,
|
||||
username = prefs.getString("mib_profile_username", "") ?: "",
|
||||
email = prefs.getString("mib_profile_email", "") ?: "",
|
||||
mobile = prefs.getString("mib_profile_mobile", "") ?: "",
|
||||
enrolled = prefs.getString("mib_profile_enrolled", "") ?: ""
|
||||
)
|
||||
}
|
||||
|
||||
fun saveBmlUserProfile(p: BmlUserProfile) {
|
||||
prefs.edit().putString("bml_full_name", p.fullName)
|
||||
.putString("bml_profile_email", p.email)
|
||||
.putString("bml_profile_mobile", p.mobile)
|
||||
.putString("bml_profile_customer_id", p.customerId)
|
||||
.putString("bml_profile_idcard", p.idCard)
|
||||
.putString("bml_profile_birthdate", p.birthdate)
|
||||
.apply()
|
||||
}
|
||||
|
||||
fun loadBmlUserProfile(): BmlUserProfile? {
|
||||
val name = prefs.getString("bml_full_name", null) ?: return null
|
||||
return BmlUserProfile(
|
||||
fullName = name,
|
||||
email = prefs.getString("bml_profile_email", "") ?: "",
|
||||
mobile = prefs.getString("bml_profile_mobile", "") ?: "",
|
||||
customerId = prefs.getString("bml_profile_customer_id", "") ?: "",
|
||||
idCard = prefs.getString("bml_profile_idcard", "") ?: "",
|
||||
birthdate = prefs.getString("bml_profile_birthdate", "") ?: ""
|
||||
)
|
||||
}
|
||||
|
||||
private fun getOrCreateKey(): SecretKey {
|
||||
val ks = KeyStore.getInstance("AndroidKeyStore").also { it.load(null) }
|
||||
ks.getKey(keyAlias, null)?.let { return it as SecretKey }
|
||||
|
||||
Reference in New Issue
Block a user