mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-28 10:47:46 +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.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import androidx.annotation.DimenRes
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.DiffUtil
|
||||
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.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 {
|
||||
@ -50,12 +54,28 @@ class ConversationActionBarView : LinearLayout {
|
||||
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
|
||||
@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)
|
||||
}
|
||||
|
||||
fun update(recipient: Recipient, openGroup: OpenGroup? = null) {
|
||||
binding.profilePictureView.root.update(recipient)
|
||||
binding.conversationTitleView.text = when {
|
||||
recipient.isLocalNumber -> context.getString(R.string.note_to_self)
|
||||
else -> recipient.toShortString()
|
||||
|
@ -85,7 +85,6 @@ 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
|
||||
@ -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.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
|
||||
@ -176,7 +174,6 @@ 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
|
||||
@ -458,7 +455,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
actionBar.title = ""
|
||||
actionBar.setDisplayHomeAsUpEnabled(true)
|
||||
actionBar.setHomeButtonEnabled(true)
|
||||
binding!!.toolbarContent.bind(this, recipient, viewModel.openGroup)
|
||||
binding!!.toolbarContent.bind(this, viewModel.threadId, recipient, viewModel.openGroup, glide)
|
||||
maybeUpdateToolbar(recipient)
|
||||
}
|
||||
|
||||
@ -626,9 +623,8 @@ 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
|
||||
@ -658,10 +654,6 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
||||
|
||||
private fun maybeUpdateToolbar(recipient: Recipient) {
|
||||
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() {
|
||||
|
@ -43,25 +43,16 @@ import java.io.IOException
|
||||
object ConversationMenuHelper {
|
||||
|
||||
fun onPrepareOptionsMenu(
|
||||
mainMenu: Menu,
|
||||
menu: Menu,
|
||||
inflater: MenuInflater,
|
||||
thread: Recipient,
|
||||
context: Context,
|
||||
onOptionsItemSelected: (MenuItem) -> Unit
|
||||
context: Context
|
||||
) {
|
||||
// Prepare
|
||||
mainMenu.clear()
|
||||
menu.clear()
|
||||
val isOpenGroup = thread.isOpenGroupRecipient
|
||||
// Base menu (options that should always be present)
|
||||
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 {
|
||||
/*TODO: item.setActionView(R.layout.view_profile_overflow)
|
||||
item.actionView.setOnClickListener { onOptionsItemSelected(item) }*/
|
||||
}
|
||||
val menu = item.subMenu
|
||||
inflater.inflate(R.menu.menu_conversation, menu)
|
||||
// Expiring messages
|
||||
if (thread.expireMessages == 0 && !isOpenGroup &&
|
||||
(thread.hasApprovedMe() || thread.isClosedGroupRecipient || thread.isLocalNumber)
|
||||
|
@ -4,34 +4,47 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/conversationTitleView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
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" />
|
||||
<include layout="@layout/view_profile_picture"
|
||||
android:id="@+id/profilePictureView"
|
||||
android:layout_width="@dimen/medium_profile_picture_size"
|
||||
android:layout_height="@dimen/medium_profile_picture_size" />
|
||||
|
||||
<androidx.viewpager2.widget.ViewPager2
|
||||
android:id="@+id/settings_pager"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/very_small_spacing"/>
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<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"/>
|
||||
<TextView
|
||||
android:id="@+id/conversationTitleView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
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" />
|
||||
|
||||
</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">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_overflow"
|
||||
android:icon="@drawable/ic_outline_settings_24"
|
||||
app:showAsAction="always">
|
||||
android:title="@string/conversation__menu_view_all_media"
|
||||
android:id="@+id/menu_view_all_media" />
|
||||
|
||||
<menu>
|
||||
<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_view_all_media"
|
||||
android:id="@+id/menu_view_all_media" />
|
||||
|
||||
<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>
|
||||
<item
|
||||
android:title="@string/conversation__menu_add_shortcut"
|
||||
android:id="@+id/menu_add_shortcut" />
|
||||
|
||||
</menu>
|
||||
|
Loading…
x
Reference in New Issue
Block a user