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..f422ed0973d 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), "https://wikimediafoundation.org/wikipedia-year-in-review-2024/"), + 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..7947b3bf605 --- /dev/null +++ b/app/src/main/java/org/wikipedia/feed/onboarding/YIROnboardingCard.kt @@ -0,0 +1,28 @@ +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 +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() && + WikipediaApp.instance.appOrSystemLanguageCode == "en" && + LocalDate.now() <= LocalDate.of(2025, 2, 28) && + !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") +} diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml index bd9a2826bbe..6742a171c30 100644 --- a/app/src/main/res/values/preference_keys.xml +++ b/app/src/main/res/values/preference_keys.xml @@ -70,6 +70,7 @@ feedCardsLangSupported feedCardsLangDisabled feedCustomizeOnboardingCardEnabled + feedYirOnboardingCardEnabled addArticles addReadingLists deleteReadingLists 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.]]>
+ 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"}]"/> + +