From ea9e0ddc5c87064137b80d6dd07c578a25dd9bd6 Mon Sep 17 00:00:00 2001 From: Dmitry Brant Date: Fri, 13 Dec 2024 11:30:19 -0500 Subject: [PATCH 01/12] 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 02/12] 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 03/12] 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 04/12] 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 05/12] 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 06/12] 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 07/12] 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.]]>
+ From 1225d5a743eac0605d30a3562d2cc57720cc8400 Mon Sep 17 00:00:00 2001 From: Cooltey Feng Date: Fri, 17 Jan 2025 05:28:58 -0800 Subject: [PATCH 08/12] Follow up: automatically clean up hidden cards when enable the YiR card (#5237) --- .../settings/DeveloperSettingsPreferenceLoader.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/org/wikipedia/settings/DeveloperSettingsPreferenceLoader.kt b/app/src/main/java/org/wikipedia/settings/DeveloperSettingsPreferenceLoader.kt index df7cf876199..2870d9cb724 100644 --- a/app/src/main/java/org/wikipedia/settings/DeveloperSettingsPreferenceLoader.kt +++ b/app/src/main/java/org/wikipedia/settings/DeveloperSettingsPreferenceLoader.kt @@ -154,6 +154,13 @@ internal class DeveloperSettingsPreferenceLoader(fragment: PreferenceFragmentCom UserContributionEvent.logOpen() true } + findPreference(R.string.preference_key_feed_yir_onboarding_card_enabled).onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _: Preference, isEnabled: Any? -> + if (isEnabled is Boolean && isEnabled) { + Prefs.hiddenCards = emptySet() + Toast.makeText(activity, "Please relaunch the app.", Toast.LENGTH_SHORT).show() + } + true + } } private fun setUpMediaWikiSettings() { From 789041b0e254376fa7e260355bf3ff688e7313f4 Mon Sep 17 00:00:00 2001 From: Dmitry Brant Date: Fri, 17 Jan 2025 08:39:51 -0500 Subject: [PATCH 09/12] Fix a couple of issues when invoking Gallery from Suggested Edits. --- app/src/main/java/org/wikipedia/dataclient/RestService.kt | 2 +- .../feed/suggestededits/SuggestedEditsCardItemFragment.kt | 3 +-- app/src/main/java/org/wikipedia/gallery/GalleryActivity.kt | 2 +- .../main/java/org/wikipedia/gallery/GalleryViewModel.kt | 2 +- app/src/main/java/org/wikipedia/page/PageActivity.kt | 2 +- .../org/wikipedia/page/linkpreview/LinkPreviewDialog.kt | 7 ++----- .../org/wikipedia/page/linkpreview/LinkPreviewViewModel.kt | 4 ++-- 7 files changed, 9 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/org/wikipedia/dataclient/RestService.kt b/app/src/main/java/org/wikipedia/dataclient/RestService.kt index c51e4bb6186..0a692a2c8a6 100644 --- a/app/src/main/java/org/wikipedia/dataclient/RestService.kt +++ b/app/src/main/java/org/wikipedia/dataclient/RestService.kt @@ -59,7 +59,7 @@ interface RestService { @GET("page/media-list/{title}/{revision}") suspend fun getMediaList( @Path("title") title: String, - @Path("revision") revision: Long + @Path("revision") revision: Long? = null ): MediaList @GET("page/media-list/{title}/{revision}") diff --git a/app/src/main/java/org/wikipedia/feed/suggestededits/SuggestedEditsCardItemFragment.kt b/app/src/main/java/org/wikipedia/feed/suggestededits/SuggestedEditsCardItemFragment.kt index 0fa2503290d..4ad015dff1f 100644 --- a/app/src/main/java/org/wikipedia/feed/suggestededits/SuggestedEditsCardItemFragment.kt +++ b/app/src/main/java/org/wikipedia/feed/suggestededits/SuggestedEditsCardItemFragment.kt @@ -32,7 +32,6 @@ import org.wikipedia.descriptions.DescriptionEditActivity.Action.TRANSLATE_CAPTI import org.wikipedia.descriptions.DescriptionEditActivity.Action.TRANSLATE_DESCRIPTION import org.wikipedia.descriptions.DescriptionEditReviewView.Companion.ARTICLE_EXTRACT_MAX_LINE_WITHOUT_IMAGE import org.wikipedia.descriptions.DescriptionEditReviewView.Companion.ARTICLE_EXTRACT_MAX_LINE_WITH_IMAGE -import org.wikipedia.gallery.GalleryActivity import org.wikipedia.history.HistoryEntry import org.wikipedia.page.PageActivity import org.wikipedia.page.PageTitle @@ -93,7 +92,7 @@ class SuggestedEditsCardItemFragment : Fragment() { } val pageTitle = viewModel.sourceSummaryForEdit!!.pageTitle if (viewModel.cardActionType === ADD_CAPTION || viewModel.cardActionType === TRANSLATE_CAPTION) { - it.context.startActivity(GalleryActivity.newIntent(it.context, pageTitle, pageTitle.prefixedText, pageTitle.wikiSite, 0)) + it.context.startActivity(FilePageActivity.newIntent(it.context, pageTitle)) } else { it.context.startActivity(PageActivity.newIntentForNewTab(it.context, HistoryEntry(pageTitle, HistoryEntry.SOURCE_SUGGESTED_EDITS), pageTitle)) } diff --git a/app/src/main/java/org/wikipedia/gallery/GalleryActivity.kt b/app/src/main/java/org/wikipedia/gallery/GalleryActivity.kt index 772621589ff..7f3d763d5bd 100644 --- a/app/src/main/java/org/wikipedia/gallery/GalleryActivity.kt +++ b/app/src/main/java/org/wikipedia/gallery/GalleryActivity.kt @@ -638,7 +638,7 @@ class GalleryActivity : BaseActivity(), LinkPreviewDialog.LoadPageCallback, Gall const val EXTRA_FILENAME = "filename" const val EXTRA_REVISION = "revision" - fun newIntent(context: Context, pageTitle: PageTitle?, filename: String, wiki: WikiSite, revision: Long): Intent { + fun newIntent(context: Context, pageTitle: PageTitle?, filename: String, wiki: WikiSite, revision: Long? = null): Intent { return Intent(context, GalleryActivity::class.java) .putExtra(Constants.ARG_WIKISITE, wiki) .putExtra(Constants.ARG_TITLE, pageTitle) diff --git a/app/src/main/java/org/wikipedia/gallery/GalleryViewModel.kt b/app/src/main/java/org/wikipedia/gallery/GalleryViewModel.kt index c6c0db77f64..b074ba778ea 100644 --- a/app/src/main/java/org/wikipedia/gallery/GalleryViewModel.kt +++ b/app/src/main/java/org/wikipedia/gallery/GalleryViewModel.kt @@ -19,7 +19,7 @@ import org.wikipedia.util.Resource class GalleryViewModel(savedStateHandle: SavedStateHandle) : ViewModel() { val pageTitle = savedStateHandle.get(Constants.ARG_TITLE) val wikiSite = savedStateHandle.get(Constants.ARG_WIKISITE)!! - val revision = savedStateHandle[GalleryActivity.EXTRA_REVISION] ?: 0L + val revision = savedStateHandle[GalleryActivity.EXTRA_REVISION] as Long? var initialFilename = savedStateHandle.get(GalleryActivity.EXTRA_FILENAME) private val _uiState = MutableStateFlow(Resource()) diff --git a/app/src/main/java/org/wikipedia/page/PageActivity.kt b/app/src/main/java/org/wikipedia/page/PageActivity.kt index ba5001bcaf5..c242aed702c 100644 --- a/app/src/main/java/org/wikipedia/page/PageActivity.kt +++ b/app/src/main/java/org/wikipedia/page/PageActivity.kt @@ -172,7 +172,7 @@ class PageActivity : BaseActivity(), PageFragment.Callback, LinkPreviewDialog.Lo startActivity(FilePageActivity.newIntent(this, imageTitle)) } else if (action === DescriptionEditActivity.Action.ADD_CAPTION || action === DescriptionEditActivity.Action.TRANSLATE_CAPTION) { pageFragment.title?.let { pageTitle -> - startActivity(GalleryActivity.newIntent(this, pageTitle, imageTitle.prefixedText, wikiSite, 0)) + startActivity(GalleryActivity.newIntent(this, pageTitle, imageTitle.prefixedText, wikiSite)) } } } diff --git a/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.kt b/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.kt index 51dc3245f26..c5ff63ab71e 100644 --- a/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.kt +++ b/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewDialog.kt @@ -78,7 +78,6 @@ class LinkPreviewDialog : ExtendedBottomSheetDialogFragment(), LinkPreviewErrorV private var linkPreviewInteraction: ArticleLinkPreviewInteraction? = null private var overlayView: LinkPreviewOverlayView? = null private var navigateSuccess = false - private var revision: Long = 0 private val viewModel: LinkPreviewViewModel by viewModels() private val menuListener = PopupMenu.OnMenuItemClickListener { item -> @@ -142,7 +141,7 @@ class LinkPreviewDialog : ExtendedBottomSheetDialogFragment(), LinkPreviewErrorV options = ActivityOptionsCompat.makeSceneTransitionAnimation(requireActivity(), view, requireActivity().getString(R.string.transition_page_gallery)) } requestGalleryLauncher.launch(GalleryActivity.newIntent(requireContext(), viewModel.pageTitle, - imageName, viewModel.pageTitle.wikiSite, revision), options) + imageName, viewModel.pageTitle.wikiSite), options) } private val requestGalleryLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { @@ -238,8 +237,6 @@ class LinkPreviewDialog : ExtendedBottomSheetDialogFragment(), LinkPreviewErrorV ) linkPreviewInteraction?.logLinkClick() - revision = summary.revision - binding.linkPreviewTitle.text = StringUtil.fromHtml(summary.displayTitle) if (viewModel.fromPlaces) { viewModel.location?.let { startLocation -> @@ -374,7 +371,7 @@ class LinkPreviewDialog : ExtendedBottomSheetDialogFragment(), LinkPreviewErrorV } private fun showPreview(contents: LinkPreviewContents) { - viewModel.loadGallery(revision) + viewModel.loadGallery() setPreviewContents(contents) } diff --git a/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewViewModel.kt b/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewViewModel.kt index 80070cf9b59..28fd591ee43 100644 --- a/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewViewModel.kt +++ b/app/src/main/java/org/wikipedia/page/linkpreview/LinkPreviewViewModel.kt @@ -76,13 +76,13 @@ class LinkPreviewViewModel(savedStateHandle: SavedStateHandle) : ViewModel() { } } - fun loadGallery(revision: Long) { + fun loadGallery() { if (Prefs.isImageDownloadEnabled && !pageTitle.isFilePage) { viewModelScope.launch(CoroutineExceptionHandler { _, throwable -> L.w("Failed to fetch gallery collection.", throwable) }) { val mediaList = ServiceFactory.getRest(pageTitle.wikiSite) - .getMediaList(pageTitle.prefixedText, revision) + .getMediaList(pageTitle.prefixedText) val maxImages = 10 val items = mediaList.getItems("image", "video").asReversed() val titleList = From bf51225d00dcd1c878aef45eeb7a33062cb1975b Mon Sep 17 00:00:00 2001 From: Dmitry Brant Date: Fri, 17 Jan 2025 08:51:38 -0500 Subject: [PATCH 10/12] Split off overloads. --- app/src/main/java/org/wikipedia/dataclient/RestService.kt | 7 ++++++- .../main/java/org/wikipedia/gallery/GalleryViewModel.kt | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/wikipedia/dataclient/RestService.kt b/app/src/main/java/org/wikipedia/dataclient/RestService.kt index 0a692a2c8a6..4ff38a0fcff 100644 --- a/app/src/main/java/org/wikipedia/dataclient/RestService.kt +++ b/app/src/main/java/org/wikipedia/dataclient/RestService.kt @@ -56,10 +56,15 @@ interface RestService { @Headers("Accept: $ACCEPT_HEADER_SUMMARY") suspend fun getRandomSummary(): PageSummary + @GET("page/media-list/{title}") + suspend fun getMediaList( + @Path("title") title: String + ): MediaList + @GET("page/media-list/{title}/{revision}") suspend fun getMediaList( @Path("title") title: String, - @Path("revision") revision: Long? = null + @Path("revision") revision: Long ): MediaList @GET("page/media-list/{title}/{revision}") diff --git a/app/src/main/java/org/wikipedia/gallery/GalleryViewModel.kt b/app/src/main/java/org/wikipedia/gallery/GalleryViewModel.kt index b074ba778ea..c2a3b56b77a 100644 --- a/app/src/main/java/org/wikipedia/gallery/GalleryViewModel.kt +++ b/app/src/main/java/org/wikipedia/gallery/GalleryViewModel.kt @@ -34,7 +34,7 @@ class GalleryViewModel(savedStateHandle: SavedStateHandle) : ViewModel() { _uiState.value = Resource.Error(throwable) }) { pageTitle?.let { - val response = ServiceFactory.getRest(it.wikiSite).getMediaList(it.prefixedText, revision) + val response = if (revision != null) ServiceFactory.getRest(it.wikiSite).getMediaList(it.prefixedText, revision) else ServiceFactory.getRest(it.wikiSite).getMediaList(it.prefixedText) _uiState.value = Resource.Success(response) } } From 874410ee4e348a37ca75b495300e8c645b524c97 Mon Sep 17 00:00:00 2001 From: Dmitry Brant Date: Fri, 17 Jan 2025 09:55:18 -0500 Subject: [PATCH 11/12] Streamline calls to PageSummary and MediaList. --- .../org/wikipedia/dataclient/RestService.kt | 32 ++++++------ .../descriptions/DescriptionEditViewModel.kt | 6 +-- .../wikipedia/edit/EditSectionViewModel.kt | 4 +- .../wikipedia/page/PageFragmentLoadState.kt | 4 +- .../savedpages/SavedPageSyncService.kt | 52 ++++++++----------- ...uggestedEditsImageRecsFragmentViewModel.kt | 2 +- .../provider/EditingSuggestionsProvider.kt | 6 +-- .../main/java/org/wikipedia/util/L10nUtil.kt | 2 +- .../widgets/WidgetFeaturedPageWorker.kt | 4 +- 9 files changed, 50 insertions(+), 62 deletions(-) diff --git a/app/src/main/java/org/wikipedia/dataclient/RestService.kt b/app/src/main/java/org/wikipedia/dataclient/RestService.kt index 4ff38a0fcff..14a39f80284 100644 --- a/app/src/main/java/org/wikipedia/dataclient/RestService.kt +++ b/app/src/main/java/org/wikipedia/dataclient/RestService.kt @@ -32,21 +32,25 @@ interface RestService { @Headers("x-analytics: preview=1", "Accept: $ACCEPT_HEADER_SUMMARY") @GET("page/summary/{title}") - suspend fun getSummaryResponse( + suspend fun getPageSummary( @Path("title") title: String, @Header("Referer") referrerUrl: String? = null, @Header("Cache-Control") cacheControl: String? = null, @Header(OfflineCacheInterceptor.SAVE_HEADER) saveHeader: String? = null, @Header(OfflineCacheInterceptor.LANG_HEADER) langHeader: String? = null, @Header(OfflineCacheInterceptor.TITLE_HEADER) titleHeader: String? = null - ): Response + ): PageSummary @Headers("x-analytics: preview=1", "Accept: $ACCEPT_HEADER_SUMMARY") @GET("page/summary/{title}") - suspend fun getPageSummary( - @Header("Referer") referrerUrl: String?, - @Path("title") title: String - ): PageSummary + suspend fun getSummaryResponse( + @Path("title") title: String, + @Header("Referer") referrerUrl: String? = null, + @Header("Cache-Control") cacheControl: String? = null, + @Header(OfflineCacheInterceptor.SAVE_HEADER) saveHeader: String? = null, + @Header(OfflineCacheInterceptor.LANG_HEADER) langHeader: String? = null, + @Header(OfflineCacheInterceptor.TITLE_HEADER) titleHeader: String? = null + ): Response @Headers("Accept: $ACCEPT_HEADER_DEFINITION") @GET("page/definition/{title}") @@ -58,7 +62,11 @@ interface RestService { @GET("page/media-list/{title}") suspend fun getMediaList( - @Path("title") title: String + @Path("title") title: String, + @Header("Cache-Control") cacheControl: String? = null, + @Header(OfflineCacheInterceptor.SAVE_HEADER) saveHeader: String? = null, + @Header(OfflineCacheInterceptor.LANG_HEADER) langHeader: String? = null, + @Header(OfflineCacheInterceptor.TITLE_HEADER) titleHeader: String? = null ): MediaList @GET("page/media-list/{title}/{revision}") @@ -67,16 +75,6 @@ interface RestService { @Path("revision") revision: Long ): MediaList - @GET("page/media-list/{title}/{revision}") - suspend fun getMediaListResponse( - @Path("title") title: String?, - @Path("revision") revision: Long, - @Header("Cache-Control") cacheControl: String?, - @Header(OfflineCacheInterceptor.SAVE_HEADER) saveHeader: String?, - @Header(OfflineCacheInterceptor.LANG_HEADER) langHeader: String?, - @Header(OfflineCacheInterceptor.TITLE_HEADER) titleHeader: String? - ): Response - @GET("feed/onthisday/events/{mm}/{dd}") suspend fun getOnThisDay(@Path("mm") month: Int, @Path("dd") day: Int): OnThisDay diff --git a/app/src/main/java/org/wikipedia/descriptions/DescriptionEditViewModel.kt b/app/src/main/java/org/wikipedia/descriptions/DescriptionEditViewModel.kt index d361ae7d539..c5efb996259 100644 --- a/app/src/main/java/org/wikipedia/descriptions/DescriptionEditViewModel.kt +++ b/app/src/main/java/org/wikipedia/descriptions/DescriptionEditViewModel.kt @@ -61,7 +61,7 @@ class DescriptionEditViewModel(savedStateHandle: SavedStateHandle) : ViewModel() }) { _loadPageSummaryState.value = Resource.Loading() editingAllowed = false - val summaryResponse = async { ServiceFactory.getRest(pageTitle.wikiSite).getPageSummary(null, pageTitle.prefixedText) } + val summaryResponse = async { ServiceFactory.getRest(pageTitle.wikiSite).getPageSummary(pageTitle.prefixedText) } val infoResponse = async { ServiceFactory.get(pageTitle.wikiSite).getWikiTextForSectionWithInfo(pageTitle.prefixedText, 0) } val editError = infoResponse.await().query?.firstPage()?.getErrorForAction("edit") @@ -145,8 +145,8 @@ class DescriptionEditViewModel(savedStateHandle: SavedStateHandle) : ViewModel() var revision = -1L while (revision < newRevision && retry < 10) { delay(2000) - val pageSummaryResponse = ServiceFactory.getRest(pageTitle.wikiSite).getSummaryResponse(pageTitle.prefixedText, cacheControl = OkHttpConnectionFactory.CACHE_CONTROL_FORCE_NETWORK.toString()) - revision = pageSummaryResponse.body()?.revision ?: -1L + val pageSummary = ServiceFactory.getRest(pageTitle.wikiSite).getPageSummary(pageTitle.prefixedText, cacheControl = OkHttpConnectionFactory.CACHE_CONTROL_FORCE_NETWORK.toString()) + revision = pageSummary.revision retry++ } _waitForRevisionState.value = Resource.Success(true) diff --git a/app/src/main/java/org/wikipedia/edit/EditSectionViewModel.kt b/app/src/main/java/org/wikipedia/edit/EditSectionViewModel.kt index 2bc5eee3f45..6ff02ee5bb1 100644 --- a/app/src/main/java/org/wikipedia/edit/EditSectionViewModel.kt +++ b/app/src/main/java/org/wikipedia/edit/EditSectionViewModel.kt @@ -135,8 +135,8 @@ class EditSectionViewModel(savedStateHandle: SavedStateHandle) : ViewModel() { while (revision < newRevision && retry < 10) { delay(2000) val pageSummaryResponse = ServiceFactory.getRest(pageTitle.wikiSite) - .getSummaryResponse(pageTitle.prefixedText, cacheControl = OkHttpConnectionFactory.CACHE_CONTROL_FORCE_NETWORK.toString()) - revision = pageSummaryResponse.body()?.revision ?: -1L + .getPageSummary(pageTitle.prefixedText, cacheControl = OkHttpConnectionFactory.CACHE_CONTROL_FORCE_NETWORK.toString()) + revision = pageSummaryResponse.revision retry++ } _waitForRevisionState.value = Resource.Success(revision) diff --git a/app/src/main/java/org/wikipedia/page/PageFragmentLoadState.kt b/app/src/main/java/org/wikipedia/page/PageFragmentLoadState.kt index b3b35437072..9b6f436f7eb 100644 --- a/app/src/main/java/org/wikipedia/page/PageFragmentLoadState.kt +++ b/app/src/main/java/org/wikipedia/page/PageFragmentLoadState.kt @@ -155,8 +155,8 @@ class PageFragmentLoadState(private var model: PageViewModel, val pageSummaryResponse = pageSummaryRequest.await() val watchedResponse = watchedRequest.await() - val isWatched = watchedResponse.query?.firstPage()?.watched ?: false - val hasWatchlistExpiry = watchedResponse.query?.firstPage()?.hasWatchlistExpiry() ?: false + val isWatched = watchedResponse.query?.firstPage()?.watched == true + val hasWatchlistExpiry = watchedResponse.query?.firstPage()?.hasWatchlistExpiry() == true if (pageSummaryResponse.body() == null) { throw RuntimeException("Summary response was invalid.") } diff --git a/app/src/main/java/org/wikipedia/savedpages/SavedPageSyncService.kt b/app/src/main/java/org/wikipedia/savedpages/SavedPageSyncService.kt index a896f5a6922..f365b897a32 100644 --- a/app/src/main/java/org/wikipedia/savedpages/SavedPageSyncService.kt +++ b/app/src/main/java/org/wikipedia/savedpages/SavedPageSyncService.kt @@ -9,6 +9,7 @@ import androidx.work.OneTimeWorkRequestBuilder import androidx.work.WorkManager import androidx.work.WorkerParameters import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.async import kotlinx.coroutines.withContext import okhttp3.Request import okio.Buffer @@ -23,9 +24,7 @@ import org.wikipedia.dataclient.WikiSite import org.wikipedia.dataclient.okhttp.HttpStatusException import org.wikipedia.dataclient.okhttp.OfflineCacheInterceptor import org.wikipedia.dataclient.okhttp.OkHttpConnectionFactory -import org.wikipedia.dataclient.page.PageSummary import org.wikipedia.events.PageDownloadEvent -import org.wikipedia.gallery.MediaList import org.wikipedia.page.PageTitle import org.wikipedia.pageimages.db.PageImage import org.wikipedia.readinglist.database.ReadingListPage @@ -35,7 +34,6 @@ import org.wikipedia.settings.Prefs import org.wikipedia.util.* import org.wikipedia.util.log.L import org.wikipedia.views.CircularProgressBar -import retrofit2.Response import java.io.IOException import java.util.concurrent.TimeUnit @@ -158,11 +156,21 @@ class SavedPageSyncService(context: Context, params: WorkerParameters) : Corouti return withContext(Dispatchers.IO) { val pageTitle = ReadingListPage.toPageTitle(page) - // API calls - val summaryResponse = reqPageSummary(pageTitle) - val revision = summaryResponse.body()?.revision ?: 0 - val mediaListResponse = reqMediaList(pageTitle, revision) - val mobileHTMLResponse = reqMobileHTML(pageTitle) + val summaryCall = async { ServiceFactory.getRest(pageTitle.wikiSite).getPageSummary(pageTitle.prefixedText, + cacheControl = OkHttpConnectionFactory.CACHE_CONTROL_FORCE_NETWORK.toString(), + saveHeader = OfflineCacheInterceptor.SAVE_HEADER_SAVE, langHeader = pageTitle.wikiSite.languageCode, + titleHeader = UriUtil.encodeURL(pageTitle.prefixedText)) } + + val mediaListCall = async { ServiceFactory.getRest(pageTitle.wikiSite).getMediaList(pageTitle.prefixedText, + cacheControl = OkHttpConnectionFactory.CACHE_CONTROL_FORCE_NETWORK.toString(), + saveHeader = OfflineCacheInterceptor.SAVE_HEADER_SAVE, langHeader = pageTitle.wikiSite.languageCode, + titleHeader = UriUtil.encodeURL(pageTitle.prefixedText)) } + + val mobileHTMLCall = async { reqMobileHTML(pageTitle) } + + val summaryResponse = summaryCall.await() + val mediaListResponse = mediaListCall.await() + val mobileHTMLResponse = mobileHTMLCall.await() page.downloadProgress = MEDIA_LIST_PROGRESS FlowEventBus.post(PageDownloadEvent(page)) @@ -175,22 +183,22 @@ class SavedPageSyncService(context: Context, params: WorkerParameters) : Corouti } if (Prefs.isImageDownloadEnabled) { // download thumbnail and lead image - if (!summaryResponse.body()?.thumbnailUrl.isNullOrEmpty()) { - page.thumbUrl = UriUtil.resolveProtocolRelativeUrl(pageTitle.wikiSite, summaryResponse.body()?.thumbnailUrl.orEmpty()) + if (!summaryResponse.thumbnailUrl.isNullOrEmpty()) { + page.thumbUrl = UriUtil.resolveProtocolRelativeUrl(pageTitle.wikiSite, summaryResponse.thumbnailUrl.orEmpty()) AppDatabase.instance.pageImagesDao().insertPageImageSync(PageImage(pageTitle, page.thumbUrl.orEmpty())) fileUrls.add(UriUtil.resolveProtocolRelativeUrl( ImageUrlUtil.getUrlForPreferredSize(page.thumbUrl.orEmpty(), DimenUtil.calculateLeadImageWidth()))) } // download article images - for (item in mediaListResponse.body()?.getItems("image").orEmpty()) { + for (item in mediaListResponse.getItems("image")) { item.srcSets.let { fileUrls.add(item.getImageUrl(DimenUtil.densityScalar)) } } } - page.displayTitle = summaryResponse.body()?.displayTitle.orEmpty() - page.description = summaryResponse.body()?.description.orEmpty() + page.displayTitle = summaryResponse.displayTitle.orEmpty() + page.description = summaryResponse.description.orEmpty() reqSaveFiles(page, pageTitle, fileUrls) @@ -202,24 +210,6 @@ class SavedPageSyncService(context: Context, params: WorkerParameters) : Corouti } } - private suspend fun reqPageSummary(pageTitle: PageTitle): Response { - return withContext(Dispatchers.IO) { - ServiceFactory.getRest(pageTitle.wikiSite).getSummaryResponse(pageTitle.prefixedText, - null, OkHttpConnectionFactory.CACHE_CONTROL_FORCE_NETWORK.toString(), - OfflineCacheInterceptor.SAVE_HEADER_SAVE, pageTitle.wikiSite.languageCode, - UriUtil.encodeURL(pageTitle.prefixedText)) - } - } - - private suspend fun reqMediaList(pageTitle: PageTitle, revision: Long): Response { - return withContext(Dispatchers.IO) { - ServiceFactory.getRest(pageTitle.wikiSite).getMediaListResponse(pageTitle.prefixedText, - revision, OkHttpConnectionFactory.CACHE_CONTROL_FORCE_NETWORK.toString(), - OfflineCacheInterceptor.SAVE_HEADER_SAVE, pageTitle.wikiSite.languageCode, - UriUtil.encodeURL(pageTitle.prefixedText)) - } - } - private suspend fun reqMobileHTML(pageTitle: PageTitle): okhttp3.Response { val request = makeUrlRequest(pageTitle.wikiSite, ServiceFactory.getRestBasePath(pageTitle.wikiSite) + diff --git a/app/src/main/java/org/wikipedia/suggestededits/SuggestedEditsImageRecsFragmentViewModel.kt b/app/src/main/java/org/wikipedia/suggestededits/SuggestedEditsImageRecsFragmentViewModel.kt index 69b0cadec29..113c5983c5f 100644 --- a/app/src/main/java/org/wikipedia/suggestededits/SuggestedEditsImageRecsFragmentViewModel.kt +++ b/app/src/main/java/org/wikipedia/suggestededits/SuggestedEditsImageRecsFragmentViewModel.kt @@ -66,7 +66,7 @@ class SuggestedEditsImageRecsFragmentViewModel(savedStateHandle: SavedStateHandl recommendation = page?.growthimagesuggestiondata?.first()!! val wikiSite = WikiSite.forLanguageCode(langCode) - summary = ServiceFactory.getRest(wikiSite).getPageSummary(null, page.title) + summary = ServiceFactory.getRest(wikiSite).getPageSummary(page.title) pageTitle = summary.getPageTitle(wikiSite) val thumbUrl = UriUtil.resolveProtocolRelativeUrl(ImageUrlUtil.getUrlForPreferredSize(recommendation.images[0].metadata!!.thumbUrl, Constants.PREFERRED_CARD_THUMBNAIL_SIZE)) diff --git a/app/src/main/java/org/wikipedia/suggestededits/provider/EditingSuggestionsProvider.kt b/app/src/main/java/org/wikipedia/suggestededits/provider/EditingSuggestionsProvider.kt index 8d2c7a4296e..0b0777febbd 100644 --- a/app/src/main/java/org/wikipedia/suggestededits/provider/EditingSuggestionsProvider.kt +++ b/app/src/main/java/org/wikipedia/suggestededits/provider/EditingSuggestionsProvider.kt @@ -94,7 +94,7 @@ object EditingSuggestionsProvider { } } - pageSummary = ServiceFactory.getRest(wiki).getPageSummary(null, title) + pageSummary = ServiceFactory.getRest(wiki).getPageSummary(title) } finally { mutex.release() } @@ -154,14 +154,14 @@ object EditingSuggestionsProvider { titles?.let { val sourcePageSummary = async { - ServiceFactory.getRest(it.first.wikiSite).getPageSummary(null, it.first.prefixedText).apply { + ServiceFactory.getRest(it.first.wikiSite).getPageSummary(it.first.prefixedText).apply { if (description.isNullOrEmpty()) { description = it.first.description } } } val targetPageSummary = async { - ServiceFactory.getRest(it.second.wikiSite).getPageSummary(null, it.second.prefixedText) + ServiceFactory.getRest(it.second.wikiSite).getPageSummary(it.second.prefixedText) } pair = sourcePageSummary.await() to targetPageSummary.await() } diff --git a/app/src/main/java/org/wikipedia/util/L10nUtil.kt b/app/src/main/java/org/wikipedia/util/L10nUtil.kt index 2b118ee735b..b812f15d1e6 100644 --- a/app/src/main/java/org/wikipedia/util/L10nUtil.kt +++ b/app/src/main/java/org/wikipedia/util/L10nUtil.kt @@ -159,7 +159,7 @@ object L10nUtil { if (shouldUpdateExtracts) { list.map { pageSummary -> async { - ServiceFactory.getRest(wikiSite).getPageSummary(null, pageSummary.apiTitle) + ServiceFactory.getRest(wikiSite).getPageSummary(pageSummary.apiTitle) } }.awaitAll().forEachIndexed { index, pageSummary -> list[index].extract = pageSummary.extract diff --git a/app/src/main/java/org/wikipedia/widgets/WidgetFeaturedPageWorker.kt b/app/src/main/java/org/wikipedia/widgets/WidgetFeaturedPageWorker.kt index a8596a0c1d4..1c971fb9e0b 100644 --- a/app/src/main/java/org/wikipedia/widgets/WidgetFeaturedPageWorker.kt +++ b/app/src/main/java/org/wikipedia/widgets/WidgetFeaturedPageWorker.kt @@ -31,13 +31,13 @@ class WidgetFeaturedPageWorker( val summary = if (result.tfa != null) { val hasParentLanguageCode = !WikipediaApp.instance.languageState.getDefaultLanguageCode(WikipediaApp.instance.wikiSite.languageCode).isNullOrEmpty() if (hasParentLanguageCode) { - ServiceFactory.getRest(WikipediaApp.instance.wikiSite).getPageSummary(null, result.tfa.apiTitle) + ServiceFactory.getRest(WikipediaApp.instance.wikiSite).getPageSummary(result.tfa.apiTitle) } else { result.tfa } } else { val response = ServiceFactory.get(mainPageTitle.wikiSite).parseTextForMainPage(mainPageTitle.prefixedText) - ServiceFactory.getRest(WikipediaApp.instance.wikiSite).getPageSummary(null, findFeaturedArticleTitle(response.text)) + ServiceFactory.getRest(WikipediaApp.instance.wikiSite).getPageSummary(findFeaturedArticleTitle(response.text)) } val pageTitle = summary.getPageTitle(app.wikiSite) From f1a311371f1194c0139c4b25c3a2ca4298357e11 Mon Sep 17 00:00:00 2001 From: Dmitry Brant Date: Fri, 17 Jan 2025 10:12:23 -0500 Subject: [PATCH 12/12] Use named parameters. --- .../main/java/org/wikipedia/page/PageFragmentLoadState.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/wikipedia/page/PageFragmentLoadState.kt b/app/src/main/java/org/wikipedia/page/PageFragmentLoadState.kt index 9b6f436f7eb..c42c04923fb 100644 --- a/app/src/main/java/org/wikipedia/page/PageFragmentLoadState.kt +++ b/app/src/main/java/org/wikipedia/page/PageFragmentLoadState.kt @@ -140,8 +140,9 @@ class PageFragmentLoadState(private var model: PageViewModel, } val pageSummaryRequest = async { - ServiceFactory.getRest(title.wikiSite).getSummaryResponse(title.prefixedText, null, model.cacheControl.toString(), - if (model.isInReadingList) OfflineCacheInterceptor.SAVE_HEADER_SAVE else null, title.wikiSite.languageCode, UriUtil.encodeURL(title.prefixedText)) + ServiceFactory.getRest(title.wikiSite).getSummaryResponse(title.prefixedText, cacheControl = model.cacheControl.toString(), + saveHeader = if (model.isInReadingList) OfflineCacheInterceptor.SAVE_HEADER_SAVE else null, + langHeader = title.wikiSite.languageCode, titleHeader = UriUtil.encodeURL(title.prefixedText)) } val watchedRequest = async { if (WikipediaApp.instance.isOnline && AccountUtil.isLoggedIn) {