mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 20:15:21 +00:00
Revert overflow menu changes
This commit is contained in:
parent
48a99a85c3
commit
312164e364
@ -5,6 +5,7 @@ import android.util.AttributeSet
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import androidx.annotation.DimenRes
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.DiffUtil
|
import androidx.recyclerview.widget.DiffUtil
|
||||||
import androidx.recyclerview.widget.ListAdapter
|
import androidx.recyclerview.widget.ListAdapter
|
||||||
@ -17,11 +18,14 @@ import network.loki.messenger.databinding.ViewConversationSettingBinding
|
|||||||
import org.session.libsession.messaging.open_groups.OpenGroup
|
import org.session.libsession.messaging.open_groups.OpenGroup
|
||||||
import org.session.libsession.utilities.ExpirationUtil
|
import org.session.libsession.utilities.ExpirationUtil
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
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.GroupDatabase
|
||||||
import org.thoughtcrime.securesms.database.LokiAPIDatabase
|
import org.thoughtcrime.securesms.database.LokiAPIDatabase
|
||||||
|
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||||
import org.thoughtcrime.securesms.util.DateUtils
|
import org.thoughtcrime.securesms.util.DateUtils
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@AndroidEntryPoint
|
@AndroidEntryPoint
|
||||||
class ConversationActionBarView : LinearLayout {
|
class ConversationActionBarView : LinearLayout {
|
||||||
@ -50,12 +54,28 @@ class ConversationActionBarView : LinearLayout {
|
|||||||
mediator.attach()
|
mediator.attach()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bind(delegate: ConversationActionBarDelegate, recipient: Recipient, openGroup: OpenGroup? = null) {
|
fun bind(
|
||||||
|
delegate: ConversationActionBarDelegate,
|
||||||
|
threadId: Long,
|
||||||
|
recipient: Recipient,
|
||||||
|
openGroup: OpenGroup? = null,
|
||||||
|
glide: GlideRequests
|
||||||
|
) {
|
||||||
this.delegate = delegate
|
this.delegate = delegate
|
||||||
|
@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)
|
||||||
update(recipient, openGroup)
|
update(recipient, openGroup)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update(recipient: Recipient, openGroup: OpenGroup? = null) {
|
fun update(recipient: Recipient, openGroup: OpenGroup? = null) {
|
||||||
|
binding.profilePictureView.root.update(recipient)
|
||||||
binding.conversationTitleView.text = when {
|
binding.conversationTitleView.text = when {
|
||||||
recipient.isLocalNumber -> context.getString(R.string.note_to_self)
|
recipient.isLocalNumber -> context.getString(R.string.note_to_self)
|
||||||
else -> recipient.toShortString()
|
else -> recipient.toShortString()
|
||||||
|
@ -85,7 +85,6 @@ import org.thoughtcrime.securesms.ApplicationContext
|
|||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
||||||
import org.thoughtcrime.securesms.attachments.ScreenshotObserver
|
import org.thoughtcrime.securesms.attachments.ScreenshotObserver
|
||||||
import org.thoughtcrime.securesms.audio.AudioRecorder
|
import org.thoughtcrime.securesms.audio.AudioRecorder
|
||||||
import org.thoughtcrime.securesms.components.ProfilePictureView
|
|
||||||
import org.thoughtcrime.securesms.contacts.SelectContactsActivity.Companion.selectedContactsKey
|
import org.thoughtcrime.securesms.contacts.SelectContactsActivity.Companion.selectedContactsKey
|
||||||
import org.thoughtcrime.securesms.contactshare.SimpleTextWatcher
|
import org.thoughtcrime.securesms.contactshare.SimpleTextWatcher
|
||||||
import org.thoughtcrime.securesms.conversation.ConversationActionBarDelegate
|
import org.thoughtcrime.securesms.conversation.ConversationActionBarDelegate
|
||||||
@ -108,7 +107,6 @@ import org.thoughtcrime.securesms.conversation.v2.search.SearchBottomBar
|
|||||||
import org.thoughtcrime.securesms.conversation.v2.search.SearchViewModel
|
import org.thoughtcrime.securesms.conversation.v2.search.SearchViewModel
|
||||||
import org.thoughtcrime.securesms.conversation.v2.utilities.AttachmentManager
|
import org.thoughtcrime.securesms.conversation.v2.utilities.AttachmentManager
|
||||||
import org.thoughtcrime.securesms.conversation.v2.utilities.BaseDialog
|
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.MentionUtilities
|
||||||
import org.thoughtcrime.securesms.conversation.v2.utilities.ResendMessageUtilities
|
import org.thoughtcrime.securesms.conversation.v2.utilities.ResendMessageUtilities
|
||||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
|
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
|
||||||
@ -176,7 +174,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
ConversationMenuHelper.ConversationMenuListener {
|
ConversationMenuHelper.ConversationMenuListener {
|
||||||
|
|
||||||
private var binding: ActivityConversationV2Binding? = null
|
private var binding: ActivityConversationV2Binding? = null
|
||||||
private var overflowMenuItem: MenuItem? = null
|
|
||||||
|
|
||||||
@Inject lateinit var textSecurePreferences: TextSecurePreferences
|
@Inject lateinit var textSecurePreferences: TextSecurePreferences
|
||||||
@Inject lateinit var threadDb: ThreadDatabase
|
@Inject lateinit var threadDb: ThreadDatabase
|
||||||
@ -458,7 +455,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
actionBar.title = ""
|
actionBar.title = ""
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true)
|
actionBar.setDisplayHomeAsUpEnabled(true)
|
||||||
actionBar.setHomeButtonEnabled(true)
|
actionBar.setHomeButtonEnabled(true)
|
||||||
binding!!.toolbarContent.bind(this, recipient, viewModel.openGroup)
|
binding!!.toolbarContent.bind(this, viewModel.threadId, recipient, viewModel.openGroup, glide)
|
||||||
maybeUpdateToolbar(recipient)
|
maybeUpdateToolbar(recipient)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -626,9 +623,8 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
menuInflater,
|
menuInflater,
|
||||||
recipient,
|
recipient,
|
||||||
this
|
this
|
||||||
) { onOptionsItemSelected(it) }
|
)
|
||||||
}
|
}
|
||||||
overflowMenuItem = menu.findItem(R.id.menu_overflow)
|
|
||||||
viewModel.recipient?.let { maybeUpdateToolbar(it) }
|
viewModel.recipient?.let { maybeUpdateToolbar(it) }
|
||||||
super.onPrepareOptionsMenu(menu)
|
super.onPrepareOptionsMenu(menu)
|
||||||
return true
|
return true
|
||||||
@ -658,10 +654,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
|
|
||||||
private fun maybeUpdateToolbar(recipient: Recipient) {
|
private fun maybeUpdateToolbar(recipient: Recipient) {
|
||||||
binding?.toolbarContent?.update(recipient, viewModel.openGroup)
|
binding?.toolbarContent?.update(recipient, viewModel.openGroup)
|
||||||
val profilePictureView = overflowMenuItem?.actionView?.findViewById<ProfilePictureView>(R.id.profilePictureView)
|
|
||||||
profilePictureView?.glide = glide
|
|
||||||
MentionManagerUtilities.populateUserPublicKeyCacheIfNeeded(viewModel.threadId, this)
|
|
||||||
profilePictureView?.update(recipient)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showOrHideInputIfNeeded() {
|
private fun showOrHideInputIfNeeded() {
|
||||||
|
@ -43,25 +43,16 @@ import java.io.IOException
|
|||||||
object ConversationMenuHelper {
|
object ConversationMenuHelper {
|
||||||
|
|
||||||
fun onPrepareOptionsMenu(
|
fun onPrepareOptionsMenu(
|
||||||
mainMenu: Menu,
|
menu: Menu,
|
||||||
inflater: MenuInflater,
|
inflater: MenuInflater,
|
||||||
thread: Recipient,
|
thread: Recipient,
|
||||||
context: Context,
|
context: Context
|
||||||
onOptionsItemSelected: (MenuItem) -> Unit
|
|
||||||
) {
|
) {
|
||||||
// Prepare
|
// Prepare
|
||||||
mainMenu.clear()
|
menu.clear()
|
||||||
val isOpenGroup = thread.isOpenGroupRecipient
|
val isOpenGroup = thread.isOpenGroupRecipient
|
||||||
// Base menu (options that should always be present)
|
// Base menu (options that should always be present)
|
||||||
inflater.inflate(R.menu.menu_conversation, mainMenu)
|
inflater.inflate(R.menu.menu_conversation, menu)
|
||||||
val item = mainMenu.findItem(R.id.menu_overflow)
|
|
||||||
if (thread.isGroupRecipient) {
|
|
||||||
item.setIcon(R.drawable.ic_outline_settings_24)
|
|
||||||
} else {
|
|
||||||
/*TODO: item.setActionView(R.layout.view_profile_overflow)
|
|
||||||
item.actionView.setOnClickListener { onOptionsItemSelected(item) }*/
|
|
||||||
}
|
|
||||||
val menu = item.subMenu
|
|
||||||
// Expiring messages
|
// Expiring messages
|
||||||
if (thread.expireMessages == 0 && !isOpenGroup &&
|
if (thread.expireMessages == 0 && !isOpenGroup &&
|
||||||
(thread.hasApprovedMe() || thread.isClosedGroupRecipient || thread.isLocalNumber)
|
(thread.hasApprovedMe() || thread.isClosedGroupRecipient || thread.isLocalNumber)
|
||||||
|
@ -4,34 +4,47 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
android:gravity="center_horizontal"
|
android:orientation="horizontal"
|
||||||
android:orientation="vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<TextView
|
<include layout="@layout/view_profile_picture"
|
||||||
android:id="@+id/conversationTitleView"
|
android:id="@+id/profilePictureView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="@dimen/medium_profile_picture_size"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="@dimen/medium_profile_picture_size" />
|
||||||
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" />
|
|
||||||
|
|
||||||
<androidx.viewpager2.widget.ViewPager2
|
<LinearLayout
|
||||||
android:id="@+id/settings_pager"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginBottom="@dimen/very_small_spacing"/>
|
android:gravity="center_horizontal"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<com.google.android.material.tabs.TabLayout
|
<TextView
|
||||||
android:id="@+id/settings_tab_layout"
|
android:id="@+id/conversationTitleView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="@dimen/very_small_spacing"
|
android:layout_height="wrap_content"
|
||||||
app:tabBackground="@drawable/tab_indicator_dot"
|
tools:text="@tools:sample/full_names"
|
||||||
app:tabGravity="center"
|
android:textColor="?android:textColorPrimary"
|
||||||
app:tabIndicator="@null"
|
android:textStyle="bold"
|
||||||
app:tabPaddingStart="@dimen/very_small_spacing"
|
android:textSize="@dimen/large_font_size"
|
||||||
app:tabPaddingEnd="@dimen/very_small_spacing"/>
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end" />
|
||||||
|
|
||||||
</LinearLayout>
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
|
android:id="@+id/settings_pager"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/very_small_spacing"/>
|
||||||
|
|
||||||
|
<com.google.android.material.tabs.TabLayout
|
||||||
|
android:id="@+id/settings_tab_layout"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="@dimen/very_small_spacing"
|
||||||
|
app:tabBackground="@drawable/tab_indicator_dot"
|
||||||
|
app:tabGravity="center"
|
||||||
|
app:tabIndicator="@null"
|
||||||
|
app:tabPaddingStart="@dimen/very_small_spacing"
|
||||||
|
app:tabPaddingEnd="@dimen/very_small_spacing"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -4,28 +4,17 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_overflow"
|
android:title="@string/conversation__menu_view_all_media"
|
||||||
android:icon="@drawable/ic_outline_settings_24"
|
android:id="@+id/menu_view_all_media" />
|
||||||
app:showAsAction="always">
|
|
||||||
|
|
||||||
<menu>
|
<item
|
||||||
|
android:title="@string/SearchToolbar_search"
|
||||||
|
android:id="@+id/menu_search"
|
||||||
|
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||||
|
app:showAsAction="collapseActionView" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:title="@string/conversation__menu_view_all_media"
|
android:title="@string/conversation__menu_add_shortcut"
|
||||||
android:id="@+id/menu_view_all_media" />
|
android:id="@+id/menu_add_shortcut" />
|
||||||
|
|
||||||
<item
|
|
||||||
android:title="@string/SearchToolbar_search"
|
|
||||||
android:id="@+id/menu_search"
|
|
||||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
|
||||||
app:showAsAction="collapseActionView" />
|
|
||||||
|
|
||||||
<item
|
|
||||||
android:title="@string/conversation__menu_add_shortcut"
|
|
||||||
android:id="@+id/menu_add_shortcut" />
|
|
||||||
|
|
||||||
</menu>
|
|
||||||
|
|
||||||
</item>
|
|
||||||
|
|
||||||
</menu>
|
</menu>
|
||||||
|
Loading…
Reference in New Issue
Block a user