Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.OpenL
import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.ShowSignInFlow
import org.wordpress.android.ui.deeplinks.handlers.DeepLinkHandlers
import org.wordpress.android.ui.deeplinks.handlers.ServerTrackingHandler
import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalPhaseHelper
import org.wordpress.android.util.UriWrapper
import org.wordpress.android.util.analytics.AnalyticsUtilsWrapper
import org.wordpress.android.viewmodel.Event
Expand All @@ -38,7 +37,6 @@ class DeepLinkingIntentReceiverViewModel
private val deepLinkTrackingUtils: DeepLinkTrackingUtils,
private val analyticsUtilsWrapper: AnalyticsUtilsWrapper,
private val openWebLinksWithJetpackHelper: DeepLinkOpenWebLinksWithJetpackHelper,
private val jetpackFeatureRemovalPhaseHelper: JetpackFeatureRemovalPhaseHelper
) : ScopedViewModel(uiDispatcher) {
private val _navigateAction = MutableLiveData<Event<NavigateAction>>()
val navigateAction = _navigateAction as LiveData<Event<NavigateAction>>
Expand Down Expand Up @@ -111,7 +109,7 @@ class DeepLinkingIntentReceiverViewModel
* and builds the navigation action based on them
*/
private fun handleUrl(uriWrapper: UriWrapper, action: String? = null): Boolean {
return interceptNavigationActionIfNeeded(buildNavigateAction(uriWrapper))?.also {
return buildNavigateAction(uriWrapper)?.also {
if (action != null) {
deepLinkTrackingUtils.track(action, it, uriWrapper)
}
Expand All @@ -123,24 +121,6 @@ class DeepLinkingIntentReceiverViewModel
} != null
}

@Suppress("ComplexMethod")
private fun interceptNavigationActionIfNeeded(navigationAction: NavigateAction?): NavigateAction?{
if (!jetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures())
return navigationAction

return when (navigationAction) {
NavigateAction.OpenStats,
is NavigateAction.OpenStatsForTimeframe,
is NavigateAction.OpenStatsForSite,
is NavigateAction.OpenStatsForSiteAndTimeframe,
NavigateAction.OpenReader,
is NavigateAction.OpenInReader,
is NavigateAction.ViewPostInReader,
NavigateAction.OpenNotifications -> null
else -> navigationAction
}
}

private fun loginIsUnnecessary(action: NavigateAction): Boolean {
return accountStore.hasAccessToken() ||
action is OpenInBrowser ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ class JetpackFeatureRemovalOverlayUtil @Inject constructor(
enum class JetpackFeatureCollectionOverlaySource(val label: String) {
FEATURE_CARD("card"),
APP_OPEN("app_open"),
DISABLED_ENTRY_POINT("disabled_entry_point"),
UNSPECIFIED("unspecified");

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import org.wordpress.android.ui.LocaleAwareActivity;
import org.wordpress.android.ui.PagePostCreationSourcesDetail;
import org.wordpress.android.ui.RequestCodes;
import org.wordpress.android.ui.Shortcut;
import org.wordpress.android.ui.ShortcutsNavigator;
import org.wordpress.android.ui.WPTooltipView;
import org.wordpress.android.ui.accounts.LoginActivity;
Expand Down Expand Up @@ -159,7 +160,9 @@
import org.wordpress.android.workers.weeklyroundup.WeeklyRoundupScheduler;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.inject.Inject;

Expand Down Expand Up @@ -366,6 +369,8 @@ public void onCreate(Bundle savedInstanceState) {
initSelectedSite();
mShortcutsNavigator.showTargetScreen(getIntent().getStringExtra(
ShortcutsNavigator.ACTION_OPEN_SHORTCUT), this, getSelectedSite());
showJetpackOverlayIfNeeded(getIntent().getStringExtra(
ShortcutsNavigator.ACTION_OPEN_SHORTCUT));
} else if (openRequestedPage) {
handleOpenPageIntent(getIntent());
} else if (isQuickStartRequestedFromPush) {
Expand Down Expand Up @@ -486,6 +491,44 @@ && getIntent().getExtras().getBoolean(ARG_CONTINUE_JETPACK_CONNECT, false)) {
displayJetpackFeatureCollectionOverlayIfNeeded();
}

private void showJetpackOverlayIfNeeded(String action) {
if (!mJetpackFeatureRemovalOverlayUtil.shouldHideJetpackFeatures()) {
return;
}
Shortcut shortcut = Shortcut.fromActionString(action);
if (shortcut == null) {
AppLog.e(AppLog.T.MAIN, String.format("Unknown Android Shortcut action[%s]", action));
return;
}

Map<String, String> trackingProperties = new HashMap<>();
trackingProperties.put("calling_function", "shortcut_" + shortcut.name());

switch (shortcut) {
case CREATE_NEW_POST:
break;
case OPEN_STATS:
case OPEN_NOTIFICATIONS:
showJetpackFeatureOverlayAccessedInCorrectly(trackingProperties);
break;
default:
AppLog.e(AppLog.T.MAIN, String.format("Unknown Android Shortcut[%s]", shortcut));
}
}

private void showJetpackFeatureOverlayAccessedInCorrectly(Map<String, String> trackingProperties) {
mAnalyticsTrackerWrapper.track(
Stat.JETPACK_FEATURE_INCORRECTLY_ACCESSED, trackingProperties);
JetpackFeatureFullScreenOverlayFragment.newInstance(
null,
false,
false,
SiteCreationSource.UNSPECIFIED,
true,
JetpackFeatureCollectionOverlaySource.DISABLED_ENTRY_POINT
).show(getSupportFragmentManager(), JetpackFeatureFullScreenOverlayFragment.TAG);
}

private void setUpMainView() {
if (!mJetpackFeatureRemovalOverlayUtil.shouldHideJetpackFeatures()) {
if (mBottomNav != null) {
Expand Down Expand Up @@ -773,17 +816,30 @@ protected void onNewIntent(Intent intent) {

private void handleOpenPageIntent(Intent intent) {
String pagePosition = intent.getStringExtra(ARG_OPEN_PAGE);
Log.e("Main", "handleOpenPageIntent " + pagePosition);
if (!TextUtils.isEmpty(pagePosition)) {
switch (pagePosition) {
case ARG_MY_SITE:
if (mBottomNav != null) mBottomNav.setCurrentSelectedPage(PageType.MY_SITE);
break;
case ARG_NOTIFICATIONS:
setUpMainView();
if (mJetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures()) {
Map<String, String> trackingProperties = new HashMap<>();
trackingProperties.put("calling_function", "deeplink_notifications");
showJetpackFeatureOverlayAccessedInCorrectly(trackingProperties);
break;
}
if (mBottomNav != null) mBottomNav.setCurrentSelectedPage(PageType.NOTIFS);
break;
case ARG_READER:
setUpMainView();
if (mJetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures()) {
Map<String, String> trackingProperties = new HashMap<>();
trackingProperties.put("calling_function", "deeplink_reader");
showJetpackFeatureOverlayAccessedInCorrectly(trackingProperties);
break;
}
if (intent.getBooleanExtra(ARG_READER_BOOKMARK_TAB, false) && mBottomNav != null && mBottomNav
.getActiveFragment() instanceof ReaderFragment) {
((ReaderFragment) mBottomNav.getActiveFragment()).requestBookmarkTab();
Expand All @@ -803,6 +859,12 @@ private void handleOpenPageIntent(Intent intent) {
if (!mSelectedSiteRepository.hasSelectedSite()) {
initSelectedSite();
}
if (mJetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures()) {
Map<String, String> trackingProperties = new HashMap<>();
trackingProperties.put("calling_function", "deeplink_stats");
showJetpackFeatureOverlayAccessedInCorrectly(trackingProperties);
break;
}
if (intent.hasExtra(ARG_STATS_TIMEFRAME)) {
ActivityLauncher.viewBlogStatsForTimeframe(this, getSelectedSite(),
(StatsTimeframe) intent.getSerializableExtra(ARG_STATS_TIMEFRAME));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureFullScreenOverlayViewModel;
import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureOverlayActions.ForwardToJetpack;
import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalOverlayUtil.JetpackFeatureCollectionOverlaySource;
import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalPhaseHelper;
import org.wordpress.android.ui.mysite.SelectedSiteRepository;
import org.wordpress.android.ui.posts.EditPostActivity;
import org.wordpress.android.ui.prefs.AppPrefs;
Expand Down Expand Up @@ -167,7 +166,6 @@ public enum DirectOperation {
@Inject JetpackAppMigrationFlowUtils mJetpackAppMigrationFlowUtils;
private JetpackFeatureFullScreenOverlayViewModel mJetpackFullScreenViewModel;
@Inject AccountStore mAccountStore;
@Inject JetpackFeatureRemovalPhaseHelper mJetpackFeatureRemovalPhaseHelper;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -299,7 +297,7 @@ private void handleDeepLinking() {
host = uri.getHost();
}

if (uri == null || mJetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures()) {
if (uri == null) {
mReaderTracker.trackDeepLink(AnalyticsTracker.Stat.DEEP_LINKED, action, host, uri);
// invalid uri so, just show the entry screen
Intent intent = new Intent(this, WPLaunchActivity.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ class DeepLinkingIntentReceiverViewModelTest : BaseUnitTest() {
serverTrackingHandler,
deepLinkTrackingUtils,
analyticsUtilsWrapper,
openWebLinksWithJetpackHelper,
jetpackFeatureRemovalPhaseHelper
openWebLinksWithJetpackHelper
)
isFinished = false
viewModel.finish.observeForever {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,8 @@ public enum Stat {
REMOVE_FEATURE_CARD_LINK_TAPPED,
REMOVE_FEATURE_CARD_MENU_ACCESSED,
REMOVE_FEATURE_CARD_HIDE_TAPPED,
REMOVE_FEATURE_CARD_REMIND_LATER_TAPPED
REMOVE_FEATURE_CARD_REMIND_LATER_TAPPED,
JETPACK_FEATURE_INCORRECTLY_ACCESSED
}

private static final List<Tracker> TRACKERS = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2503,6 +2503,8 @@ public static String getEventNameForStat(AnalyticsTracker.Stat stat) {
return "remove_feature_card_hide_tapped";
case REMOVE_FEATURE_CARD_REMIND_LATER_TAPPED:
return "remove_feature_card_remind_later_tapped";
case JETPACK_FEATURE_INCORRECTLY_ACCESSED:
return "jetpack_feature_incorrectly_accessed";
}
return null;
}
Expand Down