Skip to content

Commit

Permalink
Merge pull request #582 from kiva/bugfix-581
Browse files Browse the repository at this point in the history
Bugfix #581 | Fix social login buttons with white backgrounds
  • Loading branch information
lbalmaceda authored Jul 3, 2020
2 parents 5d81b94 + 3b0abe3 commit c9654b2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public void onFocusChange(View v, boolean hasFocus) {
}

private StateListDrawable getTouchFeedbackBackground(@ColorInt int pressedColor, @ViewUtils.Corners int corners) {
final ShapeDrawable normalBackground;
final Drawable normalBackground;
final ShapeDrawable pressedBackground;

boolean shouldDrawOutline = pressedColor == Color.WHITE;
if (shouldDrawOutline) {
int outlineColor = getResources().getColor(R.color.com_auth0_lock_social_light_background_focused);
normalBackground = ViewUtils.getRoundedOutlineBackground(getResources(), outlineColor);
normalBackground = ViewUtils.getOpaqueRoundedOutlineBackground(getResources(), pressedColor, outlineColor);
pressedBackground = ViewUtils.getRoundedBackground(this, outlineColor, corners);
} else {
normalBackground = ViewUtils.getRoundedBackground(this, pressedColor, corners);
Expand Down
27 changes: 25 additions & 2 deletions lib/src/main/java/com/auth0/android/lock/views/ViewUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import android.content.res.Resources;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.os.Build;
Expand Down Expand Up @@ -113,10 +114,10 @@ static ShapeDrawable getRoundedBackground(@NonNull View view, @ColorInt int colo
}

/**
* Generates a rounded outline drawable with the given background color.
* Generates a rounded outline drawable with a transparent background.
*
* @param resources the context's current resources.
* @param color the color to use as background.
* @param color the color to use for the outline.
* @return the rounded drawable.
*/
static ShapeDrawable getRoundedOutlineBackground(Resources resources, @ColorInt int color) {
Expand All @@ -128,6 +129,28 @@ static ShapeDrawable getRoundedOutlineBackground(Resources resources, @ColorInt
return drawable;
}

/**
* Generates a rounded outline drawable with the given background color.
*
* @param resources the context's current resources.
* @param backgroundColor the color to use for the background.
* @param outlineColor the color to use for the outline
* @return the opaque rounded drawable.
*/
static Drawable getOpaqueRoundedOutlineBackground(
Resources resources,
@ColorInt int backgroundColor,
@ColorInt int outlineColor
) {
int cornerRadius = resources.getDimensionPixelSize(R.dimen.com_auth0_lock_widget_corner_radius);
int stroke = resources.getDimensionPixelSize(R.dimen.com_auth0_lock_input_field_stroke_width);
GradientDrawable drawable = new GradientDrawable();
drawable.setCornerRadius(cornerRadius);
drawable.setColor(backgroundColor);
drawable.setStroke(stroke, outlineColor);
return drawable;
}

/**
* Sets a background drawable to a view, safely using the latest available sdk method.
*
Expand Down

0 comments on commit c9654b2

Please sign in to comment.