瀏覽代碼

feat: show notification sequence number in upper right (#84)

![](https://gitea.angry.im/attachments/049f819a-b647-4db6-ae3d-6519cf8ff2e9)

Reviewed-on: https://gitea.angry.im/PeterCxy/OpenEUICC/pulls/84
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
septs 1 年之前
父節點
當前提交
858b6d55d6

+ 13 - 3
app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt

@@ -117,11 +117,14 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
        launchTask {
            notificationAdapter.notifications =
                euiccChannelManager.withEuiccChannel(logicalSlotId) { channel ->
-                   val profiles = channel.lpa.profiles
+                   val nameMap = buildMap {
+                       for (profile in channel.lpa.profiles) {
+                           put(profile.iccid, profile.displayName)
+                       }
+                   }
 
                    channel.lpa.notifications.map {
-                       val profile = profiles.find { p -> p.iccid == it.iccid }
-                       LocalProfileNotificationWrapper(it, profile?.displayName ?: "???")
+                       LocalProfileNotificationWrapper(it, nameMap[it.iccid] ?: "???")
                    }
                }
        }
@@ -136,6 +139,8 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
     inner class NotificationViewHolder(private val root: View):
         RecyclerView.ViewHolder(root), View.OnCreateContextMenuListener, OnMenuItemClickListener {
         private val address: TextView = root.requireViewById(R.id.notification_address)
+        private val sequenceNumber: TextView =
+            root.requireViewById(R.id.notification_sequence_number)
         private val profileName: TextView = root.requireViewById(R.id.notification_profile_name)
 
         private lateinit var notification: LocalProfileNotificationWrapper
@@ -157,6 +162,7 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
             }
         }
 
+
         private fun operationToLocalizedText(operation: LocalProfileNotification.Operation) =
             root.context.getText(
                 when (operation) {
@@ -170,6 +176,10 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker {
             notification = value
 
             address.text = value.inner.notificationAddress
+            sequenceNumber.text = root.context.getString(
+                R.string.profile_notification_sequence_number_format,
+                value.inner.seqNumber
+            )
             profileName.text = Html.fromHtml(
                 root.context.getString(R.string.profile_notification_name_format,
                     operationToLocalizedText(value.inner.profileManagementOperation),

+ 9 - 0
app-common/src/main/res/layout/notification_item.xml

@@ -15,6 +15,15 @@
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintTop_toTopOf="parent" />
 
+    <TextView
+        android:id="@+id/notification_sequence_number"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginHorizontal="24dp"
+        android:layout_marginVertical="12dp"
+        app:layout_constraintRight_toRightOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
     <TextView
         android:id="@+id/notification_profile_name"
         android:layout_width="0dp"

+ 0 - 1
app-common/src/main/res/values-ja/strings.xml

@@ -89,7 +89,6 @@
     <string name="profile_notification_operation_delete">削除しました</string>
     <string name="profile_notification_operation_enable">有効化しました</string>
     <string name="profile_notification_operation_disable">無効化しました</string>
-    <string name="profile_notification_name_format">&lt;b&gt;%1$s&lt;/b&gt; %2$s (%3$s)</string>
     <string name="profile_notification_process">処理</string>
     <string name="profile_notification_delete">削除</string>
     <string name="euicc_info">eUICC 情報</string>

+ 2 - 1
app-common/src/main/res/values/strings.xml

@@ -103,7 +103,8 @@
     <string name="profile_notification_operation_delete">Deleted</string>
     <string name="profile_notification_operation_enable">Enabled</string>
     <string name="profile_notification_operation_disable">Disabled</string>
-    <string name="profile_notification_name_format">&lt;b&gt;%1$s&lt;/b&gt; %2$s (%3$s)</string>
+    <string name="profile_notification_name_format" translatable="false">&lt;b&gt;%1$s&lt;/b&gt; %2$s (%3$s)</string>
+    <string name="profile_notification_sequence_number_format" translatable="false">#%d</string>
     <string name="profile_notification_process">Process</string>
     <string name="profile_notification_delete">Delete</string>