From d430673bb0b060422fdca48cd192014c46b9c9d3 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Wed, 9 Feb 2022 12:06:21 +0530 Subject: [PATCH 01/25] Remove Jetpack filtering for sites --- .../src/main/java/org/wordpress/android/util/SiteUtils.java | 2 -- 1 file changed, 2 deletions(-) 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); } } From a0f67dc129dd103396fcf52ff16ea38081afd50e Mon Sep 17 00:00:00 2001 From: ashiagr Date: Wed, 9 Feb 2022 12:30:34 +0530 Subject: [PATCH 02/25] Enable add new site menu for Jetpack app --- .../java/org/wordpress/android/ui/main/SitePickerActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..834070047920 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 @@ -241,7 +241,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(true); } // no point showing search if there aren't multiple blogs From 7ccd749782b49c8de9e07fff75a88501e26c645c Mon Sep 17 00:00:00 2001 From: ashiagr Date: Wed, 9 Feb 2022 15:39:10 +0530 Subject: [PATCH 03/25] Restrict adding self-hosted site in Jetpack app using add new site option --- .../android/ui/main/SitePickerActivity.java | 23 +++++++++++++------ .../android/ui/mysite/MySiteFragment.kt | 2 +- .../android/ui/mysite/SiteNavigationAction.kt | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) 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 834070047920..1fa28d917ef6 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 @@ -753,18 +753,27 @@ 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.IS_JETPACK_APP) { + // user is signed into jetpack app, so restrict showing option to 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/mysite/MySiteFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteFragment.kt index 2b66c5430982..b38d2e3d2a2c 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 @@ -303,7 +303,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/SiteNavigationAction.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/SiteNavigationAction.kt index dc0ee3380efb..c8b5b6abe960 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, From 85f767f0d511b7e9f16409d689709d9b7ac68985 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Wed, 9 Feb 2022 18:20:14 +0530 Subject: [PATCH 04/25] Update login lib version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3de098b5e83d..a800abf0286f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ ext { coroutinesVersion = '1.5.2' wordPressUtilsVersion = '2.3.0' - wordPressLoginVersion = '0.0.8' + wordPressLoginVersion = '79-cd431185a9642fa91a19523606cf44ab322e6917' gutenbergMobileVersion = 'v1.71.0' storiesVersion = '1.2.1' aboutAutomatticVersion = '0.0.4' From 200208fe9d2a39a1c2a7bb5d1f0546a1feb73489 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Thu, 10 Feb 2022 11:34:32 +0530 Subject: [PATCH 05/25] Enable add site menu using build config constant --- WordPress/build.gradle | 4 ++++ .../org/wordpress/android/ui/main/SitePickerActivity.java | 4 +++- .../java/org/wordpress/android/util/BuildConfigWrapper.kt | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 730eb02998b2..9e8cd15cf62c 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -117,6 +117,9 @@ 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" + manifestPlaceholders = [magicLinkScheme:"wordpress"] } @@ -151,6 +154,7 @@ android { applicationId "com.jetpack.android" buildConfigField "boolean", "IS_JETPACK_APP", "true" + buildConfigField "boolean", "ENABLE_SITE_CREATION", "true" buildConfigField "String", "TRACKS_EVENT_PREFIX", '"jpandroid_"' buildConfigField "String", "PUSH_NOTIFICATIONS_APP_KEY", '"com.jetpack.android"' 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 1fa28d917ef6..0e3d6810fa97 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(true); + mMenuAdd.setVisible(mBuildConfigWrapper.isSiteCreationEnabled()); } // no point showing search if there aren't multiple blogs 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..685152a2b7ce 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,6 @@ class BuildConfigWrapper @Inject constructor() { fun isDebugSettingsEnabled(): Boolean = BuildConfig.ENABLE_DEBUG_SETTINGS val isJetpackApp = BuildConfig.IS_JETPACK_APP + + val isSiteCreationEnabled = BuildConfig.ENABLE_SITE_CREATION } From 861ad82780a233c1d463fddf0289a41e32204db1 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Thu, 10 Feb 2022 10:59:47 +0530 Subject: [PATCH 06/25] Enable new login epilogue with create new site button using build config constant --- .../main/java/org/wordpress/android/ui/ActivityLauncher.java | 4 ++-- .../android/ui/accounts/login/LoginEpilogueFragment.java | 2 +- .../java/org/wordpress/android/ui/main/SitePickerAdapter.java | 2 +- .../java/org/wordpress/android/ui/main/WPMainActivity.java | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java b/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java index 8351a2898c8e..72fa4f336ad0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/ActivityLauncher.java @@ -1379,12 +1379,12 @@ public static void showLoginEpilogue( Activity activity, boolean doLoginUpdate, ArrayList 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/login/LoginEpilogueFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginEpilogueFragment.java index f2b49370e20c..18d513527fab 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 @@ -117,7 +117,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/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 8b6b52a711c9..68ac9b03eada 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 @@ -378,7 +378,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; @@ -1272,7 +1272,7 @@ public void onAuthenticationChanged(OnAuthenticationChanged event) { this, true, getIntent().getIntegerArrayListExtra(ARG_OLD_SITES_IDS), - mBuildConfigWrapper.isJetpackApp() + mBuildConfigWrapper.isSiteCreationEnabled() ); } } From 4519984a5067320cbb992bd140de5c4f65f641ab Mon Sep 17 00:00:00 2001 From: ashiagr Date: Thu, 10 Feb 2022 11:15:14 +0530 Subject: [PATCH 07/25] Restrict adding self-hosted site in Jetpack app using build config constant --- WordPress/build.gradle | 2 ++ .../java/org/wordpress/android/ui/main/SitePickerActivity.java | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 9e8cd15cf62c..91435b5038da 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -119,6 +119,7 @@ android { // 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" manifestPlaceholders = [magicLinkScheme:"wordpress"] } @@ -155,6 +156,7 @@ 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 "String", "TRACKS_EVENT_PREFIX", '"jpandroid_"' buildConfigField "String", "PUSH_NOTIFICATIONS_APP_KEY", '"com.jetpack.android"' 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 0e3d6810fa97..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 @@ -757,8 +757,7 @@ public void onDestroyActionMode(ActionMode actionMode) { public static void addSite(Activity activity, boolean hasAccessToken) { if (hasAccessToken) { - if (BuildConfig.IS_JETPACK_APP) { - // user is signed into jetpack app, so restrict showing option to add self-hosted site + 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 From 324f3a07183e806dd44d11451a6f8b47caab6570 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Thu, 10 Feb 2022 12:06:34 +0530 Subject: [PATCH 08/25] Add build constant to enable signup in Jetpack app --- WordPress/build.gradle | 2 ++ .../main/java/org/wordpress/android/util/BuildConfigWrapper.kt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 91435b5038da..92078f831180 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -120,6 +120,7 @@ android { // 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" manifestPlaceholders = [magicLinkScheme:"wordpress"] } @@ -157,6 +158,7 @@ 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 "String", "TRACKS_EVENT_PREFIX", '"jpandroid_"' buildConfigField "String", "PUSH_NOTIFICATIONS_APP_KEY", '"com.jetpack.android"' 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 685152a2b7ce..ae938c104324 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt @@ -21,4 +21,6 @@ class BuildConfigWrapper @Inject constructor() { val isJetpackApp = BuildConfig.IS_JETPACK_APP val isSiteCreationEnabled = BuildConfig.ENABLE_SITE_CREATION + + val isSignupEnabled = BuildConfig.ENABLE_SIGNUP } From c7b5e42f9591976e41b950e2405c858be13931a2 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Thu, 10 Feb 2022 12:10:05 +0530 Subject: [PATCH 09/25] Enable signup using build config constant --- .../accounts/login/LoginPrologueViewModel.kt | 18 +++++++++++---- .../android/ui/accounts/LoginActivity.java | 4 +++- .../LoginPrologueViewModelTest.kt | 23 +++++++++++++++++-- 3 files changed, 38 insertions(+), 7 deletions(-) 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/main/java/org/wordpress/android/ui/accounts/LoginActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/LoginActivity.java index 7696cdd25e6b..8c95d437c268 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: 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() From 4b7206fed4d69768231e0593e1d70581237e61e1 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Thu, 10 Feb 2022 14:59:08 +0530 Subject: [PATCH 10/25] Enable reader using build config constant --- WordPress/build.gradle | 2 ++ .../org/wordpress/android/ui/main/WPMainNavigationView.kt | 4 ++-- .../ui/notifications/NotificationsListFragmentPage.kt | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 92078f831180..98434589c493 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -121,6 +121,7 @@ android { buildConfigField "boolean", "ENABLE_SITE_CREATION", "true" buildConfigField "boolean", "ENABLE_ADD_SELF_HOSTED_SITE", "true" buildConfigField "boolean", "ENABLE_SIGNUP", "true" + buildConfigField "boolean", "ENABLE_READER", "true" manifestPlaceholders = [magicLinkScheme:"wordpress"] } @@ -159,6 +160,7 @@ android { 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 "String", "TRACKS_EVENT_PREFIX", '"jpandroid_"' buildConfigField "String", "PUSH_NOTIFICATIONS_APP_KEY", '"com.jetpack.android"' 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/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 } From 2cf853e6662c622449c4fc6ef6912c6d145702cc Mon Sep 17 00:00:00 2001 From: ashiagr Date: Thu, 10 Feb 2022 16:07:44 +0530 Subject: [PATCH 11/25] Enable create (page/post/story) FAB using build config constant --- WordPress/build.gradle | 2 + .../android/util/BuildConfigWrapper.kt | 2 + .../viewmodel/main/WPMainActivityViewModel.kt | 4 +- .../main/WPMainActivityViewModelTest.kt | 54 ++++++++++--------- 4 files changed, 35 insertions(+), 27 deletions(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 98434589c493..d33b0dfbb51e 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -122,6 +122,7 @@ android { buildConfigField "boolean", "ENABLE_ADD_SELF_HOSTED_SITE", "true" buildConfigField "boolean", "ENABLE_SIGNUP", "true" buildConfigField "boolean", "ENABLE_READER", "true" + buildConfigField "boolean", "ENABLE_CREATE_FAB", "true" manifestPlaceholders = [magicLinkScheme:"wordpress"] } @@ -161,6 +162,7 @@ android { 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 "String", "TRACKS_EVENT_PREFIX", '"jpandroid_"' buildConfigField "String", "PUSH_NOTIFICATIONS_APP_KEY", '"com.jetpack.android"' 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 ae938c104324..67cb22f7cefe 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt @@ -23,4 +23,6 @@ class BuildConfigWrapper @Inject constructor() { val isSiteCreationEnabled = BuildConfig.ENABLE_SITE_CREATION val isSignupEnabled = BuildConfig.ENABLE_SIGNUP + + val isCreateFabEnabled = BuildConfig.ENABLE_CREATE_FAB } 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..324846f314fd 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,7 +224,7 @@ 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() 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..c5d01f75c5b5 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)) @@ -655,8 +655,12 @@ class WPMainActivityViewModelTest : BaseUnitTest() { assertThat(viewModel.mainActions.value!!.map { it.actionType }).isEqualTo(expectedOrder) } - private fun startViewModelWithDefaultParameters(isJetpackApp: Boolean = false) { + private fun startViewModelWithDefaultParameters( + isJetpackApp: Boolean = false, + isCreateFabEnabled: Boolean = true + ) { whenever(buildConfigWrapper.isJetpackApp).thenReturn(isJetpackApp) + whenever(buildConfigWrapper.isCreateFabEnabled).thenReturn(isCreateFabEnabled) viewModel.start(site = initSite(hasFullAccessToContent = true, supportsStories = true)) } From 59613d3d1370364703d6eaeb94df4c8e3f51d456 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Thu, 10 Feb 2022 15:42:30 +0530 Subject: [PATCH 12/25] Enable quick action using build config constant --- WordPress/build.gradle | 2 ++ .../android/ui/mysite/cards/CardsBuilder.kt | 2 +- .../org/wordpress/android/util/BuildConfigWrapper.kt | 2 ++ .../android/ui/mysite/cards/CardsBuilderTest.kt | 12 ++++++------ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index d33b0dfbb51e..575cc5139425 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -123,6 +123,7 @@ android { buildConfigField "boolean", "ENABLE_SIGNUP", "true" buildConfigField "boolean", "ENABLE_READER", "true" buildConfigField "boolean", "ENABLE_CREATE_FAB", "true" + buildConfigField "boolean", "ENABLE_QUICK_ACTION", "true" manifestPlaceholders = [magicLinkScheme:"wordpress"] } @@ -163,6 +164,7 @@ android { buildConfigField "boolean", "ENABLE_SIGNUP", "true" buildConfigField "boolean", "ENABLE_READER", "true" buildConfigField "boolean", "ENABLE_CREATE_FAB", "true" + buildConfigField "boolean", "ENABLE_QUICK_ACTION", "true" buildConfigField "String", "TRACKS_EVENT_PREFIX", '"jpandroid_"' buildConfigField "String", "PUSH_NOTIFICATIONS_APP_KEY", '"com.jetpack.android"' 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/util/BuildConfigWrapper.kt b/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt index 67cb22f7cefe..391775e6ce5a 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt @@ -25,4 +25,6 @@ class BuildConfigWrapper @Inject constructor() { val isSignupEnabled = BuildConfig.ENABLE_SIGNUP val isCreateFabEnabled = BuildConfig.ENABLE_CREATE_FAB + + val isQuickActionEnabled = BuildConfig.ENABLE_QUICK_ACTION } 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 a4ea1f961ee4..b0751048d87a 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 @@ -101,19 +101,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 */ From 575e55ec87c966c7558129a663809b565ae97c77 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Thu, 10 Feb 2022 15:49:53 +0530 Subject: [PATCH 13/25] Enable followed sites settings using build config constant --- WordPress/build.gradle | 2 ++ .../prefs/notifications/NotificationsSettingsFragment.java | 6 +++--- .../java/org/wordpress/android/util/BuildConfigWrapper.kt | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 575cc5139425..274e9a30b7e2 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -124,6 +124,7 @@ android { buildConfigField "boolean", "ENABLE_READER", "true" buildConfigField "boolean", "ENABLE_CREATE_FAB", "true" buildConfigField "boolean", "ENABLE_QUICK_ACTION", "true" + buildConfigField "boolean", "ENABLE_FOLLOWED_SITES_SETTINGS", "true" manifestPlaceholders = [magicLinkScheme:"wordpress"] } @@ -165,6 +166,7 @@ android { 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 "String", "TRACKS_EVENT_PREFIX", '"jpandroid_"' buildConfigField "String", "PUSH_NOTIFICATIONS_APP_KEY", '"com.jetpack.android"' 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 391775e6ce5a..ebfafe910dea 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt @@ -27,4 +27,6 @@ class BuildConfigWrapper @Inject constructor() { val isCreateFabEnabled = BuildConfig.ENABLE_CREATE_FAB val isQuickActionEnabled = BuildConfig.ENABLE_QUICK_ACTION + + val isFollowedSitesSettingsEnabled = BuildConfig.ENABLE_FOLLOWED_SITES_SETTINGS } From aec0761b32d635fa25eb2c2083ec7cf859d6d6aa Mon Sep 17 00:00:00 2001 From: ashiagr Date: Thu, 10 Feb 2022 16:24:41 +0530 Subject: [PATCH 14/25] Enable feature announcement using build config constant --- WordPress/build.gradle | 2 ++ .../org/wordpress/android/util/BuildConfigWrapper.kt | 2 ++ .../viewmodel/main/WPMainActivityViewModel.kt | 7 +++---- .../viewmodel/main/WPMainActivityViewModelTest.kt | 12 ++++++------ 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 274e9a30b7e2..cce09216dfe8 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -125,6 +125,7 @@ android { 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"] } @@ -167,6 +168,7 @@ android { 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/main/java/org/wordpress/android/util/BuildConfigWrapper.kt b/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt index ebfafe910dea..ad23f7f91b44 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt @@ -29,4 +29,6 @@ class BuildConfigWrapper @Inject constructor() { 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/viewmodel/main/WPMainActivityViewModel.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModel.kt index 324846f314fd..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 @@ -227,12 +227,11 @@ class WPMainActivityViewModel @Inject constructor( 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/test/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/viewmodel/main/WPMainActivityViewModelTest.kt index c5d01f75c5b5..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 @@ -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()) @@ -656,10 +656,10 @@ class WPMainActivityViewModelTest : BaseUnitTest() { } private fun startViewModelWithDefaultParameters( - isJetpackApp: Boolean = false, + isWhatsNewFeatureEnabled: Boolean = true, isCreateFabEnabled: Boolean = true ) { - whenever(buildConfigWrapper.isJetpackApp).thenReturn(isJetpackApp) + whenever(buildConfigWrapper.isWhatsNewFeatureEnabled).thenReturn(isWhatsNewFeatureEnabled) whenever(buildConfigWrapper.isCreateFabEnabled).thenReturn(isCreateFabEnabled) viewModel.start(site = initSite(hasFullAccessToContent = true, supportsStories = true)) } From 45748da1ece481896d71b2fcd7bb0f5190c10f1f Mon Sep 17 00:00:00 2001 From: ashiagr Date: Thu, 10 Feb 2022 16:48:26 +0530 Subject: [PATCH 15/25] Enable App Settings -> What's New using build config constant --- .../org/wordpress/android/ui/prefs/AppSettingsFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); } } From 1e19bf673fbdea97ec61288ea3bacb8e26432a29 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Thu, 10 Feb 2022 17:55:37 +0530 Subject: [PATCH 16/25] Enable shortcut for new post --- WordPress/src/jetpack/res/xml/shortcuts.xml | 2 +- WordPress/src/jetpackJalapeno/res/xml/shortcuts.xml | 2 +- WordPress/src/jetpackWasabi/res/xml/shortcuts.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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"> Date: Mon, 14 Feb 2022 15:59:12 +0530 Subject: [PATCH 17/25] Don't show no jetpack sites for jetpack app when site creation is enabled --- .../android/ui/accounts/LoginActivity.java | 2 +- .../ui/accounts/LoginEpilogueViewModel.kt | 2 +- .../ui/accounts/LoginEpilogueViewModelTest.kt | 50 +++++++++++++------ 3 files changed, 38 insertions(+), 16 deletions(-) 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 8c95d437c268..fc46ed04a85d 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 @@ -307,7 +307,7 @@ 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); 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..ed01e9eeb1ee 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,7 +31,7 @@ class LoginEpilogueViewModel @Inject constructor( } private fun handleNoSitesFound() { - if (buildConfigWrapper.isJetpackApp) { + if (buildConfigWrapper.isJetpackApp && !buildConfigWrapper.isSiteCreationEnabled) { _navigationEvents.postValue(Event(LoginNavigationEvents.ShowNoJetpackSites)) } else { if (appPrefsWrapper.shouldShowPostSignupInterstitial) { 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..92bb856bc3c5 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,20 @@ 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 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 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 + 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 +198,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 +219,12 @@ class LoginEpilogueViewModelTest : BaseUnitTest() { fun init( isJetpackApp: Boolean, + isSiteCreationEnabled: Boolean = true, hasSite: Boolean = false, postSignupInterstitialShownEarlier: Boolean = false ) { whenever(buildConfigWrapper.isJetpackApp).thenReturn(isJetpackApp) + whenever(buildConfigWrapper.isSiteCreationEnabled).thenReturn(isSiteCreationEnabled) whenever(siteStore.hasSite()).thenReturn(hasSite) whenever(appPrefsWrapper.shouldShowPostSignupInterstitial).thenReturn(!postSignupInterstitialShownEarlier) } From 92b851ecd7c805c10f0768dc489969aaf051c5a4 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Mon, 14 Feb 2022 16:29:54 +0530 Subject: [PATCH 18/25] Show post signup interstitial screen for Jetpack app when signup is enabled --- .../android/ui/accounts/LoginActivity.java | 11 +++- .../ui/accounts/LoginEpilogueViewModel.kt | 2 +- .../ui/accounts/LoginEpilogueViewModelTest.kt | 50 +++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) 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 fc46ed04a85d..8ab03da3739f 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 @@ -310,7 +310,16 @@ private void loggedInAndFinish(ArrayList oldSitesIds, boolean doLoginUp 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 ed01e9eeb1ee..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 @@ -34,7 +34,7 @@ class LoginEpilogueViewModel @Inject constructor( 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/test/java/org/wordpress/android/ui/accounts/LoginEpilogueViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/accounts/LoginEpilogueViewModelTest.kt index 92bb856bc3c5..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 @@ -178,6 +178,54 @@ class LoginEpilogueViewModelTest : BaseUnitTest() { } /* 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 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) @@ -220,11 +268,13 @@ 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) } From 950749c747e6504ebba7a0c80aee9608f039025f Mon Sep 17 00:00:00 2001 From: ashiagr Date: Mon, 14 Feb 2022 16:42:11 +0530 Subject: [PATCH 19/25] Replace app name on signup interstitial screen --- WordPress/src/jetpack/res/values/strings.xml | 3 +++ 1 file changed, 3 insertions(+) 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 From b63ce2d8ed7adb9209b679023a5070e5ba2d3621 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Mon, 14 Feb 2022 18:59:15 +0530 Subject: [PATCH 20/25] Add release notes --- RELEASE-NOTES.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 3b5833f12a2e..265875b0eeba 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -6,6 +6,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] 19.2 ----- From 1f7698212fcc8fdd35d024e8ab46729a94cf9d72 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Tue, 15 Feb 2022 11:12:23 +0530 Subject: [PATCH 21/25] Hide My Site empty view illustration with WordPress app icon in Jetpack app. --- .../android/ui/mysite/MySiteViewModel.kt | 9 ++++--- .../android/ui/mysite/MySiteViewModelTest.kt | 25 +++++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) 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 b9aa340ea2cd..8be93ac8f88c 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 @@ -17,8 +17,8 @@ import org.wordpress.android.analytics.AnalyticsTracker.Stat.MY_SITE_PULL_TO_REF import org.wordpress.android.fluxc.model.DynamicCardType import org.wordpress.android.fluxc.model.MediaModel import org.wordpress.android.fluxc.model.SiteModel -import org.wordpress.android.fluxc.model.experiments.Variation.Control import org.wordpress.android.fluxc.model.dashboard.CardModel.PostsCardModel +import org.wordpress.android.fluxc.model.experiments.Variation.Control import org.wordpress.android.fluxc.store.AccountStore import org.wordpress.android.fluxc.store.QuickStartStore.QuickStartTask import org.wordpress.android.fluxc.store.QuickStartStore.QuickStartTaskType @@ -66,6 +66,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 @@ -119,7 +120,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>() @@ -322,7 +324,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/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt index fde2f573f856..8359f3caea89 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 @@ -33,12 +33,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 @@ -101,6 +101,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 @@ -147,6 +148,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 @@ -293,7 +295,8 @@ class MySiteViewModelTest : BaseUnitTest() { mySiteSourceManager, cardsTracker, siteItemsTracker, - domainRegistrationCardShownTracker + domainRegistrationCardShownTracker, + buildConfigWrapper ) uiModels = mutableListOf() snackbars = mutableListOf() @@ -418,7 +421,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 @@ -428,7 +432,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 @@ -437,6 +442,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 From ef7b71136ff957960d9d87191b2f729df3e5ca64 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Tue, 15 Feb 2022 11:19:51 +0530 Subject: [PATCH 22/25] Fix ktlint issue --- .../java/org/wordpress/android/ui/mysite/MySiteViewModel.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 8be93ac8f88c..32135178d834 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 @@ -324,8 +324,8 @@ class MySiteViewModel @Inject constructor( private fun buildNoSiteState(): NoSites { // Hide actionable empty view image when screen height is under specified min height. - val shouldShowImage = !buildConfigWrapper.isJetpackApp - && 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) } From f2b93e41e6fbde9a147e95d6e58c10301dbc241c Mon Sep 17 00:00:00 2001 From: ashiagr Date: Thu, 17 Feb 2022 16:18:35 +0530 Subject: [PATCH 23/25] Add illustration for post signup interstitial screen --- .../res/drawable/img_illustration_construct_site_190dp.xml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 WordPress/src/jetpack/res/drawable/img_illustration_construct_site_190dp.xml diff --git a/WordPress/src/jetpack/res/drawable/img_illustration_construct_site_190dp.xml b/WordPress/src/jetpack/res/drawable/img_illustration_construct_site_190dp.xml new file mode 100644 index 000000000000..bdfca0289c56 --- /dev/null +++ b/WordPress/src/jetpack/res/drawable/img_illustration_construct_site_190dp.xml @@ -0,0 +1,3 @@ + + + From df5022c22c7ff4547720c7026140801f465d06b4 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Fri, 18 Feb 2022 17:29:20 +0530 Subject: [PATCH 24/25] Refactor: Use post signup interstitial screen img wrapping appropriate jp/ wp image for the screen. --- ..._site_190dp.xml => img_post_signup_interstitial_screen.xml} | 0 .../main/res/drawable/img_post_signup_interstitial_screen.xml | 3 +++ .../src/main/res/layout/post_signup_interstitial_default.xml | 2 +- .../src/main/res/layout/post_signup_interstitial_landscape.xml | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) rename WordPress/src/jetpack/res/drawable/{img_illustration_construct_site_190dp.xml => img_post_signup_interstitial_screen.xml} (100%) create mode 100644 WordPress/src/main/res/drawable/img_post_signup_interstitial_screen.xml diff --git a/WordPress/src/jetpack/res/drawable/img_illustration_construct_site_190dp.xml b/WordPress/src/jetpack/res/drawable/img_post_signup_interstitial_screen.xml similarity index 100% rename from WordPress/src/jetpack/res/drawable/img_illustration_construct_site_190dp.xml rename to WordPress/src/jetpack/res/drawable/img_post_signup_interstitial_screen.xml 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" From f552f2eaf0fab090f9bbe9d01b939a1225668507 Mon Sep 17 00:00:00 2001 From: ashiagr Date: Fri, 18 Feb 2022 17:46:03 +0530 Subject: [PATCH 25/25] Build: Update login lib hash --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8059eef0ccef..d7524c888598 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ ext { coroutinesVersion = '1.5.2' wordPressUtilsVersion = '2.3.0' - wordPressLoginVersion = '79-cd431185a9642fa91a19523606cf44ab322e6917' + wordPressLoginVersion = 'trunk-b751840af927f5182efd2e451717c93bd6f0a24a' gutenbergMobileVersion = 'v1.71.1' storiesVersion = '1.2.1' aboutAutomatticVersion = '0.0.4'