Compare commits
4 commits
375d13b7c4
...
4fb59a4b01
Author | SHA1 | Date | |
---|---|---|---|
4fb59a4b01 | |||
16636988b0 | |||
93e7297caa | |||
1087a676d4 |
4 changed files with 37 additions and 9 deletions
|
@ -80,7 +80,7 @@ class DownloadWizardActivity: BaseEuiccAccessActivity() {
|
|||
} else {
|
||||
View.GONE
|
||||
}
|
||||
prevButton.visibility = if (it.hasNext) {
|
||||
prevButton.visibility = if (it.hasPrev) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
View.GONE
|
||||
|
|
|
@ -5,8 +5,10 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.CheckBox
|
||||
import android.widget.TextView
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.DividerItemDecoration
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.ViewHolder
|
||||
|
@ -51,6 +53,7 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
|
|||
recyclerView.adapter = adapter
|
||||
recyclerView.layoutManager =
|
||||
LinearLayoutManager(view.context, LinearLayoutManager.VERTICAL, false)
|
||||
recyclerView.addItemDecoration(DividerItemDecoration(requireContext(), LinearLayoutManager.VERTICAL))
|
||||
return view
|
||||
}
|
||||
|
||||
|
@ -76,33 +79,55 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
|
|||
adapter.slots = slots
|
||||
adapter.notifyDataSetChanged()
|
||||
hideProgressBar()
|
||||
loaded = true
|
||||
refreshButtons()
|
||||
}
|
||||
|
||||
private class SlotItemHolder(val root: View) : ViewHolder(root) {
|
||||
private class SlotItemHolder(val adapter: SlotInfoAdapter, val root: View) : ViewHolder(root) {
|
||||
private val title = root.requireViewById<TextView>(R.id.slot_item_title)
|
||||
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 checkBox = root.requireViewById<CheckBox>(R.id.slot_checkbox)
|
||||
|
||||
fun bind(item: SlotInfo) {
|
||||
private var curIdx = -1
|
||||
|
||||
init {
|
||||
root.setOnClickListener(this::onSelect)
|
||||
checkBox.setOnClickListener(this::onSelect)
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun onSelect(view: View) {
|
||||
if (curIdx < 0) return
|
||||
if (adapter.currentSelectedIdx == curIdx) return
|
||||
val lastIdx = adapter.currentSelectedIdx
|
||||
adapter.currentSelectedIdx = curIdx
|
||||
adapter.notifyItemChanged(lastIdx)
|
||||
adapter.notifyItemChanged(curIdx)
|
||||
}
|
||||
|
||||
fun bind(item: SlotInfo, idx: Int) {
|
||||
curIdx = idx
|
||||
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)
|
||||
checkBox.isChecked = adapter.currentSelectedIdx == idx
|
||||
}
|
||||
}
|
||||
|
||||
private class SlotInfoAdapter : RecyclerView.Adapter<SlotItemHolder>() {
|
||||
var slots: List<SlotInfo> = listOf()
|
||||
var currentSelectedIdx = 0
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SlotItemHolder {
|
||||
val root = LayoutInflater.from(parent.context).inflate(R.layout.download_slot_item, parent, false)
|
||||
return SlotItemHolder(root)
|
||||
return SlotItemHolder(this, root)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = slots.size
|
||||
|
||||
override fun onBindViewHolder(holder: SlotItemHolder, position: Int) {
|
||||
holder.bind(slots[position])
|
||||
holder.bind(slots[position], position)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,10 +3,11 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="10sp"
|
||||
android:layout_marginTop="10sp"
|
||||
android:paddingBottom="20sp"
|
||||
android:paddingTop="10sp"
|
||||
android:paddingStart="20sp"
|
||||
android:paddingEnd="20sp">
|
||||
android:paddingEnd="20sp"
|
||||
android:background="?attr/selectableItemBackground">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/slot_item_title"
|
||||
|
@ -22,6 +23,7 @@
|
|||
android:id="@+id/slot_item_eid_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="100dp"
|
||||
android:text="@string/download_wizard_slot_eid"
|
||||
android:textSize="14sp" />
|
||||
|
||||
|
@ -35,6 +37,7 @@
|
|||
android:id="@+id/slot_item_active_profile_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minWidth="100dp"
|
||||
android:text="@string/download_wizard_slot_active_profile"
|
||||
android:textSize="14sp" />
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
<string name="download_wizard">Download Wizard</string>
|
||||
<string name="download_wizard_back">Back</string>
|
||||
<string name="download_wizard_next">Next</string>
|
||||
<string name="download_wizard_slot_select">Select an eSIM slot:</string>
|
||||
<string name="download_wizard_slot_select">Confirm the eSIM slot:</string>
|
||||
<string name="download_wizard_slot_title">Logical slot %d</string>
|
||||
<string name="download_wizard_slot_eid">eID:</string>
|
||||
<string name="download_wizard_slot_active_profile">Active Profile:</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue