Compare commits

..

1 Commits

Author SHA1 Message Date
ahusan 4fe67aba6e contacts: paginate MIB contact loading + cache progressively
The old refresh path called MibContactsClient.fetchContacts() per
profile, which greedily walked every page and stuffed the union into
the contacts cache in one shot. A user with several hundred or several
thousand MIB beneficiaries paid for N round-trips before the screen
could render, and the cache write encrypted the whole blob each time.

Introduces a paginator that streams contacts on demand:

  * MibContactsClient.fetchContactsPage(session, start, count) — single
    page; fetchContacts() now layers on top for callers that want all
    pages.

  * MibContactsPaginator — walks the user's MIB profiles serially under
    the existing mibMutex, returning one page per nextPage() call.
    Categories are accumulated across calls.

  * HomeActivity.refreshContacts now requests just the first page
    (default 30 contacts) per login. Subsequent pages arrive via
    HomeActivity.loadMoreMibContacts(), which ContactsFragment fires
    from a scroll listener when the user is within 5 rows of the end
    of any tab. NEXT_PAGE_SIZE is 100 — matches the API's natural
    page size.

  * ContactsCache.appendContacts merges a new page into the cached
    list (dedupe by benefNo) instead of overwriting. The first page
    of a refresh still uses save() so deletions take effect.

  * HomeViewModel exposes mibContactsLoading / mibContactsHasMore
    so the fragment can show a loading footer (item_loading_footer)
    on each contact tab while a page is in flight.

  * ContactsAdapter grows a showLoadingFooter flag and a second view
    type for the footer row.

