Skip to content

Commit d87b6b9

Browse files
coolteyWilliamraidbrant
authored
[Feature branch] The Donation Reminder (#5783)
* Add donation reminder helper class for T399605 * Update comment * Update helper config * Create a Donation reminder data class for the configuration (#5802) * Create a Donation reminder data class for the configuration * Lint * Simplify * Change to val * Move donation reminder helper to the sub package * Fix lint * Strings for donation reminders (#5812) * - strings for donation reminders * - order fixes * Donation reminder set-up form (#5786) * - adds DonationReminderActivity, DonationReminderScreen initial code - adds a text with inline element support * - adds other components for the donation reminder screen - code fixes * - adds Donation Field with popup components - adds viewModel logic to retrieve donation amounts and other data - create readable code structure - created ui state data class for compose * - adds an info tooltip and headline icon, text align fix * - adds custom dialog - code re-structure * - ui fixes * - adds snackbar when user confirms the reminder * - adds validators, maximum threshold and ui fixes - adds hardcoded donation frequencies and amounts * - adds proper validation with error icon - adds config call to retrieve min and max amount * - adds donations category in the settings screen - adds donation reminder to setting screen * - updates DonationReminderHelper.kt * - code fixes * - code fixes * - adds "isFromSettings" logic and adds TODO * - code/ui fixes - adds timestamp preference * - code fixes to fit the new DonationReminderConfig * - move DonationReminderHelper.kt to donationreminder package - lint fixes * - adds external experiment link * - code fixes * - optimizes currency format recomposition - code/ui fixes * - converts the dataType articleFrequency and donateAmount to float - - update strings and logic for the float data type * - code fix * - code fixes * - move currency formatting and amount formatting logic to a separate DonateUtil object * - using directly instead of importing * - code fixes * - Adds string resources * - adds generic for selectable Option to handle different number types - ui/string fixes * - code fixes * - code/ui fixes --------- Co-authored-by: Cooltey Feng <[email protected]> * - updates logic which shows toggle or confirm button based on where it comes from (#5816) - adds loading and error state - updates code structure * Use strings item instead of hard-coded text * - code fix (#5819) * Donation reminder: In-article prompt (#5787) * Donation reminder: In-article prompt * Set message card height? * Fix height for now * Use post for now * Get a better measure method * Unused import * Set strings and preferences * Update logic and preference * update helper class * Refine card layout * Lint * Handle visibility properly * Update label * Correct monospace - should apply this programmtically * handle bottom space correctly * Adjust the padding and animation * Fix unreachable IDE error * Update space in different cases * Adjust height correctly * Show snackbar message * Update helper class * Add logic for different card messages * donation flow * Add strings and set up donation bottomsheet for donation reminder * Google Pay * References fix * fix lint * make sure the prefs works correctly * Set up Gpay and the flow * Update card height and logic of showing the reminder * Article visit * 15 seconds as valid time spent on an article * Update donate dialog paddings * Set the currency from helper class * Lint * - strings for donation reminders * - order fixes * Update string names * Change d to s * Change d to s #2 * string update * More proper parameter from `d` to `s` * Update strings * Filled amount * Wire filled amount to GooglePay screen * Add filled amount to the list and sort * Fix lint * Update code error * Update imports * Update the logic of showing the prompt * Reset the config after reaching the condition * Lint fix * condition update * Refine the algorithm * Code review comments * Update the get * Refine the logic * reset the active status when enabling the feature * logic update --------- Co-authored-by: williamrai <[email protected]> * Use proper title for Settings and add two buttons for QA purposes. (#5820) * Add two reset buttons in developer preferences for testing purposes * Use proper title in Settings preference * Donation Reminders Survey (#5794) * Donation reminder: In-article prompt * Set message card height? * Fix height for now * Use post for now * Get a better measure method * Unused import * Set strings and preferences * Update logic and preference * update helper class * Refine card layout * Lint * Handle visibility properly * Update label * Correct monospace - should apply this programmtically * - adds DonationRemindersSurveyGroupAssignment, DonationReminderSurveyState for handling donation reminders survey dialog - adds preference to track the survey dialog state and article visit - copies over code from donation reminder in-prompt PR * handle bottom space correctly * Adjust the padding and animation * Fix unreachable IDE error * Update space in different cases * Adjust height correctly * Show snackbar message * - adds survey dialog - adds strings * Update helper class * Add logic for different card messages * donation flow * Add strings and set up donation bottomsheet for donation reminder * - updates donation reminders survey logic - copies over preference from other donation reminders PR * Google Pay * - code fixes to fit the new DonationReminderConfig * - lint fixes * References fix * fix lint * - lint fixes * make sure the prefs works correctly * Set up Gpay and the flow * Update card height and logic of showing the reminder * Article visit * 15 seconds as valid time spent on an article * Update donate dialog paddings * Set the currency from helper class * Lint * - strings for donation reminders * - order fixes * Update string names * Change d to s * Change d to s #2 * string update * More proper parameter from `d` to `s` * Update strings * Filled amount * Wire filled amount to GooglePay screen * Add filled amount to the list and sort * Fix lint * Update code error * Update imports * Update the logic of showing the prompt * Reset the config after reaching the condition * Lint fix * condition update * Refine the algorithm * Code review comments * Update the get * - adds a TODO * Refine the logic * - code fix * reset the active status when enabling the feature * logic update * - code fix * - code fixes * - code fixes * - survey logic fix * - code fixes --------- Co-authored-by: Cooltey Feng <[email protected]> * - updates userGroup "B" logic to show survey dialog on next time user sees milestone reminder (#5823) * Donation Reminders Instrumentation (#5822) * - adds instrumentation * - adds instrumentation and adds defaultValues to SelectableOption data class * - adds new campaign_id for donation reminder - adds instrumentation and isNavigatingToExternalUrl to safeguard against saving reminder if user navigates using external link * - adds TODO * - instrumentation fixes for gpay_sucess * Code format updated --------- Co-authored-by: Cooltey Feng <[email protected]> * Survey Instrumentation Donation Reminders (#5835) * - adds user groups as action data for sending survey events * - code fixes * Design review fix * Update margins * Border to use 1dp * Remove unused thank you message * Donation reminder UI fixes (#5843) * - design fixes * - using window inset for retrieving bottom navigation height - code fixes * - code fixes * - code fixes * Update experiment end date * Design fix: add horizontal paddings to the about button * Code review comments and update experiment date * Lint * String. * Use translated strings in preferences category * Unrelated change --------- Co-authored-by: William Rai <[email protected]> Co-authored-by: williamrai <[email protected]> Co-authored-by: Dmitry Brant <[email protected]> Co-authored-by: Dmitry Brant <[email protected]>
1 parent 7f91b84 commit d87b6b9

39 files changed

+2184
-140
lines changed

app/src/extra/java/org/wikipedia/donate/GooglePayActivity.kt

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class GooglePayActivity : BaseActivity() {
4646
private var shouldWatchText = true
4747
private var typedManually = false
4848

49-
private val transactionFee get() = max(getAmountFloat(binding.donateAmountText.text.toString()) * GooglePayComponent.TRANSACTION_FEE_PERCENTAGE, viewModel.transactionFee)
49+
private val transactionFee get() = max(DonateUtil.getAmountFloat(binding.donateAmountText.text.toString()) * GooglePayComponent.TRANSACTION_FEE_PERCENTAGE, viewModel.transactionFee)
5050

5151
public override fun onCreate(savedInstanceState: Bundle?) {
5252
super.onCreate(savedInstanceState)
@@ -56,7 +56,7 @@ class GooglePayActivity : BaseActivity() {
5656
supportActionBar?.setDisplayHomeAsUpEnabled(true)
5757
title = ""
5858

59-
binding.donateAmountInput.prefixText = viewModel.currencySymbol
59+
binding.donateAmountInput.prefixText = DonateUtil.currencySymbol
6060

6161
paymentsClient = GooglePayComponent.createPaymentsClient(this)
6262

@@ -87,7 +87,7 @@ class GooglePayActivity : BaseActivity() {
8787
)
8888
CampaignCollection.addDonationResult(
8989
amount = viewModel.finalAmount,
90-
currency = viewModel.currencyCode,
90+
currency = DonateUtil.currencyCode,
9191
recurring = binding.checkBoxRecurring.isChecked
9292
)
9393
setResult(RESULT_OK)
@@ -109,7 +109,7 @@ class GooglePayActivity : BaseActivity() {
109109
return@setOnClickListener
110110
}
111111

112-
var totalAmount = getAmountFloat(amountText)
112+
var totalAmount = DonateUtil.getAmountFloat(amountText)
113113
if (binding.checkBoxTransactionFee.isChecked) {
114114
totalAmount += transactionFee
115115
}
@@ -135,7 +135,7 @@ class GooglePayActivity : BaseActivity() {
135135
}
136136
val buttonToHighlight = binding.amountPresetsContainer.children.firstOrNull { child ->
137137
if (child is MaterialButton) {
138-
val amount = getAmountFloat(text.toString())
138+
val amount = DonateUtil.getAmountFloat(text.toString())
139139
child.tag == amount
140140
} else {
141141
false
@@ -166,18 +166,20 @@ class GooglePayActivity : BaseActivity() {
166166
}
167167

168168
private fun validateInput(text: String): Boolean {
169-
val amount = getAmountFloat(text)
169+
val amount = DonateUtil.getAmountFloat(text)
170170
val min = viewModel.minimumAmount
171171
val max = viewModel.maximumAmount
172172

173173
updateTransactionFee()
174174

175175
if (amount <= 0f || amount < min) {
176-
binding.donateAmountInput.error = getString(R.string.donate_gpay_minimum_amount, viewModel.currencyFormat.format(min))
176+
binding.donateAmountInput.error = getString(R.string.donate_gpay_minimum_amount,
177+
DonateUtil.currencyFormat.format(min))
177178
DonorExperienceEvent.submit("submission_error", "gpay", "error_reason: min_amount")
178179
return false
179180
} else if (max > 0f && amount > max) {
180-
binding.donateAmountInput.error = getString(R.string.donate_gpay_maximum_amount, viewModel.currencyFormat.format(max))
181+
binding.donateAmountInput.error = getString(R.string.donate_gpay_maximum_amount,
182+
DonateUtil.currencyFormat.format(max))
181183
DonorExperienceEvent.submit("submission_error", "gpay", "error_reason: max_amount")
182184
return false
183185
} else {
@@ -219,23 +221,38 @@ class GooglePayActivity : BaseActivity() {
219221
.build())
220222

221223
val viewIds = mutableListOf<Int>()
222-
val presets = donationConfig.currencyAmountPresets[viewModel.currencyCode]
223-
presets?.forEach { amount ->
224+
val presets = donationConfig.currencyAmountPresets[DonateUtil.currencyCode]?.toMutableSet()
225+
if (viewModel.filledAmount > 0f) {
226+
presets?.add(viewModel.filledAmount)
227+
}
228+
var filledAmountButton: MaterialButton? = null
229+
presets?.sorted()?.forEach { amount ->
224230
val viewId = View.generateViewId()
225231
viewIds.add(viewId)
226232
val button = MaterialButton(this)
227-
button.text = viewModel.currencyFormat.format(amount)
233+
button.text = DonateUtil.currencyFormat.format(amount)
228234
button.id = viewId
229235
button.tag = amount
236+
if (amount == viewModel.filledAmount) {
237+
filledAmountButton = button
238+
}
230239
binding.amountPresetsContainer.addView(button)
240+
231241
button.setOnClickListener {
232242
setButtonHighlighted(it)
233243
setAmountText(it.tag as Float)
234244
DonorExperienceEvent.logAction("amount_selected", "gpay")
235245
}
236246
}
237247
binding.amountPresetsFlow.referencedIds = viewIds.toIntArray()
238-
setButtonHighlighted()
248+
setFilledAmountToText()
249+
setButtonHighlighted(filledAmountButton)
250+
}
251+
252+
private fun setFilledAmountToText() {
253+
if (viewModel.filledAmount > 0f) {
254+
setAmountText(viewModel.filledAmount)
255+
}
239256
}
240257

241258
private fun setButtonHighlighted(button: View? = null) {
@@ -254,17 +271,7 @@ class GooglePayActivity : BaseActivity() {
254271

255272
private fun updateTransactionFee() {
256273
binding.checkBoxTransactionFee.text = getString(R.string.donate_gpay_check_transaction_fee,
257-
viewModel.currencyFormat.format(transactionFee))
258-
}
259-
260-
private fun getAmountFloat(text: String): Float {
261-
var result: Float?
262-
result = text.toFloatOrNull()
263-
if (result == null) {
264-
val text2 = if (text.contains(".")) text.replace(".", ",") else text.replace(",", ".")
265-
result = text2.toFloatOrNull()
266-
}
267-
return result ?: 0f
274+
DonateUtil.currencyFormat.format(transactionFee))
268275
}
269276

270277
private fun setAmountText(amount: Float) {
@@ -306,11 +313,13 @@ class GooglePayActivity : BaseActivity() {
306313
companion object {
307314
private const val LOAD_PAYMENT_DATA_REQUEST_CODE = 42
308315
private const val CAMPAIGN_ID_APP_MENU = "appmenu"
316+
const val FILLED_AMOUNT = "filledAmount"
309317

310-
fun newIntent(context: Context, campaignId: String? = null, donateUrl: String? = null): Intent {
318+
fun newIntent(context: Context, campaignId: String? = null, donateUrl: String? = null, filledAmount: Float = 0f): Intent {
311319
return Intent(context, GooglePayActivity::class.java)
312320
.putExtra(DonateDialog.ARG_CAMPAIGN_ID, campaignId)
313321
.putExtra(DonateDialog.ARG_DONATE_URL, donateUrl)
322+
.putExtra(FILLED_AMOUNT, filledAmount)
314323
}
315324
}
316325
}

app/src/extra/java/org/wikipedia/donate/GooglePayComponent.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ internal object GooglePayComponent {
7878
return available
7979
}
8080

81-
fun getDonateActivityIntent(activity: Activity, campaignId: String? = null, donateUrl: String? = null): Intent {
82-
return GooglePayActivity.newIntent(activity, campaignId, donateUrl)
81+
fun getDonateActivityIntent(activity: Activity, campaignId: String? = null, donateUrl: String? = null, filledAmount: Float = 0f): Intent {
82+
return GooglePayActivity.newIntent(activity, campaignId, donateUrl, filledAmount)
8383
}
8484

8585
fun getPaymentDataRequestJson(

app/src/extra/java/org/wikipedia/donate/GooglePayViewModel.kt

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.wikipedia.donate
22

3+
import androidx.lifecycle.SavedStateHandle
34
import androidx.lifecycle.ViewModel
45
import androidx.lifecycle.viewModelScope
56
import com.google.android.gms.wallet.PaymentData
@@ -19,52 +20,45 @@ import org.wikipedia.dataclient.donate.CampaignCollection
1920
import org.wikipedia.dataclient.donate.DonationConfig
2021
import org.wikipedia.dataclient.donate.DonationConfigHelper
2122
import org.wikipedia.settings.Prefs
22-
import org.wikipedia.util.GeoUtil
2323
import org.wikipedia.util.Resource
2424
import org.wikipedia.util.log.L
25-
import java.text.NumberFormat
2625
import java.time.Instant
27-
import java.util.Locale
2826
import java.util.concurrent.TimeUnit
2927
import kotlin.math.abs
3028

31-
class GooglePayViewModel : ViewModel() {
29+
class GooglePayViewModel(savedStateHandle: SavedStateHandle) : ViewModel() {
30+
val filledAmount = savedStateHandle.get<Float>(GooglePayActivity.FILLED_AMOUNT) ?: 0f
3231
val uiState = MutableStateFlow(Resource<DonationConfig>())
3332
private var donationConfig: DonationConfig? = null
34-
private val currentCountryCode get() = GeoUtil.geoIPCountry.orEmpty()
3533

36-
val currencyFormat: NumberFormat = NumberFormat.getCurrencyInstance(Locale.Builder()
37-
.setLocale(Locale.getDefault()).setRegion(currentCountryCode).build())
38-
val currencyCode get() = currencyFormat.currency?.currencyCode ?: GooglePayComponent.CURRENCY_FALLBACK
39-
val currencySymbol get() = currencyFormat.currency?.symbol ?: "$"
40-
val decimalFormat = GooglePayComponent.getDecimalFormat(currencyCode)
34+
val decimalFormat = GooglePayComponent.getDecimalFormat(DonateUtil.currencyCode)
4135

42-
val transactionFee get() = donationConfig?.currencyTransactionFees?.get(currencyCode)
36+
val transactionFee get() = donationConfig?.currencyTransactionFees?.get(DonateUtil.currencyCode)
4337
?: donationConfig?.currencyTransactionFees?.get("default") ?: 0f
4438

45-
val minimumAmount get() = donationConfig?.currencyMinimumDonation?.get(currencyCode) ?: 0f
39+
val minimumAmount get() = donationConfig?.currencyMinimumDonation?.get(DonateUtil.currencyCode) ?: 0f
4640

4741
val maximumAmount: Float get() {
48-
var max = donationConfig?.currencyMaximumDonation?.get(currencyCode) ?: 0f
42+
var max = donationConfig?.currencyMaximumDonation?.get(DonateUtil.currencyCode) ?: 0f
4943
if (max == 0f) {
5044
val defaultMin = donationConfig?.currencyMinimumDonation?.get(GooglePayComponent.CURRENCY_FALLBACK) ?: 0f
5145
if (defaultMin > 0f) {
52-
max = (donationConfig?.currencyMinimumDonation?.get(currencyCode) ?: 0f) / defaultMin *
46+
max = (donationConfig?.currencyMinimumDonation?.get(DonateUtil.currencyCode) ?: 0f) / defaultMin *
5347
(donationConfig?.currencyMaximumDonation?.get(GooglePayComponent.CURRENCY_FALLBACK) ?: 0f)
5448
}
5549
}
5650
return max
5751
}
5852

59-
val emailOptInRequired get() = donationConfig?.countryCodeEmailOptInRequired.orEmpty().contains(currentCountryCode)
53+
val emailOptInRequired get() = donationConfig?.countryCodeEmailOptInRequired.orEmpty().contains(DonateUtil.currentCountryCode)
6054

6155
var disclaimerInformationSharing: String? = null
6256
var disclaimerMonthlyCancel: String? = null
6357

6458
var finalAmount = 0f
6559

6660
init {
67-
currencyFormat.minimumFractionDigits = 0
61+
DonateUtil.currencyFormat.minimumFractionDigits = 0
6862
load()
6963
}
7064

@@ -75,8 +69,7 @@ class GooglePayViewModel : ViewModel() {
7569
uiState.value = Resource.Loading()
7670

7771
val donationConfigCall = async { DonationConfigHelper.getConfig() }
78-
val donationMessagesCall = async { ServiceFactory.get(WikipediaApp.instance.wikiSite,
79-
DonationConfigHelper.DONATE_WIKI_URL, Service::class.java).getMessages(
72+
val donationMessagesCall = async { ServiceFactory[WikipediaApp.instance.wikiSite, DonationConfigHelper.DONATE_WIKI_URL, Service::class.java].getMessages(
8073
listOf(MSG_DISCLAIMER_INFORMATION_SHARING, MSG_DISCLAIMER_MONTHLY_CANCEL).joinToString("|"),
8174
null, WikipediaApp.instance.appOrSystemLanguageCode) }
8275

@@ -94,7 +87,7 @@ class GooglePayViewModel : ViewModel() {
9487

9588
val paymentMethodsCall = async {
9689
ServiceFactory.get(WikiSite(GooglePayComponent.PAYMENTS_API_URL))
97-
.getPaymentMethods(currentCountryCode)
90+
.getPaymentMethods(DonateUtil.currentCountryCode)
9891
}
9992
paymentMethodsCall.await().response?.let { response ->
10093
Prefs.paymentMethodsLastQueryTime = now
@@ -107,8 +100,8 @@ class GooglePayViewModel : ViewModel() {
107100

108101
if (Prefs.paymentMethodsMerchantId.isEmpty() ||
109102
Prefs.paymentMethodsGatewayId.isEmpty() ||
110-
!donationConfig!!.countryCodeGooglePayEnabled.contains(currentCountryCode) ||
111-
!donationConfig!!.currencyAmountPresets.containsKey(currencyCode)) {
103+
!donationConfig!!.countryCodeGooglePayEnabled.contains(DonateUtil.currentCountryCode) ||
104+
!donationConfig!!.currencyAmountPresets.containsKey(DonateUtil.currencyCode)) {
112105
uiState.value = NoPaymentMethod()
113106
} else {
114107
uiState.value = Resource.Success(donationConfig!!)
@@ -118,7 +111,7 @@ class GooglePayViewModel : ViewModel() {
118111

119112
fun getPaymentDataRequest(): PaymentDataRequest {
120113
return PaymentDataRequest.fromJson(GooglePayComponent.getPaymentDataRequestJson(finalAmount,
121-
currencyCode,
114+
DonateUtil.currencyCode,
122115
Prefs.paymentMethodsMerchantId,
123116
Prefs.paymentMethodsGatewayId
124117
).toString())
@@ -149,17 +142,17 @@ class GooglePayViewModel : ViewModel() {
149142

150143
// The backend expects the final amount in the canonical decimal format, instead of
151144
// any localized format, e.g. comma as decimal separator.
152-
val decimalFormatCanonical = GooglePayComponent.getDecimalFormat(currencyCode, true)
145+
val decimalFormatCanonical = GooglePayComponent.getDecimalFormat(DonateUtil.currencyCode, true)
153146

154147
val response = ServiceFactory.get(WikiSite(GooglePayComponent.PAYMENTS_API_URL))
155148
.submitPayment(
156149
decimalFormatCanonical.format(finalAmount),
157150
BuildConfig.VERSION_NAME,
158151
CampaignCollection.getFormattedCampaignId(campaignId),
159152
billingObj.optString("locality", ""),
160-
currentCountryCode,
161-
currencyCode,
162-
billingObj.optString("countryCode", currentCountryCode),
153+
DonateUtil.currentCountryCode,
154+
DonateUtil.currencyCode,
155+
billingObj.optString("countryCode", DonateUtil.currentCountryCode),
163156
paymentDataObj.optString("email", ""),
164157
billingObj.optString("name", ""),
165158
WikipediaApp.instance.appOrSystemLanguageCode,

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@
376376
android:name=".readinglist.recommended.RecommendedReadingListSettingsActivity"
377377
android:windowSoftInputMode="adjustResize" />
378378

379+
<activity
380+
android:name=".donate.donationreminder.DonationReminderActivity"
381+
android:windowSoftInputMode="adjustResize"/>
382+
379383
<provider
380384
android:name=".WikipediaFileProvider"
381385
android:authorities="${applicationId}.fileprovider"

app/src/main/java/org/wikipedia/analytics/eventplatform/DonorExperienceEvent.kt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package org.wikipedia.analytics.eventplatform
22

3+
import kotlinx.serialization.SerialName
4+
import kotlinx.serialization.Serializable
35
import org.wikipedia.WikipediaApp
46
import org.wikipedia.dataclient.donate.CampaignCollection
7+
import org.wikipedia.json.JsonUtil
58
import org.wikipedia.settings.Prefs
69

710
open class DonorExperienceEvent {
@@ -22,6 +25,37 @@ open class DonorExperienceEvent {
2225
)
2326
}
2427

28+
fun logDonationReminderAction(
29+
action: String,
30+
activeInterface: String,
31+
wikiId: String = WikipediaApp.instance.appOrSystemLanguageCode,
32+
defaultMilestone: Boolean? = null,
33+
campaignId: String? = null,
34+
articleFrequency: Int? = null,
35+
donateAmount: Float? = null,
36+
settingSelect: Boolean? = null,
37+
feedbackSelect: Int? = null,
38+
feedbackText: String? = null,
39+
userGroup: String? = null
40+
) {
41+
val actionData = DonationRemindersActionData(
42+
defaultMilestone = defaultMilestone,
43+
campaignId = campaignId?.let { CampaignCollection.getFormattedCampaignId(campaignId) },
44+
articleFrequency = articleFrequency,
45+
donateAmount = donateAmount,
46+
settingSelect = settingSelect,
47+
feedbackSelect = feedbackSelect,
48+
feedbackText = feedbackText,
49+
userGroup = userGroup
50+
)
51+
submit(
52+
action,
53+
activeInterface,
54+
JsonUtil.encodeToString(actionData).orEmpty(),
55+
wikiId
56+
)
57+
}
58+
2559
fun submit(
2660
action: String,
2761
activeInterface: String,
@@ -40,4 +74,16 @@ open class DonorExperienceEvent {
4074
)
4175
}
4276
}
77+
78+
@Serializable
79+
class DonationRemindersActionData(
80+
@SerialName("milestone_default") val defaultMilestone: Boolean? = null,
81+
@SerialName("campaign_id") val campaignId: String? = null,
82+
@SerialName("read_freq") val articleFrequency: Int? = null,
83+
@SerialName("donate_amount") val donateAmount: Float? = null,
84+
@SerialName("setting_select") val settingSelect: Boolean? = null,
85+
@SerialName("feedback_select") val feedbackSelect: Int? = null,
86+
@SerialName("feedback_text") val feedbackText: String? = null,
87+
@SerialName("user_group") val userGroup: String? = null
88+
)
4389
}

app/src/main/java/org/wikipedia/bridge/CommunicationBridge.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import android.annotation.SuppressLint
44
import android.os.Handler
55
import android.os.Looper
66
import android.os.Message
7-
import android.webkit.*
7+
import android.webkit.ConsoleMessage
8+
import android.webkit.JavascriptInterface
9+
import android.webkit.ValueCallback
10+
import android.webkit.WebChromeClient
11+
import android.webkit.WebView
12+
import android.webkit.WebViewClient
813
import kotlinx.serialization.Serializable
914
import kotlinx.serialization.json.JsonObject
1015
import org.wikipedia.bridge.JavaScriptActionHandler.setUp
@@ -40,6 +45,7 @@ class CommunicationBridge constructor(private val communicationBridgeListener: C
4045
val model: PageViewModel
4146
val isPreview: Boolean
4247
val toolbarMargin: Int
48+
val messageCardHeight: Int
4349
}
4450

4551
init {
@@ -175,7 +181,7 @@ class CommunicationBridge constructor(private val communicationBridgeListener: C
175181
val setupSettings: String
176182
get() = setUp(communicationBridgeListener.webView.context,
177183
communicationBridgeListener.model.title!!, communicationBridgeListener.isPreview,
178-
communicationBridgeListener.toolbarMargin)
184+
communicationBridgeListener.toolbarMargin, communicationBridgeListener.messageCardHeight)
179185
}
180186

181187
@Serializable

0 commit comments

Comments
 (0)