ui: Usb should use its own refresh progress bar
All checks were successful
/ build-debug (push) Successful in 4m44s
All checks were successful
/ build-debug (push) Successful in 4m44s
This commit is contained in:
parent
388f15a531
commit
b2fb3d23cb
3 changed files with 18 additions and 16 deletions
|
@ -50,16 +50,6 @@ open class MainActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
|
|||
}
|
||||
}
|
||||
|
||||
var loading: Boolean
|
||||
get() = loadingProgress.visibility == View.VISIBLE
|
||||
set(value) {
|
||||
loadingProgress.visibility = if (value) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
protected lateinit var tm: TelephonyManager
|
||||
|
||||
private val usbReceiver = object : BroadcastReceiver() {
|
||||
|
@ -122,7 +112,7 @@ open class MainActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
|
|||
}
|
||||
|
||||
private suspend fun init(fromUsbEvent: Boolean = false) {
|
||||
loading = true
|
||||
loadingProgress.visibility = View.VISIBLE
|
||||
viewPager.visibility = View.GONE
|
||||
tabs.visibility = View.GONE
|
||||
|
||||
|
@ -142,7 +132,7 @@ open class MainActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
|
|||
}
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
loading = false
|
||||
loadingProgress.visibility = View.GONE
|
||||
|
||||
knownChannels.sortedBy { it.logicalSlotId }.forEach { channel ->
|
||||
pages.add(Page(
|
||||
|
@ -179,7 +169,7 @@ open class MainActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker {
|
|||
|
||||
private fun refresh(fromUsbEvent: Boolean = false) {
|
||||
lifecycleScope.launch {
|
||||
loading = true
|
||||
loadingProgress.visibility = View.VISIBLE
|
||||
viewPager.visibility = View.GONE
|
||||
tabs.visibility = View.GONE
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.commit
|
||||
|
@ -69,6 +70,7 @@ class UsbCcidReaderFragment : Fragment(), OpenEuiccContextMarker {
|
|||
|
||||
private lateinit var text: TextView
|
||||
private lateinit var permissionButton: Button
|
||||
private lateinit var loadingProgress: ProgressBar
|
||||
|
||||
private var usbDevice: UsbDevice? = null
|
||||
private var usbChannel: EuiccChannel? = null
|
||||
|
@ -82,6 +84,7 @@ class UsbCcidReaderFragment : Fragment(), OpenEuiccContextMarker {
|
|||
|
||||
text = view.requireViewById(R.id.usb_reader_text)
|
||||
permissionButton = view.requireViewById(R.id.usb_grant_permission)
|
||||
loadingProgress = view.requireViewById(R.id.loading)
|
||||
|
||||
permissionButton.setOnClickListener {
|
||||
usbManager.requestPermission(usbDevice, usbPendingIntent)
|
||||
|
@ -135,14 +138,13 @@ class UsbCcidReaderFragment : Fragment(), OpenEuiccContextMarker {
|
|||
private suspend fun tryLoadUsbChannel() {
|
||||
text.visibility = View.GONE
|
||||
permissionButton.visibility = View.GONE
|
||||
|
||||
(requireActivity() as MainActivity).loading = true
|
||||
loadingProgress.visibility = View.VISIBLE
|
||||
|
||||
val (device, channel) = withContext(Dispatchers.IO) {
|
||||
euiccChannelManager.enumerateUsbEuiccChannel()
|
||||
}
|
||||
|
||||
(requireActivity() as MainActivity).loading = false
|
||||
loadingProgress.visibility = View.GONE
|
||||
|
||||
usbDevice = device
|
||||
usbChannel = channel
|
||||
|
|
|
@ -4,6 +4,16 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loading"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="true"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/usb_reader_text"
|
||||
android:layout_width="match_parent"
|
||||
|
|
Loading…
Add table
Reference in a new issue