diff --git a/app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt b/app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt index b232339..5dd633e 100644 --- a/app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt +++ b/app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt @@ -110,10 +110,20 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener, } true } + else -> super.onOptionsItemSelected(item) } - protected open suspend fun onCreateFooterViews(parent: ViewGroup): List = listOf() + protected open suspend fun onCreateFooterViews( + parent: ViewGroup, + profiles: List + ): List = + if (profiles.isEmpty()) { + val view = layoutInflater.inflate(R.layout.footer_no_profile, parent, false) + listOf(view) + } else { + listOf() + } @SuppressLint("NotifyDataSetChanged") private fun refresh() { @@ -128,12 +138,12 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener, val profiles = withContext(Dispatchers.IO) { euiccChannelManager.notifyEuiccProfilesChanged(channel.logicalSlotId) - channel.lpa.profiles + channel.lpa.profiles.operational } withContext(Dispatchers.Main) { - adapter.profiles = profiles.operational - adapter.footerViews = onCreateFooterViews(profileList) + adapter.profiles = profiles + adapter.footerViews = onCreateFooterViews(profileList, profiles) adapter.notifyDataSetChanged() swipeRefresh.isRefreshing = false } @@ -250,6 +260,13 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener, } inner class FooterViewHolder: ViewHolder(FrameLayout(requireContext())) { + init { + itemView.layoutParams = ViewGroup.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ) + } + fun attach(view: View) { view.parent?.let { (it as ViewGroup).removeView(view) } (itemView as FrameLayout).addView(view) diff --git a/app-common/src/main/res/layout/footer_no_profile.xml b/app-common/src/main/res/layout/footer_no_profile.xml new file mode 100644 index 0000000..b02c67c --- /dev/null +++ b/app-common/src/main/res/layout/footer_no_profile.xml @@ -0,0 +1,21 @@ + + + + + + \ No newline at end of file diff --git a/app-common/src/main/res/values/strings.xml b/app-common/src/main/res/values/strings.xml index 07b7090..caafd5f 100644 --- a/app-common/src/main/res/values/strings.xml +++ b/app-common/src/main/res/values/strings.xml @@ -1,6 +1,7 @@ No removable eUICC card accessible by this app is detected on this device. + No profiles (yet) on this eSIM. Unknown Help Reload Slots diff --git a/app/src/main/java/im/angry/openeuicc/ui/PrivilegedEuiccManagementFragment.kt b/app/src/main/java/im/angry/openeuicc/ui/PrivilegedEuiccManagementFragment.kt index c1d46f0..7d055f4 100644 --- a/app/src/main/java/im/angry/openeuicc/ui/PrivilegedEuiccManagementFragment.kt +++ b/app/src/main/java/im/angry/openeuicc/ui/PrivilegedEuiccManagementFragment.kt @@ -16,17 +16,22 @@ class PrivilegedEuiccManagementFragment: EuiccManagementFragment() { newInstanceEuicc(PrivilegedEuiccManagementFragment::class.java, slotId, portId) } - override suspend fun onCreateFooterViews(parent: ViewGroup): List = - // isMEP can map to a slow operation (UiccCardInfo.isMultipleEnabledProfilesSupported()) - // so let's do it in the IO context - if (withContext(Dispatchers.IO) { channel.isMEP }) { - val view = layoutInflater.inflate(R.layout.footer_mep, parent, false) - view.requireViewById