mirror of
https://github.com/thunderbird/thunderbird-android.git
synced 2024-09-20 04:02:14 +02:00
Message Details: Move compose action into overflow menu
This commit is contained in:
parent
e0f0300e82
commit
169152e46f
@ -13,6 +13,7 @@ import androidx.annotation.StringRes
|
||||
import androidx.appcompat.widget.PopupMenu
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.MenuCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.setFragmentResult
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@ -153,7 +154,6 @@ class MessageDetailsFragment : ToolbarBottomSheetDialogFragment() {
|
||||
addEventHook(cryptoStatusClickEventHook)
|
||||
addEventHook(participantClickEventHook)
|
||||
addEventHook(addToContactsClickEventHook)
|
||||
addEventHook(composeClickEventHook)
|
||||
addEventHook(overflowClickEventHook)
|
||||
}
|
||||
|
||||
@ -242,34 +242,6 @@ class MessageDetailsFragment : ToolbarBottomSheetDialogFragment() {
|
||||
addToContactsLauncher.launch(context = requireContext(), name = address.personal, email = address.address)
|
||||
}
|
||||
|
||||
private val composeClickEventHook = object : ClickEventHook<ParticipantItem>() {
|
||||
override fun onBind(viewHolder: RecyclerView.ViewHolder): View? {
|
||||
return if (viewHolder is ParticipantItem.ViewHolder) {
|
||||
viewHolder.menuCompose
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View, position: Int, fastAdapter: FastAdapter<ParticipantItem>, item: ParticipantItem) {
|
||||
val address = item.participant.address
|
||||
composeMessageToAddress(address)
|
||||
}
|
||||
}
|
||||
|
||||
private fun composeMessageToAddress(address: Address) {
|
||||
// TODO: Use the identity this message was sent to as sender identity
|
||||
|
||||
val intent = Intent(context, MessageCompose::class.java).apply {
|
||||
action = Intent.ACTION_SEND
|
||||
putExtra(Intent.EXTRA_EMAIL, arrayOf(address.toString()))
|
||||
putExtra(MessageCompose.EXTRA_ACCOUNT, messageReference.accountUuid)
|
||||
}
|
||||
|
||||
dismiss()
|
||||
requireContext().startActivity(intent)
|
||||
}
|
||||
|
||||
private val overflowClickEventHook = object : ClickEventHook<ParticipantItem>() {
|
||||
override fun onBind(viewHolder: RecyclerView.ViewHolder): View? {
|
||||
return if (viewHolder is ParticipantItem.ViewHolder) {
|
||||
@ -289,8 +261,11 @@ class MessageDetailsFragment : ToolbarBottomSheetDialogFragment() {
|
||||
inflate(R.menu.participant_overflow_menu)
|
||||
}
|
||||
|
||||
val menu = popupMenu.menu
|
||||
MenuCompat.setGroupDividerEnabled(menu, true)
|
||||
|
||||
if (participant.address.personal == null) {
|
||||
popupMenu.menu.findItem(R.id.copy_name_and_email_address).isVisible = false
|
||||
menu.findItem(R.id.copy_name_and_email_address).isVisible = false
|
||||
}
|
||||
|
||||
popupMenu.setOnMenuItemClickListener { item: MenuItem ->
|
||||
@ -303,11 +278,25 @@ class MessageDetailsFragment : ToolbarBottomSheetDialogFragment() {
|
||||
|
||||
private fun onOverflowMenuItemClick(itemId: Int, participant: Participant) {
|
||||
when (itemId) {
|
||||
R.id.compose_to -> composeMessageToAddress(participant.address)
|
||||
R.id.copy_email_address -> viewModel.onCopyEmailAddressToClipboard(participant)
|
||||
R.id.copy_name_and_email_address -> viewModel.onCopyNameAndEmailAddressToClipboard(participant)
|
||||
}
|
||||
}
|
||||
|
||||
private fun composeMessageToAddress(address: Address) {
|
||||
// TODO: Use the identity this message was sent to as sender identity
|
||||
|
||||
val intent = Intent(context, MessageCompose::class.java).apply {
|
||||
action = Intent.ACTION_SEND
|
||||
putExtra(Intent.EXTRA_EMAIL, arrayOf(address.toString()))
|
||||
putExtra(MessageCompose.EXTRA_ACCOUNT, messageReference.accountUuid)
|
||||
}
|
||||
|
||||
dismiss()
|
||||
requireContext().startActivity(intent)
|
||||
}
|
||||
|
||||
private fun showCryptoKeys(pendingIntent: PendingIntent) {
|
||||
requireActivity().startIntentSender(pendingIntent.intentSender, null, 0, 0, 0)
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ internal class ParticipantItem(
|
||||
|
||||
class ViewHolder(view: View) : FastAdapter.ViewHolder<ParticipantItem>(view) {
|
||||
val menuAddContact: View = view.findViewById(R.id.menu_add_contact)
|
||||
val menuCompose: View = view.findViewById(R.id.menu_compose)
|
||||
val menuOverflow: View = view.findViewById(R.id.menu_overflow)
|
||||
|
||||
private val contactPicture: ImageView = view.findViewById(R.id.contact_picture)
|
||||
@ -32,7 +31,6 @@ internal class ParticipantItem(
|
||||
|
||||
init {
|
||||
TooltipCompat.setTooltipText(menuAddContact, menuAddContact.contentDescription)
|
||||
TooltipCompat.setTooltipText(menuCompose, menuCompose.contentDescription)
|
||||
TooltipCompat.setTooltipText(menuOverflow, menuOverflow.contentDescription)
|
||||
}
|
||||
|
||||
|
@ -68,22 +68,9 @@
|
||||
android:contentDescription="@string/action_add_to_contacts"
|
||||
android:focusable="true"
|
||||
android:paddingHorizontal="12dp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/menu_compose"
|
||||
app:layout_constraintTop_toTopOf="@+id/menu_compose"
|
||||
app:srcCompat="?attr/messageDetailsAddContactIcon" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/menu_compose"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="72dp"
|
||||
android:background="?attr/controlBackground"
|
||||
android:clickable="true"
|
||||
android:contentDescription="@string/compose_action"
|
||||
android:focusable="true"
|
||||
android:paddingHorizontal="12dp"
|
||||
app:layout_constraintEnd_toStartOf="@id/menu_overflow"
|
||||
app:layout_constraintTop_toTopOf="@+id/menu_overflow"
|
||||
app:srcCompat="@drawable/ic_envelope" />
|
||||
app:srcCompat="?attr/messageDetailsAddContactIcon" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/menu_overflow"
|
||||
|
@ -1,9 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/copy_email_address"
|
||||
android:title="@string/action_copy_email_address" />
|
||||
<item
|
||||
android:id="@+id/copy_name_and_email_address"
|
||||
android:title="@string/action_copy_name_and_email_address" />
|
||||
<group android:id="@+id/group_main">
|
||||
<item
|
||||
android:id="@+id/compose_to"
|
||||
android:title="@string/action_compose_message_to" />
|
||||
</group>
|
||||
<group android:id="@+id/group_other">
|
||||
<item
|
||||
android:id="@+id/copy_email_address"
|
||||
android:title="@string/action_copy_email_address" />
|
||||
<item
|
||||
android:id="@+id/copy_name_and_email_address"
|
||||
android:title="@string/action_copy_name_and_email_address" />
|
||||
</group>
|
||||
</menu>
|
||||
|
@ -1322,6 +1322,8 @@ You can keep this message and use it as a backup for your secret key. If you wan
|
||||
|
||||
<!-- Name of the action to add a person to contacts. Usually displayed in a menu or in a tooltip when long-pressing the associated icon. -->
|
||||
<string name="action_add_to_contacts">Add to contacts</string>
|
||||
<!-- Name of the action to compose a new message to a particular address. Usually displayed in a menu or in a tooltip when long-pressing the associated icon. -->
|
||||
<string name="action_compose_message_to">Compose message to</string>
|
||||
<!-- Name of the action to copy an email address to the clipboard. Usually displayed in a menu or in a tooltip when long-pressing the associated icon. -->
|
||||
<string name="action_copy_email_address">Copy email address</string>
|
||||
<!-- Name of the action to copy a name and email address to the clipboard. Usually displayed in a menu or in a tooltip when long-pressing the associated icon. -->
|
||||
|
Loading…
Reference in New Issue
Block a user