浏览代码

chore: improve compatibility check (#96)

Reviewed-on: https://gitea.angry.im/PeterCxy/OpenEUICC/pulls/96
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
septs 1 年之前
父节点
当前提交
d3e54ece58

+ 12 - 8
app-unpriv/src/main/java/im/angry/openeuicc/ui/CompatibilityCheckActivity.kt

@@ -1,6 +1,8 @@
 package im.angry.openeuicc.ui
 
+import android.annotation.SuppressLint
 import android.os.Bundle
+import android.text.Html
 import android.view.MenuItem
 import android.view.View
 import android.view.ViewGroup
@@ -8,6 +10,7 @@ import android.widget.TextView
 import androidx.activity.enableEdgeToEdge
 import androidx.appcompat.app.AppCompatActivity
 import androidx.core.view.children
+import androidx.core.view.isVisible
 import androidx.lifecycle.lifecycleScope
 import androidx.recyclerview.widget.DividerItemDecoration
 import androidx.recyclerview.widget.LinearLayoutManager
@@ -29,15 +32,16 @@ class CompatibilityCheckActivity: AppCompatActivity() {
         setupToolbarInsets()
         supportActionBar!!.setDisplayHomeAsUpEnabled(true)
 
-        compatibilityCheckList = requireViewById(R.id.recycler_view)
-        compatibilityCheckList.layoutManager =
-            LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
-        compatibilityCheckList.addItemDecoration(DividerItemDecoration(this, LinearLayoutManager.VERTICAL))
-        compatibilityCheckList.adapter = adapter
+        compatibilityCheckList = requireViewById<RecyclerView>(R.id.recycler_view).also {
+            it.layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
+            it.addItemDecoration(DividerItemDecoration(this, LinearLayoutManager.VERTICAL))
+            it.adapter = adapter
+        }
 
         setupRootViewInsets(compatibilityCheckList)
     }
 
+    @SuppressLint("NotifyDataSetChanged")
     override fun onStart() {
         super.onStart()
         lifecycleScope.launch {
@@ -61,10 +65,10 @@ class CompatibilityCheckActivity: AppCompatActivity() {
 
         fun bindItem(item: CompatibilityCheck) {
             titleView.text = item.title
-            descView.text = item.description
+            descView.text = Html.fromHtml(item.description, Html.FROM_HTML_MODE_COMPACT)
 
             statusContainer.children.forEach {
-                it.visibility = View.GONE
+                it.isVisible = false
             }
 
             val viewId = when (item.state) {
@@ -73,7 +77,7 @@ class CompatibilityCheckActivity: AppCompatActivity() {
                 CompatibilityCheck.State.FAILURE_UNKNOWN -> R.id.compatibility_check_unknown
                 else -> R.id.compatibility_check_progress_bar
             }
-            root.requireViewById<View>(viewId).visibility = View.VISIBLE
+            root.requireViewById<View>(viewId).isVisible = true
         }
     }
 

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

@@ -12,11 +12,11 @@
     <string name="compatibility_check_omapi_connectivity">OMAPI Connectivity</string>
     <string name="compatibility_check_omapi_connectivity_desc">Does your device allow access to Secure Elements on SIM cards via OMAPI?</string>
     <string name="compatibility_check_omapi_connectivity_fail">Unable to detect Secure Element readers for SIM cards via OMAPI. If you have not inserted a SIM in this device, try inserting one and retry this check.</string>
-    <string name="compatibility_check_omapi_connectivity_partial_success_sim_number">Successfully detected Secure Element access, but only for the following SIM slots: <b>SIM%s</b>.</string>
+    <string name="compatibility_check_omapi_connectivity_partial_success_sim_number">Successfully detected Secure Element access, but only for the following SIM slots: &lt;b&gt;SIM%s&lt;/b&gt;.</string>
     <string name="compatibility_check_isdr_channel">ISD-R Channel Access</string>
     <string name="compatibility_check_isdr_channel_desc">Does your device support opening an ISD-R (management) channel to eSIMs via OMAPI?</string>
     <string name="compatibility_check_isdr_channel_desc_unknown">Cannot determine whether ISD-R access through OMAPI is supported. You might want to retry with SIM cards inserted (any SIM card will do) if not already.</string>
-    <string name="compatibility_check_isdr_channel_desc_partial_fail">OMAPI access to ISD-R is only possible on the following SIM slots: <b>SIM%s</b>.</string>
+    <string name="compatibility_check_isdr_channel_desc_partial_fail">OMAPI access to ISD-R is only possible on the following SIM slots: &lt;b&gt;SIM%s&lt;/b&gt;.</string>
     <string name="compatibility_check_known_broken">Not on the Known Broken List</string>
     <string name="compatibility_check_known_broken_desc">Making sure your device is not known to have bugs associated with removable eSIMs.</string>
     <string name="compatibility_check_known_broken_fail">Oops, your device is known to have bugs when accessing removable eSIMs. This does not necessarily mean that it will not work at all, but you will have to proceed with caution.</string>