forked from shihaam/thijooree
optimize contact picker ui to disable forbidden transfers
This commit is contained in:
@@ -164,7 +164,7 @@ class BmlLoginFlow {
|
||||
val resp = apiClient.newCall(apiRequest(session, "$BASE_URL/api/mobile/dashboard")).execute()
|
||||
val json = resp.body?.string() ?: return emptyList()
|
||||
resp.close()
|
||||
return parseDashboard(json)
|
||||
return parseDashboard(json, "bml_${session.deviceId}")
|
||||
}
|
||||
|
||||
fun fetchContacts(session: BmlSession): List<MibBeneficiary> {
|
||||
@@ -181,7 +181,7 @@ class BmlLoginFlow {
|
||||
.header("x-app-version", APP_VERSION)
|
||||
.build()
|
||||
|
||||
private fun parseDashboard(json: String): List<MibAccount> {
|
||||
private fun parseDashboard(json: String, loginTag: String): List<MibAccount> {
|
||||
val root = JSONObject(json)
|
||||
if (!root.optBoolean("success")) return emptyList()
|
||||
val dashboard = root.optJSONObject("payload")?.optJSONArray("dashboard") ?: return emptyList()
|
||||
@@ -211,7 +211,8 @@ class BmlLoginFlow {
|
||||
blockedAmount = "%.2f".format(item.optDouble("lockedAmount", 0.0)),
|
||||
mvrBalance = if (currency == "MVR") "%.2f".format(available) else "0.00",
|
||||
statusDesc = status,
|
||||
profileImageHash = null
|
||||
profileImageHash = null,
|
||||
loginTag = loginTag
|
||||
))
|
||||
} else if (accountType == "Card") {
|
||||
val isPrepaid = item.optBoolean("prepaid_card", false)
|
||||
@@ -230,7 +231,8 @@ class BmlLoginFlow {
|
||||
blockedAmount = "0.00",
|
||||
mvrBalance = if (currency == "MVR") "%.2f".format(available) else "0.00",
|
||||
statusDesc = status,
|
||||
profileImageHash = null
|
||||
profileImageHash = null,
|
||||
loginTag = loginTag
|
||||
))
|
||||
} else {
|
||||
// Linked debit cards have no independent balance or account link — skip
|
||||
|
||||
@@ -125,7 +125,7 @@ class MibLoginFlow(private val prefs: android.content.SharedPreferences) {
|
||||
|
||||
lastSession = session2
|
||||
lastProfiles = profiles
|
||||
return fetchAllProfiles(session2, profiles)
|
||||
return fetchAllProfiles(session2, profiles, "mib_$username")
|
||||
}
|
||||
|
||||
// ─── Helpers ─────────────────────────────────────────────────────────────
|
||||
@@ -204,7 +204,7 @@ class MibLoginFlow(private val prefs: android.content.SharedPreferences) {
|
||||
doRequest(session, payload, "n")
|
||||
}
|
||||
|
||||
private fun fetchAllProfiles(session: MibSession, profiles: List<MibProfile>): List<MibAccount> {
|
||||
private fun fetchAllProfiles(session: MibSession, profiles: List<MibProfile>, loginTag: String): List<MibAccount> {
|
||||
val allAccounts = mutableListOf<MibAccount>()
|
||||
for (profile in profiles) {
|
||||
val payload = baseData(session, "P47").apply {
|
||||
@@ -231,7 +231,8 @@ class MibLoginFlow(private val prefs: android.content.SharedPreferences) {
|
||||
blockedAmount = a.optString("blockedAmount"),
|
||||
mvrBalance = a.optString("mvrBalance"),
|
||||
statusDesc = a.optString("statusDesc"),
|
||||
profileImageHash = profile.customerImage
|
||||
profileImageHash = profile.customerImage,
|
||||
loginTag = loginTag
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,8 @@ data class MibAccount(
|
||||
val blockedAmount: String,
|
||||
val mvrBalance: String,
|
||||
val statusDesc: String,
|
||||
val profileImageHash: String?
|
||||
val profileImageHash: String?,
|
||||
val loginTag: String = ""
|
||||
)
|
||||
|
||||
data class MibBeneficiaryCategory(
|
||||
|
||||
Reference in New Issue
Block a user