Skip to content

Commit 5fb1a22

Browse files
author
AmandaRiu
committed
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
1 parent ad485b2 commit 5fb1a22

38 files changed

+295
-130
lines changed

WordPressLoginFlow/build.gradle

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ buildscript {
44
jcenter()
55
}
66
dependencies {
7-
classpath 'com.android.tools.build:gradle:3.2.1'
7+
classpath 'com.android.tools.build:gradle:3.3.2'
88
}
99
}
1010

@@ -35,12 +35,12 @@ dependencies {
3535
exclude group: "com.mcxiaoke.volley"
3636
}
3737

38-
implementation 'com.android.support:appcompat-v7:28.0.0'
39-
implementation 'com.android.support:animated-vector-drawable:28.0.0'
40-
implementation 'com.android.support:support-media-compat:28.0.0'
41-
implementation 'com.android.support:support-v13:28.0.0'
42-
implementation 'com.android.support:gridlayout-v7:28.0.0'
43-
implementation 'com.android.support:design:28.0.0'
38+
implementation 'androidx.appcompat:appcompat:1.0.2'
39+
implementation 'androidx.vectordrawable:vectordrawable-animated:1.0.0'
40+
implementation 'androidx.media:media:1.0.1'
41+
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
42+
implementation 'androidx.gridlayout:gridlayout:1.0.0'
43+
implementation 'com.google.android.material:material:1.0.0'
4444

4545
api 'com.google.android.gms:play-services-auth:15.0.1'
4646

