ソースを参照

ui: Show free space when selecting slot

Peter Cai 1 年間 前
コミット
aaca9e807a

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

@@ -26,6 +26,7 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
         val hasMultiplePorts: Boolean,
         val portId: Int,
         val eID: String,
+        val freeSpace: Int,
         val enabledProfileName: String?
     )
 
@@ -77,6 +78,7 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
                     channel.port.card.ports.size > 1,
                     channel.portId,
                     channel.lpa.eID,
+                    channel.lpa.euiccInfo2?.freeNvram ?: 0,
                     channel.lpa.profiles.find { it.state == LocalProfileInfo.State.Enabled }?.displayName
                 )
             }
@@ -105,6 +107,7 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
         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 freeSpace = root.requireViewById<TextView>(R.id.slot_item_free_space)
         private val checkBox = root.requireViewById<CheckBox>(R.id.slot_checkbox)
 
         private var curIdx = -1
@@ -143,6 +146,7 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
             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)
+            freeSpace.text = formatFreeSpace(item.freeSpace)
             checkBox.isChecked = adapter.currentSelectedIdx == idx
         }
     }

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

@@ -61,6 +61,20 @@
         android:layout_height="wrap_content"
         android:textSize="14sp" />
 
+    <TextView
+        android:id="@+id/slot_item_free_space_label"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:minWidth="100dp"
+        android:text="@string/download_wizard_slot_free_space"
+        android:textSize="14sp" />
+
+    <TextView
+        android:id="@+id/slot_item_free_space"
+        android:layout_width="0dp"
+        android:layout_height="wrap_content"
+        android:textSize="14sp" />
+
     <androidx.constraintlayout.helper.widget.Flow
         android:id="@+id/flow1"
         android:layout_width="0dp"
@@ -68,7 +82,7 @@
         android:layout_marginStart="10sp"
         android:layout_marginTop="20sp"
         android:layout_marginEnd="10sp"
-        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: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,slot_item_free_space_label,slot_item_free_space"
         app:flow_wrapMode="aligned"
         app:flow_horizontalAlign="start"
         app:flow_horizontalBias="1"

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

@@ -69,6 +69,7 @@
     <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>
+    <string name="download_wizard_slot_free_space">Free Space:</string>
 
     <string name="profile_rename_new_name">New nickname</string>