diff --git a/app/src/main/java/com/auth0/android/lock/app/DemoActivity.java b/app/src/main/java/com/auth0/android/lock/app/DemoActivity.java
index 75e4bab7b..a979e3498 100644
--- a/app/src/main/java/com/auth0/android/lock/app/DemoActivity.java
+++ b/app/src/main/java/com/auth0/android/lock/app/DemoActivity.java
@@ -228,6 +228,7 @@ private void showPasswordlessLock() {
private Auth0 getAccount() {
Auth0 account = new Auth0(getString(R.string.com_auth0_client_id), getString(R.string.com_auth0_domain));
account.setOIDCConformant(true);
+ account.setLoggingEnabled(true);
return account;
}
diff --git a/lib/src/main/java/com/auth0/android/lock/PasswordlessLockActivity.java b/lib/src/main/java/com/auth0/android/lock/PasswordlessLockActivity.java
index 8184c77b1..2eb12f86a 100644
--- a/lib/src/main/java/com/auth0/android/lock/PasswordlessLockActivity.java
+++ b/lib/src/main/java/com/auth0/android/lock/PasswordlessLockActivity.java
@@ -247,6 +247,9 @@ public void run() {
};
private void showLinkSentLayout() {
+ //Next 2 lines required to avoid focus on the form behind
+ rootView.setFocusable(false);
+ rootView.setFocusableInTouchMode(false);
TextView successMessage = (TextView) passwordlessSuccessCover.findViewById(R.id.com_auth0_lock_passwordless_message);
successMessage.setText(String.format(getString(R.string.com_auth0_lock_title_passwordless_link_sent), lastPasswordlessIdentity));
TextView gotCodeButton = (TextView) passwordlessSuccessCover.findViewById(R.id.com_auth0_lock_got_code);
diff --git a/lib/src/main/java/com/auth0/android/lock/views/ActionButton.java b/lib/src/main/java/com/auth0/android/lock/views/ActionButton.java
index 61962d5d9..6a27d37f0 100644
--- a/lib/src/main/java/com/auth0/android/lock/views/ActionButton.java
+++ b/lib/src/main/java/com/auth0/android/lock/views/ActionButton.java
@@ -30,8 +30,10 @@
import android.graphics.drawable.Drawable;
import android.graphics.drawable.RippleDrawable;
import android.graphics.drawable.StateListDrawable;
+import android.support.annotation.Nullable;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;
+import android.support.v4.graphics.ColorUtils;
import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
@@ -68,22 +70,35 @@ private void init(Theme lockTheme) {
ViewUtils.setBackground(icon, generateStateBackground(lockTheme));
ViewUtils.setBackground(labeledLayout, generateStateBackground(lockTheme));
showLabel(false);
+ icon.setFocusable(true);
+ icon.setFocusableInTouchMode(false);
+ labeledLayout.setFocusable(true);
+ labeledLayout.setFocusableInTouchMode(false);
}
private Drawable generateStateBackground(Theme lockTheme) {
int normalColor = lockTheme.getPrimaryColor(getContext());
int pressedColor = lockTheme.getDarkPrimaryColor(getContext());
+ //164 -> 64% alpha
+ int focusedColor = ColorUtils.setAlphaComponent(normalColor, 164);
int disabledColor = ContextCompat.getColor(getContext(), R.color.com_auth0_lock_submit_disabled);
+ final StateListDrawable buttonDrawable = new StateListDrawable();
+ buttonDrawable.addState(new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed}, new ColorDrawable(pressedColor));
+ buttonDrawable.addState(new int[]{android.R.attr.state_enabled, android.R.attr.state_focused}, new ColorDrawable(focusedColor));
+ buttonDrawable.addState(new int[]{android.R.attr.state_enabled}, new ColorDrawable(normalColor));
+ buttonDrawable.addState(new int[]{}, new ColorDrawable(disabledColor));
+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
- return new RippleDrawable(ColorStateList.valueOf(pressedColor), new ColorDrawable(normalColor), null);
- } else {
- StateListDrawable states = new StateListDrawable();
- states.addState(new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed}, new ColorDrawable(pressedColor));
- states.addState(new int[]{android.R.attr.state_enabled}, new ColorDrawable(normalColor));
- states.addState(new int[]{}, new ColorDrawable(disabledColor));
- return states;
+ return new RippleDrawable(ColorStateList.valueOf(pressedColor), buttonDrawable, null);
}
+ return buttonDrawable;
+ }
+
+ @Override
+ public void setOnClickListener(@Nullable OnClickListener l) {
+ icon.setOnClickListener(l);
+ labeledLayout.setOnClickListener(l);
}
/**
diff --git a/lib/src/main/java/com/auth0/android/lock/views/ChangePasswordFormView.java b/lib/src/main/java/com/auth0/android/lock/views/ChangePasswordFormView.java
index 6e82e44bd..170d12ba6 100644
--- a/lib/src/main/java/com/auth0/android/lock/views/ChangePasswordFormView.java
+++ b/lib/src/main/java/com/auth0/android/lock/views/ChangePasswordFormView.java
@@ -60,6 +60,7 @@ private void init(String email) {
emailInput.setText(email);
emailInput.setIdentityListener(this);
emailInput.setOnEditorActionListener(this);
+ requestFocus();
}
@Override
diff --git a/lib/src/main/java/com/auth0/android/lock/views/ClassicLockView.java b/lib/src/main/java/com/auth0/android/lock/views/ClassicLockView.java
index 570bb5146..b654aed2f 100644
--- a/lib/src/main/java/com/auth0/android/lock/views/ClassicLockView.java
+++ b/lib/src/main/java/com/auth0/android/lock/views/ClassicLockView.java
@@ -273,6 +273,7 @@ public boolean onBackPressed() {
resetHeaderTitle();
showSignUpTerms(subForm instanceof CustomFieldsFormView);
removeSubForm();
+ clearFocus();
return true;
}
}
diff --git a/lib/src/main/java/com/auth0/android/lock/views/CountryCodeSelectorView.java b/lib/src/main/java/com/auth0/android/lock/views/CountryCodeSelectorView.java
index ceef3c790..417b6af50 100644
--- a/lib/src/main/java/com/auth0/android/lock/views/CountryCodeSelectorView.java
+++ b/lib/src/main/java/com/auth0/android/lock/views/CountryCodeSelectorView.java
@@ -26,12 +26,12 @@
import android.content.Context;
import android.graphics.drawable.Drawable;
-import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.ShapeDrawable;
+import android.graphics.drawable.StateListDrawable;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.util.AttributeSet;
import android.util.Log;
-import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -84,13 +84,17 @@ private void setupBackground() {
Drawable rightBackground = ViewUtils.getRoundedBackground(getResources(), ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_country_code_background), ViewUtils.Corners.ONLY_RIGHT);
ViewUtils.setBackground(icon, leftBackground);
ViewUtils.setBackground(chevron, rightBackground);
- ViewGroup parent = ((ViewGroup) countryNameTextView.getParent());
- Drawable bg = parent.getBackground();
- GradientDrawable gd = bg == null ? new GradientDrawable() : (GradientDrawable) bg;
- gd.setCornerRadius(getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_corner_radius));
- gd.setStroke(getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_input_field_stroke_width), ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_field_border_normal));
- gd.setColor(ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_field_border_normal));
- ViewUtils.setBackground(parent, gd);
+
+ ShapeDrawable normalBackground = ViewUtils.getRoundedBackground(getResources(), ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_field_border_normal), ViewUtils.Corners.ALL);
+ Drawable focusedBackground = ViewUtils.getRoundedOutlineBackground(getResources(), ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_field_border_focused));
+
+ StateListDrawable states = new StateListDrawable();
+ states.addState(new int[]{android.R.attr.state_focused}, focusedBackground);
+ states.addState(new int[]{}, normalBackground);
+
+ setFocusableInTouchMode(false);
+ setFocusable(true);
+ ViewUtils.setBackground(this, states);
}
private void prepareTask() {
diff --git a/lib/src/main/java/com/auth0/android/lock/views/ImageCheckbox.java b/lib/src/main/java/com/auth0/android/lock/views/ImageCheckbox.java
new file mode 100644
index 000000000..fcff4fc95
--- /dev/null
+++ b/lib/src/main/java/com/auth0/android/lock/views/ImageCheckbox.java
@@ -0,0 +1,114 @@
+package com.auth0.android.lock.views;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+import android.support.annotation.Nullable;
+import android.support.v4.content.ContextCompat;
+import android.support.v4.view.AccessibilityDelegateCompat;
+import android.support.v4.view.ViewCompat;
+import android.support.v4.view.accessibility.AccessibilityEventCompat;
+import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
+import android.support.v7.widget.AppCompatImageButton;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.accessibility.AccessibilityEvent;
+import android.widget.Checkable;
+import android.widget.ImageButton;
+
+import com.auth0.android.lock.R;
+
+/**
+ * A custom CheckBox implementation that doesn't have a TextView next to the ImageView, and changes the background drawable when focused.
+ */
+public class ImageCheckbox extends AppCompatImageButton implements Checkable {
+
+ private static final int[] DRAWABLE_STATE_CHECKED = new int[]{android.R.attr.state_checked};
+ private final Drawable focusedBackground;
+
+ private boolean mChecked;
+ private OnCheckedChangeListener checkedChangedListener;
+
+ public ImageCheckbox(Context context) {
+ this(context, null);
+ }
+
+ public ImageCheckbox(Context context, AttributeSet attrs) {
+ this(context, attrs, android.support.v7.appcompat.R.attr.imageButtonStyle);
+ }
+
+ public ImageCheckbox(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+
+ ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegateCompat() {
+ @Override
+ public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
+ super.onInitializeAccessibilityEvent(host, event);
+ event.setChecked(isChecked());
+ }
+
+ @Override
+ public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
+ super.onInitializeAccessibilityNodeInfo(host, info);
+ info.setCheckable(true);
+ info.setChecked(isChecked());
+ }
+ });
+ setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ toggle();
+ }
+ });
+ ViewUtils.setBackground(this, null);
+ focusedBackground = ContextCompat.getDrawable(getContext(), R.drawable.com_auth0_lock_link_background);
+ }
+
+
+ @Override
+ public void setChecked(boolean checked) {
+ if (mChecked != checked) {
+ mChecked = checked;
+ refreshDrawableState();
+ sendAccessibilityEvent(AccessibilityEventCompat.TYPE_WINDOW_CONTENT_CHANGED);
+ if (checkedChangedListener != null) {
+ checkedChangedListener.onCheckedChanged(this, checked);
+ }
+ }
+ }
+
+ @Override
+ public boolean isChecked() {
+ return mChecked;
+ }
+
+ @Override
+ public void toggle() {
+ setChecked(!mChecked);
+ }
+
+ @Override
+ public int[] onCreateDrawableState(int extraSpace) {
+ if (mChecked) {
+ return mergeDrawableStates(super.onCreateDrawableState(extraSpace + DRAWABLE_STATE_CHECKED.length), DRAWABLE_STATE_CHECKED);
+ } else {
+ return super.onCreateDrawableState(extraSpace);
+ }
+ }
+
+ @Override
+ protected void onFocusChanged(boolean gainFocus, int direction, @Nullable Rect previouslyFocusedRect) {
+ super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
+ ViewUtils.setBackground(this, gainFocus ? focusedBackground : null);
+ }
+
+ void setOnCheckedChangeListener(OnCheckedChangeListener listener) {
+ checkedChangedListener = listener;
+ }
+
+ interface OnCheckedChangeListener {
+ void onCheckedChanged(ImageButton view, boolean isChecked);
+ }
+
+}
+
diff --git a/lib/src/main/java/com/auth0/android/lock/views/LinkTextView.java b/lib/src/main/java/com/auth0/android/lock/views/LinkTextView.java
new file mode 100644
index 000000000..d80c7e914
--- /dev/null
+++ b/lib/src/main/java/com/auth0/android/lock/views/LinkTextView.java
@@ -0,0 +1,44 @@
+package com.auth0.android.lock.views;
+
+import android.content.Context;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+import android.support.annotation.Nullable;
+import android.support.v4.content.ContextCompat;
+import android.util.AttributeSet;
+
+import com.auth0.android.lock.R;
+
+/**
+ * A custom AppCompatTextView implementation that changes the background drawable when focused.
+ */
+public class LinkTextView extends android.support.v7.widget.AppCompatTextView {
+ private Drawable focusedBackground;
+
+ public LinkTextView(Context context) {
+ super(context);
+ init();
+ }
+
+ public LinkTextView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init();
+ }
+
+ public LinkTextView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init();
+ }
+
+ private void init() {
+ focusedBackground = ContextCompat.getDrawable(getContext(), R.drawable.com_auth0_lock_link_background);
+ setFocusableInTouchMode(false);
+ setFocusable(true);
+ }
+
+ @Override
+ protected void onFocusChanged(boolean gainFocus, int direction, @Nullable Rect previouslyFocusedRect) {
+ super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
+ ViewUtils.setBackground(this, gainFocus ? focusedBackground : null);
+ }
+}
diff --git a/lib/src/main/java/com/auth0/android/lock/views/ModeSelectionView.java b/lib/src/main/java/com/auth0/android/lock/views/ModeSelectionView.java
index e46b956c9..a4b4a4d6b 100644
--- a/lib/src/main/java/com/auth0/android/lock/views/ModeSelectionView.java
+++ b/lib/src/main/java/com/auth0/android/lock/views/ModeSelectionView.java
@@ -58,21 +58,21 @@ private void init() {
}
public void setSelectedMode(@AuthMode int mode) {
- tabLayout.getTabAt(mode).select();
+ TabLayout.Tab tab = tabLayout.getTabAt(mode);
+ tab.select();
+ toggleBoldText(tab, true);
}
@Override
public void onTabSelected(TabLayout.Tab tab) {
- final TextView text = (TextView) tab.getCustomView().findViewById(android.R.id.text1);
- setBoldFont(text, true);
+ toggleBoldText(tab, true);
//noinspection WrongConstant
callback.onModeSelected(getCurrentMode(tab));
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
- final TextView text = (TextView) tab.getCustomView().findViewById(android.R.id.text1);
- setBoldFont(text, false);
+ toggleBoldText(tab, false);
}
@Override
@@ -81,8 +81,9 @@ public void onTabReselected(TabLayout.Tab tab) {
callback.onModeSelected(getCurrentMode(tab));
}
- private void setBoldFont(TextView view, boolean bold) {
- view.setTypeface(bold ? view.getTypeface() : null, bold ? Typeface.BOLD : Typeface.NORMAL);
+ private void toggleBoldText(TabLayout.Tab tab, boolean bold) {
+ final TextView text = (TextView) tab.getCustomView().findViewById(android.R.id.text1);
+ text.setTypeface(bold ? text.getTypeface() : null, bold ? Typeface.BOLD : Typeface.NORMAL);
}
public interface ModeSelectedListener {
diff --git a/lib/src/main/java/com/auth0/android/lock/views/SocialButton.java b/lib/src/main/java/com/auth0/android/lock/views/SocialButton.java
index 616c03c4b..f5f36be34 100644
--- a/lib/src/main/java/com/auth0/android/lock/views/SocialButton.java
+++ b/lib/src/main/java/com/auth0/android/lock/views/SocialButton.java
@@ -2,8 +2,6 @@
import android.annotation.SuppressLint;
import android.content.Context;
-import android.graphics.Color;
-import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.StateListDrawable;
@@ -20,9 +18,11 @@
@SuppressLint("Instantiatable")
class SocialButton extends RelativeLayout {
+ private static final int NORMAL_STATE_ALPHA = 230;
+ private static final float FOCUSED_STATE_ALPHA = 0.64f;
+
private boolean smallSize;
private ImageView icon;
- private View touchArea;
private TextView title;
public SocialButton(Context context, AttributeSet attrs) {
@@ -40,20 +40,24 @@ private void init() {
inflate(getContext(), smallSize ? R.layout.com_auth0_lock_btn_social_small : R.layout.com_auth0_lock_btn_social_large, this);
icon = (ImageView) findViewById(R.id.com_auth0_lock_icon);
title = smallSize ? null : (TextView) findViewById(R.id.com_auth0_lock_text);
- touchArea = smallSize ? (View) icon.getParent() : findViewById(R.id.com_auth0_lock_touch_area);
- setClickable(false);
+ setFocusableInTouchMode(false);
+ setFocusable(true);
+ setOnFocusChangeListener(new OnFocusChangeListener() {
+ @Override
+ public void onFocusChange(View v, boolean hasFocus) {
+ v.setAlpha(hasFocus ? FOCUSED_STATE_ALPHA : 1f);
+ }
+ });
}
- private StateListDrawable getTouchFeedbackBackground(@ColorInt int color) {
- Drawable background = ViewUtils.getRoundedBackground(getResources(), color, ViewUtils.Corners.ALL);
+ private StateListDrawable getTouchFeedbackBackground(@ColorInt int pressedColor, @ViewUtils.Corners int corners) {
+ ShapeDrawable normalBackground = ViewUtils.getRoundedBackground(getResources(), pressedColor, corners);
+ normalBackground.getPaint().setAlpha(NORMAL_STATE_ALPHA);
+ Drawable pressedBackground = ViewUtils.getRoundedBackground(getResources(), pressedColor, corners);
StateListDrawable states = new StateListDrawable();
- states.addState(new int[]{android.R.attr.state_pressed},
- background);
- states.addState(new int[]{android.R.attr.state_focused},
- background);
- states.addState(new int[]{},
- new ColorDrawable(Color.TRANSPARENT));
+ states.addState(new int[]{android.R.attr.state_pressed}, pressedBackground);
+ states.addState(new int[]{}, normalBackground);
return states;
}
@@ -64,29 +68,21 @@ private StateListDrawable getTouchFeedbackBackground(@ColorInt int color) {
* @param mode the current button mode. Used to prefix the title with "Log In" or "Sign Up".
*/
public void setStyle(AuthConfig config, @AuthMode int mode) {
- final String name = config.getName(getContext());
final Drawable logo = config.getLogo(getContext());
final int backgroundColor = config.getBackgroundColor(getContext());
+ Drawable touchBackground = getTouchFeedbackBackground(backgroundColor, smallSize ? ViewUtils.Corners.ALL : ViewUtils.Corners.ONLY_RIGHT);
- ShapeDrawable leftBackground = ViewUtils.getRoundedBackground(getResources(), backgroundColor, smallSize ? ViewUtils.Corners.ALL : ViewUtils.Corners.ONLY_LEFT);
- if (!smallSize) {
+ icon.setImageDrawable(logo);
+ if (smallSize) {
+ ViewUtils.setBackground(icon, touchBackground);
+ } else {
+ final String name = config.getName(getContext());
+ ShapeDrawable leftBackground = ViewUtils.getRoundedBackground(getResources(), backgroundColor, ViewUtils.Corners.ONLY_LEFT);
final String prefixFormat = getResources().getString(mode == AuthMode.LOG_IN ? R.string.com_auth0_lock_social_log_in : R.string.com_auth0_lock_social_sign_up);
title.setText(String.format(prefixFormat, name));
- ShapeDrawable rightBackground = ViewUtils.getRoundedBackground(getResources(), backgroundColor, ViewUtils.Corners.ONLY_RIGHT);
- rightBackground.getPaint().setAlpha(230);
- ViewUtils.setBackground(title, rightBackground);
- } else {
- leftBackground.getPaint().setAlpha(230);
+ ViewUtils.setBackground(icon, leftBackground);
+ ViewUtils.setBackground(title, touchBackground);
}
-
- Drawable touchBackground = getTouchFeedbackBackground(backgroundColor);
- ViewUtils.setBackground(touchArea, touchBackground);
- ViewUtils.setBackground(icon, leftBackground);
- icon.setImageDrawable(logo);
}
- @Override
- public void setOnClickListener(OnClickListener l) {
- touchArea.setOnClickListener(l);
- }
}
diff --git a/lib/src/main/java/com/auth0/android/lock/views/ValidatedInputView.java b/lib/src/main/java/com/auth0/android/lock/views/ValidatedInputView.java
index 4e79797b2..8b5aa01a6 100644
--- a/lib/src/main/java/com/auth0/android/lock/views/ValidatedInputView.java
+++ b/lib/src/main/java/com/auth0/android/lock/views/ValidatedInputView.java
@@ -27,7 +27,6 @@
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Typeface;
-import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Handler;
@@ -36,7 +35,6 @@
import android.support.annotation.IntDef;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;
-import android.support.v7.widget.AppCompatCheckBox;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
@@ -44,9 +42,10 @@
import android.util.AttributeSet;
import android.util.Log;
import android.util.Patterns;
+import android.view.View;
import android.view.ViewGroup;
-import android.widget.CompoundButton;
import android.widget.EditText;
+import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -83,7 +82,7 @@ public class ValidatedInputView extends LinearLayout {
private TextView errorDescription;
private EditText input;
private ImageView icon;
- private AppCompatCheckBox showPasswordToggle;
+ private ImageCheckbox showPasswordToggle;
private IdentityListener identityListener;
private int inputIcon;
private boolean hasValidInput;
@@ -128,7 +127,7 @@ private void init(AttributeSet attrs) {
errorDescription = (TextView) findViewById(R.id.errorDescription);
icon = (ImageView) findViewById(R.id.com_auth0_lock_icon);
input = (EditText) findViewById(R.id.com_auth0_lock_input);
- showPasswordToggle = (AppCompatCheckBox) findViewById(R.id.com_auth0_lock_show_password_toggle);
+ showPasswordToggle = (ImageCheckbox) findViewById(R.id.com_auth0_lock_show_password_toggle);
if (attrs == null || isInEditMode()) {
return;
@@ -143,25 +142,34 @@ private void init(AttributeSet attrs) {
setupInputValidation();
updateBorder(true);
- showPasswordToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ setNextFocusRightId(R.id.com_auth0_lock_show_password_toggle);
+ showPasswordToggle.setOnCheckedChangeListener(new ImageCheckbox.OnCheckedChangeListener() {
@Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ public void onCheckedChanged(ImageButton view, boolean isChecked) {
if (dataType != PASSWORD) {
return;
}
String passwordValue = input.getText().toString();
if (isChecked) {
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
- buttonView.setButtonDrawable(R.drawable.com_auth0_lock_ic_password_visible);
+ view.setImageResource(R.drawable.com_auth0_lock_ic_password_visible);
} else {
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
input.setTransformationMethod(PasswordTransformationMethod.getInstance());
- buttonView.setButtonDrawable(R.drawable.com_auth0_lock_ic_password_hidden);
+ view.setImageResource(R.drawable.com_auth0_lock_ic_password_hidden);
}
setText(passwordValue);
input.setTypeface(Typeface.DEFAULT);
}
});
+ input.setOnFocusChangeListener(new OnFocusChangeListener() {
+ @Override
+ public void onFocusChange(View v, boolean hasFocus) {
+ if (!isInTouchMode()) {
+ updateBorder(true);
+ }
+ }
+ });
}
@Override
@@ -302,7 +310,9 @@ protected void updateBorder(boolean isValid) {
Drawable bg = parent.getBackground();
GradientDrawable gd = bg == null ? new GradientDrawable() : (GradientDrawable) bg;
gd.setCornerRadius(getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_widget_corner_radius));
- int strokeColor = isValid ? R.color.com_auth0_lock_input_field_border_normal : R.color.com_auth0_lock_input_field_border_error;
+
+ boolean isFocused = input.hasFocus() && !isInTouchMode();
+ int strokeColor = isValid ? (isFocused ? R.color.com_auth0_lock_input_field_border_focused : R.color.com_auth0_lock_input_field_border_normal) : R.color.com_auth0_lock_input_field_border_error;
gd.setStroke(getResources().getDimensionPixelSize(R.dimen.com_auth0_lock_input_field_stroke_width), ContextCompat.getColor(getContext(), strokeColor));
gd.setColor(ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_field_border_normal));
ViewUtils.setBackground(parent, gd);
@@ -316,9 +326,7 @@ private void createBackground() {
Drawable leftBackground = ViewUtils.getRoundedBackground(getResources(), ContextCompat.getColor(getContext(), R.color.com_auth0_lock_input_field_border_normal), ViewUtils.Corners.ONLY_LEFT);
Drawable rightBackground = ViewUtils.getRoundedBackground(getResources(), inputBackgroundColor, ViewUtils.Corners.ONLY_RIGHT);
ViewUtils.setBackground(icon, leftBackground);
- ViewUtils.setBackground(input, dataType == PASSWORD ? new ColorDrawable(inputBackgroundColor) : rightBackground);
- ViewUtils.setBackground(showPasswordToggle, rightBackground);
-
+ ViewUtils.setBackground((ViewGroup) input.getParent(), rightBackground);
}
@Override
diff --git a/lib/src/main/java/com/auth0/android/lock/views/ViewUtils.java b/lib/src/main/java/com/auth0/android/lock/views/ViewUtils.java
index 9994005d9..f2fc19466 100644
--- a/lib/src/main/java/com/auth0/android/lock/views/ViewUtils.java
+++ b/lib/src/main/java/com/auth0/android/lock/views/ViewUtils.java
@@ -26,6 +26,7 @@
import android.content.res.ColorStateList;
import android.content.res.Resources;
+import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
@@ -102,6 +103,22 @@ static ShapeDrawable getRoundedBackground(Resources resources, @ColorInt int col
return drawable;
}
+ /**
+ * Generates a rounded outline drawable with the given background color.
+ *
+ * @param resources the context's current resources.
+ * @param color the color to use as background.
+ * @return the rounded drawable.
+ */
+ static ShapeDrawable getRoundedOutlineBackground(Resources resources, @ColorInt int color) {
+ int r = resources.getDimensionPixelSize(R.dimen.com_auth0_lock_widget_corner_radius);
+ int t = resources.getDimensionPixelSize(R.dimen.com_auth0_lock_input_field_stroke_width);
+ RoundRectShape rr = new RoundRectShape(new float[]{r, r, r, r, r, r, r, r}, new RectF(t, t, t, t), new float[]{r, r, r, r, r, r, r, r});
+ ShapeDrawable drawable = new ShapeDrawable(rr);
+ drawable.getPaint().setColor(color);
+ return drawable;
+ }
+
/**
* Sets a background drawable to a view, safely using the latest available sdk method.
*
diff --git a/lib/src/main/res/color/com_auth0_lock_text.xml b/lib/src/main/res/color/com_auth0_lock_text.xml
index 81b29ea38..ca35dd44d 100644
--- a/lib/src/main/res/color/com_auth0_lock_text.xml
+++ b/lib/src/main/res/color/com_auth0_lock_text.xml
@@ -1,5 +1,4 @@
-
-
-
-
+
+
\ No newline at end of file
diff --git a/lib/src/main/res/drawable/com_auth0_lock_link_background.xml b/lib/src/main/res/drawable/com_auth0_lock_link_background.xml
new file mode 100644
index 000000000..1bc36f572
--- /dev/null
+++ b/lib/src/main/res/drawable/com_auth0_lock_link_background.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/src/main/res/drawable/com_auth0_lock_tab.xml b/lib/src/main/res/drawable/com_auth0_lock_tab.xml
new file mode 100644
index 000000000..500b388ae
--- /dev/null
+++ b/lib/src/main/res/drawable/com_auth0_lock_tab.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/src/main/res/drawable/com_auth0_lock_terms.xml b/lib/src/main/res/drawable/com_auth0_lock_terms.xml
new file mode 100644
index 000000000..6bf80c194
--- /dev/null
+++ b/lib/src/main/res/drawable/com_auth0_lock_terms.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/src/main/res/layout/com_auth0_lock_activity_lock_passwordless.xml b/lib/src/main/res/layout/com_auth0_lock_activity_lock_passwordless.xml
index bea30ebdc..275bffed2 100644
--- a/lib/src/main/res/layout/com_auth0_lock_activity_lock_passwordless.xml
+++ b/lib/src/main/res/layout/com_auth0_lock_activity_lock_passwordless.xml
@@ -47,16 +47,15 @@
android:id="@+id/com_auth0_lock_link_sent_cover"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
+ android:layout_alignParentTop="true"
android:background="@android:color/white"
- android:clickable="true"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone"
tools:background="@null"
- tools:visibility="visible"
- android:layout_alignParentTop="true"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true">
+ tools:visibility="visible">
-
-
diff --git a/lib/src/main/res/layout/com_auth0_lock_btn_social_large.xml b/lib/src/main/res/layout/com_auth0_lock_btn_social_large.xml
index 574e119f7..148b406f4 100644
--- a/lib/src/main/res/layout/com_auth0_lock_btn_social_large.xml
+++ b/lib/src/main/res/layout/com_auth0_lock_btn_social_large.xml
@@ -24,12 +24,13 @@
diff --git a/lib/src/main/res/layout/com_auth0_lock_btn_social_small.xml b/lib/src/main/res/layout/com_auth0_lock_btn_social_small.xml
index 0ee56609d..90ad7bd28 100644
--- a/lib/src/main/res/layout/com_auth0_lock_btn_social_small.xml
+++ b/lib/src/main/res/layout/com_auth0_lock_btn_social_small.xml
@@ -24,6 +24,7 @@
-
-
+ android:layout_marginBottom="@dimen/com_auth0_lock_widget_vertical_margin_field"
+ android:nextFocusDown="@+id/com_auth0_lock_input_passwordless" />
\ No newline at end of file
diff --git a/lib/src/main/res/layout/com_auth0_lock_tab_layout.xml b/lib/src/main/res/layout/com_auth0_lock_tab_layout.xml
index a9004acfe..8b3a280ec 100644
--- a/lib/src/main/res/layout/com_auth0_lock_tab_layout.xml
+++ b/lib/src/main/res/layout/com_auth0_lock_tab_layout.xml
@@ -7,6 +7,7 @@
android:id="@+id/com_auth0_lock_tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ app:tabBackground="@drawable/com_auth0_lock_tab"
app:tabMode="fixed"
app:tabIndicatorColor="@color/com_auth0_lock_text"
app:tabIndicatorHeight="@dimen/com_auth0_lock_widget_tab_strip_height"
diff --git a/lib/src/main/res/layout/com_auth0_lock_terms_layout.xml b/lib/src/main/res/layout/com_auth0_lock_terms_layout.xml
index 54a57561d..25b606bd8 100644
--- a/lib/src/main/res/layout/com_auth0_lock_terms_layout.xml
+++ b/lib/src/main/res/layout/com_auth0_lock_terms_layout.xml
@@ -25,11 +25,13 @@
+ android:paddingTop="@dimen/com_auth0_lock_bottom_banner_vertical_margin">
-
+ android:layout_marginEnd="9dp"
+ android:layout_marginRight="9dp"
+ android:checked="true" />
80dp
138dp
- 2dp
+ 3dp
15dp
2dp
- 54dp
- 50dp
+ 54dp
35dp
40dp
7dp
diff --git a/lib/src/main/res/values-v16/styles.xml b/lib/src/main/res/values-v16/styles.xml
index 6dc3726b5..026c194f3 100644
--- a/lib/src/main/res/values-v16/styles.xml
+++ b/lib/src/main/res/values-v16/styles.xml
@@ -29,13 +29,14 @@
- normal
- wrap_content
- wrap_content
- - @color/com_auth0_lock_normal_text
+ - @color/com_auth0_lock_text
@@ -159,6 +159,7 @@