Browse Source

ui: Fix multi-SE channel title in the rest of activities

Of course all of this needs to be refactored including adding support
for multi-SE chips over USB readers, but that will be a task for the
next release cycle.
Peter Cai 1 month ago
parent
commit
0c305ff6ff

+ 25 - 6
app-common/src/main/java/im/angry/openeuicc/ui/EuiccInfoActivity.kt

@@ -31,7 +31,9 @@ import im.angry.openeuicc.util.formatFreeSpace
 import im.angry.openeuicc.util.mainViewPaddingInsetHandler
 import im.angry.openeuicc.util.setupRootViewSystemBarInsets
 import im.angry.openeuicc.util.tryParseEuiccVendorInfo
+import kotlinx.coroutines.Dispatchers
 import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
 import net.typeblog.lpac_jni.impl.PKID_GSMA_LIVE_CI
 import net.typeblog.lpac_jni.impl.PKID_GSMA_TEST_CI
 
@@ -92,10 +94,12 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
 
         swipeRefresh.setOnRefreshListener { refresh() }
 
-        setupRootViewSystemBarInsets(window.decorView.rootView, arrayOf(
-            this::activityToolbarInsetHandler,
-            mainViewPaddingInsetHandler(infoList)
-        ))
+        setupRootViewSystemBarInsets(
+            window.decorView.rootView, arrayOf(
+                this::activityToolbarInsetHandler,
+                mainViewPaddingInsetHandler(infoList)
+            )
+        )
     }
 
     override fun onOptionsItemSelected(item: MenuItem): Boolean = when (item.itemId) {
@@ -115,8 +119,23 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
         swipeRefresh.isRefreshing = true
 
         lifecycleScope.launch {
-            (infoList.adapter!! as EuiccInfoAdapter).euiccInfoItems =
-                euiccChannelManager.withEuiccChannel(logicalSlotId, seId, fn = ::buildEuiccInfoItems)
+            euiccChannelManager.withEuiccChannel(logicalSlotId, seId) { channel ->
+                // When the chip multi-SE, we need to include seId in the title (because we don't have access
+                // to hasMultipleSE in the onCreate() function, we need to do it here).
+                // TODO: Move channel formatting to somewhere centralized and remove this hack. (And also, of course, add support for USB)
+                if (channel.hasMultipleSE && logicalSlotId != EuiccChannelManager.USB_CHANNEL_ID) {
+                    withContext(Dispatchers.Main) {
+                        title =
+                            appContainer.customizableTextProvider.formatNonUsbChannelNameWithSeId(logicalSlotId, seId)
+                    }
+                }
+
+                val items = buildEuiccInfoItems(channel)
+
+                withContext(Dispatchers.Main) {
+                    (infoList.adapter!! as EuiccInfoAdapter).euiccInfoItems = items
+                }
+            }
 
             swipeRefresh.isRefreshing = false
         }

+ 7 - 0
app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt

@@ -137,6 +137,13 @@ class NotificationsActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker
     private fun refresh() {
         launchTask {
             notificationAdapter.notifications = withEuiccChannel { channel ->
+                if (channel.hasMultipleSE && logicalSlotId != EuiccChannelManager.USB_CHANNEL_ID) {
+                    withContext(Dispatchers.Main) {
+                        title =
+                            appContainer.customizableTextProvider.formatNonUsbChannelNameWithSeId(logicalSlotId, seId)
+                    }
+                }
+
                 val nameMap = channel.lpa.profiles
                     .associate { Pair(it.iccid, it.displayName) }