From 5fb1a226b93578dcba8310b9d57c72a096b1c614 Mon Sep 17 00:00:00 2001 From: AmandaRiu Date: Wed, 3 Jul 2019 19:45:47 -0600 Subject: [PATCH 001/446] Squashed 'libs/login/' changes from 78c5307f7a..979ddf4aec 979ddf4aec Merge commit '827a47189094a6bc7800eaccc3ed069841251373' into sync-login-lib df3c11ed09 added textAlignment property to secondary button in login da783ea3c7 Login screens: added textAlignment property to labels 6d486bbf6b Merge pull request #21 from wordpress-mobile/merge-wpa-develop 57a2d00b14 Update login lib standalone FluxC hash 0ea2405def Merge commit 'ad485b27b26ffb38b8718940b0b7556b902dc28c' into sync-login-lib 6df15ab86b Update 2FA unavailable API error message eefd72f317 Show error and continue login on OAuth client 2FA error ca3b68e817 Merge branch 'amanda/signin-has-woo' into amanda/signin-tracks-events 4755048046 Remove part of login site error msg and add help button 3cc4f31b3b Refresh branch with AndroidX changes in develop 76c40f3034 Fixed incorrect ordering of imports in login library 08a9f0c65a First pass at AndroidX migration. Used the migration wizard then did far too much cleanup. a46ceeb96b Track connected site info requests, success, and failures 47528a1c33 Special handling for atomic sites 578dca7f29 Update androidx dependencies 1d09d1536d Fix AndroidX import order 48df84638f Fix import ordering for androidx d3dc35035a Migrate to AndroidX e9e219db2f Add logic to get connected site info for woo login mode. 873db9b385 Add new logic to change the label to show the site logging into 9f442e9a2f Add new WOO_LOGIN_MODE 309eeda212 Add new string to handle non-WordPress site error dfc6991275 Revert "Add new loginMode for woo and update related error strings" 9b44d78d3e Add debug property to populate site address during login 45ae481c03 Add new loginMode for woo and update related error strings 91731b6196 Add a way to hide the option to login by site address 4d6c83f111 Merge pull request #9890 from wordpress-mobile/update-dagger-version-to-v2.22.1 9cbf3f17ff Merge pull request #9885 from wordpress-mobile/update-login-library 0ddf4dcdbd Update Glide version to 4.9.0 f7860b9861 Updated Dagger in the login library 1c311d430c Updated Dagger in the login library 79dd984392 Updated login library to Glide 4.9.0 e995e12f02 Revert sdk change for login library 954e7ddebc Updated targetSdkVersion to 28 7ee1e1c003 Added another catch block to handle NoActivityFoundException 804225d94f Merge commit 'a9cf59e44590548a123efeb521f9ff99b3277072' into update-login-lib git-subtree-dir: libs/login git-subtree-split: 979ddf4aec664cf9afafa1cdf7d99599488f1eee --- WordPressLoginFlow/build.gradle | 24 +++--- .../android/login/GoogleFragment.java | 5 +- .../android/login/Login2FaFragment.java | 11 +-- .../android/login/LoginAnalyticsListener.java | 3 + .../android/login/LoginBaseFormFragment.java | 33 +++++--- .../android/login/LoginEmailFragment.java | 68 +++++++++++---- .../login/LoginEmailPasswordFragment.java | 9 +- .../login/LoginHttpAuthDialogFragment.java | 9 +- .../android/login/LoginListener.java | 7 +- .../login/LoginMagicLinkRequestFragment.java | 11 +-- .../login/LoginMagicLinkSentFragment.java | 11 +-- .../wordpress/android/login/LoginMode.java | 3 +- .../login/LoginSiteAddressFragment.java | 84 ++++++++++++++++++- .../LoginSiteAddressHelpDialogFragment.java | 7 +- .../login/LoginUsernamePasswordFragment.java | 7 +- .../android/login/LoginWpcomService.java | 7 +- .../login/SignupBottomSheetDialog.java | 6 +- .../android/login/SignupEmailFragment.java | 9 +- .../android/login/SignupGoogleFragment.java | 3 +- .../login/SignupMagicLinkFragment.java | 13 +-- .../login/widgets/WPBottomSheetDialog.java | 6 +- .../login/widgets/WPLoginInputRow.java | 10 ++- .../login_magic_link_request_screen.xml | 4 +- .../login_magic_link_sent_screen.xml | 4 +- .../signup_bottom_sheet_dialog.xml | 12 +-- .../res/layout-land/signup_magic_link.xml | 4 +- .../main/res/layout/login_alert_http_auth.xml | 12 +-- .../layout/login_email_password_screen.xml | 2 + .../main/res/layout/login_email_screen.xml | 2 + .../src/main/res/layout/login_form_screen.xml | 5 +- .../src/main/res/layout/login_input_row.xml | 2 +- .../login_magic_link_request_screen.xml | 2 +- .../res/layout/login_site_address_screen.xml | 2 + .../res/layout/signup_bottom_sheet_dialog.xml | 12 +-- .../src/main/res/layout/toolbar_login.xml | 4 +- .../src/main/res/values/strings.xml | 6 +- config/checkstyle.xml | 2 +- gradle.properties-example | 4 + 38 files changed, 295 insertions(+), 130 deletions(-) diff --git a/WordPressLoginFlow/build.gradle b/WordPressLoginFlow/build.gradle index 4539b7b12211..786af0be0fa2 100644 --- a/WordPressLoginFlow/build.gradle +++ b/WordPressLoginFlow/build.gradle @@ -4,7 +4,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:3.3.2' } } @@ -35,12 +35,12 @@ dependencies { exclude group: "com.mcxiaoke.volley" } - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation 'com.android.support:animated-vector-drawable:28.0.0' - implementation 'com.android.support:support-media-compat:28.0.0' - implementation 'com.android.support:support-v13:28.0.0' - implementation 'com.android.support:gridlayout-v7:28.0.0' - implementation 'com.android.support:design:28.0.0' + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.vectordrawable:vectordrawable-animated:1.0.0' + implementation 'androidx.media:media:1.0.1' + implementation 'androidx.legacy:legacy-support-v13:1.0.0' + implementation 'androidx.gridlayout:gridlayout:1.0.0' + implementation 'com.google.android.material:material:1.0.0' api 'com.google.android.gms:play-services-auth:15.0.1' @@ -51,7 +51,7 @@ dependencies { exclude group: "org.wordpress", module: "utils" } } else { - implementation("com.github.wordpress-mobile.WordPress-FluxC-Android:fluxc:8cdbf03cf3d595ef904bab3c1dc207e39242c882") { + implementation("com.github.wordpress-mobile.WordPress-FluxC-Android:fluxc:9f07b031646dd3e6021d4b8e0a35647c9109ff27") { exclude group: "com.android.support" exclude group: "org.wordpress", module: "utils" } @@ -61,11 +61,11 @@ dependencies { annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0' // Dagger - implementation 'com.google.dagger:dagger:2.11' - annotationProcessor 'com.google.dagger:dagger-compiler:2.11' + implementation 'com.google.dagger:dagger:2.22.1' + annotationProcessor 'com.google.dagger:dagger-compiler:2.22.1' compileOnly 'org.glassfish:javax.annotation:10.0-b28' - implementation 'com.google.dagger:dagger-android-support:2.11' - annotationProcessor 'com.google.dagger:dagger-android-processor:2.11' + implementation 'com.google.dagger:dagger-android-support:2.22.1' + annotationProcessor 'com.google.dagger:dagger-android-processor:2.22.1' lintChecks 'org.wordpress:lint:1.0.1' } diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/GoogleFragment.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/GoogleFragment.java index cdb255b4a018..1d41c8d45593 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/GoogleFragment.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/GoogleFragment.java @@ -4,10 +4,11 @@ import android.content.Intent; import android.content.IntentSender; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.app.Fragment; import android.util.Log; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; + import com.google.android.gms.auth.api.Auth; import com.google.android.gms.auth.api.signin.GoogleSignInOptions; import com.google.android.gms.common.ConnectionResult; diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/Login2FaFragment.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/Login2FaFragment.java index 074e30e44c84..917cc60cf752 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/Login2FaFragment.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/Login2FaFragment.java @@ -3,11 +3,6 @@ import android.content.ClipboardManager; import android.content.Context; import android.os.Bundle; -import android.support.annotation.LayoutRes; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.StringRes; -import android.support.v7.app.AlertDialog; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; @@ -20,6 +15,12 @@ import android.widget.EditText; import android.widget.TextView; +import androidx.annotation.LayoutRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.StringRes; +import androidx.appcompat.app.AlertDialog; + import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import org.wordpress.android.fluxc.generated.AccountActionBuilder; diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginAnalyticsListener.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginAnalyticsListener.java index 231b1d09d04f..0143865f1d07 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginAnalyticsListener.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginAnalyticsListener.java @@ -51,4 +51,7 @@ public interface LoginAnalyticsListener { void trackUrlHelpScreenViewed(); void trackUsernamePasswordFormViewed(); void trackWpComBackgroundServiceUpdate(Map properties); + void trackConnectedSiteInfoRequested(String url); + void trackConnectedSiteInfoFailed(String url, String errorContext, String errorType, String errorDescription); + void trackConnectedSiteInfoSucceeded(Map properties); } diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginBaseFormFragment.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginBaseFormFragment.java index eba9357aa352..a91b70dc85e0 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginBaseFormFragment.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginBaseFormFragment.java @@ -5,15 +5,6 @@ import android.content.DialogInterface; import android.net.Uri; import android.os.Bundle; -import android.support.annotation.CallSuper; -import android.support.annotation.LayoutRes; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.StringRes; -import android.support.v4.app.Fragment; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.Menu; @@ -26,6 +17,16 @@ import android.widget.EditText; import android.widget.TextView; +import androidx.annotation.CallSuper; +import androidx.annotation.LayoutRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.StringRes; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.fragment.app.Fragment; + import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import org.wordpress.android.fluxc.Dispatcher; @@ -33,6 +34,7 @@ import org.wordpress.android.fluxc.generated.AccountActionBuilder; import org.wordpress.android.fluxc.generated.SiteActionBuilder; import org.wordpress.android.fluxc.store.AccountStore; +import org.wordpress.android.fluxc.store.AccountStore.AccountErrorType; import org.wordpress.android.fluxc.store.AccountStore.OnAccountChanged; import org.wordpress.android.fluxc.store.SiteStore; import org.wordpress.android.fluxc.store.SiteStore.OnSiteChanged; @@ -40,6 +42,7 @@ import org.wordpress.android.util.AppLog; import org.wordpress.android.util.EditTextUtils; import org.wordpress.android.util.ToastUtils; +import org.wordpress.android.util.ToastUtils.Duration; import javax.inject.Inject; @@ -290,9 +293,15 @@ public void onAccountChanged(OnAccountChanged event) { if (event.isError()) { AppLog.e(AppLog.T.API, "onAccountChanged has error: " + event.error.type + " - " + event.error.message); - ToastUtils.showToast(getContext(), R.string.error_fetch_my_profile); - onLoginFinished(false); - return; + if (event.error.type == AccountErrorType.SETTINGS_FETCH_REAUTHORIZATION_REQUIRED_ERROR) { + // This probably means we're logging in to 2FA-enabled account with a non-production WP.com client id. + // A few WordPress.com APIs like /me/settings/ won't work for this account. + ToastUtils.showToast(getContext(), R.string.error_disabled_apis, Duration.LONG); + } else { + ToastUtils.showToast(getContext(), R.string.error_fetch_my_profile, Duration.LONG); + onLoginFinished(false); + return; + } } if (event.causeOfChange == AccountAction.FETCH_ACCOUNT) { diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginEmailFragment.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginEmailFragment.java index b00b63b0fe78..4fa31858f042 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginEmailFragment.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginEmailFragment.java @@ -1,14 +1,11 @@ package org.wordpress.android.login; import android.app.PendingIntent; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.IntentSender; import android.os.Bundle; -import android.support.annotation.LayoutRes; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v7.app.AlertDialog; import android.text.Editable; import android.text.Html; import android.text.TextWatcher; @@ -22,6 +19,11 @@ import android.widget.LinearLayout; import android.widget.TextView; +import androidx.annotation.LayoutRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; + import com.google.android.gms.auth.api.Auth; import com.google.android.gms.auth.api.credentials.Credential; import com.google.android.gms.auth.api.credentials.CredentialPickerConfig; @@ -66,6 +68,9 @@ public class LoginEmailFragment extends LoginBaseFormFragment imp private static final int GOOGLE_API_CLIENT_ID = 1002; private static final int EMAIL_CREDENTIALS_REQUEST_CODE = 25100; + private static final String ARG_HIDE_LOGIN_BY_SITE_OPTION = "ARG_HIDE_LOGIN_BY_SITE_OPTION"; + private static final String ARG_LOGIN_SITE_URL = "ARG_LOGIN_SITE_URL"; + public static final String TAG = "login_email_fragment_tag"; public static final int MAX_EMAIL_LENGTH = 100; @@ -78,6 +83,17 @@ public class LoginEmailFragment extends LoginBaseFormFragment imp protected WPLoginInputRow mEmailInput; protected boolean mHasDismissedEmailHints; protected boolean mIsDisplayingEmailHints; + protected boolean mHideLoginWithSiteOption; + protected String mLoginSiteUrl; + + public static LoginEmailFragment newInstance(Boolean hideLoginWithSiteOption, String url) { + LoginEmailFragment fragment = new LoginEmailFragment(); + Bundle args = new Bundle(); + args.putBoolean(ARG_HIDE_LOGIN_BY_SITE_OPTION, hideLoginWithSiteOption); + args.putString(ARG_LOGIN_SITE_URL, url); + fragment.setArguments(args); + return fragment; + } @Override protected @LayoutRes int getContentLayout() { @@ -102,6 +118,9 @@ protected void setupLabel(@NonNull TextView label) { case WPCOM_LOGIN_ONLY: label.setText(R.string.enter_email_wordpress_com); break; + case WOO_LOGIN_MODE: + label.setText(getString(R.string.enter_email_for_site, mLoginSiteUrl)); + break; case JETPACK_STATS: label.setText(R.string.login_to_to_connect_jetpack); break; @@ -161,18 +180,22 @@ public void onClick(View view) { }); LinearLayout siteLoginButton = rootView.findViewById(R.id.login_site_button); - siteLoginButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - if (mLoginListener != null) { - if (mLoginListener.getLoginMode() == LoginMode.JETPACK_STATS) { - mLoginListener.loginViaWpcomUsernameInstead(); - } else { - mLoginListener.loginViaSiteAddress(); + if (mHideLoginWithSiteOption) { + siteLoginButton.setVisibility(View.GONE); + } else { + siteLoginButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + if (mLoginListener != null) { + if (mLoginListener.getLoginMode() == LoginMode.JETPACK_STATS) { + mLoginListener.loginViaWpcomUsernameInstead(); + } else { + mLoginListener.loginViaSiteAddress(); + } } } - } - }); + }); + } ImageView siteLoginButtonIcon = rootView.findViewById(R.id.login_site_button_icon); TextView siteLoginButtonText = rootView.findViewById(R.id.login_site_button_text); @@ -180,6 +203,7 @@ public void onClick(View view) { switch (mLoginListener.getLoginMode()) { case FULL: case WPCOM_LOGIN_ONLY: + case WOO_LOGIN_MODE: case SHARE_INTENT: siteLoginButtonIcon.setImageResource(R.drawable.ic_domains_grey_24dp); siteLoginButtonText.setText(R.string.enter_site_address_instead); @@ -210,6 +234,13 @@ public void onClick(View view) { } } }); + } else if (mLoginListener.getLoginMode() == LoginMode.WOO_LOGIN_MODE) { + secondaryButton.setText(getResources().getString(R.string.login_need_help_finding_connected_email)); + secondaryButton.setOnClickListener(new OnClickListener() { + public void onClick(View view) { + mLoginListener.showHelpFindingConnectedEmail(); + } + }); } else { secondaryButton.setVisibility(View.GONE); } @@ -243,6 +274,13 @@ public void onAttach(Context context) { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + + Bundle args = getArguments(); + if (args != null) { + mHideLoginWithSiteOption = args.getBoolean(ARG_HIDE_LOGIN_BY_SITE_OPTION, false); + mLoginSiteUrl = args.getString(ARG_LOGIN_SITE_URL, ""); + } + mGoogleApiClient = new GoogleApiClient.Builder(getActivity()) .addConnectionCallbacks(LoginEmailFragment.this) .enableAutoManage(getActivity(), GOOGLE_API_CLIENT_ID, LoginEmailFragment.this) @@ -444,6 +482,8 @@ public void getEmailHints() { startIntentSenderForResult(intent.getIntentSender(), EMAIL_CREDENTIALS_REQUEST_CODE, null, 0, 0, 0, null); } catch (IntentSender.SendIntentException exception) { AppLog.d(T.NUX, LOG_TAG + "Could not start email hint picker" + exception); + } catch (ActivityNotFoundException exception) { + AppLog.d(T.NUX, LOG_TAG + "Could not find any activity to handle email hint picker" + exception); } } diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginEmailPasswordFragment.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginEmailPasswordFragment.java index 420a765aa770..86a20ed80edd 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginEmailPasswordFragment.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginEmailPasswordFragment.java @@ -2,9 +2,6 @@ import android.content.Context; import android.os.Bundle; -import android.support.annotation.LayoutRes; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; @@ -15,10 +12,14 @@ import android.widget.EditText; import android.widget.TextView; +import androidx.annotation.LayoutRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; -import org.wordpress.android.login.LoginWpcomService.OnCredentialsOK; import org.wordpress.android.login.LoginWpcomService.LoginState; +import org.wordpress.android.login.LoginWpcomService.OnCredentialsOK; import org.wordpress.android.login.util.SiteUtils; import org.wordpress.android.login.widgets.WPLoginInputRow; import org.wordpress.android.login.widgets.WPLoginInputRow.OnEditorCommitListener; diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginHttpAuthDialogFragment.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginHttpAuthDialogFragment.java index aa4f013c036f..66b1151b9ddf 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginHttpAuthDialogFragment.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginHttpAuthDialogFragment.java @@ -5,10 +5,6 @@ import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.DialogFragment; -import android.support.v7.app.AlertDialog; import android.text.Editable; import android.text.TextWatcher; import android.view.ContextThemeWrapper; @@ -17,6 +13,11 @@ import android.widget.EditText; import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; +import androidx.fragment.app.DialogFragment; + import org.wordpress.android.util.EditTextUtils; public class LoginHttpAuthDialogFragment extends DialogFragment { diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginListener.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginListener.java index e17875f309df..a55fb4125142 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginListener.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginListener.java @@ -1,8 +1,9 @@ package org.wordpress.android.login; import android.net.Uri; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import org.wordpress.android.fluxc.network.MemorizingTrustManager; import org.wordpress.android.fluxc.store.SiteStore; @@ -25,6 +26,7 @@ interface SelfSignedSSLCallback { void helpEmailScreen(String email); void helpSocialEmailScreen(String email); void addGoogleLoginFragment(); + void showHelpFindingConnectedEmail(); // Login Request Magic Link callbacks void showMagicLinkSentScreen(String email); @@ -46,6 +48,7 @@ interface SelfSignedSSLCallback { // Login Site Address input callbacks void alreadyLoggedInWpcom(ArrayList oldSitesIds); void gotWpcomSiteInfo(String siteAddress, String siteName, String siteIconUrl); + void gotConnectedSiteInfo(String siteAddress, boolean hasJetpack); void gotXmlRpcEndpoint(String inputSiteAddress, String endpointAddress); void handleSslCertificateError(MemorizingTrustManager memorizingTrustManager, SelfSignedSSLCallback callback); void helpSiteAddress(String url); diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMagicLinkRequestFragment.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMagicLinkRequestFragment.java index 14e2afa5db42..6082ec3b1404 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMagicLinkRequestFragment.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMagicLinkRequestFragment.java @@ -5,11 +5,6 @@ import android.content.DialogInterface; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -19,6 +14,12 @@ import android.widget.Button; import android.widget.ImageView; +import androidx.annotation.Nullable; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.fragment.app.Fragment; + import com.bumptech.glide.Glide; import com.bumptech.glide.load.DataSource; import com.bumptech.glide.load.engine.GlideException; diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMagicLinkSentFragment.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMagicLinkSentFragment.java index 683b6396acce..54ce0dc1aa18 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMagicLinkSentFragment.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMagicLinkSentFragment.java @@ -2,11 +2,6 @@ import android.content.Context; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; @@ -14,6 +9,12 @@ import android.view.View; import android.view.ViewGroup; +import androidx.annotation.Nullable; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.fragment.app.Fragment; + import javax.inject.Inject; import dagger.android.support.AndroidSupportInjection; diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMode.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMode.java index 8e569c053bd1..c71973571efb 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMode.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginMode.java @@ -9,7 +9,8 @@ public enum LoginMode { JETPACK_STATS, WPCOM_LOGIN_DEEPLINK, WPCOM_REAUTHENTICATE, - SHARE_INTENT; + SHARE_INTENT, + WOO_LOGIN_MODE; private static final String ARG_LOGIN_MODE = "ARG_LOGIN_MODE"; diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginSiteAddressFragment.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginSiteAddressFragment.java index c5d52db215be..2bcbfff80faa 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginSiteAddressFragment.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginSiteAddressFragment.java @@ -4,9 +4,6 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; -import android.support.annotation.LayoutRes; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; @@ -18,6 +15,10 @@ import android.widget.EditText; import android.widget.TextView; +import androidx.annotation.LayoutRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import org.wordpress.android.fluxc.Dispatcher; @@ -28,6 +29,7 @@ import org.wordpress.android.fluxc.network.discovery.SelfHostedEndpointFinder.DiscoveryError; import org.wordpress.android.fluxc.store.AccountStore; import org.wordpress.android.fluxc.store.AccountStore.OnDiscoveryResponse; +import org.wordpress.android.fluxc.store.SiteStore.OnConnectSiteInfoChecked; import org.wordpress.android.fluxc.store.SiteStore.OnWPComSiteFetched; import org.wordpress.android.login.util.SiteUtils; import org.wordpress.android.login.widgets.WPLoginInputRow; @@ -39,6 +41,7 @@ import org.wordpress.android.util.UrlUtils; import java.util.ArrayList; +import java.util.HashMap; import javax.inject.Inject; @@ -86,6 +89,9 @@ protected void setupContent(ViewGroup rootView) { // important for accessibility - talkback getActivity().setTitle(R.string.site_address_login_title); mSiteAddressInput = rootView.findViewById(R.id.login_site_address_row); + if (BuildConfig.DEBUG) { + mSiteAddressInput.getEditText().setText(BuildConfig.DEBUG_WPCOM_WEBSITE_URL); + } mSiteAddressInput.addTextChangedListener(this); mSiteAddressInput.setOnEditorCommitListener(this); } @@ -162,7 +168,16 @@ protected void discover() { mRequestedSiteAddress = cleanedSiteAddress; String cleanedXmlrpcSuffix = UrlUtils.removeXmlrpcSuffix(mRequestedSiteAddress); - mDispatcher.dispatch(SiteActionBuilder.newFetchWpcomSiteByUrlAction(cleanedXmlrpcSuffix)); + + if (mLoginListener.getLoginMode() == LoginMode.WOO_LOGIN_MODE) { + // TODO: This is temporary code to test out sign in flow milestone 1 effectiveness. If we move + // forward with this flow, we will need to just call the XMLRPC discovery code and handle all the + // edge cases such as HTTP auth and self-signed SSL. + mAnalyticsListener.trackConnectedSiteInfoRequested(cleanedXmlrpcSuffix); + mDispatcher.dispatch(SiteActionBuilder.newFetchConnectSiteInfoAction(cleanedXmlrpcSuffix)); + } else { + mDispatcher.dispatch(SiteActionBuilder.newFetchWpcomSiteByUrlAction(cleanedXmlrpcSuffix)); + } startProgress(); } @@ -353,4 +368,65 @@ public void onDiscoverySucceeded(OnDiscoveryResponse event) { AppLog.i(T.NUX, "Discovery succeeded, endpoint: " + event.xmlRpcEndpoint); mLoginListener.gotXmlRpcEndpoint(requestedSiteAddress, event.xmlRpcEndpoint); } + + @SuppressWarnings("unused") + @Subscribe(threadMode = ThreadMode.MAIN) + public void onFetchedConnectSiteInfo(OnConnectSiteInfoChecked event) { + if (mRequestedSiteAddress == null) { + // bail if user canceled + return; + } + + if (!isAdded()) { + return; + } + + // hold the URL in a variable to use below otherwise it gets cleared up by endProgress + final String requestedSiteAddress = mRequestedSiteAddress; + + if (isInProgress()) { + endProgress(); + } + + if (event.isError()) { + mAnalyticsListener.trackConnectedSiteInfoFailed( + requestedSiteAddress, + event.getClass().getSimpleName(), + event.error.type.name(), + event.error.message); + + AppLog.e(T.API, "onFetchedConnectSiteInfo has error: " + event.error.message); + + showError(R.string.invalid_site_url_message); + } else { + // TODO: If we plan to keep this logic we should convert these labels to constants + HashMap properties = new HashMap<>(); + properties.put("url", event.info.url); + properties.put("urlAfterRedirects", event.info.urlAfterRedirects); + properties.put("exists", Boolean.toString(event.info.exists)); + properties.put("hasJetpack", Boolean.toString(event.info.hasJetpack)); + properties.put("isJetpackActive", Boolean.toString(event.info.isJetpackActive)); + properties.put("isJetpackConnected", Boolean.toString(event.info.isJetpackConnected)); + properties.put("isWordPress", Boolean.toString(event.info.isWordPress)); + properties.put("isWPCom", Boolean.toString(event.info.isWPCom)); + mAnalyticsListener.trackConnectedSiteInfoSucceeded(properties); + + if (!event.info.exists) { + // Site does not exist + showError(R.string.invalid_site_url_message); + } else if (!event.info.isWordPress) { + // Not a WordPress site + showError(R.string.enter_wordpress_site); + } else { + boolean hasJetpack = false; + if (event.info.isWPCom && event.info.hasJetpack) { + // This is likely an atomic site. + hasJetpack = true; + } else if (event.info.hasJetpack && event.info.isJetpackActive && event.info.isJetpackConnected) { + hasJetpack = true; + } + mLoginListener.gotConnectedSiteInfo(event.info.url, hasJetpack); + } + } + } } diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginSiteAddressHelpDialogFragment.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginSiteAddressHelpDialogFragment.java index 07a0353fd489..eca020bf209f 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginSiteAddressHelpDialogFragment.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginSiteAddressHelpDialogFragment.java @@ -4,11 +4,12 @@ import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.v4.app.DialogFragment; -import android.support.v7.app.AlertDialog; import android.view.ContextThemeWrapper; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; +import androidx.fragment.app.DialogFragment; + import org.wordpress.android.fluxc.store.AccountStore; import org.wordpress.android.fluxc.store.SiteStore; diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginUsernamePasswordFragment.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginUsernamePasswordFragment.java index 3f3eea205c7a..e02c72321141 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginUsernamePasswordFragment.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginUsernamePasswordFragment.java @@ -3,9 +3,6 @@ import android.content.Context; import android.graphics.Rect; import android.os.Bundle; -import android.support.annotation.LayoutRes; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; @@ -18,6 +15,10 @@ import android.widget.ScrollView; import android.widget.TextView; +import androidx.annotation.LayoutRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginWpcomService.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginWpcomService.java index 86e9cf1e8e29..947b3c09c511 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginWpcomService.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginWpcomService.java @@ -3,9 +3,10 @@ import android.app.Notification; import android.content.Context; import android.content.Intent; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.annotation.StringRes; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.annotation.StringRes; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupBottomSheetDialog.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupBottomSheetDialog.java index 03f6b5798154..700670277c69 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupBottomSheetDialog.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupBottomSheetDialog.java @@ -2,13 +2,15 @@ import android.content.Context; import android.content.DialogInterface; -import android.support.annotation.NonNull; -import android.support.design.widget.BottomSheetBehavior; import android.text.Html; import android.view.LayoutInflater; import android.view.View; import android.widget.Button; +import androidx.annotation.NonNull; + +import com.google.android.material.bottomsheet.BottomSheetBehavior; + import org.wordpress.android.login.widgets.WPBottomSheetDialog; public class SignupBottomSheetDialog extends WPBottomSheetDialog { diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupEmailFragment.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupEmailFragment.java index ad667dfcf5e3..0d2a66f8167d 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupEmailFragment.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupEmailFragment.java @@ -5,10 +5,6 @@ import android.content.Intent; import android.content.IntentSender; import android.os.Bundle; -import android.support.annotation.LayoutRes; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v7.app.AlertDialog; import android.text.Editable; import android.text.TextWatcher; import android.util.Patterns; @@ -19,6 +15,11 @@ import android.widget.Button; import android.widget.TextView; +import androidx.annotation.LayoutRes; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; + import com.google.android.gms.auth.api.Auth; import com.google.android.gms.auth.api.credentials.Credential; import com.google.android.gms.auth.api.credentials.CredentialPickerConfig; diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupGoogleFragment.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupGoogleFragment.java index 91ffe71d8094..cc71f9112690 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupGoogleFragment.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupGoogleFragment.java @@ -4,7 +4,8 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; -import android.support.annotation.NonNull; + +import androidx.annotation.NonNull; import com.google.android.gms.auth.api.Auth; import com.google.android.gms.auth.api.signin.GoogleSignInAccount; diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupMagicLinkFragment.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupMagicLinkFragment.java index 882c6226298c..30cc011cb1d7 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupMagicLinkFragment.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/SignupMagicLinkFragment.java @@ -4,12 +4,6 @@ import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AlertDialog; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.Menu; @@ -19,6 +13,13 @@ import android.view.ViewGroup; import android.widget.Button; +import androidx.annotation.Nullable; +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.fragment.app.Fragment; + import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; import org.wordpress.android.fluxc.Dispatcher; diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPBottomSheetDialog.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPBottomSheetDialog.java index 24b2da033616..9f77f1e2b305 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPBottomSheetDialog.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPBottomSheetDialog.java @@ -1,10 +1,12 @@ package org.wordpress.android.login.widgets; import android.content.Context; -import android.support.annotation.NonNull; -import android.support.design.widget.BottomSheetDialog; import android.view.WindowManager; +import androidx.annotation.NonNull; + +import com.google.android.material.bottomsheet.BottomSheetDialog; + import org.wordpress.android.login.R; import org.wordpress.android.util.DisplayUtils; diff --git a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPLoginInputRow.java b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPLoginInputRow.java index d9ef1f90c19d..1cb90f8b2f83 100644 --- a/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPLoginInputRow.java +++ b/WordPressLoginFlow/src/main/java/org/wordpress/android/login/widgets/WPLoginInputRow.java @@ -9,10 +9,6 @@ import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; -import android.support.annotation.Nullable; -import android.support.design.widget.TextInputLayout; -import android.support.v4.content.ContextCompat; -import android.support.v4.graphics.drawable.DrawableCompat; import android.text.TextWatcher; import android.util.AttributeSet; import android.util.SparseArray; @@ -24,6 +20,12 @@ import android.widget.RelativeLayout; import android.widget.TextView; +import androidx.annotation.Nullable; +import androidx.core.content.ContextCompat; +import androidx.core.graphics.drawable.DrawableCompat; + +import com.google.android.material.textfield.TextInputLayout; + import org.wordpress.android.login.R; /** diff --git a/WordPressLoginFlow/src/main/res/layout-land/login_magic_link_request_screen.xml b/WordPressLoginFlow/src/main/res/layout-land/login_magic_link_request_screen.xml index 3a99b4023af4..e8edec571f4e 100644 --- a/WordPressLoginFlow/src/main/res/layout-land/login_magic_link_request_screen.xml +++ b/WordPressLoginFlow/src/main/res/layout-land/login_magic_link_request_screen.xml @@ -60,7 +60,7 @@ android:clipToPadding="false" tools:ignore="InconsistentLayout"> - - - - - - + - - + - - + diff --git a/WordPressLoginFlow/src/main/res/layout-land/signup_magic_link.xml b/WordPressLoginFlow/src/main/res/layout-land/signup_magic_link.xml index 86412338692d..9a9e425626f0 100644 --- a/WordPressLoginFlow/src/main/res/layout-land/signup_magic_link.xml +++ b/WordPressLoginFlow/src/main/res/layout-land/signup_magic_link.xml @@ -59,7 +59,7 @@ android:paddingTop="@dimen/margin_medium_large" tools:ignore="InconsistentLayout"> - - + diff --git a/WordPressLoginFlow/src/main/res/layout/login_alert_http_auth.xml b/WordPressLoginFlow/src/main/res/layout/login_alert_http_auth.xml index cca0fea52a19..320e38aba742 100644 --- a/WordPressLoginFlow/src/main/res/layout/login_alert_http_auth.xml +++ b/WordPressLoginFlow/src/main/res/layout/login_alert_http_auth.xml @@ -5,21 +5,21 @@ android:layout_height="match_parent" android:padding="?attr/dialogPreferredPadding"> - - - + - - - + diff --git a/WordPressLoginFlow/src/main/res/layout/login_email_password_screen.xml b/WordPressLoginFlow/src/main/res/layout/login_email_password_screen.xml index d0fb277070dd..bd28c1e74ca3 100644 --- a/WordPressLoginFlow/src/main/res/layout/login_email_password_screen.xml +++ b/WordPressLoginFlow/src/main/res/layout/login_email_password_screen.xml @@ -18,6 +18,8 @@ android:layout_height="wrap_content" android:layout_marginTop="@dimen/margin_extra_large" android:layout_marginBottom="@dimen/margin_extra_large" + android:textAlignment="viewStart" + android:gravity="start" tools:text="@string/enter_site_address" /> diff --git a/WordPressLoginFlow/src/main/res/layout/login_form_screen.xml b/WordPressLoginFlow/src/main/res/layout/login_form_screen.xml index b098889bca1c..b73464ee00ae 100644 --- a/WordPressLoginFlow/src/main/res/layout/login_form_screen.xml +++ b/WordPressLoginFlow/src/main/res/layout/login_form_screen.xml @@ -37,7 +37,7 @@ android:layout_alignParentBottom="true" android:clipToPadding="false"> - - - - diff --git a/WordPressLoginFlow/src/main/res/layout/signup_bottom_sheet_dialog.xml b/WordPressLoginFlow/src/main/res/layout/signup_bottom_sheet_dialog.xml index eab8ce45968c..d41a6be9e682 100644 --- a/WordPressLoginFlow/src/main/res/layout/signup_bottom_sheet_dialog.xml +++ b/WordPressLoginFlow/src/main/res/layout/signup_bottom_sheet_dialog.xml @@ -13,7 +13,7 @@ android:paddingRight="@dimen/margin_extra_large" android:paddingTop="@dimen/margin_medium" > - - + - - + - - + diff --git a/WordPressLoginFlow/src/main/res/layout/toolbar_login.xml b/WordPressLoginFlow/src/main/res/layout/toolbar_login.xml index 8e069fad8b25..bac5435ba1ba 100644 --- a/WordPressLoginFlow/src/main/res/layout/toolbar_login.xml +++ b/WordPressLoginFlow/src/main/res/layout/toolbar_login.xml @@ -1,5 +1,5 @@ - - + diff --git a/WordPressLoginFlow/src/main/res/values/strings.xml b/WordPressLoginFlow/src/main/res/values/strings.xml index 43060a6f5771..26c045e7c2ab 100644 --- a/WordPressLoginFlow/src/main/res/values/strings.xml +++ b/WordPressLoginFlow/src/main/res/values/strings.xml @@ -15,6 +15,7 @@ Your notifications travel with you — see comments and likes as they happen. Manage your Jetpack-powered site on the go — you\'ve got WordPress in your pocket. Log in to WordPress.com using an email address to manage all your WordPress sites. + Log in with WordPress.com to connect to %1$s Next Open mail Alternatively: @@ -82,6 +83,7 @@ This site already exists in the app, you can\'t add it. A duplicate site has been detected. Couldn\'t retrieve your profile + Could not fetch settings: Some APIs are unavailable for this OAuth app ID + account combination. Log in to the WordPress.com account you used to connect Jetpack. Log in again to continue. Checking email @@ -99,7 +101,7 @@ site XMLRPC endpoint. The app needs that in order to communicate with your site. Contact your host to solve this problem. Please enter a WordPress.com or Jetpack-connected self-hosted WordPress site - + The website at this address is not a WordPress site. For us to connect to it, the site must have WordPress installed. A network error occurred. Please check your connection and try again. Logged in! @@ -138,4 +140,6 @@ placeholder + + Need help finding the email you connected with? diff --git a/config/checkstyle.xml b/config/checkstyle.xml index ae088941c51b..2ebaaac1412c 100644 --- a/config/checkstyle.xml +++ b/config/checkstyle.xml @@ -154,7 +154,7 @@ - + diff --git a/gradle.properties-example b/gradle.properties-example index 25f6dd86df44..d6cbf29bcc27 100644 --- a/gradle.properties-example +++ b/gradle.properties-example @@ -4,3 +4,7 @@ wp.debug.wpcom_login_email = wp.debug.wpcom_login_username = wp.debug.wpcom_login_password = +wp.debug.wpcom_website_url = + +android.useAndroidX=true +android.enableJetifier=true From fcd4382495664e1baca74a50742760dfb663aa98 Mon Sep 17 00:00:00 2001 From: AmandaRiu Date: Wed, 3 Jul 2019 19:59:24 -0600 Subject: [PATCH 002/446] Fix build errors by implementing new interface methods in login lib These methods are not used by the WordPress app so they don't do anything and are only implemented to allow a successful build. These new methods were added for the Woo app. --- .../android/ui/accounts/LoginActivity.java | 8 ++++++++ .../ui/accounts/login/LoginAnalyticsTracker.java | 14 ++++++++++++++ 2 files changed, 22 insertions(+) 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 ff0ea0cf5736..368cabb80005 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 @@ -826,4 +826,12 @@ private void dismissSignupSheet() { public AndroidInjector supportFragmentInjector() { return mFragmentInjector; } + + @Override public void showHelpFindingConnectedEmail() { + // Not used in WordPress app + } + + @Override public void gotConnectedSiteInfo(String siteAddress, boolean hasJetpack) { + // Not used in WordPress app + } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginAnalyticsTracker.java b/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginAnalyticsTracker.java index 3fd1b6bcb983..c9af77eb8258 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginAnalyticsTracker.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/accounts/login/LoginAnalyticsTracker.java @@ -236,4 +236,18 @@ public void trackUsernamePasswordFormViewed() { public void trackWpComBackgroundServiceUpdate(Map properties) { AnalyticsTracker.track(AnalyticsTracker.Stat.LOGIN_WPCOM_BACKGROUND_SERVICE_UPDATE, properties); } + + @Override public void trackConnectedSiteInfoRequested(String url) { + // Not used in WordPress app + } + + @Override + public void trackConnectedSiteInfoFailed(String url, String errorContext, String errorType, + String errorDescription) { + // Not used in WordPress app + } + + @Override public void trackConnectedSiteInfoSucceeded(Map properties) { + // Not used in WordPress app + } } From 1e51fe9b223a3f918a44aeceef0514404e36b4c3 Mon Sep 17 00:00:00 2001 From: AmandaRiu Date: Wed, 3 Jul 2019 19:59:42 -0600 Subject: [PATCH 003/446] Copy new login lib strings to main strings file for localization --- WordPress/src/main/res/values/strings.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index 52efb3f9d613..12c001b6453f 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -2270,6 +2270,7 @@ Enter your password instead Alternatively: Log in to WordPress.com using an email address to manage all your WordPress sites. + Log in with WordPress.com to connect to %1$s Next Open mail Log in by entering your site address. @@ -2320,6 +2321,8 @@ Google login could not be started. \nMaybe try a different account? Please enter a WordPress.com or Jetpack-connected self-hosted WordPress site + The website at this address is not a WordPress site. For us to connect to it, the site must have WordPress installed. + Need help finding the email you connected with? Email address login Site address login From 15f299134c210cc407aa95c0b80947ad0ca86812 Mon Sep 17 00:00:00 2001 From: Lorenzo Mattei Date: Thu, 4 Jul 2019 13:25:09 +0200 Subject: [PATCH 004/446] Add lane for automatic beta versioning --- Gemfile.lock | 6 ++---- fastlane/Fastfile | 42 ++++++++++++++++++++++++++++++++++++++++++ fastlane/Pluginfile | 3 ++- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 85a78faee618..05f62721c7c5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,5 @@ -GIT - remote: https://github.com/wordpress-mobile/release-toolkit - revision: d5ad0466ab9f72161cd55916577cf52ee386f9cf - tag: 0.5.0 +PATH + remote: ../release-toolkit specs: fastlane-plugin-wpmreleasetoolkit (0.5.0) diffy (~> 3.3) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index f43ef420c0cd..82662ea056fb 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -111,6 +111,48 @@ ENV["HAS_ALPHA_VERSION"]="true" source_files: files, release_version: options[:version]) end + + ##################################################################################### + # new_beta_release + # ----------------------------------------------------------------------------------- + # This lane updates the release branch for a new beta release. It will update the + # current release branch by default. If you want to update a different branch + # (i.e. hotfix branch) pass the related version with the 'base_version' param + # (example: base_version:10.6.1 will work on the 10.6.1 branch) + # ----------------------------------------------------------------------------------- + # Usage: + # bundle exec fastlane new_beta_release [skip_confirm:] [base_version:] + # + # Example: + # bundle exec fastlane new_beta_release + # bundle exec fastlane new_beta_release skip_confirm:true + # bundle exec fastlane new_beta_release base_version:10.6.1 + ##################################################################################### + desc "Updates a release branch for a new beta release" + lane :new_beta_release do | options | + android_betabuild_prechecks(options) + android_bump_version_beta() + android_tag_build() + end + + ##################################################################################### + # new_hotfix_release + # ----------------------------------------------------------------------------------- + # This lane updates the release branch for a new hotix release. + # ----------------------------------------------------------------------------------- + # Usage: + # bundle exec fastlane new_hotfix_release [skip_confirm:] [version:] + # + # Example: + # bundle exec fastlane new_hotfix_release version:10.6.1 + # bundle exec fastlane new_hotfix_release skip_confirm:true version:10.6.1 + ##################################################################################### + desc "Creates a new hotfix branch from the given tag" + lane :new_hotfix_release do | options | + #prev_ver = android_hotfix_prechecks(options) + #android_bump_version_hotfix(previous_version: prev_ver, version: options[:version]) + #android_tag_build() + end ##################################################################################### # finalize_release diff --git a/fastlane/Pluginfile b/fastlane/Pluginfile index 80a71078a4aa..b8bc9365af9f 100644 --- a/fastlane/Pluginfile +++ b/fastlane/Pluginfile @@ -2,7 +2,8 @@ # # Ensure this file is checked in to source control! -gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', tag:'0.5.0' +#gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', tag:'0.5.0' +gem 'fastlane-plugin-wpmreleasetoolkit', path: '../../../wordpress-mobile/release-toolkit' From b98a363e62b7f22732b09037a71e74bbcfab3ec6 Mon Sep 17 00:00:00 2001 From: Lorenzo Mattei Date: Thu, 4 Jul 2019 15:01:11 +0200 Subject: [PATCH 005/446] Add lane for hotfix branch generation --- fastlane/Fastfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 82662ea056fb..9ce72da30966 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -149,9 +149,9 @@ ENV["HAS_ALPHA_VERSION"]="true" ##################################################################################### desc "Creates a new hotfix branch from the given tag" lane :new_hotfix_release do | options | - #prev_ver = android_hotfix_prechecks(options) - #android_bump_version_hotfix(previous_version: prev_ver, version: options[:version]) - #android_tag_build() + prev_ver = android_hotfix_prechecks(options) + android_bump_version_hotfix(previous_version_name: prev_ver, version_name: options[:version_name], version_code: options[:version_code]) + android_tag_build(tag_alpha: false) end ##################################################################################### From bc706d200f725fcee572e382839a31c634af9a75 Mon Sep 17 00:00:00 2001 From: Lorenzo Mattei Date: Thu, 4 Jul 2019 15:07:26 +0200 Subject: [PATCH 006/446] Fix --- fastlane/Fastfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 9ce72da30966..1b7064a4bab5 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -149,7 +149,7 @@ ENV["HAS_ALPHA_VERSION"]="true" ##################################################################################### desc "Creates a new hotfix branch from the given tag" lane :new_hotfix_release do | options | - prev_ver = android_hotfix_prechecks(options) + prev_ver = android_hotfix_prechecks(version_name: options[:version_name], skip_confirm: options[:skip_confirm]) android_bump_version_hotfix(previous_version_name: prev_ver, version_name: options[:version_name], version_code: options[:version_code]) android_tag_build(tag_alpha: false) end From 9beab6b9dd3a11267f916333974a3bfa013edf1c Mon Sep 17 00:00:00 2001 From: Lorenzo Mattei Date: Thu, 4 Jul 2019 15:21:52 +0200 Subject: [PATCH 007/446] Update to the latest release-toolkit --- Gemfile.lock | 6 ++++-- fastlane/Pluginfile | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 05f62721c7c5..51c616ebaa39 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,5 +1,7 @@ -PATH - remote: ../release-toolkit +GIT + remote: https://github.com/wordpress-mobile/release-toolkit + revision: e1833343a11f01526c606c3f0215875aea77c2c7 + ref: e1833343a11f01526c606c3f0215875aea77c2c7 specs: fastlane-plugin-wpmreleasetoolkit (0.5.0) diffy (~> 3.3) diff --git a/fastlane/Pluginfile b/fastlane/Pluginfile index b8bc9365af9f..d2b8c0e0b58f 100644 --- a/fastlane/Pluginfile +++ b/fastlane/Pluginfile @@ -2,8 +2,8 @@ # # Ensure this file is checked in to source control! -#gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', tag:'0.5.0' -gem 'fastlane-plugin-wpmreleasetoolkit', path: '../../../wordpress-mobile/release-toolkit' +gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', ref:'e1833343a11f01526c606c3f0215875aea77c2c7' + From 27bdaaac0b26c437890719a9219ca9b97951ac9d Mon Sep 17 00:00:00 2001 From: Lorenzo Mattei Date: Mon, 8 Jul 2019 12:52:31 +0200 Subject: [PATCH 008/446] Remove redundant check --- tools/release-checks.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tools/release-checks.sh b/tools/release-checks.sh index 0fec98891617..1d253443ebea 100755 --- a/tools/release-checks.sh +++ b/tools/release-checks.sh @@ -74,14 +74,8 @@ function printVersion() { echo "$BUILDFILE version $gradle_version" } -function checkThatConfigurationFilesAreUpToDate() { - bundle exec fastlane run configure_validate - pOk -} - checkNewLanguages checkENStrings -checkThatConfigurationFilesAreUpToDate printVersion # checkDeviceToTest # runConnectedTests From 6887c9185b0ae988eddcf85e3f1ab767219ec96d Mon Sep 17 00:00:00 2001 From: Lorenzo Mattei Date: Mon, 8 Jul 2019 12:53:01 +0200 Subject: [PATCH 009/446] Update finalize lane --- Gemfile.lock | 6 ++---- fastlane/Fastfile | 2 ++ fastlane/Pluginfile | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 51c616ebaa39..05f62721c7c5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,5 @@ -GIT - remote: https://github.com/wordpress-mobile/release-toolkit - revision: e1833343a11f01526c606c3f0215875aea77c2c7 - ref: e1833343a11f01526c606c3f0215875aea77c2c7 +PATH + remote: ../release-toolkit specs: fastlane-plugin-wpmreleasetoolkit (0.5.0) diffy (~> 3.3) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 1b7064a4bab5..5a9e21b06f5c 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -170,6 +170,8 @@ ENV["HAS_ALPHA_VERSION"]="true" lane :finalize_release do | options | android_finalize_prechecks(options) android_update_metadata(options) unless android_current_branch_is_hotfix + android_bump_version_final_release() unless android_current_branch_is_hotfix + android_tag_build(tag_alpha: false) end ##################################################################################### diff --git a/fastlane/Pluginfile b/fastlane/Pluginfile index d2b8c0e0b58f..3158b0644c1b 100644 --- a/fastlane/Pluginfile +++ b/fastlane/Pluginfile @@ -2,7 +2,8 @@ # # Ensure this file is checked in to source control! -gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', ref:'e1833343a11f01526c606c3f0215875aea77c2c7' +#gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', ref:'e1833343a11f01526c606c3f0215875aea77c2c7' +gem 'fastlane-plugin-wpmreleasetoolkit', path: '../../../wordpress-mobile/release-toolkit' From 04c2fad5c4f640a057b3684f5f11b813bdd79031 Mon Sep 17 00:00:00 2001 From: Lorenzo Mattei Date: Mon, 8 Jul 2019 12:53:16 +0200 Subject: [PATCH 010/446] Remove unused actions --- .../android_current_branch_is_hotfix.rb | 46 ---------- .../actions/android_finalize_prechecks.rb | 74 ----------------- fastlane/actions/android_update_metadata.rb | 48 ----------- .../actions/android_update_metadata_source.rb | 83 ------------------- 4 files changed, 251 deletions(-) delete mode 100644 fastlane/actions/android_current_branch_is_hotfix.rb delete mode 100644 fastlane/actions/android_finalize_prechecks.rb delete mode 100644 fastlane/actions/android_update_metadata.rb delete mode 100644 fastlane/actions/android_update_metadata_source.rb diff --git a/fastlane/actions/android_current_branch_is_hotfix.rb b/fastlane/actions/android_current_branch_is_hotfix.rb deleted file mode 100644 index a1de7634f7b1..000000000000 --- a/fastlane/actions/android_current_branch_is_hotfix.rb +++ /dev/null @@ -1,46 +0,0 @@ -module Fastlane - module Actions - module SharedValues - ANDROID_CURRENT_BRANCH_IS_HOTFIX_CUSTOM_VALUE = :ANDROID_CURRENT_BRANCH_IS_HOTFIX_CUSTOM_VALUE - end - - class AndroidCurrentBranchIsHotfixAction < Action - def self.run(params) - require_relative '../helpers/android_version_helper.rb' - Fastlane::Helpers::AndroidVersionHelper::is_hotfix(Fastlane::Helpers::AndroidVersionHelper::get_version_name) - end - - ##################################################### - # @!group Documentation - ##################################################### - - def self.description - "Checks if the current branch is for a hotfix" - end - - def self.details - "Checks if the current branch is for a hotfix" - end - - def self.available_options - - end - - def self.output - - end - - def self.return_value - "True if the branch is for a hotfix, false otherwise" - end - - def self.authors - ["loremattei"] - end - - def self.is_supported?(platform) - platform == :android - end - end - end -end diff --git a/fastlane/actions/android_finalize_prechecks.rb b/fastlane/actions/android_finalize_prechecks.rb deleted file mode 100644 index 1f7f4f8b0c12..000000000000 --- a/fastlane/actions/android_finalize_prechecks.rb +++ /dev/null @@ -1,74 +0,0 @@ -module Fastlane - module Actions - module SharedValues - ANDROID_FINALIZE_PRECHECKS_CUSTOM_VALUE = :ANDROID_FINALIZE_PRECHECKS_CUSTOM_VALUE - end - - class AndroidFinalizePrechecksAction < Action - def self.run(params) - UI.message "Skip confirm: #{params[:skip_confirm]}" - - require_relative '../helpers/android_version_helper.rb' - require_relative '../helpers/android_git_helper.rb' - - UI.user_error!("This is not a release branch. Abort.") unless other_action.git_branch.start_with?("release/") - - version = Fastlane::Helpers::AndroidVersionHelper::get_version_name - message = "Finalizing release: #{version}\n" - if (!params[:skip_confirm]) - if (!UI.confirm("#{message}Do you want to continue?")) - UI.user_error!("Aborted by user request") - end - else - UI.message(message) - end - - # Check local repo status - other_action.ensure_git_status_clean() - - version - end - - ##################################################### - # @!group Documentation - ##################################################### - - def self.description - "Runs some prechecks before finalizing a release" - end - - def self.details - "Runs some prechecks before finalizing a release" - end - - def self.available_options - # Define all options your action supports. - - # Below a few examples - [ - FastlaneCore::ConfigItem.new(key: :skip_confirm, - env_name: "FL_ANDROID_FINALIZE_PRECHECKS_SKIPCONFIRM", - description: "Skips confirmation", - is_string: false, # true: verifies the input is a string, false: every kind of value - default_value: false) # the default value if the user didn't provide one - ] - end - - def self.output - - end - - def self.return_value - "The current app version" - end - - def self.authors - ["loremattei"] - end - - def self.is_supported?(platform) - platform == :android - end - end - end -end diff --git a/fastlane/actions/android_update_metadata.rb b/fastlane/actions/android_update_metadata.rb deleted file mode 100644 index 248d101bc576..000000000000 --- a/fastlane/actions/android_update_metadata.rb +++ /dev/null @@ -1,48 +0,0 @@ -module Fastlane - module Actions - module SharedValues - ANDROID_UPDATE_METADATA_CUSTOM_VALUE = :ANDROID_UPDATE_METADATA_CUSTOM_VALUE - end - - class AndroidUpdateMetadataAction < Action - def self.run(params) - require_relative '../helpers/android_git_helper.rb' - - Fastlane::Helpers::AndroidGitHelper.update_metadata() - Fastlane::Action::sh("./tools/release-checks.sh") - end - - ##################################################### - # @!group Documentation - ##################################################### - - def self.description - "Downloads translated metadata from the translation system" - end - - def self.details - "Downloads translated metadata from the translation system" - end - - def self.available_options - - end - - def self.output - - end - - def self.return_value - - end - - def self.authors - ["loremattei"] - end - - def self.is_supported?(platform) - platform == :android - end - end - end -end diff --git a/fastlane/actions/android_update_metadata_source.rb b/fastlane/actions/android_update_metadata_source.rb deleted file mode 100644 index 1a64ce159685..000000000000 --- a/fastlane/actions/android_update_metadata_source.rb +++ /dev/null @@ -1,83 +0,0 @@ -module Fastlane - module Actions - class AndroidUpdateMetadataSourceAction < Action - def self.run(params) - # Check local repo status - other_action.ensure_git_status_clean() - - other_action.an_update_metadata_source(po_file_path: params[:po_file_path], - source_files: params[:source_files], - release_version: params[:release_version]) - - Action.sh("git add #{params[:po_file_path]}") - params[:source_files].each do | key, file | - Action.sh("git add #{file}") - end - - repo_status = Actions.sh("git status --porcelain") - repo_clean = repo_status.empty? - if (!repo_clean) then - Action.sh("git commit -m \"Update metadata strings\"") - Action.sh("git push") - end - end - - ##################################################### - # @!group Documentation - ##################################################### - - def self.description - "Updates the PlayStoreStrings.po file with the data from text source files" - end - - def self.details - "Updates the PlayStoreStrings.po file with the data from text source files" - end - - def self.available_options - # Define all options your action supports. - - # Below a few examples - [ - FastlaneCore::ConfigItem.new(key: :po_file_path, - env_name: "FL_ANDROID_UPDATE_METADATA_SOURCE_PO_FILE_PATH", - description: "The path of the .po file to update", - is_string: true, - verify_block: proc do |value| - UI.user_error!("No .po file path for UpdateMetadataSourceAction given, pass using `po_file_path: 'file path'`") unless (value and not value.empty?) - UI.user_error!("Couldn't find file at path '#{value}'") unless File.exist?(value) - end), - FastlaneCore::ConfigItem.new(key: :release_version, - env_name: "FL_ANDROID_UPDATE_METADATA_SOURCE_RELEASE_VERSION", - description: "The release version of the app (to use to mark the release notes)", - verify_block: proc do |value| - UI.user_error!("No relase version for UpdateMetadataSourceAction given, pass using `release_version: 'version'`") unless (value and not value.empty?) - end), - FastlaneCore::ConfigItem.new(key: :source_files, - env_name: "FL_ANDROID_UPDATE_METADATA_SOURCE_SOURCE_FILES", - description: "The hash with the path to the source files and the key to use to include their content", - is_string: false, - verify_block: proc do |value| - UI.user_error!("No source file hash for UpdateMetadataSourceAction given, pass using `source_files: 'source file hash'`") unless (value and not value.empty?) - end) - ] - end - - def self.output - - end - - def self.return_value - - end - - def self.authors - ["loremattei"] - end - - def self.is_supported?(platform) - platform == :android - end - end - end -end From ed9fe139e433667157a237dc1f5198685287fbef Mon Sep 17 00:00:00 2001 From: Lorenzo Mattei Date: Mon, 8 Jul 2019 18:38:46 +0200 Subject: [PATCH 011/446] Update metadata download lane --- fastlane/Fastfile | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 5a9e21b06f5c..86535c506869 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -169,9 +169,18 @@ ENV["HAS_ALPHA_VERSION"]="true" desc "Updates store metadata and runs the release checks" lane :finalize_release do | options | android_finalize_prechecks(options) - android_update_metadata(options) unless android_current_branch_is_hotfix - android_bump_version_final_release() unless android_current_branch_is_hotfix + hotfix = android_current_branch_is_hotfix + android_update_metadata(options) unless hotfix + android_bump_version_final_release() unless hotfix + version = android_get_release_version() unless hotfix + download_metadata_strings(version: version["name"], build_number: version["code"]) unless hotfix android_tag_build(tag_alpha: false) + + # Wrap up + removebranchprotection(repository:GHHELPER_REPO, branch: "release/#{version["name"]}") + setfrozentag(repository:GHHELPER_REPO, milestone: version["name"], freeze: false) + close_milestone(repository:GHHELPER_REPO, milestone: version["name"]) + create_new_milestone(repository:GHHELPER_REPO) end ##################################################################################### @@ -289,11 +298,15 @@ ENV["HAS_ALPHA_VERSION"]="true" } delete_old_changelogs(build: options[:build_number]) + download_path=Dir.pwd + "/metadata/android" gp_downloadmetadata(project_url: "https://translate.wordpress.org/projects/apps/android/release-notes/", target_files: files, locales: SUPPORTED_LOCALES.map {| hsh | [ hsh[:glotpress], hsh[:google_play] ]}, source_locale: "en-US", - download_path: Dir.pwd + "/metadata/android") + download_path: download_path) + + android_create_xml_release_notes(download_path: download_path, build_number: "#{options[:build_number]}", locales: SUPPORTED_LOCALES.map {| hsh | [ hsh[:glotpress], hsh[:google_play] ]}) + sh("git add #{download_path} && git commit -m \"Update metadata translations for #{options[:version]}\" && git push") end ######################################################################## From 9d79b3a78f35481f1d1238caaac494c05b06f7e3 Mon Sep 17 00:00:00 2001 From: Lorenzo Mattei Date: Mon, 8 Jul 2019 18:55:57 +0200 Subject: [PATCH 012/446] Update to the latest release-toolkit --- Gemfile.lock | 6 ++++-- fastlane/Pluginfile | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 05f62721c7c5..878972475c61 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,5 +1,7 @@ -PATH - remote: ../release-toolkit +GIT + remote: https://github.com/wordpress-mobile/release-toolkit + revision: 74f7c92135ff0422c336964c782ee6bebb46cfa1 + ref: 74f7c92135ff0422c336964c782ee6bebb46cfa1 specs: fastlane-plugin-wpmreleasetoolkit (0.5.0) diffy (~> 3.3) diff --git a/fastlane/Pluginfile b/fastlane/Pluginfile index 3158b0644c1b..71d6c66c4969 100644 --- a/fastlane/Pluginfile +++ b/fastlane/Pluginfile @@ -2,8 +2,7 @@ # # Ensure this file is checked in to source control! -#gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', ref:'e1833343a11f01526c606c3f0215875aea77c2c7' -gem 'fastlane-plugin-wpmreleasetoolkit', path: '../../../wordpress-mobile/release-toolkit' +gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', ref:'74f7c92135ff0422c336964c782ee6bebb46cfa1' From 3a64d90feb8c08a2971823fe9da93d638a7820ae Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 10 Jul 2019 13:02:18 -0700 Subject: [PATCH 013/446] When arriving to a wizard site creation step, make sure old data from previous visits is cleared for that step. --- .../android/ui/sitecreation/SiteCreationMainVM.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt index e5a4d686a932..65177a4438f5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt @@ -12,6 +12,10 @@ import org.wordpress.android.R import org.wordpress.android.ui.sitecreation.SiteCreationMainVM.SiteCreationScreenTitle.ScreenTitleEmpty import org.wordpress.android.ui.sitecreation.SiteCreationMainVM.SiteCreationScreenTitle.ScreenTitleGeneral import org.wordpress.android.ui.sitecreation.SiteCreationMainVM.SiteCreationScreenTitle.ScreenTitleStepCount +import org.wordpress.android.ui.sitecreation.SiteCreationStep.DOMAINS +import org.wordpress.android.ui.sitecreation.SiteCreationStep.SEGMENTS +import org.wordpress.android.ui.sitecreation.SiteCreationStep.SITE_INFO +import org.wordpress.android.ui.sitecreation.SiteCreationStep.VERTICALS import org.wordpress.android.ui.sitecreation.misc.SiteCreationTracker import org.wordpress.android.ui.sitecreation.previews.SitePreviewViewModel.CreateSiteState import org.wordpress.android.ui.utils.UiString.UiStringRes @@ -51,6 +55,7 @@ class SiteCreationMainVM @Inject constructor( val navigationTargetObservable: SingleEventObservable by lazy { SingleEventObservable( Transformations.map(wizardManager.navigatorLiveData) { + clearOldState(it) WizardNavigationTarget(it, siteCreationState) } ) @@ -114,6 +119,15 @@ class SiteCreationMainVM @Inject constructor( } } + private fun clearOldState(wizardStep: SiteCreationStep) { + when (wizardStep) { + SEGMENTS -> siteCreationState = siteCreationState.copy(segmentId = null) + VERTICALS -> siteCreationState = siteCreationState.copy(verticalId = null) + SITE_INFO -> siteCreationState = siteCreationState.copy(siteTitle = null, siteTagLine = null) + DOMAINS -> siteCreationState = siteCreationState.copy(domain = null) + } + } + fun onVerticalsScreenFinished(verticalId: String) { siteCreationState = siteCreationState.copy(verticalId = verticalId) wizardManager.showNextStep() From 895c9d1e41e632cc1748f5e1bee229a95c9a3875 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 10 Jul 2019 16:59:32 -0700 Subject: [PATCH 014/446] Add stubbing for wizardManager.showNextStep() in selectSegment test so that we do not go straight back to segment step and clear our state --- .../android/ui/sitecreation/SiteCreationMainVMTest.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt index 728a0c5bb586..8530da2e1e4f 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt @@ -107,6 +107,10 @@ class SiteCreationMainVMTest { @Test fun siteCreationStateUpdatedWithSelectedSegment() { + whenever(wizardManager.showNextStep()).then { + wizardManagerNavigatorLiveData.value = SiteCreationStep.VERTICALS + Unit + } viewModel.onSegmentSelected(SEGMENT_ID) assertThat(currentWizardState(viewModel).segmentId).isEqualTo(SEGMENT_ID) } From 72624fcf36a740063dafa6213818c5c0f20e3e43 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 11 Jul 2019 17:44:22 -0700 Subject: [PATCH 015/446] Made method name more specific. No longer copy data class unless value is not null, in order to limit unnecessary updates to the state and to simplify testing while retaining default data class equality --- .../ui/sitecreation/SiteCreationMainVM.kt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt index 65177a4438f5..f27e97859a49 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt @@ -55,7 +55,7 @@ class SiteCreationMainVM @Inject constructor( val navigationTargetObservable: SingleEventObservable by lazy { SingleEventObservable( Transformations.map(wizardManager.navigatorLiveData) { - clearOldState(it) + clearOldSiteCreationState(it) WizardNavigationTarget(it, siteCreationState) } ) @@ -119,12 +119,18 @@ class SiteCreationMainVM @Inject constructor( } } - private fun clearOldState(wizardStep: SiteCreationStep) { + private fun clearOldSiteCreationState(wizardStep: SiteCreationStep) { when (wizardStep) { - SEGMENTS -> siteCreationState = siteCreationState.copy(segmentId = null) - VERTICALS -> siteCreationState = siteCreationState.copy(verticalId = null) - SITE_INFO -> siteCreationState = siteCreationState.copy(siteTitle = null, siteTagLine = null) - DOMAINS -> siteCreationState = siteCreationState.copy(domain = null) + SEGMENTS -> siteCreationState.segmentId?.let { + siteCreationState = siteCreationState.copy(segmentId = null) } + VERTICALS -> siteCreationState.verticalId?.let { + siteCreationState = siteCreationState.copy(verticalId = null) } + SITE_INFO -> { + siteCreationState.siteTitle?.let { siteCreationState = siteCreationState.copy(siteTitle = null) } + siteCreationState.siteTagLine?.let { siteCreationState = siteCreationState.copy(siteTagLine = null) } + } + DOMAINS -> siteCreationState.domain?.let { + siteCreationState = siteCreationState.copy(domain = null) } } } From becd76ce65dd414069e648b1b0cf94ba57ab8140 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 11 Jul 2019 17:47:12 -0700 Subject: [PATCH 016/446] Updated stateRestored test to model a real use case that does not fail because of cleared state --- .../android/ui/sitecreation/SiteCreationMainVMTest.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt index 8530da2e1e4f..f03e8b928b34 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt @@ -221,7 +221,9 @@ class SiteCreationMainVMTest { @Test fun siteCreationStateRestored() { - val expectedState = SiteCreationState() + /* we need to model a real use case of data only existing for steps the user has visited (Segment only in + this case). Otherwise, subsequent steps' state will be cleared and make the test fail. (issue #10189)*/ + val expectedState = SiteCreationState(1L) whenever(savedInstanceState.getParcelable(KEY_SITE_CREATION_STATE)) .thenReturn(expectedState) @@ -229,9 +231,9 @@ class SiteCreationMainVMTest { val newViewModel = SiteCreationMainVM(tracker, wizardManager) newViewModel.start(savedInstanceState) - /* we need simulate navigation to the next step as wizardManager.showNextStep() isn't invoked - when the VM is restored from a savedInstanceState. */ - wizardManagerNavigatorLiveData.value = siteCreationStep + /* we need to simulate navigation to the next step (Vertical selection, see comment above) as + wizardManager.showNextStep() isn't invoked when the VM is restored from a savedInstanceState. */ + wizardManagerNavigatorLiveData.value = SiteCreationStep.VERTICALS newViewModel.navigationTargetObservable.observeForever(navigationTargetObserver) assertThat(currentWizardState(newViewModel)).isSameAs(expectedState) From cd0d976aa5fae6684e6be579384fdd3db7fb97da Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 11 Jul 2019 17:59:15 -0700 Subject: [PATCH 017/446] Added new test for clearing old site creation data when returning to a step --- .../ui/sitecreation/SiteCreationMainVMTest.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt index f03e8b928b34..0f06dcec5197 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt @@ -255,6 +255,19 @@ class SiteCreationMainVMTest { verify(wizardManager).setCurrentStepIndex(index) } + @Test + fun oldSiteCreationDataClearedWhenReturningToPreviousStep() { + // See issue #10189 - unintended data retained if user goes backwards in wizard + whenever(wizardManager.showNextStep()).then { + wizardManagerNavigatorLiveData.value = SiteCreationStep.SITE_INFO + Unit + } + viewModel.onVerticalsScreenFinished(VERTICAL_ID) + assertThat(currentWizardState(viewModel).verticalId).isEqualTo(VERTICAL_ID) + wizardManagerNavigatorLiveData.value = SiteCreationStep.VERTICALS + assertThat(currentWizardState(viewModel).verticalId).isEqualTo(null) + } + private fun currentWizardState(vm: SiteCreationMainVM) = vm.navigationTargetObservable.lastEvent!!.wizardState } From 01f65f5e614957bfe8f97678891df3057645186f Mon Sep 17 00:00:00 2001 From: Javon Date: Fri, 12 Jul 2019 15:21:13 -0500 Subject: [PATCH 018/446] add README for UI tests --- .../java/org/wordpress/android/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 WordPress/src/androidTest/java/org/wordpress/android/README.md diff --git a/WordPress/src/androidTest/java/org/wordpress/android/README.md b/WordPress/src/androidTest/java/org/wordpress/android/README.md new file mode 100644 index 000000000000..fc0fa6208db1 --- /dev/null +++ b/WordPress/src/androidTest/java/org/wordpress/android/README.md @@ -0,0 +1,14 @@ +## UI tests Overview + +WordPress for Android has UI acceptance tests for critical user flows through the app, such as login, +signup, and publishing. The tests use mocked network requests with [WireMock](http://wiremock.org/), +defined in [WordPressMocks](https://github.com/wordpress-mobile/WordPressMocks). + +## Running the tests + +**Note that due to the mock server setup, tests cannot be run on physical devices right now.** + + +1. Follow the [build instructions](https://github.com/wordpress-mobile/WordPress-Android#build-instructions) + (steps 1-7) to clone, build and run the project in Android Studio. +2. Run the tests `/Users/javon/Automattic-Projects/WordPress-Android/WordPress/src/androidTest/java/org/wordpress/android/e2e` \ No newline at end of file From ab09353f5f2679529d69e08113298d12d5d1c43b Mon Sep 17 00:00:00 2001 From: Javon Date: Mon, 15 Jul 2019 08:44:44 -0500 Subject: [PATCH 019/446] add README for UI tests --- .../java/org/wordpress/android/README.md | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/WordPress/src/androidTest/java/org/wordpress/android/README.md b/WordPress/src/androidTest/java/org/wordpress/android/README.md index fc0fa6208db1..cd1ff4e23598 100644 --- a/WordPress/src/androidTest/java/org/wordpress/android/README.md +++ b/WordPress/src/androidTest/java/org/wordpress/android/README.md @@ -11,4 +11,35 @@ defined in [WordPressMocks](https://github.com/wordpress-mobile/WordPressMocks). 1. Follow the [build instructions](https://github.com/wordpress-mobile/WordPress-Android#build-instructions) (steps 1-7) to clone, build and run the project in Android Studio. -2. Run the tests `/Users/javon/Automattic-Projects/WordPress-Android/WordPress/src/androidTest/java/org/wordpress/android/e2e` \ No newline at end of file +2. Run the tests in `Tests in org.wordpress.android.e2e` + +There's no additional steps needed to make the tests run against the mock server -- that's configured set up by default + +## Adding a new test? + +Great! When adding a new UI test, consider: + +* Whether you need to test a user flow (to accomplish a task or goal) or a specific feature (e.g. boundary testing). +* What screens/pages are being tested(defined in `pages/`). +* What user flows are being used(defined in `flows/`). +* Any specific UI components being interacted with?(defined in `components/`). +* What network requests are made during the test (defined in the `WordPressMocks` repo). + +It's preferred to focus UI tests on entire user flows, and group tests with related flows or goals in the same test file. + +When you add a new test, you may need to add new screens, methods, and flows, when writing these I encourage to check +`support/WPSupportUtils.java` for additional code to reuse to automating the task. Our tests are also used to generate screenshots +and a lot of useful helper functions are made available through that auxillary file. Wherever possible, avoid the use + of a string to select a UI element on the screen, the use of other identifiers such as id or content description is preferable + and should be used where possible, even if that means adding it to a UI element that might be missing the appropriate field. + This ensures tests can be run regardless of the device language. + +## Adding or updating network mocks + +When you add a test (or when the app changes), the request definitions for WireMock need to be updated. You can read WireMock’s documentation [here](http://wiremock.org/docs/). + +If you are unsure what network requests need to be mocked for a test, an easy way to find out is to run the app through [Charles Proxy](https://www.charlesproxy.com/) and observe the required requests. + +`WordPressMocks` is included as a library in `WordPress-Android` and are located in `libs/mocks/WordPressMocks/`, you can update +your local mock files and make changes here. Additionally a pull request updating the mocks +here should have an accompanying pull request to the `WordPressMocks` repo so that the mocks can be shared across the platforms. \ No newline at end of file From d5d89daea14bb7a9db9964d23bb802ccc2781091 Mon Sep 17 00:00:00 2001 From: Javon Date: Mon, 15 Jul 2019 11:07:52 -0500 Subject: [PATCH 020/446] include missing mock file --- .../rest_v2_sites_158396482_gutenberg.json | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 libs/mocks/WordPressMocks/src/main/assets/mocks/mappings/wpcom/sites/rest_v2_sites_158396482_gutenberg.json diff --git a/libs/mocks/WordPressMocks/src/main/assets/mocks/mappings/wpcom/sites/rest_v2_sites_158396482_gutenberg.json b/libs/mocks/WordPressMocks/src/main/assets/mocks/mappings/wpcom/sites/rest_v2_sites_158396482_gutenberg.json new file mode 100644 index 000000000000..b4e3d0d7c6d8 --- /dev/null +++ b/libs/mocks/WordPressMocks/src/main/assets/mocks/mappings/wpcom/sites/rest_v2_sites_158396482_gutenberg.json @@ -0,0 +1,30 @@ +{ + "request": { + "urlPattern": "/wpcom/v2/sites/158396482/gutenberg(/)?($|\\?.*)", + "method": "POST", + "headers": { + "Content-Type": { + "equalTo": "application/json; charset=UTF-8" + } + }, + "bodyPatterns" : [ { + "equalToJson" : { + "editor" : "aztec", + "platform" : "mobile" + } + } ] + }, + "response": { + "status": 200, + "jsonBody": { + "editor_mobile": "aztec", + "editor_web": "gutenberg", + "opt_in": "https:\/\/public-api.wordpress.com\/wpcom\/v2\/sites\/158396482\/gutenberg?editor=gutenberg&platform=mobile" + }, + "headers": { + "Content-Type": "application/json", + "Connection": "keep-alive", + "Cache-Control": "no-cache, must-revalidate, max-age=0" + } + } +} \ No newline at end of file From 7bd7d79bcc0911ebb38a5d03a753c482ee2804fa Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Jul 2019 09:59:29 -0700 Subject: [PATCH 021/446] Removed unnecessary whenever to make oldSiteCreationDataCleared test easier to read. --- .../android/ui/sitecreation/SiteCreationMainVMTest.kt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt index 0f06dcec5197..5caad8fcc3d3 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt @@ -258,10 +258,6 @@ class SiteCreationMainVMTest { @Test fun oldSiteCreationDataClearedWhenReturningToPreviousStep() { // See issue #10189 - unintended data retained if user goes backwards in wizard - whenever(wizardManager.showNextStep()).then { - wizardManagerNavigatorLiveData.value = SiteCreationStep.SITE_INFO - Unit - } viewModel.onVerticalsScreenFinished(VERTICAL_ID) assertThat(currentWizardState(viewModel).verticalId).isEqualTo(VERTICAL_ID) wizardManagerNavigatorLiveData.value = SiteCreationStep.VERTICALS From c19b468e1c6ab01e85d3a38bd00a93ed0312fb82 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Jul 2019 10:01:09 -0700 Subject: [PATCH 022/446] Exchanged hardcoded value for labeled SEGMENT_ID constant --- .../wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt index 5caad8fcc3d3..abc90fbb3f89 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVMTest.kt @@ -223,7 +223,7 @@ class SiteCreationMainVMTest { fun siteCreationStateRestored() { /* we need to model a real use case of data only existing for steps the user has visited (Segment only in this case). Otherwise, subsequent steps' state will be cleared and make the test fail. (issue #10189)*/ - val expectedState = SiteCreationState(1L) + val expectedState = SiteCreationState(SEGMENT_ID) whenever(savedInstanceState.getParcelable(KEY_SITE_CREATION_STATE)) .thenReturn(expectedState) From 1c8d8e7c78f516558996298b4a47d583adce7996 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 15 Jul 2019 10:11:16 -0700 Subject: [PATCH 023/446] Completed when options to suppress Android Studio warning --- .../org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt index f27e97859a49..3803f0b1c59c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/sitecreation/SiteCreationMainVM.kt @@ -15,6 +15,7 @@ import org.wordpress.android.ui.sitecreation.SiteCreationMainVM.SiteCreationScre import org.wordpress.android.ui.sitecreation.SiteCreationStep.DOMAINS import org.wordpress.android.ui.sitecreation.SiteCreationStep.SEGMENTS import org.wordpress.android.ui.sitecreation.SiteCreationStep.SITE_INFO +import org.wordpress.android.ui.sitecreation.SiteCreationStep.SITE_PREVIEW import org.wordpress.android.ui.sitecreation.SiteCreationStep.VERTICALS import org.wordpress.android.ui.sitecreation.misc.SiteCreationTracker import org.wordpress.android.ui.sitecreation.previews.SitePreviewViewModel.CreateSiteState @@ -131,6 +132,7 @@ class SiteCreationMainVM @Inject constructor( } DOMAINS -> siteCreationState.domain?.let { siteCreationState = siteCreationState.copy(domain = null) } + SITE_PREVIEW -> {} // intentionally left empty } } From 6037392ddf678931215e8b84728971cfee779091 Mon Sep 17 00:00:00 2001 From: Javon Date: Mon, 15 Jul 2019 15:30:22 -0500 Subject: [PATCH 024/446] add additional documentation on mock files with charles --- libs/mocks/WordPressMocks/README.md | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 libs/mocks/WordPressMocks/README.md diff --git a/libs/mocks/WordPressMocks/README.md b/libs/mocks/WordPressMocks/README.md new file mode 100644 index 000000000000..dbe780faeb07 --- /dev/null +++ b/libs/mocks/WordPressMocks/README.md @@ -0,0 +1,34 @@ +## WordPress Mocks + +Clone of mock files in https://github.com/wordpress-mobile/WordPressMocks. + +It contains a number of JSON files used by WireMock to handle requests and are located in `src/main/assets`. To generate one of these files +you're fist going to want to set up Charles to work with your Android emulator. If you've never done this I found +[this article](https://medium.com/@daptronic/the-android-emulator-and-charles-proxy-a-love-story-595c23484e02) to be a +good place to start. Once you've done that you'll want to walk through the specfic flow you're testing and store the JSON contents +of the necessary responses in the `jsonBody` field of the `response` field in the mock file. + +Here's an example of what this might look like, + +``` +{ + "request": { + "urlPattern": "/rest/v1.1/me/", + "method": "GET" + }, + "response": { + "status": 200, + "jsonBody": { + // ..... Your response here + }, + "headers": { + "Content-Type": "application/json", + "Connection": "keep-alive", + "Cache-Control": "no-cache, must-revalidate, max-age=0" + } + } +} +``` + +These files are used to match network requests while the tests are being ran. For more on request matching with +WireMock check out [their documentation](http://wiremock.org/docs/request-matching/). \ No newline at end of file From 555a125d2d053b26b658f7155ba8f043987de598 Mon Sep 17 00:00:00 2001 From: Javon Date: Mon, 15 Jul 2019 17:09:10 -0500 Subject: [PATCH 025/446] move location of mock example --- libs/mocks/README.md | 35 +++++++++++++++++++++++++++++ libs/mocks/WordPressMocks/README.md | 34 ---------------------------- 2 files changed, 35 insertions(+), 34 deletions(-) delete mode 100644 libs/mocks/WordPressMocks/README.md diff --git a/libs/mocks/README.md b/libs/mocks/README.md index 6e0236221671..8003e708f91f 100644 --- a/libs/mocks/README.md +++ b/libs/mocks/README.md @@ -62,6 +62,41 @@ Note: You can add this repository as a remote to simplify the `git subtree push` This will allow to use this form instead: $ git subtree pull --prefix=libs/mocks mockslib develop --squash + + +## Creating a mock file + +The JSON files used by WireMock to handle requests and are located in `src/main/assets`. To generate one of these files +you're first going to want to set up [Charles Proxy](https://www.charlesproxy.com/)(or similar) to work with your Android emulator. + If you've never done this I found +[this article](https://medium.com/@daptronic/the-android-emulator-and-charles-proxy-a-love-story-595c23484e02) to be a +good place to start. Once you've done that you'll want to walk through the specfic flow you're testing and store the JSON contents +of the necessary responses in the `jsonBody` field of the `response` field in the mock file. + +Here's an example of what this might look like, + +``` +{ + "request": { + "urlPattern": "/rest/v1.1/me/", + "method": "GET" + }, + "response": { + "status": 200, + "jsonBody": { + // ..... Your response here + }, + "headers": { + "Content-Type": "application/json", + "Connection": "keep-alive", + "Cache-Control": "no-cache, must-revalidate, max-age=0" + } + } +} +``` + +These files are used to match network requests while the tests are being ran. For more on request matching with +WireMock check out [their documentation](http://wiremock.org/docs/request-matching/). ## License ## diff --git a/libs/mocks/WordPressMocks/README.md b/libs/mocks/WordPressMocks/README.md deleted file mode 100644 index dbe780faeb07..000000000000 --- a/libs/mocks/WordPressMocks/README.md +++ /dev/null @@ -1,34 +0,0 @@ -## WordPress Mocks - -Clone of mock files in https://github.com/wordpress-mobile/WordPressMocks. - -It contains a number of JSON files used by WireMock to handle requests and are located in `src/main/assets`. To generate one of these files -you're fist going to want to set up Charles to work with your Android emulator. If you've never done this I found -[this article](https://medium.com/@daptronic/the-android-emulator-and-charles-proxy-a-love-story-595c23484e02) to be a -good place to start. Once you've done that you'll want to walk through the specfic flow you're testing and store the JSON contents -of the necessary responses in the `jsonBody` field of the `response` field in the mock file. - -Here's an example of what this might look like, - -``` -{ - "request": { - "urlPattern": "/rest/v1.1/me/", - "method": "GET" - }, - "response": { - "status": 200, - "jsonBody": { - // ..... Your response here - }, - "headers": { - "Content-Type": "application/json", - "Connection": "keep-alive", - "Cache-Control": "no-cache, must-revalidate, max-age=0" - } - } -} -``` - -These files are used to match network requests while the tests are being ran. For more on request matching with -WireMock check out [their documentation](http://wiremock.org/docs/request-matching/). \ No newline at end of file From 3d43b3c2ca0d96045f697c1072cee483956de918 Mon Sep 17 00:00:00 2001 From: AmandaRiu Date: Mon, 15 Jul 2019 21:10:19 -0600 Subject: [PATCH 026/446] Revert unintentional config changes --- .idea/codeStyles/Project.xml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index e83ad190f0af..40146908b459 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,10 +1,42 @@ + + +