From ea9e0ddc5c87064137b80d6dd07c578a25dd9bd6 Mon Sep 17 00:00:00 2001 From: Dmitry Brant Date: Fri, 13 Dec 2024 11:30:19 -0500 Subject: [PATCH 1/7] Year-in-review Feed card. --- .../eventplatform/BreadCrumbLogEvent.kt | 15 ++++++++---- .../feed/announcement/Announcement.kt | 1 + .../feed/announcement/AnnouncementCard.kt | 8 +++++++ .../feed/announcement/AnnouncementCardView.kt | 23 ++++++++++++++++++- .../java/org/wikipedia/feed/model/CardType.kt | 4 +--- .../feed/onboarding/OnboardingClient.kt | 16 ++++++++++++- .../feed/onboarding/YIROnboardingCard.kt | 21 +++++++++++++++++ app/src/main/res/values/preference_keys.xml | 1 + app/src/main/res/values/strings.xml | 4 ++++ 9 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt diff --git a/app/src/main/java/org/wikipedia/analytics/eventplatform/BreadCrumbLogEvent.kt b/app/src/main/java/org/wikipedia/analytics/eventplatform/BreadCrumbLogEvent.kt index 7dc921e6800..3aa57d7244d 100644 --- a/app/src/main/java/org/wikipedia/analytics/eventplatform/BreadCrumbLogEvent.kt +++ b/app/src/main/java/org/wikipedia/analytics/eventplatform/BreadCrumbLogEvent.kt @@ -4,7 +4,7 @@ import android.app.Activity import android.content.Context import android.view.MenuItem import android.view.View -import android.widget.Checkable +import android.widget.CompoundButton import android.widget.TextView import androidx.fragment.app.Fragment import kotlinx.serialization.SerialName @@ -37,11 +37,11 @@ class BreadCrumbLogEvent( if (context is SettingsActivity) { return } - val viewReadableName = BreadCrumbViewUtil.getReadableNameForView(view) - val str = "$viewReadableName." + when (view) { - is Checkable -> if (!view.isChecked) "on" else "off" - else -> "click" + var viewReadableName = BreadCrumbViewUtil.getReadableNameForView(view) + if (view.tag is String && (view.tag as String).isNotEmpty()) { + viewReadableName += "." + view.tag as String } + val str = "$viewReadableName." + if (view is CompoundButton) { if (!view.isChecked) "on" else "off" } else "click" EventPlatformClient.submit(BreadCrumbLogEvent(BreadCrumbViewUtil.getReadableScreenName(context), str)) } @@ -61,6 +61,11 @@ class BreadCrumbLogEvent( "show" + invokeSource?.let { ".from." + it.value }.orEmpty())) } + fun logImpression(context: Context, name: String) { + EventPlatformClient.submit(BreadCrumbLogEvent(BreadCrumbViewUtil.getReadableScreenName(context), + "impression.$name")) + } + fun logBackPress(context: Context) { EventPlatformClient.submit(BreadCrumbLogEvent(BreadCrumbViewUtil.getReadableScreenName(context), "back")) } diff --git a/app/src/main/java/org/wikipedia/feed/announcement/Announcement.kt b/app/src/main/java/org/wikipedia/feed/announcement/Announcement.kt index 66c3cabe530..665cef4db7c 100644 --- a/app/src/main/java/org/wikipedia/feed/announcement/Announcement.kt +++ b/app/src/main/java/org/wikipedia/feed/announcement/Announcement.kt @@ -26,6 +26,7 @@ class Announcement(val id: String = "", // for iOS versions, so these need to be serialized manually. @SerialName("min_version") private val minVersion: JsonElement? = null, @SerialName("max_version") private val maxVersion: JsonElement? = null, + val imageAspectRatio: Double? = null, val border: Boolean? = null, val beta: Boolean? = null, val placement: String = PLACEMENT_FEED, diff --git a/app/src/main/java/org/wikipedia/feed/announcement/AnnouncementCard.kt b/app/src/main/java/org/wikipedia/feed/announcement/AnnouncementCard.kt index aa299773f62..b50f0abe73b 100644 --- a/app/src/main/java/org/wikipedia/feed/announcement/AnnouncementCard.kt +++ b/app/src/main/java/org/wikipedia/feed/announcement/AnnouncementCard.kt @@ -63,4 +63,12 @@ open class AnnouncementCard(private val announcement: Announcement) : Card() { fun hasBorder(): Boolean { return announcement.border == true } + + fun getId(): String { + return announcement.id + } + + fun aspectRatio(): Double { + return announcement.imageAspectRatio ?: 0.0 + } } diff --git a/app/src/main/java/org/wikipedia/feed/announcement/AnnouncementCardView.kt b/app/src/main/java/org/wikipedia/feed/announcement/AnnouncementCardView.kt index 6e26360114f..07613c03865 100644 --- a/app/src/main/java/org/wikipedia/feed/announcement/AnnouncementCardView.kt +++ b/app/src/main/java/org/wikipedia/feed/announcement/AnnouncementCardView.kt @@ -4,12 +4,15 @@ import android.content.Context import android.net.Uri import android.view.LayoutInflater import android.view.ViewGroup +import android.widget.ImageView import androidx.core.content.ContextCompat import androidx.core.text.method.LinkMovementMethodCompat import androidx.core.view.updateLayoutParams import org.wikipedia.R +import org.wikipedia.analytics.eventplatform.BreadCrumbLogEvent import org.wikipedia.databinding.ViewCardAnnouncementBinding import org.wikipedia.feed.model.Card +import org.wikipedia.feed.onboarding.YIROnboardingCard import org.wikipedia.feed.view.DefaultFeedCardView import org.wikipedia.util.DimenUtil import org.wikipedia.util.StringUtil @@ -44,18 +47,32 @@ class AnnouncementCardView(context: Context) : DefaultFeedCardView { - // This is not actually used, since this type of card will not be shown in the feed. return AnnouncementCardView(ctx) } }, diff --git a/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingClient.kt b/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingClient.kt index 86ab5193ab0..f259c0834da 100644 --- a/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingClient.kt +++ b/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingClient.kt @@ -17,7 +17,7 @@ class OnboardingClient : FeedClient { private fun getCards(context: Context): List { val cards = ArrayList() - val card: OnboardingCard + var card: OnboardingCard // NOTE: When adding new onboarding cards, please add them to the *beginning* of the list. @@ -41,6 +41,20 @@ class OnboardingClient : FeedClient { if (card.shouldShow() && Prefs.exploreFeedVisitCount <= SHOW_CUSTOMIZE_ONBOARDING_CARD_COUNT) { cards.add(card) } + + card = YIROnboardingCard( + Announcement(id = "yir2024Card", + text = context.getString(R.string.year_in_review_text), + imageUrl = "https://upload.wikimedia.org/wikipedia/commons/2/21/WYiR_Block_1.gif", + action = Announcement.Action(context.getString(R.string.year_in_review_action_positive), "TODO"), + negativeText = context.getString(R.string.view_announcement_card_negative_action), + imageAspectRatio = 4.0 / 3.0 + ) + ) + if (card.shouldShow()) { + cards.add(card) + } + return cards } diff --git a/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt b/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt new file mode 100644 index 00000000000..4a2e40fb9e4 --- /dev/null +++ b/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt @@ -0,0 +1,21 @@ +package org.wikipedia.feed.onboarding + +import org.wikipedia.R +import org.wikipedia.feed.announcement.Announcement +import org.wikipedia.feed.model.CardType +import java.time.LocalDate + +class YIROnboardingCard(announcement: Announcement) : OnboardingCard(announcement) { + + override fun type(): CardType { + return CardType.YEAR_IN_REVIEW_ANNOUNCEMENT + } + + override fun shouldShow(): Boolean { + return super.shouldShow() && LocalDate.now() <= LocalDate.of(2025, 1, 31) + } + + override fun prefKey(): Int { + return R.string.preference_key_feed_yir_onboarding_card_enabled + } +} diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml index f7bf088f428..9d3bb39ff88 100644 --- a/app/src/main/res/values/preference_keys.xml +++ b/app/src/main/res/values/preference_keys.xml @@ -71,6 +71,7 @@ feedCardsLangSupported feedCardsLangDisabled feedCustomizeOnboardingCardEnabled + feedYirOnboardingCardEnabled addArticles addReadingLists deleteReadingLists diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0b2cfba9c0c..ce2fed70797 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1848,4 +1848,8 @@ Submit Additional feedback Feedback submitted. Thank you! + + Take me there + Wikipedia 2024 Year in Review

Wikipedia is the largest knowledge resource ever assembled in the history of the world, and it’s freely available to everyone everywhere. Here’s a review of 2024 through the lens of Wikipedia.]]>
+ From 51f7c471e020f88488ac9a90505be2ad8e4b87bd Mon Sep 17 00:00:00 2001 From: Dmitry Brant Date: Mon, 16 Dec 2024 10:13:23 -0500 Subject: [PATCH 2/7] qq. --- app/src/main/res/values-qq/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/res/values-qq/strings.xml b/app/src/main/res/values-qq/strings.xml index 76cf48d6ef2..cf63c373680 100644 --- a/app/src/main/res/values-qq/strings.xml +++ b/app/src/main/res/values-qq/strings.xml @@ -1762,4 +1762,6 @@ Positive action button text for the survey dialog Hint label for the survey dialog input field. Text for the snackbar message the feedback form in the survey dialog that indicates the feedback has been submitted. + Button label that takes the user to the new Year-in-review feature. + Text of a dialog box that tells the user about the new Year-in-review feature. From 7feffa89b2050ad1d45ec50dc52615b6fd3467d0 Mon Sep 17 00:00:00 2001 From: Dmitry Brant Date: Tue, 17 Dec 2024 08:07:33 -0500 Subject: [PATCH 3/7] Add url. --- .../main/java/org/wikipedia/feed/onboarding/OnboardingClient.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingClient.kt b/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingClient.kt index f259c0834da..f422ed0973d 100644 --- a/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingClient.kt +++ b/app/src/main/java/org/wikipedia/feed/onboarding/OnboardingClient.kt @@ -46,7 +46,7 @@ class OnboardingClient : FeedClient { Announcement(id = "yir2024Card", text = context.getString(R.string.year_in_review_text), imageUrl = "https://upload.wikimedia.org/wikipedia/commons/2/21/WYiR_Block_1.gif", - action = Announcement.Action(context.getString(R.string.year_in_review_action_positive), "TODO"), + action = Announcement.Action(context.getString(R.string.year_in_review_action_positive), "https://wikimediafoundation.org/wikipedia-year-in-review-2024/"), negativeText = context.getString(R.string.view_announcement_card_negative_action), imageAspectRatio = 4.0 / 3.0 ) From 7daf9ac4fbe1928ba35bb99392bbbb963c755e19 Mon Sep 17 00:00:00 2001 From: Dmitry Brant Date: Mon, 6 Jan 2025 09:47:40 -0500 Subject: [PATCH 4/7] Add list of excluded countries. --- .../org/wikipedia/feed/onboarding/YIROnboardingCard.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt b/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt index 4a2e40fb9e4..312185f529e 100644 --- a/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt +++ b/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt @@ -3,6 +3,7 @@ package org.wikipedia.feed.onboarding import org.wikipedia.R import org.wikipedia.feed.announcement.Announcement import org.wikipedia.feed.model.CardType +import org.wikipedia.util.GeoUtil import java.time.LocalDate class YIROnboardingCard(announcement: Announcement) : OnboardingCard(announcement) { @@ -12,10 +13,14 @@ class YIROnboardingCard(announcement: Announcement) : OnboardingCard(announcemen } override fun shouldShow(): Boolean { - return super.shouldShow() && LocalDate.now() <= LocalDate.of(2025, 1, 31) + return super.shouldShow() && + LocalDate.now() <= LocalDate.of(2025, 1, 31) && + !excludedCountries.contains(GeoUtil.geoIPCountry) } override fun prefKey(): Int { return R.string.preference_key_feed_yir_onboarding_card_enabled } + + private val excludedCountries = setOf("RU", "IR", "CN", "HK", "MO", "SA", "CU", "MM", "BY", "EG", "PS", "GN", "PK", "KH", "VN", "SD", "AE", "SY", "JO", "VE", "AF") } From 9322e5b79cf61c23ff3c0bf8565ca027978ce65f Mon Sep 17 00:00:00 2001 From: Dmitry Brant Date: Wed, 15 Jan 2025 13:53:10 -0500 Subject: [PATCH 5/7] Extend date. --- .../java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt b/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt index 312185f529e..496ddd3bb42 100644 --- a/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt +++ b/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt @@ -14,7 +14,7 @@ class YIROnboardingCard(announcement: Announcement) : OnboardingCard(announcemen override fun shouldShow(): Boolean { return super.shouldShow() && - LocalDate.now() <= LocalDate.of(2025, 1, 31) && + LocalDate.now() <= LocalDate.of(2025, 2, 31) && !excludedCountries.contains(GeoUtil.geoIPCountry) } From 7bffc28f504baba1da60bdb0f929987684c0bbed Mon Sep 17 00:00:00 2001 From: Dmitry Brant Date: Wed, 15 Jan 2025 14:16:25 -0500 Subject: [PATCH 6/7] Restrict to en. --- .../java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt | 4 +++- app/src/main/res/xml/developer_preferences.xml | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt b/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt index 496ddd3bb42..7947b3bf605 100644 --- a/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt +++ b/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt @@ -1,6 +1,7 @@ package org.wikipedia.feed.onboarding import org.wikipedia.R +import org.wikipedia.WikipediaApp import org.wikipedia.feed.announcement.Announcement import org.wikipedia.feed.model.CardType import org.wikipedia.util.GeoUtil @@ -14,7 +15,8 @@ class YIROnboardingCard(announcement: Announcement) : OnboardingCard(announcemen override fun shouldShow(): Boolean { return super.shouldShow() && - LocalDate.now() <= LocalDate.of(2025, 2, 31) && + WikipediaApp.instance.appOrSystemLanguageCode == "en" && + LocalDate.now() <= LocalDate.of(2025, 2, 28) && !excludedCountries.contains(GeoUtil.geoIPCountry) } diff --git a/app/src/main/res/xml/developer_preferences.xml b/app/src/main/res/xml/developer_preferences.xml index 916dcd1b2c1..0228e26b6c1 100644 --- a/app/src/main/res/xml/developer_preferences.xml +++ b/app/src/main/res/xml/developer_preferences.xml @@ -448,6 +448,10 @@ android:title="Donation results" android:dialogMessage="Example: [{"dateTime":"2024-10-22T00:00:00.000"}]"/> + + From 017239b515c8f1cfd6fab4955faa7291f3bee3f6 Mon Sep 17 00:00:00 2001 From: Dmitry Brant Date: Thu, 16 Jan 2025 10:42:30 -0500 Subject: [PATCH 7/7] Make YiR strings not translatable. --- app/src/main/res/values-qq/strings.xml | 2 -- app/src/main/res/values/strings.xml | 3 --- app/src/main/res/values/strings_no_translate.xml | 3 +++ 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/src/main/res/values-qq/strings.xml b/app/src/main/res/values-qq/strings.xml index 742a70611db..b7ca4ac69d9 100644 --- a/app/src/main/res/values-qq/strings.xml +++ b/app/src/main/res/values-qq/strings.xml @@ -1706,8 +1706,6 @@ Positive action button text for the survey dialog Hint label for the survey dialog input field. Text for the snackbar message the feedback form in the survey dialog that indicates the feedback has been submitted. - Button label that takes the user to the new Year-in-review feature. - Text of a dialog box that tells the user about the new Year-in-review feature. Title text shown at the top of the confirmation dialog when deleting donation history Explanatory message shown in the confirmation dialog that clarifies the scope of deletion - that it only affects donations recorded on the current device Label for the confirmation button in the deletion dialog that executes the deletion action diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3c70f40319f..f56caa8e3c1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1793,7 +1793,4 @@ Additional feedback Feedback submitted. Thank you! - Take me there - Wikipedia 2024 Year in Review

Wikipedia is the largest knowledge resource ever assembled in the history of the world, and it’s freely available to everyone everywhere. Here’s a review of 2024 through the lens of Wikipedia.]]>
- diff --git a/app/src/main/res/values/strings_no_translate.xml b/app/src/main/res/values/strings_no_translate.xml index 8573f35e7a3..3baa5fa13f9 100644 --- a/app/src/main/res/values/strings_no_translate.xml +++ b/app/src/main/res/values/strings_no_translate.xml @@ -88,4 +88,7 @@ {{{diffLink}}} [[%1$s|%2$s]] + Take me there + Wikipedia 2024 Year in Review

Wikipedia is the largest knowledge resource ever assembled in the history of the world, and it’s freely available to everyone everywhere. Here’s a review of 2024 through the lens of Wikipedia.]]>
+