[go: nahoru, domu]

Skip to content

Commit

Permalink
Squashed 'libs/login/' changes from 78c5307f7a..979ddf4aec
Browse files Browse the repository at this point in the history
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
  • Loading branch information
AmandaRiu committed Jul 3, 2019
1 parent ad485b2 commit 43aef95
Show file tree
Hide file tree
Showing 38 changed files with 295 additions and 130 deletions.
24 changes: 12 additions & 12 deletions WordPressLoginFlow/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down Expand Up @@ -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'

Expand All @@ -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"
}
Expand All @@ -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'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,7 @@ public interface LoginAnalyticsListener {
void trackUrlHelpScreenViewed();
void trackUsernamePasswordFormViewed();
void trackWpComBackgroundServiceUpdate(Map<String, ?> properties);
void trackConnectedSiteInfoRequested(String url);
void trackConnectedSiteInfoFailed(String url, String errorContext, String errorType, String errorDescription);
void trackConnectedSiteInfoSucceeded(Map<String, ?> properties);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,20 +17,32 @@
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;
import org.wordpress.android.fluxc.action.AccountAction;
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;
import org.wordpress.android.fluxc.store.SiteStore.SiteErrorType;
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;

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -66,6 +68,9 @@ public class LoginEmailFragment extends LoginBaseFormFragment<LoginListener> 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;

Expand All @@ -78,6 +83,17 @@ public class LoginEmailFragment extends LoginBaseFormFragment<LoginListener> 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() {
Expand All @@ -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;
Expand Down Expand Up @@ -161,25 +180,30 @@ 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);

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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);
Expand All @@ -46,6 +48,7 @@ interface SelfSignedSSLCallback {
// Login Site Address input callbacks
void alreadyLoggedInWpcom(ArrayList<Integer> 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);
Expand Down
Loading

0 comments on commit 43aef95

Please sign in to comment.