Add the ability to edit a link preview in stories before sending.

Resolves #14035
This commit is contained in:
Sagar
2025-03-05 01:06:45 +05:30
committed by Greyson Parrelli
parent cf529b354b
commit e00d780115
3 changed files with 15 additions and 1 deletions

View File

@@ -120,6 +120,10 @@ class TextStoryPostCreationFragment : Fragment(R.layout.stories_text_post_creati
viewModel.setLinkPreview("")
}
binding.storyTextPost.setLinkPreviewClickListener {
TextStoryPostLinkEntryFragment(true).show(childFragmentManager, null)
}
val launcher = registerForActivityResult(StoriesMultiselectForwardActivity.SelectionContract()) {
if (it.isNotEmpty()) {
performSend(it.toSet())

View File

@@ -131,6 +131,10 @@ class TextStoryPostCreationViewModel(private val repository: TextStoryPostSendRe
)
}
fun getLinkInputPreset(): String? {
return store.state.linkPreviewUri
}
class Factory(private val repository: TextStoryPostSendRepository) : ViewModelProvider.Factory {
override fun <T : ViewModel> create(modelClass: Class<T>): T {
return modelClass.cast(TextStoryPostCreationViewModel(repository)) as T

View File

@@ -21,7 +21,7 @@ import org.thoughtcrime.securesms.util.ViewUtil
import org.thoughtcrime.securesms.util.setIncognitoKeyboardEnabled
import org.thoughtcrime.securesms.util.visible
class TextStoryPostLinkEntryFragment : KeyboardEntryDialogFragment(
class TextStoryPostLinkEntryFragment(private val shouldPreset: Boolean = false) : KeyboardEntryDialogFragment(
contentLayoutId = R.layout.stories_text_post_link_entry_fragment
) {
@@ -35,6 +35,12 @@ class TextStoryPostLinkEntryFragment : KeyboardEntryDialogFragment(
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
input = view.findViewById(R.id.input)
if (shouldPreset) {
viewModel.getLinkInputPreset()?.let {
input.text.append(it)
linkPreviewViewModel.onTextChanged(it, 0, it.length - 1)
}
}
val linkPreview: StoryLinkPreviewView = view.findViewById(R.id.link_preview)
val confirmButton: View = view.findViewById(R.id.confirm_button)