Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with Snackbar action after completing SE Feed items. #5205

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,18 @@ class SuggestedEditsCardItemFragment : Fragment() {
if (it.resultCode == RESULT_OK) {
if (isAdded) {
val openPageListener = SuggestedEditsSnackbars.OpenPageListener {
// Note: at this point, the fragment may have already been replaced by a different one (because
// we call showCardContent() down below), so we can't use requireActivity() here, and instead
// should use the context from the snackbar view.
if (viewModel.cardActionType === ADD_IMAGE_TAGS) {
startActivity(FilePageActivity.newIntent(requireActivity(), PageTitle(viewModel.imageTagPage?.title, WikiSite(WikipediaApp.instance.appOrSystemLanguageCode))))
it.context.startActivity(FilePageActivity.newIntent(it.context, PageTitle(viewModel.imageTagPage?.title, WikiSite.forLanguageCode(WikipediaApp.instance.appOrSystemLanguageCode))))
return@OpenPageListener
}
val pageTitle = viewModel.sourceSummaryForEdit!!.pageTitle
if (viewModel.cardActionType === ADD_CAPTION || viewModel.cardActionType === TRANSLATE_CAPTION) {
startActivity(GalleryActivity.newIntent(requireActivity(), pageTitle, pageTitle.prefixedText, pageTitle.wikiSite, 0))
it.context.startActivity(GalleryActivity.newIntent(it.context, pageTitle, pageTitle.prefixedText, pageTitle.wikiSite, 0))
} else {
startActivity(PageActivity.newIntentForNewTab(requireContext(), HistoryEntry(pageTitle, HistoryEntry.SOURCE_SUGGESTED_EDITS), pageTitle))
it.context.startActivity(PageActivity.newIntentForNewTab(it.context, HistoryEntry(pageTitle, HistoryEntry.SOURCE_SUGGESTED_EDITS), pageTitle))
}
}
SuggestedEditsSnackbars.show(requireActivity(), viewModel.cardActionType, true, viewModel.targetSummaryForEdit?.lang, true, openPageListener)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.wikipedia.suggestededits

import android.app.Activity
import android.view.View
import com.google.android.material.snackbar.Snackbar
import org.wikipedia.R
import org.wikipedia.WikipediaApp
Expand All @@ -11,7 +12,7 @@ import org.wikipedia.util.FeedbackUtil
object SuggestedEditsSnackbars {

fun interface OpenPageListener {
fun open()
fun open(actionView: View)
}

private const val MAX_SHOW_PER_SESSION = 2
Expand Down Expand Up @@ -39,7 +40,7 @@ object SuggestedEditsSnackbars {
})
})
if (enableViewAction && listener != null) {
snackbar.setAction(R.string.suggested_edits_article_cta_snackbar_action) { listener.open() }
snackbar.setAction(R.string.suggested_edits_article_cta_snackbar_action) { listener.open(it) }
}

snackbar.addCallback(object : Snackbar.Callback() {
Expand Down
Loading