Skip to content

Commit

Permalink
Squashed 'libs/login/' changes from a3a1c83492..7a466b64e1
Browse files Browse the repository at this point in the history
7a466b64e1 Merge pull request #42 from wordpress-mobile/merge/WordPress-Android/12538
69420f4718 Disable continue button when verification code is empty
a651591cab Merge pull request #41 from wordpress-mobile/merge/uls-changes
4a0f98e7d0 Update signatures of LoginAnalyticsListener methods that receive properties
34c2a6725d Update LoginEmailFragment to avoid trying to disable nonexistent button
db4a99ece6 Merge pull request #12503 from wordpress-mobile/add-source-to-account-created-event
e703eb9ae1 Update trackCreatedAccount to use CreatedAccountSource
9dfa35975d Introduce CreatedAccountSource to LoginAnalyticsListener
2d4870d234 Convert LoginAnalyticsListener to Kotlin
5680616a17 Remove temporary GravatarUtils from AvatarHelper
4aaa4560e3 Update AvatarHelper to use fixed GravatarUtils
f35f72f886 Bump Utils library version in the Login library
92fb1820a0 Merge pull request #12415 from wordpress-mobile/feature/disable-primary-buttons-on-empty-fields
0dc932d182 Remove unnecessary non-null checks
28fa9f74f2 Merge branch 'develop' into feature/unified-login-signup
2549443fe7 Merge pull request #12010 from wordpress-mobile/merge/loginlib/woo-dark-mode
5014577306 Merge pull request #12425 from wordpress-mobile/issue/unified-login-signup-theming-issues
7ce7661f0d Stop using the default Gravatar placeholder on Login Epilogue
b8b08aeff8 Update placeholder color to ensure compatibility on older API levels
e486867240 Disable primary button when username or password are missing
1d3b66e9a6 Disable primary button when password is not filled in
1ace43e4ae Disable continue button when email is empty
581c9e97ec Update LoginFlow theme to ensure compatibility on older API levels
b2971aab66 Remove nested selectors to ensure compatibility on older API levels
0844510f93 Merge pull request #12294 from wordpress-mobile/fix/remove-unused-click-event
c970ac36bf Merge branch 'develop' into feature/unified-login-signup
17e0788dbe Remove event that's never triggered in the new flow
f87d1e5448 Add missing click tracking to magic link screens
f9ea9f696a Add click tracking to Signup Confirmation screen
23a0b2793c Add screen tracking to Signup Confirmation screen
497686214f Fix a bug when flow is switched when returning from the google flow
163646574c Merge branch 'feature/unified-login-failure-tracking' into feature/unified-login-interaction-tracking
18d01c6190 Move google error tracking to LoginActivity.java
6ce30e4a18 Merge branch 'feature/unified-login-signup' into feature/unified-login-failure-tracking
c2ecfda3f2 Merge pull request #12056 from wordpress-mobile/issue/11785-add-signup-confirmation-screen
effb35b47b Fix indentation issue
cbc341d89c Add tracking for the email hints dialog
17cee3ef05 Add email click tracking
d3c5f3f7ae Add click tracking to help
f772966dde Merge branch 'feature/unified-login-failure-tracking' into feature/unified-login-interaction-tracking
6fbfcd7249 Add error logging where it was missing
7cadea49ed Cleanup failure tracking
646ba2ded7 Merge branch 'feature/unified-login-signup' into feature/unified-login-failure-tracking
cbec230041 Merge pull request #12048 from wordpress-mobile/issue/11785-update-login-flow-layouts
546fb2b245 Implement help dialog on the signup confirmation screen
fa0db85fba Implement signup confirmation screen for google signup
9cdcbc7af1 Implement signup confirmation screen for email signup
dd7b6736f3 Update TOS links colors
b42a8b13f6 Merge pull request #12047 from wordpress-mobile/issue/11785-update-login-flow-theme
855ac5269e Extract avatar loading logic to a helper class
30f1fadf17 Update email header component layout
7bdca2d2a0 Update Signup Magic Link screen
7ca256af24 Rename Signup Magic Link screen layout file
06a2d4c6e5 Update Signup Email screen
fcd4a97d2a Rename Signup Email screen layout file
0048078ec0 Update Login Username Password screen
21b3fbb250 Update Login Site Address screen
9a453c4329 Update Login 2FA screen
1c2610f396 Update Login Email Password screen
a06c6bd863 Update Login Magic Link Sent screen
951456aaaa Extract magic link header to a separate layout file
1a4100633d UI update to Magic Link Request screen
1c2526d13b Update base form layout
668da0a21d Extract old Login Email screen to a separate layout file
5e942b4176 UI update to Login Email screen
80a4c0d908 Update login theme and styles
16dac21f5e Merge pull request #11944 from wordpress-mobile/issue/11783-update-epilogue-ui
b3d8998027 Merge commit '46923a963c480113b797856bfaf179dad5044d2d' into merge/loginlib/woo-dark-mode
4f1af83e96 Fix NPE when primary button is missing
d0cfd5ed63 End progress when the login fragment is destroyed
2274f87e22 Add click tracking to unified login and signup flow
81c9feeb28 Use universal method for failure tracking
9e5f139de1 First step of failure tracking
9cebf7a88b Remove method that's not tracking screen change
c6469d5b9e Add source to tracking events
eefd096bcd Add screen tracking to login and signup
fdc65a5240 Bump login library minSdkVersion to 21 and targetSdkVersion to 29
44e989e866 Merge pull request #12000 from wordpress-mobile/fix/9905_Crash_InflateException_Binary_XML_file_line_NEW
eac3784277 Revert unintentional change during merge
5502b855c4 Merge commit 'd4d2d895dd0c1469adf230607fe801146f9f91ff' into merge/loginlib/woo-dark-mode
1f1f28318c Merge pull request #11934 from wordpress-mobile/update/fragments
0c40f732f4 Set password icon programmatically
eb8ed2635f Fix wrong password icon
f0e7106f68 Remove unused resources
044893cfb7 Update login epilogue secondary button strings
c5c79810c9 Update signup epilogue primary button string
fb1712af70 fixed lint error and replaced all observers owner parameter with viewLifecycleOwner
05af8f4c85 Remove unused strings from the login library
0f40e7e9e6 Add ability to enable login via site address from the prologue screen
689b1d9574 Add ability to disable login via site address from the email screen
fd236a31e6 Merge pull request #11717 from wordpress-mobile/issue/11705-google-sign-in
92ef161140 Move @OverRide annotation to conform with the current code style
8871b22436 Merge branch 'feature/unified-login-signup' into feature/introduce-kotlin
debde7c28e Add library version locally to the login library
e7e8df0379 Move progress dialog to better handle configuration changes
1c871c9f33 Update log messages for sign-up from login functionality
9c13cb0cf3 Add flag to turn the sign-up from login functionality on
3cae24c922 Add loading dialog to LoginGoogleFragment
a00ec92d95 Update LoginGoogleFragment so it supports sign-up from login
a09bdda7c5 Use correct versions to fix build
217b13ff0b Introduce kotlin to LoginFlow and bump libraries
79c4db7291 Add flag to turn the sign-up from login functionality on
beff169fc2 Update LoginEmailFragment so it supports sign-up from login

