Skip to content

Commit

Permalink
refactor rename withSocialButtonStyle and onlyUseConnections builders…
Browse files Browse the repository at this point in the history
… methods
  • Loading branch information
lbalmaceda authored and hzalaz committed Sep 21, 2016
1 parent 2cca61a commit ecb0a5f
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 64 deletions.
16 changes: 8 additions & 8 deletions app/src/main/java/com/auth0/android/lock/app/DemoActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
import android.widget.RadioGroup;

import com.auth0.android.Auth0;
import com.auth0.android.lock.AuthButtonSize;
import com.auth0.android.lock.AuthenticationCallback;
import com.auth0.android.lock.InitialScreen;
import com.auth0.android.lock.Lock;
import com.auth0.android.lock.LockCallback;
import com.auth0.android.lock.PasswordlessLock;
import com.auth0.android.lock.InitialScreen;
import com.auth0.android.lock.SocialButtonStyle;
import com.auth0.android.lock.UsernameStyle;
import com.auth0.android.lock.utils.LockException;
import com.auth0.android.result.Credentials;
Expand Down Expand Up @@ -137,9 +137,9 @@ private void showClassicLock() {
builder.loginAfterSignUp(checkboxLoginAfterSignUp.isChecked());

if (groupSocialStyle.getCheckedRadioButtonId() == R.id.radio_social_style_big) {
builder.withSocialButtonStyle(SocialButtonStyle.BIG);
builder.withAuthButtonSize(AuthButtonSize.BIG);
} else if (groupSocialStyle.getCheckedRadioButtonId() == R.id.radio_social_style_small) {
builder.withSocialButtonStyle(SocialButtonStyle.SMALL);
builder.withAuthButtonSize(AuthButtonSize.SMALL);
}

if (groupUsernameStyle.getCheckedRadioButtonId() == R.id.radio_username_style_email) {
Expand All @@ -160,7 +160,7 @@ private void showClassicLock() {
builder.initialScreen(InitialScreen.LOG_IN);
}

builder.onlyUseConnections(generateConnections());
builder.allowedConnections(generateConnections());
if (checkboxConnectionsDB.isChecked()) {
if (groupDefaultDB.getCheckedRadioButtonId() == R.id.radio_default_db_policy) {
builder.setDefaultDatabaseConnection("with-strength");
Expand All @@ -182,9 +182,9 @@ private void showPasswordlessLock() {
builder.useBrowser(groupWebMode.getCheckedRadioButtonId() == R.id.radio_use_browser);

if (groupSocialStyle.getCheckedRadioButtonId() == R.id.radio_social_style_big) {
builder.withSocialButtonStyle(SocialButtonStyle.BIG);
builder.withAuthButtonSize(AuthButtonSize.BIG);
} else if (groupSocialStyle.getCheckedRadioButtonId() == R.id.radio_social_style_small) {
builder.withSocialButtonStyle(SocialButtonStyle.SMALL);
builder.withAuthButtonSize(AuthButtonSize.SMALL);
}

if (groupPasswordlessMode.getCheckedRadioButtonId() == R.id.radio_use_link) {
Expand All @@ -193,7 +193,7 @@ private void showPasswordlessLock() {
builder.useCode();
}

builder.onlyUseConnections(generateConnections());
builder.allowedConnections(generateConnections());

passwordlessLock = builder.build(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import static com.auth0.android.lock.SocialButtonStyle.BIG;
import static com.auth0.android.lock.SocialButtonStyle.SMALL;
import static com.auth0.android.lock.SocialButtonStyle.UNSPECIFIED;
import static com.auth0.android.lock.AuthButtonSize.BIG;
import static com.auth0.android.lock.AuthButtonSize.SMALL;
import static com.auth0.android.lock.AuthButtonSize.UNSPECIFIED;

@IntDef({UNSPECIFIED, BIG, SMALL})
@Retention(RetentionPolicy.SOURCE)
public @interface SocialButtonStyle {
public @interface AuthButtonSize {
int UNSPECIFIED = 0;
int BIG = 1;
int SMALL = 2;
Expand Down
18 changes: 9 additions & 9 deletions lib/src/main/java/com/auth0/android/lock/Lock.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
import com.auth0.android.Auth0;
import com.auth0.android.authentication.ParameterBuilder;
import com.auth0.android.lock.LockCallback.LockEvent;
import com.auth0.android.lock.provider.AuthResolver;
import com.auth0.android.lock.internal.configuration.Options;
import com.auth0.android.lock.internal.configuration.Theme;
import com.auth0.android.lock.provider.AuthResolver;
import com.auth0.android.lock.utils.CustomField;
import com.auth0.android.lock.utils.LockException;
import com.auth0.android.provider.AuthHandler;
Expand Down Expand Up @@ -294,7 +294,7 @@ public Builder withAuthenticationParameters(@NonNull Map<String, Object> authent
* @param connections a non-null List containing the allowed Auth0 Connections.
* @return the current builder instance
*/
public Builder onlyUseConnections(@NonNull List<String> connections) {
public Builder allowedConnections(@NonNull List<String> connections) {
options.setConnections(connections);
return this;
}
Expand All @@ -312,16 +312,16 @@ public Builder withUsernameStyle(@UsernameStyle int style) {
}

/**
* Social Button style to use when Social connections are available. If social
* is the only connection type, by default it will use the Big style. If social and db or
* enterprise are present and there's only one social connection, the button will use the
* Big style. In the rest of the cases, it will use Small style.
* Auth Button size to use when Social connections are available. If Social
* is the only connection type it will default to the BIG size. If Database or
* Enterprise are present and there's only one Social connection, the button will use the
* BIG size. In the rest of the cases, it will use SMALL size.
*
* @param style a valid SocialButtonStyle.
* @param style a valid AuthButtonSize.
* @return the current builder instance
*/
public Builder withSocialButtonStyle(@SocialButtonStyle int style) {
options.setSocialButtonStyle(style);
public Builder withAuthButtonSize(@AuthButtonSize int style) {
options.setAuthButtonSize(style);
return this;
}

Expand Down
16 changes: 8 additions & 8 deletions lib/src/main/java/com/auth0/android/lock/PasswordlessLock.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,16 @@ private Builder withTheme(@NonNull Theme theme) {
}

/**
* Social Button style to use when Social connections are available. If social
* is the only connection type, by default it will use the Big style. If social and db or
* enterprise are present and there's only one social connection, the button will use the
* Big style. In the rest of the cases, it will use Small style.
* Auth Button size to use when Social connections are available. If Social
* is the only connection type it will default to the BIG size. If Database or
* Enterprise are present and there's only one Social connection, the button will use the
* BIG size. In the rest of the cases, it will use SMALL size.
*
* @param style a valid SocialButtonStyle.
* @param style a valid AuthButtonSize.
* @return the current builder instance
*/
public Builder withSocialButtonStyle(@SocialButtonStyle int style) {
options.setSocialButtonStyle(style);
public Builder withAuthButtonSize(@AuthButtonSize int style) {
options.setAuthButtonSize(style);
return this;
}

Expand Down Expand Up @@ -318,7 +318,7 @@ public Builder withAuthenticationParameters(@NonNull Map<String, Object> authent
* @param connections a non-null List containing the allowed Auth0 Connections.
* @return the current builder instance
*/
public Builder onlyUseConnections(@NonNull List<String> connections) {
public Builder allowedConnections(@NonNull List<String> connections) {
options.setConnections(connections);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import android.support.annotation.StyleRes;
import android.util.Log;

import com.auth0.android.lock.AuthButtonSize;
import com.auth0.android.lock.InitialScreen;
import com.auth0.android.lock.SocialButtonStyle;
import com.auth0.android.lock.UsernameStyle;
import com.auth0.android.lock.utils.CustomField;
import com.auth0.android.lock.views.AuthConfig;
Expand Down Expand Up @@ -62,7 +62,7 @@ public class Configuration {
private boolean mustAcceptTerms;
@UsernameStyle
private int usernameStyle;
@SocialButtonStyle
@AuthButtonSize
private int socialButtonStyle;
private boolean loginAfterSignUp;
@PasswordlessMode
Expand Down Expand Up @@ -165,7 +165,7 @@ private <T extends BaseConnection> List<T> filterConnections(@NonNull List<Conne

private void parseLocalOptions(Options options) {
usernameStyle = options.usernameStyle();
socialButtonStyle = options.socialButtonStyle();
socialButtonStyle = options.authButtonSize();
loginAfterSignUp = options.loginAfterSignUp();
mustAcceptTerms = options.mustAcceptTerms();

Expand Down Expand Up @@ -231,7 +231,7 @@ public int getInitialScreen() {
return initialScreen;
}

@SocialButtonStyle
@AuthButtonSize
public int getSocialButtonStyle() {
return socialButtonStyle;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import com.auth0.android.Auth0;
import com.auth0.android.authentication.AuthenticationAPIClient;
import com.auth0.android.lock.Auth0Parcelable;
import com.auth0.android.lock.AuthButtonSize;
import com.auth0.android.lock.InitialScreen;
import com.auth0.android.lock.SocialButtonStyle;
import com.auth0.android.lock.UsernameStyle;
import com.auth0.android.lock.utils.CustomField;

Expand All @@ -62,7 +62,7 @@ public class Options implements Parcelable {
private boolean useBrowser;
private boolean usePKCE;
private boolean closable;
private int socialButtonStyle;
private int authButtonSize;
private int usernameStyle;
private boolean useCodePasswordless;
private boolean allowLogIn;
Expand Down Expand Up @@ -111,7 +111,7 @@ protected Options(Parcel in) {
defaultDatabaseConnection = in.readString();
usernameStyle = in.readInt();
initialScreen = in.readInt();
socialButtonStyle = in.readInt();
authButtonSize = in.readInt();
theme = in.readParcelable(Theme.class.getClassLoader());
privacyURL = in.readString();
termsURL = in.readString();
Expand Down Expand Up @@ -174,7 +174,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeString(defaultDatabaseConnection);
dest.writeInt(usernameStyle);
dest.writeInt(initialScreen);
dest.writeInt(socialButtonStyle);
dest.writeInt(authButtonSize);
dest.writeParcelable(theme, flags);
dest.writeString(privacyURL);
dest.writeString(termsURL);
Expand Down Expand Up @@ -280,13 +280,13 @@ public void setAllowLogIn(boolean allowLogIn) {
this.allowLogIn = allowLogIn;
}

public void setSocialButtonStyle(@SocialButtonStyle int socialButtonStyle) {
this.socialButtonStyle = socialButtonStyle;
public void setAuthButtonSize(@AuthButtonSize int authButtonSize) {
this.authButtonSize = authButtonSize;
}

@SocialButtonStyle
public int socialButtonStyle() {
return socialButtonStyle;
@AuthButtonSize
public int authButtonSize() {
return authButtonSize;
}

public boolean allowLogIn() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.auth0.android.lock.AuthButtonSize;
import com.auth0.android.lock.R;
import com.auth0.android.lock.internal.configuration.AuthMode;
import com.auth0.android.lock.InitialScreen;
import com.auth0.android.lock.SocialButtonStyle;
import com.auth0.android.lock.events.DatabaseSignUpEvent;
import com.auth0.android.lock.views.interfaces.IdentityListener;
import com.auth0.android.lock.views.interfaces.LockWidgetForm;
Expand Down Expand Up @@ -133,10 +133,10 @@ private void addSocialLayout() {
boolean formContainsFields = showDatabase || showEnterprise;
boolean singleConnection = lockWidget.getConfiguration().getSocialConnections().size() == 1;

if (style == SocialButtonStyle.UNSPECIFIED) {
if (style == AuthButtonSize.UNSPECIFIED) {
socialLayout = new SocialView(lockWidget, formContainsFields && !singleConnection);
} else {
socialLayout = new SocialView(lockWidget, style == SocialButtonStyle.SMALL);
socialLayout = new SocialView(lockWidget, style == AuthButtonSize.SMALL);
}

formsHolder.addView(socialLayout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
import android.widget.LinearLayout;
import android.widget.TextView;

import com.auth0.android.lock.AuthButtonSize;
import com.auth0.android.lock.R;
import com.auth0.android.lock.adapters.Country;
import com.auth0.android.lock.internal.configuration.PasswordlessMode;
import com.auth0.android.lock.SocialButtonStyle;
import com.auth0.android.lock.views.interfaces.LockWidgetPasswordless;

public class PasswordlessFormLayout extends LinearLayout implements PasswordlessInputCodeFormView.OnCodeResendListener, PasswordlessRequestCodeFormView.OnAlreadyGotCodeListener {
Expand Down Expand Up @@ -87,10 +87,10 @@ private void addSocialLayout(boolean passwordlessAvailable) {
int style = lockWidget.getConfiguration().getSocialButtonStyle();
boolean fewConnections = lockWidget.getConfiguration().getSocialConnections().size() <= MAX_SOCIAL_BIG_BUTTONS_WITH_PASSWORDLESS;

if (style == SocialButtonStyle.UNSPECIFIED) {
if (style == AuthButtonSize.UNSPECIFIED) {
socialLayout = new SocialView(lockWidget, passwordlessAvailable && !fewConnections);
} else {
socialLayout = new SocialView(lockWidget, style == SocialButtonStyle.SMALL);
socialLayout = new SocialView(lockWidget, style == AuthButtonSize.SMALL);
}

addView(socialLayout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

package com.auth0.android.lock.internal.configuration;

import com.auth0.android.lock.AuthButtonSize;
import com.auth0.android.lock.InitialScreen;
import com.auth0.android.lock.R;
import com.auth0.android.lock.SocialButtonStyle;
import com.auth0.android.lock.UsernameStyle;
import com.auth0.android.lock.utils.CustomField;
import com.auth0.android.lock.utils.CustomField.FieldType;
Expand Down Expand Up @@ -100,7 +100,7 @@ public void shouldKeepApplicationDefaultsIfOptionsAreNotModified() throws Except
assertThat(configuration.loginAfterSignUp(), is(true));
assertThat(configuration.getUsernameStyle(), is(equalTo(UsernameStyle.DEFAULT)));
assertThat(configuration.getInitialScreen(), is(equalTo(InitialScreen.LOG_IN)));
assertThat(configuration.getSocialButtonStyle(), is(equalTo(SocialButtonStyle.UNSPECIFIED)));
assertThat(configuration.getSocialButtonStyle(), is(equalTo(AuthButtonSize.UNSPECIFIED)));
assertThat(configuration.hasExtraFields(), is(false));
assertThat(configuration.getPasswordPolicy(), is(PasswordStrength.NONE));
assertThat(configuration.mustAcceptTerms(), is(false));
Expand Down Expand Up @@ -128,15 +128,15 @@ public void shouldMergeApplicationWithOptionsIfDefaultDatabaseExists() throws Ex
options.setAllowForgotPassword(false);
options.setLoginAfterSignUp(false);
options.setUsernameStyle(UsernameStyle.USERNAME);
options.setSocialButtonStyle(SocialButtonStyle.BIG);
options.setAuthButtonSize(AuthButtonSize.BIG);
configuration = new Configuration(connections, options);
assertThat(configuration.isUsernameRequired(), is(false));
assertThat(configuration.allowLogIn(), is(false));
assertThat(configuration.allowSignUp(), is(false));
assertThat(configuration.allowForgotPassword(), is(false));
assertThat(configuration.loginAfterSignUp(), is(false));
assertThat(configuration.getUsernameStyle(), is(equalTo(UsernameStyle.USERNAME)));
assertThat(configuration.getSocialButtonStyle(), is(equalTo(SocialButtonStyle.BIG)));
assertThat(configuration.getSocialButtonStyle(), is(equalTo(AuthButtonSize.BIG)));
assertThat(configuration.hasExtraFields(), is(false));
}

Expand Down
Loading

0 comments on commit ecb0a5f

Please sign in to comment.