Skip to content

Commit af7451d

Browse files
adalpariclaude[bot]
authored andcommitted
CMM-992 reader deeplinks (#22374)
* Supporting read and discovery deeplinks * Fixing discovery issue * Handling feed links * Handling search and tags * Some improvements * Re-adding deleted code * Lint fixes * Adding tests for ReaderActivityLauncher * Update WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> * chore: trigger CI * Supporting the new Calypso banner specs * Adding some tests --------- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
1 parent b3e2433 commit af7451d

File tree

14 files changed

+768
-41
lines changed

14 files changed

+768
-41
lines changed

WordPress/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,8 @@ dependencies {
493493
testImplementation(libs.assertj.core)
494494
testImplementation(libs.kotlinx.coroutines.test)
495495
testImplementation(libs.turbine)
496+
testImplementation(libs.robolectric)
497+
testImplementation(libs.androidx.test.core)
496498

497499
androidTestImplementation project(path:':libs:mocks')
498500

WordPress/src/main/AndroidManifest.xml

Lines changed: 106 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,82 @@
581581
android:pathPattern="/site-monitoring/.*"
582582
android:scheme="http" />
583583

584+
<data
585+
android:host="wordpress.com"
586+
android:path="/read"
587+
android:scheme="https" />
588+
589+
<data
590+
android:host="wordpress.com"
591+
android:path="/read"
592+
android:scheme="http" />
593+
594+
<data
595+
android:host="wordpress.com"
596+
android:path="/discover"
597+
android:scheme="https" />
598+
599+
<data
600+
android:host="wordpress.com"
601+
android:path="/discover"
602+
android:scheme="http" />
603+
604+
<data
605+
android:host="wordpress.com"
606+
android:pathPattern="/read/feeds/.*"
607+
android:scheme="https" />
608+
609+
<data
610+
android:host="wordpress.com"
611+
android:pathPattern="/read/feeds/.*"
612+
android:scheme="http" />
613+
614+
<data
615+
android:host="wordpress.com"
616+
android:pathPattern="/reader/feeds/.*"
617+
android:scheme="https" />
618+
619+
<data
620+
android:host="wordpress.com"
621+
android:pathPattern="/reader/feeds/.*"
622+
android:scheme="http" />
623+
624+
<data
625+
android:host="wordpress.com"
626+
android:path="/read/search"
627+
android:scheme="https"
628+
tools:ignore="IntentFilterUniqueDataAttributes" />
629+
630+
<data
631+
android:host="wordpress.com"
632+
android:path="/read/search"
633+
android:scheme="http"
634+
tools:ignore="IntentFilterUniqueDataAttributes" />
635+
636+
<data
637+
android:host="wordpress.com"
638+
android:path="/reader/search"
639+
android:scheme="https"
640+
tools:ignore="IntentFilterUniqueDataAttributes" />
641+
642+
<data
643+
android:host="wordpress.com"
644+
android:path="/reader/search"
645+
android:scheme="http"
646+
tools:ignore="IntentFilterUniqueDataAttributes" />
647+
648+
<data
649+
android:host="wordpress.com"
650+
android:pathPattern="/tag/.*"
651+
android:scheme="https"
652+
tools:ignore="IntentFilterUniqueDataAttributes" />
653+
654+
<data
655+
android:host="wordpress.com"
656+
android:pathPattern="/tag/.*"
657+
android:scheme="http"
658+
tools:ignore="IntentFilterUniqueDataAttributes" />
659+
584660
</intent-filter>
585661
</activity-alias>
586662

@@ -612,49 +688,71 @@
612688
<data
613689
android:host="wordpress.com"
614690
android:pathPattern="/read/feeds/.*/posts/.*"
615-
android:scheme="https" >
691+
android:scheme="https"
692+
tools:ignore="IntentFilterUniqueDataAttributes" >
616693
</data>
617694

618695
<data
619696
android:host="wordpress.com"
620697
android:pathPattern="/read/feeds/.*/posts/.*"
621-
android:scheme="http" >
698+
android:scheme="http"
699+
tools:ignore="IntentFilterUniqueDataAttributes" >
622700
</data>
623701

624702
<data
625703
android:host="wordpress.com"
626704
android:pathPattern="/read/blogs/.*/posts/.*"
627-
android:scheme="https" >
705+
android:scheme="https"
706+
tools:ignore="IntentFilterUniqueDataAttributes" >
628707
</data>
629708

630709
<data
631710
android:host="wordpress.com"
632711
android:pathPattern="/read/blogs/.*/posts/.*"
633-
android:scheme="http" >
712+
android:scheme="http"
713+
tools:ignore="IntentFilterUniqueDataAttributes" >
634714
</data>
635715

636716
<data
637717
android:host="*.wordpress.com"
638718
android:pathPattern="/2.../../../.*"
639-
android:scheme="https" >
719+
android:scheme="https"
720+
tools:ignore="IntentFilterUniqueDataAttributes" >
640721
</data>
641722

642723
<data
643724
android:host="*.wordpress.com"
644725
android:pathPattern="/2.../../../.*"
645-
android:scheme="http" >
726+
android:scheme="http"
727+
tools:ignore="IntentFilterUniqueDataAttributes" >
646728
</data>
647729

648730
<data
649731
android:host="*.wordpress.com"
650732
android:pathPattern="/19../../../.*"
651-
android:scheme="https" >
733+
android:scheme="https"
734+
tools:ignore="IntentFilterUniqueDataAttributes" >
652735
</data>
653736

654737
<data
655738
android:host="*.wordpress.com"
656739
android:pathPattern="/19../../../.*"
657-
android:scheme="http" >
740+
android:scheme="http"
741+
tools:ignore="IntentFilterUniqueDataAttributes" >
742+
</data>
743+
744+
<data
745+
android:host="wordpress.com"
746+
android:pathPattern="/reader/feeds/.*/posts/.*"
747+
android:scheme="https"
748+
tools:ignore="IntentFilterUniqueDataAttributes" >
749+
</data>
750+
751+
<data
752+
android:host="wordpress.com"
753+
android:pathPattern="/reader/feeds/.*/posts/.*"
754+
android:scheme="http"
755+
tools:ignore="IntentFilterUniqueDataAttributes" >
658756
</data>
659757

660758
<data

WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,43 @@ public static void viewReaderInNewStack(Context context) {
338338
context.startActivity(intent);
339339
}
340340

341+
public static void viewReaderDiscoverInNewStack(Context context) {
342+
Intent intent = getMainActivityInNewStack(context);
343+
intent.putExtra(WPMainActivity.ARG_OPEN_PAGE, WPMainActivity.ARG_READER);
344+
intent.putExtra(WPMainActivity.ARG_READER_DISCOVER_TAB, true);
345+
context.startActivity(intent);
346+
}
347+
348+
public static void viewReaderFeedInNewStack(Context context, long feedId) {
349+
Intent mainActivityIntent = getMainActivityInNewStack(context)
350+
.putExtra(WPMainActivity.ARG_OPEN_PAGE, WPMainActivity.ARG_READER);
351+
Intent feedIntent = ReaderActivityLauncher.buildReaderFeedIntent(context, feedId, "deeplink");
352+
TaskStackBuilder.create(context)
353+
.addNextIntent(mainActivityIntent)
354+
.addNextIntent(feedIntent)
355+
.startActivities();
356+
}
357+
358+
public static void viewReaderSearchInNewStack(Context context) {
359+
Intent mainActivityIntent = getMainActivityInNewStack(context)
360+
.putExtra(WPMainActivity.ARG_OPEN_PAGE, WPMainActivity.ARG_READER);
361+
Intent searchIntent = ReaderActivityLauncher.createReaderSearchIntent(context);
362+
TaskStackBuilder.create(context)
363+
.addNextIntent(mainActivityIntent)
364+
.addNextIntent(searchIntent)
365+
.startActivities();
366+
}
367+
368+
public static void viewReaderTagInNewStack(@NonNull Context context, @NonNull String tagSlug) {
369+
Intent mainActivityIntent = getMainActivityInNewStack(context)
370+
.putExtra(WPMainActivity.ARG_OPEN_PAGE, WPMainActivity.ARG_READER);
371+
Intent tagIntent = ReaderActivityLauncher.buildReaderTagIntent(context, tagSlug, "deeplink");
372+
TaskStackBuilder.create(context)
373+
.addNextIntent(mainActivityIntent)
374+
.addNextIntent(tagIntent)
375+
.startActivities();
376+
}
377+
341378
public static void viewPostDeeplinkInNewStack(Context context, Uri uri) {
342379
Intent mainActivityIntent = getMainActivityInNewStack(context)
343380
.putExtra(WPMainActivity.ARG_OPEN_PAGE, WPMainActivity.ARG_READER);

WordPress/src/main/java/org/wordpress/android/ui/deeplinks/DeepLinkNavigator.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.OpenN
1818
import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.OpenPages
1919
import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.OpenPagesForSite
2020
import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.OpenQRCodeAuthFlow
21+
import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.OpenFeedInReader
2122
import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.OpenReader
23+
import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.OpenReaderDiscover
24+
import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.OpenReaderSearch
25+
import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.OpenTagInReader
2226
import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.OpenStats
2327
import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.OpenStatsForSite
2428
import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.OpenStatsForSiteAndTimeframe
@@ -78,6 +82,10 @@ class DeepLinkNavigator
7882
)
7983

8084
OpenReader -> ActivityLauncher.viewReaderInNewStack(activity)
85+
OpenReaderDiscover -> ActivityLauncher.viewReaderDiscoverInNewStack(activity)
86+
OpenReaderSearch -> ActivityLauncher.viewReaderSearchInNewStack(activity)
87+
is OpenFeedInReader -> ActivityLauncher.viewReaderFeedInNewStack(activity, navigateAction.feedId)
88+
is OpenTagInReader -> ActivityLauncher.viewReaderTagInNewStack(activity, navigateAction.tagSlug)
8189
is OpenInReader -> ActivityLauncher.viewPostDeeplinkInNewStack(activity, navigateAction.uri.uri)
8290
is ViewPostInReader -> ActivityLauncher.viewReaderPostDetailInNewStack(
8391
activity,
@@ -123,6 +131,10 @@ class DeepLinkNavigator
123131
data class OpenEditorForPost(val site: SiteModel, val postId: Int) : NavigateAction()
124132
data class OpenEditorForSite(val site: SiteModel) : NavigateAction()
125133
object OpenReader : NavigateAction()
134+
object OpenReaderDiscover : NavigateAction()
135+
object OpenReaderSearch : NavigateAction()
136+
data class OpenFeedInReader(val feedId: Long) : NavigateAction()
137+
data class OpenTagInReader(val tagSlug: String) : NavigateAction()
126138
data class OpenInReader(val uri: UriWrapper) : NavigateAction()
127139
data class ViewPostInReader(val blogId: Long, val postId: Long, val uri: UriWrapper) : NavigateAction()
128140
object OpenEditor : NavigateAction()

0 commit comments

Comments
 (0)