git-subtree-dir: libs/login
git-subtree-split: 7a466b64e1dfa472fb7224ceff72c8096e7e3b9d
  • Loading branch information
oguzkocer committed Aug 7, 2020
1 parent 46923a9 commit 52d3d3e
Show file tree
Hide file tree
Showing 65 changed files with 1,737 additions and 972 deletions.
45 changes: 29 additions & 16 deletions WordPressLoginFlow/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
buildscript {
ext {
kotlin_version = '1.3.61'
kotlin_ktx_version = '1.2.0'
daggerVersion = '2.22.1'
appCompatVersion = '1.0.2'
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'

repositories {
google()
Expand All @@ -17,12 +27,12 @@ repositories {
}

android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
compileSdkVersion 29
buildToolsVersion "29.0.2"

defaultConfig {
minSdkVersion 17
targetSdkVersion 28
minSdkVersion 21
targetSdkVersion 29
versionCode 2
versionName "1.1"

Expand All @@ -31,17 +41,20 @@ android {
}

dependencies {
implementation ('org.wordpress:utils:1.20.3') {
implementation ('org.wordpress:utils:1.26') {
exclude group: "com.android.volley"
}

implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.vectordrawable:vectordrawable-animated:1.0.0'
implementation 'androidx.media:media:1.0.1'
implementation "androidx.appcompat:appcompat:$appCompatVersion"
implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
implementation 'androidx.media:media:1.1.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.android.material:material:1.1.0'

implementation "androidx.core:core-ktx:$kotlin_ktx_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

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

// Share FluxC version from host project if defined, otherwise fallback to default
Expand All @@ -58,21 +71,21 @@ dependencies {
}

implementation 'com.github.bumptech.glide:glide:4.10.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
kapt 'com.github.bumptech.glide:compiler:4.10.0'

// Dagger
implementation 'com.google.dagger:dagger:2.22.1'
annotationProcessor 'com.google.dagger:dagger-compiler:2.22.1'
implementation "com.google.dagger:dagger:$daggerVersion"
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
compileOnly 'org.glassfish:javax.annotation:10.0-b28'
implementation 'com.google.dagger:dagger-android-support:2.22.1'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.22.1'
implementation "com.google.dagger:dagger-android-support:$daggerVersion"
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"

lintChecks 'org.wordpress:lint:1.0.1'

testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.27.0'
testImplementation 'androidx.arch.core:core-testing:2.0.1'
testImplementation 'org.robolectric:robolectric:4.3'
testImplementation 'org.mockito:mockito-core:2.28.2'
testImplementation 'androidx.arch.core:core-testing:2.1.0'
testImplementation 'org.robolectric:robolectric:4.3.1'
testImplementation 'org.assertj:assertj-core:3.11.1'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.AppLog.T;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.inject.Inject;

import static android.app.Activity.RESULT_OK;
Expand Down Expand Up @@ -52,7 +55,7 @@ public class GoogleFragment extends Fragment implements ConnectionCallbacks, OnC
protected String mIdToken;
protected String mPhotoUrl;

protected static final String SERVICE_TYPE_GOOGLE = "google";
public static final String SERVICE_TYPE_GOOGLE = "google";

@Inject protected Dispatcher mDispatcher;
@Inject protected SiteStore mSiteStore;
Expand Down Expand Up @@ -246,4 +249,13 @@ public void onActivityResult(int request, int result, Intent data) {
break;
}
}

// Remove scale from photo URL path string. Current URL matches /s96-c, which returns a 96 x 96
// pixel image. Removing /s96-c from the string returns a 512 x 512 pixel image. Using regular
// expressions may help if the photo URL scale value in the returned path changes.
protected String removeScaleFromGooglePhotoUrl(String photoUrl) {
Pattern pattern = Pattern.compile("(/s[0-9]+-c)");
Matcher matcher = pattern.matcher(photoUrl);
return matcher.find() ? photoUrl.replace(matcher.group(1), "") : photoUrl;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.Toolbar;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;

Expand Down Expand Up @@ -89,7 +91,7 @@ public class Login2FaFragment extends LoginBaseFormFragment<LoginListener> imple

ArrayList<Integer> mOldSitesIDs;

private Button mSecondaryButton;
private Button mOtpButton;
private String mEmailAddress;
private String mIdToken;
private String mNonce;
Expand Down Expand Up @@ -172,29 +174,35 @@ protected void setupContent(ViewGroup rootView) {

// restrict the allowed input chars to just numbers
m2FaInput.getEditText().setKeyListener(DigitsKeyListener.getInstance("0123456789"));
}

@Override
protected void setupBottomButtons(Button secondaryButton, Button primaryButton) {
secondaryButton.setText(R.string.login_text_otp);
secondaryButton.setOnClickListener(new OnClickListener() {
mOtpButton = rootView.findViewById(R.id.login_otp_button);
mOtpButton.setText(mSentSmsCode ? R.string.login_text_otp_another : R.string.login_text_otp);
mOtpButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (isAdded()) {
mAnalyticsListener.trackSendCodeWithTextClicked();
doAuthAction(R.string.requesting_otp, "", true);
}
}
});
secondaryButton.setText(getString(mSentSmsCode ? R.string.login_text_otp_another : R.string.login_text_otp));
mSecondaryButton = secondaryButton;
}

@Override
protected void setupBottomButtons(Button secondaryButton, Button primaryButton) {
secondaryButton.setVisibility(View.GONE);
primaryButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
next();
}
});
}

@Override
protected void buildToolbar(Toolbar toolbar, ActionBar actionBar) {
actionBar.setTitle(R.string.log_in);
}

@Override
protected EditText getEditTextToFocusOnStart() {
return m2FaInput.getEditText();
Expand Down Expand Up @@ -275,9 +283,12 @@ public void onResume() {
if (TextUtils.isEmpty(m2FaInput.getEditText().getText())) {
m2FaInput.setText(getAuthCodeFromClipboard());
}

updateContinueButtonEnabledStatus();
}

protected void next() {
mAnalyticsListener.trackSubmit2faCodeClicked();
if (TextUtils.isEmpty(m2FaInput.getEditText().getText())) {
show2FaError(getString(R.string.login_empty_2fa));
return;
Expand Down Expand Up @@ -318,7 +329,7 @@ private String getAuthCodeFromClipboard() {
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(CLIPBOARD_SERVICE);

if (clipboard.getPrimaryClip() != null && clipboard.getPrimaryClip().getItemAt(0) != null
&& clipboard.getPrimaryClip().getItemAt(0).getText() != null) {
&& clipboard.getPrimaryClip().getItemAt(0).getText() != null) {
String code = clipboard.getPrimaryClip().getItemAt(0).getText().toString();

final Matcher twoStepAuthCodeMatcher = TWO_STEP_AUTH_CODE.matcher("");
Expand Down Expand Up @@ -365,12 +376,19 @@ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
show2FaError(null);
updateContinueButtonEnabledStatus();
}

private void show2FaError(String message) {
mAnalyticsListener.trackFailure(message);
m2FaInput.setError(message);
}

private void updateContinueButtonEnabledStatus() {
String currentVerificationCode = m2FaInput.getEditText().getText().toString();
getPrimaryButton().setEnabled(!currentVerificationCode.trim().isEmpty());
}

@Override
protected void endProgress() {
super.endProgress();
Expand All @@ -389,14 +407,15 @@ private void handleAuthError(AuthenticationErrorType error, String errorMessage)
// TODO: FluxC: could be specific?
default:
AppLog.e(T.NUX, "Server response: " + errorMessage);

mAnalyticsListener.trackFailure(errorMessage);
ToastUtils.showToast(getActivity(),
errorMessage == null ? getString(R.string.error_generic) : errorMessage);
break;
}
}

private void showErrorDialog(String message) {
mAnalyticsListener.trackFailure(message);
AlertDialog dialog = new MaterialAlertDialogBuilder(getActivity())
.setMessage(message)
.setPositiveButton(R.string.login_error_button, null)
Expand Down Expand Up @@ -485,7 +504,7 @@ public void onSocialChanged(OnSocialChanged event) {
mAnalyticsListener.trackSocialConnectFailure();
doFinishLogin();
}
// Two-factor authentication code was sent via SMS to account phone number; replace SMS nonce with response.
// Two-factor authentication code was sent via SMS to account phone number; replace SMS nonce with response.
} else if (!TextUtils.isEmpty(event.phoneNumber) && !TextUtils.isEmpty(event.nonce)) {
endProgress();
mPhoneNumber = event.phoneNumber;
Expand Down Expand Up @@ -514,7 +533,7 @@ protected void onLoginFinished() {

private void setTextForSms() {
mLabel.setText(getString(R.string.enter_verification_code_sms, mPhoneNumber));
mSecondaryButton.setText(getString(R.string.login_text_otp_another));
mOtpButton.setText(getString(R.string.login_text_otp_another));
mSentSmsCode = true;
}
}

This file was deleted.

Loading

0 comments on commit 52d3d3e

Please sign in to comment.