Browse Source

fix: channel title (#292)

Reviewed-on: https://gitea.angry.im/PeterCxy/OpenEUICC/pulls/292
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
septs 4 weeks ago
parent
commit
c676c27338

+ 13 - 10
app-common/src/main/java/im/angry/openeuicc/ui/EuiccInfoActivity.kt

@@ -76,13 +76,11 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
             intent.getParcelableExtra("seId")
         } ?: EuiccChannel.SecureElementId.DEFAULT
 
-        val channelTitle = if (logicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
-            getString(R.string.channel_type_usb)
-        } else {
-            appContainer.customizableTextProvider.formatNonUsbChannelName(logicalSlotId)
-        }
-
-        title = getString(R.string.euicc_info_activity_title, channelTitle)
+        setChannelTitle(
+            if (logicalSlotId == EuiccChannelManager.USB_CHANNEL_ID)
+                getString(R.string.channel_type_usb) else
+                appContainer.customizableTextProvider.formatNonUsbChannelName(logicalSlotId)
+        )
 
         swipeRefresh.setOnRefreshListener { refresh() }
 
@@ -103,6 +101,10 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
         else -> super.onOptionsItemSelected(item)
     }
 
+    private fun setChannelTitle(title: CharSequence) {
+        super.setTitle(getString(R.string.euicc_info_activity_title, title))
+    }
+
     override fun onInit() {
         refresh()
     }
@@ -117,8 +119,9 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
                 // 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 title = appContainer.customizableTextProvider
+                            .formatNonUsbChannelNameWithSeId(logicalSlotId, seId)
+                        setChannelTitle(title)
                     }
                 }
 
@@ -166,7 +169,7 @@ class EuiccInfoActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
             // FS.27 v2.0, Security Guidelines for UICC Profiles (Page 25 of 27, 2024-01-30)
             // https://www.gsma.com/solutions-and-impact/technologies/security/wp-content/uploads/2024/01/FS.27-Security-Guidelines-for-UICC-Credentials-v2.0-FINAL-23-July.pdf#page=25
             val resId = when {
-                signers.isEmpty() -> R.string.euicc_info_unknown // the case is not mp, but it's is not common
+                signers.isEmpty() -> R.string.euicc_info_unknown // the case is not mp, but it is not common
                 PKID_GSMA_LIVE_CI.any(signers::contains) -> R.string.euicc_info_ci_gsma_live
                 PKID_GSMA_TEST_CI.any(signers::contains) -> R.string.euicc_info_ci_gsma_test
                 else -> R.string.euicc_info_ci_unknown

+ 12 - 9
app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt

@@ -74,13 +74,11 @@ class NotificationsActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker
 
         // This is slightly different from the MainActivity logic
         // due to the length (we don't want to display the full USB product name)
-        val channelTitle = if (logicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
-            getString(R.string.channel_type_usb)
-        } else {
-            appContainer.customizableTextProvider.formatNonUsbChannelName(logicalSlotId)
-        }
-
-        title = getString(R.string.profile_notifications_detailed_format, channelTitle)
+        setChannelTitle(
+            if (logicalSlotId == EuiccChannelManager.USB_CHANNEL_ID)
+                getString(R.string.channel_type_usb) else
+                appContainer.customizableTextProvider.formatNonUsbChannelName(logicalSlotId)
+        )
 
         swipeRefresh.setOnRefreshListener {
             refresh()
@@ -116,6 +114,10 @@ class NotificationsActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker
             else -> super.onOptionsItemSelected(item)
         }
 
+    private fun setChannelTitle(title: CharSequence) {
+        super.setTitle(getString(R.string.profile_notifications_detailed_format, title))
+    }
+
     private fun launchTask(task: suspend () -> Unit) {
         swipeRefresh.isRefreshing = true
 
@@ -135,8 +137,9 @@ class NotificationsActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker
             notificationAdapter.notifications = withEuiccChannel { channel ->
                 if (channel.hasMultipleSE && logicalSlotId != EuiccChannelManager.USB_CHANNEL_ID) {
                     withContext(Dispatchers.Main) {
-                        title =
-                            appContainer.customizableTextProvider.formatNonUsbChannelNameWithSeId(logicalSlotId, seId)
+                        val channelTitle = appContainer.customizableTextProvider
+                            .formatNonUsbChannelNameWithSeId(logicalSlotId, seId)
+                        setChannelTitle(channelTitle)
                     }
                 }