Search remains client-side over the loaded set — results may be
partial until the user keeps scrolling. The MIB API supports
server-side search via the `search` parameter but wiring it in is a
separate change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 18:27:17 +05:00
36 changed files with 363 additions and 257 deletions
@@ -61,38 +61,51 @@ class MibContactsClient {
}
}
/** Fetch a single page of contacts. Returns the list and the server-reported total count.
* [start] is 1-based; [count] is the desired page size. */
fun fetchContactsPage(
session: MibSession,
start: Int,
count: Int
): Pair<List<MibBeneficiary>, Int> {
val end = start + count - 1
// Server uses 100-row pages internally for its own pagination; we mirror that
// by computing a page index that aligns with our start offset.
val page = ((start - 1) / 100) + 1
val body = FormBody.Builder()
.add("page", page.toString())
.add("search", "")
.add("searchCategoryId", "0")
.add("benefType", "A")
.add("sortBenef", "name")
.add("sortDir", "asc")
.add("start", start.toString())
.add("end", end.toString())
.add("includeCount", "1")
.build()
val request = Request.Builder()
.url("$BASE_WV_URL/ajaxBeneficiary/main")
.post(body)
.withSessionHeaders(session)
.build()
return client.newCall(request).execute().use { response ->
if (!response.isSuccessful) return Pair(emptyList(), 0)
parseContacts(response.body?.string() ?: return Pair(emptyList(), 0))
}
}
/** Convenience: fetch all pages and return the union. Used by callers that don't paginate. */
fun fetchContacts(session: MibSession): List<MibBeneficiary> {
val all = mutableListOf<MibBeneficiary>()
var page = 1
var start = 1
val pageSize = 100
while (true) {
val start = (page - 1) * pageSize + 1
val end = page * pageSize
val body = FormBody.Builder()
.add("page", page.toString())
.add("search", "")
.add("searchCategoryId", "0")
.add("benefType", "A")
.add("sortBenef", "name")
.add("sortDir", "asc")
.add("start", start.toString())
.add("end", end.toString())
.add("includeCount", "1")
.build()
val request = Request.Builder()
.url("$BASE_WV_URL/ajaxBeneficiary/main")
.post(body)
.withSessionHeaders(session)
.build()
val (contacts, totalCount) = client.newCall(request).execute().use { response ->
if (!response.isSuccessful) return all
parseContacts(response.body?.string() ?: return all)
}
val (contacts, totalCount) = fetchContactsPage(session, start, pageSize)
all.addAll(contacts)
if (all.size >= totalCount || contacts.isEmpty()) break
page++
start += pageSize
}
return all
}
@@ -0,0 +1,80 @@
package sh.sar.basedbank.api.mib
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
import sh.sar.basedbank.BasedBankApp
import sh.sar.basedbank.api.models.BankContact
import sh.sar.basedbank.api.models.BankContactCategory
/**
* Streams MIB contacts one page at a time, walking the user's MIB profiles in order.
*
* For multi-profile users we stay on the current profile until its server-reported
* `total_count` is reached, then advance to the next profile. Each profile switch is
* protected by the global `mibMutex` to keep the session state coherent.
*
* Categories are fetched lazily on the first page of each profile and accumulated
* across calls — the latest snapshot is exposed via [allCategories].
*/
class MibContactsPaginator(
private val app: BasedBankApp,
val loginId: String,
private val session: MibSession,
private val profiles: List<MibProfile>,
private val client: MibContactsClient = MibContactsClient()
) {
private var profileIndex = 0
private var nextStart = 1
private var totalForCurrentProfile = -1
private var categoriesFetchedForProfile = false
private val accumulatedCategories = LinkedHashMap<String, BankContactCategory>()
val allCategories: List<BankContactCategory>
get() = accumulatedCategories.values.toList()
fun hasMore(): Boolean = profileIndex < profiles.size
/** Fetch one page of up to [count] contacts. Returns the contacts contributed by
* this call (may be empty if a profile errored or returned no rows). Advances
* the internal cursor; subsequent calls continue from where this left off. */
suspend fun nextPage(count: Int): List<BankContact> = withContext(Dispatchers.IO) {
if (!hasMore()) return@withContext emptyList()
val profile = profiles[profileIndex]
val flow = app.mibFlowFor(loginId)
val contacts = app.mibMutex.withLock {
try {
flow.switchProfile(session, profile)
if (!categoriesFetchedForProfile) {
for (cat in client.fetchCategories(session)) {
accumulatedCategories.putIfAbsent(
cat.id,
BankContactCategory(cat.id, cat.categoryName, cat.numBenef)
)
}
categoriesFetchedForProfile = true
}
val (page, total) = client.fetchContactsPage(session, nextStart, count)
if (total > 0) totalForCurrentProfile = total
nextStart += page.size.coerceAtLeast(count)
page.map { it.copy(profileId = profile.profileId) }
} catch (_: Exception) {
// Bail on this profile and advance — keeps the paginator robust.
emptyList()
}
}
val exhausted =
(totalForCurrentProfile > 0 && nextStart - 1 >= totalForCurrentProfile) ||
contacts.isEmpty()
if (exhausted) {
profileIndex++
nextStart = 1
totalForCurrentProfile = -1
categoriesFetchedForProfile = false
}
contacts
}
}
@@ -142,8 +142,6 @@ class AccountHistoryFragment : Fragment() {
}
adapter.setTransactions(filtered)
binding.emptyView.visibility = if (filtered.isEmpty() && !isLoading) View.VISIBLE else View.GONE
binding.skeletonContainer.visibility =
if (allTransactions.isEmpty() && isLoading) View.VISIBLE else View.GONE
}
private fun resetAndReload() {
@@ -170,9 +168,6 @@ class AccountHistoryFragment : Fragment() {
if (firstPageDone && allTransactions.isNotEmpty()) {
adapter.showLoadingFooter = true
} else if (allTransactions.isEmpty()) {
binding.skeletonContainer.visibility = View.VISIBLE
binding.emptyView.visibility = View.GONE
}
val app = requireActivity().application as BasedBankApp
@@ -192,7 +187,6 @@ class AccountHistoryFragment : Fragment() {
isLoading = false
if (_binding == null) return@launch
binding.skeletonContainer.visibility = View.GONE
if (!firstPageDone) {
firstPageDone = true
@@ -8,6 +8,7 @@ import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
@@ -20,7 +21,7 @@ class ContactsAdapter(
private val onImageNeeded: (hash: String) -> Unit,
private val onDeleteClick: (ContactDisplay) -> Unit,
private val onTransferClick: (ContactDisplay) -> Unit
) : RecyclerView.Adapter<ContactsAdapter.ViewHolder>() {
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private var allContacts: List<ContactDisplay> = emptyList()
private var displayed: List<ContactDisplay> = emptyList()
@@ -28,6 +29,15 @@ class ContactsAdapter(
private var activeCategoryId: String? = null
private var searchQuery: String = ""
/** When true, a loading footer row is shown after the last contact. */
var showLoadingFooter: Boolean = false
set(value) {
if (field == value) return
field = value
if (value) notifyItemInserted(displayed.size)
else notifyItemRemoved(displayed.size)
}
fun updateContacts(contacts: List<ContactDisplay>) {
allContacts = contacts
applyFilter()
@@ -58,24 +68,32 @@ class ContactsAdapter(
notifyDataSetChanged()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
override fun getItemViewType(position: Int): Int =
if (position == displayed.size && showLoadingFooter) VIEW_TYPE_FOOTER else VIEW_TYPE_CONTACT
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
if (viewType == VIEW_TYPE_FOOTER) {
val footer = LayoutInflater.from(parent.context)
.inflate(R.layout.item_loading_footer, parent, false)
return FooterHolder(footer)
}
val binding = ItemContactBinding.inflate(LayoutInflater.from(parent.context), parent, false)
val holder = ViewHolder(binding)
binding.btnTransferContact.setOnClickListener {
val pos = holder.bindingAdapterPosition
if (pos != RecyclerView.NO_POSITION) onTransferClick(displayed[pos])
if (pos != RecyclerView.NO_POSITION && pos < displayed.size) onTransferClick(displayed[pos])
}
binding.btnEditContact.setOnClickListener {
Toast.makeText(it.context, R.string.work_in_progress, Toast.LENGTH_SHORT).show()
}
binding.btnDeleteContact.setOnClickListener {
val pos = holder.bindingAdapterPosition
if (pos != RecyclerView.NO_POSITION) onDeleteClick(displayed[pos])
if (pos != RecyclerView.NO_POSITION && pos < displayed.size) onDeleteClick(displayed[pos])
}
binding.root.setOnLongClickListener {
val pos = holder.bindingAdapterPosition
if (pos == RecyclerView.NO_POSITION) return@setOnLongClickListener false
if (pos == RecyclerView.NO_POSITION || pos >= displayed.size) return@setOnLongClickListener false
val account = displayed[pos].accountNumber
val clipboard = it.context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
clipboard.setPrimaryClip(ClipData.newPlainText("account", account))
@@ -86,15 +104,23 @@ class ContactsAdapter(
return holder
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
if (holder is FooterHolder) return
val contact = displayed[position]
val cachedImage = contact.imageHash?.let { hash ->
imageCache[hash] ?: run { onImageNeeded(hash); null }
}
holder.bind(contact, cachedImage)
(holder as ViewHolder).bind(contact, cachedImage)
}
override fun getItemCount() = displayed.size
override fun getItemCount() = displayed.size + if (showLoadingFooter) 1 else 0
private class FooterHolder(view: View) : RecyclerView.ViewHolder(view)
private companion object {
const val VIEW_TYPE_CONTACT = 0
const val VIEW_TYPE_FOOTER = 1
}
inner class ViewHolder(val binding: ItemContactBinding) :
RecyclerView.ViewHolder(binding.root) {
@@ -9,7 +9,6 @@ import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.widget.addTextChangedListener
@@ -77,6 +76,9 @@ class ContactsFragment : Fragment() {
fun updateImage(hash: String, bitmap: Bitmap) =
contactAdapters.forEach { it.updateImage(hash, bitmap) }
fun setLoadingFooter(visible: Boolean) =
contactAdapters.forEach { it.showLoadingFooter = visible }
inner class PageHolder(val rv: RecyclerView) : RecyclerView.ViewHolder(rv)
override fun getItemCount() = pages.size
@@ -94,6 +96,7 @@ class ContactsFragment : Fragment() {
val p80 = (65 * density).toInt()
setPadding(0, p4, 0, p80)
adapter = contactAdapters[viewType]
addOnScrollListener(scrollListener)
}
return PageHolder(rv)
}
@@ -101,6 +104,24 @@ class ContactsFragment : Fragment() {
override fun onBindViewHolder(holder: PageHolder, position: Int) {}
}
/** Triggers paginated MIB contact loading when the user scrolls within
* LOAD_MORE_THRESHOLD rows of the end of any tab. */
private val scrollListener = object : RecyclerView.OnScrollListener() {
override fun onScrolled(rv: RecyclerView, dx: Int, dy: Int) {
if (dy <= 0) return
val lm = rv.layoutManager as? LinearLayoutManager ?: return
val total = lm.itemCount
if (total == 0) return
if (lm.findLastVisibleItemPosition() >= total - LOAD_MORE_THRESHOLD) {
(activity as? HomeActivity)?.loadMoreMibContacts()
}
}
}
private companion object {
const val LOAD_MORE_THRESHOLD = 5
}
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
_binding = FragmentContactsBinding.inflate(inflater, container, false)
return binding.root
@@ -150,6 +171,15 @@ class ContactsFragment : Fragment() {
binding.emptyView.visibility = if (contacts.isEmpty()) View.VISIBLE else View.GONE
binding.loadingView.visibility = View.GONE
}
// Show a loading footer on each contact list while more MIB pages are arriving.
val updateFooter: () -> Unit = {
val loading = viewModel.mibContactsLoading.value == true
val hasMore = viewModel.mibContactsHasMore.value == true
pagerAdapter.setLoadingFooter(loading && hasMore)
}
viewModel.mibContactsLoading.observe(viewLifecycleOwner) { updateFooter() }
viewModel.mibContactsHasMore.observe(viewLifecycleOwner) { updateFooter() }
}
private fun attachMediator(pages: List<TabPage>) {
@@ -166,6 +196,10 @@ class ContactsFragment : Fragment() {
}
val savedPosition = binding.viewPager.currentItem
pagerAdapter = ContactsPagerAdapter(pages)
pagerAdapter.setLoadingFooter(
(viewModel.mibContactsLoading.value == true) &&
(viewModel.mibContactsHasMore.value == true)
)
binding.viewPager.adapter = pagerAdapter
attachMediator(pages)
binding.viewPager.setCurrentItem(savedPosition.coerceIn(0, pages.size - 1), false)
@@ -195,10 +229,10 @@ class ContactsFragment : Fragment() {
viewLifecycleOwner.lifecycleScope.launch {
val success = withContext(Dispatchers.IO) { ContactManager.delete(contact, app) }
if (success) {
Toast.makeText(requireContext(), R.string.contact_deleted, Toast.LENGTH_SHORT).show()
removeFromViewModel(contact)
Snackbar.make(binding.root, R.string.contact_deleted, Snackbar.LENGTH_SHORT).show()
} else {
Snackbar.make(binding.root, R.string.contact_delete_failed, Snackbar.LENGTH_LONG).show()
Toast.makeText(requireContext(), R.string.contact_delete_failed, Toast.LENGTH_SHORT).show()
}
}
}
@@ -57,6 +57,7 @@ import sh.sar.basedbank.ui.login.LoginActivity
import sh.sar.basedbank.api.models.BankContact
import sh.sar.basedbank.api.models.BankContactCategory
import sh.sar.basedbank.api.mib.MibContactsClient
import sh.sar.basedbank.api.mib.MibContactsPaginator
import sh.sar.basedbank.api.mib.MibCardsClient
import sh.sar.basedbank.api.mib.MibFinancingClient
import sh.sar.basedbank.api.mib.MibProfile
@@ -73,6 +74,10 @@ class HomeActivity : AppCompatActivity() {
private lateinit var binding: ActivityHomeBinding
private val viewModel: HomeViewModel by viewModels()
/** One paginator per MIB login. Reset on every refresh. */
private var mibContactPaginators: List<MibContactsPaginator> = emptyList()
private var mibLoadMoreInFlight = false
private lateinit var toggle: ActionBarDrawerToggle
private var suppressBottomNavCallback = false
@@ -923,44 +928,78 @@ fun applyNavLabelVisibility() {
return result
}
/** Spin up (or replace) the paginator for this MIB login and fetch the first page.
* Subsequent pages arrive via [loadMoreMibContacts] in response to user scrolling. */
private fun refreshContacts(loginId: String, session: MibSession, profiles: List<MibProfile>) {
if (profiles.isEmpty()) return
val flow = (application as BasedBankApp).mibFlowFor(loginId)
val contactsClient = MibContactsClient()
val paginator = MibContactsPaginator(
app = application as BasedBankApp,
loginId = loginId,
session = session,
profiles = profiles
)
// Replace any existing paginator for this login.
mibContactPaginators = mibContactPaginators.filter { it.loginId != loginId } + paginator
viewModel.mibContactsHasMore.value = mibContactPaginators.any { it.hasMore() }
lifecycleScope.launch {
try {
val (allContacts, allCategories) = withContext(Dispatchers.IO) {
val seenContacts = mutableSetOf<String>()
val seenCategories = mutableSetOf<String>()
val contacts = mutableListOf<BankContact>()
val categories = mutableListOf<BankContactCategory>()
for (profile in profiles) {
try {
flow.switchProfile(session, profile)
for (cat in contactsClient.fetchCategories(session)) {
if (seenCategories.add(cat.id)) categories.add(cat)
}
for (contact in contactsClient.fetchContacts(session)) {
if (seenContacts.add(contact.benefNo))
contacts.add(contact.copy(profileId = profile.profileId))
}
} catch (_: Exception) { /* profile has no contacts access */ }
}
Pair(contacts, categories)
}
if (allContacts.isNotEmpty()) {
ContactsCache.save(this@HomeActivity, allContacts, allCategories)
val store = sh.sar.basedbank.util.CredentialStore(this@HomeActivity)
val bmlContacts = ContactsCache.loadBml(this@HomeActivity, store.getBmlLoginIds())
val fahipayContacts = ContactsCache.loadFahipay(this@HomeActivity)
val fahipayCategories = ContactsCache.loadFahipayCategories(this@HomeActivity)
viewModel.contacts.postValue(mergeContacts(mergeContacts(allContacts, bmlContacts), fahipayContacts))
viewModel.contactCategories.postValue(allCategories + fahipayCategories)
}
} catch (_: Exception) { /* keep cached data */ }
viewModel.mibContactsLoading.postValue(true)
val firstPage = try {
paginator.nextPage(MIB_FIRST_PAGE_SIZE)
} catch (_: Exception) {
null
}
// Treat a successful refresh as authoritative: replace the cached MIB list
// with the first page, even if it shrinks (so deletions take effect).
if (firstPage != null) {
ContactsCache.save(this@HomeActivity, firstPage, paginator.allCategories)
publishContacts(paginator.allCategories)
}
viewModel.mibContactsLoading.postValue(false)
viewModel.mibContactsHasMore.postValue(mibContactPaginators.any { it.hasMore() })
}
}
/** Called by ContactsFragment when the user scrolls near the end of the loaded list. */
fun loadMoreMibContacts() {
if (mibLoadMoreInFlight) return
val paginator = mibContactPaginators.firstOrNull { it.hasMore() } ?: return
mibLoadMoreInFlight = true
lifecycleScope.launch {
viewModel.mibContactsLoading.postValue(true)
val page = try {
paginator.nextPage(MIB_NEXT_PAGE_SIZE)
} catch (_: Exception) {
emptyList()
}
if (page.isNotEmpty()) {
ContactsCache.appendContacts(this@HomeActivity, page, paginator.allCategories)
publishContacts(paginator.allCategories)
}
mibLoadMoreInFlight = false
viewModel.mibContactsLoading.postValue(false)
viewModel.mibContactsHasMore.postValue(mibContactPaginators.any { it.hasMore() })
}
}
/** Merge the current MIB cache with BML and Fahipay caches and post to the view model. */
private fun publishContacts(mibCategories: List<BankContactCategory>) {
val store = sh.sar.basedbank.util.CredentialStore(this)
val mibContacts = ContactsCache.loadContacts(this)
val bmlContacts = ContactsCache.loadBml(this, store.getBmlLoginIds())
val fahipayContacts = ContactsCache.loadFahipay(this)
val fahipayCategories = ContactsCache.loadFahipayCategories(this)
viewModel.contacts.postValue(
mergeContacts(mergeContacts(mibContacts, bmlContacts), fahipayContacts)
)
viewModel.contactCategories.postValue(mibCategories + fahipayCategories)
}
companion object {
private const val MIB_FIRST_PAGE_SIZE = 30
private const val MIB_NEXT_PAGE_SIZE = 100
}
fun refreshBalances(src: BankAccount) {
val app = application as BasedBankApp
lifecycleScope.launch {
@@ -23,6 +23,11 @@ class HomeViewModel : ViewModel() {
val contacts = MutableLiveData<List<BankContact>>(emptyList())
val contactCategories = MutableLiveData<List<BankContactCategory>>(emptyList())
/** True while MIB contacts are paging in (initial load or scroll-triggered next page). */
val mibContactsLoading = MutableLiveData<Boolean>(false)
/** True while any MIB paginator still has pages to deliver. */
val mibContactsHasMore = MutableLiveData<Boolean>(false)
data class BmlLimitsData(val userName: String, val limits: List<BmlForeignLimit>)
val bmlLimits = MutableLiveData<List<BmlLimitsData>>(emptyList())
@@ -305,7 +305,12 @@ ViewCompat.setOnApplyWindowInsetsListener(binding.contentLayout) { v, insets ->
if (statusLabel == null) { tv.visibility = View.GONE; return }
tv.visibility = View.VISIBLE
tv.text = statusLabel
tv.setBackgroundResource(R.drawable.card_overlay_pill_bg)
val dp = tv.context.resources.displayMetrics.density
tv.background = GradientDrawable().apply {
shape = GradientDrawable.RECTANGLE
cornerRadius = 12 * dp
setColor(0xCC212121.toInt())
}
}
fun formatMasked(masked: String): String {
@@ -181,9 +181,6 @@ class TransferHistoryFragment : Fragment() {
if (firstBatchDone && allTransactions.isNotEmpty()) {
adapter.showLoadingFooter = true
} else if (allTransactions.isEmpty()) {
binding.skeletonContainer.visibility = View.VISIBLE
binding.emptyView.visibility = View.GONE
}
val app = requireActivity().application as BasedBankApp
@@ -289,7 +286,6 @@ class TransferHistoryFragment : Fragment() {
isLoading = false
if (_binding == null) return@launch
binding.skeletonContainer.visibility = View.GONE
val raw = bannerMsg.get()
when {
@@ -333,8 +329,6 @@ class TransferHistoryFragment : Fragment() {
}
adapter.setTransactions(filtered)
binding.emptyView.visibility = if (filtered.isEmpty() && !isLoading) View.VISIBLE else View.GONE
binding.skeletonContainer.visibility =
if (allTransactions.isEmpty() && isLoading) View.VISIBLE else View.GONE
}
private fun loadContactImage(name: String) {
@@ -51,6 +51,21 @@ object ContactsCache {
prefs.apply()
}
/** Merge new MIB contacts into the cached list, deduping by benefNo. Categories
* are replaced wholesale (the latest snapshot is canonical). Safe to call
* repeatedly as pages arrive. */
fun appendContacts(
context: Context,
newContacts: List<BankContact>,
categories: List<BankContactCategory>
) {
if (newContacts.isEmpty() && categories.isEmpty()) return
val existing = loadContacts(context)
val seen = existing.map { it.benefNo }.toHashSet()
val merged = existing + newContacts.filter { seen.add(it.benefNo) }
save(context, merged, categories)
}
fun clear(context: Context) {
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().clear().apply()
}
@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Translucent dark pill used as a status overlay on card-visual surfaces
(item_card_dashboard / _stack / _wallet / _settings_entry). Theme-independent
by design: it sits on top of card artwork, not the surface color. -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="12dp" />
<solid android:color="#CC212121" />
</shape>
+2 -2
View File
@@ -44,8 +44,8 @@
android:id="@+id/connectivityBanner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorErrorContainer"
android:textColor="?attr/colorOnErrorContainer"
android:background="#C62828"
android:textColor="#FFFFFF"
android:gravity="center"
android:paddingTop="6dp"
android:paddingBottom="6dp"
@@ -48,28 +48,12 @@
android:paddingBottom="16dp"
android:clipToPadding="false" />
<LinearLayout
android:id="@+id/skeletonContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<include layout="@layout/item_skeleton_transaction" />
<include layout="@layout/item_skeleton_transaction" />
<include layout="@layout/item_skeleton_transaction" />
<include layout="@layout/item_skeleton_transaction" />
<include layout="@layout/item_skeleton_transaction" />
<include layout="@layout/item_skeleton_transaction" />
<include layout="@layout/item_skeleton_transaction" />
<include layout="@layout/item_skeleton_transaction" />
</LinearLayout>
<TextView
android:id="@+id/emptyView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/transactions_empty"
android:text="No transactions found"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="?attr/colorOnSurfaceVariant"
android:visibility="gone" />
@@ -49,7 +49,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/activities_empty"
android:text="No recent transfers"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="?attr/colorOnSurfaceVariant"
android:visibility="gone" />
@@ -38,7 +38,7 @@
android:layout_marginBottom="16dp"
android:clickable="true"
android:focusable="true"
app:cardCornerRadius="@dimen/card_radius_lg"
app:cardCornerRadius="16dp"
app:strokeWidth="1dp"
app:strokeColor="?attr/colorOutline">
@@ -81,7 +81,7 @@
android:layout_marginBottom="16dp"
android:clickable="true"
android:focusable="true"
app:cardCornerRadius="@dimen/card_radius_lg"
app:cardCornerRadius="16dp"
app:strokeWidth="1dp"
app:strokeColor="?attr/colorOutline">
@@ -125,7 +125,7 @@
android:layout_marginBottom="16dp"
android:clickable="true"
android:focusable="true"
app:cardCornerRadius="@dimen/card_radius_lg"
app:cardCornerRadius="16dp"
app:strokeWidth="1dp"
app:strokeColor="?attr/colorOutline">
@@ -117,8 +117,8 @@
android:layout_marginBottom="8dp"
android:visibility="invisible"
app:cardBackgroundColor="?attr/colorSecondaryContainer"
app:cardCornerRadius="@dimen/card_radius_md"
app:cardElevation="@dimen/card_elevation_flat">
app:cardCornerRadius="12dp"
app:cardElevation="0dp">
<LinearLayout
android:layout_width="match_parent"
+22 -30
View File
@@ -21,7 +21,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/screen_margin">
android:padding="16dp">
<!-- Balance cards row -->
<LinearLayout
@@ -34,8 +34,8 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="8dp"
app:cardElevation="@dimen/card_elevation_raised"
app:cardCornerRadius="@dimen/card_radius_md">
app:cardElevation="1dp"
app:cardCornerRadius="12dp">
<LinearLayout
android:layout_width="match_parent"
@@ -56,8 +56,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="MVR —"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:fontFeatureSettings="tnum" />
android:textAppearance="?attr/textAppearanceTitleMedium" />
</LinearLayout>
@@ -68,8 +67,8 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="8dp"
app:cardElevation="@dimen/card_elevation_raised"
app:cardCornerRadius="@dimen/card_radius_md">
app:cardElevation="1dp"
app:cardCornerRadius="12dp">
<LinearLayout
android:layout_width="match_parent"
@@ -90,8 +89,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="USD —"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:fontFeatureSettings="tnum" />
android:textAppearance="?attr/textAppearanceTitleMedium" />
</LinearLayout>
@@ -114,8 +112,8 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="8dp"
app:cardElevation="@dimen/card_elevation_raised"
app:cardCornerRadius="@dimen/card_radius_md">
app:cardElevation="1dp"
app:cardCornerRadius="12dp">
<LinearLayout
android:layout_width="match_parent"
@@ -136,8 +134,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="MVR —"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:fontFeatureSettings="tnum" />
android:textAppearance="?attr/textAppearanceTitleMedium" />
</LinearLayout>
@@ -149,8 +146,8 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="8dp"
app:cardElevation="@dimen/card_elevation_raised"
app:cardCornerRadius="@dimen/card_radius_md">
app:cardElevation="1dp"
app:cardCornerRadius="12dp">
<LinearLayout
android:layout_width="match_parent"
@@ -171,8 +168,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="USD —"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:fontFeatureSettings="tnum" />
android:textAppearance="?attr/textAppearanceTitleMedium" />
</LinearLayout>
@@ -195,8 +191,8 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="8dp"
app:cardElevation="@dimen/card_elevation_raised"
app:cardCornerRadius="@dimen/card_radius_md"
app:cardElevation="1dp"
app:cardCornerRadius="12dp"
app:cardBackgroundColor="?attr/colorErrorContainer"
android:visibility="gone">
@@ -220,8 +216,7 @@
android:layout_marginTop="4dp"
android:text="MVR —"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:textColor="?attr/colorOnErrorContainer"
android:fontFeatureSettings="tnum" />
android:textColor="?attr/colorOnErrorContainer" />
<TextView
android:id="@+id/tvBlockedSecondary"
@@ -230,7 +225,6 @@
android:layout_marginTop="2dp"
android:textAppearance="?attr/textAppearanceLabelSmall"
android:textColor="?attr/colorOnErrorContainer"
android:fontFeatureSettings="tnum"
android:alpha="0.75"
android:visibility="gone" />
@@ -244,8 +238,8 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="8dp"
app:cardElevation="@dimen/card_elevation_raised"
app:cardCornerRadius="@dimen/card_radius_md"
app:cardElevation="1dp"
app:cardCornerRadius="12dp"
app:cardBackgroundColor="?attr/colorErrorContainer"
android:clickable="true"
android:focusable="true"
@@ -271,8 +265,7 @@
android:layout_marginTop="4dp"
android:text="MVR —"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:textColor="?attr/colorOnErrorContainer"
android:fontFeatureSettings="tnum" />
android:textColor="?attr/colorOnErrorContainer" />
</LinearLayout>
@@ -286,8 +279,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
app:cardElevation="@dimen/card_elevation_raised"
app:cardCornerRadius="@dimen/card_radius_md"
app:cardElevation="1dp"
app:cardCornerRadius="12dp"
android:clickable="true"
android:focusable="true">
@@ -310,8 +303,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text="MVR —"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:fontFeatureSettings="tnum" />
android:textAppearance="?attr/textAppearanceTitleMedium" />
</LinearLayout>
@@ -52,7 +52,7 @@
android:layout_marginBottom="12dp"
android:clickable="true"
android:focusable="true"
app:cardCornerRadius="@dimen/card_radius_lg"
app:cardCornerRadius="16dp"
app:strokeWidth="1dp"
app:strokeColor="?attr/colorOutline">
<LinearLayout
@@ -94,7 +94,7 @@
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
app:cardCornerRadius="@dimen/card_radius_lg"
app:cardCornerRadius="16dp"
app:strokeWidth="1dp"
app:strokeColor="?attr/colorOutline">
<LinearLayout
@@ -49,28 +49,12 @@
android:paddingBottom="16dp"
android:clipToPadding="false" />
<LinearLayout
android:id="@+id/skeletonContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<include layout="@layout/item_skeleton_transaction" />
<include layout="@layout/item_skeleton_transaction" />
<include layout="@layout/item_skeleton_transaction" />
<include layout="@layout/item_skeleton_transaction" />
<include layout="@layout/item_skeleton_transaction" />
<include layout="@layout/item_skeleton_transaction" />
<include layout="@layout/item_skeleton_transaction" />
<include layout="@layout/item_skeleton_transaction" />
</LinearLayout>
<TextView
android:id="@+id/emptyView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/transactions_empty"
android:text="No transactions found"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="?attr/colorOnSurfaceVariant"
android:visibility="gone" />
+3 -5
View File
@@ -9,8 +9,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingHorizontal="@dimen/list_item_padding_h"
android:paddingVertical="@dimen/list_item_padding_v"
android:paddingHorizontal="16dp"
android:paddingVertical="14dp"
android:gravity="center_vertical"
android:foreground="?attr/selectableItemBackground">
@@ -70,8 +70,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceTitleSmall"
android:textColor="?attr/colorOnSurface"
android:fontFeatureSettings="tnum" />
android:textColor="?attr/colorOnSurface" />
<TextView
android:id="@+id/tvBlocked"
@@ -80,7 +79,6 @@
android:layout_marginTop="2dp"
android:textAppearance="?attr/textAppearanceLabelSmall"
android:textColor="?attr/colorError"
android:fontFeatureSettings="tnum"
android:visibility="gone" />
<ImageButton
@@ -15,7 +15,6 @@
android:scaleType="fitCenter"
android:layout_marginEnd="10dp"
android:visibility="gone"
android:importantForAccessibility="no"
app:shapeAppearanceOverlay="@style/ShapeAppearance.Circle"
xmlns:app="http://schemas.android.com/apk/res-auto" />
@@ -50,8 +49,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceBodySmall"
android:textColor="?attr/colorOnSurface"
android:fontFeatureSettings="tnum" />
android:textColor="?attr/colorOnSurface" />
</LinearLayout>
@@ -7,8 +7,8 @@
android:layout_marginHorizontal="16dp"
android:layout_marginTop="12dp"
android:layout_marginBottom="8dp"
app:cardCornerRadius="@dimen/card_radius_lg"
app:cardElevation="@dimen/card_elevation_flat"
app:cardCornerRadius="16dp"
app:cardElevation="0dp"
app:strokeWidth="1dp"
app:strokeColor="?attr/colorOutlineVariant">
@@ -114,8 +114,7 @@
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:textColor="?attr/colorOnSurface"
android:layout_marginTop="2dp"
android:fontFeatureSettings="tnum" />
android:layout_marginTop="2dp" />
</LinearLayout>
@@ -138,8 +137,7 @@
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:textColor="?attr/colorOnSurface"
android:layout_marginTop="2dp"
android:fontFeatureSettings="tnum" />
android:layout_marginTop="2dp" />
</LinearLayout>
@@ -164,8 +162,7 @@
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:textColor="?attr/colorError"
android:layout_marginTop="2dp"
android:fontFeatureSettings="tnum" />
android:layout_marginTop="2dp" />
</LinearLayout>
+7 -5
View File
@@ -5,10 +5,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:clickable="true"
android:focusable="true"
app:cardCornerRadius="@dimen/card_radius_lg"
app:cardElevation="@dimen/card_elevation_flat"
app:cardCornerRadius="16dp"
app:cardElevation="0dp"
app:strokeWidth="1dp"
app:strokeColor="?attr/colorOutlineVariant">
@@ -53,7 +51,11 @@
android:id="@+id/tvLoanStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Widget.App.StatusChip" />
android:paddingHorizontal="10dp"
android:paddingVertical="4dp"
android:background="@drawable/chip_background"
android:textAppearance="?attr/textAppearanceLabelSmall"
android:textColor="?attr/colorOnSecondaryContainer" />
</LinearLayout>
+3 -4
View File
@@ -9,8 +9,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingHorizontal="@dimen/list_item_padding_h"
android:paddingVertical="@dimen/list_item_padding_v"
android:paddingHorizontal="16dp"
android:paddingVertical="14dp"
android:gravity="center_vertical"
android:foreground="?attr/selectableItemBackground">
@@ -83,8 +83,7 @@
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceTitleSmall"
android:textColor="?attr/colorOnSurface"
android:layout_marginTop="6dp"
android:fontFeatureSettings="tnum" />
android:layout_marginTop="6dp" />
<ImageButton
android:id="@+id/btnTransfer"
@@ -5,10 +5,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:clickable="true"
android:focusable="true"
app:cardCornerRadius="@dimen/card_radius_lg"
app:cardElevation="@dimen/card_elevation_flat"
app:cardCornerRadius="16dp"
app:cardElevation="0dp"
app:strokeWidth="1dp"
app:strokeColor="?attr/colorOutlineVariant">
@@ -53,7 +51,11 @@
android:id="@+id/tvStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Widget.App.StatusChip" />
android:paddingHorizontal="10dp"
android:paddingVertical="4dp"
android:background="@drawable/chip_background"
android:textAppearance="?attr/textAppearanceLabelSmall"
android:textColor="?attr/colorOnSecondaryContainer" />
</LinearLayout>
@@ -5,10 +5,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:clickable="true"
android:focusable="true"
app:cardElevation="@dimen/card_elevation_raised"
app:cardCornerRadius="@dimen/card_radius_md">
app:cardElevation="1dp"
app:cardCornerRadius="12dp">
<LinearLayout
android:layout_width="match_parent"
+3 -4
View File
@@ -5,16 +5,15 @@
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingHorizontal="@dimen/list_item_padding_h"
android:paddingVertical="@dimen/list_item_padding_v"
android:paddingHorizontal="16dp"
android:paddingVertical="14dp"
android:background="?attr/selectableItemBackground">
<ImageView
android:id="@+id/ivIcon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="16dp"
android:importantForAccessibility="no" />
android:layout_marginEnd="16dp" />
<LinearLayout
android:layout_width="0dp"
+1 -2
View File
@@ -13,8 +13,7 @@
android:id="@+id/ivNavIcon"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_marginBottom="6dp"
android:importantForAccessibility="no" />
android:layout_marginBottom="6dp" />
<TextView
android:id="@+id/tvNavLabel"
+2 -2
View File
@@ -6,8 +6,8 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginBottom="12dp"
app:cardCornerRadius="@dimen/card_radius_lg"
app:cardElevation="@dimen/card_elevation_raised">
app:cardCornerRadius="16dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
@@ -16,7 +16,6 @@
android:layout_width="44dp"
android:layout_height="44dp"
android:scaleType="centerCrop"
android:importantForAccessibility="no"
app:shapeAppearanceOverlay="@style/ShapeAppearance.Circle" />
<LinearLayout
@@ -54,7 +53,6 @@
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceTitleMedium"
android:textColor="?attr/colorOnSurface"
android:fontFeatureSettings="tnum"
android:paddingHorizontal="8dp"
android:visibility="gone" />
@@ -20,6 +20,10 @@
android:id="@+id/tvProfileType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Widget.App.StatusChip" />
android:paddingHorizontal="10dp"
android:paddingVertical="4dp"
android:background="@drawable/chip_background"
android:textAppearance="?attr/textAppearanceLabelSmall"
android:textColor="?attr/colorOnSecondaryContainer" />
</LinearLayout>
@@ -86,7 +86,6 @@
android:layout_height="wrap_content"
android:textAppearance="?attr/textAppearanceTitleSmall"
android:textStyle="bold"
android:fontFeatureSettings="tnum"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/fvAvatar"
app:layout_constraintBottom_toBottomOf="@id/fvAvatar" />
@@ -65,8 +65,8 @@
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:visibility="gone"
app:cardCornerRadius="@dimen/card_radius_md"
app:cardElevation="@dimen/card_elevation_raised">
app:cardCornerRadius="12dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
+1 -33
View File
@@ -5,36 +5,4 @@
<dimen name="nav_header_vertical_spacing">8dp</dimen>
<dimen name="nav_header_height">176dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<!-- ====== Design tokens ======================================== -->
<!-- Card surfaces.
Two-tier radius:
lg → hero/standalone cards (bank tiles, history header, finance deals, OTP cards)
md → repeating row/summary cards (dashboard cards, foreign limit, bottom sheets)
Card-visual representations (item_card_*) keep their own larger radius/elevation
to read as real credit cards — they are not tokenized. -->
<dimen name="card_radius_lg">16dp</dimen>
<dimen name="card_radius_md">12dp</dimen>
<!-- Card elevation. Two tiers:
flat → outlined cards (paired with a colorOutlineVariant stroke)
raised → subtle Material 3 default raise
Larger elevations belong to specific card-visual surfaces only. -->
<dimen name="card_elevation_flat">0dp</dimen>
<dimen name="card_elevation_raised">1dp</dimen>
<!-- Screen-level spacing -->
<dimen name="screen_margin">16dp</dimen>
<dimen name="section_gap">16dp</dimen>
<!-- Standard list/row padding -->
<dimen name="list_item_padding_h">16dp</dimen>
<dimen name="list_item_padding_v">14dp</dimen>
<!-- Gutters: small inline spacing units -->
<dimen name="gutter_xs">2dp</dimen>
<dimen name="gutter_sm">4dp</dimen>
<dimen name="gutter_md">8dp</dimen>
<dimen name="gutter_lg">12dp</dimen>
</resources>
</resources>
-2
View File
@@ -255,8 +255,6 @@
<!-- Accounts -->
<string name="accounts_empty">No accounts found</string>
<string name="activities_empty">No recent transfers</string>
<string name="transactions_empty">No transactions found</string>
<!-- Contacts -->
<string name="contacts_empty">No contacts found</string>
-9
View File
@@ -1,15 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<style name="ShapeAppearance.Circle" parent="ShapeAppearance.Material3.Corner.Full" />
<!-- Reusable status chip (filled, secondary container). Apply to a TextView via style. -->
<style name="Widget.App.StatusChip" parent="">
<item name="android:paddingHorizontal">10dp</item>
<item name="android:paddingVertical">4dp</item>
<item name="android:background">@drawable/chip_background</item>
<item name="android:textAppearance">?attr/textAppearanceLabelSmall</item>
<item name="android:textColor">?attr/colorOnSecondaryContainer</item>
</style>
<style name="Theme.BasedBank" parent="Theme.Material3.DayNight.NoActionBar">
<item name="colorPrimary">@color/seed_primary</item>
<item name="colorSecondary">@color/seed_secondary</item>