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

[Contributions dashboard] survey dialog #5044

Open
wants to merge 11 commits into
base: contributions-dashboard-design
Choose a base branch
from
Open
4 changes: 4 additions & 0 deletions app/src/main/java/org/wikipedia/settings/Prefs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -750,4 +750,8 @@ object Prefs {
var isRecurringDonor
get() = PrefsIoUtil.getBoolean(R.string.preference_key_is_recurring_donor, false)
set(value) = PrefsIoUtil.setBoolean(R.string.preference_key_is_recurring_donor, value)

var contributionDashboardSurveyDialogShown
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename contribution to plural.

get() = PrefsIoUtil.getBoolean(R.string.preference_key_contribution_dashboard_survey_dialog_shown, false)
set(value) = PrefsIoUtil.setBoolean(R.string.preference_key_contribution_dashboard_survey_dialog_shown, value)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ package org.wikipedia.suggestededits
import android.app.Activity
import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.LayoutInflater
import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
import android.view.ViewGroup
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.constraintlayout.widget.Group
import androidx.core.view.isVisible
import androidx.core.widget.NestedScrollView
Expand All @@ -18,6 +22,7 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import kotlinx.coroutines.launch
import org.wikipedia.Constants
import org.wikipedia.R
Expand Down Expand Up @@ -388,6 +393,32 @@ class SuggestedEditsTasksFragment : Fragment() {
}
}

private fun showSurveyDialog(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this dialog will not be reused in other places, can we make this even simpler, just like this?

Please make sure to add a check for the preference for the one-time popup purpose.

private fun maybeShowImportReadingListsNewInstallDialog() {
if (!Prefs.importReadingListsNewInstallDialogShown) {
ReadingListsAnalyticsHelper.logReceiveStart(requireActivity())
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.shareable_reading_lists_new_install_dialog_title)
.setMessage(R.string.shareable_reading_lists_new_install_dialog_content)
.setNegativeButton(R.string.shareable_reading_lists_new_install_dialog_got_it, null)
.show()
Prefs.importReadingListsNewInstallDialogShown = true
}
}

@StringRes titleId: Int = R.string.contributions_dashboard_survey_dialog_title,
@StringRes messageId: Int = R.string.contributions_dashboard_survey_dialog_message,
@DrawableRes iconId: Int = R.drawable.ic_feedback,
delayMillis: Long = 10000,
isCancellable: Boolean = false
) {
Handler(Looper.getMainLooper()).postDelayed({
Prefs.contributionDashboardSurveyDialogShown = true
MaterialAlertDialogBuilder(requireContext(), R.style.AlertDialogTheme_Icon)
.setTitle(titleId)
.setMessage(messageId)
.setCancelable(isCancellable)
.setIcon(iconId)
.setPositiveButton(R.string.contributions_dashboard_survey_dialog_ok) { _, _ ->
UriUtil.visitInExternalBrowser(
requireContext(),
Uri.parse(getString(R.string.contribution_dashboard_survey_url))
)
}
.setNegativeButton(R.string.contributions_dashboard_survey_dialog_cancel) { _, _ ->
// dismiss
}.show()
}, delayMillis)
}

