diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActionBarView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActionBarView.kt index b52f2e6bde..0c95628de5 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActionBarView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationActionBarView.kt @@ -5,7 +5,6 @@ import android.util.AttributeSet import android.view.LayoutInflater import android.view.ViewGroup import android.widget.LinearLayout -import androidx.annotation.DimenRes import androidx.core.view.isVisible import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter @@ -18,14 +17,11 @@ import network.loki.messenger.databinding.ViewConversationSettingBinding import org.session.libsession.messaging.open_groups.OpenGroup import org.session.libsession.utilities.ExpirationUtil import org.session.libsession.utilities.recipients.Recipient -import org.thoughtcrime.securesms.conversation.v2.utilities.MentionManagerUtilities import org.thoughtcrime.securesms.database.GroupDatabase import org.thoughtcrime.securesms.database.LokiAPIDatabase -import org.thoughtcrime.securesms.mms.GlideRequests import org.thoughtcrime.securesms.util.DateUtils import java.util.Locale import javax.inject.Inject -import kotlin.math.roundToInt @AndroidEntryPoint class ConversationActionBarView : LinearLayout { @@ -54,26 +50,12 @@ class ConversationActionBarView : LinearLayout { mediator.attach() } - fun bind(threadId: Long, recipient: Recipient, glide: GlideRequests, delegate: ConversationActionBarDelegate) { + fun bind(recipient: Recipient, delegate: ConversationActionBarDelegate) { this.delegate = delegate - binding.conversationTitleView.text = when { - recipient.isLocalNumber -> context.getString(R.string.note_to_self) - else -> recipient.toShortString() - } - @DimenRes val sizeID: Int = if (recipient.isClosedGroupRecipient) { - R.dimen.medium_profile_picture_size - } else { - R.dimen.small_profile_picture_size - } - val size = resources.getDimension(sizeID).roundToInt() - binding.profilePictureView.root.layoutParams = LayoutParams(size, size) - binding.profilePictureView.root.glide = glide - MentionManagerUtilities.populateUserPublicKeyCacheIfNeeded(threadId, context) - binding.profilePictureView.root.update(recipient) + update(recipient) } fun update(recipient: Recipient) { - binding.profilePictureView.root.update(recipient) binding.conversationTitleView.text = when { recipient.isLocalNumber -> context.getString(R.string.note_to_self) else -> recipient.toShortString() diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index d7144004b8..df19b4695b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -84,6 +84,7 @@ import org.thoughtcrime.securesms.ApplicationContext import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity import org.thoughtcrime.securesms.attachments.ScreenshotObserver import org.thoughtcrime.securesms.audio.AudioRecorder +import org.thoughtcrime.securesms.components.ProfilePictureView import org.thoughtcrime.securesms.contacts.SelectContactsActivity.Companion.selectedContactsKey import org.thoughtcrime.securesms.contactshare.SimpleTextWatcher import org.thoughtcrime.securesms.conversation.ConversationActionBarDelegate @@ -106,6 +107,7 @@ import org.thoughtcrime.securesms.conversation.v2.search.SearchBottomBar import org.thoughtcrime.securesms.conversation.v2.search.SearchViewModel import org.thoughtcrime.securesms.conversation.v2.utilities.AttachmentManager import org.thoughtcrime.securesms.conversation.v2.utilities.BaseDialog +import org.thoughtcrime.securesms.conversation.v2.utilities.MentionManagerUtilities import org.thoughtcrime.securesms.conversation.v2.utilities.MentionUtilities import org.thoughtcrime.securesms.conversation.v2.utilities.ResendMessageUtilities import org.thoughtcrime.securesms.crypto.IdentityKeyUtil @@ -173,6 +175,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe ConversationMenuHelper.ConversationMenuListener { private var binding: ActivityConversationV2Binding? = null + private var overflowMenuItem: MenuItem? = null @Inject lateinit var textSecurePreferences: TextSecurePreferences @Inject lateinit var threadDb: ThreadDatabase @@ -357,7 +360,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe updateUnreadCountIndicator() setUpTypingObserver() setUpRecipientObserver() - binding?.toolbarContent?.updateSubtitle(viewModel.recipient!!) getLatestOpenGroupInfoIfNeeded() setUpBlockedBanner() binding!!.searchBottomBar.setEventListener(this) @@ -454,7 +456,8 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe actionBar.title = "" actionBar.setDisplayHomeAsUpEnabled(true) actionBar.setHomeButtonEnabled(true) - binding!!.toolbarContent.bind(viewModel.threadId, recipient, glide, this) + binding!!.toolbarContent.bind(recipient, this) + maybeUpdateToolbar(recipient) } // called from onCreate @@ -547,6 +550,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe viewModel.openGroup?.let { openGroup -> OpenGroupApi.getMemberCount(openGroup.room, openGroup.server).successUi { binding?.toolbarContent?.updateSubtitle(viewModel.recipient!!, openGroup) + maybeUpdateToolbar(viewModel.recipient!!) } } } @@ -612,8 +616,10 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe menuInflater, recipient, this - ) + ) { onOptionsItemSelected(it) } } + overflowMenuItem = menu.findItem(R.id.menu_overflow) + viewModel.recipient?.let { maybeUpdateToolbar(it) } super.onPrepareOptionsMenu(menu) return true } @@ -623,7 +629,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe tearDownRecipientObserver() super.onDestroy() binding = null -// actionBarBinding = null } // endregion @@ -637,10 +642,18 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe setUpMessageRequestsBar() invalidateOptionsMenu() showOrHideInputIfNeeded() - binding?.toolbarContent?.update(threadRecipient) + maybeUpdateToolbar(threadRecipient) } } + private fun maybeUpdateToolbar(recipient: Recipient) { + binding?.toolbarContent?.update(recipient) + val profilePictureView = overflowMenuItem?.actionView?.findViewById(R.id.profilePictureView) + profilePictureView?.glide = glide + MentionManagerUtilities.populateUserPublicKeyCacheIfNeeded(viewModel.threadId, this) + profilePictureView?.update(recipient) + } + private fun showOrHideInputIfNeeded() { val recipient = viewModel.recipient if (recipient != null && recipient.isClosedGroupRecipient) { @@ -909,6 +922,10 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe if (item.itemId == android.R.id.home) { return false } + else if (item.itemId == R.id.menu_overflow) { + binding?.toolbar?.showOverflowMenu() + return false + } return viewModel.recipient?.let { recipient -> ConversationMenuHelper.onOptionItemSelected(this, item, recipient) } ?: false diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt index 76463fbfd0..720ebcd5c8 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/menus/ConversationMenuHelper.kt @@ -43,16 +43,25 @@ import java.io.IOException object ConversationMenuHelper { fun onPrepareOptionsMenu( - menu: Menu, + mainMenu: Menu, inflater: MenuInflater, thread: Recipient, - context: Context + context: Context, + onOptionsItemSelected: (MenuItem) -> Unit ) { // Prepare - menu.clear() + mainMenu.clear() val isOpenGroup = thread.isOpenGroupRecipient // Base menu (options that should always be present) - inflater.inflate(R.menu.menu_conversation, menu) + inflater.inflate(R.menu.menu_conversation, mainMenu) + val item = mainMenu.findItem(R.id.menu_overflow) + if (thread.isGroupRecipient) { + item.setIcon(R.drawable.ic_outline_settings_24) + } else { + item.setActionView(R.layout.view_profile_overflow) + item.actionView.setOnClickListener { onOptionsItemSelected(item) } + } + val menu = item.subMenu // One-on-one chat menu (options that should only be present for one-on-one chats) if (thread.isContactRecipient) { if (thread.isBlocked) { diff --git a/app/src/main/res/drawable/ic_outline_settings_24.xml b/app/src/main/res/drawable/ic_outline_settings_24.xml new file mode 100644 index 0000000000..c939e9ce8b --- /dev/null +++ b/app/src/main/res/drawable/ic_outline_settings_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/expiration_timer_menu.xml b/app/src/main/res/layout/expiration_timer_menu.xml deleted file mode 100644 index 5139045021..0000000000 --- a/app/src/main/res/layout/expiration_timer_menu.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/view_conversation_action_bar.xml b/app/src/main/res/layout/view_conversation_action_bar.xml index fb5ad17f4b..2cebcd3843 100644 --- a/app/src/main/res/layout/view_conversation_action_bar.xml +++ b/app/src/main/res/layout/view_conversation_action_bar.xml @@ -4,48 +4,34 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" - android:gravity="center_vertical" - android:orientation="horizontal"> + android:gravity="center_horizontal" + android:orientation="vertical"> - + tools:text="@tools:sample/full_names" + android:textColor="?android:textColorPrimary" + android:textStyle="bold" + android:textSize="@dimen/large_font_size" + android:maxLines="1" + android:ellipsize="end" /> - + - + - - - - - - - \ No newline at end of file + diff --git a/app/src/main/res/layout/view_profile_overflow.xml b/app/src/main/res/layout/view_profile_overflow.xml new file mode 100644 index 0000000000..4214c76548 --- /dev/null +++ b/app/src/main/res/layout/view_profile_overflow.xml @@ -0,0 +1,18 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_conversation.xml b/app/src/main/res/menu/menu_conversation.xml index 3be7af2964..16426221ab 100644 --- a/app/src/main/res/menu/menu_conversation.xml +++ b/app/src/main/res/menu/menu_conversation.xml @@ -4,17 +4,29 @@ xmlns:app="http://schemas.android.com/apk/res-auto"> + android:id="@+id/menu_overflow" + android:icon="@drawable/ic_outline_settings_24" + android:title="@string/conversation_context__menu_call" + app:showAsAction="always"> - + - + + + + + + + + +