Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetpack App: Show all sites and allow site creation #15920

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ 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"

manifestPlaceholders = [magicLinkScheme:"wordpress"]
}

Expand Down Expand Up @@ -151,6 +155,8 @@ 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"'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1379,12 +1379,12 @@ public static void showLoginEpilogue(
Activity activity,
boolean doLoginUpdate,
ArrayList<Integer> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ && getResources().getConfiguration().orientation == Configuration.ORIENTATION_PO
}

private boolean isNewLoginEpilogueScreenEnabled() {
return !mBuildConfigWrapper.isJetpackApp()
return mBuildConfigWrapper.isSiteCreationEnabled()
&& !mShowAndReturn;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ private boolean isValidPosition(int position) {
}

private boolean isNewLoginEpilogueScreenEnabled() {
return !mBuildConfigWrapper.isJetpackApp()
return mBuildConfigWrapper.isSiteCreationEnabled()
&& !mShowAndReturn;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1272,7 +1272,7 @@ public void onAuthenticationChanged(OnAuthenticationChanged event) {
this,
true,
getIntent().getIntegerArrayListExtra(ARG_OLD_SITES_IDS),
mBuildConfigWrapper.isJetpackApp()
mBuildConfigWrapper.isSiteCreationEnabled()
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
ashiagr marked this conversation as resolved.
Show resolved Hide resolved
data class ShowQuickStartDialog(
@StringRes val title: Int,
@StringRes val message: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -387,7 +386,6 @@ public static boolean isScanEnabled(boolean scanPurchased, SiteModel site) {
@NonNull
public static FetchSitesPayload getFetchSitesPayload() {
ArrayList<SiteFilter> siteFilters = new ArrayList<>();
if (BuildConfig.IS_JETPACK_APP) siteFilters.add(SiteFilter.JETPACK);
return new FetchSitesPayload(siteFilters);
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -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'
Expand Down