private inner class TaskViewCallback : SuggestedEditsTaskView.Callback {
override fun onViewClick(task: SuggestedEditsTask, secondary: Boolean) {
if (WikipediaApp.instance.languageState.appLanguageCodes.size < Constants.MIN_LANGUAGES_TO_UNLOCK_TRANSLATION && secondary) {
Expand Down
76 changes: 50 additions & 26 deletions app/src/main/java/org/wikipedia/views/SurveyDialog.kt
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are no changes in this file, would it be possible to reset the change and make another PR for the format updates?

Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ import org.wikipedia.util.DimenUtil
import org.wikipedia.util.FeedbackUtil

object SurveyDialog {

fun showFeedbackOptionsDialog(activity: Activity,
titleId: Int = R.string.patroller_diff_feedback_dialog_title,
messageId: Int = R.string.patroller_diff_feedback_dialog_message,
snackbarMessageId: Int = R.string.patroller_diff_feedback_submitted_snackbar,
invokeSource: Constants.InvokeSource,
historyEntry: HistoryEntry? = null) {
fun showFeedbackOptionsDialog(
activity: Activity,
titleId: Int = R.string.patroller_diff_feedback_dialog_title,
messageId: Int = R.string.patroller_diff_feedback_dialog_message,
snackbarMessageId: Int = R.string.patroller_diff_feedback_submitted_snackbar,
invokeSource: Constants.InvokeSource,
historyEntry: HistoryEntry? = null
) {
var dialog: AlertDialog? = null
val binding = DialogFeedbackOptionsBinding.inflate(activity.layoutInflater)
binding.titleText.text = activity.getString(titleId)
Expand All @@ -49,8 +50,10 @@ object SurveyDialog {
showFeedbackInputDialog(activity, snackbarMessageId, invokeSource)
}

PatrollerExperienceEvent.logAction("feedback_selection", "feedback_form",
PatrollerExperienceEvent.getActionDataString(feedbackOption = feedbackOption))
PatrollerExperienceEvent.logAction(
"feedback_selection", "feedback_form",
PatrollerExperienceEvent.getActionDataString(feedbackOption = feedbackOption)
)
}
binding.optionSatisfied.setOnClickListener(clickListener)
binding.optionNeutral.setOnClickListener(clickListener)
Expand All @@ -61,25 +64,33 @@ object SurveyDialog {
binding.optionNeutral.isChecked = true
binding.feedbackInputContainer.isVisible = true

ExperimentalLinkPreviewInteraction(source = historyEntry?.source ?: HistoryEntry.SOURCE_SEARCH, RecommendedContentAnalyticsHelper.abcTest.getGroupName())
ExperimentalLinkPreviewInteraction(
source = historyEntry?.source ?: HistoryEntry.SOURCE_SEARCH,
RecommendedContentAnalyticsHelper.abcTest.getGroupName()
)
.logImpression(feedbackShown = true)
}

val dialogBuilder = MaterialAlertDialogBuilder(activity, R.style.AlertDialogTheme_AdjustResize)
.setCancelable(false)
.setView(binding.root)
val dialogBuilder =
MaterialAlertDialogBuilder(activity, R.style.AlertDialogTheme_AdjustResize)
.setCancelable(false)
.setView(binding.root)

if (invokeSource == Constants.InvokeSource.RECOMMENDED_CONTENT) {
binding.submitButton.setOnClickListener {
val feedbackInput = binding.feedbackInput.text.toString()

ExperimentalLinkPreviewInteraction(source = historyEntry?.source ?: HistoryEntry.SOURCE_SEARCH,
RecommendedContentAnalyticsHelper.abcTest.getGroupName())
.logNavigate(feedbackShown = true, feedbackSelect = when {
binding.optionSatisfied.isChecked -> "satisfied"
binding.optionUnsatisfied.isChecked -> "unsatisfied"
else -> "neutral"
}, feedbackText = feedbackInput)
ExperimentalLinkPreviewInteraction(
source = historyEntry?.source ?: HistoryEntry.SOURCE_SEARCH,
RecommendedContentAnalyticsHelper.abcTest.getGroupName()
)
.logNavigate(
feedbackShown = true, feedbackSelect = when {
binding.optionSatisfied.isChecked -> "satisfied"
binding.optionUnsatisfied.isChecked -> "unsatisfied"
else -> "neutral"
}, feedbackText = feedbackInput
)

showFeedbackSnackbarAndTooltip(activity, snackbarMessageId, invokeSource)
dialog?.dismiss()
Expand All @@ -94,22 +105,33 @@ object SurveyDialog {
dialog = dialogBuilder.show()
}

private fun showFeedbackInputDialog(activity: Activity, messageId: Int, source: Constants.InvokeSource) {
private fun showFeedbackInputDialog(
activity: Activity,
messageId: Int,
source: Constants.InvokeSource
) {
val feedbackView = activity.layoutInflater.inflate(R.layout.dialog_feedback_input, null)
PatrollerExperienceEvent.logAction("impression", "feedback_input_form")
MaterialAlertDialogBuilder(activity)
.setTitle(R.string.patroller_diff_feedback_dialog_feedback_title)
.setView(feedbackView)
.setPositiveButton(R.string.patroller_diff_feedback_dialog_submit) { _, _ ->
val feedbackInput = feedbackView.findViewById<TextInputEditText>(R.id.feedbackInput).text.toString()
PatrollerExperienceEvent.logAction("feedback_input_submit", "feedback_input_form",
PatrollerExperienceEvent.getActionDataString(feedbackText = feedbackInput))
val feedbackInput =
feedbackView.findViewById<TextInputEditText>(R.id.feedbackInput).text.toString()
PatrollerExperienceEvent.logAction(
"feedback_input_submit", "feedback_input_form",
PatrollerExperienceEvent.getActionDataString(feedbackText = feedbackInput)
)
showFeedbackSnackbarAndTooltip(activity, messageId, source)
}
.show()
}

private fun showFeedbackSnackbarAndTooltip(activity: Activity, messageId: Int, source: Constants.InvokeSource) {
private fun showFeedbackSnackbarAndTooltip(
activity: Activity,
messageId: Int,
source: Constants.InvokeSource
) {
FeedbackUtil.showMessage(activity, messageId)
when (source) {
Constants.InvokeSource.SUGGESTED_EDITS_RECENT_EDITS -> {
Expand All @@ -132,12 +154,14 @@ object SurveyDialog {
Constants.InvokeSource.SUGGESTED_EDITS_RECENT_EDITS -> {
Prefs.showOneTimeRecentEditsFeedbackForm = false
}
else -> { }

else -> {}
}
}
}
}, 100)
}

else -> {}
}
}
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_feedback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure but did you use the icon from the Figma design or the material design library? If it was from the Figma design, I think we can import the icon from the material design library directly in case Sarah wants the exact design from her design.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The icon Sarah used was in the material design library, so i imported from there.

android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,15C12.283,15 12.521,14.904 12.712,14.712C12.904,14.521 13,14.283 13,14C13,13.717 12.904,13.479 12.712,13.288C12.521,13.096 12.283,13 12,13C11.717,13 11.479,13.096 11.288,13.288C11.096,13.479 11,13.717 11,14C11,14.283 11.096,14.521 11.288,14.712C11.479,14.904 11.717,15 12,15ZM11,11H13V5H11V11ZM2,22V4C2,3.45 2.196,2.979 2.588,2.588C2.979,2.196 3.45,2 4,2H20C20.55,2 21.021,2.196 21.413,2.588C21.804,2.979 22,3.45 22,4V16C22,16.55 21.804,17.021 21.413,17.413C21.021,17.804 20.55,18 20,18H6L2,22ZM5.15,16H20V4H4V17.125L5.15,16Z"
android:fillColor="#000000"/>
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/values/preference_keys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,5 @@
<string name="preference_key_recommended_content_survey_shown">recommendedContentSurveyShown</string>
<string name="preference_key_donor_history_saved">hasDonorHistorySaved</string>
<string name="preference_key_is_recurring_donor">isRecurringDonor</string>
<string name="preference_key_contribution_dashboard_survey_dialog_shown">contributionDashboardSurveyDialogShown</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings_no_translate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<string name="donate_tax_url">https://donate.wikimedia.org/wiki/Special:LandingCheck?landing_page=Tax_deductibility&amp;basic=true</string>
<string name="donate_email">[email protected]</string>
<string name="donor_privacy_policy_url">https://foundation.wikimedia.org/wiki/Policy:Donor_privacy_policy</string>
<string name="contribution_dashboard_survey_url">https://docs.google.com/forms/d/1wIJWp75MMyp2e51kSaPH9ctByUzbyhazEOaJTxQhKqs/edit</string>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same: contribution -> contributions


<!-- Accounts -->
<string name="account_name">@string/wikimedia</string>
Expand Down
Loading