瀏覽代碼

feat: show incorrect lpa string alert dialog (#101)

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

+ 11 - 1
app-common/src/main/java/im/angry/openeuicc/ui/wizard/DownloadWizardMethodSelectFragment.kt

@@ -1,5 +1,6 @@
 package im.angry.openeuicc.ui.wizard
 
+import android.app.AlertDialog
 import android.graphics.BitmapFactory
 import android.os.Bundle
 import android.view.LayoutInflater
@@ -104,7 +105,16 @@ class DownloadWizardMethodSelectFragment : DownloadWizardActivity.DownloadWizard
 
     private fun processLpaString(s: String) {
         val components = s.split("$")
-        if (components.size < 3 || components[0] != "LPA:1") return
+        if (components.size < 3 || components[0] != "LPA:1") {
+            AlertDialog.Builder(requireContext()).apply {
+                setTitle(R.string.profile_download_incorrect_lpa_string)
+                setMessage(R.string.profile_download_incorrect_lpa_string_message)
+                setCancelable(true)
+                setNegativeButton(android.R.string.cancel, null)
+                show()
+            }
+            return
+        }
         state.smdp = components[1]
         state.matchingId = components[2]
         gotoNextFragment(DownloadWizardDetailsFragment())

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

@@ -56,6 +56,8 @@
 
     <string name="profile_download_low_nvram_title">This download may fail</string>
     <string name="profile_download_low_nvram_message">This download may fail due to low remaining capacity.</string>
+    <string name="profile_download_incorrect_lpa_string">Incorrect LPA String</string>
+    <string name="profile_download_incorrect_lpa_string_message">The LPA string could not be parsed</string>
 
     <string name="download_wizard">Download Wizard</string>
     <string name="download_wizard_back">Back</string>