@@ -51,7 +51,7 @@ dependencies {
5151
exclude group: "org.wordpress", module: "utils"
5252
}
5353
} else {
54-
implementation("com.github.wordpress-mobile.WordPress-FluxC-Android:fluxc:8cdbf03cf3d595ef904bab3c1dc207e39242c882") {
54+
implementation("com.github.wordpress-mobile.WordPress-FluxC-Android:fluxc:9f07b031646dd3e6021d4b8e0a35647c9109ff27") {
5555
exclude group: "com.android.support"
5656
exclude group: "org.wordpress", module: "utils"
5757
}
@@ -61,11 +61,11 @@ dependencies {
6161
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
6262

6363
// Dagger
64-
implementation 'com.google.dagger:dagger:2.11'
65-
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
64+
implementation 'com.google.dagger:dagger:2.22.1'
65+
annotationProcessor 'com.google.dagger:dagger-compiler:2.22.1'
6666
compileOnly 'org.glassfish:javax.annotation:10.0-b28'
67-
implementation 'com.google.dagger:dagger-android-support:2.11'
68-
annotationProcessor 'com.google.dagger:dagger-android-processor:2.11'
67+
implementation 'com.google.dagger:dagger-android-support:2.22.1'
68+
annotationProcessor 'com.google.dagger:dagger-android-processor:2.22.1'
6969

7070
lintChecks 'org.wordpress:lint:1.0.1'
7171
}

WordPressLoginFlow/src/main/java/org/wordpress/android/login/GoogleFragment.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
import android.content.Intent;
55
import android.content.IntentSender;
66
import android.os.Bundle;
7-
import android.support.annotation.NonNull;
8-
import android.support.v4.app.Fragment;
97
import android.util.Log;
108

9+
import androidx.annotation.NonNull;
10+
import androidx.fragment.app.Fragment;
11+
1112
import com.google.android.gms.auth.api.Auth;
1213
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
1314
import com.google.android.gms.common.ConnectionResult;

WordPressLoginFlow/src/main/java/org/wordpress/android/login/Login2FaFragment.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
import android.content.ClipboardManager;
44
import android.content.Context;
55
import android.os.Bundle;
6-
import android.support.annotation.LayoutRes;
7-
import android.support.annotation.NonNull;
8-
import android.support.annotation.Nullable;
9-
import android.support.annotation.StringRes;
10-
import android.support.v7.app.AlertDialog;
116
import android.text.Editable;
127
import android.text.TextUtils;
138
import android.text.TextWatcher;
@@ -20,6 +15,12 @@
2015
import android.widget.EditText;
2116
import android.widget.TextView;
2217

18+
import androidx.annotation.LayoutRes;
19+
import androidx.annotation.NonNull;
20+
import androidx.annotation.Nullable;
21+
import androidx.annotation.StringRes;
22+
import androidx.appcompat.app.AlertDialog;
23+
2324
import org.greenrobot.eventbus.Subscribe;
2425
import org.greenrobot.eventbus.ThreadMode;
2526
import org.wordpress.android.fluxc.generated.AccountActionBuilder;

WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginAnalyticsListener.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,7 @@ public interface LoginAnalyticsListener {
5151
void trackUrlHelpScreenViewed();
5252
void trackUsernamePasswordFormViewed();
5353
void trackWpComBackgroundServiceUpdate(Map<String, ?> properties);
54+
void trackConnectedSiteInfoRequested(String url);
55+
void trackConnectedSiteInfoFailed(String url, String errorContext, String errorType, String errorDescription);
56+
void trackConnectedSiteInfoSucceeded(Map<String, ?> properties);
5457
}

WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginBaseFormFragment.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@
55
import android.content.DialogInterface;
66
import android.net.Uri;
77
import android.os.Bundle;
8-
import android.support.annotation.CallSuper;
9-
import android.support.annotation.LayoutRes;
10-
import android.support.annotation.NonNull;
11-
import android.support.annotation.Nullable;
12-
import android.support.annotation.StringRes;
13-
import android.support.v4.app.Fragment;
14-
import android.support.v7.app.ActionBar;
15-
import android.support.v7.app.AppCompatActivity;
16-
import android.support.v7.widget.Toolbar;
178
import android.text.TextWatcher;
189
import android.view.LayoutInflater;
1910
import android.view.Menu;
@@ -26,20 +17,32 @@
2617
import android.widget.EditText;
2718
import android.widget.TextView;
2819

20+
import androidx.annotation.CallSuper;
21+
import androidx.annotation.LayoutRes;
22+
import androidx.annotation.NonNull;
23+
import androidx.annotation.Nullable;
24+
import androidx.annotation.StringRes;
25+
import androidx.appcompat.app.ActionBar;
26+
import androidx.appcompat.app.AppCompatActivity;
27+
import androidx.appcompat.widget.Toolbar;
28+
import androidx.fragment.app.Fragment;
29+
2930
import org.greenrobot.eventbus.Subscribe;
3031
import org.greenrobot.eventbus.ThreadMode;
3132
import org.wordpress.android.fluxc.Dispatcher;
3233
import org.wordpress.android.fluxc.action.AccountAction;
3334
import org.wordpress.android.fluxc.generated.AccountActionBuilder;
3435
import org.wordpress.android.fluxc.generated.SiteActionBuilder;
3536
import org.wordpress.android.fluxc.store.AccountStore;
37+
import org.wordpress.android.fluxc.store.AccountStore.AccountErrorType;
3638
import org.wordpress.android.fluxc.store.AccountStore.OnAccountChanged;
3739
import org.wordpress.android.fluxc.store.SiteStore;
3840
import org.wordpress.android.fluxc.store.SiteStore.OnSiteChanged;
3941
import org.wordpress.android.fluxc.store.SiteStore.SiteErrorType;
4042
import org.wordpress.android.util.AppLog;
4143
import org.wordpress.android.util.EditTextUtils;
4244
import org.wordpress.android.util.ToastUtils;
45+
import org.wordpress.android.util.ToastUtils.Duration;
4346

4447
import javax.inject.Inject;
4548

@@ -290,9 +293,15 @@ public void onAccountChanged(OnAccountChanged event) {
290293

291294
if (event.isError()) {
292295
AppLog.e(AppLog.T.API, "onAccountChanged has error: " + event.error.type + " - " + event.error.message);
293-
ToastUtils.showToast(getContext(), R.string.error_fetch_my_profile);
294-
onLoginFinished(false);
295-
return;
296+
if (event.error.type == AccountErrorType.SETTINGS_FETCH_REAUTHORIZATION_REQUIRED_ERROR) {
297+
// This probably means we're logging in to 2FA-enabled account with a non-production WP.com client id.
298+
// A few WordPress.com APIs like /me/settings/ won't work for this account.
299+
ToastUtils.showToast(getContext(), R.string.error_disabled_apis, Duration.LONG);
300+
} else {
301+
ToastUtils.showToast(getContext(), R.string.error_fetch_my_profile, Duration.LONG);
302+
onLoginFinished(false);
303+
return;
304+
}
296305
}
297306

298307
if (event.causeOfChange == AccountAction.FETCH_ACCOUNT) {

WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginEmailFragment.java

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
package org.wordpress.android.login;
22

33
import android.app.PendingIntent;
4+
import android.content.ActivityNotFoundException;
45
import android.content.Context;
56
import android.content.Intent;
67
import android.content.IntentSender;
78
import android.os.Bundle;
8-
import android.support.annotation.LayoutRes;
9-
import android.support.annotation.NonNull;
10-
import android.support.annotation.Nullable;
11-
import android.support.v7.app.AlertDialog;
129
import android.text.Editable;
1310
import android.text.Html;
1411
import android.text.TextWatcher;
@@ -22,6 +19,11 @@
2219
import android.widget.LinearLayout;
2320
import android.widget.TextView;
2421

22+
import androidx.annotation.LayoutRes;
23+
import androidx.annotation.NonNull;
24+
import androidx.annotation.Nullable;
25+
import androidx.appcompat.app.AlertDialog;
26+
2527
import com.google.android.gms.auth.api.Auth;
2628
import com.google.android.gms.auth.api.credentials.Credential;
2729
import com.google.android.gms.auth.api.credentials.CredentialPickerConfig;
@@ -66,6 +68,9 @@ public class LoginEmailFragment extends LoginBaseFormFragment<LoginListener> imp
6668
private static final int GOOGLE_API_CLIENT_ID = 1002;
6769
private static final int EMAIL_CREDENTIALS_REQUEST_CODE = 25100;
6870

71+
private static final String ARG_HIDE_LOGIN_BY_SITE_OPTION = "ARG_HIDE_LOGIN_BY_SITE_OPTION";
72+
private static final String ARG_LOGIN_SITE_URL = "ARG_LOGIN_SITE_URL";
73+
6974
public static final String TAG = "login_email_fragment_tag";
7075
public static final int MAX_EMAIL_LENGTH = 100;
7176

@@ -78,6 +83,17 @@ public class LoginEmailFragment extends LoginBaseFormFragment<LoginListener> imp
7883
protected WPLoginInputRow mEmailInput;
7984
protected boolean mHasDismissedEmailHints;
8085
protected boolean mIsDisplayingEmailHints;
86+
protected boolean mHideLoginWithSiteOption;
87+
protected String mLoginSiteUrl;
88+
89+
public static LoginEmailFragment newInstance(Boolean hideLoginWithSiteOption, String url) {
90+
LoginEmailFragment fragment = new LoginEmailFragment();
91+
Bundle args = new Bundle();
92+
args.putBoolean(ARG_HIDE_LOGIN_BY_SITE_OPTION, hideLoginWithSiteOption);
93+
args.putString(ARG_LOGIN_SITE_URL, url);
94+
fragment.setArguments(args);
95+
return fragment;
96+
}
8197

8298
@Override
8399
protected @LayoutRes int getContentLayout() {
@@ -102,6 +118,9 @@ protected void setupLabel(@NonNull TextView label) {
102118
case WPCOM_LOGIN_ONLY:
103119
label.setText(R.string.enter_email_wordpress_com);
104120
break;
121+
case WOO_LOGIN_MODE:
122+
label.setText(getString(R.string.enter_email_for_site, mLoginSiteUrl));
123+
break;
105124
case JETPACK_STATS:
106125
label.setText(R.string.login_to_to_connect_jetpack);
107126
break;
@@ -161,25 +180,30 @@ public void onClick(View view) {
161180
});
162181

163182
LinearLayout siteLoginButton = rootView.findViewById(R.id.login_site_button);
164-
siteLoginButton.setOnClickListener(new OnClickListener() {
165-
@Override
166-
public void onClick(View view) {
167-
if (mLoginListener != null) {
168-
if (mLoginListener.getLoginMode() == LoginMode.JETPACK_STATS) {
169-
mLoginListener.loginViaWpcomUsernameInstead();
170-
} else {
171-
mLoginListener.loginViaSiteAddress();
183+
if (mHideLoginWithSiteOption) {
184+
siteLoginButton.setVisibility(View.GONE);
185+
} else {
186+
siteLoginButton.setOnClickListener(new OnClickListener() {
187+
@Override
188+
public void onClick(View view) {
189+
if (mLoginListener != null) {
190+
if (mLoginListener.getLoginMode() == LoginMode.JETPACK_STATS) {
191+
mLoginListener.loginViaWpcomUsernameInstead();
192+
} else {
193+
mLoginListener.loginViaSiteAddress();
194+
}
172195
}
173196
}
174-
}
175-
});
197+
});
198+
}
176199

177200
ImageView siteLoginButtonIcon = rootView.findViewById(R.id.login_site_button_icon);
178201
TextView siteLoginButtonText = rootView.findViewById(R.id.login_site_button_text);
179202

180203
switch (mLoginListener.getLoginMode()) {
181204
case FULL:
182205
case WPCOM_LOGIN_ONLY:
206+
case WOO_LOGIN_MODE:
183207
case SHARE_INTENT:
184208
siteLoginButtonIcon.setImageResource(R.drawable.ic_domains_grey_24dp);
185209
siteLoginButtonText.setText(R.string.enter_site_address_instead);
@@ -210,6 +234,13 @@ public void onClick(View view) {
210234
}
211235
}
212236
});
237+
} else if (mLoginListener.getLoginMode() == LoginMode.WOO_LOGIN_MODE) {
238+
secondaryButton.setText(getResources().getString(R.string.login_need_help_finding_connected_email));
239+
secondaryButton.setOnClickListener(new OnClickListener() {
240+
public void onClick(View view) {
241+
mLoginListener.showHelpFindingConnectedEmail();
242+
}
243+
});
213244
} else {
214245
secondaryButton.setVisibility(View.GONE);
215246
}
@@ -243,6 +274,13 @@ public void onAttach(Context context) {
243274
@Override
244275
public void onCreate(Bundle savedInstanceState) {
245276
super.onCreate(savedInstanceState);
277+
278+
Bundle args = getArguments();
279+
if (args != null) {
280+
mHideLoginWithSiteOption = args.getBoolean(ARG_HIDE_LOGIN_BY_SITE_OPTION, false);
281+
mLoginSiteUrl = args.getString(ARG_LOGIN_SITE_URL, "");
282+
}
283+
246284
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
247285
.addConnectionCallbacks(LoginEmailFragment.this)
248286
.enableAutoManage(getActivity(), GOOGLE_API_CLIENT_ID, LoginEmailFragment.this)
@@ -444,6 +482,8 @@ public void getEmailHints() {
444482
startIntentSenderForResult(intent.getIntentSender(), EMAIL_CREDENTIALS_REQUEST_CODE, null, 0, 0, 0, null);
445483
} catch (IntentSender.SendIntentException exception) {
446484
AppLog.d(T.NUX, LOG_TAG + "Could not start email hint picker" + exception);
485+
} catch (ActivityNotFoundException exception) {
486+
AppLog.d(T.NUX, LOG_TAG + "Could not find any activity to handle email hint picker" + exception);
447487
}
448488
}
449489

WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginEmailPasswordFragment.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
import android.content.Context;
44
import android.os.Bundle;
5-
import android.support.annotation.LayoutRes;
6-
import android.support.annotation.NonNull;
7-
import android.support.annotation.Nullable;
85
import android.text.Editable;
96
import android.text.TextUtils;
107
import android.text.TextWatcher;
@@ -15,10 +12,14 @@
1512
import android.widget.EditText;
1613
import android.widget.TextView;
1714

15+
import androidx.annotation.LayoutRes;
16+
import androidx.annotation.NonNull;
17+
import androidx.annotation.Nullable;
18+
1819
import org.greenrobot.eventbus.Subscribe;
1920
import org.greenrobot.eventbus.ThreadMode;
20-
import org.wordpress.android.login.LoginWpcomService.OnCredentialsOK;
2121
import org.wordpress.android.login.LoginWpcomService.LoginState;
22+
import org.wordpress.android.login.LoginWpcomService.OnCredentialsOK;
2223
import org.wordpress.android.login.util.SiteUtils;
2324
import org.wordpress.android.login.widgets.WPLoginInputRow;
2425
import org.wordpress.android.login.widgets.WPLoginInputRow.OnEditorCommitListener;

WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginHttpAuthDialogFragment.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
import android.content.DialogInterface;
66
import android.content.Intent;
77
import android.os.Bundle;
8-
import android.support.annotation.NonNull;
9-
import android.support.annotation.Nullable;
10-
import android.support.v4.app.DialogFragment;
11-
import android.support.v7.app.AlertDialog;
128
import android.text.Editable;
139
import android.text.TextWatcher;
1410
import android.view.ContextThemeWrapper;
@@ -17,6 +13,11 @@
1713
import android.widget.EditText;
1814
import android.widget.TextView;
1915

16+
import androidx.annotation.NonNull;
17+
import androidx.annotation.Nullable;
18+
import androidx.appcompat.app.AlertDialog;
19+
import androidx.fragment.app.DialogFragment;
20+
2021
import org.wordpress.android.util.EditTextUtils;
2122

2223
public class LoginHttpAuthDialogFragment extends DialogFragment {

WordPressLoginFlow/src/main/java/org/wordpress/android/login/LoginListener.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package org.wordpress.android.login;
22

33
import android.net.Uri;
4-
import android.support.annotation.NonNull;
5-
import android.support.annotation.Nullable;
4+
5+
import androidx.annotation.NonNull;
6+
import androidx.annotation.Nullable;
67

78
import org.wordpress.android.fluxc.network.MemorizingTrustManager;
89
import org.wordpress.android.fluxc.store.SiteStore;
@@ -25,6 +26,7 @@ interface SelfSignedSSLCallback {
2526
void helpEmailScreen(String email);
2627
void helpSocialEmailScreen(String email);
2728
void addGoogleLoginFragment();
29+
void showHelpFindingConnectedEmail();
2830

2931
// Login Request Magic Link callbacks
3032
void showMagicLinkSentScreen(String email);
@@ -46,6 +48,7 @@ interface SelfSignedSSLCallback {
4648
// Login Site Address input callbacks
4749
void alreadyLoggedInWpcom(ArrayList<Integer> oldSitesIds);
4850
void gotWpcomSiteInfo(String siteAddress, String siteName, String siteIconUrl);
51+
void gotConnectedSiteInfo(String siteAddress, boolean hasJetpack);
4952
void gotXmlRpcEndpoint(String inputSiteAddress, String endpointAddress);
5053
void handleSslCertificateError(MemorizingTrustManager memorizingTrustManager, SelfSignedSSLCallback callback);
5154
void helpSiteAddress(String url);

0 commit comments

Comments
 (0)