Compare commits

..

No commits in common. "4fb59a4b015ba3251eeb5ac3a51c701b044ee1ad" and "375d13b7c481021108b94620bed77a250cc951bd" have entirely different histories.

4 changed files with 9 additions and 37 deletions

View file

@ -80,7 +80,7 @@ class DownloadWizardActivity: BaseEuiccAccessActivity() {
} else { } else {
View.GONE View.GONE
} }
prevButton.visibility = if (it.hasPrev) { prevButton.visibility = if (it.hasNext) {
View.VISIBLE View.VISIBLE
} else { } else {
View.GONE View.GONE

View file

@ -5,10 +5,8 @@ import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.CheckBox
import android.widget.TextView import android.widget.TextView
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ViewHolder import androidx.recyclerview.widget.RecyclerView.ViewHolder
@ -53,7 +51,6 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
recyclerView.adapter = adapter recyclerView.adapter = adapter
recyclerView.layoutManager = recyclerView.layoutManager =
LinearLayoutManager(view.context, LinearLayoutManager.VERTICAL, false) LinearLayoutManager(view.context, LinearLayoutManager.VERTICAL, false)
recyclerView.addItemDecoration(DividerItemDecoration(requireContext(), LinearLayoutManager.VERTICAL))
return view return view
} }
@ -79,55 +76,33 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
adapter.slots = slots adapter.slots = slots
adapter.notifyDataSetChanged() adapter.notifyDataSetChanged()
hideProgressBar() hideProgressBar()
loaded = true
refreshButtons() refreshButtons()
} }
private class SlotItemHolder(val adapter: SlotInfoAdapter, val root: View) : ViewHolder(root) { private class SlotItemHolder(val root: View) : ViewHolder(root) {
private val title = root.requireViewById<TextView>(R.id.slot_item_title) private val title = root.requireViewById<TextView>(R.id.slot_item_title)
private val eID = root.requireViewById<TextView>(R.id.slot_item_eid) 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 activeProfile = root.requireViewById<TextView>(R.id.slot_item_active_profile)
private val checkBox = root.requireViewById<CheckBox>(R.id.slot_checkbox)
private var curIdx = -1 fun bind(item: SlotInfo) {
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) title.text = root.context.getString(R.string.download_wizard_slot_title, item.logicalSlotId)
eID.text = item.eID eID.text = item.eID
activeProfile.text = item.enabledProfileName ?: root.context.getString(R.string.unknown) activeProfile.text = item.enabledProfileName ?: root.context.getString(R.string.unknown)
checkBox.isChecked = adapter.currentSelectedIdx == idx
} }
} }
private class SlotInfoAdapter : RecyclerView.Adapter<SlotItemHolder>() { private class SlotInfoAdapter : RecyclerView.Adapter<SlotItemHolder>() {
var slots: List<SlotInfo> = listOf() var slots: List<SlotInfo> = listOf()
var currentSelectedIdx = 0
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SlotItemHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SlotItemHolder {
val root = LayoutInflater.from(parent.context).inflate(R.layout.download_slot_item, parent, false) val root = LayoutInflater.from(parent.context).inflate(R.layout.download_slot_item, parent, false)
return SlotItemHolder(this, root) return SlotItemHolder(root)
} }
override fun getItemCount(): Int = slots.size override fun getItemCount(): Int = slots.size
override fun onBindViewHolder(holder: SlotItemHolder, position: Int) { override fun onBindViewHolder(holder: SlotItemHolder, position: Int) {
holder.bind(slots[position], position) holder.bind(slots[position])
} }
} }
} }

View file

@ -3,11 +3,10 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="20sp" android:layout_marginBottom="10sp"
android:paddingTop="10sp" android:layout_marginTop="10sp"
android:paddingStart="20sp" android:paddingStart="20sp"
android:paddingEnd="20sp" android:paddingEnd="20sp">
android:background="?attr/selectableItemBackground">
<TextView <TextView
android:id="@+id/slot_item_title" android:id="@+id/slot_item_title"
@ -23,7 +22,6 @@
android:id="@+id/slot_item_eid_label" android:id="@+id/slot_item_eid_label"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minWidth="100dp"
android:text="@string/download_wizard_slot_eid" android:text="@string/download_wizard_slot_eid"
android:textSize="14sp" /> android:textSize="14sp" />
@ -37,7 +35,6 @@
android:id="@+id/slot_item_active_profile_label" android:id="@+id/slot_item_active_profile_label"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minWidth="100dp"
android:text="@string/download_wizard_slot_active_profile" android:text="@string/download_wizard_slot_active_profile"
android:textSize="14sp" /> android:textSize="14sp" />

View file

@ -61,7 +61,7 @@
<string name="download_wizard">Download Wizard</string> <string name="download_wizard">Download Wizard</string>
<string name="download_wizard_back">Back</string> <string name="download_wizard_back">Back</string>
<string name="download_wizard_next">Next</string> <string name="download_wizard_next">Next</string>
<string name="download_wizard_slot_select">Confirm the eSIM slot:</string> <string name="download_wizard_slot_select">Select an eSIM slot:</string>
<string name="download_wizard_slot_title">Logical slot %d</string> <string name="download_wizard_slot_title">Logical slot %d</string>
<string name="download_wizard_slot_eid">eID:</string> <string name="download_wizard_slot_eid">eID:</string>
<string name="download_wizard_slot_active_profile">Active Profile:</string> <string name="download_wizard_slot_active_profile">Active Profile:</string>