Skip to content

Commit

Permalink
PP-756, PP-757: Adjust account deletion UI (#269)
Browse files Browse the repository at this point in the history
* Adjust account deletion UI

* Remove the popup menu in favour of a plain dialog popup.
* Fix the missing error message when trying to delete the last account.
* Use "Remove" instead of "Delete" for consistency.

Fix: https://ebce-lyrasis.atlassian.net/browse/PP-756

* Note changes
  • Loading branch information
io7m authored Nov 27, 2023
1 parent faec3bf commit ff9d9b7
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 32 deletions.
9 changes: 7 additions & 2 deletions README-CHANGES.xml
Original file line number Diff line number Diff line change
Expand Up @@ -407,19 +407,24 @@
</c:change>
</c:changes>
</c:release>
<c:release date="2023-11-21T15:13:27+00:00" is-open="true" ticket-system="org.lyrasis.jira" version="1.9.0">
<c:release date="2023-11-27T10:20:36+00:00" is-open="true" ticket-system="org.lyrasis.jira" version="1.9.0">
<c:changes>
<c:change date="2023-11-17T00:00:00+00:00" summary="Updated Readium version."/>
<c:change date="2023-11-20T00:00:00+00:00" summary="Fix an LCP audiobook crash.">
<c:tickets>
<c:ticket id="PP-737"/>
</c:tickets>
</c:change>
<c:change date="2023-11-21T15:13:27+00:00" summary="Make account deletion icon visible.">
<c:change date="2023-11-21T00:00:00+00:00" summary="Make account deletion icon visible.">
<c:tickets>
<c:ticket id="PP-738"/>
</c:tickets>
</c:change>
<c:change date="2023-11-27T10:20:36+00:00" summary="Adjust account deletion UI for consistency.">
<c:tickets>
<c:ticket id="PP-756"/>
</c:tickets>
</c:change>
</c:changes>
</c:release>
</c:releases>
Expand Down
2 changes: 1 addition & 1 deletion org.thepalaceproject.android.platform
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class AccountsDatabase private constructor(

if (this.accounts.size == 1) {
throw AccountsDatabaseLastAccountException(
"At least one account must exist at any given time"
"At least one account must exist at any given time."
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,19 @@ class ProfileAccountDeleteTask(
this.publishSuccessEvent(account)
this.taskRecorder.finishSuccess(Unit)
} catch (e: AccountsDatabaseLastAccountException) {
this.taskRecorder.currentStepFailed(
e.message ?: e.javaClass.name,
"oneAccountMustExist",
e
)
this.publishFailureEvent()
this.taskRecorder.finishFailure()
} catch (e: Throwable) {
this.taskRecorder.currentStepFailed(
e.message ?: e.javaClass.name,
"deletionFailed",
e
)
this.publishFailureEvent()
this.taskRecorder.finishFailure()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
package org.nypl.simplified.ui.accounts

import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.widget.PopupMenu
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import org.librarysimplified.ui.accounts.R
import org.nypl.simplified.accounts.database.api.AccountType
import org.nypl.simplified.ui.images.ImageAccountIcons
import org.nypl.simplified.ui.images.ImageLoaderType
import org.librarysimplified.ui.accounts.R

/**
* An adapter for a list of accounts.
Expand Down Expand Up @@ -47,7 +45,7 @@ class AccountListAdapter(
}

class AccountViewHolder(
val itemView: View,
itemView: View,
private val imageLoader: ImageLoaderType,
private val onItemClicked: (AccountType) -> Unit,
private val onItemDeleteClicked: (AccountType) -> Unit
Expand All @@ -58,7 +56,7 @@ class AccountListAdapter(
itemView.findViewById<TextView>(R.id.accountTitle)
private val accountCaptionView =
itemView.findViewById<TextView>(R.id.accountCaption)
private val popupMenuIcon =
private val deleteIcon =
itemView.findViewById<View>(R.id.popupMenuIcon)

private var accountItem: AccountType? = null
Expand All @@ -70,30 +68,12 @@ class AccountListAdapter(
}
}

val popupMenu =
PopupMenu(this.popupMenuIcon.context, this.popupMenuIcon, Gravity.END)
.apply {
inflate(R.menu.account_list_item)
}

popupMenu.setOnMenuItemClickListener { menuItem ->
when (menuItem.itemId) {
R.id.menuItemDelete -> {
this.accountItem?.let { account ->
this.onItemDeleteClicked.invoke(account)
}
}
this.deleteIcon.visibility = View.VISIBLE
this.deleteIcon.setOnClickListener {
this.accountItem?.let { account ->
this.onItemDeleteClicked.invoke(account)
}
true
}

this.popupMenuIcon
.apply {
visibility = View.VISIBLE
}
.setOnClickListener {
popupMenu.show()
}
}

fun bind(item: AccountType) {
Expand Down
2 changes: 1 addition & 1 deletion simplified-ui-accounts/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<string name="accountAgeVerification">Age Verification</string>
<string name="accountCreationFailed">Library creation failed</string>
<string name="accountCreationFailedMessage">The library could not be created.</string>
<string name="accountDelete">Delete</string>
<string name="accountDelete">Remove</string>
<string name="accountEULAStatement">By signing in, you agree to the End User License Agreement.</string>
<string name="accountLogin">Sign in</string>
<string name="accountForgotPassword">Forgot your password?</string>
Expand Down

0 comments on commit ff9d9b7

Please sign in to comment.