|
1 | 1 | package org.wikipedia.feed |
2 | 2 |
|
| 3 | +import android.app.Activity |
3 | 4 | import android.net.Uri |
4 | 5 | import android.os.Bundle |
5 | 6 | import android.util.Pair |
6 | 7 | import android.view.LayoutInflater |
7 | 8 | import android.view.View |
8 | 9 | import android.view.ViewGroup |
9 | 10 | import androidx.activity.result.contract.ActivityResultContracts |
| 11 | +import androidx.core.net.toUri |
10 | 12 | import androidx.fragment.app.Fragment |
11 | 13 | import androidx.lifecycle.lifecycleScope |
12 | 14 | import androidx.recyclerview.widget.RecyclerView |
@@ -41,6 +43,7 @@ import org.wikipedia.settings.SettingsActivity |
41 | 43 | import org.wikipedia.settings.languages.WikipediaLanguagesActivity |
42 | 44 | import org.wikipedia.util.FeedbackUtil |
43 | 45 | import org.wikipedia.util.UriUtil |
| 46 | +import java.time.LocalDate |
44 | 47 |
|
45 | 48 | class FeedFragment : Fragment() { |
46 | 49 | private var _binding: FragmentFeedBinding? = null |
@@ -379,5 +382,27 @@ class FeedFragment : Fragment() { |
379 | 382 | retainInstance = true |
380 | 383 | } |
381 | 384 | } |
| 385 | + |
| 386 | + fun maybeShowExploreFeedSurvey(activity: Activity) { |
| 387 | + if (Prefs.exploreFeedSurveyShown || WikipediaApp.instance.languageState.systemLanguageCode != "en") return |
| 388 | + |
| 389 | + val currentDate = LocalDate.now() |
| 390 | + val startDate = LocalDate.of(2025, 11, 24) |
| 391 | + val endDate = LocalDate.of(2025, 11, 30) |
| 392 | + |
| 393 | + if (currentDate !in startDate..endDate) { |
| 394 | + return |
| 395 | + } |
| 396 | + |
| 397 | + MaterialAlertDialogBuilder(activity) |
| 398 | + .setTitle(R.string.explore_feed_survey_dialog_title) |
| 399 | + .setMessage(R.string.explore_feed_survey_dialog_message) |
| 400 | + .setPositiveButton(R.string.explore_feed_survey_dialog_positive_button_label) { _, _ -> |
| 401 | + UriUtil.handleExternalLink(activity, activity.getString(R.string.explore_feed_survey_url).toUri()) |
| 402 | + } |
| 403 | + .setNegativeButton(R.string.explore_feed_survey_dialog_negative_button_label) { _, _ -> } |
| 404 | + .show() |
| 405 | + Prefs.exploreFeedSurveyShown = true |
| 406 | + } |
382 | 407 | } |
383 | 408 | } |
0 commit comments