Browse Source

ui: Expose more info in slot select fragment

Peter Cai 1 year ago
parent
commit
87f36f4166

+ 19 - 0
app-common/src/main/java/im/angry/openeuicc/ui/wizard/DownloadWizardSlotSelectFragment.kt

@@ -22,6 +22,9 @@ import net.typeblog.lpac_jni.LocalProfileInfo
 class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardStepFragment() {
     private data class SlotInfo(
         val logicalSlotId: Int,
+        val isRemovable: Boolean,
+        val hasMultiplePorts: Boolean,
+        val portId: Int,
         val eID: String,
         val enabledProfileName: String?
     )
@@ -71,6 +74,9 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
             euiccChannelManager.withEuiccChannel(slotId, portId) { channel ->
                 SlotInfo(
                     channel.logicalSlotId,
+                    channel.port.card.isRemovable,
+                    channel.port.card.ports.size > 1,
+                    channel.portId,
                     channel.lpa.eID,
                     channel.lpa.profiles.find { it.state == LocalProfileInfo.State.Enabled }?.displayName
                 )
@@ -85,6 +91,7 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
 
     private class SlotItemHolder(val adapter: SlotInfoAdapter, val root: View) : ViewHolder(root) {
         private val title = root.requireViewById<TextView>(R.id.slot_item_title)
+        private val type = root.requireViewById<TextView>(R.id.slot_item_type)
         private val eID = root.requireViewById<TextView>(R.id.slot_item_eid)
         private val activeProfile = root.requireViewById<TextView>(R.id.slot_item_active_profile)
         private val checkBox = root.requireViewById<CheckBox>(R.id.slot_checkbox)
@@ -108,6 +115,18 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
 
         fun bind(item: SlotInfo, idx: Int) {
             curIdx = idx
+
+            type.text = if (item.isRemovable) {
+                root.context.getString(R.string.download_wizard_slot_type_removable)
+            } else if (!item.hasMultiplePorts) {
+                root.context.getString(R.string.download_wizard_slot_type_internal)
+            } else {
+                root.context.getString(
+                    R.string.download_wizard_slot_type_internal_port,
+                    item.portId
+                )
+            }
+
             title.text = root.context.getString(R.string.download_wizard_slot_title, item.logicalSlotId)
             eID.text = item.eID
             activeProfile.text = item.enabledProfileName ?: root.context.getString(R.string.unknown)

+ 15 - 1
app-common/src/main/res/layout/download_slot_item.xml

@@ -19,6 +19,20 @@
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintTop_toTopOf="parent" />
 
+    <TextView
+        android:id="@+id/slot_item_type_label"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:minWidth="100dp"
+        android:text="@string/download_wizard_slot_type"
+        android:textSize="14sp" />
+
+    <TextView
+        android:id="@+id/slot_item_type"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:textSize="14sp" />
+
     <TextView
         android:id="@+id/slot_item_eid_label"
         android:layout_width="wrap_content"
@@ -54,7 +68,7 @@
         android:layout_marginStart="10sp"
         android:layout_marginTop="20sp"
         android:layout_marginEnd="10sp"
-        app:constraint_referenced_ids="slot_item_eid_label,slot_item_eid,slot_item_active_profile_label,slot_item_active_profile"
+        app:constraint_referenced_ids="slot_item_type_label,slot_item_type,slot_item_eid_label,slot_item_eid,slot_item_active_profile_label,slot_item_active_profile"
         app:flow_wrapMode="aligned"
         app:flow_horizontalAlign="start"
         app:flow_horizontalBias="1"

+ 1 - 2
app-common/src/main/res/layout/fragment_download_slot_select.xml

@@ -23,7 +23,6 @@
         app:layout_constraintStart_toStartOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintBottom_toBottomOf="parent"
-        app:layout_constrainedHeight="true"
-        app:layout_constraintHeight_max="300dp" />
+        app:layout_constrainedHeight="true" />
 
 </androidx.constraintlayout.widget.ConstraintLayout>

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

@@ -63,6 +63,10 @@
     <string name="download_wizard_next">Next</string>
     <string name="download_wizard_slot_select">Confirm the eSIM slot:</string>
     <string name="download_wizard_slot_title">Logical slot %d</string>
+    <string name="download_wizard_slot_type">Type:</string>
+    <string name="download_wizard_slot_type_removable">Removable</string>
+    <string name="download_wizard_slot_type_internal">Internal</string>
+    <string name="download_wizard_slot_type_internal_port">Internal, port %d</string>
     <string name="download_wizard_slot_eid">eID:</string>
     <string name="download_wizard_slot_active_profile">Active Profile:</string>