diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 21fd6b537560..c106f950a885 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -7,6 +7,7 @@ * [*] Site creation: Fixed bug where sites created within the app were not given the correct time zone, leading to post scheduling issues. [https://github.com/wordpress-mobile/WordPress-Android/pull/15904] * [*] Login Epilogue: Fixed bug where if no sites available, then new login epilogue screen without clickable sites and with "create new site" is shown instead of no sites empty "My Site" view. [https://github.com/wordpress-mobile/WordPress-Android/pull/15944] * [*] Fixes flickering when changing the preview mode in Page or Site design picker [https://github.com/wordpress-mobile/WordPress-Android/pull/15943] +* [**] Jetpack App: Signup using WordPress.com, create your favorite site and enjoy the Reader inside Jetpack app. [https://github.com/wordpress-mobile/WordPress-Android/pull/15946] * [*] Reader: Admins and Editors can edit comments from Reader [https://github.com/wordpress-mobile/WordPress-Android/pull/15957] * [*] Improves the error message shown when trying to create a new site with non-English characters in the domain name [https://github.com/wordpress-mobile/WordPress-Android/pull/15969] diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 54ab94ce0c0e..c5bc818144dd 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -117,6 +117,16 @@ android { buildConfigField "boolean", "COMMENTS_SNIPPET", "false" buildConfigField "boolean", "READER_COMMENTS_MODERATION", "false" + // Override these constants in jetpack product flavor to enable/ disable features + buildConfigField "boolean", "ENABLE_SITE_CREATION", "true" + buildConfigField "boolean", "ENABLE_ADD_SELF_HOSTED_SITE", "true" + buildConfigField "boolean", "ENABLE_SIGNUP", "true" + buildConfigField "boolean", "ENABLE_READER", "true" + buildConfigField "boolean", "ENABLE_CREATE_FAB", "true" + buildConfigField "boolean", "ENABLE_QUICK_ACTION", "true" + buildConfigField "boolean", "ENABLE_FOLLOWED_SITES_SETTINGS", "true" + buildConfigField "boolean", "ENABLE_WHATS_NEW_FEATURE", "true" + manifestPlaceholders = [magicLinkScheme:"wordpress"] } @@ -151,6 +161,14 @@ android { applicationId "com.jetpack.android" buildConfigField "boolean", "IS_JETPACK_APP", "true" + buildConfigField "boolean", "ENABLE_SITE_CREATION", "true" + buildConfigField "boolean", "ENABLE_ADD_SELF_HOSTED_SITE", "false" + buildConfigField "boolean", "ENABLE_SIGNUP", "true" + buildConfigField "boolean", "ENABLE_READER", "true" + buildConfigField "boolean", "ENABLE_CREATE_FAB", "true" + buildConfigField "boolean", "ENABLE_QUICK_ACTION", "true" + buildConfigField "boolean", "ENABLE_FOLLOWED_SITES_SETTINGS", "true" + buildConfigField "boolean", "ENABLE_WHATS_NEW_FEATURE", "true" buildConfigField "String", "TRACKS_EVENT_PREFIX", '"jpandroid_"' buildConfigField "String", "PUSH_NOTIFICATIONS_APP_KEY", '"com.jetpack.android"' diff --git a/WordPress/src/jetpack/java/org/wordpress/android/ui/accounts/login/LoginPrologueViewModel.kt b/WordPress/src/jetpack/java/org/wordpress/android/ui/accounts/login/LoginPrologueViewModel.kt index 4a2e98d759c4..981a6b035965 100644 --- a/WordPress/src/jetpack/java/org/wordpress/android/ui/accounts/login/LoginPrologueViewModel.kt +++ b/WordPress/src/jetpack/java/org/wordpress/android/ui/accounts/login/LoginPrologueViewModel.kt @@ -17,6 +17,7 @@ import org.wordpress.android.ui.accounts.UnifiedLoginTracker.Flow import org.wordpress.android.ui.accounts.UnifiedLoginTracker.Step.PROLOGUE import org.wordpress.android.ui.accounts.login.LoginPrologueViewModel.ButtonUiState.ContinueWithWpcomButtonState import org.wordpress.android.ui.accounts.login.LoginPrologueViewModel.ButtonUiState.EnterYourSiteAddressButtonState +import org.wordpress.android.util.BuildConfigWrapper import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper import org.wordpress.android.viewmodel.Event import org.wordpress.android.viewmodel.ScopedViewModel @@ -26,6 +27,7 @@ import javax.inject.Named class LoginPrologueViewModel @Inject constructor( private val unifiedLoginTracker: UnifiedLoginTracker, private val analyticsTrackerWrapper: AnalyticsTrackerWrapper, + private val buildConfigWrapper: BuildConfigWrapper, @Named(UI_THREAD) mainDispatcher: CoroutineDispatcher ) : ScopedViewModel(mainDispatcher) { private val _navigationEvents = MediatorLiveData>() @@ -44,7 +46,14 @@ class LoginPrologueViewModel @Inject constructor( _uiState.value = UiState( enterYourSiteAddressButtonState = EnterYourSiteAddressButtonState(::onEnterYourSiteAddressButtonClick), - continueWithWpcomButtonState = ContinueWithWpcomButtonState(::onContinueWithWpcomButtonClick) + continueWithWpcomButtonState = ContinueWithWpcomButtonState( + title = if (buildConfigWrapper.isSignupEnabled) { + R.string.continue_with_wpcom + } else { + R.string.continue_with_wpcom_no_signup + }, + onClick = ::onContinueWithWpcomButtonClick + ) ) } @@ -71,9 +80,10 @@ class LoginPrologueViewModel @Inject constructor( abstract val title: Int abstract val onClick: (() -> Unit) - data class ContinueWithWpcomButtonState(override val onClick: () -> Unit) : ButtonUiState() { - override val title = R.string.continue_with_wpcom_no_signup - } + data class ContinueWithWpcomButtonState( + override val title: Int, + override val onClick: () -> Unit + ) : ButtonUiState() data class EnterYourSiteAddressButtonState(override val onClick: () -> Unit) : ButtonUiState() { override val title = R.string.enter_your_site_address diff --git a/WordPress/src/jetpack/res/drawable/img_post_signup_interstitial_screen.xml b/WordPress/src/jetpack/res/drawable/img_post_signup_interstitial_screen.xml new file mode 100644 index 000000000000..bdfca0289c56 --- /dev/null +++ b/WordPress/src/jetpack/res/drawable/img_post_signup_interstitial_screen.xml @@ -0,0 +1,3 @@ + + + diff --git a/WordPress/src/jetpack/res/values/strings.xml b/WordPress/src/jetpack/res/values/strings.xml index a02db5a2fed7..90ded09c7bf5 100644 --- a/WordPress/src/jetpack/res/values/strings.xml +++ b/WordPress/src/jetpack/res/values/strings.xml @@ -6,6 +6,9 @@ Jetpack for Android + + Welcome to Jetpack + Site security and performance from your pocket Log in with WordPress.com diff --git a/WordPress/src/jetpack/res/xml/shortcuts.xml b/WordPress/src/jetpack/res/xml/shortcuts.xml index 77a2fd8ed7ec..f8c72f5e977c 100644 --- a/WordPress/src/jetpack/res/xml/shortcuts.xml +++ b/WordPress/src/jetpack/res/xml/shortcuts.xml @@ -34,7 +34,7 @@ android:icon="@drawable/ic_shortcut_create_post" android:shortcutId="new_post" android:shortcutShortLabel="@string/new_post" - android:enabled="false"> + android:enabled="true"> + android:enabled="true"> + android:enabled="true"> oldSitesIds, - boolean isJetpackApp + boolean isSiteCreationEnabled ) { Intent intent = new Intent(activity, LoginEpilogueActivity.class); intent.putExtra(LoginEpilogueActivity.EXTRA_DO_LOGIN_UPDATE, doLoginUpdate); intent.putIntegerArrayListExtra(LoginEpilogueActivity.ARG_OLD_SITES_IDS, oldSitesIds); - if (!isJetpackApp) { + if (isSiteCreationEnabled) { activity.startActivityForResult(intent, RequestCodes.LOGIN_EPILOGUE); } else { activity.startActivity(intent); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java index cdfd34c94cf2..2db542a7671f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java @@ -70,6 +70,7 @@ import org.wordpress.android.ui.reader.services.update.ReaderUpdateServiceStarter; import org.wordpress.android.util.AppLog; import org.wordpress.android.util.AppLog.T; +import org.wordpress.android.util.BuildConfigWrapper; import org.wordpress.android.util.SelfSignedSSLUtils; import org.wordpress.android.util.StringUtils; import org.wordpress.android.util.ToastUtils; @@ -132,6 +133,7 @@ private enum SmartLockHelperState { @Inject UnifiedLoginTracker mUnifiedLoginTracker; @Inject protected SiteStore mSiteStore; @Inject protected ViewModelProvider.Factory mViewModelFactory; + @Inject BuildConfigWrapper mBuildConfigWrapper; @Override protected void onCreate(Bundle savedInstanceState) { @@ -158,7 +160,7 @@ protected void onCreate(Bundle savedInstanceState) { break; case JETPACK_LOGIN_ONLY: mUnifiedLoginTracker.setSource(Source.DEFAULT); - mIsSignupFromLoginEnabled = false; + mIsSignupFromLoginEnabled = mBuildConfigWrapper.isSignupEnabled(); loginFromPrologue(); break; case WPCOM_LOGIN_ONLY: @@ -305,10 +307,19 @@ public LoginMode getLoginMode() { private void loggedInAndFinish(ArrayList oldSitesIds, boolean doLoginUpdate) { switch (getLoginMode()) { case JETPACK_LOGIN_ONLY: - if (!mSiteStore.hasSite()) { + if (!mSiteStore.hasSite() && !mBuildConfigWrapper.isSiteCreationEnabled()) { handleNoJetpackSites(); } else { - ActivityLauncher.showMainActivityAndLoginEpilogue(this, oldSitesIds, doLoginUpdate); + if (!mSiteStore.hasSite() + && AppPrefs.shouldShowPostSignupInterstitial() + && !doLoginUpdate + && mBuildConfigWrapper.isSiteCreationEnabled() + && mBuildConfigWrapper.isSignupEnabled() + ) { + ActivityLauncher.showPostSignupInterstitial(this); + } else { + ActivityLauncher.showMainActivityAndLoginEpilogue(this, oldSitesIds, doLoginUpdate); + } setResult(Activity.RESULT_OK); finish(); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueViewModel.kt index fa2903de3d22..565ef74fd283 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginEpilogueViewModel.kt @@ -31,10 +31,10 @@ class LoginEpilogueViewModel @Inject constructor( } private fun handleNoSitesFound() { - if (buildConfigWrapper.isJetpackApp) { + if (buildConfigWrapper.isJetpackApp && !buildConfigWrapper.isSiteCreationEnabled) { _navigationEvents.postValue(Event(LoginNavigationEvents.ShowNoJetpackSites)) } else { - if (appPrefsWrapper.shouldShowPostSignupInterstitial) { + if (appPrefsWrapper.shouldShowPostSignupInterstitial && buildConfigWrapper.isSignupEnabled) { _navigationEvents.postValue(Event(LoginNavigationEvents.ShowPostSignupInterstitialScreen)) } _navigationEvents.postValue(Event(LoginNavigationEvents.CloseWithResultOk)) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginEpilogueFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginEpilogueFragment.java index cc0a466b9887..469916a7c951 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginEpilogueFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginEpilogueFragment.java @@ -121,7 +121,7 @@ && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PO } private boolean isNewLoginEpilogueScreenEnabled() { - return !mBuildConfigWrapper.isJetpackApp() + return mBuildConfigWrapper.isSiteCreationEnabled() && !mShowAndReturn; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java index 22196f81bc05..4f5501918371 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerActivity.java @@ -50,6 +50,7 @@ import org.wordpress.android.util.AccessibilityUtils; import org.wordpress.android.util.ActivityUtils; import org.wordpress.android.util.AppLog; +import org.wordpress.android.util.BuildConfigWrapper; import org.wordpress.android.util.DeviceUtils; import org.wordpress.android.util.NetworkUtils; import org.wordpress.android.util.SiteUtils; @@ -116,6 +117,7 @@ public class SitePickerActivity extends LocaleAwareActivity @Inject Dispatcher mDispatcher; @Inject StatsStore mStatsStore; @Inject ViewModelProvider.Factory mViewModelFactory; + @Inject BuildConfigWrapper mBuildConfigWrapper; @Override public void onCreate(Bundle savedInstanceState) { @@ -241,7 +243,7 @@ private void updateMenuItemVisibility() { } else { // don't allow editing visibility unless there are multiple wp.com and jetpack sites mMenuEdit.setVisible(mSiteStore.getSitesAccessedViaWPComRestCount() > 1); - mMenuAdd.setVisible(!BuildConfig.IS_JETPACK_APP); + mMenuAdd.setVisible(mBuildConfigWrapper.isSiteCreationEnabled()); } // no point showing search if there aren't multiple blogs @@ -753,18 +755,26 @@ public void onDestroyActionMode(ActionMode actionMode) { } } - public static void addSite(Activity activity, boolean isSignedInWpCom) { - // if user is signed into wp.com use the dialog to enable choosing whether to - // create a new wp.com blog or add a self-hosted one - if (isSignedInWpCom) { - DialogFragment dialog = new AddSiteDialog(); - dialog.show(activity.getFragmentManager(), AddSiteDialog.ADD_SITE_DIALOG_TAG); + public static void addSite(Activity activity, boolean hasAccessToken) { + if (hasAccessToken) { + if (!BuildConfig.ENABLE_ADD_SELF_HOSTED_SITE) { + ActivityLauncher.newBlogForResult(activity); + } else { + // user is signed into wordpress app, so use the dialog to enable choosing whether to + // create a new wp.com blog or add a self-hosted one + showAddSiteDialog(activity); + } } else { - // user isn't signed into wp.com, so simply enable adding self-hosted + // user doesn't have an access token, so simply enable adding self-hosted ActivityLauncher.addSelfHostedSiteForResult(activity); } } + private static void showAddSiteDialog(Activity activity) { + DialogFragment dialog = new AddSiteDialog(); + dialog.show(activity.getFragmentManager(), AddSiteDialog.ADD_SITE_DIALOG_TAG); + } + /* * dialog which appears after user taps "Add site" - enables choosing whether to create * a new wp.com blog or add an existing self-hosted one diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerAdapter.java b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerAdapter.java index 274383aea193..d43b0a190274 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerAdapter.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/SitePickerAdapter.java @@ -472,7 +472,7 @@ private boolean isValidPosition(int position) { } private boolean isNewLoginEpilogueScreenEnabled() { - return !mBuildConfigWrapper.isJetpackApp() + return mBuildConfigWrapper.isSiteCreationEnabled() && !mShowAndReturn; } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java index 75d095f2c429..eaa2998b07d1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainActivity.java @@ -380,7 +380,7 @@ && getIntent().getExtras().getBoolean(ARG_CONTINUE_JETPACK_CONNECT, false)) { this, getIntent().getBooleanExtra(ARG_DO_LOGIN_UPDATE, false), getIntent().getIntegerArrayListExtra(ARG_OLD_SITES_IDS), - mBuildConfigWrapper.isJetpackApp() + mBuildConfigWrapper.isSiteCreationEnabled() ); } else if (getIntent().getBooleanExtra(ARG_SHOW_SIGNUP_EPILOGUE, false) && savedInstanceState == null) { canShowAppRatingPrompt = false; @@ -1279,7 +1279,7 @@ public void onAuthenticationChanged(OnAuthenticationChanged event) { this, true, getIntent().getIntegerArrayListExtra(ARG_OLD_SITES_IDS), - mBuildConfigWrapper.isJetpackApp() + mBuildConfigWrapper.isSiteCreationEnabled() ); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainNavigationView.kt b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainNavigationView.kt index 3b65d7c6a325..e051833ee600 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainNavigationView.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/main/WPMainNavigationView.kt @@ -80,7 +80,7 @@ class WPMainNavigationView @JvmOverloads constructor( // overlay each item with our custom view val menuView = getChildAt(0) as BottomNavigationMenuView - if (BuildConfig.IS_JETPACK_APP) hideReaderTab() + if (!BuildConfig.ENABLE_READER) hideReaderTab() val inflater = LayoutInflater.from(context) for (i in 0 until menu.size()) { @@ -315,7 +315,7 @@ class WPMainNavigationView @JvmOverloads constructor( } companion object { - private val pages = if (BuildConfig.IS_JETPACK_APP) listOf(MY_SITE, NOTIFS) else listOf(MY_SITE, READER, NOTIFS) + private val pages = if (BuildConfig.ENABLE_READER) listOf(MY_SITE, READER, NOTIFS) else listOf(MY_SITE, NOTIFS) private const val TAG_MY_SITE = "tag-mysite" private const val TAG_READER = "tag-reader" diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteFragment.kt index 186bc8752813..24c966f6993b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteFragment.kt @@ -304,7 +304,7 @@ class MySiteFragment : Fragment(R.layout.my_site_fragment), action.site, CTA_DOMAIN_CREDIT_REDEMPTION ) - is SiteNavigationAction.AddNewSite -> SitePickerActivity.addSite(activity, action.isSignedInWpCom) + is SiteNavigationAction.AddNewSite -> SitePickerActivity.addSite(activity, action.hasAccessToken) is SiteNavigationAction.ShowQuickStartDialog -> showQuickStartDialog( action.title, action.message, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt index 3771cbff5500..1779964ab17b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt @@ -68,6 +68,7 @@ import org.wordpress.android.ui.posts.BasicDialogViewModel.DialogInteraction.Dis import org.wordpress.android.ui.posts.BasicDialogViewModel.DialogInteraction.Negative import org.wordpress.android.ui.posts.BasicDialogViewModel.DialogInteraction.Positive import org.wordpress.android.ui.utils.UiString.UiStringRes +import org.wordpress.android.util.BuildConfigWrapper import org.wordpress.android.util.DisplayUtilsWrapper import org.wordpress.android.util.FluxCUtilsWrapper import org.wordpress.android.util.MediaUtilsWrapper @@ -121,7 +122,8 @@ class MySiteViewModel @Inject constructor( private val mySiteSourceManager: MySiteSourceManager, private val cardsTracker: CardsTracker, private val siteItemsTracker: SiteItemsTracker, - private val domainRegistrationCardShownTracker: DomainRegistrationCardShownTracker + private val domainRegistrationCardShownTracker: DomainRegistrationCardShownTracker, + private val buildConfigWrapper: BuildConfigWrapper ) : ScopedViewModel(mainDispatcher) { private val _onSnackbarMessage = MutableLiveData>() private val _onTechInputDialogShown = MutableLiveData>() @@ -345,7 +347,8 @@ class MySiteViewModel @Inject constructor( private fun buildNoSiteState(): NoSites { // Hide actionable empty view image when screen height is under specified min height. - val shouldShowImage = displayUtilsWrapper.getDisplayPixelHeight() >= MIN_DISPLAY_PX_HEIGHT_NO_SITE_IMAGE + val shouldShowImage = !buildConfigWrapper.isJetpackApp && + displayUtilsWrapper.getDisplayPixelHeight() >= MIN_DISPLAY_PX_HEIGHT_NO_SITE_IMAGE return NoSites(shouldShowImage) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/SiteNavigationAction.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/SiteNavigationAction.kt index 09c0196eeb0e..821409be1617 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/SiteNavigationAction.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/SiteNavigationAction.kt @@ -52,7 +52,7 @@ sealed class SiteNavigationAction { ) : SiteNavigationAction() data class OpenDomainRegistration(val site: SiteModel) : SiteNavigationAction() - data class AddNewSite(val isSignedInWpCom: Boolean) : SiteNavigationAction() + data class AddNewSite(val hasAccessToken: Boolean) : SiteNavigationAction() data class ShowQuickStartDialog( @StringRes val title: Int, @StringRes val message: Int, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/CardsBuilder.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/CardsBuilder.kt index 3f76cd90c321..38fc9a11df5f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/CardsBuilder.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/CardsBuilder.kt @@ -36,7 +36,7 @@ class CardsBuilder @Inject constructor( ): List { val cards = mutableListOf() cards.add(siteInfoCardBuilder.buildSiteInfoCard(siteInfoCardBuilderParams)) - if (!buildConfigWrapper.isJetpackApp) { + if (buildConfigWrapper.isQuickActionEnabled) { cards.add(quickActionsCardBuilder.build(quickActionsCardBuilderParams)) } if (domainRegistrationCardBuilderParams.isDomainCreditAvailable) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragmentPage.kt b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragmentPage.kt index f48d61bf8f2d..05f76fb726f0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragmentPage.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/notifications/NotificationsListFragmentPage.kt @@ -358,10 +358,10 @@ class NotificationsListFragmentPage : ViewPagerFragment(R.layout.notifications_l } else -> titleResId = R.string.notifications_empty_list } - if (BuildConfig.IS_JETPACK_APP) { - showEmptyView(titleResId) - } else { + if (BuildConfig.ENABLE_READER) { showEmptyView(titleResId, descriptionResId, buttonResId) + } else { + showEmptyView(titleResId) } actionableEmptyView.image.visibility = if (DisplayUtils.isLandscape(context)) View.GONE else View.VISIBLE } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java index f18d52433f86..ae291205ed82 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/AppSettingsFragment.java @@ -296,7 +296,7 @@ public void onWhatsNewFetched(OnWhatsNewFetched event) { WhatsNewAnnouncementModel latestAnnouncement = event.getWhatsNewItems().get(0); mWhatsNew.setSummary(getString(R.string.version_with_name_param, latestAnnouncement.getAppVersionName())); mWhatsNew.setOnPreferenceClickListener(this); - if (!BuildConfig.IS_JETPACK_APP) { + if (mBuildConfigWrapper.isWhatsNewFeatureEnabled()) { addWhatsNewPreference(); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsFragment.java index 387001c0abc3..e92eb3fa9709 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/prefs/notifications/NotificationsSettingsFragment.java @@ -147,7 +147,7 @@ public void onCreate(Bundle savedInstanceState) { addPreferencesFromResource(R.xml.notifications_settings); setHasOptionsMenu(true); removeSightAndSoundsForAPI26(); - removeFollowedBlogsPreferenceForJetpackApp(); + removeFollowedBlogsPreferenceForIfDisabled(); // Bump Analytics if (savedInstanceState == null) { @@ -169,8 +169,8 @@ private void removeSightAndSoundsForAPI26() { } } - private void removeFollowedBlogsPreferenceForJetpackApp() { - if (mBuildConfigWrapper.isJetpackApp()) { + private void removeFollowedBlogsPreferenceForIfDisabled() { + if (!mBuildConfigWrapper.isFollowedSitesSettingsEnabled()) { PreferenceScreen preferenceScreen = (PreferenceScreen) findPreference(getActivity().getString(R.string.wp_pref_notifications_root)); diff --git a/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt b/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt index e75f7e892f1d..ad23f7f91b44 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt @@ -19,4 +19,16 @@ class BuildConfigWrapper @Inject constructor() { fun isDebugSettingsEnabled(): Boolean = BuildConfig.ENABLE_DEBUG_SETTINGS val isJetpackApp = BuildConfig.IS_JETPACK_APP + + val isSiteCreationEnabled = BuildConfig.ENABLE_SITE_CREATION + + val isSignupEnabled = BuildConfig.ENABLE_SIGNUP + + val isCreateFabEnabled = BuildConfig.ENABLE_CREATE_FAB + + val isQuickActionEnabled = BuildConfig.ENABLE_QUICK_ACTION + + val isFollowedSitesSettingsEnabled = BuildConfig.ENABLE_FOLLOWED_SITES_SETTINGS + + val isWhatsNewFeatureEnabled = BuildConfig.ENABLE_WHATS_NEW_FEATURE } diff --git a/WordPress/src/main/java/org/wordpress/android/util/SiteUtils.java b/WordPress/src/main/java/org/wordpress/android/util/SiteUtils.java index fa56cc989a8a..6bf78fcaa90a 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/SiteUtils.java +++ b/WordPress/src/main/java/org/wordpress/android/util/SiteUtils.java @@ -6,7 +6,6 @@ import androidx.annotation.Nullable; import org.jetbrains.annotations.NotNull; -import org.wordpress.android.BuildConfig; import org.wordpress.android.WordPress; import org.wordpress.android.analytics.AnalyticsTracker.Stat; import org.wordpress.android.fluxc.Dispatcher; @@ -387,7 +386,6 @@ public static boolean isScanEnabled(boolean scanPurchased, SiteModel site) { @NonNull public static FetchSitesPayload getFetchSitesPayload() { ArrayList siteFilters = new ArrayList<>(); - if (BuildConfig.IS_JETPACK_APP) siteFilters.add(SiteFilter.JETPACK); return new FetchSitesPayload(siteFilters); } } diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModel.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModel.kt index 371bc442fd65..92e4321d7455 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModel.kt @@ -204,7 +204,7 @@ class WPMainActivityViewModel @Inject constructor( } fun onPageChanged(isOnMySitePageWithValidSite: Boolean, site: SiteModel?) { - val showFab = if (buildConfigWrapper.isJetpackApp) false else isOnMySitePageWithValidSite + val showFab = if (buildConfigWrapper.isCreateFabEnabled) isOnMySitePageWithValidSite else false setMainFabUiState(showFab, site) } @@ -224,15 +224,14 @@ class WPMainActivityViewModel @Inject constructor( } fun onResume(site: SiteModel?, isOnMySitePageWithValidSite: Boolean) { - val showFab = if (buildConfigWrapper.isJetpackApp) false else isOnMySitePageWithValidSite + val showFab = if (buildConfigWrapper.isCreateFabEnabled) isOnMySitePageWithValidSite else false setMainFabUiState(showFab, site) - checkAndShowFeatureAnnouncementForWordPressApp() + checkAndShowFeatureAnnouncement() } - private fun checkAndShowFeatureAnnouncementForWordPressApp() { - // Do not proceed with feature announcement check for Jetpack - if (!buildConfigWrapper.isJetpackApp) { + private fun checkAndShowFeatureAnnouncement() { + if (buildConfigWrapper.isWhatsNewFeatureEnabled) { launch { val currentVersionCode = buildConfigWrapper.getAppVersionCode() val previousVersionCode = appPrefsWrapper.lastFeatureAnnouncementAppVersionCode diff --git a/WordPress/src/main/res/drawable/img_post_signup_interstitial_screen.xml b/WordPress/src/main/res/drawable/img_post_signup_interstitial_screen.xml new file mode 100644 index 000000000000..b864828922c3 --- /dev/null +++ b/WordPress/src/main/res/drawable/img_post_signup_interstitial_screen.xml @@ -0,0 +1,3 @@ + + + diff --git a/WordPress/src/main/res/layout/post_signup_interstitial_default.xml b/WordPress/src/main/res/layout/post_signup_interstitial_default.xml index 8a94f2225324..95246f6eb896 100644 --- a/WordPress/src/main/res/layout/post_signup_interstitial_default.xml +++ b/WordPress/src/main/res/layout/post_signup_interstitial_default.xml @@ -12,7 +12,7 @@ android:layout_height="wrap_content" android:layout_marginBottom="@dimen/margin_extra_medium_large" android:contentDescription="@string/content_description_person_building_website" - android:src="@drawable/img_illustration_construct_site_190dp" + android:src="@drawable/img_post_signup_interstitial_screen" app:layout_constraintBottom_toTopOf="@+id/title_view" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" diff --git a/WordPress/src/main/res/layout/post_signup_interstitial_landscape.xml b/WordPress/src/main/res/layout/post_signup_interstitial_landscape.xml index e379f4a48d23..14137fddd7b1 100644 --- a/WordPress/src/main/res/layout/post_signup_interstitial_landscape.xml +++ b/WordPress/src/main/res/layout/post_signup_interstitial_landscape.xml @@ -12,7 +12,7 @@ android:layout_height="wrap_content" android:layout_marginEnd="@dimen/margin_extra_extra_large" android:contentDescription="@string/content_description_person_building_website" - android:src="@drawable/img_illustration_construct_site_190dp" + android:src="@drawable/img_post_signup_interstitial_screen" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/guideline" app:layout_constraintStart_toStartOf="parent" diff --git a/WordPress/src/test/java/org/wordpress/android/ui/accounts/LoginEpilogueViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/accounts/LoginEpilogueViewModelTest.kt index 6ecd120b6dbe..75e85169806f 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/accounts/LoginEpilogueViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/accounts/LoginEpilogueViewModelTest.kt @@ -134,20 +134,20 @@ class LoginEpilogueViewModelTest : BaseUnitTest() { assertThat(navigationEvents.last()).isInstanceOf(LoginNavigationEvents.CloseWithResultOk::class.java) } - /* Jetpack app - No Jetpack Sites Screen */ + /* Jetpack app - Epilogue Screen OnResume/ Login Finish */ @Test - fun `given jetpack app with no sites, when continued from epilogue, then no jetpack sites is shown`() { - init(isJetpackApp = true, hasSite = false) + fun `given jp app no site + create site enabled, when screen shown, then screen closes with ok result`() { + init(isJetpackApp = true, hasSite = false, isSiteCreationEnabled = true) val navigationEvents = initObservers().navigationEvents - viewModel.onContinue() + viewModel.onLoginEpilogueResume(doLoginUpdate = false) - assertThat(navigationEvents.last()).isInstanceOf(LoginNavigationEvents.ShowNoJetpackSites::class.java) + assertThat(navigationEvents.last()).isInstanceOf(LoginNavigationEvents.CloseWithResultOk::class.java) } @Test - fun `given jp app with no sites + login update not requested, when screen shown, then no jp sites shown`() { - init(isJetpackApp = true, hasSite = false) + fun `given jp app no site + no login update + create site disabled, when screen shown, then no jp site shown`() { + init(isJetpackApp = true, hasSite = false, isSiteCreationEnabled = false) val navigationEvents = initObservers().navigationEvents viewModel.onLoginEpilogueResume(doLoginUpdate = false) @@ -156,8 +156,8 @@ class LoginEpilogueViewModelTest : BaseUnitTest() { } @Test - fun `given jp app with no sites + login update requested, when screen shown, then no jp sites not shown`() { - init(isJetpackApp = true, hasSite = false) + fun `given jp app no site + login update + create site disabled, when screen shown, then no jp site not shown`() { + init(isJetpackApp = true, hasSite = false, isSiteCreationEnabled = false) val navigationEvents = initObservers().navigationEvents viewModel.onLoginEpilogueResume(doLoginUpdate = true) @@ -168,8 +168,8 @@ class LoginEpilogueViewModelTest : BaseUnitTest() { } @Test - fun `given jp app with no site + login update requested, when login finishes, then no jp sites shown`() { - init(isJetpackApp = true, hasSite = false) + fun `given jp app no site + do login update + create site disabled, when login finishes, then no jp site shown`() { + init(isJetpackApp = true, hasSite = false, isSiteCreationEnabled = false) val navigationEvents = initObservers().navigationEvents viewModel.onLoginFinished(doLoginUpdate = true) @@ -177,10 +177,68 @@ class LoginEpilogueViewModelTest : BaseUnitTest() { assertThat(navigationEvents.first()).isInstanceOf(LoginNavigationEvents.ShowNoJetpackSites::class.java) } - /* Jetpack app - Epilogue Screen Close On Continue */ + /* Jetpack app - Epilogue Screen On Continue */ + @Test + fun `given jp app no site + signup disabled, when continued, then screen closes with ok result`() { + init( + isJetpackApp = true, + hasSite = false, + isSiteCreationEnabled = true, + isSignupEnabled = false + ) + val navigationEvents = initObservers().navigationEvents + + viewModel.onContinue() + + assertThat(navigationEvents.first()).isInstanceOf(LoginNavigationEvents.CloseWithResultOk::class.java) + } + @Test - fun `given jetpack app with sites, when continued from epilogue, then screen closes with ok result`() { - init(isJetpackApp = true, hasSite = true) + fun `given jp app no site + signup enabled, when continued 1st time, then signup interstitial shown`() { + init( + isJetpackApp = true, + hasSite = false, + isSiteCreationEnabled = true, + isSignupEnabled = true, + postSignupInterstitialShownEarlier = false + ) + val navigationEvents = initObservers().navigationEvents + + viewModel.onContinue() + + assertThat(navigationEvents.first()) + .isInstanceOf(LoginNavigationEvents.ShowPostSignupInterstitialScreen::class.java) + } + + @Test + fun `given jp app no site + signup enabled, when continued next time, then screen closes with ok result`() { + init( + isJetpackApp = true, + hasSite = false, + isSiteCreationEnabled = true, + isSignupEnabled = true, + postSignupInterstitialShownEarlier = true + ) + val navigationEvents = initObservers().navigationEvents + + viewModel.onContinue() + + assertThat(navigationEvents.first()).isInstanceOf(LoginNavigationEvents.CloseWithResultOk::class.java) + } + + @Test + fun `given jp app with sites, when continued, then screen closes with ok result`() { + init(isJetpackApp = true, hasSite = true, isSiteCreationEnabled = false) + val navigationEvents = initObservers().navigationEvents + + viewModel.onContinue() + + assertThat(navigationEvents.last()).isInstanceOf(LoginNavigationEvents.CloseWithResultOk::class.java) + } + + @Test + fun `given jp app no site + create site enabled, when continued, then screen closes with ok result`() { + init(isJetpackApp = true, hasSite = false, isSiteCreationEnabled = true) val navigationEvents = initObservers().navigationEvents viewModel.onContinue() @@ -188,6 +246,16 @@ class LoginEpilogueViewModelTest : BaseUnitTest() { assertThat(navigationEvents.last()).isInstanceOf(LoginNavigationEvents.CloseWithResultOk::class.java) } + @Test + fun `given jp app no site + create site disabled, when continued, then no jp site shown`() { + init(isJetpackApp = true, hasSite = false, isSiteCreationEnabled = false) + val navigationEvents = initObservers().navigationEvents + + viewModel.onContinue() + + assertThat(navigationEvents.last()).isInstanceOf(LoginNavigationEvents.ShowNoJetpackSites::class.java) + } + private data class Observers(val navigationEvents: List) private fun initObservers(): Observers { @@ -199,10 +267,14 @@ class LoginEpilogueViewModelTest : BaseUnitTest() { fun init( isJetpackApp: Boolean, + isSiteCreationEnabled: Boolean = true, + isSignupEnabled: Boolean = true, hasSite: Boolean = false, postSignupInterstitialShownEarlier: Boolean = false ) { whenever(buildConfigWrapper.isJetpackApp).thenReturn(isJetpackApp) + whenever(buildConfigWrapper.isSiteCreationEnabled).thenReturn(isSiteCreationEnabled) + whenever(buildConfigWrapper.isSignupEnabled).thenReturn(isSignupEnabled) whenever(siteStore.hasSite()).thenReturn(hasSite) whenever(appPrefsWrapper.shouldShowPostSignupInterstitial).thenReturn(!postSignupInterstitialShownEarlier) } diff --git a/WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt index d4aad03981ad..7d4dec519f76 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt @@ -34,12 +34,12 @@ import org.wordpress.android.analytics.AnalyticsTracker.Stat import org.wordpress.android.fluxc.model.DynamicCardType import org.wordpress.android.fluxc.model.PostModel import org.wordpress.android.fluxc.model.SiteModel +import org.wordpress.android.fluxc.model.dashboard.CardModel.PostsCardModel +import org.wordpress.android.fluxc.model.dashboard.CardModel.PostsCardModel.PostCardModel import org.wordpress.android.fluxc.model.experiments.Variation.Control import org.wordpress.android.fluxc.model.experiments.Variation.Treatment import org.wordpress.android.fluxc.model.page.PageModel import org.wordpress.android.fluxc.model.page.PageStatus.PUBLISHED -import org.wordpress.android.fluxc.model.dashboard.CardModel.PostsCardModel -import org.wordpress.android.fluxc.model.dashboard.CardModel.PostsCardModel.PostCardModel import org.wordpress.android.fluxc.store.AccountStore import org.wordpress.android.fluxc.store.QuickStartStore.QuickStartTask import org.wordpress.android.fluxc.store.QuickStartStore.QuickStartTaskType @@ -104,6 +104,7 @@ import org.wordpress.android.ui.utils.ListItemInteraction import org.wordpress.android.ui.utils.UiString.UiStringRes import org.wordpress.android.ui.utils.UiString.UiStringResWithParams import org.wordpress.android.ui.utils.UiString.UiStringText +import org.wordpress.android.util.BuildConfigWrapper import org.wordpress.android.util.DisplayUtilsWrapper import org.wordpress.android.util.FluxCUtilsWrapper import org.wordpress.android.util.MediaUtilsWrapper @@ -150,6 +151,7 @@ class MySiteViewModelTest : BaseUnitTest() { @Mock lateinit var cardsTracker: CardsTracker @Mock lateinit var siteItemsTracker: SiteItemsTracker @Mock lateinit var domainRegistrationCardShownTracker: DomainRegistrationCardShownTracker + @Mock lateinit var buildConfigWrapper: BuildConfigWrapper private lateinit var viewModel: MySiteViewModel private lateinit var uiModels: MutableList private lateinit var snackbars: MutableList @@ -298,7 +300,8 @@ class MySiteViewModelTest : BaseUnitTest() { mySiteSourceManager, cardsTracker, siteItemsTracker, - domainRegistrationCardShownTracker + domainRegistrationCardShownTracker, + buildConfigWrapper ) uiModels = mutableListOf() snackbars = mutableListOf() @@ -423,7 +426,8 @@ class MySiteViewModelTest : BaseUnitTest() { /* EMPTY VIEW */ @Test - fun `when no site is selected and screen height is higher than 600 pixels, show empty view image`() { + fun `given wp app, when no site is selected and screen height is higher than 600 pixels, show empty view image`() { + whenever(buildConfigWrapper.isJetpackApp).thenReturn(false) whenever(displayUtilsWrapper.getDisplayPixelHeight()).thenReturn(600) onSiteSelected.value = null @@ -433,7 +437,8 @@ class MySiteViewModelTest : BaseUnitTest() { } @Test - fun `when no site is selected and screen height is lower than 600 pixels, hide empty view image`() { + fun `given wp app, when no site is selected and screen height is lower than 600 pixels, hide empty view image`() { + whenever(buildConfigWrapper.isJetpackApp).thenReturn(false) whenever(displayUtilsWrapper.getDisplayPixelHeight()).thenReturn(500) onSiteSelected.value = null @@ -442,6 +447,16 @@ class MySiteViewModelTest : BaseUnitTest() { assertThat((uiModels.last().state as NoSites).shouldShowImage).isFalse } + @Test + fun `given jp app, when no site is selected, hide empty view image`() { + whenever(buildConfigWrapper.isJetpackApp).thenReturn(true) + + onSiteSelected.value = null + + assertThat(uiModels.last().state).isInstanceOf(NoSites::class.java) + assertThat((uiModels.last().state as NoSites).shouldShowImage).isFalse + } + /* EMPTY VIEW - ADD SITE */ @Test diff --git a/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/CardsBuilderTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/CardsBuilderTest.kt index a65db79229f3..25ddcc745a41 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/CardsBuilderTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/CardsBuilderTest.kt @@ -102,19 +102,19 @@ class CardsBuilderTest { /* QUICK ACTIONS CARD */ @Test - fun `when build is Jetpack, then quick action card is not built`() { - whenever(buildConfigWrapper.isJetpackApp).thenReturn(true) + fun `when quick action enabled, then quick action card is built`() { + whenever(buildConfigWrapper.isQuickActionEnabled).thenReturn(true) val cards = buildCards() - assertThat(cards.findQuickActionsCard()).isNull() + assertThat(cards.findQuickActionsCard()).isNotNull } @Test - fun `when build is WordPress, then quick action card is built`() { - whenever(buildConfigWrapper.isJetpackApp).thenReturn(false) + fun `when quick action disabled, then quick action card is not built`() { + whenever(buildConfigWrapper.isQuickActionEnabled).thenReturn(false) val cards = buildCards() - assertThat(cards.findQuickActionsCard()).isNotNull + assertThat(cards.findQuickActionsCard()).isNull() } /* QUICK START CARD */ diff --git a/WordPress/src/test/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModelTest.kt index d61ed0d0e737..92edc6605004 100644 --- a/WordPress/src/test/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModelTest.kt @@ -111,7 +111,7 @@ class WPMainActivityViewModelTest : BaseUnitTest() { /* FAB VISIBILITY */ @Test - fun `given wordpress app, when page changed to my site, then fab is visible`() { + fun `given fab enabled, when page changed to my site, then fab is visible`() { startViewModelWithDefaultParameters() viewModel.onPageChanged(isOnMySitePageWithValidSite = true, site = initSite(hasFullAccessToContent = true)) @@ -120,7 +120,7 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } @Test - fun `given wordpress app, when page changed away from my site, then fab is hidden`() { + fun `given fab enabled, when page changed away from my site, then fab is hidden`() { startViewModelWithDefaultParameters() viewModel.onPageChanged(isOnMySitePageWithValidSite = false, site = initSite(hasFullAccessToContent = true)) @@ -129,7 +129,7 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } @Test - fun `given wordpress app, when my site page is resumed, then fab is visible`() { + fun `given fab enabled, when my site page is resumed, then fab is visible`() { startViewModelWithDefaultParameters() viewModel.onResume(isOnMySitePageWithValidSite = true, site = initSite(hasFullAccessToContent = true)) @@ -138,7 +138,7 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } @Test - fun `given wordpress app, when non my site page is resumed, then fab is hidden`() { + fun `given fab enabled, when non my site page is resumed, then fab is hidden`() { startViewModelWithDefaultParameters() viewModel.onResume(isOnMySitePageWithValidSite = false, site = initSite(hasFullAccessToContent = true)) @@ -147,8 +147,8 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } @Test - fun `given jetpack app, when page changed to my site, then fab is hidden`() { - startViewModelWithDefaultParameters(isJetpackApp = true) + fun `given fab disabled, when page changed to my site, then fab is hidden`() { + startViewModelWithDefaultParameters(isCreateFabEnabled = false) viewModel.onPageChanged(isOnMySitePageWithValidSite = true, site = initSite(hasFullAccessToContent = true)) @@ -156,8 +156,8 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } @Test - fun `given jetpack app, when page changed away from my site, then fab is hidden`() { - startViewModelWithDefaultParameters(isJetpackApp = true) + fun `given fab disabled, when page changed away from my site, then fab is hidden`() { + startViewModelWithDefaultParameters(isCreateFabEnabled = false) viewModel.onPageChanged(isOnMySitePageWithValidSite = false, site = initSite(hasFullAccessToContent = true)) @@ -165,8 +165,8 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } @Test - fun `given jetpack app, when my site page is resumed, then fab is hidden`() { - startViewModelWithDefaultParameters(isJetpackApp = true) + fun `given fab disabled, when my site page is resumed, then fab is hidden`() { + startViewModelWithDefaultParameters(isCreateFabEnabled = false) viewModel.onResume(isOnMySitePageWithValidSite = true, site = initSite(hasFullAccessToContent = true)) @@ -174,8 +174,8 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } @Test - fun `given jetpack app, when non my site page is resumed, then fab is hidden`() { - startViewModelWithDefaultParameters(isJetpackApp = true) + fun `given fab disabled, when non my site page is resumed, then fab is hidden`() { + startViewModelWithDefaultParameters(isCreateFabEnabled = false) viewModel.onResume(isOnMySitePageWithValidSite = false, site = initSite(hasFullAccessToContent = true)) @@ -185,7 +185,7 @@ class WPMainActivityViewModelTest : BaseUnitTest() { /* FAB TOOLTIP VISIBILITY */ @Test - fun `given wordpress app, when page changed to my site, then fab tooltip is visible`() { + fun `given fab enabled, when page changed to my site, then fab tooltip is visible`() { startViewModelWithDefaultParameters() viewModel.onPageChanged(isOnMySitePageWithValidSite = true, site = initSite(hasFullAccessToContent = true)) @@ -194,7 +194,7 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } @Test - fun `given wordpress app, when page changed away from my site, then fab tooltip is hidden`() { + fun `given fab enabled, when page changed away from my site, then fab tooltip is hidden`() { startViewModelWithDefaultParameters() viewModel.onPageChanged(isOnMySitePageWithValidSite = false, site = initSite(hasFullAccessToContent = true)) @@ -203,7 +203,7 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } @Test - fun `given wordpress app, when my site page is resumed, then fab tooltip is visible`() { + fun `given fab enabled, when my site page is resumed, then fab tooltip is visible`() { startViewModelWithDefaultParameters() viewModel.onResume(isOnMySitePageWithValidSite = true, site = initSite(hasFullAccessToContent = true)) @@ -212,7 +212,7 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } @Test - fun `given wordpress app, when non my site page is resumed, then fab tooltip is hidden`() { + fun `given fab enabled, when non my site page is resumed, then fab tooltip is hidden`() { startViewModelWithDefaultParameters() viewModel.onResume(isOnMySitePageWithValidSite = false, site = initSite(hasFullAccessToContent = true)) @@ -221,8 +221,8 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } @Test - fun `given jetpack app, when page changed to my site, then fab tooltip is hidden`() { - startViewModelWithDefaultParameters(isJetpackApp = true) + fun `given fab disabled, when page changed to my site, then fab tooltip is hidden`() { + startViewModelWithDefaultParameters(isCreateFabEnabled = false) viewModel.onPageChanged(isOnMySitePageWithValidSite = true, site = initSite(hasFullAccessToContent = true)) @@ -230,8 +230,8 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } @Test - fun `given jetpack app, when page changed away from my site, then fab tooltip is hidden`() { - startViewModelWithDefaultParameters(isJetpackApp = true) + fun `given fab disabled, when page changed away from my site, then fab tooltip is hidden`() { + startViewModelWithDefaultParameters(isCreateFabEnabled = false) viewModel.onPageChanged(isOnMySitePageWithValidSite = false, site = initSite(hasFullAccessToContent = true)) @@ -239,8 +239,8 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } @Test - fun `given jetpack app, when my site page is resumed, then fab tooltip is hidden`() { - startViewModelWithDefaultParameters(isJetpackApp = true) + fun `given fab disabled, when my site page is resumed, then fab tooltip is hidden`() { + startViewModelWithDefaultParameters(isCreateFabEnabled = false) viewModel.onResume(isOnMySitePageWithValidSite = true, site = initSite(hasFullAccessToContent = true)) @@ -248,8 +248,8 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } @Test - fun `given jetpack app, when non my site page is resumed, then fab tooltip is hidden`() { - startViewModelWithDefaultParameters(isJetpackApp = true) + fun `given fab disabled, when non my site page is resumed, then fab tooltip is hidden`() { + startViewModelWithDefaultParameters(isCreateFabEnabled = false) viewModel.onResume(isOnMySitePageWithValidSite = false, site = initSite(hasFullAccessToContent = true)) @@ -584,22 +584,22 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } @Test - fun `given wordpress app, when app is launched, then feature announcement is shown`() = test { + fun `given whats new feature enabled, when app is launched, then feature announcement is shown`() = test { whenever(appPrefsWrapper.featureAnnouncementShownVersion).thenReturn(-1) whenever(appPrefsWrapper.lastFeatureAnnouncementAppVersionCode).thenReturn(840) whenever(featureAnnouncementProvider.getLatestFeatureAnnouncement(true)).thenReturn( featureAnnouncement ) - startViewModelWithDefaultParameters(false) + startViewModelWithDefaultParameters(true) resumeViewModelWithDefaultParameters() verify(onFeatureAnnouncementRequestedObserver).onChanged(anyOrNull()) } @Test - fun `given jetpack app, when app is launched, then feature announcement is not shown`() = test { - startViewModelWithDefaultParameters(true) + fun `given whats new feature disabled, when app is launched, then feature announcement is not shown`() = test { + startViewModelWithDefaultParameters(isWhatsNewFeatureEnabled = false) resumeViewModelWithDefaultParameters() verify(onFeatureAnnouncementRequestedObserver, never()).onChanged(anyOrNull()) @@ -655,8 +655,12 @@ class WPMainActivityViewModelTest : BaseUnitTest() { assertThat(viewModel.mainActions.value!!.map { it.actionType }).isEqualTo(expectedOrder) } - private fun startViewModelWithDefaultParameters(isJetpackApp: Boolean = false) { - whenever(buildConfigWrapper.isJetpackApp).thenReturn(isJetpackApp) + private fun startViewModelWithDefaultParameters( + isWhatsNewFeatureEnabled: Boolean = true, + isCreateFabEnabled: Boolean = true + ) { + whenever(buildConfigWrapper.isWhatsNewFeatureEnabled).thenReturn(isWhatsNewFeatureEnabled) + whenever(buildConfigWrapper.isCreateFabEnabled).thenReturn(isCreateFabEnabled) viewModel.start(site = initSite(hasFullAccessToContent = true, supportsStories = true)) } diff --git a/WordPress/src/testJetpack/java/org.wordpress.android/ui.accounts.login/LoginPrologueViewModelTest.kt b/WordPress/src/testJetpack/java/org.wordpress.android/ui.accounts.login/LoginPrologueViewModelTest.kt index 8f853fe70ddf..b93ad5a44837 100644 --- a/WordPress/src/testJetpack/java/org.wordpress.android/ui.accounts.login/LoginPrologueViewModelTest.kt +++ b/WordPress/src/testJetpack/java/org.wordpress.android/ui.accounts.login/LoginPrologueViewModelTest.kt @@ -1,5 +1,6 @@ package org.wordpress.android.ui.accounts.login +import com.nhaarman.mockitokotlin2.whenever import kotlinx.coroutines.InternalCoroutinesApi import org.assertj.core.api.Assertions.assertThat import org.junit.Before @@ -13,6 +14,7 @@ import org.wordpress.android.ui.accounts.LoginNavigationEvents.ShowEmailLoginScr import org.wordpress.android.ui.accounts.LoginNavigationEvents.ShowLoginViaSiteAddressScreen import org.wordpress.android.ui.accounts.UnifiedLoginTracker import org.wordpress.android.ui.accounts.login.LoginPrologueViewModel.UiState +import org.wordpress.android.util.BuildConfigWrapper import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper import org.wordpress.android.viewmodel.Event @@ -20,21 +22,38 @@ import org.wordpress.android.viewmodel.Event class LoginPrologueViewModelTest : BaseUnitTest() { @Mock lateinit var unifiedLoginTracker: UnifiedLoginTracker @Mock lateinit var analyticsTrackerWrapper: AnalyticsTrackerWrapper + @Mock lateinit var buildConfigWrapper: BuildConfigWrapper private lateinit var viewModel: LoginPrologueViewModel @Before fun setUp() { - viewModel = LoginPrologueViewModel(unifiedLoginTracker, analyticsTrackerWrapper, TEST_DISPATCHER) + viewModel = LoginPrologueViewModel( + unifiedLoginTracker, + analyticsTrackerWrapper, + buildConfigWrapper, + TEST_DISPATCHER + ) } @Test - fun `when view starts, then continue with wpcom button is displayed with correct title`() { + fun `given signup disabled, when view starts, then continue with wpcom button is displayed with correct title`() { + whenever(buildConfigWrapper.isSignupEnabled).thenReturn(false) val observers = init() assertThat(observers.uiStates.last().continueWithWpcomButtonState.title) .isEqualTo(R.string.continue_with_wpcom_no_signup) } + @Test + fun `given signup enabled, when view starts, then continue with wpcom button is displayed with correct title`() { + whenever(buildConfigWrapper.isSignupEnabled).thenReturn(true) + + val observers = init() + + assertThat(observers.uiStates.last().continueWithWpcomButtonState.title) + .isEqualTo(R.string.continue_with_wpcom) + } + @Test fun `when view starts, enter your site address button is displayed with correct title`() { val observers = init() diff --git a/build.gradle b/build.gradle index 827295852698..48e93696c5b4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ ext { coroutinesVersion = '1.5.2' wordPressUtilsVersion = 'trunk-9fc3b0acf0cfa44b743f3c5f8a65279c80cc00a3' - wordPressLoginVersion = 'trunk-3f8bfa7e2c5af8daa9ae1cfc391cd6c5fa0ca4d5' + wordPressLoginVersion = 'trunk-b751840af927f5182efd2e451717c93bd6f0a24a' gutenbergMobileVersion = 'v1.71.1' storiesVersion = '1.2.1' aboutAutomatticVersion = '0.0.4'