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 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
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