mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Add entry points for adding to a group story.
This commit is contained in:
committed by
Cody Henthorne
parent
7949996c5c
commit
7b13550086
@@ -77,6 +77,7 @@ import org.thoughtcrime.securesms.recipients.ui.bottomsheet.RecipientBottomSheet
|
||||
import org.thoughtcrime.securesms.stories.Stories
|
||||
import org.thoughtcrime.securesms.stories.StoryViewerArgs
|
||||
import org.thoughtcrime.securesms.stories.dialogs.StoryDialogs
|
||||
import org.thoughtcrime.securesms.stories.viewer.AddToGroupStoryDelegate
|
||||
import org.thoughtcrime.securesms.stories.viewer.StoryViewerActivity
|
||||
import org.thoughtcrime.securesms.util.CommunicationActions
|
||||
import org.thoughtcrime.securesms.util.ContextUtil
|
||||
@@ -137,6 +138,7 @@ class ConversationSettingsFragment : DSLSettingsFragment(
|
||||
private lateinit var toolbarBadge: BadgeImageView
|
||||
private lateinit var toolbarTitle: TextView
|
||||
private lateinit var toolbarBackground: View
|
||||
private lateinit var addToGroupStoryDelegate: AddToGroupStoryDelegate
|
||||
|
||||
private val navController get() = Navigation.findNavController(requireView())
|
||||
|
||||
@@ -221,6 +223,7 @@ class ConversationSettingsFragment : DSLSettingsFragment(
|
||||
}
|
||||
}
|
||||
|
||||
addToGroupStoryDelegate = AddToGroupStoryDelegate(this)
|
||||
viewModel.state.observe(viewLifecycleOwner) { state ->
|
||||
|
||||
if (state.recipient != Recipient.UNKNOWN) {
|
||||
@@ -368,6 +371,17 @@ class ConversationSettingsFragment : DSLSettingsFragment(
|
||||
customPref(
|
||||
ButtonStripPreference.Model(
|
||||
state = state.buttonStripState,
|
||||
onAddToStoryClick = {
|
||||
if (state.recipient.isPushV2Group && state.requireGroupSettingsState().isAnnouncementGroup && !state.requireGroupSettingsState().isSelfAdmin) {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.ConversationSettingsFragment__cant_add_to_group_story)
|
||||
.setMessage(R.string.ConversationSettingsFragment__only_admins_of_this_group_can_add_to_its_story)
|
||||
.setPositiveButton(android.R.string.ok) { d, _ -> d.dismiss() }
|
||||
.show()
|
||||
} else {
|
||||
addToGroupStoryDelegate.addToStory(state.recipient.id)
|
||||
}
|
||||
},
|
||||
onVideoClick = {
|
||||
if (state.recipient.isPushV2Group && state.requireGroupSettingsState().isAnnouncementGroup && !state.requireGroupSettingsState().isSelfAdmin) {
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
|
||||
@@ -272,7 +272,8 @@ sealed class ConversationSettingsViewModel(
|
||||
isAudioSecure = recipient.isPushV2Group,
|
||||
isMuted = recipient.isMuted,
|
||||
isMuteAvailable = true,
|
||||
isSearchAvailable = true
|
||||
isSearchAvailable = true,
|
||||
isAddToStoryAvailable = recipient.isPushV2Group && !recipient.isBlocked && isActive
|
||||
),
|
||||
canModifyBlockedState = RecipientUtil.isBlockable(recipient),
|
||||
specificSettingsState = state.requireGroupSettingsState().copy(
|
||||
|
||||
@@ -24,6 +24,7 @@ object ButtonStripPreference {
|
||||
class Model(
|
||||
val state: State,
|
||||
val background: DSLSettingsIcon? = null,
|
||||
val onAddToStoryClick: () -> Unit = {},
|
||||
val onMessageClick: () -> Unit = {},
|
||||
val onVideoClick: () -> Unit = {},
|
||||
val onAudioClick: () -> Unit = {},
|
||||
@@ -41,6 +42,8 @@ object ButtonStripPreference {
|
||||
|
||||
class ViewHolder(itemView: View) : MappingViewHolder<Model>(itemView) {
|
||||
|
||||
private val addToStory: View = itemView.findViewById(R.id.add_to_story)
|
||||
private val addToStoryContainer: View = itemView.findViewById(R.id.button_strip_add_to_story_container)
|
||||
private val message: View = itemView.findViewById(R.id.message)
|
||||
private val messageContainer: View = itemView.findViewById(R.id.button_strip_message_container)
|
||||
private val videoCall: View = itemView.findViewById(R.id.start_video)
|
||||
@@ -60,6 +63,7 @@ object ButtonStripPreference {
|
||||
audioContainer.visible = model.state.isAudioAvailable
|
||||
muteContainer.visible = model.state.isMuteAvailable
|
||||
searchContainer.visible = model.state.isSearchAvailable
|
||||
addToStoryContainer.visible = model.state.isAddToStoryAvailable
|
||||
|
||||
if (model.state.isAudioSecure) {
|
||||
audioLabel.setText(R.string.ConversationSettingsFragment__audio)
|
||||
@@ -88,6 +92,7 @@ object ButtonStripPreference {
|
||||
audioCall.setOnClickListener { model.onAudioClick() }
|
||||
mute.setOnClickListener { model.onMuteClick() }
|
||||
search.setOnClickListener { model.onSearchClick() }
|
||||
addToStory.setOnClickListener { model.onAddToStoryClick() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,5 +104,6 @@ object ButtonStripPreference {
|
||||
val isSearchAvailable: Boolean = false,
|
||||
val isAudioSecure: Boolean = false,
|
||||
val isMuted: Boolean = false,
|
||||
val isAddToStoryAvailable: Boolean = false
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user