Skip to content

Commit

Permalink
remove show all
Browse files Browse the repository at this point in the history
  • Loading branch information
vvb2060 committed Jan 17, 2024
1 parent d7ebee4 commit 161123e
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HomeAdapter(listener: Listener) : IdBasedRecyclerViewAdapter() {
setListener(listener)
}

fun updateData(attestationResult: AttestationResult, showAll: Boolean) {
fun updateData(attestationResult: AttestationResult) {
val attestation = attestationResult.showAttestation

clear()
Expand Down Expand Up @@ -73,13 +73,11 @@ class HomeAdapter(listener: Listener) : IdBasedRecyclerViewAdapter() {
addItem(BootStateViewHolder.CREATOR, attestationResult, ID_BOOT_STATUS)

var id = ID_CERT_INFO_START
if (showAll) {
addItem(SubtitleViewHolder.CREATOR, SubtitleData(
R.string.cert_chain,
R.string.cert_chain_description), id++)
attestationResult.certs.forEach { certInfo ->
addItem(CommonItemViewHolder.CERT_INFO_CREATOR, certInfo, id++)
}
addItem(SubtitleViewHolder.CREATOR, SubtitleData(
R.string.cert_chain,
R.string.cert_chain_description), id++)
attestationResult.certs.forEach { certInfo ->
addItem(CommonItemViewHolder.CERT_INFO_CREATOR, certInfo, id++)
}

id = ID_DESCRIPTION_START
Expand All @@ -106,7 +104,7 @@ class HomeAdapter(listener: Listener) : IdBasedRecyclerViewAdapter() {
else BaseEncoding.base64().encode(it) + " (base64)"
}), id++)

if (showAll) addItem(CommonItemViewHolder.COMMON_CREATOR, CommonData(
addItem(CommonItemViewHolder.COMMON_CREATOR, CommonData(
R.string.unique_id,
R.string.unique_id_description,
attestation.uniqueId?.let { BaseEncoding.base64().encode(it) }), id)
Expand All @@ -118,15 +116,10 @@ class HomeAdapter(listener: Listener) : IdBasedRecyclerViewAdapter() {

val tee = createAuthorizationItems(attestation.teeEnforced)
val sw = createAuthorizationItems(attestation.softwareEnforced)
val showIndex = authorizationItemTitles.indexOf(R.string.authorization_list_rootOfTrust)
for (i in tee.indices) {
if (tee[i] == null && sw[i] == null) {
continue
}
if (!showAll && i < showIndex) {
id++ // Keep id stable
continue
}

addItem(CommonItemViewHolder.AUTHORIZATION_ITEM_CREATOR, AuthorizationItemData(
authorizationItemTitles[i],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class HomeFragment : AppFragment(), HomeAdapter.Listener, MenuProvider {
Status.SUCCESS -> {
binding.progress.isVisible = false
binding.list.isVisible = true
adapter.updateData(res.data!!, viewModel.preferShowAll)
adapter.updateData(res.data!!)
}
Status.ERROR -> {
binding.progress.isVisible = false
Expand All @@ -97,7 +97,7 @@ class HomeFragment : AppFragment(), HomeAdapter.Listener, MenuProvider {
override fun onAttestationInfoClick(data: Attestation) {
val result = viewModel.attestationResult.value!!.data!!
result.showAttestation = data
adapter.updateData(result, viewModel.preferShowAll)
adapter.updateData(result)
}

override fun onCertInfoClick(data: CertificateInfo) {
Expand Down Expand Up @@ -162,10 +162,6 @@ class HomeFragment : AppFragment(), HomeAdapter.Listener, MenuProvider {
isVisible = viewModel.hasDeviceIds
isChecked = viewModel.preferIncludeProps
}
menu.findItem(R.id.menu_show_all).apply {
isVisible = viewModel.attestationResult.value?.data != null
isChecked = viewModel.preferShowAll
}
menu.findItem(R.id.menu_save).isVisible = viewModel.currentCerts != null
}

Expand Down Expand Up @@ -193,12 +189,6 @@ class HomeFragment : AppFragment(), HomeAdapter.Listener, MenuProvider {
viewModel.preferIncludeProps = status
viewModel.load()
}
R.id.menu_show_all -> {
val status = !item.isChecked
item.isChecked = status
viewModel.preferShowAll = status
adapter.updateData(viewModel.attestationResult.value!!.data!!, status)
}
R.id.menu_reset -> {
viewModel.load(true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@ class HomeViewModel(pm: PackageManager, private val sp: SharedPreferences) : Vie
sp.edit { putBoolean("prefer_including_props", value) }
}

var preferShowAll = sp.getBoolean("prefer_show_all", false)
set(value) {
field = value
sp.edit { putBoolean("prefer_show_all", value) }
}

init {
keyStore.load(null)
load()
Expand Down
6 changes: 0 additions & 6 deletions app/src/main/res/menu/home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
android:checkable="true"
android:title="@string/attest_device_props" />

<item
android:id="@+id/menu_show_all"
android:showAsAction="never"
android:checkable="true"
android:title="@string/show_all" />

<item
android:id="@+id/menu_reset"
android:showAsAction="never"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<string name="use_strongbox">使用 StrongBox</string>
<string name="use_attest_key">使用应用生成的认证密钥</string>
<string name="attest_device_props">认证设备属性</string>
<string name="show_all">显示全部</string>
<string name="reset">重置</string>
<string name="load_certs">从文件加载</string>
<string name="save_certs">保存到文件</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<string name="use_strongbox">Use StrongBox</string>
<string name="use_attest_key">Use app generated attest key</string>
<string name="attest_device_props">Attest device props</string>
<string name="show_all">Show all</string>
<string name="reset">Reset</string>
<string name="load_certs">Load from file</string>
<string name="save_certs">Save to file</string>
Expand Down

0 comments on commit 161123e

Please sign in to comment.